diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-02-03 09:14:51 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-02-03 09:14:51 +0330 |
commit | 160da58b3f49b9c295551f81d41a106ff7f6546e (patch) | |
tree | 657a99e6cae7e69e2d21a38679253797bf108ce8 /src/compiler/ast-tree.c | |
parent | 6b5e8fbb13552ecb78f8e348578861e9409d11f1 (diff) |
make mov and def more dynamic
Diffstat (limited to 'src/compiler/ast-tree.c')
-rw-r--r-- | src/compiler/ast-tree.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c index c9b719c..7bb9f8f 100644 --- a/src/compiler/ast-tree.c +++ b/src/compiler/ast-tree.c @@ -1180,7 +1180,15 @@ bool setTypesVariable(AstTree *tree) { } bool setTypesOperatorAssign(AstTree *tree) { - return setTypesAstInfix(tree->metadata); + AstTreeInfix *infix = tree->metadata; + if (!setTypesAstInfix(infix)) { + return true; + } else if (!typeIsEqual(&infix->leftType, &infix->rightType)) { + printLog("Type mismatch"); + return false; + } else { + return true; + } } bool setTypesAstVariable(AstTreeVariable *variable) { @@ -1211,11 +1219,6 @@ bool setTypesAstInfix(AstTreeInfix *infix) { AstTree *lType = makeTypeOf(&infix->left); AstTree *rType = makeTypeOf(&infix->right); - if (!typeIsEqual(lType, rType)) { - printLog("Type mismatch"); - return false; - } - infix->leftType = *lType; infix->rightType = *rType; @@ -1313,3 +1316,22 @@ bool astTreeCleanAstVariable(AstTreeVariable *variable) { return true; } + +size_t astTreeTypeSize(AstTree tree) { + switch (tree.token) { + case AST_TREE_TOKEN_TYPE_U64: + return 8; + case AST_TREE_TOKEN_FUNCTION: + case AST_TREE_TOKEN_KEYWORD_PRINT_U64: + case AST_TREE_TOKEN_TYPE_TYPE: + case AST_TREE_TOKEN_TYPE_FUNCTION: + case AST_TREE_TOKEN_TYPE_VOID: + case AST_TREE_TOKEN_FUNCTION_CALL: + case AST_TREE_TOKEN_VARIABLE: + case AST_TREE_TOKEN_VARIABLE_DEFINE: + case AST_TREE_TOKEN_VALUE_U64: + case AST_TREE_TOKEN_OPERATOR_ASSIGN: + case AST_TREE_TOKEN_NONE: + } + UNREACHABLE; +} |