From d77264637524901531f4be84c4787bcbd401c355 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 24 Mar 2023 23:03:32 -0500 Subject: [PATCH] added: `#import` at function scope; bugfix: numerous --- compiler/src/clone.c | 1 + compiler/src/lex.c | 1 - compiler/src/parser.c | 10 ++++++++++ compiler/src/symres.c | 4 ++++ core/builtin.onyx | 23 +++++++++++------------ core/conv/format.onyx | 2 +- core/intrinsics/atomics.onyx | 2 +- core/io/stdio.onyx | 4 ++-- core/misc/any_utils.onyx | 2 +- core/onyx/cptr.onyx | 2 +- core/os/file.onyx | 3 ++- core/random/random.onyx | 4 +++- core/runtime/info/helper.onyx | 4 +++- core/runtime/platform/onyx/platform.onyx | 7 ++++--- core/runtime/platform/wasi/env.onyx | 13 ++++++++----- core/runtime/platform/wasi/wasi_fs.onyx | 12 +++++++----- core/string/string.onyx | 24 ++++++++++++++++-------- docs/bugs | 2 +- examples/04_fixed_arrays.onyx | 3 ++- examples/05_slices.onyx | 3 ++- examples/06_dynamic_arrays.onyx | 3 ++- examples/07_structs.onyx | 3 ++- examples/08_enums.onyx | 3 ++- examples/10_switch_statements.onyx | 3 ++- examples/11_map.onyx | 3 ++- examples/12_varargs.onyx | 3 ++- examples/13_use_keyword.onyx | 9 +++++---- examples/14_overloaded_procs.onyx | 3 ++- examples/15_polymorphic_procs.onyx | 3 ++- examples/16_pipe_operator.onyx | 5 +++-- examples/17_operator_overload.onyx | 3 ++- examples/18_macros.onyx | 3 ++- examples/19_do_blocks.onyx | 3 ++- examples/20_auto_return.onyx | 3 ++- examples/21_quick_functions.onyx | 3 ++- examples/22_interfaces.onyx | 6 +++--- examples/50_misc.onyx | 3 ++- tests/aoc-2020/day1.onyx | 5 ++++- tests/aoc-2020/day10.onyx | 3 ++- tests/aoc-2020/day11.onyx | 3 ++- tests/hello_world.onyx | 3 ++- tests/if_expressions.onyx | 5 +++-- tests/interfaces.onyx | 8 +++++++- tests/multiple_returns_robustness.onyx | 3 ++- tests/new_printf.onyx | 4 ++-- tests/overload_with_autocast.onyx | 3 ++- tests/string_stream_test.onyx | 4 +++- 47 files changed, 148 insertions(+), 81 deletions(-) diff --git a/compiler/src/clone.c b/compiler/src/clone.c index f0c02fab..28b8f64a 100644 --- a/compiler/src/clone.c +++ b/compiler/src/clone.c @@ -117,6 +117,7 @@ static inline i32 ast_kind_to_size(AstNode* node) { case Ast_Kind_Directive_Remove: return sizeof(AstDirectiveRemove); case Ast_Kind_Directive_First: return sizeof(AstDirectiveFirst); case Ast_Kind_Directive_Export_Name: return sizeof(AstDirectiveExportName); + case Ast_Kind_Import: return sizeof(AstImport); case Ast_Kind_Count: return 0; } diff --git a/compiler/src/lex.c b/compiler/src/lex.c index 4458c485..7bf9aa1f 100644 --- a/compiler/src/lex.c +++ b/compiler/src/lex.c @@ -38,7 +38,6 @@ static const char* token_type_names[] = { "macro", "interface", "where", - "import", "", // end "->", diff --git a/compiler/src/parser.c b/compiler/src/parser.c index 2cf8a1a0..174566f3 100644 --- a/compiler/src/parser.c +++ b/compiler/src/parser.c @@ -566,6 +566,7 @@ static AstTyped* parse_factor(OnyxParser* parser) { } case Token_Type_Keyword_Package: { + onyx_report_warning(peek_token(-1)->pos, "Use of deprecated feature: package expression."); retval = (AstTyped *) parse_package_expression(parser); break; } @@ -1498,6 +1499,7 @@ static AstNode* parse_use_stmt(OnyxParser* parser) { 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 (consume_token_if_next(parser, '{')) { bh_arr_new(global_heap_allocator, use_node->only, 4); @@ -1726,6 +1728,14 @@ static AstNode* parse_statement(OnyxParser* parser) { break; } + if (parse_possible_directive(parser, "import")) { + // :LinearTokenDependent + retval = (AstNode *) parse_import_statement(parser, parser->curr - 2); + ENTITY_SUBMIT(retval); + needs_semicolon = 0; + break; + } + if (next_tokens_are(parser, 2, '#', Token_Type_Symbol)) { retval = (AstNode *) parse_factor(parser); break; diff --git a/compiler/src/symres.c b/compiler/src/symres.c index e75a09bb..6dd4299c 100644 --- a/compiler/src/symres.c +++ b/compiler/src/symres.c @@ -974,6 +974,10 @@ static SymresStatus symres_statement(AstNode** stmt, b32 *remove) { SYMRES(use, (AstUse *) *stmt); break; + case Ast_Kind_Import: + if (remove) *remove = 1; + break; + default: SYMRES(expression, (AstTyped **) stmt); break; } diff --git a/core/builtin.onyx b/core/builtin.onyx index fd6a4904..69fd374d 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -2,10 +2,6 @@ package builtin #import runtime -#if #defined(package core) { - #import core -} - // // Explanation of `package builtin` // @@ -201,6 +197,8 @@ default_log_level :: (level: Log_Level) { #if runtime.runtime != .Custom { #local default_logger_proc :: (logger: &Default_Logger, level: Log_Level, msg: str, module: str) { + #import core; + if level < logger.minimum_level do return; if module { @@ -267,12 +265,14 @@ cfree :: (ptr: rawptr) => raw_free(context.allocator, ptr); // This cannot be used in a custom runtime, as the other core // packages are not included. #if runtime.runtime != .Custom { + #import core + #import core.memory + new :: #match #local {} #overload new :: ($T: type_expr, allocator := context.allocator) -> &T { - use package core.intrinsics.onyx { __initialize } - memory :: package core.memory + use core.intrinsics.onyx { __initialize } res := cast(&T) raw_alloc(allocator, sizeof T); memory.set(res, 0, sizeof T); @@ -283,8 +283,7 @@ cfree :: (ptr: rawptr) => raw_free(context.allocator, ptr); #overload new :: (T: type_expr, allocator := context.allocator) -> rawptr { - memory :: package core.memory - type_info :: package runtime.info + type_info :: runtime.info info := type_info.get_type_info(T); size := type_info.size_of(T); @@ -451,12 +450,12 @@ Code :: struct {_:i32;} // remove some confusion around the 3 different array types as dynamic arrays would clearly just be // normal structures. With the recent addition of macros and iterators, there really wouldn't be much // difference anyway. -#if #defined((package core.map).Map) { - Map :: (package core.map).Map; +#if #defined(core.map.Map) { + Map :: core.map.Map; } -#if #defined((package core.set).Set) { - Set :: (package core.set).Set; +#if #defined(core.set.Set) { + Set :: core.set.Set; } diff --git a/core/conv/format.onyx b/core/conv/format.onyx index 90b70234..fee0e326 100644 --- a/core/conv/format.onyx +++ b/core/conv/format.onyx @@ -21,7 +21,7 @@ custom_formatters_initialized :: #init () { map.init(&custom_parsers, default=null_proc); #if Enable_Custom_Formatters { - use package runtime.info; + use runtime.info; for type_idx: type_table.count { type := type_table[type_idx]; diff --git a/core/intrinsics/atomics.onyx b/core/intrinsics/atomics.onyx index ed00b212..e10d26f7 100644 --- a/core/intrinsics/atomics.onyx +++ b/core/intrinsics/atomics.onyx @@ -1,7 +1,7 @@ package core.intrinsics.atomics #local { - runtime :: package runtime + #import runtime #if !runtime.Multi_Threading_Enabled { #error "Multi-threading is not enabled so you cannot include the 'core.intrinsics.atomics' package." diff --git a/core/io/stdio.onyx b/core/io/stdio.onyx index 8e5f602a..4d313039 100644 --- a/core/io/stdio.onyx +++ b/core/io/stdio.onyx @@ -1,8 +1,8 @@ // Currently, these symbols are dumped in the 'core' namespace, which means -// most programs that just 'use package core' can access all of them, which +// most programs that just 'use core' can access all of them, which // is convenient; However, it doesn't hurt to wonder if they should be the // 'core.io' package so these would become like 'io.printf(...)'. Of course, -// you could always still do 'use package core.io', which would bring these +// you could always still do 'use core.io', which would bring these // in anyway. package core diff --git a/core/misc/any_utils.onyx b/core/misc/any_utils.onyx index 88789a31..c1850f9b 100644 --- a/core/misc/any_utils.onyx +++ b/core/misc/any_utils.onyx @@ -127,7 +127,7 @@ any_to_map :: (v: any) -> (Map(str, any), success: bool) { any_iter :: (arr: any) -> Iterator(any) { base_ptr, elem_type, count := any_as_array(arr); if count == 0 { - return .{ null, ((_) => any.{}, false) }; + return .{ null, ((_: rawptr) => any.{}, false) }; } return iter.generator( diff --git a/core/onyx/cptr.onyx b/core/onyx/cptr.onyx index 6a474648..210a2fb1 100644 --- a/core/onyx/cptr.onyx +++ b/core/onyx/cptr.onyx @@ -70,7 +70,7 @@ cptr :: struct (T: type_expr) { // to the same idea as 'null' in Onyx. if this.data == 0 do return null; - wasm :: package core.intrinsics.wasm + #import core.intrinsics.wasm // Using 1 instead of 0 because a null pointer (0) converts // to the memory address 0, not the base address for the WASM // memory. diff --git a/core/os/file.onyx b/core/os/file.onyx index 9cfd9eae..27dbeac7 100644 --- a/core/os/file.onyx +++ b/core/os/file.onyx @@ -9,7 +9,8 @@ package core.os use core -#local fs :: package runtime.platform + +#local fs :: runtime.platform FileError :: enum { diff --git a/core/random/random.onyx b/core/random/random.onyx index 00df5f73..1431dfa7 100644 --- a/core/random/random.onyx +++ b/core/random/random.onyx @@ -1,5 +1,7 @@ package core.random +#import core + // // The state of a random number generator. Random :: struct { @@ -52,7 +54,7 @@ Random :: struct { // Returns a random string of length `bytes_long`. If `alpha_numeric` is // true, then the string will only consist of alpha-numeric characters. string :: (self: &Random, bytes_long: u32, alpha_numeric := false, allocator := context.allocator) -> str { - memory :: package core.memory + #import core.memory s := memory.make_slice(u8, bytes_long, allocator=allocator); for& s { diff --git a/core/runtime/info/helper.onyx b/core/runtime/info/helper.onyx index 39b85bf2..bae2f9aa 100644 --- a/core/runtime/info/helper.onyx +++ b/core/runtime/info/helper.onyx @@ -331,8 +331,10 @@ populate_struct_vtable :: (table: &$Table_Type, struct_type: type_expr, safe := } for_all_types :: macro (body: Code) { + #import runtime + for runtime.info.type_table.count { - type_info := (package runtime.info).type_table[it]; + type_info := runtime.info.type_table[it]; type_idx : type_expr = ~~ it; #unquote body; diff --git a/core/runtime/platform/onyx/platform.onyx b/core/runtime/platform/onyx/platform.onyx index 8fa49b97..55e2c55f 100644 --- a/core/runtime/platform/onyx/platform.onyx +++ b/core/runtime/platform/onyx/platform.onyx @@ -2,6 +2,7 @@ package runtime.platform #import core #import runtime +#import main use core use runtime { @@ -104,8 +105,8 @@ __start :: () { __runtime_initialize(); context.thread_id = 0; - #if (typeof (package main).main) == #type () -> void { - (package main).main(); + #if (typeof main.main) == #type () -> void { + main.main(); } else { args : [] cstr; @@ -116,7 +117,7 @@ __start :: () { argv_buf := cast(cstr) calloc(argv_buf_size); __args_get(args.data, argv_buf); - (package main).main(args); + main.main(args); } __flush_stdio(); diff --git a/core/runtime/platform/wasi/env.onyx b/core/runtime/platform/wasi/env.onyx index c1f7db36..24d8f0e7 100644 --- a/core/runtime/platform/wasi/env.onyx +++ b/core/runtime/platform/wasi/env.onyx @@ -1,16 +1,19 @@ package core.env -#local runtime :: package runtime +#import runtime +#import core.map +#import core.memory +#import core.string +#import wasi + + #if runtime.runtime != .Wasi && runtime.runtime != .Onyx { #error "'core.env' is only available with the 'wasi' and 'onyx' runtimes."; } -use package wasi { environ_get, environ_sizes_get, Size } -#package map :: package core.map -#package memory :: package core.memory -#package string :: package core.string +use wasi { environ_get, environ_sizes_get, Size } Environment :: struct { vars : Map(str, str); diff --git a/core/runtime/platform/wasi/wasi_fs.onyx b/core/runtime/platform/wasi/wasi_fs.onyx index c8ee8b20..6fcd7f33 100644 --- a/core/runtime/platform/wasi/wasi_fs.onyx +++ b/core/runtime/platform/wasi/wasi_fs.onyx @@ -1,14 +1,16 @@ package runtime.platform -#local runtime :: package runtime +#import runtime +#import core +#import wasi + +use core + #if runtime.runtime != .Wasi { #error "The file system library is currently only available on the WASI runtime, and should only be included if that is the chosen runtime." } -use package core - -#local wasi :: package wasi -use package wasi { +use wasi { FileDescriptor, FDFlags, OFlags, Rights, LookupFlags, Errno, diff --git a/core/string/string.onyx b/core/string/string.onyx index e643d840..bc45d71d 100644 --- a/core/string/string.onyx +++ b/core/string/string.onyx @@ -654,37 +654,45 @@ bisect :: (s: str, substr: str) -> (str, str) { // to_dyn_str :: (x: str, allocator := context.allocator) -> dyn_str { - return (package core.array).make(x, allocator); + #import core.array + return array.make(x, allocator); } delete :: macro (x: &dyn_str, idx: u32) -> u8 { - return (package core.array).delete(x, idx); + #import core.array + return array.delete(x, idx); } append :: #match { macro (x: &dyn_str, other: str) { - (package core.array).concat(x, other); + #import core.array + array.concat(x, other); }, macro (x: &dyn_str, other: u8) { - (package core.array).push(x, other); + #import core.array + array.push(x, other); }, } clear :: macro (x: &dyn_str) { - (package core.array).clear(x); + #import core.array + array.clear(x); } retreat :: macro (x: &dyn_str, chars := 1) { - (package core.array).pop(x, chars); + #import core.array + array.pop(x, chars); } insert :: #match #locked { macro (x: &dyn_str, idx: u32, new_str: str) -> bool { - return (package core.array).insert(x, idx, new_str); + #import core.array + return array.insert(x, idx, new_str); }, macro (x: &dyn_str, idx: u32, ch: u8) -> bool { - return (package core.array).insert(x, idx, ch); + #import core.array + return array.insert(x, idx, ch); } } diff --git a/docs/bugs b/docs/bugs index 10d44f07..bc056028 100644 --- a/docs/bugs +++ b/docs/bugs @@ -125,7 +125,7 @@ List of known bugs: use_package_breaking :: () { println("Test 1"); - use package foo + use foo println("Test 2"); } diff --git a/examples/04_fixed_arrays.onyx b/examples/04_fixed_arrays.onyx index b68f91dc..393c3928 100644 --- a/examples/04_fixed_arrays.onyx +++ b/examples/04_fixed_arrays.onyx @@ -17,7 +17,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // The following declares a fixed-size array of 10 i32s on the stack. Currently, diff --git a/examples/05_slices.onyx b/examples/05_slices.onyx index 1cc792ad..085f1c51 100644 --- a/examples/05_slices.onyx +++ b/examples/05_slices.onyx @@ -7,7 +7,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // A dummy array to demonstrate. diff --git a/examples/06_dynamic_arrays.onyx b/examples/06_dynamic_arrays.onyx index b307a414..2825d4cc 100644 --- a/examples/06_dynamic_arrays.onyx +++ b/examples/06_dynamic_arrays.onyx @@ -9,7 +9,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // Declaring dynamic arrays in Onyx looks like this. The diff --git a/examples/07_structs.onyx b/examples/07_structs.onyx index ff2b5926..e7bd2e43 100644 --- a/examples/07_structs.onyx +++ b/examples/07_structs.onyx @@ -7,7 +7,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { diff --git a/examples/08_enums.onyx b/examples/08_enums.onyx index 63449417..bc145828 100644 --- a/examples/08_enums.onyx +++ b/examples/08_enums.onyx @@ -6,7 +6,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // To declare a simple, use the enum keyword. diff --git a/examples/10_switch_statements.onyx b/examples/10_switch_statements.onyx index 9c9bec6c..cbfce526 100644 --- a/examples/10_switch_statements.onyx +++ b/examples/10_switch_statements.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { x := 10 + 3 * 5; diff --git a/examples/11_map.onyx b/examples/11_map.onyx index cc75c9fa..d3c9c6cc 100644 --- a/examples/11_map.onyx +++ b/examples/11_map.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // Onyx does not have map type built into the language semantics, diff --git a/examples/12_varargs.onyx b/examples/12_varargs.onyx index 12bf339e..649c5fda 100644 --- a/examples/12_varargs.onyx +++ b/examples/12_varargs.onyx @@ -17,7 +17,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { diff --git a/examples/13_use_keyword.onyx b/examples/13_use_keyword.onyx index cb30eac0..7edf73b3 100644 --- a/examples/13_use_keyword.onyx +++ b/examples/13_use_keyword.onyx @@ -16,7 +16,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // Here are the uses of 'use' currently. @@ -25,15 +26,15 @@ main :: (args: [] cstr) { // You can 'use' a package. You hopefully already knew this. // This brings in all the symbols from the core.alloc package into // this scope. - use package core.alloc + use core.alloc // You can also restrict and partially rename the symbols that collide - use package core.string { string_free :: free } + use core.string { string_free :: free } } { // You can also 'use' a package that is a subpackage of another package. Here, 'string' - // is a subpackage of 'core' and the above 'use package core' makes this package + // is a subpackage of 'core' and the above 'use core' makes this package // available for you to write code like 'string.equal(...)'. However, because it is // a namespace, you can 'use' it. use string diff --git a/examples/14_overloaded_procs.onyx b/examples/14_overloaded_procs.onyx index f60e9ae8..c555e693 100644 --- a/examples/14_overloaded_procs.onyx +++ b/examples/14_overloaded_procs.onyx @@ -34,7 +34,8 @@ #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { // See the overloaded procedure defined below. diff --git a/examples/15_polymorphic_procs.onyx b/examples/15_polymorphic_procs.onyx index c0e7013d..6fb1300d 100644 --- a/examples/15_polymorphic_procs.onyx +++ b/examples/15_polymorphic_procs.onyx @@ -59,7 +59,8 @@ compose :: (a: $A, f: (A) -> $B, g: (B) -> $C) -> C { #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { } diff --git a/examples/16_pipe_operator.onyx b/examples/16_pipe_operator.onyx index 107da554..ba69e6d8 100644 --- a/examples/16_pipe_operator.onyx +++ b/examples/16_pipe_operator.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core { println } +#import core +use core { println } main :: (args: [] cstr) { // These functions will be used to demo the pipe operator. @@ -34,4 +35,4 @@ main :: (args: [] cstr) { // It is not an operator you probably will not have to use very // often; But when you have code like the first println above, // it can clean up the code and make it easier to read. -} \ No newline at end of file +} diff --git a/examples/17_operator_overload.onyx b/examples/17_operator_overload.onyx index 96cac6a3..091c66b4 100644 --- a/examples/17_operator_overload.onyx +++ b/examples/17_operator_overload.onyx @@ -1,5 +1,6 @@ #load "core/std" -use package core +#import core +use core // Operator overloading allows you to define what it means to perform // a binary operation between two types. In Onyx, they are defined in diff --git a/examples/18_macros.onyx b/examples/18_macros.onyx index bc5941bf..e01ae472 100644 --- a/examples/18_macros.onyx +++ b/examples/18_macros.onyx @@ -135,4 +135,5 @@ main :: (args: [] cstr) { } #load "core/std" -use package core \ No newline at end of file +#import core +use core diff --git a/examples/19_do_blocks.onyx b/examples/19_do_blocks.onyx index 80631ecb..b4f47106 100644 --- a/examples/19_do_blocks.onyx +++ b/examples/19_do_blocks.onyx @@ -66,4 +66,5 @@ main :: (args: [] cstr) { } #load "core/std" -use package core +#import core +use core diff --git a/examples/20_auto_return.onyx b/examples/20_auto_return.onyx index 04139700..b72800f4 100644 --- a/examples/20_auto_return.onyx +++ b/examples/20_auto_return.onyx @@ -43,5 +43,6 @@ main :: (args: [] cstr) { } #load "core/std" -use package core +#import core +use core diff --git a/examples/21_quick_functions.onyx b/examples/21_quick_functions.onyx index d43abc84..bac0dc17 100644 --- a/examples/21_quick_functions.onyx +++ b/examples/21_quick_functions.onyx @@ -45,4 +45,5 @@ main :: (args) => { } #load "core/std" -use package core +#import core +use core diff --git a/examples/22_interfaces.onyx b/examples/22_interfaces.onyx index 1bf958af..5a0da1e8 100644 --- a/examples/22_interfaces.onyx +++ b/examples/22_interfaces.onyx @@ -135,6 +135,6 @@ main :: (args) => { } #load "core/std" - -use package core -use package core.intrinsics.onyx +#import core +use core +use core.intrinsics.onyx diff --git a/examples/50_misc.onyx b/examples/50_misc.onyx index 4b0e4b75..193c6bdb 100644 --- a/examples/50_misc.onyx +++ b/examples/50_misc.onyx @@ -67,4 +67,5 @@ main :: (args) => { } #load "core/std" -use package core +#import core +use core diff --git a/tests/aoc-2020/day1.onyx b/tests/aoc-2020/day1.onyx index 7162889a..1547b17f 100644 --- a/tests/aoc-2020/day1.onyx +++ b/tests/aoc-2020/day1.onyx @@ -1,6 +1,9 @@ #load "core/std" -use package core +#import core +#import core.io +#import core.array +use core {printf} main :: (args: [] cstr) { contents := #file_contents "./tests/aoc-2020/input/day1.txt"; diff --git a/tests/aoc-2020/day10.onyx b/tests/aoc-2020/day10.onyx index 8866633a..ca1a654a 100644 --- a/tests/aoc-2020/day10.onyx +++ b/tests/aoc-2020/day10.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core count_ending_paths :: (nums: [..] u32) -> u64 { tally := array.make(u64, nums.count); diff --git a/tests/aoc-2020/day11.onyx b/tests/aoc-2020/day11.onyx index ca09764b..f6ede0ff 100644 --- a/tests/aoc-2020/day11.onyx +++ b/tests/aoc-2020/day11.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core GameOfSeats :: struct { width : u32; diff --git a/tests/hello_world.onyx b/tests/hello_world.onyx index 88198e4f..d69e04b6 100644 --- a/tests/hello_world.onyx +++ b/tests/hello_world.onyx @@ -2,7 +2,8 @@ package main #load "core/std" -use package core +#import core +use core main :: (args: [] cstr) { println("Hello, World!"); diff --git a/tests/if_expressions.onyx b/tests/if_expressions.onyx index 050a26e1..b42b89b9 100644 --- a/tests/if_expressions.onyx +++ b/tests/if_expressions.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core {println, printf} some_function :: () -> f32 { println("In some function!"); @@ -27,4 +28,4 @@ main :: (args: [] cstr) { v: V2 = (.{ 10, 20 }) if true else .{ 30, 40 }; printf("{}\n", v); -} \ No newline at end of file +} diff --git a/tests/interfaces.onyx b/tests/interfaces.onyx index 83a2a92f..5134c42b 100644 --- a/tests/interfaces.onyx +++ b/tests/interfaces.onyx @@ -1,6 +1,12 @@ #load "core/std" -use package core +#import core +#import core.hash +#import core.conv +#import core.array +#import core.iter + +use core {println, printf} Hashable :: interface (t :$T) { { hash.to_u32(t) } -> u32; diff --git a/tests/multiple_returns_robustness.onyx b/tests/multiple_returns_robustness.onyx index 9ee7330e..8400200a 100644 --- a/tests/multiple_returns_robustness.onyx +++ b/tests/multiple_returns_robustness.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core foo :: () -> (i32, i32) { return 50, 60; diff --git a/tests/new_printf.onyx b/tests/new_printf.onyx index 19730868..07711f83 100644 --- a/tests/new_printf.onyx +++ b/tests/new_printf.onyx @@ -1,7 +1,7 @@ #load "core/std" -use package core +#import core main :: (args: [] cstr) { - printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str)); + core.printf("{} {} {{}} {} {.1} {.5} {}\n", 123, "Test", false, 12.34, 12.3456789, [..] map.Map(i32, str)); } diff --git a/tests/overload_with_autocast.onyx b/tests/overload_with_autocast.onyx index 2328fdb2..93ee4ee6 100644 --- a/tests/overload_with_autocast.onyx +++ b/tests/overload_with_autocast.onyx @@ -1,6 +1,7 @@ #load "core/std" -use package core +#import core +use core {println} overloaded :: #match { (x: str, y: i32) do println("Called str, i32"); , diff --git a/tests/string_stream_test.onyx b/tests/string_stream_test.onyx index 0e97c870..1eabe635 100644 --- a/tests/string_stream_test.onyx +++ b/tests/string_stream_test.onyx @@ -1,6 +1,8 @@ #load "core/std" -use package core +#import core +#import core.io +use core {println} main :: (args: [] cstr) { some_string := "This is a test string that can be read.\n\n\n\n\n\n1234 4567"; -- 2.25.1