bugfix with deferred statements in macros
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 29 Aug 2021 21:44:04 +0000 (16:44 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sun, 29 Aug 2021 21:44:04 +0000 (16:44 -0500)
bin/onyx
include/onyxastnodes.h
modules/ui/components/workspace.onyx
src/onyxwasm.c

index 8fb63e10d8eda1a518b3256b1b2d5d09b2d20041..15df32450febd4af2954ef117f5f9457407ef32f 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 759251ad0e62132fa1767adae85c8ea19ede159e..aaf7be657f1e509bc0812a74ef42e482188b67e0 100644 (file)
@@ -493,13 +493,14 @@ typedef enum VarArgKind {
 
 typedef enum BlockRule {
     Block_Rule_New_Scope         = BH_BIT(1),
-    Block_Rule_Clear_Defer       = BH_BIT(2),
-    Block_Rule_Override_Return   = BH_BIT(3),
+    Block_Rule_Emit_Instructions = BH_BIT(2),
+    Block_Rule_Clear_Defer       = BH_BIT(3),
+    Block_Rule_Override_Return   = BH_BIT(4),
 
-    Block_Rule_Normal     = Block_Rule_New_Scope | Block_Rule_Clear_Defer,
+    Block_Rule_Normal     = Block_Rule_New_Scope | Block_Rule_Clear_Defer | Block_Rule_Emit_Instructions,
     Block_Rule_Macro      = Block_Rule_New_Scope,
     Block_Rule_Code_Block = Block_Rule_New_Scope,
-    Block_Rule_Do_Block   = Block_Rule_New_Scope | Block_Rule_Clear_Defer | Block_Rule_Override_Return,
+    Block_Rule_Do_Block   = Block_Rule_New_Scope | Block_Rule_Clear_Defer | Block_Rule_Override_Return | Block_Rule_Emit_Instructions,
 } BlockRule;
 
 typedef struct Arguments Arguments;
index eba50d647a3d5ab38d9205a39aba1b224d66f761..4977611f9d16a258acf6ede817f1dc06b21efcdc 100644 (file)
@@ -30,9 +30,7 @@ workspace_start :: (use r: Rectangle, site := #callsite, state: ^Workspace_State
 
     @Hack // This whole situtation is a hack of trying to a pointer to a valid state.
     if state == null {
-        state = map.get_ptr(^workspace_states, hash);
-
-        if state == null {
+        if state = map.get_ptr(^workspace_states, hash); state == null {
             map.put(^workspace_states, hash, .{});
             state = map.get_ptr(^workspace_states, hash);
         }
@@ -51,8 +49,8 @@ workspace_start :: (use r: Rectangle, site := #callsite, state: ^Workspace_State
         }
     }
 
-    mx, my := get_mouse_position();
-    if Rectangle.contains(r, mx, my) {
+    if  mx, my := get_mouse_position();
+        Rectangle.contains(r, mx, my) {
         set_hot_item(hash);
     }
 
index 435a7820dd3e9526f1aa8e1e4cdddffa2c14b9ba..beeddfb91b811119b9bd5bd2a94ec42717967a51 100644 (file)
@@ -282,7 +282,7 @@ EMIT_FUNC(function_body, AstFunction* fd) {
 EMIT_FUNC(block, AstBlock* block, b32 generate_block_headers) {
     bh_arr(WasmInstruction) code = *pcode;
 
-    generate_block_headers = generate_block_headers && (block->rules & Block_Rule_New_Scope);
+    generate_block_headers = generate_block_headers && (block->rules & Block_Rule_Emit_Instructions);
 
     if (generate_block_headers) {
         emit_enter_structured_block(mod, &code, (block->rules & Block_Rule_Override_Return)