More work towards the new API
This commit is contained in:
23
Codegen.jai
23
Codegen.jai
@@ -38,9 +38,13 @@ Codegen_Result :: struct {
|
||||
}
|
||||
|
||||
init_codegen_state :: (state : *Codegen_State, root : *AST_Node, checker_result : Semantic_Check_Result, output_language : Output_Language) {
|
||||
init_codegen_state(state, root, checker_result.scope_stack, checker_result.type_variables, output_language);
|
||||
}
|
||||
|
||||
init_codegen_state :: (state : *Codegen_State, root : *AST_Node, scope_stack : Scope_Stack, type_vars : [..]Type_Variable, output_language : Output_Language) {
|
||||
state.root = root;
|
||||
state.scope_stack = checker_result.scope_stack;
|
||||
state.type_variables = checker_result.type_variables;
|
||||
state.scope_stack = scope_stack;
|
||||
state.type_variables = type_vars;
|
||||
state.current_scope = cast(Scope_Handle)1;
|
||||
state.output_language = output_language;
|
||||
init_string_builder(*state.builder);
|
||||
@@ -504,6 +508,21 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
|
||||
}
|
||||
}
|
||||
|
||||
codegen :: (result : *Compile_Result) {
|
||||
for *file : result.files {
|
||||
state : Codegen_State;
|
||||
init_codegen_state(*state, file.ast_root, file.scope_stack, file.type_variables, .HLSL);
|
||||
|
||||
codegen(*state);
|
||||
|
||||
file.output_text = state.result.result_text; // need to copy at some point. This whole thing is messy...
|
||||
|
||||
copy_messages(state.result.messages, *result.messages);
|
||||
|
||||
print("OUTPUT: \n\n%\n\n", file.output_text);
|
||||
}
|
||||
}
|
||||
|
||||
codegen :: (state : *Codegen_State) -> Codegen_Result {
|
||||
found_function : bool = false;
|
||||
// found_struct : bool = false;
|
||||
|
||||
Reference in New Issue
Block a user