From ba1c61293bce7e609a35a64822db1c983dfb3d5a Mon Sep 17 00:00:00 2001 From: lyon Date: Tue, 22 Feb 2022 00:41:45 +0800 Subject: [PATCH] rename --- port/linux/test/VM-test.cpp | 62 +++++++++++++++---------------- port/linux/test/object-test.cpp | 4 +- port/linux/test/pikaMain-test.cpp | 6 +-- port/linux/test/sysObj-test.cpp | 4 +- src/PikaObj.c | 4 +- src/PikaObj.h | 4 +- src/PikaVM.c | 34 ++++++++--------- src/PikaVM.h | 4 +- 8 files changed, 61 insertions(+), 61 deletions(-) diff --git a/port/linux/test/VM-test.cpp b/port/linux/test/VM-test.cpp index e65430706..056c09d60 100644 --- a/port/linux/test/VM-test.cpp +++ b/port/linux/test/VM-test.cpp @@ -12,16 +12,16 @@ extern "C" { /* test head */ -VM_Parameters* pikaVM_runAsmWithPars(PikaObj* self, - VM_Parameters* locals, - VM_Parameters* globals, +VMParameters* pikaVM_runAsmWithPars(PikaObj* self, + VMParameters* locals, + VMParameters* globals, char* pikaAsm); char* Parser_LineToAsm(Args* buffs, char* line, Stack* blockStack); char* Parser_multiLineToAsm(Args* outBuffs, char* multiLine); -int32_t __clearInvokeQueues(VM_Parameters* locals); +int32_t __clearInvokeQueues(VMParameters* locals); int32_t pikaVM_runAsmLine(PikaObj* self, - VM_Parameters* locals, - VM_Parameters* globals, + VMParameters* locals, + VMParameters* globals, char* pikaAsm, int32_t lineAddr); } @@ -58,7 +58,7 @@ TEST(VM, a_1d1) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); ASSERT_FLOAT_EQ(args_getFloat(globals->list, (char*)"a"), 1.1); obj_deinit(self); @@ -73,7 +73,7 @@ TEST(VM, str_xy) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); ASSERT_STREQ(args_getStr(globals->list, (char*)"a"), (char*)"xy"); @@ -89,7 +89,7 @@ TEST(VM, str_xy_space) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); ASSERT_STREQ(args_getStr(globals->list, (char*)"a"), (char*)"xy "); @@ -103,7 +103,7 @@ TEST(VM, ref_a_b) { PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); Args* buffs = New_strBuff(); - VM_Parameters* globals = + VMParameters* globals = pikaVM_runAsm(self, Parser_LineToAsm(buffs, (char*)"a = 'xy '", NULL)); globals = pikaVM_runAsmWithPars( self, globals, globals, Parser_LineToAsm(buffs, (char*)"b = a", NULL)); @@ -119,7 +119,7 @@ TEST(VM, Run_add) { PikaObj* self = newRootObj((char*)"root", New_PikaMath_Operator); Args* buffs = New_strBuff(); - VM_Parameters* globals = pikaVM_runAsm( + VMParameters* globals = pikaVM_runAsm( self, Parser_LineToAsm(buffs, (char*)"a = plusInt(1,2)", NULL)); args_deinit(buffs); @@ -134,7 +134,7 @@ TEST(VM, Run_add_multy) { PikaObj* self = newRootObj((char*)"root", New_PikaMath_Operator); Args* buffs = New_strBuff(); - VM_Parameters* globals = + VMParameters* globals = pikaVM_runAsm(self, Parser_LineToAsm(buffs, (char*)"b = 2", NULL)); globals = pikaVM_runAsmWithPars( self, globals, globals, @@ -152,7 +152,7 @@ TEST(VM, Run_add_1_2_3) { PikaObj* self = newRootObj((char*)"root", New_PikaMath_Operator); Args* buffs = New_strBuff(); - VM_Parameters* globals = pikaVM_runAsm( + VMParameters* globals = pikaVM_runAsm( self, Parser_LineToAsm(buffs, (char*)"a = plusInt(1, plusInt(2,3) )", NULL)); @@ -176,7 +176,7 @@ TEST(VM, JEZ) { Args* sysRes = New_args(NULL); args_setErrorCode(sysRes, 0); args_setSysOut(sysRes, (char*)""); - VM_Parameters* globals = self; + VMParameters* globals = self; lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); @@ -199,7 +199,7 @@ TEST(VM, JMP) { Args* sysRes = New_args(NULL); args_setErrorCode(sysRes, 0); args_setSysOut(sysRes, (char*)""); - VM_Parameters* globals = self; + VMParameters* globals = self; lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); __clearInvokeQueues(globals); @@ -222,7 +222,7 @@ TEST(VM, JMP_back1) { Args* sysRes = New_args(NULL); args_setErrorCode(sysRes, 0); args_setSysOut(sysRes, (char*)""); - VM_Parameters* globals = self; + VMParameters* globals = self; lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); lineAddr = pikaVM_runAsmLine(self, globals, globals, pikaAsm, lineAddr); @@ -250,7 +250,7 @@ TEST(VM, WHILE) { printf("%s", pikaAsm); pikaMemInfo.heapUsedMax = 0; PikaObj* self = New_TinyObj(NULL); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); EXPECT_EQ(args_getInt(globals->list, (char*)"a"), 0); EXPECT_EQ(args_getInt(globals->list, (char*)"b"), 1); // obj_deinit(globals); @@ -265,7 +265,7 @@ TEST(VM, a_1_1) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int res = args_getInt(globals->list, (char*)"a"); obj_deinit(self); @@ -281,7 +281,7 @@ TEST(VM, a_1_1d1) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); float res = args_getFloat(globals->list, (char*)"a"); obj_deinit(self); @@ -297,7 +297,7 @@ TEST(VM, a_jjcc) { char* pikaAsm = Parser_LineToAsm(buffs, line, NULL); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); float res = args_getFloat(globals->list, (char*)"a"); obj_deinit(self); @@ -318,7 +318,7 @@ TEST(VM, while_a_1to10) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int res = args_getInt(globals->list, (char*)"a"); obj_deinit(self); @@ -340,7 +340,7 @@ TEST(VM, mem_x) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"", New_PikaMain); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int res = obj_getInt(globals, (char*)"mem.x"); EXPECT_EQ(2, res); @@ -382,7 +382,7 @@ TEST(VM, RET_instruct) { "0 RET\n" "B0\n"; PikaObj* self = New_TinyObj(NULL); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); Arg* returnArg = args_getArg(globals->list, (char*)"return"); int num = arg_getInt(returnArg); EXPECT_EQ(num, 13); @@ -403,7 +403,7 @@ TEST(VM, RUN_DEF) { "0 RUN test\n" "0 OUT a\n"; PikaObj* self = New_TinyObj(NULL); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int num = obj_getInt(globals, (char*)"a"); EXPECT_EQ(num, 1); obj_deinit(self); @@ -455,7 +455,7 @@ TEST(VM, RUN_local_b) { "0 RUN test\n" "0 OUT c\n"; PikaObj* self = newRootObj((char*)"", New_BaseObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int a = obj_getInt(globals, (char*)"a"); int b = obj_getInt(globals, (char*)"b"); int c = obj_getInt(globals, (char*)"c"); @@ -484,7 +484,7 @@ TEST(VM, RUN_DEF_add) { "0 RUN add\n" "0 OUT c\n"; PikaObj* self = newRootObj((char*)"", New_BaseObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int a = obj_getInt(globals, (char*)"a"); int b = obj_getInt(globals, (char*)"b"); int c = obj_getInt(globals, (char*)"c"); @@ -508,7 +508,7 @@ TEST(VM, run_def_add) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int c = args_getInt(globals->list, (char*)"c"); obj_deinit(self); @@ -528,7 +528,7 @@ TEST(VM, equ) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int c = args_getInt(globals->list, (char*)"a"); obj_deinit(self); @@ -552,7 +552,7 @@ TEST(VM, if_elif) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int b = args_getInt(globals->list, (char*)"b"); obj_deinit(self); @@ -576,7 +576,7 @@ TEST(VM, if_else) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int b = args_getInt(globals->list, (char*)"b"); obj_deinit(self); @@ -600,7 +600,7 @@ TEST(VM, if_else_) { char* pikaAsm = Parser_multiLineToAsm(buffs, line); printf("%s", pikaAsm); PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj); - VM_Parameters* globals = pikaVM_runAsm(self, pikaAsm); + VMParameters* globals = pikaVM_runAsm(self, pikaAsm); int b = args_getInt(globals->list, (char*)"b"); obj_deinit(self); diff --git a/port/linux/test/object-test.cpp b/port/linux/test/object-test.cpp index d65e66623..e7f6eba07 100644 --- a/port/linux/test/object-test.cpp +++ b/port/linux/test/object-test.cpp @@ -125,7 +125,7 @@ TEST(object_test, test3) { TEST(object_test, test6) { PikaObj* obj = newRootObj((char*)"test", New_PikaObj_test); - VM_Parameters* globals = obj_runDirect(obj, (char*)"res = add(1, 2)"); + VMParameters* globals = obj_runDirect(obj, (char*)"res = add(1, 2)"); int32_t res = obj_getInt(globals, (char*)"res"); EXPECT_EQ(3, res); obj_deinit(obj); @@ -211,7 +211,7 @@ TEST(object_test, obj_run_while) { " b = 1\n" " a = 0\n" "\n"; - VM_Parameters* globals = obj_runDirect(root, lines); + VMParameters* globals = obj_runDirect(root, lines); EXPECT_EQ(obj_getInt(globals, (char*)"a"), 0); EXPECT_EQ(obj_getInt(globals, (char*)"b"), 1); obj_deinit(root); diff --git a/port/linux/test/pikaMain-test.cpp b/port/linux/test/pikaMain-test.cpp index d93453383..9f217eced 100644 --- a/port/linux/test/pikaMain-test.cpp +++ b/port/linux/test/pikaMain-test.cpp @@ -19,7 +19,7 @@ TEST(pikaMain, init) { TEST(pikaMain, new_mem) { pikaMemInfo.heapUsedMax = 0; PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain); - VM_Parameters* globals = + VMParameters* globals = obj_runDirect(pikaMain, (char*) "mem = PikaStdLib.MemChecker()\n" "mem.max()\n" @@ -37,7 +37,7 @@ TEST(pikaMain, list_new) { pikaMemInfo.heapUsedMax = 0; PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain); /* run */ - VM_Parameters* globals = + VMParameters* globals = obj_runDirect(pikaMain, (char*) "list = PikaStdData.List()\n" "list.append(7)\n" @@ -67,7 +67,7 @@ TEST(pikaMain, int_float_convert) { pikaMemInfo.heapUsedMax = 0; PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain); /* run */ - VM_Parameters* globals = + VMParameters* globals = obj_runDirect(pikaMain, (char*) "a = 1\n" "a_f = float(a)\n" diff --git a/port/linux/test/sysObj-test.cpp b/port/linux/test/sysObj-test.cpp index 1cf05e787..e4f88c3f7 100644 --- a/port/linux/test/sysObj-test.cpp +++ b/port/linux/test/sysObj-test.cpp @@ -10,7 +10,7 @@ extern "C" { extern char log_buff[LOG_BUFF_MAX][LOG_SIZE]; TEST(sysObj, print) { PikaObj* obj = newRootObj((char*)"test", New_PikaStdLib_SysObj); - VM_Parameters* globals = obj_runDirect(obj, (char*)"print('hello world')"); + VMParameters* globals = obj_runDirect(obj, (char*)"print('hello world')"); char* sysOut = args_getSysOut(globals->list); int errCode = args_getErrorCode(globals->list); printf("sysout = %s\r\n", sysOut); @@ -24,7 +24,7 @@ TEST(sysObj, print) { TEST(sysObj, noMethod) { PikaObj* obj = newRootObj((char*)"test", New_PikaStdLib_SysObj); - VM_Parameters* globals = obj_runDirect(obj, (char*)"printttt('hello world')"); + VMParameters* globals = obj_runDirect(obj, (char*)"printttt('hello world')"); char* sysOut = args_getSysOut(globals->list); int errCode = args_getErrorCode(globals->list); printf("sysout = %s\r\n", sysOut); diff --git a/src/PikaObj.c b/src/PikaObj.c index fbedd7169..bea0b3eca 100644 --- a/src/PikaObj.c +++ b/src/PikaObj.c @@ -471,8 +471,8 @@ PIKA_WEAK int __runExtern_contral(PikaObj* self, char* cmd) { return 0; } -VM_Parameters* obj_runDirect(PikaObj* self, char* cmd) { - VM_Parameters* globals = NULL; +VMParameters* obj_runDirect(PikaObj* self, char* cmd) { + VMParameters* globals = NULL; globals = pikaVM_run(self, cmd); goto exit; diff --git a/src/PikaObj.h b/src/PikaObj.h index b0280d209..dadf6908d 100644 --- a/src/PikaObj.h +++ b/src/PikaObj.h @@ -49,7 +49,7 @@ typedef struct PikaObj_t PikaObj; typedef PikaObj* (*NewFun)(Args* args); typedef PikaObj* (*InitFun)(PikaObj* self, Args* args); -typedef PikaObj VM_Parameters; +typedef PikaObj VMParameters; typedef void (*Method)(PikaObj* self, Args* args); struct PikaObj_t { @@ -149,7 +149,7 @@ void* methodArg_getPtr(Arg* method_arg); void obj_runNoRes(PikaObj* slef, char* cmd); void obj_run(PikaObj* self, char* cmd); -VM_Parameters* obj_runDirect(PikaObj* self, char* cmd); +VMParameters* obj_runDirect(PikaObj* self, char* cmd); PikaObj* New_PikaObj(void); /* tools */ diff --git a/src/PikaVM.c b/src/PikaVM.c index ba9b16c6f..0a14f9a50 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -36,14 +36,14 @@ #include "dataStrs.h" /* local head */ -VM_Parameters* pikaVM_runAsmWithPars(PikaObj* self, - VM_Parameters* locals, - VM_Parameters* globals, - char* pikaAsm); +VMParameters* pikaVM_runAsmWithPars(PikaObj* self, + VMParameters* locals, + VMParameters* globals, + char* pikaAsm); struct VMState { - VM_Parameters* locals; - VM_Parameters* globals; + VMParameters* locals; + VMParameters* globals; Queue* q0; Queue* q1; int32_t jmp; @@ -145,7 +145,7 @@ static int32_t __getAddrOffsetFromJmp(char* start, char* code, int32_t jmp) { return offset; } -int32_t __clearInvokeQueues(VM_Parameters* vm_pars) { +int32_t __clearInvokeQueues(VMParameters* vm_pars) { for (char deepthChar = '0'; deepthChar < '9'; deepthChar++) { char deepth[2] = {0}; deepth[0] = deepthChar; @@ -202,7 +202,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self, char* data) { Args* buffs = New_strBuff(); Arg* returnArg = NULL; - VM_Parameters* subLocals = NULL; + VMParameters* subLocals = NULL; char* methodPath = data; PikaObj* methodHostObj; Arg* method_arg; @@ -666,8 +666,8 @@ static enum Instruct __getInstruct(char* line) { } int32_t pikaVM_runAsmLine(PikaObj* self, - VM_Parameters* locals, - VM_Parameters* globals, + VMParameters* locals, + VMParameters* globals, char* pikaAsm, int32_t lineAddr) { Args* buffs = New_strBuff(); @@ -740,10 +740,10 @@ nextLine: return nextAddr; } -VM_Parameters* pikaVM_runAsmWithPars(PikaObj* self, - VM_Parameters* locals, - VM_Parameters* globals, - char* pikaAsm) { +VMParameters* pikaVM_runAsmWithPars(PikaObj* self, + VMParameters* locals, + VMParameters* globals, + char* pikaAsm) { int lineAddr = 0; int size = strGetSize(pikaAsm); args_setErrorCode(locals->list, 0); @@ -771,13 +771,13 @@ VM_Parameters* pikaVM_runAsmWithPars(PikaObj* self, return locals; } -VM_Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm) { +VMParameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm) { return pikaVM_runAsmWithPars(self, self, self, pikaAsm); } -VM_Parameters* pikaVM_run(PikaObj* self, char* multiLine) { +VMParameters* pikaVM_run(PikaObj* self, char* multiLine) { Args* buffs = New_strBuff(); - VM_Parameters* globals = NULL; + VMParameters* globals = NULL; char* pikaAsm = Parser_multiLineToAsm(buffs, multiLine); if (NULL == pikaAsm) { __platform_printf("[error]: Syntax error.\r\n"); diff --git a/src/PikaVM.h b/src/PikaVM.h index ac27b894b..463b8cde5 100644 --- a/src/PikaVM.h +++ b/src/PikaVM.h @@ -29,7 +29,7 @@ #define __PIKA__VM__H #include "PikaObj.h" -VM_Parameters* pikaVM_run(PikaObj* self, char* pyLine); -VM_Parameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm); +VMParameters* pikaVM_run(PikaObj* self, char* pyLine); +VMParameters* pikaVM_runAsm(PikaObj* self, char* pikaAsm); #endif