From: Brendan Hansen Date: Tue, 28 Mar 2023 01:35:45 +0000 (-0500) Subject: bugfix: remaining bugs from `use` change X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2719a8c9b32ca9734c20c7ed1fe92a096ace94b9;p=onyx.git bugfix: remaining bugs from `use` change --- diff --git a/compiler/include/parser.h b/compiler/include/parser.h index 76961fd9..0501ab87 100644 --- a/compiler/include/parser.h +++ b/compiler/include/parser.h @@ -51,6 +51,9 @@ typedef struct OnyxParser { b32 hit_unexpected_token : 1; b32 parse_calls : 1; + + // Currently, package expressions are only allowed in certain places. + b32 allow_package_expressions : 1; } OnyxParser; const char* onyx_ast_node_kind_string(AstKind kind); diff --git a/compiler/src/parser.c b/compiler/src/parser.c index 948c2388..02a64621 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -565,7 +565,9 @@ static AstTyped* parse_factor(OnyxParser* parser) { } case Token_Type_Keyword_Package: { - onyx_report_warning(peek_token(-1)->pos, "Use of deprecated feature: package expression."); + if (!parser->allow_package_expressions) + onyx_report_warning(peek_token(-1)->pos, "Use of deprecated feature: package expression."); + retval = (AstTyped *) parse_package_expression(parser); break; } @@ -738,9 +740,11 @@ static AstTyped* parse_factor(OnyxParser* parser) { defined->token = parser->curr - 1; defined->type_node = (AstType *) &basic_type_bool; + parser->allow_package_expressions = 1; expect_token(parser, '('); defined->expr = parse_expression(parser, 0); expect_token(parser, ')'); + parser->allow_package_expressions = 0; retval = (AstTyped *) defined; break; @@ -3746,6 +3750,7 @@ OnyxParser onyx_parser_create(bh_allocator alloc, OnyxTokenizer *tokenizer) { parser.tag_depth = 0; parser.overload_count = 0; parser.injection_point = NULL; + parser.allow_package_expressions = 0; parser.polymorph_context = (PolymorphicContext) { .root_node = NULL, diff --git a/core/encoding/ini.onyx b/core/encoding/ini.onyx index 537123a3..fed04d1b 100644 --- a/core/encoding/ini.onyx +++ b/core/encoding/ini.onyx @@ -39,6 +39,7 @@ use core.io use core { aprintf } use core.intrinsics.types { type_is_struct } +use runtime // // Represents if the parsing was successful or encountered an error. diff --git a/core/onyx/cbindgen.onyx b/core/onyx/cbindgen.onyx index 66d8ba5d..f2802ead 100644 --- a/core/onyx/cbindgen.onyx +++ b/core/onyx/cbindgen.onyx @@ -11,14 +11,15 @@ package cbindgen // #load "core/std" // #load "./module" // -// use core +// use core {*} +// use your_module // // main :: () { // path := module_path(#file); // c_file_path := string.concat(path, "temporary.c"); // success := cbindgen.generate_c_binding(.{ // output_file = c_file_path, -// foreign_block = something.foreign_block, +// foreign_block = your_module.foreign_block, // cast_map = .[], // custom_implementations = .[], // preamble = .[ @@ -39,10 +40,12 @@ package cbindgen // } // +use runtime + #if #defined (runtime.Generated_Foreign_Info) { -use core -use runtime +use core {package, *} +use simd {*} #if runtime.compiler_os == .Linux { #if #defined (runtime.vars.CC) { @@ -53,8 +56,6 @@ use runtime } -use core -use simd Cast_Mapping :: struct { type: type_expr; @@ -193,7 +194,7 @@ compile_c_file :: ( } write_function_body :: (writer, ff, cast_map, name_map) => { - use runtime.info; + use runtime.info {*}; method_type := ff.type; method_info := cast (&Type_Info_Function) get_type_info(method_type); @@ -232,7 +233,7 @@ compile_c_file :: ( } print_body :: (writer, method_name, method_info, cast_map) => { - use runtime.info; + use runtime.info {*}; callw, call := io.string_builder(); defer io.buffer_stream_free(call); defer cfree(call); @@ -278,7 +279,7 @@ compile_c_file :: ( } type_to_wasm_type :: (t: type_expr, for_return := false) -> str { - use runtime.info; + use runtime.info {*}; param_info := get_type_info(t); switch param_info.kind { @@ -330,7 +331,7 @@ compile_c_file :: ( } type_encoding :: (t: type_expr) -> str { - use runtime.info; + use runtime.info {*}; param_info := get_type_info(t); switch param_info.kind {