From 260d5db3c743aa8f59d0b3d5794ad76d1d57b39a Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 31 Oct 2022 07:50:46 -0500 Subject: [PATCH] experimentally loading core/std by default --- compiler/include/astnodes.h | 1 + compiler/src/onyx.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/compiler/include/astnodes.h b/compiler/include/astnodes.h index 0b336593..6258625a 100644 --- a/compiler/include/astnodes.h +++ b/compiler/include/astnodes.h @@ -1579,6 +1579,7 @@ struct CompileOptions { b32 use_post_mvp_features : 1; b32 use_multi_threading : 1; b32 generate_foreign_info : 1; + b32 no_std : 1; Runtime runtime; diff --git a/compiler/src/onyx.c b/compiler/src/onyx.c index 6f908e66..a629fa9e 100644 --- a/compiler/src/onyx.c +++ b/compiler/src/onyx.c @@ -74,6 +74,7 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg .use_post_mvp_features = 1, .use_multi_threading = 0, + .no_std = 0, .runtime = Runtime_Onyx, @@ -162,6 +163,9 @@ static CompileOptions compile_opts_parse(bh_allocator alloc, int argc, char *arg else if (!strcmp(argv[i], "--generate-foreign-info")) { options.generate_foreign_info = 1; } + else if (!strcmp(argv[i], "--no-std")) { + options.no_std = 1; + } else if (!strcmp(argv[i], "-I")) { bh_arr_push(options.included_folders, argv[++i]); } @@ -317,6 +321,15 @@ static void context_init(CompileOptions* opts) { AstInclude* load_node = create_load(context.ast_alloc, (char *) *filename); add_entities_for_node(NULL, (AstNode *) load_node, context.global_scope, NULL); } + + if (!context.options->no_std) { + entity_heap_insert(&context.entities, ((Entity) { + .state = Entity_State_Parse, + .type = Entity_Type_Load_File, + .package = NULL, + .include = create_load(context.ast_alloc, "core/std"), + })); + } } static void context_free() { -- 2.25.1