jjcc is ok

This commit is contained in:
lyon1998 2021-10-21 18:28:52 +08:00
parent a385cefdb0
commit d20053516c
2 changed files with 21 additions and 1 deletions

View File

@ -262,4 +262,19 @@ TEST(VM, a_1_1d1) {
args_deinit(buffs);
ASSERT_FLOAT_EQ(res, 2.1);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(VM, a_jjcc) {
char* line = (char*)"a = (1 + 1.1) * 3 - 2 /4.0";
Args* buffs = New_strBuff();
char* pikaAsm = pikaParseLineToAsm(buffs, line, NULL);
printf("%s", pikaAsm);
PikaObj* self = newRootObj((char*)"root", New_PikaStdLib_SysObj);
args_deinit(pikaVM_runAsm(self, pikaAsm));
float res = obj_getFloat(self, (char*)"a");
obj_deinit(self);
args_deinit(buffs);
ASSERT_FLOAT_EQ(res, 5.8);
EXPECT_EQ(pikaMemNow(), 0);
}

View File

@ -246,6 +246,11 @@ Arg* pikaVM_runAsmInstruct(PikaObj* self,
Arg* returnArg = NULL;
Args* methodArgs = NULL;
char* methodPath = data;
PikaObj* methodHostClass = NULL;
if (strEqu(data, "")) {
returnArg = arg_copy(queue_popArg(invokeQuene1));
goto RUN_exit;
}
PikaObj* methodHostObj = obj_getObj(self, methodPath, 1);
if (NULL == methodHostObj) {
/* error, not found object */
@ -257,7 +262,7 @@ Arg* pikaVM_runAsmInstruct(PikaObj* self,
void* classPtr = obj_getPtr(methodHostObj, "_clsptr");
char* methodHostClassName =
strsAppend(buffs, "classObj-", obj_getName(methodHostObj));
PikaObj* methodHostClass = obj_getClassObjByNewFun(
methodHostClass = obj_getClassObjByNewFun(
methodHostObj, methodHostClassName, classPtr);
/* get method Ptr */
void (*methodPtr)(PikaObj * self, Args * args) =