extern variables and object-like macro consts

This commit is contained in:
2026-06-17 21:52:05 +02:00
parent f5605fd3ec
commit 19e9fbdd4b
33 changed files with 3136 additions and 116 deletions
+75 -7
View File
@@ -68,16 +68,59 @@ Alias :: struct {
}
Function :: struct {
name: string,
params: []Type_Id,
result: Type_Id,
variadic: bool,
reason: string,
name: string,
params: []Type_Id,
result: Type_Id,
variadic: bool,
link_name: string,
reason: string,
}
// Trampoline is a generated C wrapper that gives an external symbol to a
// `static inline` (or otherwise internal-linkage) C function so brolang can
// call it. The wrapper is compiled and linked alongside the program. `source`
// is the wrapper function only; `header` is the absolute path the wrapper must
// `#include`, emitted once per unique header by the driver.
Trampoline :: struct {
symbol: string,
source: string,
header: string,
}
Variable :: struct {
name: string,
type: Type_Id,
mutable: bool,
reason: string,
}
Macro_Value_Kind :: enum u8 {
Invalid,
Integer,
Float,
}
Macro_Value :: struct {
kind: Macro_Value_Kind,
type: Type_Id,
integer: u64,
negative: bool,
}
Macro_Constant :: struct {
name: string,
type: Type_Id,
type_name: string,
value: Macro_Value,
values: []Macro_Value,
aggregate: bool,
reason: string,
}
Unsupported :: struct {
name: string,
reason: string,
name: string,
reason: string,
final_macro: bool,
}
Result :: struct {
@@ -85,7 +128,10 @@ Result :: struct {
records: [dynamic]Record,
aliases: [dynamic]Alias,
functions: [dynamic]Function,
variables: [dynamic]Variable,
macros: [dynamic]Macro_Constant,
unsupported: [dynamic]Unsupported,
trampolines: [dynamic]Trampoline,
error_message: string,
infrastructure: bool,
available: bool,
@@ -99,7 +145,10 @@ init_result :: proc(allocator := context.allocator) -> Result {
result.records.allocator = allocator
result.aliases.allocator = allocator
result.functions.allocator = allocator
result.variables.allocator = allocator
result.macros.allocator = allocator
result.unsupported.allocator = allocator
result.trampolines.allocator = allocator
return result
}
@@ -123,18 +172,37 @@ destroy_result :: proc(result: ^Result) {
for function in result.functions {
delete(function.name, result.allocator)
delete(function.params, result.allocator)
delete(function.link_name, result.allocator)
delete(function.reason, result.allocator)
}
for variable in result.variables {
delete(variable.name, result.allocator)
delete(variable.reason, result.allocator)
}
for macro in result.macros {
delete(macro.name, result.allocator)
delete(macro.type_name, result.allocator)
delete(macro.values, result.allocator)
delete(macro.reason, result.allocator)
}
for item in result.unsupported {
delete(item.name, result.allocator)
delete(item.reason, result.allocator)
}
for trampoline in result.trampolines {
delete(trampoline.symbol, result.allocator)
delete(trampoline.source, result.allocator)
delete(trampoline.header, result.allocator)
}
delete(result.error_message, result.allocator)
delete(result.types)
delete(result.records)
delete(result.aliases)
delete(result.functions)
delete(result.variables)
delete(result.macros)
delete(result.unsupported)
delete(result.trampolines)
}
Request :: struct {
File diff suppressed because it is too large Load Diff