mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
...
This commit is contained in:
parent
d8f2808462
commit
a96173fd6a
@ -909,6 +909,13 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
base = py_totype(TOP());
|
base = py_totype(TOP());
|
||||||
}
|
}
|
||||||
POP();
|
POP();
|
||||||
|
|
||||||
|
py_TypeInfo* base_ti = c11__at(py_TypeInfo, &self->types, base);
|
||||||
|
if(base_ti->is_sealed){
|
||||||
|
TypeError("type '%t' is not an acceptable base type", base);
|
||||||
|
goto __ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
py_Type type =
|
py_Type type =
|
||||||
pk_newtype(py_name2str(name), base, frame->module, NULL, true, false);
|
pk_newtype(py_name2str(name), base, frame->module, NULL, true, false);
|
||||||
PUSH(py_tpobject(type));
|
PUSH(py_tpobject(type));
|
||||||
|
@ -313,8 +313,12 @@ py_Type pk_newtype(const char* name,
|
|||||||
c11_vector* types = &pk_current_vm->types;
|
c11_vector* types = &pk_current_vm->types;
|
||||||
py_Type index = types->count;
|
py_Type index = types->count;
|
||||||
py_TypeInfo* ti = c11_vector__emplace(types);
|
py_TypeInfo* ti = c11_vector__emplace(types);
|
||||||
|
py_TypeInfo* base_ti = base ? c11__at(py_TypeInfo, types, base) : NULL;
|
||||||
|
if(base_ti && base_ti->is_sealed){
|
||||||
|
c11__abort("type '%s' is not an acceptable base type", py_name2str(base_ti->name));
|
||||||
|
}
|
||||||
py_TypeInfo__ctor(ti, py_name(name), index, base, module ? *module : *py_NIL);
|
py_TypeInfo__ctor(ti, py_name(name), index, base, module ? *module : *py_NIL);
|
||||||
if(!dtor && base) { dtor = c11__at(py_TypeInfo, types, base)->dtor; }
|
if(!dtor && base) dtor = base_ti->dtor;
|
||||||
ti->dtor = dtor;
|
ti->dtor = dtor;
|
||||||
ti->is_python = is_python;
|
ti->is_python = is_python;
|
||||||
ti->is_sealed = is_sealed;
|
ti->is_sealed = is_sealed;
|
||||||
|
@ -106,7 +106,7 @@ py_Type pk_BaseException__register() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
py_Type pk_Exception__register() {
|
py_Type pk_Exception__register() {
|
||||||
py_Type type = pk_newtype("Exception", tp_BaseException, NULL, NULL, false, true);
|
py_Type type = pk_newtype("Exception", tp_BaseException, NULL, NULL, false, false);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user