aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/ast-tree.c4
-rw-r--r--src/runner/runner.c12
2 files changed, 8 insertions, 8 deletions
diff --git a/src/compiler/ast-tree.c b/src/compiler/ast-tree.c
index 628784a..a4159d1 100644
--- a/src/compiler/ast-tree.c
+++ b/src/compiler/ast-tree.c
@@ -5842,7 +5842,7 @@ bool setTypesIf(AstTree *tree, AstTreeSetTypesHelper helper,
return false;
}
- if (isConst(metadata->condition)) {
+ if (metadata->condition->token == AST_TREE_TOKEN_KEYWORD_COMPTIME) {
AstTree *condition = getValue(metadata->condition, true);
AstTree *result;
bool condi = *(AstTreeBool *)condition->metadata;
@@ -5913,7 +5913,7 @@ bool setTypesWhile(AstTree *tree, AstTreeSetTypesHelper _helper,
return false;
}
- if (isConst(metadata->condition)) {
+ if (metadata->condition->token == AST_TREE_TOKEN_KEYWORD_COMPTIME) {
AstTree *condition = getValue(metadata->condition, true);
bool condi = *(AstTreeBool *)condition->metadata;
astTreeDelete(condition);
diff --git a/src/runner/runner.c b/src/runner/runner.c
index c5355cc..9cb67f8 100644
--- a/src/runner/runner.c
+++ b/src/runner/runner.c
@@ -991,15 +991,13 @@ AstTree *runAstTreeCFunction(AstTree *tree, AstTree **arguments,
UNREACHABLE;
}
- ffi_cif cif;
- ffi_type *args[arguments_size];
- void *values[arguments_size];
- ffi_arg rc;
-
if (funcType->arguments_size != arguments_size) {
UNREACHABLE;
}
+ ffi_type *args[arguments_size];
+ void *values[arguments_size];
+
for (size_t i = 0; i < arguments_size; ++i) {
AstTreeTypeFunctionArgument arg = funcType->arguments[i];
args[i] = toFFIType(arg.type);
@@ -1014,13 +1012,15 @@ AstTree *runAstTreeCFunction(AstTree *tree, AstTree **arguments,
values[i] = arguments[i]->metadata;
}
+ ffi_cif cif;
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, arguments_size,
toFFIType(funcType->returnType), args) == FFI_OK) {
+ ffi_arg rc;
ffi_call(&cif, fun, &rc, values);
if (typeIsEqual(funcType->returnType, &AST_TREE_VOID_TYPE)) {
return &AST_TREE_VOID_TYPE;
} else {
- size_t size = getSizeOfType(funcType->returnType);
+ const size_t size = getSizeOfType(funcType->returnType);
AstTreeRawValue *value = a404m_malloc(size);
memcpy(value, &rc, size);
return newAstTree(AST_TREE_TOKEN_RAW_VALUE, value,