A bunch of new allocation related stuff.

This commit is contained in:
2025-09-10 06:59:29 +02:00
parent f4a9592f26
commit ceafd197f5
18 changed files with 852 additions and 170 deletions

View File

@@ -628,19 +628,31 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
}
codegen :: (result : *Compile_Result) {
codegen(result, .HLSL);
}
codegen :: (result : *Compile_Result, output_language : Output_Language, allocator := temp) {
if result.had_error {
return;
}
state : Codegen_State;
state.result = result;
state.current_scope = cast(Scope_Handle)1;
state.output_language = .HLSL;
init_string_builder(*state.builder);
codegen(*state);
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
state : Codegen_State;
state.result = result;
state.current_scope = cast(Scope_Handle)1;
state.output_language = output_language;
init_string_builder(*state.builder);
codegen(*state);
}
}
#scope_file
codegen :: (state : *Codegen_State) {
found_function : bool = false;
// found_struct : bool = false;
@@ -679,15 +691,5 @@ codegen :: (state : *Codegen_State) {
state.result.codegen_result_text = builder_to_string(*state.builder);
}
codegen :: (result : *Compile_Result, output_language : Output_Language) {
codegen_state : Codegen_State;
codegen_state.result = result;
codegen_state.current_scope = cast(Scope_Handle)1;
codegen_state.output_language = output_language;
init_string_builder(*codegen_state.builder);
codegen(*codegen_state);
}
#scope_module
#import "ncore";