mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
debug p0.x = 1 error
This commit is contained in:
parent
5497dde01c
commit
695554046b
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -13,7 +13,7 @@
|
||||
"args": [
|
||||
// "--gtest_filter=queueObj.currentObj"
|
||||
// "--gtest_filter=parser*"
|
||||
// "--gtest_filter=VM.Run_add_1_2_3"
|
||||
"--gtest_filter=VM.while_a_d_x"
|
||||
// "--gtest_filter=block.ifrun2"
|
||||
// "--gtest_filter=sysObj.print"
|
||||
// "--gtest_filter=object_test.a_b"
|
||||
|
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "BaseObj.h"
|
||||
#include "PikaMain.h"
|
||||
#include "PikaMath_Operator.h"
|
||||
#include "PikaParser.h"
|
||||
#include "PikaStdLib_SysObj.h"
|
||||
@ -298,3 +299,24 @@ TEST(VM, while_a_1to10) {
|
||||
ASSERT_FLOAT_EQ(res, 10);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(VM, while_a_d_x) {
|
||||
char* line = (char*)
|
||||
"mem = PikaStdLib.MemChecker()\n"
|
||||
"mem.x = 1\n"
|
||||
"print(mem.x)\n"
|
||||
"mem.x = 2\n"
|
||||
"print(mem.x)\n"
|
||||
"\n";
|
||||
Args* buffs = New_strBuff();
|
||||
char* pikaAsm = pikaParseMultiLineToAsm(buffs, line);
|
||||
printf("%s", pikaAsm);
|
||||
PikaObj* self = newRootObj((char*)"", New_PikaMain);
|
||||
args_deinit(pikaVM_runAsm(self, pikaAsm));
|
||||
|
||||
int res = obj_getInt(self, (char*)"mem.x");
|
||||
obj_deinit(self);
|
||||
args_deinit(buffs);
|
||||
ASSERT_FLOAT_EQ(res, 2);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
12
src/PikaVM.c
12
src/PikaVM.c
@ -115,7 +115,10 @@ Arg* pikaVM_runAsmInstruct(PikaObj* self,
|
||||
}
|
||||
if (instruct == OUT) {
|
||||
Arg* outArg = arg_copy(queue_popArg(invokeQuene0));
|
||||
outArg = arg_setName(outArg, data);
|
||||
Args* buffs = New_strBuff();
|
||||
char* argName = strsGetLastToken(buffs, data, '.');
|
||||
outArg = arg_setName(outArg, argName);
|
||||
args_deinit(buffs);
|
||||
obj_setArg(self, data, outArg);
|
||||
arg_deinit(outArg);
|
||||
return NULL;
|
||||
@ -127,7 +130,8 @@ Arg* pikaVM_runAsmInstruct(PikaObj* self,
|
||||
if (strEqu(data, (char*)"False")) {
|
||||
return arg_setInt(NULL, "", 0);
|
||||
}
|
||||
return arg_copy(obj_getArg(self, data));
|
||||
Arg* arg = arg_copy(obj_getArg(self, data));
|
||||
return arg;
|
||||
}
|
||||
if (instruct == JMP) {
|
||||
*jmp = fast_atoi(data);
|
||||
@ -561,8 +565,8 @@ Args* pikaVM_runAsm(PikaObj* self, char* pikaAsm) {
|
||||
__platformPrintf("%s\r\n", sysOut);
|
||||
}
|
||||
if (0 != errcode) {
|
||||
Args *buffs = New_strBuff();
|
||||
char *onlyThisLine = strsGetFirstToken(buffs, thisLine, '\n');
|
||||
Args* buffs = New_strBuff();
|
||||
char* onlyThisLine = strsGetFirstToken(buffs, thisLine, '\n');
|
||||
__platformPrintf("[info] input commond: %s\r\n", onlyThisLine);
|
||||
args_deinit(buffs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user