SIMD and use package in polyproc bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 5 Mar 2021 23:20:57 +0000 (17:20 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 5 Mar 2021 23:20:57 +0000 (17:20 -0600)
bin/onyx
core/builtin.onyx
docs/bugs
src/onyxparser.c
src/onyxwasm.c

index 19ad013c8390694dc444b5680566182a76489844..7e78bd707d604bdd9e6d4336f8158b9eb5efc68f 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index cfa31b3e8bba12d14b0c031fc5d397e3937386ed..ccb573251a9ad036d0dd00f8348418b7b19d5ed7 100644 (file)
@@ -133,14 +133,13 @@ cresize :: (ptr: rawptr, size: u32) -> rawptr do return raw_resize(context.alloc
 cfree   :: (ptr: rawptr) do raw_free(context.allocator, ptr);
 
 #if build_opts.Runtime != build_opts.Runtime_Custom {
-    use package core.intrinsics.wasm { __initialize }
-
     new :: ($T: type_expr, allocator := context.allocator, initialize := true) -> ^T {
         res := cast(^T) raw_alloc(allocator, sizeof T);
 
         // @Robustness: This should be a '#if' when those are added in procedures because
         // otherwise the __initialize intrinsic is going to be generated no matter what.
         // This could be a problem if the type is not something that can be initialized.
+        use package core.intrinsics.wasm { __initialize }
         if initialize do __initialize(res);
         
         return res;
index ebd71fb70e6f9fa8126bb6d622883c34bde4468a..94500bebbbcea0a60aa95c4e13024130ece54ed3 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -4,7 +4,7 @@ List of known bugs:
     enum { Foo, Bar, Baz };
     enum { Foo; Bar; Baz };
 
-[ ] Using a package in the middle of a procedures removes all remaining statements in the procedure.
+[X] Using a package in the middle of a procedures removes all remaining statements in the procedure.
     This is mostly likely due to the changes made with use package statements being treated as entities now.
     
     use_package_breaking :: () {
index 7baaf1c571fbaeefcf7d0abe2f450e95c1be9b02..e3e8f70f96920762f531f7d783acfdd1d41c6e32 100644 (file)
@@ -1207,7 +1207,7 @@ static AstNode* parse_use_stmt(OnyxParser* parser) {
         }
         
         ENTITY_SUBMIT(upack);
-        return (AstNode *) upack;
+        return NULL;
 
     } else {
         AstUse* use_node = make_node(AstUse, Ast_Kind_Use);
@@ -2238,7 +2238,7 @@ static void parse_top_level_statement(OnyxParser* parser) {
     switch ((u16) parser->curr->type) {
         case Token_Type_Keyword_Use: {
             AstNode* use_node = parse_use_stmt(parser);
-            ENTITY_SUBMIT(use_node);
+            if (use_node) ENTITY_SUBMIT(use_node);
             return;
         }
 
index 2f9dc4027fe023f11685d2642095f91dfbc96455..7dc355de5dbb9fcc2c809eaf89375120ec2bdef8 100644 (file)
@@ -1318,7 +1318,7 @@ EMIT_FUNC(call, AstCall* call) {
     }
 
 #define SIMD_EXTRACT_LANE_INSTR(instr, arg_arr) \
-    emit_expression(mod, &code, arg_arr[1]->value);\
+    emit_expression(mod, &code, arg_arr[0]->value);\
     if (arg_arr[1]->value->kind != Ast_Kind_NumLit) { \
         onyx_report_error(arg_arr[1]->token->pos, "SIMD lane instructions expect a compile time lane number."); \
         *pcode = code; \
@@ -1327,16 +1327,16 @@ EMIT_FUNC(call, AstCall* call) {
     WID(instr, (u8) ((AstNumLit *) arg_arr[1]->value)->value.i);
 
 #define SIMD_REPLACE_LANE_INSTR(instr, arg_arr) { \
-        emit_expression(mod, &code, arg_arr[1]->value);\
-        if (arg_arr[1]->value->kind != Ast_Kind_NumLit) { \
-            onyx_report_error(arg_arr[1]->token->pos, "SIMD lane instructions expect a compile time lane number."); \
-            *pcode = code; \
-            return; \
-        } \
-        u8 lane = (u8) ((AstNumLit *) arg_arr[1]->value)->value.i; \
-        emit_expression(mod, &code, arg_arr[2]->value); \
-        WID(instr, lane); \
-    }
+    emit_expression(mod, &code, arg_arr[0]->value);\
+    if (arg_arr[1]->value->kind != Ast_Kind_NumLit) { \
+        onyx_report_error(arg_arr[1]->token->pos, "SIMD lane instructions expect a compile time lane number."); \
+        *pcode = code; \
+        return; \
+    } \
+    u8 lane = (u8) ((AstNumLit *) arg_arr[1]->value)->value.i; \
+    emit_expression(mod, &code, arg_arr[2]->value); \
+    WID(instr, lane); \
+}
 
 
 EMIT_FUNC(intrinsic_call, AstCall* call) {