mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix error info
This commit is contained in:
parent
a3dc9b577f
commit
2fae86de32
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -20,7 +20,7 @@
|
||||
"args": [
|
||||
// "--gtest_filter=pikaMain.list__set__",
|
||||
// "--gtest_filter=parser._3_3",
|
||||
// "--gtest_filter=VM.a_jjcc",
|
||||
// "--gtest_filter=VM.a_3",
|
||||
// "--gtest_filter=parser.a_cuohao_j",
|
||||
// "--gtest_filter=lexser.jjcc",
|
||||
// "--gtest_filter=lexser.a_j",
|
||||
|
@ -957,3 +957,18 @@ TEST(VM, _3_3) {
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(VM, a_3) {
|
||||
char* line = (char*)"a-3";
|
||||
Args* buffs = New_strBuff();
|
||||
char* pikaAsm = Parser_LineToAsm(buffs, line, NULL);
|
||||
printf("%s", pikaAsm);
|
||||
PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj);
|
||||
__platform_printf((char*)"BEGIN\r\n");
|
||||
pikaVM_runAsm(self, pikaAsm);
|
||||
EXPECT_STREQ(log_buff[3], (char*)"BEGIN\r\n");
|
||||
EXPECT_STREQ(log_buff[2], (char*)"NameError: name 'a' is not defined\r\n");
|
||||
obj_deinit(self);
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -1180,7 +1180,7 @@ void VMState_solveUnusedStack(VMState* vs) {
|
||||
arg_deinit(arg);
|
||||
continue;
|
||||
}
|
||||
if (vs->error_code != 0) {
|
||||
if (vs->line_error_code != 0) {
|
||||
arg_deinit(arg);
|
||||
continue;
|
||||
}
|
||||
@ -1208,6 +1208,7 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self,
|
||||
.jmp = 0,
|
||||
.pc = pc,
|
||||
.error_code = 0,
|
||||
.line_error_code = 0,
|
||||
};
|
||||
stack_init(&(vs.stack));
|
||||
while (vs.pc < size) {
|
||||
@ -1219,9 +1220,11 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self,
|
||||
VMState_solveUnusedStack(&vs);
|
||||
stack_reset(&(vs.stack));
|
||||
vs.error_code = 0;
|
||||
vs.line_error_code = 0;
|
||||
}
|
||||
vs.pc = pikaVM_runInstructUnit(self, &vs, this_ins_unit);
|
||||
if (0 != vs.error_code) {
|
||||
vs.line_error_code = vs.error_code;
|
||||
InstructUnit* head_ins_unit = this_ins_unit;
|
||||
/* get first ins of a line */
|
||||
while (1) {
|
||||
@ -1245,6 +1248,7 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self,
|
||||
}
|
||||
}
|
||||
__platform_error_handle();
|
||||
vs.error_code = 0;
|
||||
}
|
||||
}
|
||||
VMState_solveUnusedStack(&vs);
|
||||
@ -1252,6 +1256,7 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self,
|
||||
return locals;
|
||||
}
|
||||
|
||||
|
||||
VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
||||
ByteCodeFrame* byteCode_frame) {
|
||||
return pikaVM_runByteCodeWithState(self, self, self, byteCode_frame, 0);
|
||||
|
@ -46,6 +46,7 @@ typedef struct VMState_t {
|
||||
int32_t pc;
|
||||
ByteCodeFrame* bytecode_frame;
|
||||
uint8_t error_code;
|
||||
uint8_t line_error_code;
|
||||
} VMState;
|
||||
|
||||
VMParameters* pikaVM_run(PikaObj* self, char* pyLine);
|
||||
|
Loading…
x
Reference in New Issue
Block a user