mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
fixing workspace when find arg form obj
fixed
This commit is contained in:
parent
42dc3209d0
commit
0c5cd8340d
3
port/linux/.vscode/launch.json
vendored
3
port/linux/.vscode/launch.json
vendored
@ -19,7 +19,8 @@
|
|||||||
// "--gtest_filter=thread.test1"
|
// "--gtest_filter=thread.test1"
|
||||||
// "--gtest_filter=eventloop.test1"
|
// "--gtest_filter=eventloop.test1"
|
||||||
// "--gtest_filter=parser.tuple_single"
|
// "--gtest_filter=parser.tuple_single"
|
||||||
"--gtest_filter=parser.split_slice"
|
// "--gtest_filter=parser.split_slice"
|
||||||
|
"--gtest_filter=vm.var_global_run"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
|
44
src/PikaVM.c
44
src/PikaVM.c
@ -999,14 +999,16 @@ static Arg* VM_instruction_handler_REF(PikaObj* self,
|
|||||||
aRes = _obj_getProp(oHost, arg_name);
|
aRes = _obj_getProp(oHost, arg_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find res in globlas */
|
/* find res in globals */
|
||||||
if (NULL == aRes) {
|
if (arg_path == arg_name) {
|
||||||
aRes = args_getArg(vm->globals->list, arg_name);
|
if (NULL == aRes) {
|
||||||
}
|
aRes = args_getArg(vm->globals->list, arg_name);
|
||||||
|
}
|
||||||
|
|
||||||
/* find res in globals prop */
|
/* find res in globals prop */
|
||||||
if (NULL == aRes) {
|
if (NULL == aRes) {
|
||||||
aRes = _obj_getProp(vm->globals, arg_name);
|
aRes = _obj_getProp(vm->globals, arg_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* proxy */
|
/* proxy */
|
||||||
@ -1786,6 +1788,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
VMParameters* oSublocals = NULL;
|
VMParameters* oSublocals = NULL;
|
||||||
VMParameters* oSublocalsInit = NULL;
|
VMParameters* oSublocalsInit = NULL;
|
||||||
char* sRunPath = data;
|
char* sRunPath = data;
|
||||||
|
char* sArgName = NULL;
|
||||||
PikaObj* oMethodHost = NULL;
|
PikaObj* oMethodHost = NULL;
|
||||||
PikaObj* oThis = NULL;
|
PikaObj* oThis = NULL;
|
||||||
Arg* aMethod = NULL;
|
Arg* aMethod = NULL;
|
||||||
@ -1799,6 +1802,10 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
.try_result = TRY_RESULT_NONE};
|
.try_result = TRY_RESULT_NONE};
|
||||||
pika_assert(NULL != vm->run_state);
|
pika_assert(NULL != vm->run_state);
|
||||||
|
|
||||||
|
if (NULL != sRunPath) {
|
||||||
|
sArgName = strPointToLastToken(sRunPath, '.');
|
||||||
|
}
|
||||||
|
|
||||||
/* inhert */
|
/* inhert */
|
||||||
if (vm->pc - 2 * (int)instructUnit_getSize() >= 0) {
|
if (vm->pc - 2 * (int)instructUnit_getSize() >= 0) {
|
||||||
if (CLS == VMstate_getInstructWithOffset(
|
if (CLS == VMstate_getInstructWithOffset(
|
||||||
@ -1823,6 +1830,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
/* support for super() */
|
/* support for super() */
|
||||||
if (strEqu(sRunPath, "super")) {
|
if (strEqu(sRunPath, "super")) {
|
||||||
sRunPath = _find_super_class_name(vm);
|
sRunPath = _find_super_class_name(vm);
|
||||||
|
sArgName = sRunPath;
|
||||||
vm->in_super = PIKA_TRUE;
|
vm->in_super = PIKA_TRUE;
|
||||||
vm->super_invoke_deepth = VMState_getInvokeDeepthNow(vm);
|
vm->super_invoke_deepth = VMState_getInvokeDeepthNow(vm);
|
||||||
bSkipInit = PIKA_TRUE;
|
bSkipInit = PIKA_TRUE;
|
||||||
@ -1911,16 +1919,18 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
aMethod = obj_getMethodArg_noalloc(oMethodHost, sRunPath, &arg_reg1);
|
aMethod = obj_getMethodArg_noalloc(oMethodHost, sRunPath, &arg_reg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get method in locals */
|
if (sArgName == sRunPath) {
|
||||||
if (NULL == aMethod) {
|
/* get method in locals */
|
||||||
aMethod = obj_getMethodArg_noalloc(vm->locals, sRunPath, &arg_reg1);
|
if (NULL == aMethod) {
|
||||||
}
|
aMethod = obj_getMethodArg_noalloc(vm->locals, sRunPath, &arg_reg1);
|
||||||
|
}
|
||||||
/* get method in global */
|
/* get method in global */
|
||||||
if (NULL == aMethod) {
|
if (NULL == aMethod) {
|
||||||
aMethod = obj_getMethodArg_noalloc(vm->globals, sRunPath, &arg_reg1);
|
aMethod =
|
||||||
if (aMethod != NULL) {
|
obj_getMethodArg_noalloc(vm->globals, sRunPath, &arg_reg1);
|
||||||
oThis = vm->globals;
|
if (aMethod != NULL) {
|
||||||
|
oThis = vm->globals;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_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
|
#endif
|
||||||
|
|
||||||
TEST_END
|
TEST_END
|
@ -59,7 +59,7 @@ extern char log_buff[LOG_BUFF_MAX][LOG_SIZE];
|
|||||||
|
|
||||||
#define TEST_RUN_LINES(_test_suite_, _test_name_, _lines_) \
|
#define TEST_RUN_LINES(_test_suite_, _test_name_, _lines_) \
|
||||||
TEST(_test_suite_, _test_name_) { \
|
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_run(self, (_lines_)); /* collect */ /* assert */ \
|
||||||
obj_deinit(self); \
|
obj_deinit(self); \
|
||||||
EXPECT_EQ(pikaMemNow(), 0); \
|
EXPECT_EQ(pikaMemNow(), 0); \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user