From 258ad19e6e03e1f1a93e16972cac1096a2d93e04 Mon Sep 17 00:00:00 2001 From: A404M Date: Wed, 29 Jan 2025 06:26:49 +0330 Subject: add global variables fix shadowing in different levels better type checking --- src/compiler/ast-tree.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/compiler/ast-tree.h') diff --git a/src/compiler/ast-tree.h b/src/compiler/ast-tree.h index 7590003..852441c 100644 --- a/src/compiler/ast-tree.h +++ b/src/compiler/ast-tree.h @@ -15,7 +15,7 @@ typedef enum AstTreeToken { AST_TREE_TOKEN_TYPE_U64, AST_TREE_TOKEN_FUNCTION_CALL, - AST_TREE_TOKEN_CONSTANT, + AST_TREE_TOKEN_VARIABLE, AST_TREE_TOKEN_VALUE_U64, AST_TREE_TOKEN_NONE, @@ -24,6 +24,7 @@ typedef enum AstTreeToken { typedef struct AstTree { AstTreeToken token; void *metadata; + bool typeChecked; } AstTree; typedef struct AstTreeVariable { @@ -114,10 +115,19 @@ AstTree *astTreeParsePrintU64(ParserNode *parserNode, AstTreeVariables **variables, size_t variables_size); -bool astTreeParseConstant(ParserNode *parserNode, - AstTreeVariables **variables, - size_t variables_size); +bool astTreeParseConstant(ParserNode *parserNode, AstTreeVariables **variables, + size_t variables_size); -bool hasTypeOf(AstTree *value,const AstTree *type); +bool hasTypeOf(AstTree *value, const AstTree *type); +bool isFunction(AstTree *value); AstTree *makeTypeOf(AstTree *value); bool typeIsEqual(const AstTree *type0, const AstTree *type1); + +bool setAllTypesRoot(AstTreeRoot *root); +bool setAllTypes(AstTree *tree); +bool setTypesFunction(AstTree *tree); +bool setTypesPrintU64(AstTree *tree); +bool setTypesTypeFunction(AstTree *tree); +bool setTypesFunctionCall(AstTree *tree); +bool setTypesVariable(AstTree *tree); +bool setTypesAstVariable(AstTreeVariable *variable); -- cgit v1.2.3