From: Brendan Hansen Date: Fri, 5 Mar 2021 23:20:57 +0000 (-0600) Subject: SIMD and use package in polyproc bugfixes X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bfb3f8627cff2c582c8b1a688ce73a2ce680f4ce;p=onyx.git SIMD and use package in polyproc bugfixes --- diff --git a/bin/onyx b/bin/onyx index 19ad013c..7e78bd70 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/builtin.onyx b/core/builtin.onyx index cfa31b3e..ccb57325 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -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; diff --git a/docs/bugs b/docs/bugs index ebd71fb7..94500beb 100644 --- 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 :: () { diff --git a/src/onyxparser.c b/src/onyxparser.c index 7baaf1c5..e3e8f70f 100644 --- a/src/onyxparser.c +++ b/src/onyxparser.c @@ -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; } diff --git a/src/onyxwasm.c b/src/onyxwasm.c index 2f9dc402..7dc355de 100644 --- a/src/onyxwasm.c +++ b/src/onyxwasm.c @@ -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) {