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:
2025-02-17 19:07:14 +11:00
parent 02dfc996b4
commit 639250f028
12 changed files with 215 additions and 26 deletions

View File

@@ -24,6 +24,7 @@ typedef enum Toy_AstType {
TOY_AST_WHILE_THEN,
TOY_AST_BREAK,
TOY_AST_CONTINUE,
TOY_AST_RETURN,
TOY_AST_PRINT,
TOY_AST_VAR_DECLARE,
@@ -171,6 +172,11 @@ typedef struct Toy_AstContinue {
Toy_AstType type;
} Toy_AstContinue;
typedef struct Toy_AstReturn {
Toy_AstType type;
Toy_Ast* child;
} Toy_AstReturn;
typedef struct Toy_AstPrint {
Toy_AstType type;
Toy_Ast* child;
@@ -235,6 +241,7 @@ union Toy_Ast { //see 'test_ast.c' for bitness tests
Toy_AstWhileThen whileThen;
Toy_AstBreak breakPoint;
Toy_AstContinue continuePoint;
Toy_AstReturn fnReturn;
Toy_AstPrint print;
Toy_AstVarDeclare varDeclare;
Toy_AstVarAssign varAssign;
@@ -263,6 +270,7 @@ void Toy_private_emitAstIfThenElse(Toy_Bucket** bucketHandle, Toy_Ast** astHandl
void Toy_private_emitAstWhileThen(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_Ast* condBranch, Toy_Ast* thenBranch);
void Toy_private_emitAstBreak(Toy_Bucket** bucketHandle, Toy_Ast** rootHandle);
void Toy_private_emitAstContinue(Toy_Bucket** bucketHandle, Toy_Ast** rootHandle);
void Toy_private_emitAstReturn(Toy_Bucket** bucketHandle, Toy_Ast** astHandle);
void Toy_private_emitAstPrint(Toy_Bucket** bucketHandle, Toy_Ast** astHandle);
void Toy_private_emitAstVariableDeclaration(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_String* name, Toy_Ast* expr);