reflection foundation, tuples, debug.print
This commit is contained in:
@@ -630,13 +630,18 @@ lower_compound_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instructi
|
||||
|
||||
lower_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instruction_Id {
|
||||
stack := state.expr_stack
|
||||
state.expr_stack = nil
|
||||
clear_dynamic_array(&stack)
|
||||
defer {
|
||||
for frame in stack {
|
||||
delete(frame.args, state.allocator)
|
||||
}
|
||||
clear_dynamic_array(&stack)
|
||||
state.expr_stack = stack
|
||||
if state.expr_stack == nil {
|
||||
state.expr_stack = stack
|
||||
} else {
|
||||
delete(stack)
|
||||
}
|
||||
}
|
||||
append(&stack, Lower_Expr_Frame{expr=expr_id})
|
||||
last := ir.INVALID_INSTRUCTION
|
||||
@@ -1656,12 +1661,29 @@ append_injected_main :: proc(module: ^ir.Module, hir_module: ^hir.Module, alloca
|
||||
b=ir.INVALID_INSTRUCTION,
|
||||
diagnostic=source.INVALID_DIAGNOSTIC,
|
||||
})
|
||||
main_function := &hir_module.functions[main_index]
|
||||
param_index, param_ok := hir.index(main_function.params[0], hir.INVALID_LOCAL, len(main_function.locals))
|
||||
if !param_ok {
|
||||
return
|
||||
}
|
||||
init_args := make([]ir.Instruction_Id, 1, allocator)
|
||||
init_args[0] = provider_call
|
||||
init_value := ir.instruction_id(len(instructions))
|
||||
append(&instructions, ir.Instruction{
|
||||
op=.Aggregate,
|
||||
type=main_function.locals[param_index].type,
|
||||
args=init_args,
|
||||
target=ir.INVALID_REF,
|
||||
a=ir.INVALID_INSTRUCTION,
|
||||
b=ir.INVALID_INSTRUCTION,
|
||||
diagnostic=source.INVALID_DIAGNOSTIC,
|
||||
})
|
||||
args := make([]ir.Instruction_Id, 1, allocator)
|
||||
args[0] = provider_call
|
||||
args[0] = init_value
|
||||
main_call := ir.instruction_id(len(instructions))
|
||||
append(&instructions, ir.Instruction{
|
||||
op=.Call,
|
||||
type=hir_module.functions[main_index].result,
|
||||
type=main_function.result,
|
||||
args=args,
|
||||
target=ir.function_ref(ir.Function_Id(main_index)),
|
||||
a=ir.INVALID_INSTRUCTION,
|
||||
|
||||
Reference in New Issue
Block a user