diff options
author | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-05-15 01:29:06 +0330 |
---|---|---|
committer | A404M <ahmadmahmoudiprogrammer@gmail.com> | 2025-05-15 01:29:06 +0330 |
commit | b6a27a2fcc02641801b4193d0f068608e18dbcbd (patch) | |
tree | d08437a7f8594d9a5f0f8e16545a27328427fef5 /src/compiler/ast-tree.h | |
parent | cfd7848462aa50e039d73df041eab93f9a48b49f (diff) |
add first version of shape shifter
Diffstat (limited to 'src/compiler/ast-tree.h')
-rw-r--r-- | src/compiler/ast-tree.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/compiler/ast-tree.h b/src/compiler/ast-tree.h index 16f137e..de0dcd7 100644 --- a/src/compiler/ast-tree.h +++ b/src/compiler/ast-tree.h @@ -64,11 +64,14 @@ typedef enum AstTreeToken { AST_TREE_TOKEN_VALUE_NULL, AST_TREE_TOKEN_VALUE_UNDEFINED, AST_TREE_TOKEN_VALUE_NAMESPACE, + AST_TREE_TOKEN_VALUE_SHAPE_SHIFTER, AST_TREE_TOKEN_VALUE_INT, AST_TREE_TOKEN_VALUE_FLOAT, AST_TREE_TOKEN_VALUE_BOOL, AST_TREE_TOKEN_VALUE_OBJECT, + AST_TREE_TOKEN_SHAPE_SHIFTER_ELEMENT, + AST_TREE_TOKEN_OPERATOR_ASSIGN, AST_TREE_TOKEN_OPERATOR_PLUS, AST_TREE_TOKEN_OPERATOR_MINUS, @@ -283,12 +286,27 @@ typedef struct AstTreeNamespace { size_t importedIndex; } AstTreeNamespace; +typedef struct AstTreeShapeShifter { + AstTreeFunction *function; + struct { + AstTreeFunctionCall **calls; + AstTreeFunction **functions; + size_t size; + } generateds; +} AstTreeShapeShifter; + +typedef struct AstTreeShapeShifterElement { + AstTree *shapeShifter; + size_t index; +} AstTreeShapeShifterElement; + #ifdef PRINT_COMPILE_TREE void astTreePrint(const AstTree *tree, int indent); void astTreeVariablePrint(const AstTreeVariable *variable, int indent); void astTreeRootPrint(const AstTreeRoot *root); #endif +void astTreeFunctionDestroy(AstTreeFunction function); void astTreeDestroy(AstTree tree); void astTreeVariableDestroy(AstTreeVariable variable); void astTreeVariableDelete(AstTreeVariable *variable); @@ -300,6 +318,7 @@ void astTreeRootsDestroy(AstTreeRoots roots); AstTree *newAstTree(AstTreeToken token, void *metadata, AstTree *type, char const *str_begin, char const *str_end); AstTree *copyAstTree(AstTree *tree); +AstTree *copyAstTreeWithCheck(AstTree *tree); AstTree *copyAstTreeBack(AstTree *tree, AstTreeVariables oldVariables[], AstTreeVariables newVariables[], size_t variables_size, bool safetyCheck); @@ -311,6 +330,10 @@ AstTreeVariables copyAstTreeVariables(AstTreeVariables variables, AstTreeVariables oldVariables[], AstTreeVariables newVariables[], size_t variables_size, bool safetyCheck); +AstTreeFunction *copyAstTreeFunction(AstTreeFunction *function, + AstTreeVariables oldVariables[], + AstTreeVariables newVariables[], + size_t variables_size, bool safetyCheck); AstTreeRoots makeAstTree(const char *filePath #ifdef PRINT_STATISTICS @@ -378,6 +401,8 @@ bool isFunction(AstTree *value); bool isShapeShifter(AstTreeFunction *function); bool isConst(AstTree *tree); AstTree *makeTypeOf(AstTree *value); +AstTree *makeTypeOfFunction(AstTreeFunction *function, const char *str_begin, + const char *str_end); bool typeIsEqual(AstTree *type0, AstTree *type1); bool typeIsEqualBack(const AstTree *type0, const AstTree *type1); AstTree *getValue(AstTree *tree); @@ -447,6 +472,8 @@ bool setTypesBuiltinBinaryWithRet(AstTree *tree, AstTreeSetTypesHelper helper, AstTree *retType); bool setTypesTypeArray(AstTree *tree, AstTreeSetTypesHelper helper); bool setTypesArrayAccess(AstTree *tree, AstTreeSetTypesHelper helper); +bool setTypesAstFunction(AstTreeFunction *function, + AstTreeSetTypesHelper helper); bool setTypesAstVariable(AstTreeVariable *variable, AstTreeSetTypesHelper helper); |