summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-04-07 14:44:16 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-04-07 14:44:16 +0330
commit62b7af496f2c694ff5361cf21042bbe14f969c64 (patch)
tree4c9b32af2d2baa49ad9941fc73a90133e1c27a77 /src
parent1f73f7e22c207fa72391253e21332e02d055bd72 (diff)
add more type stuff
Diffstat (limited to 'src')
-rw-r--r--src/compiler/ast-tree.c12
-rw-r--r--src/runner/runner.c7
-rw-r--r--src/runner/runner.h1
3 files changed, 18 insertions, 2 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c
index 0dc5424..55209c4 100644
--- a/src/compiler/ast-tree.c
+++ b/src/compiler/ast-tree.c
@@ -1555,7 +1555,7 @@ AstTree *astTreeParseFunction(ParserNode *parserNode, AstTreeHelper *p_helper) {
argument->type = type;
argument->name_begin = arg_metadata->name->str_begin;
argument->name_end = arg_metadata->name->str_end;
- argument->isConst = false; // all arguments are not constants
+ argument->isConst = true; // all arguments are constants
if (!pushVariable(&helper, &function->arguments, argument)) {
astTreeVariableDelete(argument);
@@ -2532,6 +2532,10 @@ AstTree *makeTypeOf(AstTree *value) {
bool typeIsEqual(AstTree *type0, AstTree *type1) {
AstTree *left = getValue(type0);
AstTree *right = getValue(type1);
+ if (left == NULL || right == NULL) {
+ printLog("Can't check types");
+ UNREACHABLE;
+ }
bool ret = typeIsEqualBack(left, right);
@@ -3231,6 +3235,9 @@ bool setTypesReturn(AstTree *tree, AstTreeSetTypesHelper _helper,
.lookingType = getValue(function->returnType),
.treeHelper = _helper.treeHelper,
};
+ if (helper.lookingType == NULL) {
+ return false;
+ }
if (!setAllTypes(metadata->value, helper, NULL)) {
return false;
}
@@ -3628,6 +3635,9 @@ bool setTypesComptime(AstTree *tree, AstTreeSetTypesHelper helper) {
}
AstTree *newTree = getValue(operand);
+ if (newTree == NULL) {
+ return false;
+ }
if (operand != newTree) {
astTreeDelete(operand);
diff --git a/src/runner/runner.c b/src/runner/runner.c
index c6a8bf0..984af3f 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -30,6 +30,11 @@ void runnerVariableSetValue(AstTreeVariable *variable, AstTree *value) {
if (variable->isConst) {
UNREACHABLE;
}
+ runnerVariableSetValueWihtoutConstCheck(variable, value);
+}
+
+void runnerVariableSetValueWihtoutConstCheck(AstTreeVariable *variable,
+ AstTree *value) {
if (variable->value != NULL) {
astTreeDelete(variable->value);
}
@@ -71,7 +76,7 @@ AstTree *runAstTreeFunction(AstTree *tree, AstTreeFunctionCallParam *arguments,
AstTreeFunctionCallParam param = arguments[i];
AstTreeVariable *arg = function->arguments.data[i];
AstTree *value = runExpression(param.value, &shouldRet, false);
- runnerVariableSetValue(arg, value);
+ runnerVariableSetValueWihtoutConstCheck(arg, value);
}
shouldRet = false;
diff --git a/src/runner/runner.h b/src/runner/runner.h
index 10fd8dc..2ff2ec2 100644
--- a/src/runner/runner.h
+++ b/src/runner/runner.h
@@ -4,6 +4,7 @@
#include <stdint.h>
void runnerVariableSetValue(AstTreeVariable *variable,AstTree *value);
+void runnerVariableSetValueWihtoutConstCheck(AstTreeVariable *variable,AstTree *value);
bool runAstTree(AstTreeRoot *root);