diff --git a/Codegen.jai b/Codegen.jai index f1b1640..7f252e9 100644 --- a/Codegen.jai +++ b/Codegen.jai @@ -38,13 +38,9 @@ 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 = scope_stack; - state.type_variables = type_vars; + state.scope_stack = checker_result.scope_stack; + state.type_variables = checker_result.type_variables; state.current_scope = cast(Scope_Handle)1; state.output_language = output_language; init_string_builder(*state.builder); @@ -508,21 +504,6 @@ 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; diff --git a/Lexing.jai b/Lexing.jai index 2c4421c..3451623 100644 --- a/Lexing.jai +++ b/Lexing.jai @@ -499,12 +499,14 @@ scan_next_token :: (lexer : *Lexer) -> *Token { // return error_token(lexer, tprint("Invalid token: %", s)); } + + lex :: (result : *Compile_Result) { if result.had_error { return; } - for *file : result.files { + for file : result.files { lexer : Lexer; init_lexer_from_string(*lexer, file.file.source); token : *Token = scan_next_token(*lexer); @@ -512,7 +514,6 @@ lex :: (result : *Compile_Result) { token = scan_next_token(*lexer); } - file.tokens.tokens = lexer.result.tokens; // @Incomplete(nb): Temporary until we figure out a good way of passing this stuff around copy_messages(lexer.result.messages, *result.messages); } diff --git a/Semantic_Analysis.jai b/Semantic_Analysis.jai index 60a74ff..78d49d6 100644 --- a/Semantic_Analysis.jai +++ b/Semantic_Analysis.jai @@ -1651,37 +1651,6 @@ type_check :: (checker : *Semantic_Checker, root : *AST_Node) { traverse(checker, root); } -check :: (result : *Compile_Result) { - for *file : result.files { - checker : Semantic_Checker; - init_semantic_checker(*checker, file.ast_root, file.file.path); - check(*checker); - - //@Incomplete: Copy over the result from the checker result - - //@Note: Meh copy string... - file.vertex_entry_point = checker.result.vertex_entry_point; - file.pixel_entry_point = checker.result.pixel_entry_point; - - file.constant_buffers.array = checker.result.constant_buffers.array; - file.constant_buffers.count = checker.result.constant_buffers.count; - file.scope_stack.allocator = checker.result.scope_stack.allocator; - file.scope_stack.arena = checker.result.scope_stack.arena; - - file.scope_stack.stack.data = checker.result.scope_stack.stack.data; - file.scope_stack.stack.count = checker.result.scope_stack.stack.count; - - file.type_var_arena = checker.result.type_var_arena; - file.type_var_allocator = checker.result.type_var_allocator; - file.type_variables.data = checker.result.type_variables.data; - file.type_variables.count = checker.result.type_variables.count; - - file.property_name = copy_string(checker.result.property_name); - - copy_messages(checker.result.messages, *result.messages); - } -} - check :: (checker : *Semantic_Checker, root : *AST_Node) -> Semantic_Check_Result { checker.current_buffer_index = 0; checker.current_sampler_index = 0; diff --git a/Test.jai b/Test.jai index b1b6914..a32e3ad 100644 --- a/Test.jai +++ b/Test.jai @@ -407,10 +407,10 @@ run_codegen_test :: (path : string, output_type : Output_Type = 0) -> Result, Co return result, codegen_result; } -run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result { +run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compilation_Result { compiler : Shader_Compiler; result : Result; - compilation_result := compile_file(*compiler, .[path]); + compilation_result := compile_file(*compiler, path); print("\n"); if compilation_result.had_error { @@ -470,7 +470,7 @@ run_test :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Resul } if stage_flags & .Compile { - result, compilation_result := run_compile_test(file_path, output_type); + result = run_compile_test(file_path, output_type); } } diff --git a/module.jai b/module.jai index c24dfb9..647ff40 100644 --- a/module.jai +++ b/module.jai @@ -145,21 +145,7 @@ Compiled_File :: struct { file : Input_File; tokens : Token_Stream; ast_root : *AST_Node; - ast_nodes : [..]AST_Node; - - vertex_entry_point : *AST_Node; - pixel_entry_point : *AST_Node; - - constant_buffers : Static_Array(Type_Variable_Handle, 16); - - scope_stack : Scope_Stack; - type_variables : [..]Type_Variable; - type_var_arena : Arena; - type_var_allocator : Allocator; - - property_name : string; - - output_text : string; + ast_nodes : [..]AST_Node; } Compile_Result :: struct { @@ -382,9 +368,9 @@ compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Resul } lex(*result); - parse(*result); - check(*result); - codegen(*result); + // parse(*result); + // check(*result); + // codegen(*result); return result; }