stop compilation after checker errors
This commit is contained in:
@@ -29,6 +29,15 @@ write_escaped_c_string :: proc(builder: ^strings.Builder, value: string) {
|
||||
}
|
||||
}
|
||||
|
||||
has_errors :: proc(diagnostics: ^source.Diagnostics) -> bool {
|
||||
for diagnostic in diagnostics.items {
|
||||
if diagnostic.severity == .Error {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
compile_package :: proc(
|
||||
input_path, output_path: string,
|
||||
link_arguments: []linker.Argument = nil,
|
||||
@@ -142,6 +151,10 @@ compile_package :: proc(
|
||||
vmem.arena_free_all(&lexer_arena)
|
||||
hir_module := checker.check(&ast_module, &diagnostics, &symbols, selected, vmem.arena_allocator(&checker_arena))
|
||||
vmem.arena_free_all(&parser_arena)
|
||||
if has_errors(&diagnostics) {
|
||||
source.print_all(&diagnostics)
|
||||
return 1
|
||||
}
|
||||
ir_module := lower.lower(&hir_module, vmem.arena_allocator(&lower_arena))
|
||||
vmem.arena_free_all(&checker_arena)
|
||||
opt.run(&ir_module)
|
||||
@@ -149,6 +162,10 @@ compile_package :: proc(
|
||||
llvm_text := llvm.emit(&ir_module, &diagnostics, &symbols)
|
||||
defer delete(llvm_text)
|
||||
vmem.arena_free_all(&lower_arena)
|
||||
if has_errors(&diagnostics) {
|
||||
source.print_all(&diagnostics)
|
||||
return 1
|
||||
}
|
||||
llvm_path := fmt.tprintf("%s.brolang-%d.ll", output_path, os2.get_pid())
|
||||
defer _ = os.remove(llvm_path)
|
||||
if err := os.write_entire_file_or_err(llvm_path, transmute([]byte)llvm_text); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user