WIP: Started on break & continue, needs Toy_Array in Toy_Value first

This commit is contained in:
2024-11-28 13:43:26 +11:00
parent 6cc331d462
commit 431893bf60
6 changed files with 99 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ typedef enum Toy_AstType {
TOY_AST_ASSERT,
TOY_AST_IF_THEN_ELSE,
TOY_AST_WHILE_THEN,
TOY_AST_BREAK,
TOY_AST_CONTINUE,
TOY_AST_PRINT,
TOY_AST_VAR_DECLARE,
@@ -138,6 +140,14 @@ typedef struct Toy_AstWhileThen {
Toy_Ast* thenBranch;
} Toy_AstWhileThen;
typedef struct Toy_AstBreak {
Toy_AstType type;
} Toy_AstBreak;
typedef struct Toy_AstContinue {
Toy_AstType type;
} Toy_AstContinue;
typedef struct Toy_AstPrint {
Toy_AstType type;
Toy_Ast* child;
@@ -185,6 +195,8 @@ union Toy_Ast { //32 | 64 BITNESS
Toy_AstAssert assert; //16 | 24
Toy_AstIfThenElse ifThenElse; //16 | 32
Toy_AstWhileThen whileThen; //16 | 24
Toy_AstBreak breakPoint; //4 | 4
Toy_AstContinue continuePoint; //4 | 4
Toy_AstPrint print; //8 | 16
Toy_AstVarDeclare varDeclare; //16 | 24
Toy_AstVarAssign varAssign; //16 | 24
@@ -207,6 +219,8 @@ void Toy_private_emitAstCompound(Toy_Bucket** bucketHandle, Toy_Ast** astHandle,
void Toy_private_emitAstAssert(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_Ast* child, Toy_Ast* msg);
void Toy_private_emitAstIfThenElse(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_Ast* condBranch, Toy_Ast* thenBranch, Toy_Ast* elseBranch);
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_emitAstPrint(Toy_Bucket** bucketHandle, Toy_Ast** astHandle);
void Toy_private_emitAstVariableDeclaration(Toy_Bucket** bucketHandle, Toy_Ast** astHandle, Toy_String* name, Toy_Ast* expr);