aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/ast-tree.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-14 13:46:46 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-14 13:46:46 +0330
commit9e0005e248a26cb8f8ecc5138756a9157bf899b5 (patch)
tree57dfaaf88701a6397f17f552587aef7edd16ba76 /src/compiler/ast-tree.c
parent4f0e7d81333f0e5f5cf3c5ff6c88bfed9648962b (diff)
fix some bugs
implemented another raylib example
Diffstat (limited to 'src/compiler/ast-tree.c')
-rw-r--r--src/compiler/ast-tree.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c
index 280b820..ad696f6 100644
--- a/src/compiler/ast-tree.c
+++ b/src/compiler/ast-tree.c
@@ -6256,6 +6256,36 @@ bool setTypesOperatorGeneral(AstTree *tree, AstTreeSetTypesHelper _helper,
if (metadata->function->type->token == AST_TREE_TOKEN_TYPE_FUNCTION) {
AstTreeTypeFunction *function = metadata->function->type->metadata;
tree->type = copyAstTree(function->returnType);
+ } else if (metadata->function->type->token == AST_TREE_TOKEN_TYPE_MACRO) {
+ metadata->function = getValue(metadata->function, false, helper.scope);
+ if (metadata->function->token != AST_TREE_TOKEN_VALUE_MACRO) {
+ UNREACHABLE;
+ }
+ AstTreeMacro *macro = metadata->function->metadata;
+ AstTreeFunction *function =
+ copyAstTreeFunction(macro->function, NULL, NULL, 0, true);
+
+ if (!setTypesAstFunction(function, NULL, helper)) {
+ astTreeFunctionDestroy(*function);
+ free(function);
+ return false;
+ }
+
+ AstTree *functionType = makeTypeOfFunction(function, NULL, NULL);
+
+ if (!doesFunctionMatch(functionType->metadata, metadata, helper)) {
+ printError(tree->str_begin, tree->str_end, "Function call doesn't match");
+ return NULL;
+ }
+
+ const char *str_begin = metadata->function->str_begin;
+ const char *str_end = metadata->function->str_end;
+ astTreeDelete(metadata->function);
+
+ metadata->function = newAstTree(AST_TREE_TOKEN_FUNCTION, function,
+ functionType, str_begin, str_end);
+
+ tree->type = copyAstTree(function->returnType);
} else if (metadata->function->type->token ==
AST_TREE_TOKEN_TYPE_SHAPE_SHIFTER) {
AstTree *function = getShapeShifterElement(metadata, helper);
@@ -6266,6 +6296,7 @@ bool setTypesOperatorGeneral(AstTree *tree, AstTreeSetTypesHelper _helper,
AstTreeTypeFunction *functionType = metadata->function->type->metadata;
tree->type = copyAstTree(functionType->returnType);
} else {
+ printLog("%s", AST_TREE_TOKEN_STRINGS[metadata->function->type->token]);
UNREACHABLE;
}
@@ -8313,7 +8344,6 @@ AstTree *getShapeShifterElement(AstTreeFunctionCall *metadata,
shapeShifter->generateds.functions = a404m_realloc(
shapeShifter->generateds.functions,
generateds_size * sizeof(*shapeShifter->generateds.functions));
- printLog("%ld", generateds_size);
shapeShifter->generateds.calls = a404m_realloc(
shapeShifter->generateds.calls,
generateds_size * sizeof(*shapeShifter->generateds.calls));