@@ -137,12 +137,9 @@ onyx_context_t *onyx_context_create() {
137
137
prepare_builtins (context );
138
138
compiler_events_init (context );
139
139
140
- // Options should be moved directly inside of the context instead of through a pointer...
141
- context -> options = malloc (sizeof (* context -> options ));
142
- memset (context -> options , 0 , sizeof (* context -> options ));
143
- context -> options -> use_post_mvp_features = 1 ;
144
- context -> options -> enable_optional_semicolons = 1 ;
145
- context -> options -> generate_type_info = 1 ;
140
+ context -> options .use_post_mvp_features = 1 ;
141
+ context -> options .enable_optional_semicolons = 1 ;
142
+ context -> options .generate_type_info = 1 ;
146
143
147
144
OnyxFilePos internal_location = { 0 };
148
145
internal_location .filename = "<compiler internal>" ;
@@ -175,8 +172,7 @@ void onyx_context_free(onyx_context_t *ctx) {
175
172
bh_scratch_free (& context -> scratch );
176
173
bh_managed_heap_free (& context -> heap );
177
174
178
- bh_arr_free (context -> options -> mapped_folders );
179
- free (context -> options );
175
+ bh_arr_free (context -> options .mapped_folders );
180
176
free (ctx );
181
177
182
178
HACK_global_heap_allocator = NULL ;
@@ -212,7 +208,7 @@ static b32 process_source_file(Context *context, char* filename) {
212
208
213
209
bh_arr_push (context -> loaded_files , fc );
214
210
215
- // if (context->options-> verbose_output == 2)
211
+ // if (context->options. verbose_output == 2)
216
212
// bh_printf("Processing source file: %s (%d bytes)\n", file.filename, fc.length);
217
213
218
214
parse_source_file (context , & bh_arr_last (context -> loaded_files ));
@@ -233,7 +229,7 @@ static b32 process_load_entity(Context *context, Entity* ent) {
233
229
include -> name ,
234
230
parent_folder ,
235
231
".onyx" ,
236
- context -> options -> mapped_folders ,
232
+ context -> options . mapped_folders ,
237
233
context -> gp_alloc
238
234
);
239
235
@@ -259,7 +255,7 @@ static b32 process_load_entity(Context *context, Entity* ent) {
259
255
include -> name ,
260
256
parent_folder ,
261
257
"" ,
262
- context -> options -> mapped_folders ,
258
+ context -> options . mapped_folders ,
263
259
context -> gp_alloc
264
260
);
265
261
bh_path_convert_separators (folder );
@@ -418,7 +414,7 @@ static void prime_pump(Context *context) {
418
414
.include = create_load (context , "core:runtime/build_opts" , -1 ),
419
415
}));
420
416
421
- if (context -> options -> runtime != Runtime_Custom ) {
417
+ if (context -> options . runtime != Runtime_Custom ) {
422
418
// HACK
423
419
context -> special_global_entities .remaining = 5 ;
424
420
@@ -461,7 +457,7 @@ static void prime_pump(Context *context) {
461
457
add_entities_for_node (& context -> entities , NULL , (AstNode * ) & context -> builtins .closure_base , context -> global_scope , NULL );
462
458
add_entities_for_node (& context -> entities , NULL , (AstNode * ) & context -> builtins .stack_trace , context -> global_scope , NULL );
463
459
464
- if (!context -> options -> no_core ) {
460
+ if (!context -> options . no_core ) {
465
461
entity_heap_insert (& context -> entities , ((Entity ) {
466
462
.state = Entity_State_Parse ,
467
463
.type = Entity_Type_Load_File ,
@@ -470,15 +466,15 @@ static void prime_pump(Context *context) {
470
466
}));
471
467
}
472
468
473
- if (context -> options -> generate_symbol_info_file ) {
469
+ if (context -> options . generate_symbol_info_file ) {
474
470
context -> symbol_info = bh_alloc_item (context -> gp_alloc , SymbolInfoTable );
475
471
bh_imap_init (& context -> symbol_info -> node_to_id , context -> gp_alloc , 512 );
476
472
bh_arr_new (context -> gp_alloc , context -> symbol_info -> symbols , 128 );
477
473
bh_arr_new (context -> gp_alloc , context -> symbol_info -> symbols_resolutions , 128 );
478
474
sh_new_arena (context -> symbol_info -> files );
479
475
}
480
476
481
- if (context -> options -> generate_odoc ) {
477
+ if (context -> options . generate_odoc ) {
482
478
context -> doc_info = bh_alloc_item (context -> gp_alloc , OnyxDocInfo );
483
479
memset (context -> doc_info , 0 , sizeof (OnyxDocInfo ));
484
480
bh_arr_new (context -> gp_alloc , context -> doc_info -> procedures , 128 );
@@ -517,7 +513,7 @@ onyx_pump_t onyx_pump(onyx_context_t *ctx) {
517
513
u64 perf_start ;
518
514
EntityType perf_entity_type ;
519
515
EntityState perf_entity_state ;
520
- if (context -> options -> running_perf ) {
516
+ if (context -> options . running_perf ) {
521
517
perf_start = bh_time_curr_micro ();
522
518
perf_entity_type = ent -> type ;
523
519
perf_entity_state = ent -> state ;
@@ -568,7 +564,7 @@ onyx_pump_t onyx_pump(onyx_context_t *ctx) {
568
564
if (ent -> state != Entity_State_Finalized && ent -> state != Entity_State_Failed )
569
565
entity_heap_insert_existing (& context -> entities , ent );
570
566
571
- if (context -> options -> running_perf ) {
567
+ if (context -> options . running_perf ) {
572
568
u64 perf_end = bh_time_curr_micro ();
573
569
574
570
u64 duration = perf_end - perf_start ;
@@ -660,23 +656,23 @@ int32_t onyx_set_option_bytes(onyx_context_t *ctx, onyx_option_t opt, char *valu
660
656
661
657
int32_t onyx_set_option_int (onyx_context_t * ctx , onyx_option_t opt , int32_t value ) {
662
658
switch (opt ) {
663
- case ONYX_OPTION_POST_MVP_FEATURES : ctx -> context .options -> use_post_mvp_features = value ; return 1 ;
664
- case ONYX_OPTION_MULTI_THREADING : ctx -> context .options -> use_multi_threading = value ; return 1 ;
665
- case ONYX_OPTION_GENERATE_FOREIGN_INFO : ctx -> context .options -> generate_foreign_info = value ; return 1 ;
666
- case ONYX_OPTION_GENERATE_TYPE_INFO : ctx -> context .options -> generate_type_info = value ; return 1 ;
667
- case ONYX_OPTION_GENERATE_METHOD_INFO : ctx -> context .options -> generate_method_info = value ; return 1 ;
668
- case ONYX_OPTION_GENERATE_DEBUG_INFO : ctx -> context .options -> debug_info_enabled = value ; return 1 ;
669
- case ONYX_OPTION_GENERATE_STACK_TRACE : ctx -> context .options -> stack_trace_enabled = value ; return 1 ;
670
- case ONYX_OPTION_GENERATE_NAME_SECTION : ctx -> context .options -> generate_name_section = value ; return 1 ;
671
- case ONYX_OPTION_GENERATE_SYMBOL_INFO : ctx -> context .options -> generate_symbol_info_file = value ; return 1 ;
672
- case ONYX_OPTION_GENERATE_LSP_INFO : ctx -> context .options -> generate_lsp_info_file = value ; return 1 ;
673
- case ONYX_OPTION_GENERATE_DOC_INFO : ctx -> context .options -> generate_odoc = value ; return 1 ;
674
- case ONYX_OPTION_DISABLE_CORE : ctx -> context .options -> no_core = value ; return 1 ;
675
- case ONYX_OPTION_DISABLE_STALE_CODE : ctx -> context .options -> no_stale_code = value ; return 1 ;
676
- case ONYX_OPTION_OPTIONAL_SEMICOLONS : ctx -> context .options -> enable_optional_semicolons = value ; return 1 ;
677
- case ONYX_OPTION_DISABLE_FILE_CONTENTS : ctx -> context .options -> no_file_contents = value ; return 1 ;
678
- case ONYX_OPTION_DISABLE_EXTENSIONS : ctx -> context .options -> no_compiler_extensions = value ; return 1 ;
679
- case ONYX_OPTION_PLATFORM : ctx -> context .options -> runtime = value ; return 1 ;
659
+ case ONYX_OPTION_POST_MVP_FEATURES : ctx -> context .options . use_post_mvp_features = value ; return 1 ;
660
+ case ONYX_OPTION_MULTI_THREADING : ctx -> context .options . use_multi_threading = value ; return 1 ;
661
+ case ONYX_OPTION_GENERATE_FOREIGN_INFO : ctx -> context .options . generate_foreign_info = value ; return 1 ;
662
+ case ONYX_OPTION_GENERATE_TYPE_INFO : ctx -> context .options . generate_type_info = value ; return 1 ;
663
+ case ONYX_OPTION_GENERATE_METHOD_INFO : ctx -> context .options . generate_method_info = value ; return 1 ;
664
+ case ONYX_OPTION_GENERATE_DEBUG_INFO : ctx -> context .options . debug_info_enabled = value ; return 1 ;
665
+ case ONYX_OPTION_GENERATE_STACK_TRACE : ctx -> context .options . stack_trace_enabled = value ; return 1 ;
666
+ case ONYX_OPTION_GENERATE_NAME_SECTION : ctx -> context .options . generate_name_section = value ; return 1 ;
667
+ case ONYX_OPTION_GENERATE_SYMBOL_INFO : ctx -> context .options . generate_symbol_info_file = value ; return 1 ;
668
+ case ONYX_OPTION_GENERATE_LSP_INFO : ctx -> context .options . generate_lsp_info_file = value ; return 1 ;
669
+ case ONYX_OPTION_GENERATE_DOC_INFO : ctx -> context .options . generate_odoc = value ; return 1 ;
670
+ case ONYX_OPTION_DISABLE_CORE : ctx -> context .options . no_core = value ; return 1 ;
671
+ case ONYX_OPTION_DISABLE_STALE_CODE : ctx -> context .options . no_stale_code = value ; return 1 ;
672
+ case ONYX_OPTION_OPTIONAL_SEMICOLONS : ctx -> context .options . enable_optional_semicolons = value ; return 1 ;
673
+ case ONYX_OPTION_DISABLE_FILE_CONTENTS : ctx -> context .options . no_file_contents = value ; return 1 ;
674
+ case ONYX_OPTION_DISABLE_EXTENSIONS : ctx -> context .options . no_compiler_extensions = value ; return 1 ;
675
+ case ONYX_OPTION_PLATFORM : ctx -> context .options . runtime = value ; return 1 ;
680
676
681
677
default :
682
678
break ;
@@ -711,7 +707,7 @@ void onyx_add_mapped_dir(onyx_context_t *ctx, char *mapped_name, int32_t mapped_
711
707
if (mapped_length < 0 ) mapped_length = strlen (mapped_name );
712
708
if (dir_length < 0 ) dir_length = strlen (dir );
713
709
714
- bh_arr_push (ctx -> context .options -> mapped_folders , ((bh_mapped_folder ) {
710
+ bh_arr_push (ctx -> context .options . mapped_folders , ((bh_mapped_folder ) {
715
711
bh_strdup_len (ctx -> context .ast_alloc , mapped_name , mapped_length ),
716
712
bh_strdup_len (ctx -> context .ast_alloc , dir , dir_length )
717
713
}));
0 commit comments