aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.c')
-rw-r--r--src/compiler.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler.c b/src/compiler.c
index bcb36c3..d3e4e80 100644
--- a/src/compiler.c
+++ b/src/compiler.c
@@ -144,16 +144,25 @@ static void* thread_callback_parse_file(void *userdata) {
/* TODO: Handle errors (stop resolving ast in all other threads and report errors/warnings) */
static void* thread_callback_resolve_ast(void *userdata) {
- Parser *parser;
CompilerAstResolverThreadUserData compiler_ast_resolver_userdata;
+ Parser *parser;
+ AstCompilerContext compiler_context;
assert(!amal_thread_is_main());
am_memcpy(&compiler_ast_resolver_userdata, userdata, sizeof(compiler_ast_resolver_userdata));
am_free(userdata);
parser = compiler_ast_resolver_userdata.parser;
+ compiler_context.parser = parser;
for(;;) {
+ int result;
amal_log_debug("Resolving AST for file: %.*s", parser->tokenizer.code_name.size, parser->tokenizer.code_name.data);
- scope_resolve(&parser->scope);
+ result = setjmp(compiler_context.env);
+ if(result == 0)
+ scope_resolve(&parser->scope, &compiler_context);
+ else {
+ /* TODO: stop resolving ast in all other threads */
+ break;
+ }
cleanup_if_error(amal_mutex_lock(&compiler_ast_resolver_userdata.compiler->mutex, "thread_callback_resolve_ast"));
if(compiler_ast_resolver_userdata.compiler->resolve_ast_index + 1 >= (int)buffer_get_size(&compiler_ast_resolver_userdata.compiler->parsers, Parser))
break;
@@ -284,7 +293,7 @@ static CHECK_RESULT int amal_compiler_resolve_ast(amal_compiler *self) {
thread_work_data.type = THREAD_WORK_RESOLVE_AST;
thread_work_data.value.parser = parser;
return_if_error(amal_compiler_select_thread_for_work(self, thread_work_data, &thread_selected));
- /* After all threads have been used, they will handle using the remaining parsers */
+ /* After all threads have been used, they will handle using the remaining parsers or stop if there is an error */
if(!thread_selected)
break;
}