mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
up
This commit is contained in:
parent
f0069e109a
commit
14433b1210
41
src/ceval.h
41
src/ceval.h
@ -319,6 +319,7 @@ __NEXT_STEP:;
|
|||||||
if(item == nullptr) ValueError("not enough values to unpack");
|
if(item == nullptr) ValueError("not enough values to unpack");
|
||||||
frame->push(item);
|
frame->push(item);
|
||||||
}
|
}
|
||||||
|
// handle extra items
|
||||||
if(byte.op == OP_UNPACK_EX){
|
if(byte.op == OP_UNPACK_EX){
|
||||||
List extras;
|
List extras;
|
||||||
while(true){
|
while(true){
|
||||||
@ -332,25 +333,29 @@ __NEXT_STEP:;
|
|||||||
}
|
}
|
||||||
}; DISPATCH();
|
}; DISPATCH();
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
case OP_BEGIN_CLASS: {
|
||||||
|
StrName name = frame->co->names[byte.arg];
|
||||||
|
PyObject* super_cls = frame->popx();
|
||||||
|
if(super_cls == None) super_cls = _t(tp_object);
|
||||||
|
check_type(super_cls, tp_type);
|
||||||
|
PyObject* cls = new_type_object(frame->_module, name, OBJ_GET(Type, super_cls));
|
||||||
|
frame->push(cls);
|
||||||
|
} DISPATCH();
|
||||||
|
case OP_END_CLASS: {
|
||||||
|
PyObject* cls = frame->popx();
|
||||||
|
cls->attr()._try_perfect_rehash();
|
||||||
|
}; DISPATCH();
|
||||||
|
case OP_STORE_CLASS_ATTR: {
|
||||||
|
StrName name = frame->co->names[byte.arg];
|
||||||
|
PyObject* obj = frame->popx();
|
||||||
|
PyObject* cls = frame->top();
|
||||||
|
cls->attr().set(name, obj);
|
||||||
|
} DISPATCH();
|
||||||
|
/*****************************************/
|
||||||
|
/*****************************************/
|
||||||
|
/*****************************************/
|
||||||
// case OP_SETUP_DECORATOR: DISPATCH();
|
// case OP_SETUP_DECORATOR: DISPATCH();
|
||||||
// case OP_BEGIN_CLASS: {
|
|
||||||
// StrName name = frame->co->names[byte.arg];
|
|
||||||
// PyObject* clsBase = frame->popx();
|
|
||||||
// if(clsBase == None) clsBase = _t(tp_object);
|
|
||||||
// check_type(clsBase, tp_type);
|
|
||||||
// PyObject* cls = new_type_object(frame->_module, name, OBJ_GET(Type, clsBase));
|
|
||||||
// frame->push(cls);
|
|
||||||
// } DISPATCH();
|
|
||||||
// case OP_END_CLASS: {
|
|
||||||
// PyObject* cls = frame->popx();
|
|
||||||
// cls->attr()._try_perfect_rehash();
|
|
||||||
// }; DISPATCH();
|
|
||||||
// case OP_STORE_CLASS_ATTR: {
|
|
||||||
// StrName name = frame->co->names[byte.arg];
|
|
||||||
// PyObject* obj = frame->popx();
|
|
||||||
// PyObject* cls = frame->top();
|
|
||||||
// cls->attr().set(name, obj);
|
|
||||||
// } DISPATCH();
|
|
||||||
// case OP_ASSERT: {
|
// case OP_ASSERT: {
|
||||||
// PyObject* _msg = frame->pop_value(this);
|
// PyObject* _msg = frame->pop_value(this);
|
||||||
// Str msg = CAST(Str, asStr(_msg));
|
// Str msg = CAST(Str, asStr(_msg));
|
||||||
|
@ -835,7 +835,8 @@ class Compiler {
|
|||||||
ctx()->emit(OP_STORE_ATTR, index, prev().line);
|
ctx()->emit(OP_STORE_ATTR, index, prev().line);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ctx()->emit(OP_STORE_CLASS_ATTR, ctx()->add_name(decl->name), BC_KEEPLINE);
|
int index = ctx()->add_name(decl->name);
|
||||||
|
ctx()->emit(OP_STORE_CLASS_ATTR, index, prev().line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,6 @@ OPCODE(YIELD_VALUE)
|
|||||||
|
|
||||||
OPCODE(SETUP_DECORATOR)
|
OPCODE(SETUP_DECORATOR)
|
||||||
|
|
||||||
OPCODE(BEGIN_CLASS)
|
|
||||||
OPCODE(END_CLASS)
|
|
||||||
OPCODE(STORE_CLASS_ATTR)
|
|
||||||
|
|
||||||
/**************************/
|
/**************************/
|
||||||
OPCODE(NO_OP)
|
OPCODE(NO_OP)
|
||||||
/**************************/
|
/**************************/
|
||||||
@ -96,4 +92,9 @@ OPCODE(IMPORT_STAR)
|
|||||||
OPCODE(UNPACK_SEQUENCE)
|
OPCODE(UNPACK_SEQUENCE)
|
||||||
OPCODE(UNPACK_EX)
|
OPCODE(UNPACK_EX)
|
||||||
/**************************/
|
/**************************/
|
||||||
|
// TODO: examine this
|
||||||
|
OPCODE(BEGIN_CLASS)
|
||||||
|
OPCODE(END_CLASS)
|
||||||
|
OPCODE(STORE_CLASS_ATTR)
|
||||||
|
/**************************/
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user