|| (node->kind == Ast_Kind_Memres);
}
-static inline b32 binop_is_assignment(AstBinaryOp* binop) {
- return (binop->operation >= Binary_Op_Assign_Start
- && binop->operation <= Binary_Op_Assign_End);
+static inline b32 binop_is_assignment(BinaryOp binop) {
+ return (binop >= Binary_Op_Assign_Start && binop <= Binary_Op_Assign_End);
}
-static inline b32 binop_is_compare(AstBinaryOp* binop) {
- return (binop->operation >= Binary_Op_Equal
- && binop->operation <= Binary_Op_Greater_Equal);
+static inline b32 binop_is_compare(BinaryOp binop) {
+ return (binop >= Binary_Op_Equal && binop <= Binary_Op_Greater_Equal);
}
static inline b32 node_is_type(AstNode* node) {
else if (!strcmp(argv[i], "-VV")) {
options.verbose_output = 2;
}
+ else if (!strcmp(argv[i], "-VVV")) {
+ options.verbose_output = 3;
+ }
else if (!strcmp(argv[i], "--fun") || !strcmp(argv[i], "-F")) {
options.fun_output = 1;
}
bh_table_put(bh_file_contents, compiler_state->loaded_files, (char *) filename, fc);
fc = bh_table_get(bh_file_contents, compiler_state->loaded_files, (char *) filename);
- if (compiler_state->options->verbose_output)
+ if (compiler_state->options->verbose_output == 2)
bh_printf("Processing source file: %s\n", file.filename);
ParseResults results = parse_source_file(compiler_state, &fc);
static b32 process_entity(CompilerState* compiler_state, Entity* ent) {
i32 changed = 1;
- if (compiler_state->options->verbose_output == 2) {
+ if (compiler_state->options->verbose_output == 3) {
if (ent->expr && ent->expr->token)
printf("%s | %s | %s:%i:%i\n",
entity_state_strings[ent->state],
u64 duration = bh_time_duration(start_time);
- if (compiler_state->options->verbose_output) {
+ if (compiler_state->options->verbose_output > 0) {
// TODO: Replace these with bh_printf when padded formatting is added.
printf("\nStatistics:\n");
printf(" Time taken: %lf seconds\n", (double) duration / 1000);
binop->flags |= Ast_Flag_Comptime;
}
- if (binop_is_assignment(binop)) return check_binop_assignment(binop, assignment_is_ok);
- if (binop_is_compare(binop)) return check_binaryop_compare(pbinop);
- if (binop->operation == Binary_Op_Bool_And
- || binop->operation == Binary_Op_Bool_Or)
+ if (binop_is_assignment(binop->operation)) return check_binop_assignment(binop, assignment_is_ok);
+ if (binop_is_compare(binop->operation)) return check_binaryop_compare(pbinop);
+ if (binop->operation == Binary_Op_Bool_And || binop->operation == Binary_Op_Bool_Or)
return check_binaryop_bool(pbinop);
if (binop->left->type == NULL) {
}
if (binop->left->type->kind != Type_Kind_Basic || binop->right->type->kind != Type_Kind_Basic) {
+ if (bh_arr_length(operator_overloads[binop->operation]) == 0) goto not_overloaded;
+
bh_arr(AstTyped *) args = NULL;
bh_arr_new(global_heap_allocator, args, 2);
bh_arr_push(args, binop->left);
onyx_report_error(func->token->pos, "Expected 2 exactly arguments for binary operator overload.");
}
+ if (binop_is_assignment(func->operator_overload) ||
+ binop_is_compare(func->operator_overload)) {
+ onyx_report_error(func->token->pos, "'%s' is not currently overloadable.", binaryop_string[func->operator_overload]);
+ }
+
bh_arr_push(operator_overloads[func->operator_overload], (AstTyped *) func);
}
EMIT_FUNC(binop, AstBinaryOp* binop) {
bh_arr(WasmInstruction) code = *pcode;
- if (binop_is_assignment(binop)) {
+ if (binop_is_assignment(binop->operation)) {
emit_assignment(mod, &code, binop);
*pcode = code;
return;