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