From d897a65b93941a881cf6872fa107373a4dc019be Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sat, 25 Mar 2023 14:31:17 -0500 Subject: [PATCH] added: `#import` functions as `use` statement --- compiler/include/astnodes.h | 2 + compiler/src/parser.c | 39 ++++++++++++++----- tests/aoc-2020/day10.onyx | 3 +- tests/aoc-2020/day12.onyx | 2 +- tests/aoc-2020/day13.onyx | 2 +- tests/aoc-2020/day14.onyx | 2 +- tests/aoc-2020/day15.onyx | 2 +- tests/aoc-2020/day16.onyx | 2 +- tests/aoc-2020/day18.onyx | 2 +- tests/aoc-2020/day19.onyx | 2 +- tests/aoc-2020/day2.onyx | 2 +- tests/aoc-2020/day20.onyx | 2 +- tests/aoc-2020/day21.onyx | 2 +- tests/aoc-2020/day22.onyx | 2 +- tests/aoc-2020/day23.onyx | 2 +- tests/aoc-2020/day24.onyx | 2 +- tests/aoc-2020/day25.onyx | 2 +- tests/aoc-2020/day3.onyx | 2 +- tests/aoc-2020/day4.onyx | 2 +- tests/aoc-2020/day5.onyx | 2 +- tests/aoc-2020/day6.onyx | 2 +- tests/aoc-2020/day7.onyx | 2 +- tests/aoc-2020/day8.onyx | 2 +- tests/aoc-2020/day9.onyx | 2 +- tests/aoc-2021/day01.onyx | 4 +- tests/aoc-2021/day02.onyx | 4 +- tests/aoc-2021/day03.onyx | 2 +- tests/aoc-2021/day04.onyx | 2 +- tests/aoc-2021/day05.onyx | 2 +- tests/aoc-2021/day06.onyx | 2 +- tests/aoc-2021/day07.onyx | 2 +- tests/aoc-2021/day08.onyx | 2 +- tests/aoc-2021/day09.onyx | 2 +- tests/aoc-2021/day10.onyx | 2 +- tests/aoc-2021/day11.onyx | 2 +- tests/aoc-2021/day12.onyx | 2 +- tests/aoc-2021/day13.onyx | 2 +- tests/aoc-2021/day14.onyx | 2 +- tests/aoc-2021/day15.onyx | 2 +- tests/aoc-2021/day16.onyx | 2 +- tests/aoc-2021/day17.onyx | 2 +- tests/array_struct_robustness.onyx | 2 +- tests/atomics.onyx | 4 +- tests/auto_poly.onyx | 2 +- tests/avl_test.onyx | 2 +- tests/baked_parameters.onyx | 2 +- tests/better_field_accesses.onyx | 2 +- tests/bucket_array.onyx | 2 +- tests/bugs/anonymous_struct_defaults.onyx | 2 +- tests/bugs/defer_block_in_macro.onyx | 2 +- tests/bugs/fallthrough_defer_interaction.onyx | 2 +- .../bugs/macro_auto_return_not_resolved.onyx | 2 +- tests/bugs/namespace_aliasing.onyx | 2 +- tests/caller_location.onyx | 4 +- tests/compile_time_procedures.onyx | 2 +- tests/complicated_polymorph.onyx | 2 +- tests/defer_with_continue.onyx | 2 +- tests/defined_test.onyx | 2 +- tests/float_parsing.onyx | 2 +- tests/i32map.onyx | 2 +- tests/implicit_initialize_locals.onyx | 2 +- tests/init_procedures.onyx | 2 +- tests/lazy_iterators.onyx | 2 +- tests/named_arguments_test.onyx | 2 +- tests/new_printf.onyx | 4 +- tests/new_struct_behaviour.onyx | 2 +- tests/operator_overload.onyx | 2 +- tests/overload_precedence.onyx | 2 +- tests/persist_locals.onyx | 2 +- tests/poly_struct_in_type_info.onyx | 5 ++- tests/poly_structs_with_values.onyx | 2 +- tests/polymorphic_array_lengths.onyx | 2 +- tests/remove_test.onyx | 2 +- tests/sets.onyx | 2 +- tests/struct_robustness.onyx | 2 +- tests/struct_use_pointer_member.onyx | 2 +- tests/switch_using_equals.onyx | 2 +- tests/vararg_test.onyx | 2 +- 78 files changed, 115 insertions(+), 92 deletions(-) diff --git a/compiler/include/astnodes.h b/compiler/include/astnodes.h index 5e5aef91..0043a259 100644 --- a/compiler/include/astnodes.h +++ b/compiler/include/astnodes.h @@ -1176,6 +1176,8 @@ struct AstImport { AstNode_base; AstPackage *imported_package; + + AstUse *implicit_use_node; }; diff --git a/compiler/src/parser.c b/compiler/src/parser.c index 174566f3..a24f8d1c 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -1494,18 +1494,16 @@ static AstReturn* parse_return_stmt(OnyxParser* parser) { return return_node; } -static AstNode* parse_use_stmt(OnyxParser* parser) { - OnyxToken* use_token = expect_token(parser, Token_Type_Keyword_Use); - AstUse* use_node = make_node(AstUse, Ast_Kind_Use); - use_node->token = use_token; - use_node->expr = parse_expression(parser, 1); - if (!use_node->expr) return NULL; - +static b32 parse_use_stmt_internal(OnyxParser* parser, AstUse* use_node) { if (consume_token_if_next(parser, '{')) { - bh_arr_new(global_heap_allocator, use_node->only, 4); + if (next_tokens_are(parser, 2, '*', '}')) { + consume_tokens(parser, 2); + return 1; + } + bh_arr_new(global_heap_allocator, use_node->only, 4); while (!consume_token_if_next(parser, '}')) { - if (parser->hit_unexpected_token) return NULL; + if (parser->hit_unexpected_token) return 0; QualifiedUse qu; qu.as_name = expect_token(parser, Token_Type_Symbol); @@ -1523,6 +1521,18 @@ static AstNode* parse_use_stmt(OnyxParser* parser) { } } + return 1; +} + +static AstNode* parse_use_stmt(OnyxParser* parser) { + OnyxToken* use_token = expect_token(parser, Token_Type_Keyword_Use); + AstUse* use_node = make_node(AstUse, Ast_Kind_Use); + use_node->token = use_token; + use_node->expr = parse_expression(parser, 1); + if (!use_node->expr) return NULL; + + if (!parse_use_stmt_internal(parser, use_node)) return NULL; + if (use_node->expr->kind == Ast_Kind_Package) { ENTITY_SUBMIT(use_node); return NULL; @@ -3667,6 +3677,17 @@ static AstImport* parse_import_statement(OnyxParser* parser, OnyxToken *token) { import_node->imported_package = package_node; + if (parser->curr->type == '{') { + AstUse *use_node = make_node(AstUse, Ast_Kind_Use); + use_node->token = parser->curr; + use_node->expr = (AstTyped *) package_node; + + if (!parse_use_stmt_internal(parser, use_node)) return NULL; + + import_node->implicit_use_node = use_node; + ENTITY_SUBMIT(use_node); + } + return import_node; } diff --git a/tests/aoc-2020/day10.onyx b/tests/aoc-2020/day10.onyx index ca1a654a..001d4fc8 100644 --- a/tests/aoc-2020/day10.onyx +++ b/tests/aoc-2020/day10.onyx @@ -1,7 +1,6 @@ #load "core/std" -#import core -use core +#import core {*} count_ending_paths :: (nums: [..] u32) -> u64 { tally := array.make(u64, nums.count); diff --git a/tests/aoc-2020/day12.onyx b/tests/aoc-2020/day12.onyx index 8decca70..e57cbe51 100644 --- a/tests/aoc-2020/day12.onyx +++ b/tests/aoc-2020/day12.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Ship :: struct { x : i32 = 0; diff --git a/tests/aoc-2020/day13.onyx b/tests/aoc-2020/day13.onyx index ece1646c..f695a1d1 100644 --- a/tests/aoc-2020/day13.onyx +++ b/tests/aoc-2020/day13.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} inv_mod :: (a_: i64, m_: i64) -> i64 { if m_ <= 1 do return 0; diff --git a/tests/aoc-2020/day14.onyx b/tests/aoc-2020/day14.onyx index f031e09b..37828521 100644 --- a/tests/aoc-2020/day14.onyx +++ b/tests/aoc-2020/day14.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} MASK_SIZE :: 36 Bitmask :: [MASK_SIZE] u8; diff --git a/tests/aoc-2020/day15.onyx b/tests/aoc-2020/day15.onyx index 1d543650..76795087 100644 --- a/tests/aoc-2020/day15.onyx +++ b/tests/aoc-2020/day15.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} initial_numbers := u32.[ 1, 20, 8, 12, 0, 14 ]; diff --git a/tests/aoc-2020/day16.onyx b/tests/aoc-2020/day16.onyx index d1c29117..1e3be230 100644 --- a/tests/aoc-2020/day16.onyx +++ b/tests/aoc-2020/day16.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Field :: struct { name : str = ""; diff --git a/tests/aoc-2020/day18.onyx b/tests/aoc-2020/day18.onyx index f690de0d..70d9206d 100644 --- a/tests/aoc-2020/day18.onyx +++ b/tests/aoc-2020/day18.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} parse_factor :: (file: &str) -> u64 { string.strip_leading_whitespace(file); diff --git a/tests/aoc-2020/day19.onyx b/tests/aoc-2020/day19.onyx index da06eabb..62907f7a 100644 --- a/tests/aoc-2020/day19.onyx +++ b/tests/aoc-2020/day19.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} // nt -> t Term :: struct { diff --git a/tests/aoc-2020/day2.onyx b/tests/aoc-2020/day2.onyx index d523ac1a..6d0f8cfd 100644 --- a/tests/aoc-2020/day2.onyx +++ b/tests/aoc-2020/day2.onyx @@ -2,7 +2,7 @@ package main #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { contents := #file_contents "./tests/aoc-2020/input/day2.txt"; diff --git a/tests/aoc-2020/day20.onyx b/tests/aoc-2020/day20.onyx index c116d713..58f8be71 100644 --- a/tests/aoc-2020/day20.onyx +++ b/tests/aoc-2020/day20.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} TILE_DATA_WIDTH :: 10 TILE_DATA_HEIGHT :: 10 diff --git a/tests/aoc-2020/day21.onyx b/tests/aoc-2020/day21.onyx index 01fdfedf..791bca19 100644 --- a/tests/aoc-2020/day21.onyx +++ b/tests/aoc-2020/day21.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} /* What questions the data layout needs to answer easily: diff --git a/tests/aoc-2020/day22.onyx b/tests/aoc-2020/day22.onyx index fdbbf7b3..69a73ee7 100644 --- a/tests/aoc-2020/day22.onyx +++ b/tests/aoc-2020/day22.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} key_arena : alloc.arena.ArenaState; key_alloc : Allocator; diff --git a/tests/aoc-2020/day23.onyx b/tests/aoc-2020/day23.onyx index 6440e6dd..24973d9d 100644 --- a/tests/aoc-2020/day23.onyx +++ b/tests/aoc-2020/day23.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} cups : [..] i32; diff --git a/tests/aoc-2020/day24.onyx b/tests/aoc-2020/day24.onyx index 06367a2d..2b930623 100644 --- a/tests/aoc-2020/day24.onyx +++ b/tests/aoc-2020/day24.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Vec2 :: struct { x: i32 = 0; diff --git a/tests/aoc-2020/day25.onyx b/tests/aoc-2020/day25.onyx index 60f7fee3..0f0078e0 100644 --- a/tests/aoc-2020/day25.onyx +++ b/tests/aoc-2020/day25.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} power_mod :: (base: u32, exp: u32, mod: u32) -> u32 { t: u64 = 1; diff --git a/tests/aoc-2020/day3.onyx b/tests/aoc-2020/day3.onyx index 7eb37a47..2b03522c 100644 --- a/tests/aoc-2020/day3.onyx +++ b/tests/aoc-2020/day3.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Point :: struct { x, y : i32; diff --git a/tests/aoc-2020/day4.onyx b/tests/aoc-2020/day4.onyx index bb2a01db..089934f0 100644 --- a/tests/aoc-2020/day4.onyx +++ b/tests/aoc-2020/day4.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} // Returns the number of fields process_passport :: (contents: &str) -> u32 { diff --git a/tests/aoc-2020/day5.onyx b/tests/aoc-2020/day5.onyx index b2adef19..7fdb64ec 100644 --- a/tests/aoc-2020/day5.onyx +++ b/tests/aoc-2020/day5.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { contents := #file_contents "./tests/aoc-2020/input/day5.txt"; diff --git a/tests/aoc-2020/day6.onyx b/tests/aoc-2020/day6.onyx index c79d69a4..5835e20a 100644 --- a/tests/aoc-2020/day6.onyx +++ b/tests/aoc-2020/day6.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} part_1 :: (contents: &str) -> u32 { chars : [26] bool; diff --git a/tests/aoc-2020/day7.onyx b/tests/aoc-2020/day7.onyx index fb9055e3..eaccf477 100644 --- a/tests/aoc-2020/day7.onyx +++ b/tests/aoc-2020/day7.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} BagGraph :: struct { nodes : [..] &BagNode; diff --git a/tests/aoc-2020/day8.onyx b/tests/aoc-2020/day8.onyx index e9e1bd6e..92c5417b 100644 --- a/tests/aoc-2020/day8.onyx +++ b/tests/aoc-2020/day8.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} OpCode :: enum (u16) { Nop; Acc; Jmp; diff --git a/tests/aoc-2020/day9.onyx b/tests/aoc-2020/day9.onyx index 9e619c32..9e869b6a 100644 --- a/tests/aoc-2020/day9.onyx +++ b/tests/aoc-2020/day9.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} find_contiguous_subarray_with_sum :: (nums: [..] u64, sum: u64) -> (i32, i32) { start := 0; diff --git a/tests/aoc-2021/day01.onyx b/tests/aoc-2021/day01.onyx index 838b3e5f..e227592d 100644 --- a/tests/aoc-2021/day01.onyx +++ b/tests/aoc-2021/day01.onyx @@ -1,6 +1,8 @@ #load "core/std" -use package core +#import core.io +#import core.os +#import core {printf} count_increasing :: (arr: [] $T) -> u32 { increased_count := 0; diff --git a/tests/aoc-2021/day02.onyx b/tests/aoc-2021/day02.onyx index 9c0c55ac..34c353ef 100644 --- a/tests/aoc-2021/day02.onyx +++ b/tests/aoc-2021/day02.onyx @@ -1,8 +1,6 @@ PART :: 2 -#load "core/std" - -use package core +#import core {*} main :: (args) => { for file: os.with_file("tests/aoc-2021/input/day02.txt") { diff --git a/tests/aoc-2021/day03.onyx b/tests/aoc-2021/day03.onyx index 7510252e..fcaa57a8 100644 --- a/tests/aoc-2021/day03.onyx +++ b/tests/aoc-2021/day03.onyx @@ -2,7 +2,7 @@ PART :: 2 #load "core/std" -use package core +#import core {*} read_binary :: (r: &io.Reader) -> i32 { n := 0; diff --git a/tests/aoc-2021/day04.onyx b/tests/aoc-2021/day04.onyx index 4d639b2b..0bf7f8e2 100644 --- a/tests/aoc-2021/day04.onyx +++ b/tests/aoc-2021/day04.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Cell :: u8 diff --git a/tests/aoc-2021/day05.onyx b/tests/aoc-2021/day05.onyx index 47d68fb9..eadadbec 100644 --- a/tests/aoc-2021/day05.onyx +++ b/tests/aoc-2021/day05.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Line :: struct { x1, y1: i32; diff --git a/tests/aoc-2021/day06.onyx b/tests/aoc-2021/day06.onyx index 37c607e6..8dfe61b9 100644 --- a/tests/aoc-2021/day06.onyx +++ b/tests/aoc-2021/day06.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args) => { for file: os.with_file("./tests/aoc-2021/input/day06.txt") { diff --git a/tests/aoc-2021/day07.onyx b/tests/aoc-2021/day07.onyx index 452cd1e5..3d7bfada 100644 --- a/tests/aoc-2021/day07.onyx +++ b/tests/aoc-2021/day07.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args) => { for file: os.with_file("./tests/aoc-2021/input/day07.txt") { diff --git a/tests/aoc-2021/day08.onyx b/tests/aoc-2021/day08.onyx index e6dbc762..9c89487a 100644 --- a/tests/aoc-2021/day08.onyx +++ b/tests/aoc-2021/day08.onyx @@ -1,7 +1,7 @@ PART :: 2 #load "core/std" -use package core +#import core {*} // Encoded segments // diff --git a/tests/aoc-2021/day09.onyx b/tests/aoc-2021/day09.onyx index f954a54a..83e438d1 100644 --- a/tests/aoc-2021/day09.onyx +++ b/tests/aoc-2021/day09.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Pos :: struct {x,y: i32;} #match hash.to_u32 (use p: Pos) => x * 13 & 17 * y; diff --git a/tests/aoc-2021/day10.onyx b/tests/aoc-2021/day10.onyx index ab810730..7a3da0bc 100644 --- a/tests/aoc-2021/day10.onyx +++ b/tests/aoc-2021/day10.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args) => { for file: os.with_file("./tests/aoc-2021/input/day10.txt") { diff --git a/tests/aoc-2021/day11.onyx b/tests/aoc-2021/day11.onyx index 59451f9d..9baff835 100644 --- a/tests/aoc-2021/day11.onyx +++ b/tests/aoc-2021/day11.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Pos :: struct {x, y:i32;} #match hash.to_u32 (use p: Pos) => x * 45238271 + y * 34725643; diff --git a/tests/aoc-2021/day12.onyx b/tests/aoc-2021/day12.onyx index a525d855..8d42a94b 100644 --- a/tests/aoc-2021/day12.onyx +++ b/tests/aoc-2021/day12.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Communative_Pair :: struct (T: type_expr) where hash.Hashable(T) { a, b: T; diff --git a/tests/aoc-2021/day13.onyx b/tests/aoc-2021/day13.onyx index 7876fb02..b1dcf4d9 100644 --- a/tests/aoc-2021/day13.onyx +++ b/tests/aoc-2021/day13.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Point :: struct { x, y: i32; diff --git a/tests/aoc-2021/day14.onyx b/tests/aoc-2021/day14.onyx index aa4e3361..843e95d0 100644 --- a/tests/aoc-2021/day14.onyx +++ b/tests/aoc-2021/day14.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Rule :: struct { pair: Pair(u8, u8); diff --git a/tests/aoc-2021/day15.onyx b/tests/aoc-2021/day15.onyx index c05ca031..9fd783cb 100644 --- a/tests/aoc-2021/day15.onyx +++ b/tests/aoc-2021/day15.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} queued :: struct { x, y: i32; cost: i32; }; #operator == (u1, u2: queued) => u1.x == u2.x && u1.y == u2.y; diff --git a/tests/aoc-2021/day16.onyx b/tests/aoc-2021/day16.onyx index 941d4abd..afbbe24d 100644 --- a/tests/aoc-2021/day16.onyx +++ b/tests/aoc-2021/day16.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} base16_to_hex :: (s: str) -> u32 { res := 0; diff --git a/tests/aoc-2021/day17.onyx b/tests/aoc-2021/day17.onyx index 529bfbba..cd917f69 100644 --- a/tests/aoc-2021/day17.onyx +++ b/tests/aoc-2021/day17.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} tx0: i32 ty0: i32 diff --git a/tests/array_struct_robustness.onyx b/tests/array_struct_robustness.onyx index de454d54..a7184776 100644 --- a/tests/array_struct_robustness.onyx +++ b/tests/array_struct_robustness.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Vec2 :: struct { x: i32; y: i32; } diff --git a/tests/atomics.onyx b/tests/atomics.onyx index 2bc90761..4eb7fd17 100644 --- a/tests/atomics.onyx +++ b/tests/atomics.onyx @@ -1,8 +1,8 @@ #load "core/std" #load "core/intrinsics/atomics" -use package core -use package core.intrinsics.atomics +#import core {*} +#import core.intrinsics.atomics {*} Shared_Data :: struct { arr: [] i32; diff --git a/tests/auto_poly.onyx b/tests/auto_poly.onyx index 186c01b4..2a38250e 100644 --- a/tests/auto_poly.onyx +++ b/tests/auto_poly.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} dumb :: (it: Iterator, m: &Map) { println(it.Iter_Type); diff --git a/tests/avl_test.onyx b/tests/avl_test.onyx index ab818a3a..6575cde0 100644 --- a/tests/avl_test.onyx +++ b/tests/avl_test.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: () { tree: &avl_tree.AVL_Tree(i32); diff --git a/tests/baked_parameters.onyx b/tests/baked_parameters.onyx index eaf0d603..f43a7159 100644 --- a/tests/baked_parameters.onyx +++ b/tests/baked_parameters.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} count_to :: ($N: i32) { for i: 0 .. N do printf("{} ", i); diff --git a/tests/better_field_accesses.onyx b/tests/better_field_accesses.onyx index df0fe17f..f46d20f4 100644 --- a/tests/better_field_accesses.onyx +++ b/tests/better_field_accesses.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Foo :: struct { x, y: i32; diff --git a/tests/bucket_array.onyx b/tests/bucket_array.onyx index 3e06092a..85ca8601 100644 --- a/tests/bucket_array.onyx +++ b/tests/bucket_array.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { ba := bucket_array.make(i32, 4); diff --git a/tests/bugs/anonymous_struct_defaults.onyx b/tests/bugs/anonymous_struct_defaults.onyx index 81a8d338..519d7c95 100644 --- a/tests/bugs/anonymous_struct_defaults.onyx +++ b/tests/bugs/anonymous_struct_defaults.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} S :: struct { some_array: [..] struct { diff --git a/tests/bugs/defer_block_in_macro.onyx b/tests/bugs/defer_block_in_macro.onyx index 091f6e31..46aac22b 100644 --- a/tests/bugs/defer_block_in_macro.onyx +++ b/tests/bugs/defer_block_in_macro.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} test_macro :: macro () { defer { diff --git a/tests/bugs/fallthrough_defer_interaction.onyx b/tests/bugs/fallthrough_defer_interaction.onyx index f57c9a78..2d2a001f 100644 --- a/tests/bugs/fallthrough_defer_interaction.onyx +++ b/tests/bugs/fallthrough_defer_interaction.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} custom_iterator :: () -> Iterator(i32) { diff --git a/tests/bugs/macro_auto_return_not_resolved.onyx b/tests/bugs/macro_auto_return_not_resolved.onyx index 691ed8fb..38f1865b 100644 --- a/tests/bugs/macro_auto_return_not_resolved.onyx +++ b/tests/bugs/macro_auto_return_not_resolved.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Point :: struct { x, y: i32; } diff --git a/tests/bugs/namespace_aliasing.onyx b/tests/bugs/namespace_aliasing.onyx index 94582312..519d8a31 100644 --- a/tests/bugs/namespace_aliasing.onyx +++ b/tests/bugs/namespace_aliasing.onyx @@ -1,5 +1,5 @@ #load "core/std" -use package core +#import core {*} SomeNamespace :: struct { foo :: () { diff --git a/tests/caller_location.onyx b/tests/caller_location.onyx index fe27a40c..91615d44 100644 --- a/tests/caller_location.onyx +++ b/tests/caller_location.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} using_callsite :: (value: $T, site := #callsite) { println(value); @@ -25,4 +25,4 @@ Something :: struct { } } -#local runtime :: package runtime +#import runtime diff --git a/tests/compile_time_procedures.onyx b/tests/compile_time_procedures.onyx index c9f6e656..88d3f130 100644 --- a/tests/compile_time_procedures.onyx +++ b/tests/compile_time_procedures.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Test_VTable :: struct { first : (i32) -> i32; diff --git a/tests/complicated_polymorph.onyx b/tests/complicated_polymorph.onyx index 9c985dfb..e28c1ad7 100644 --- a/tests/complicated_polymorph.onyx +++ b/tests/complicated_polymorph.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { baked_proc :: (x: $T, $func: (T) -> typeof x) -> T { diff --git a/tests/defer_with_continue.onyx b/tests/defer_with_continue.onyx index 6594a51a..bbf58fff 100644 --- a/tests/defer_with_continue.onyx +++ b/tests/defer_with_continue.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { defer println("At the end!"); diff --git a/tests/defined_test.onyx b/tests/defined_test.onyx index 3cc44f55..fffb5852 100644 --- a/tests/defined_test.onyx +++ b/tests/defined_test.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { println(#defined(stdio)); diff --git a/tests/float_parsing.onyx b/tests/float_parsing.onyx index 3d31942e..4e3ac070 100644 --- a/tests/float_parsing.onyx +++ b/tests/float_parsing.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { diff --git a/tests/i32map.onyx b/tests/i32map.onyx index db403f76..a8e06d5f 100644 --- a/tests/i32map.onyx +++ b/tests/i32map.onyx @@ -2,7 +2,7 @@ package main #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { imap : Map(i32, str); diff --git a/tests/implicit_initialize_locals.onyx b/tests/implicit_initialize_locals.onyx index 677bd23f..4c099ce2 100644 --- a/tests/implicit_initialize_locals.onyx +++ b/tests/implicit_initialize_locals.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args) => { { diff --git a/tests/init_procedures.onyx b/tests/init_procedures.onyx index 225075aa..b5ba5a32 100644 --- a/tests/init_procedures.onyx +++ b/tests/init_procedures.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} first_init :: #init #after second_init () { println("In an #init proc."); diff --git a/tests/lazy_iterators.onyx b/tests/lazy_iterators.onyx index 8f6fff7d..604cfaba 100644 --- a/tests/lazy_iterators.onyx +++ b/tests/lazy_iterators.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} count_iterator :: (lo: $T, hi: T, step: T = 1) -> Iterator(T) { return iter.generator( diff --git a/tests/named_arguments_test.onyx b/tests/named_arguments_test.onyx index 36eb0506..26bd8e05 100644 --- a/tests/named_arguments_test.onyx +++ b/tests/named_arguments_test.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { foo :: (x: i32, y: f32) { diff --git a/tests/new_printf.onyx b/tests/new_printf.onyx index 07711f83..2887e871 100644 --- a/tests/new_printf.onyx +++ b/tests/new_printf.onyx @@ -1,7 +1,7 @@ #load "core/std" -#import core +#import core {printf, map} main :: (args: [] cstr) { - core.printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str)); + printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str)); } diff --git a/tests/new_struct_behaviour.onyx b/tests/new_struct_behaviour.onyx index 5bd6382d..ac00bb4e 100644 --- a/tests/new_struct_behaviour.onyx +++ b/tests/new_struct_behaviour.onyx @@ -2,7 +2,7 @@ #load "core/std" -use package core +#import core {*} Vec3 :: struct { diff --git a/tests/operator_overload.onyx b/tests/operator_overload.onyx index 2bf51ab6..72df5149 100644 --- a/tests/operator_overload.onyx +++ b/tests/operator_overload.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Complex :: struct { re : f32 = 0; diff --git a/tests/overload_precedence.onyx b/tests/overload_precedence.onyx index 07f4197c..54752d70 100644 --- a/tests/overload_precedence.onyx +++ b/tests/overload_precedence.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} overloaded :: #match { #order 10 (x: i32) { println("Option X"); }, diff --git a/tests/persist_locals.onyx b/tests/persist_locals.onyx index 835dab2f..7902615d 100644 --- a/tests/persist_locals.onyx +++ b/tests/persist_locals.onyx @@ -2,7 +2,7 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { diff --git a/tests/poly_struct_in_type_info.onyx b/tests/poly_struct_in_type_info.onyx index 6a022568..bd58c0c8 100644 --- a/tests/poly_struct_in_type_info.onyx +++ b/tests/poly_struct_in_type_info.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core -info :: package runtime.info + +#import core {*} +#import runtime.info Base :: struct (T: type_expr) { const: i32; diff --git a/tests/poly_structs_with_values.onyx b/tests/poly_structs_with_values.onyx index 21d6b932..f865277a 100644 --- a/tests/poly_structs_with_values.onyx +++ b/tests/poly_structs_with_values.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { NewPolyStruct :: struct (T: type_expr, N: i32) { diff --git a/tests/polymorphic_array_lengths.onyx b/tests/polymorphic_array_lengths.onyx index 8ec8c4a3..526102b1 100644 --- a/tests/polymorphic_array_lengths.onyx +++ b/tests/polymorphic_array_lengths.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { arr := u32.[ 1, 2, 3, 4, 5 ]; diff --git a/tests/remove_test.onyx b/tests/remove_test.onyx index be929078..398e37a0 100644 --- a/tests/remove_test.onyx +++ b/tests/remove_test.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args) => { x: [..] i32; diff --git a/tests/sets.onyx b/tests/sets.onyx index bea6234f..4d435566 100644 --- a/tests/sets.onyx +++ b/tests/sets.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { diff --git a/tests/struct_robustness.onyx b/tests/struct_robustness.onyx index 43165758..410d99c4 100644 --- a/tests/struct_robustness.onyx +++ b/tests/struct_robustness.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} main :: (args: [] cstr) { diff --git a/tests/struct_use_pointer_member.onyx b/tests/struct_use_pointer_member.onyx index a2806513..51925dd1 100644 --- a/tests/struct_use_pointer_member.onyx +++ b/tests/struct_use_pointer_member.onyx @@ -1,5 +1,5 @@ #load "core/std" -use package core +#import core {*} Person_Vtable :: struct { greet: (&Person) -> void; diff --git a/tests/switch_using_equals.onyx b/tests/switch_using_equals.onyx index 9eb512e9..6443aa05 100644 --- a/tests/switch_using_equals.onyx +++ b/tests/switch_using_equals.onyx @@ -1,6 +1,6 @@ #load "core/std" -use package core +#import core {*} Vector2 :: struct { x, y: i32; } #operator == macro (v1: Vector2, v2: Vector2) => v1.x == v2.x && v1.y == v2.y; diff --git a/tests/vararg_test.onyx b/tests/vararg_test.onyx index 34ca9c55..c6ceac85 100644 --- a/tests/vararg_test.onyx +++ b/tests/vararg_test.onyx @@ -2,7 +2,7 @@ package main #load "core/std" -use package core; +#import core {*}; old_va_test :: (prefix: str, va: ..i32) { println(prefix); -- 2.25.1