c interop type foundation
This commit is contained in:
+31
-1
@@ -2,6 +2,7 @@ package hir
|
||||
|
||||
import "../source"
|
||||
import "../symbol"
|
||||
import "../target"
|
||||
import "../types"
|
||||
import "core:mem"
|
||||
|
||||
@@ -74,11 +75,27 @@ Linkage :: enum u8 {
|
||||
Expr_Kind :: enum u8 {
|
||||
Invalid,
|
||||
Integer,
|
||||
Float,
|
||||
String,
|
||||
Array,
|
||||
Struct,
|
||||
None,
|
||||
Optional_Some,
|
||||
Local,
|
||||
Global,
|
||||
Address,
|
||||
Deref,
|
||||
Index,
|
||||
Slice,
|
||||
Field,
|
||||
Length,
|
||||
Slice_Ptr,
|
||||
Unwrap,
|
||||
Orelse,
|
||||
Widen,
|
||||
Negate,
|
||||
Add,
|
||||
Pointer_Add,
|
||||
Call,
|
||||
}
|
||||
|
||||
@@ -114,6 +131,7 @@ Stmt :: struct {
|
||||
kind: Stmt_Kind,
|
||||
span: source.Span,
|
||||
local: Local_Id,
|
||||
target: Expr_Id,
|
||||
expr: Expr_Id,
|
||||
diagnostic: source.Diagnostic_Id,
|
||||
}
|
||||
@@ -153,16 +171,23 @@ Module :: struct {
|
||||
statements: [dynamic]Stmt,
|
||||
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.allocator = allocator
|
||||
module.exprs.allocator = allocator
|
||||
module.statements.allocator = allocator
|
||||
module.functions.allocator = allocator
|
||||
module.globals.allocator = allocator
|
||||
module.strings.allocator = allocator
|
||||
return module
|
||||
}
|
||||
|
||||
@@ -182,8 +207,13 @@ destroy_module :: proc(module: ^Module) {
|
||||
delete(global.dependencies)
|
||||
delete(global.calls, module.allocator)
|
||||
}
|
||||
for value in module.strings {
|
||||
delete(value, module.allocator)
|
||||
}
|
||||
delete(module.exprs)
|
||||
delete(module.statements)
|
||||
delete(module.functions)
|
||||
delete(module.globals)
|
||||
delete(module.strings)
|
||||
types.destroy_store(&module.types)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user