package-type imports
This commit is contained in:
+16
-14
@@ -2,27 +2,20 @@ package compiler
|
||||
|
||||
import "./backend"
|
||||
import "./checker"
|
||||
import "./lexer"
|
||||
import "./llvm"
|
||||
import "./loader"
|
||||
import "./lower"
|
||||
import "./opt"
|
||||
import "./parser"
|
||||
import "./source"
|
||||
import "core:fmt"
|
||||
import vmem "core:mem/virtual"
|
||||
import "core:os"
|
||||
import "core:os/os2"
|
||||
|
||||
compile_file :: proc(input_path, output_path: string) -> int {
|
||||
source_bytes, ok := os.read_entire_file(input_path)
|
||||
if !ok {
|
||||
fmt.eprintln("failed to read input:", input_path)
|
||||
return 2
|
||||
}
|
||||
defer delete(source_bytes)
|
||||
|
||||
source_file := source.Source{path=input_path, text=string(source_bytes)}
|
||||
diagnostics := source.init_diagnostics(&source_file)
|
||||
compile_package :: proc(input_path, output_path: string) -> int {
|
||||
sources := source.init_store()
|
||||
defer source.destroy_store(&sources)
|
||||
diagnostics := source.init_store_diagnostics(&sources)
|
||||
defer source.destroy_diagnostics(&diagnostics)
|
||||
|
||||
lexer_arena: vmem.Arena
|
||||
@@ -50,8 +43,17 @@ compile_file :: proc(input_path, output_path: string) -> int {
|
||||
}
|
||||
defer vmem.arena_destroy(&lower_arena)
|
||||
|
||||
tokens := lexer.lex(&source_file, &diagnostics, vmem.arena_allocator(&lexer_arena))
|
||||
ast_module := parser.parse(&tokens, &diagnostics, vmem.arena_allocator(&parser_arena))
|
||||
ast_module, loaded := loader.load(
|
||||
input_path,
|
||||
&sources,
|
||||
&diagnostics,
|
||||
vmem.arena_allocator(&lexer_arena),
|
||||
vmem.arena_allocator(&parser_arena),
|
||||
)
|
||||
if !loaded {
|
||||
fmt.eprintln("failed to load root package directory:", input_path)
|
||||
return 2
|
||||
}
|
||||
vmem.arena_free_all(&lexer_arena)
|
||||
hir_module := checker.check(&ast_module, &diagnostics, vmem.arena_allocator(&checker_arena))
|
||||
vmem.arena_free_all(&parser_arena)
|
||||
|
||||
Reference in New Issue
Block a user