intern identifiers
This commit is contained in:
+14
-2
@@ -2,6 +2,7 @@ package llvm
|
||||
|
||||
import "../ir"
|
||||
import "../source"
|
||||
import "../symbol"
|
||||
import "../types"
|
||||
import "core:fmt"
|
||||
import "core:mem"
|
||||
@@ -14,6 +15,7 @@ Trap_Message :: struct {
|
||||
Emitter :: struct {
|
||||
module: ^ir.Module,
|
||||
diagnostics: ^source.Diagnostics,
|
||||
symbols: ^symbol.Table,
|
||||
builder: strings.Builder,
|
||||
messages: [dynamic]Trap_Message,
|
||||
allocator: mem.Allocator,
|
||||
@@ -271,7 +273,11 @@ emit_global_accessors :: proc(emitter: ^Emitter) {
|
||||
global_id,
|
||||
)
|
||||
strings.write_string(&emitter.builder, "check:\n %visiting = icmp eq i8 %state, 1\n br i1 %visiting, label %cycle, label %initialize\ncycle:\n")
|
||||
message_text := fmt.aprintf("runtime trap: global initialization cycle involving '%s'", global.name, allocator=emitter.allocator)
|
||||
message_text := fmt.aprintf(
|
||||
"runtime trap: global initialization cycle involving '%s'",
|
||||
symbol.resolve(emitter.symbols, global.name),
|
||||
allocator=emitter.allocator,
|
||||
)
|
||||
message := register_message(emitter, message_text)
|
||||
delete(message_text, emitter.allocator)
|
||||
emit_trap_call(emitter, message)
|
||||
@@ -366,10 +372,16 @@ emit_declarations :: proc(emitter: ^Emitter) {
|
||||
)
|
||||
}
|
||||
|
||||
emit :: proc(module: ^ir.Module, diagnostics: ^source.Diagnostics, allocator := context.allocator) -> string {
|
||||
emit :: proc(
|
||||
module: ^ir.Module,
|
||||
diagnostics: ^source.Diagnostics,
|
||||
symbols: ^symbol.Table,
|
||||
allocator := context.allocator,
|
||||
) -> string {
|
||||
emitter := Emitter{
|
||||
module=module,
|
||||
diagnostics=diagnostics,
|
||||
symbols=symbols,
|
||||
builder=strings.builder_make(allocator),
|
||||
allocator=allocator,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user