From: Brendan Hansen Date: Sun, 28 Aug 2022 17:59:41 +0000 (-0500) Subject: 'package builtin' is now just the global scope; cleanup X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=af978b6b200e1b4532091bd5ab1890860dff8ff1;p=onyx.git 'package builtin' is now just the global scope; cleanup --- diff --git a/core/builtin.onyx b/core/builtin.onyx index 0b6fe9c2..1e523816 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -3,7 +3,6 @@ package builtin // CLEANUP: Should builtin.onyx really be including other files in the compilation? // Does that complicate things too much? #load "core/runtime/build_opts" -#local runtime :: package runtime str :: #type []u8; cstr :: #type ^u8; diff --git a/core/container/array.onyx b/core/container/array.onyx index ca36054c..e747fb5d 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -70,7 +70,7 @@ copy :: #match #locked { }, (arr: [] $T, allocator := context.allocator) -> [] T { - new_arr := make([] T, arr.count); + new_arr := builtin.make([] T, arr.count); for i: 0 .. arr.count do new_arr.data[i] = arr.data[i]; return new_arr; } diff --git a/core/container/map.onyx b/core/container/map.onyx index e12ebace..7ef7bb73 100644 --- a/core/container/map.onyx +++ b/core/container/map.onyx @@ -61,7 +61,7 @@ make :: ($Key: type_expr, $Value: type_expr, default := Value.{}) -> Map(Key, Va return map; } -#match (package builtin).__make_overload macro (x: ^Map($K, $V), allocator := context.allocator) => (package core.map).make(K, V); +#match __make_overload macro (x: ^Map($K, $V), allocator := context.allocator) => core.map.make(K, V); init :: (use map: ^Map($K, $V), default := V.{}) { __initialize(map); @@ -69,7 +69,7 @@ init :: (use map: ^Map($K, $V), default := V.{}) { allocator = context.allocator; default_value = default; - hashes = make([] u32, 8, allocator=allocator); + hashes = builtin.make([] u32, 8, allocator=allocator); array.fill(hashes, -1); array.init(^entries, allocator=allocator); @@ -208,7 +208,7 @@ format_map :: (output: ^conv.Format_Output, format: ^conv.Format, x: ^Map($K, $V rehash :: (use map: ^Map, new_size: i32) { memory.free_slice(^hashes, allocator); - hashes = make([] u32, new_size, allocator=allocator); + hashes = builtin.make([] u32, new_size, allocator=allocator); array.fill(hashes, -1); for ^entry: entries do entry.next = -1; diff --git a/core/container/set.onyx b/core/container/set.onyx index c758f0ad..6ec63f4d 100644 --- a/core/container/set.onyx +++ b/core/container/set.onyx @@ -189,7 +189,7 @@ iterator :: (set: ^Set($T)) -> Iterator(T) { rehash :: (use set: ^Set, new_size: i32) { memory.free_slice(^hashes, allocator); - hashes = make([] u32, new_size, allocator=allocator); + hashes = builtin.make([] u32, new_size, allocator=allocator); array.fill(hashes, -1); for ^entry: entries do entry.next = -1; diff --git a/misc/onyx.sublime-syntax b/misc/onyx.sublime-syntax index 54a08a3e..a2365ed7 100644 --- a/misc/onyx.sublime-syntax +++ b/misc/onyx.sublime-syntax @@ -29,7 +29,7 @@ contexts: # strings in YAML. When using single quoted strings, only single quotes # need to be escaped: this is done by using two single quotes next to each # other. - - match: '\b(package|struct|interface|use|where|global|enum|if|elseif|else|for|while|do|break|continue|fallthrough|return|as|cast|sizeof|alignof|typeof|defer|switch|case|macro)\b' + - match: '\b(package|struct|interface|use|where|global|enum|if|elseif|else|for|while|do|break|continue|fallthrough|return|cast|sizeof|alignof|typeof|defer|switch|case|macro)\b' scope: keyword.control.onyx - match: '\b(bool|void|i8|u8|i16|u16|i32|u32|i64|u64|f32|f64|rawptr|str|cstr|range|type_expr|any)\b' diff --git a/misc/onyx.vim b/misc/onyx.vim index 67e93fbf..631208ee 100644 --- a/misc/onyx.vim +++ b/misc/onyx.vim @@ -15,7 +15,7 @@ syn keyword onyxKeyword if elseif else where interface syn keyword onyxKeyword for while do syn keyword onyxKeyword switch case syn keyword onyxKeyword break continue return defer fallthrough -syn keyword onyxKeyword as cast sizeof alignof typeof +syn keyword onyxKeyword cast sizeof alignof typeof syn keyword onyxType bool void syn keyword onyxType i8 u8 syn keyword onyxType i16 u16 diff --git a/misc/vscode/onyx-0.0.3.vsix b/misc/vscode/onyx-0.0.3.vsix index bb16dd8f..ba5d5157 100644 Binary files a/misc/vscode/onyx-0.0.3.vsix and b/misc/vscode/onyx-0.0.3.vsix differ diff --git a/misc/vscode/out/ovmDebug.js b/misc/vscode/out/ovmDebug.js index 38de655a..5c66268d 100644 --- a/misc/vscode/out/ovmDebug.js +++ b/misc/vscode/out/ovmDebug.js @@ -195,7 +195,7 @@ class OVMDebugSession extends debugadapter_1.LoggingDebugSession { this.running_process.stdout.on("data", (chunk) => { this.sendEvent(new debugadapter_1.OutputEvent(chunk, "console")); }); - this.attachRequest(response, { "socketPath": "/tmp/ovm-debug.0000", "stopOnEntry": true }); + this.attachRequest(response, { "socketPath": "/tmp/ovm-debug.0000", "stopOnEntry": args.stopOnEntry }); } attachRequest(response, args, request) { return __awaiter(this, void 0, void 0, function* () { diff --git a/misc/vscode/ovmDebug.ts b/misc/vscode/ovmDebug.ts index c24237c3..08d85494 100644 --- a/misc/vscode/ovmDebug.ts +++ b/misc/vscode/ovmDebug.ts @@ -267,7 +267,7 @@ export class OVMDebugSession extends LoggingDebugSession { this.sendEvent(new OutputEvent(chunk, "console")); }); - this.attachRequest(response, {"socketPath": "/tmp/ovm-debug.0000", "stopOnEntry": true}); + this.attachRequest(response, {"socketPath": "/tmp/ovm-debug.0000", "stopOnEntry": args.stopOnEntry}); } protected async attachRequest(response: DebugProtocol.AttachResponse, args: IOVMAttachRequestArguments, request?: DebugProtocol.Request): Promise { diff --git a/src/parser.c b/src/parser.c index e98ffd16..82ca91b9 100644 --- a/src/parser.c +++ b/src/parser.c @@ -3464,12 +3464,6 @@ void onyx_parse(OnyxParser *parser) { parser->file_scope = scope_create(parser->allocator, parser->package->private_scope, parser->tokenizer->tokens[0].pos); parser->current_scope = parser->file_scope; - AstUse* implicit_use_builtin = make_node(AstUse, Ast_Kind_Use); - AstPackage* implicit_builtin_package = make_node(AstPackage, Ast_Kind_Package); - implicit_builtin_package->package_name = "builtin"; - implicit_use_builtin->expr = (AstTyped *) implicit_builtin_package; - ENTITY_SUBMIT(implicit_use_builtin); - parse_top_level_statements_until(parser, Token_Type_End_Stream); parser->current_scope = parser->current_scope->parent; diff --git a/src/utils.c b/src/utils.c index 3036aab9..8c6c259b 100644 --- a/src/utils.c +++ b/src/utils.c @@ -39,10 +39,16 @@ Package* package_lookup_or_create(char* package_name, Scope* parent_scope, bh_al pac_name[strlen(package_name)] = '\0'; package->name = pac_name; - package->scope = scope_create(alloc, parent_scope, (OnyxFilePos) { 0 }); - package->private_scope = scope_create(alloc, package->scope, (OnyxFilePos) { 0 }); package->use_package_entities = NULL; + if (!strcmp(pac_name, "builtin")) { + package->private_scope = scope_create(alloc, context.global_scope, pos); + package->scope = context.global_scope; + } else { + package->scope = scope_create(alloc, parent_scope, pos); + package->private_scope = scope_create(alloc, package->scope, pos); + } + shput(context.packages, pac_name, package); if (!charset_contains(pac_name, '.')) {