mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
WIP return keyword, read more
Functions are having issues with being copied around, especially between buckets, leading to the scopes getting looped. The program gets stuck in 'incrementRefCount()'. It's past my time limit, so I'll keep working on it tomorrow with a fresh mind. All function stuff is still untested. See #163
This commit is contained in:
@@ -752,6 +752,21 @@ static unsigned int writeInstructionContinue(Toy_ModuleCompiler** mb, Toy_AstCon
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int writeInstructionReturn(Toy_ModuleCompiler** mb, Toy_AstReturn ast) {
|
||||
//the things to return
|
||||
unsigned int retCount = writeModuleCompilerCode(mb, ast.child);
|
||||
|
||||
//output the print opcode
|
||||
EMIT_BYTE(mb, code,TOY_OPCODE_RETURN);
|
||||
|
||||
//4-byte alignment
|
||||
EMIT_BYTE(mb, code,(unsigned char)retCount);
|
||||
EMIT_BYTE(mb, code,0);
|
||||
EMIT_BYTE(mb, code,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int writeInstructionPrint(Toy_ModuleCompiler** mb, Toy_AstPrint ast) {
|
||||
//the thing to print
|
||||
writeModuleCompilerCode(mb, ast.child);
|
||||
@@ -1158,6 +1173,10 @@ static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* as
|
||||
result += writeInstructionContinue(mb, ast->continuePoint);
|
||||
break;
|
||||
|
||||
case TOY_AST_RETURN:
|
||||
result += writeInstructionReturn(mb, ast->fnReturn);
|
||||
break;
|
||||
|
||||
case TOY_AST_PRINT:
|
||||
result += writeInstructionPrint(mb, ast->print);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user