c interop type foundation
This commit is contained in:
+29
-1
@@ -2,6 +2,7 @@ package ir
|
||||
|
||||
import "../source"
|
||||
import "../symbol"
|
||||
import "../target"
|
||||
import "../types"
|
||||
import "core:mem"
|
||||
|
||||
@@ -67,13 +68,28 @@ Linkage :: enum u8 {
|
||||
Opcode :: enum u8 {
|
||||
Param,
|
||||
Const,
|
||||
String,
|
||||
Aggregate,
|
||||
None,
|
||||
Optional_Some,
|
||||
Load_Global,
|
||||
Address_Global,
|
||||
Address_Of,
|
||||
Alloca,
|
||||
Index_Address,
|
||||
Field_Address,
|
||||
Load,
|
||||
Store,
|
||||
Slice,
|
||||
Length,
|
||||
Slice_Ptr,
|
||||
Unwrap,
|
||||
Orelse_Begin,
|
||||
Orelse,
|
||||
Widen,
|
||||
Neg_Checked,
|
||||
Add_Checked,
|
||||
Pointer_Add,
|
||||
Call,
|
||||
Trap,
|
||||
Return,
|
||||
@@ -117,13 +133,20 @@ Global :: struct {
|
||||
Module :: struct {
|
||||
functions: [dynamic]Function,
|
||||
globals: [dynamic]Global,
|
||||
strings: [dynamic]string,
|
||||
types: types.Store,
|
||||
target: target.Target,
|
||||
allocator: mem.Allocator,
|
||||
}
|
||||
|
||||
init_module :: proc(allocator := context.allocator) -> Module {
|
||||
init_module :: proc(selected := target.DEFAULT, allocator := context.allocator) -> Module {
|
||||
module: Module
|
||||
module.target = selected
|
||||
module.types = types.init_store(allocator)
|
||||
module.types.selected = selected
|
||||
module.functions.allocator = allocator
|
||||
module.globals.allocator = allocator
|
||||
module.strings.allocator = allocator
|
||||
module.allocator = allocator
|
||||
return module
|
||||
}
|
||||
@@ -144,6 +167,11 @@ destroy_module :: proc(module: ^Module) {
|
||||
for global in module.globals {
|
||||
destroy_instructions(global.initializer, module.allocator)
|
||||
}
|
||||
for value in module.strings {
|
||||
delete(value, module.allocator)
|
||||
}
|
||||
delete(module.functions)
|
||||
delete(module.globals)
|
||||
delete(module.strings)
|
||||
types.destroy_store(&module.types)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user