aboutsummaryrefslogtreecommitdiff
path: root/src/runner
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-30 15:26:15 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-05-30 15:26:15 +0330
commita2a6bb49368e922af28b9a54669b9f7fe5b2e6a0 (patch)
tree9cb347b996d5473a60ed961b62104789a72aa88a /src/runner
parentca529dddbedc0264b8952ee410e8b1e5f6c5a195 (diff)
better unary operator
Diffstat (limited to 'src/runner')
-rw-r--r--src/runner/runner.c40
1 files changed, 4 insertions, 36 deletions
diff --git a/src/runner/runner.c b/src/runner/runner.c
index 76058a4..d0a9498 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -1293,6 +1293,10 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet,
bool isLeft, bool isComptime, u32 *breakCount,
bool *shouldContinue, bool needOwnership) {
switch (expr->token) {
+ case AST_TREE_TOKEN_OPERATOR_LOGICAL_NOT:
+ case AST_TREE_TOKEN_OPERATOR_BITWISE_NOT:
+ case AST_TREE_TOKEN_OPERATOR_MINUS:
+ case AST_TREE_TOKEN_OPERATOR_PLUS:
case AST_TREE_TOKEN_OPERATOR_SUM:
case AST_TREE_TOKEN_OPERATOR_SUB:
case AST_TREE_TOKEN_OPERATOR_MULTIPLY:
@@ -1531,42 +1535,6 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet,
}
return ret;
}
- case AST_TREE_TOKEN_OPERATOR_LOGICAL_NOT:
- case AST_TREE_TOKEN_OPERATOR_BITWISE_NOT:
- case AST_TREE_TOKEN_OPERATOR_MINUS:
- case AST_TREE_TOKEN_OPERATOR_PLUS: {
- AstTreeUnary *metadata = expr->metadata;
- AstTree *function =
- runExpression(metadata->function->value, scope, shouldRet, false,
- isComptime, breakCount, shouldContinue, false);
- if (discontinue(*shouldRet, *breakCount)) {
- return function;
- }
-
- AstTreeFunction *fun = function->metadata;
-
- AstTree *arguments[] = {
- metadata->operand,
- };
-
- for (size_t i = 0; i < 1; ++i) {
- AstTreeVariable *arg = fun->arguments.data[i];
- arguments[i] =
- getForVariable(arguments[i], scope, shouldRet, isLeft, isComptime,
- breakCount, shouldContinue, arg->isLazy, false);
- if (discontinue(*shouldRet, *breakCount)) {
- astTreeDelete(function);
- for (size_t j = 0; j < i; ++j) {
- astTreeDelete(arguments[j]);
- }
- return arguments[i];
- }
- }
-
- AstTree *ret = runAstTreeFunction(function, arguments, 1, isComptime);
- astTreeDelete(function);
- return ret;
- }
case AST_TREE_TOKEN_TYPE_TYPE:
case AST_TREE_TOKEN_TYPE_ANY_TYPE:
case AST_TREE_TOKEN_TYPE_FUNCTION: