small bugfix when assigning to memory reservations
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 15 Aug 2020 16:22:12 +0000 (11:22 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 15 Aug 2020 16:59:39 +0000 (11:59 -0500)
include/onyxastnodes.h
onyx
src/onyxwasm.c

index c9b0e1460849e49379df381603413b53775e20c8..fa2af347530359b33d4d4dc008f818708e48a21f 100644 (file)
@@ -507,7 +507,8 @@ static inline b32 is_lval(AstNode* node) {
         || (node->kind == Ast_Kind_Global)
         || (node->kind == Ast_Kind_Dereference)
         || (node->kind == Ast_Kind_Array_Access)
-        || (node->kind == Ast_Kind_Field_Access);
+        || (node->kind == Ast_Kind_Field_Access)
+        || (node->kind == Ast_Kind_Memres);
 }
 
 static inline b32 binop_is_assignment(AstBinaryOp* binop) {
diff --git a/onyx b/onyx
index f1d476549b90b66dc98bc159ec2176d5dca3b03f..c33f8752c3d70f204e0a95ed506140066f8f75d1 100755 (executable)
Binary files a/onyx and b/onyx differ
index c6f7529d53b35a6b329480896708b8993e064b8d..c9ffe68901a306185aacd89b563ffda350458221 100644 (file)
@@ -507,6 +507,14 @@ COMPILE_FUNC(assignment, AstBinaryOp* assign) {
         compile_expression(mod, &code, assign->right);
 
         compile_store_instruction(mod, &code, field->type, offset);
+
+    } else if (lval->kind == Ast_Kind_Memres) {
+        AstMemRes* memres = (AstMemRes *) lval;
+
+        compile_memory_reservation_location(mod, &code, memres);
+        compile_expression(mod, &code, assign->right);
+        compile_store_instruction(mod, &code, memres->type, 0);
+
     } else {
         assert(("Invalid lval", 0));
     }