From 5df7f92e715ba764ee57f65d78e73111492bb64c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 20 Mar 2019 18:53:47 +0100 Subject: Add pub keyword, more import stuff, optimize hash map Hash map now stores hash of keys to reduce the number of hash operations. Positive: faster insert/get. Negative: more space required (to store usize hash). --- src/compiler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/compiler.c') diff --git a/src/compiler.c b/src/compiler.c index 8510a2c..6f9cc92 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -47,7 +47,7 @@ static CHECK_RESULT int create_default_type(amal_compiler *compiler, const char return_if_error(structdecl_init(struct_decl, &compiler->root_scope, &compiler->allocator)); return_if_error(scoped_allocator_alloc(&compiler->allocator, sizeof(LhsExpr), (void**)&lhs_expr)); - lhsexpr_init(lhs_expr, bool_true, create_buffer_view(name, strnlen(name, PATH_MAX))); + lhsexpr_init(lhs_expr, bool_true, bool_true, create_buffer_view(name, strnlen(name, PATH_MAX))); ast_init(&lhs_expr->rhs_expr, struct_decl, AST_STRUCT_DECL); ast_init(&expr, lhs_expr, AST_LHS); return scope_add_child(&compiler->root_scope, &expr); @@ -351,7 +351,6 @@ static CHECK_RESULT int amal_compiler_load_file_join_threads(amal_compiler *self ParserThreadData *parser_thread_data; bool work_failed; - result = AMAL_COMPILER_ERR; assert(amal_thread_is_main()); thread_return_data = NULL; work_failed = bool_false; @@ -449,6 +448,7 @@ int amal_compiler_load_file(amal_compiler *self, const char *filepath, FileScope bool new_entry; return_if_error(try_create_file_scope(self, filepath, file_scope, &new_entry)); + assert(file_scope && *file_scope && (*file_scope)->canonical_path.data); filepath_view = create_buffer_view((*file_scope)->canonical_path.data, (*file_scope)->canonical_path.size); if(!new_entry) { amal_log_info("amal_compiler_load_file: file already parsed: %.*s", filepath_view.size, filepath_view.data); -- cgit v1.2.3