Properly output compiled file instead of intermediate results in semcheck

This commit is contained in:
2025-08-20 21:07:14 +02:00
parent 382d790c5b
commit 01ffe9c73d
4 changed files with 106 additions and 351 deletions

View File

@@ -56,10 +56,10 @@ Reserved_GLSL_Words :: string.[
""
];
init_codegen_state :: (state : *Codegen_State, root : *AST_Node, checker_result : Semantic_Check_Result, output_language : Output_Language) {
state.root = root;
state.scope_stack = checker_result.scope_stack;
state.type_variables = checker_result.type_variables;
init_codegen_state :: (state : *Codegen_State, file : *Compiled_File, output_language : Output_Language) {
state.root = file.ast_root;
state.scope_stack = file.scope_stack;
state.type_variables = file.type_variables;
state.current_scope = cast(Scope_Handle)1;
state.output_language = output_language;
init_string_builder(*state.builder);
@@ -617,9 +617,8 @@ codegen :: (result : *Compile_Result) {
for *file : result.files {
state : Codegen_State;
// init_codegen_state(*state, file.ast_root, file.semantic_check_result, .HLSL);
init_codegen_state(*state, file, .HLSL);
//@Incomplete(nb): just call the codegen function for now with old result struct
codegen_result := codegen(*state);
file.codegen_result_text = copy_string(codegen_result.result_text);
@@ -666,9 +665,9 @@ codegen :: (state : *Codegen_State) -> Codegen_Result {
return state.result;
}
codegen :: (ast_root : *AST_Node, checker_result : Semantic_Check_Result, output_language : Output_Language) -> Codegen_Result {
codegen :: (file : *Compiled_File, output_language : Output_Language) -> Codegen_Result {
codegen_state : Codegen_State;
init_codegen_state(*codegen_state, ast_root, checker_result, output_language);
init_codegen_state(*codegen_state, file, output_language);
return codegen(*codegen_state);
}