aboutsummaryrefslogtreecommitdiff
path: root/src/runner/runner.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-09 18:56:19 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-06-09 18:56:19 +0330
commit8dc246166a007c2815f93ff6db535a660b05431c (patch)
treea3747464019316434103fe757a83fbdd990f16ce /src/runner/runner.c
parent03e9e1708eada3985529949302f214a223a297c2 (diff)
fix assigning to dereference access in a chain
Diffstat (limited to 'src/runner/runner.c')
-rw-r--r--src/runner/runner.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/runner/runner.c b/src/runner/runner.c
index ef363fe..ab4e9b5 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -1676,13 +1676,12 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet,
}
case AST_TREE_TOKEN_OPERATOR_DEREFERENCE: {
AstTreeSingleChild *metadata = expr->metadata;
- AstTree *operand = runExpression(metadata, scope, shouldRet, false,
+ AstTree *operand = runExpression(metadata, scope, shouldRet, true,
isComptime, breakCount, shouldContinue);
if (discontinue(*shouldRet, *breakCount)) {
return operand;
}
- if (operand->token == AST_TREE_TOKEN_RAW_VALUE ||
- operand->token == AST_TREE_TOKEN_RAW_VALUE_NOT_OWNED) {
+ if (operand->token == AST_TREE_TOKEN_RAW_VALUE) {
if (operand->type->token != AST_TREE_TOKEN_OPERATOR_POINTER) {
printLog("%s", AST_TREE_TOKEN_STRINGS[operand->type->token]);
UNREACHABLE;
@@ -1694,6 +1693,16 @@ AstTree *runExpression(AstTree *expr, AstTreeScope *scope, bool *shouldRet,
memcpy(value, *(void **)operand->metadata, size);
astTreeDelete(operand);
return newAstTree(AST_TREE_TOKEN_RAW_VALUE, value, type, NULL, NULL);
+ } else if (operand->token == AST_TREE_TOKEN_RAW_VALUE_NOT_OWNED) {
+ if (operand->type->token != AST_TREE_TOKEN_OPERATOR_POINTER) {
+ printLog("%s", AST_TREE_TOKEN_STRINGS[operand->type->token]);
+ UNREACHABLE;
+ }
+ AstTree *type =
+ copyAstTree((AstTreeSingleChild *)operand->type->metadata);
+ AstTreeRawValue *value = *(void **)operand->metadata;
+ astTreeDelete(operand);
+ return newAstTree(AST_TREE_TOKEN_RAW_VALUE_NOT_OWNED, value, type, NULL, NULL);
} else if (operand->token == AST_TREE_TOKEN_VARIABLE) {
AstTree *ret;
if (isLeft) {