bug fix with bitwise not unary operator in code generation
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 17:46:39 +0000 (11:46 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 14 Dec 2020 17:46:39 +0000 (11:46 -0600)
onyx
src/onyxutils.c
src/onyxwasm.c

diff --git a/onyx b/onyx
index 0c0be048b51fce9ed0255301950c9956d05017fb..ae7f54b4c3e90be781d5b6df02ccf7b6f4458a8c 100755 (executable)
Binary files a/onyx and b/onyx differ
index 82c4e6f814fef8f88e81fc423fa68ac2374f1008..eaeeb2125c678f7d771248115af9d286481167b3 100644 (file)
@@ -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);
index 7428f6f4160ecc52e32e4e7d824791b45d15d0dd..894c4b4e65d1ffc4d3f6b7d5e9e5ae3ef796af66 100644 (file)
@@ -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);
             }