mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +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 "PikaObj.h"
|
||||||
#include "BaseObj.h"
|
#include "BaseObj.h"
|
||||||
#include "PikaPlatform.h"
|
#include "PikaPlatform.h"
|
||||||
#include "PikaVM.h"
|
|
||||||
#include "dataArgs.h"
|
#include "dataArgs.h"
|
||||||
#include "dataMemory.h"
|
#include "dataMemory.h"
|
||||||
#include "dataString.h"
|
#include "dataString.h"
|
||||||
@ -357,7 +356,6 @@ static PikaObj* __initObj(PikaObj* obj, char* name) {
|
|||||||
Args* buffs = New_args(NULL);
|
Args* buffs = New_args(NULL);
|
||||||
PikaObj* thisClass;
|
PikaObj* thisClass;
|
||||||
PikaObj* newObj;
|
PikaObj* newObj;
|
||||||
Arg* methodArg;
|
|
||||||
if (NULL == newObjFun) {
|
if (NULL == newObjFun) {
|
||||||
/* no such object */
|
/* no such object */
|
||||||
res = NULL;
|
res = NULL;
|
||||||
@ -368,12 +366,6 @@ static PikaObj* __initObj(PikaObj* obj, char* name) {
|
|||||||
|
|
||||||
args_setPtrWithType(obj->list, name, TYPE_OBJECT, newObj);
|
args_setPtrWithType(obj->list, name, TYPE_OBJECT, newObj);
|
||||||
res = obj_getPtr(obj, name);
|
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;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
args_deinit(buffs);
|
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);
|
obj_setArg(vmState->locals, data, outArg);
|
||||||
if (TYPE_MATE_OBJECT == arg_getType(outArg)) {
|
if (TYPE_MATE_OBJECT == arg_getType(outArg)) {
|
||||||
/* init all object */
|
/* 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);
|
arg_deinit(outArg);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user