find local and global list by order in REF

This commit is contained in:
pikasTech 2021-10-31 15:52:33 +08:00
parent 76dee1039e
commit 3c825972f0
2 changed files with 11 additions and 6 deletions

View File

@ -137,7 +137,12 @@ Arg* pikaVM_runInstruct(PikaObj* self,
if (strEqu(data, (char*)"False")) { if (strEqu(data, (char*)"False")) {
return arg_setInt(NULL, "", 0); return arg_setInt(NULL, "", 0);
} }
/* find in local list first */
Arg* arg = arg_copy(obj_getArg(locals, data)); Arg* arg = arg_copy(obj_getArg(locals, data));
if (NULL == arg) {
/* find in global list second */
arg = arg_copy(obj_getArg(globals, data));
}
return arg; return arg;
} }
if (instruct == JMP) { if (instruct == JMP) {
@ -418,14 +423,14 @@ Arg* pikaVM_runInstruct(PikaObj* self,
return NULL; return NULL;
} }
int32_t __clearInvokeQueues(Parameters* globals) { int32_t __clearInvokeQueues(Parameters* locals) {
for (char deepthChar = '0'; deepthChar < '9'; deepthChar++) { for (char deepthChar = '0'; deepthChar < '9'; deepthChar++) {
char deepth[2] = {0}; char deepth[2] = {0};
deepth[0] = deepthChar; deepth[0] = deepthChar;
Queue* queue = (Queue*)args_getPtr(globals->attributeList, deepth); Queue* queue = (Queue*)args_getPtr(locals->attributeList, deepth);
if (NULL != queue) { if (NULL != queue) {
args_deinit(queue); args_deinit(queue);
args_removeArg(globals->attributeList, deepth); args_removeArg(locals->attributeList, deepth);
} }
} }
return 0; return 0;

View File

@ -5,18 +5,18 @@
Parameters* pikaVM_run(PikaObj* self, char* pyLine); Parameters* pikaVM_run(PikaObj* self, char* pyLine);
Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm); Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm);
Parameters* pikaVM_runAsmWithPars(PikaObj* self, Parameters* pikaVM_runAsmWithPars(PikaObj* self,
Parameters* globals,
Parameters* locals, Parameters* locals,
Parameters* globals,
char* pikaAsm); char* pikaAsm);
int32_t __clearInvokeQueues(Parameters* globals); int32_t __clearInvokeQueues(Parameters* locals);
char* useFlashAsBuff(char* pikaAsm, Args* buffs); char* useFlashAsBuff(char* pikaAsm, Args* buffs);
int32_t gotoNextLine(char* code); int32_t gotoNextLine(char* code);
int32_t gotoLastLine(char* start, char* code); int32_t gotoLastLine(char* start, char* code);
int getThisBlockDeepth(char* start, char* code, int* offset); int getThisBlockDeepth(char* start, char* code, int* offset);
int32_t pikaVM_runAsmLine(PikaObj* self, int32_t pikaVM_runAsmLine(PikaObj* self,
Parameters* globals,
Parameters* locals, Parameters* locals,
Parameters* globals,
char* pikaAsm, char* pikaAsm,
int32_t lineAddr); int32_t lineAddr);