diff --git a/port/linux/test/VM-test.cpp b/port/linux/test/VM-test.cpp index 64caebbb0..004960c11 100644 --- a/port/linux/test/VM-test.cpp +++ b/port/linux/test/VM-test.cpp @@ -92,8 +92,9 @@ TEST(VM, ref_a_b) { Parameters* globals = pikaVM_runAsm( self, pikaParseLineToAsm(buffs, (char*)"a = 'xy '", NULL)); - globals = pikaVM_runAsmWithArgs( - self, globals, pikaParseLineToAsm(buffs, (char*)"b = a", NULL)); + globals = + pikaVM_runAsmWithArgs(self, globals, globals, + pikaParseLineToAsm(buffs, (char*)"b = a", NULL)); args_deinit(buffs); ASSERT_STREQ(args_getStr(globals->attributeList, (char*)"b"), (char*)"xy "); @@ -124,7 +125,7 @@ TEST(VM, Run_add_multy) { Parameters* globals = pikaVM_runAsm(self, pikaParseLineToAsm(buffs, (char*)"b = 2", NULL)); globals = pikaVM_runAsmWithArgs( - self, globals, + self, globals, globals, pikaParseLineToAsm(buffs, (char*)"a = plusInt(1,b)", NULL)); args_deinit(buffs); diff --git a/src/PikaVM.c b/src/PikaVM.c index e1a1c4b00..0cd3d5e0d 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -101,14 +101,14 @@ int fast_atoi(char* src) { } Arg* pikaVM_runInstruct(PikaObj* self, - Parameters* globals, - Parameters* locals, - enum Instruct instruct, - char* data, - Queue* invokeQuene0, - Queue* invokeQuene1, - int32_t* jmp, - char* programConter) { + Parameters* globals, + Parameters* locals, + enum Instruct instruct, + char* data, + Queue* invokeQuene0, + Queue* invokeQuene1, + int32_t* jmp, + char* programConter) { if (instruct == NUM) { Arg* numArg = New_arg(NULL); if (strIsContain(data, '.')) { @@ -383,8 +383,8 @@ Arg* pikaVM_runInstruct(PikaObj* self, char* methodCode = (char*)methodPtr; if (methodCode[0] == 'B' && methodCode[2] == '\n') { /* VM method */ - subLocals = - pikaVM_runAsmWithArgs(methodHostObj, subLocals, methodCode); + subLocals = pikaVM_runAsmWithArgs(methodHostObj, subLocals, globals, + methodCode); /* get method return */ returnArg = arg_copy( args_getArg(subLocals->attributeList, (char*)"return")); @@ -548,8 +548,8 @@ int32_t pikaVM_runAsmLine(PikaObj* self, } Arg* resArg = - pikaVM_runInstruct(self, globals, globals, instruct, data, - invokeQuene0, invokeQuene1, &jmp, programCounter); + pikaVM_runInstruct(self, globals, globals, instruct, data, invokeQuene0, + invokeQuene1, &jmp, programCounter); if (NULL != resArg) { queue_pushArg(invokeQuene0, resArg); } @@ -584,6 +584,7 @@ char* useFlashAsBuff(char* pikaAsm, Args* buffs) { Parameters* pikaVM_runAsmWithArgs(PikaObj* self, Parameters* globals, + Parameters* locals, char* pikaAsm) { int lineAddr = 0; int size = strGetSize(pikaAsm); @@ -614,7 +615,7 @@ Parameters* pikaVM_runAsmWithArgs(PikaObj* self, Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm) { Parameters* globals = New_TinyObj(NULL); - globals = pikaVM_runAsmWithArgs(self, globals, pikaAsm); + globals = pikaVM_runAsmWithArgs(self, globals, globals, pikaAsm); return globals; } diff --git a/src/PikaVM.h b/src/PikaVM.h index 1696b0a30..ef0668974 100644 --- a/src/PikaVM.h +++ b/src/PikaVM.h @@ -2,10 +2,12 @@ #define __PIKA__VM__H #include "PikaObj.h" - Parameters* pikaVM_run(PikaObj* self, char* pyLine); Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm); -Parameters* pikaVM_runAsmWithArgs(PikaObj* self, Parameters* globals, char* pikaAsm); +Parameters* pikaVM_runAsmWithArgs(PikaObj* self, + Parameters* globals, + Parameters* locals, + char* pikaAsm); int32_t __clearInvokeQueues(Parameters* globals); char* useFlashAsBuff(char* pikaAsm, Args* buffs);