mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 03:50:16 +00:00
...
This commit is contained in:
parent
97a009dcc9
commit
5e93c0d6e8
@ -236,6 +236,12 @@ __NEXT_STEP:;
|
||||
}
|
||||
DISPATCH();
|
||||
/*****************************************/
|
||||
TARGET(BUILD_LONG) {
|
||||
const static StrName m_long("long");
|
||||
_0 = builtins->attr().try_get(m_long);
|
||||
if(_0 == nullptr) AttributeError(builtins, m_long);
|
||||
TOP() = call(_0, TOP());
|
||||
} DISPATCH();
|
||||
TARGET(BUILD_TUPLE)
|
||||
_0 = VAR(STACK_VIEW(byte.arg).to_tuple());
|
||||
STACK_SHRINK(byte.arg);
|
||||
|
@ -269,10 +269,8 @@ struct LongExpr: Expr{
|
||||
|
||||
void emit(CodeEmitContext* ctx) override {
|
||||
VM* vm = ctx->vm;
|
||||
PyObject* long_type = vm->builtins->attr().try_get("long");
|
||||
PK_ASSERT(long_type != nullptr);
|
||||
PyObject* obj = vm->call(long_type, VAR(s));
|
||||
ctx->emit(OP_LOAD_CONST, ctx->add_const(obj), line);
|
||||
ctx->emit(OP_LOAD_CONST, ctx->add_const(VAR(s)), line);
|
||||
ctx->emit(OP_BUILD_LONG, BC_NOARG, line);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -38,6 +38,7 @@ OPCODE(DELETE_GLOBAL)
|
||||
OPCODE(DELETE_ATTR)
|
||||
OPCODE(DELETE_SUBSCR)
|
||||
/**************************/
|
||||
OPCODE(BUILD_LONG)
|
||||
OPCODE(BUILD_TUPLE)
|
||||
OPCODE(BUILD_LIST)
|
||||
OPCODE(BUILD_DICT)
|
||||
|
8
src/vm.h
8
src/vm.h
@ -1565,10 +1565,10 @@ inline void Dict::_probe(PyObject *key, bool &ok, int &i) const{
|
||||
}
|
||||
|
||||
inline void CodeObjectSerializer::write_object(VM *vm, PyObject *obj){
|
||||
buffer += 'o';
|
||||
PyObject* s = vm->py_repr(obj);
|
||||
buffer += CAST(Str&, s).str();
|
||||
buffer += END;
|
||||
if(is_int(obj)) write_int(_CAST(i64, obj));
|
||||
if(is_float(obj)) write_float(_CAST(f64, obj));
|
||||
if(is_type(obj, vm->tp_str)) write_str(_CAST(Str&, obj));
|
||||
FATAL_ERROR();
|
||||
}
|
||||
|
||||
} // namespace pkpy
|
Loading…
x
Reference in New Issue
Block a user