mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
conter size at out
This commit is contained in:
parent
f984c29bc3
commit
43c764c6e0
@ -16,11 +16,9 @@ TEST(VM, a_1) {
|
|||||||
PikaObj* root = newRootObj((char*)"root", New_PikaStdLib_SysObj);
|
PikaObj* root = newRootObj((char*)"root", New_PikaStdLib_SysObj);
|
||||||
|
|
||||||
int lineAddr = 0;
|
int lineAddr = 0;
|
||||||
while (1) {
|
int size = strGetSize(pikaAsm);
|
||||||
|
while (lineAddr < size) {
|
||||||
lineAddr = pikaVM_run(root, pikaAsm, lineAddr);
|
lineAddr = pikaVM_run(root, pikaAsm, lineAddr);
|
||||||
if (lineAddr < 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_deinit(root);
|
obj_deinit(root);
|
||||||
|
11
src/PikaVM.c
11
src/PikaVM.c
@ -17,11 +17,16 @@ static int32_t getLineSize(char* str) {
|
|||||||
|
|
||||||
int32_t pikaVM_run(PikaObj* self, char* pikaAsm, int32_t lineAddr) {
|
int32_t pikaVM_run(PikaObj* self, char* pikaAsm, int32_t lineAddr) {
|
||||||
Args* buffs = New_strBuff();
|
Args* buffs = New_strBuff();
|
||||||
int32_t size = getLineSize(pikaAsm + lineAddr);
|
int32_t nextAddr = lineAddr;
|
||||||
char* line = pikaAsm + lineAddr;
|
char* code = pikaAsm + lineAddr;
|
||||||
|
int32_t lineSize = getLineSize(code);
|
||||||
|
nextAddr = lineAddr + lineSize + 1;
|
||||||
|
char* line = args_getBuff(buffs, lineSize + 1);
|
||||||
|
memcpy(line, code, lineSize);
|
||||||
|
line[lineSize + 1] = 0;
|
||||||
|
|
||||||
goto exit;
|
goto exit;
|
||||||
exit:
|
exit:
|
||||||
args_deinit(buffs);
|
args_deinit(buffs);
|
||||||
return -1;
|
return nextAddr;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user