aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/ast-tree.c32
-rw-r--r--src/runner/runner.c3
2 files changed, 33 insertions, 2 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));
diff --git a/src/runner/runner.c b/src/runner/runner.c
index f376710..c9f2dd1 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -7,8 +7,8 @@
#include "utils/type.h"
#include <dlfcn.h>
#include <ffi.h>
-#include <stdio.h>
#include <memory.h>
+#include <stdio.h>
#define doOperation(op0, op1, operator, originalType, type) \
*((originalType *)(op0)->metadata) = \
@@ -1284,6 +1284,7 @@ AstTree *runAstTreeCFunction(AstTree *tree, AstTree **arguments,
[((AstTreeSingleChild *)arguments[i]->type->metadata)->token]);
UNREACHABLE;
} else if (arguments[i]->token != AST_TREE_TOKEN_RAW_VALUE) {
+ printLog("%s", AST_TREE_TOKEN_STRINGS[arguments[i]->type->token]);
UNREACHABLE;
}
values[i] = arguments[i]->metadata;