From: Brendan Hansen Date: Mon, 14 Dec 2020 17:46:39 +0000 (-0600) Subject: bug fix with bitwise not unary operator in code generation X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=6e96826782f919c31e7010746c8c5cf1d46bee2e;p=onyx.git bug fix with bitwise not unary operator in code generation --- diff --git a/onyx b/onyx index 0c0be048..ae7f54b4 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxutils.c b/src/onyxutils.c index 82c4e6f8..eaeeb212 100644 --- a/src/onyxutils.c +++ b/src/onyxutils.c @@ -559,6 +559,9 @@ AstFunction* polymorphic_proc_lookup(AstPolyProc* pp, PolyProcLookupMethod pp_lo symbol_introduce(pp->poly_scope, param->poly_sym->token, (AstNode *) raw); } + // HACK(Brendan): Maybe each type should be given a unique id upon creation? + // Then that could be used to uniquely identify the type, instead of relying + // on the name being unique. - brendanfh 2020/12/14 static char key_buf[1024]; fori (i, 0, 1024) key_buf[i] = 0; bh_table_each_start(AstNode *, pp->poly_scope->symbols); diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 7428f6f4..894c4b4e 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -1296,14 +1296,14 @@ EMIT_FUNC(unaryop, AstUnaryOp* unop) { TypeBasic* type = &unop->type->Basic; - if (type->kind == Basic_Kind_I32 - || type->kind == Basic_Kind_I16 - || type->kind == Basic_Kind_I8) { + if (type->kind == Basic_Kind_I32 || type->kind == Basic_Kind_U32 + || type->kind == Basic_Kind_I16 || type->kind == Basic_Kind_U16 + || type->kind == Basic_Kind_I8 || type->kind == Basic_Kind_U8) { WID(WI_I32_CONST, 0xffffffff); WI(WI_I32_XOR); } - else if (type->kind == Basic_Kind_I64) { + else if (type->kind == Basic_Kind_I64 || type->kind == Basic_Kind_U64) { WIL(WI_I64_CONST, 0xffffffffffffffff); WI(WI_I64_XOR); }