mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
init obj and run __init__ in OUT instruct
This commit is contained in:
parent
a1d1d12d32
commit
ca00fd1e96
@ -29,7 +29,6 @@
|
||||
#include "PikaObj.h"
|
||||
#include "BaseObj.h"
|
||||
#include "PikaPlatform.h"
|
||||
#include "PikaVM.h"
|
||||
#include "dataArgs.h"
|
||||
#include "dataMemory.h"
|
||||
#include "dataString.h"
|
||||
@ -357,7 +356,6 @@ static PikaObj* __initObj(PikaObj* obj, char* name) {
|
||||
Args* buffs = New_args(NULL);
|
||||
PikaObj* thisClass;
|
||||
PikaObj* newObj;
|
||||
Arg* methodArg;
|
||||
if (NULL == newObjFun) {
|
||||
/* no such object */
|
||||
res = NULL;
|
||||
@ -368,12 +366,6 @@ static PikaObj* __initObj(PikaObj* obj, char* name) {
|
||||
|
||||
args_setPtrWithType(obj->list, name, TYPE_OBJECT, newObj);
|
||||
res = obj_getPtr(obj, name);
|
||||
/* run __init__() when init obj */
|
||||
methodArg = obj_getMethod(res, "__init__");
|
||||
if (NULL != methodArg) {
|
||||
arg_deinit(methodArg);
|
||||
obj_run(res, "__init__()");
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
args_deinit(buffs);
|
||||
|
11
src/PikaVM.c
11
src/PikaVM.c
@ -219,7 +219,16 @@ static Arg* VM_instruction_handler_OUT(PikaObj* self,
|
||||
obj_setArg(vmState->locals, data, outArg);
|
||||
if (TYPE_MATE_OBJECT == arg_getType(outArg)) {
|
||||
/* init all object */
|
||||
obj_getObj(self, data, 0);
|
||||
PikaObj* new_obj = obj_getObj(self, data, 0);
|
||||
/* run __init__() when init obj */
|
||||
Arg* methodArg = NULL;
|
||||
methodArg = obj_getMethod(new_obj, "__init__");
|
||||
if (NULL != methodArg) {
|
||||
arg_deinit(methodArg);
|
||||
pikaVM_runAsm(new_obj,
|
||||
"B0\n"
|
||||
"0 RUN __init__\n");
|
||||
}
|
||||
}
|
||||
arg_deinit(outArg);
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user