#load "core/memory"
#load "core/intrinsics/wasm"
-use package core.intrinsics.wasm { memory_size, memory_grow }
-#private_file memory :: package core.memory
+use package core.intrinsics.wasm {
+ memory_size, memory_grow,
+ memory_copy,
+}
// The global heap state
#private_file
}
new_ptr := heap_alloc(new_size, align);
- memory.copy(new_ptr, ptr, old_size);
+ memory_copy(new_ptr, ptr, old_size);
heap_free(ptr);
return new_ptr;
}
if (bh_arr_length(eh->entities) == 0) return;
static const char* state_colors[] = {
- "\e[91m", "\e[93m", "\e[97m", "\e[93m", "\e[94m",
- "\e[95m", "\e[94m", "\e[95m", "\e[96m", "\e[92m",
+ "\e[91m", "\e[93m", "\e[94m", "\e[93m", "\e[97m",
+ "\e[95m", "\e[97m", "\e[95m", "\e[96m", "\e[92m",
};
printf("\e[2;1H");
return Check_Success;
}
+static void report_bad_binaryop(AstBinaryOp* binop) {
+ onyx_report_error(binop->token->pos, "Binary operator '%s' not understood for arguments of type '%s' and '%s'.",
+ binaryop_string[binop->operation],
+ node_get_type_name(binop->left),
+ node_get_type_name(binop->right));
+}
+
CheckStatus check_binop_assignment(AstBinaryOp* binop, b32 assignment_is_ok) {
if (!assignment_is_ok) {
onyx_report_error(binop->token->pos, "Assignment not valid in expression.");
CheckStatus check_binaryop_compare(AstBinaryOp** pbinop) {
AstBinaryOp* binop = *pbinop;
- if (type_is_structlike_strict(binop->left->type)) {
- onyx_report_error(binop->token->pos, "Invalid type for left side of comparison operator.");
- return Check_Error;
- }
-
- if (type_is_structlike_strict(binop->right->type)) {
- onyx_report_error(binop->token->pos, "Invalid type for right side of comparison operator.");
+ if ( type_is_structlike_strict(binop->left->type)
+ || type_is_structlike_strict(binop->right->type)) {
+ report_bad_binaryop(binop);
return Check_Error;
}
AstBinaryOp* binop = *pbinop;
if (!type_is_bool(binop->left->type) || !type_is_bool(binop->right->type)) {
- onyx_report_error(binop->token->pos, "Boolean operator expects boolean types for both operands.");
+ report_bad_binaryop(binop);
return Check_Error;
}
return Check_Success;
bad_binaryop:
- onyx_report_error(binop->token->pos, "Binary operator '%s' not understood for arguments of type '%s' and '%s'.",
- binaryop_string[binop->operation],
- node_get_type_name(binop->left),
- node_get_type_name(binop->right));
+ report_bad_binaryop(binop);
return Check_Error;
}