out to self

This commit is contained in:
lyon 2022-03-01 10:52:17 +08:00
parent 31f9f10081
commit 500709b5d2
2 changed files with 14 additions and 14 deletions

View File

@ -2042,18 +2042,18 @@ TEST(parser, class_) {
char* pikaAsm = Parser_multiLineToAsm(buffs, (char*)lines);
printf("%s", pikaAsm);
EXPECT_STREQ(pikaAsm, (char* )
"B0\n"
"0 DEF Test()\n"
"0 JMP 1\n"
"B1\n"
"0 RUN PikaStdLib.PikaObj\n"
"0 SLF\n"
"B1\n"
"0 NUM 1\n"
"0 OUT x\n"
"B1\n"
"0 RET\n"
"B0\n"
"B0\n"
"0 DEF Test()\n"
"0 JMP 1\n"
"B1\n"
"0 RUN PikaStdLib.PikaObj\n"
"0 OUT self\n"
"B1\n"
"0 NUM 1\n"
"0 OUT x\n"
"B1\n"
"0 RET self\n"
"B0\n"
);
args_deinit(buffs);
EXPECT_EQ(pikaMemNow(), 0);

View File

@ -1327,7 +1327,7 @@ char* AST_toPikaASM(AST* ast, Args* outBuffs) {
/* return when exit class */
if (strEqu(blockType, "class")) {
pikaAsm = ASM_addBlockDeepth(ast, outBuffs, pikaAsm, 1);
pikaAsm = strsAppend(outBuffs, pikaAsm, (char*)"0 RET\n");
pikaAsm = strsAppend(outBuffs, pikaAsm, (char*)"0 RET self\n");
}
}
}
@ -1449,7 +1449,7 @@ char* AST_toPikaASM(AST* ast, Args* outBuffs) {
pikaAsm = strsAppend(buffs, pikaAsm, "0 RUN ");
pikaAsm = strsAppend(buffs, pikaAsm, superClass);
pikaAsm = strsAppend(buffs, pikaAsm, "\n");
pikaAsm = strsAppend(buffs, pikaAsm, "0 SLF\n");
pikaAsm = strsAppend(buffs, pikaAsm, "0 OUT self\n");
is_block_matched = 1;
args_deinit(buffs);