// #define BH_DEBUG
+
+extern struct bh_allocator global_heap_allocator;
+
+#define STBDS_REALLOC(_,p,s) (bh_resize(global_heap_allocator, p, s))
+#define STBDS_FREE(_,p) (bh_free(global_heap_allocator, p))
+
+#define BH_INTERNAL_ALLOCATOR (global_heap_allocator)
+
#define BH_DEFINE
#define BH_NO_TABLE
#define STB_DS_IMPLEMENTATION
}
#endif
+bh_managed_heap mh;
+
int main(int argc, char *argv[]) {
bh_scratch_init(&global_scratch, bh_heap_allocator(), 256 * 1024); // NOTE: 256 KiB
// were tracked and would be automatically freed at the end of execution.
// I don't know why I ever did that because that is the job of the operating
// system when a process exits.
- global_heap_allocator = bh_heap_allocator();
+ // global_heap_allocator = bh_heap_allocator();
+ bh_managed_heap_init(&mh);
+ global_heap_allocator = bh_managed_heap_allocator(&mh);
CompileOptions compile_opts = compile_opts_parse(global_heap_allocator, argc, argv);
context_init(&compile_opts);
context_free();
bh_scratch_free(&global_scratch);
- // bh_managed_heap_free(&global_heap);
+ bh_managed_heap_free(&mh);
return compiler_progress != ONYX_COMPILER_PROGRESS_SUCCESS;
}
// such as procedure definitions, string literals, struct definitions
// and declarations to be introduced into scopes.
+#include "parser.h"
#include "lex.h"
#include "errors.h"
-#include "parser.h"
#include "utils.h"
#define make_node(nclass, kind) onyx_ast_node_new(parser->allocator, sizeof(nclass), kind)
bh_arr_new(global_heap_allocator, parser.current_symbol_stack, 4);
bh_arr_new(global_heap_allocator, parser.scope_flags, 4);
bh_arr_new(global_heap_allocator, parser.stored_tags, 4);
+ bh_arr_new(global_heap_allocator, parser.current_function_stack, 4);
return parser;
}
bh_arr_free(parser->current_symbol_stack);
bh_arr_free(parser->scope_flags);
bh_arr_free(parser->stored_tags);
+ bh_arr_free(parser->current_function_stack);
}
void onyx_parse(OnyxParser *parser) {
if (bh_arr_length(auto_vars) == 0) return 0;
+ bh_arr_new(global_heap_allocator, func->poly_params, bh_arr_length(auto_vars));
+
param_idx = 0;
bh_arr_each(AutoPolymorphVariable, apv, auto_vars) {
AstPolyParam pp;
bh_arr_new(alloc, module.elems, 4);
bh_arr_new(alloc, module.libraries, 4);
bh_arr_new(alloc, module.library_paths, 4);
+ bh_arr_new(alloc, module.for_remove_info, 4);
bh_arr_new(global_heap_allocator, module.return_location_stack, 4);
bh_arr_new(global_heap_allocator, module.structured_jump_target, 16);
#endif
#endif
+#ifndef BH_INTERNAL_ALLOCATOR
+ #define BH_INTERNAL_ALLOCATOR (bh_heap_allocator())
+#endif
+
// NOTE: For lseek64
#define _LARGEFILE64_SOURCE
b32 bh_dir_read(bh_dir dir, bh_dirent* out);
void bh_dir_close(bh_dir dir);
+
+
+b32 bh_wait_for_changes_in_directories(u32 count, char ** paths);
+
+
#endif
#define bh_arr(T) T*
#define bh__arrhead(arr) (((bh__arr *)(arr)) - 1)
-#define bh_arr_allocator(arr) (arr ? bh__arrhead(arr)->allocator : bh_heap_allocator())
+#define bh_arr_allocator(arr) (arr ? bh__arrhead(arr)->allocator : BH_INTERNAL_ALLOCATOR)
#define bh_arr_length(arr) (arr ? bh__arrhead(arr)->length : 0)
#define bh_arr_capacity(arr) (arr ? bh__arrhead(arr)->capacity : 0)
#define bh_arr_size(arr) (arr ? bh__arrhead(arr)->capacity * sizeof(*(arr)) : 0)
else
bh_snprintf(path, 512, "%s%s", relative_to, fn + 2);
- if (bh_file_exists(path)) return bh_path_get_full_name(path, bh_heap_allocator());
+ if (bh_file_exists(path)) return bh_path_get_full_name(path, BH_INTERNAL_ALLOCATOR);
return fn;
}
else
bh_snprintf(path, 512, "%s%s", *folder, fn);
- if (bh_file_exists(path)) return bh_path_get_full_name(path, bh_heap_allocator());
+ if (bh_file_exists(path)) return bh_path_get_full_name(path, BH_INTERNAL_ALLOCATOR);
}
}