fixing workspace when find arg form obj

fixed
This commit is contained in:
pikastech 2023-05-06 18:48:37 +08:00
parent 42dc3209d0
commit 0c5cd8340d
4 changed files with 42 additions and 19 deletions

View File

@ -19,7 +19,8 @@
// "--gtest_filter=thread.test1"
// "--gtest_filter=eventloop.test1"
// "--gtest_filter=parser.tuple_single"
"--gtest_filter=parser.split_slice"
// "--gtest_filter=parser.split_slice"
"--gtest_filter=vm.var_global_run"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",

View File

@ -999,7 +999,8 @@ static Arg* VM_instruction_handler_REF(PikaObj* self,
aRes = _obj_getProp(oHost, arg_name);
}
/* find res in globlas */
/* find res in globals */
if (arg_path == arg_name) {
if (NULL == aRes) {
aRes = args_getArg(vm->globals->list, arg_name);
}
@ -1008,6 +1009,7 @@ static Arg* VM_instruction_handler_REF(PikaObj* self,
if (NULL == aRes) {
aRes = _obj_getProp(vm->globals, arg_name);
}
}
/* proxy */
if (NULL == aRes) {
@ -1786,6 +1788,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
VMParameters* oSublocals = NULL;
VMParameters* oSublocalsInit = NULL;
char* sRunPath = data;
char* sArgName = NULL;
PikaObj* oMethodHost = NULL;
PikaObj* oThis = NULL;
Arg* aMethod = NULL;
@ -1799,6 +1802,10 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
.try_result = TRY_RESULT_NONE};
pika_assert(NULL != vm->run_state);
if (NULL != sRunPath) {
sArgName = strPointToLastToken(sRunPath, '.');
}
/* inhert */
if (vm->pc - 2 * (int)instructUnit_getSize() >= 0) {
if (CLS == VMstate_getInstructWithOffset(
@ -1823,6 +1830,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
/* support for super() */
if (strEqu(sRunPath, "super")) {
sRunPath = _find_super_class_name(vm);
sArgName = sRunPath;
vm->in_super = PIKA_TRUE;
vm->super_invoke_deepth = VMState_getInvokeDeepthNow(vm);
bSkipInit = PIKA_TRUE;
@ -1911,18 +1919,20 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
aMethod = obj_getMethodArg_noalloc(oMethodHost, sRunPath, &arg_reg1);
}
if (sArgName == sRunPath) {
/* get method in locals */
if (NULL == aMethod) {
aMethod = obj_getMethodArg_noalloc(vm->locals, sRunPath, &arg_reg1);
}
/* get method in global */
if (NULL == aMethod) {
aMethod = obj_getMethodArg_noalloc(vm->globals, sRunPath, &arg_reg1);
aMethod =
obj_getMethodArg_noalloc(vm->globals, sRunPath, &arg_reg1);
if (aMethod != NULL) {
oThis = vm->globals;
}
}
}
/* assert method exist */
if (NULL == aMethod || ARG_TYPE_NONE == arg_getType(aMethod)) {

View File

@ -2850,6 +2850,18 @@ TEST_RUN_LINES_EXCEPT_OUTPUT(vm, single_tuple_str, "('test',)", "('test',)\r\n")
TEST_RUN_SINGLE_FILE_PASS(vm, is_not, "test/python/builtin/is_not.py")
TEST_RUN_LINES(vm,
var_global,
"import PikaStdLib\n"
"mem = PikaStdLib.MemChecker()\n"
"mem.clear\n")
TEST_RUN_LINES(vm,
var_global_run,
"import PikaStdLib\n"
"mem = PikaStdLib.MemChecker()\n"
"mem.clear()\n")
#endif
TEST_END

View File

@ -59,7 +59,7 @@ extern char log_buff[LOG_BUFF_MAX][LOG_SIZE];
#define TEST_RUN_LINES(_test_suite_, _test_name_, _lines_) \
TEST(_test_suite_, _test_name_) { \
PikaObj *self = newRootObj("root", New_PikaStdLib_SysObj); \
PikaObj *self = newRootObj("root", New_PikaMain); \
obj_run(self, (_lines_)); /* collect */ /* assert */ \
obj_deinit(self); \
EXPECT_EQ(pikaMemNow(), 0); \