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);
}

View File

@@ -127,25 +127,6 @@ Scope :: struct {
Scope_Handle :: #type, distinct u32;
Semantic_Check_Result :: struct {
messages : [..]Compiler_Message;
message_arena : Arena;
message_allocator : Allocator;
had_error : bool;
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;
}
Checker_State :: enum {
Type_Checking;
Adding_Builtins;
@@ -159,13 +140,16 @@ Semantic_Checker :: struct {
current_scope : Scope_Handle;
// type_variables : [..]Type_Variable;
result_file : *Compiled_File;
current_buffer_index : u32 = 0;
current_sampler_index : u32 = 0;
current_texture_index : u32 = 0;
result : Semantic_Check_Result;
messages : [..]Compiler_Message;
message_arena : Arena;
message_allocator : Allocator;
had_error : bool;
}
record_error :: (checker : *Semantic_Checker, message : string, source_location : Source_Range, report_source_location : bool = true) {
@@ -467,7 +451,7 @@ Attempting to access a field on a primitive type '%'.
init_string_builder(*builder,, temp);
variable := from_handle(checker, handle);
print_to_builder(*builder, "Attempting to access a field on a primitive type '%'.\n", proper_type_to_string(checker.result.type_variables, variable));
print_to_builder(*builder, "Attempting to access a field on a primitive type '%'.\n", proper_type_to_string(checker.result_file.type_variables, variable));
indent(*builder, 1);
cyan(*builder);
@@ -528,7 +512,7 @@ if_condition_has_to_be_boolean_type :: (checker : *Semantic_Checker, usage_site
usage_child := usage_site.children[0];
usage_loc := usage_child.source_location;
print_to_builder(*builder, "% has type %\n", print_from_source_location(*usage_loc), proper_type_to_string(checker.result.type_variables, var));
print_to_builder(*builder, "% has type %\n", print_from_source_location(*usage_loc), proper_type_to_string(checker.result_file.type_variables, var));
message := builder_to_string(*builder,, temp);
record_error(checker, message, usage_site.source_location, false);
@@ -570,7 +554,7 @@ type_mismatch :: (checker : *Semantic_Checker, usage_site : *AST_Node, expect_no
indent(*builder, 1);
print_to_builder(*builder, "expected:\n");
indent(*builder, 2);
proper_type_to_string(*builder, checker.result.type_variables, expect_var);
proper_type_to_string(*builder, checker.result_file.type_variables, expect_var);
append(*builder, "\n");
// indent(*builder, 2);
@@ -607,8 +591,8 @@ record_error :: (checker : *Semantic_Checker, error_string : string, locations :
error.path = checker.path;
error.message = error_string;
checker.result.had_error = true;
array_add(*checker.result.messages, error);
checker.had_error = true;
array_add(*checker.messages, error);
}
is_proper :: (var : Type_Variable) -> bool {
@@ -633,10 +617,10 @@ use_scope :: (checker : *Semantic_Checker, handle : Scope_Handle) -> Scope_Handl
push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Global) -> *Scope, Scope_Handle {
new_scope : Scope;
array_add(*checker.result.scope_stack.stack, new_scope);
array_add(*checker.result_file.scope_stack.stack, new_scope);
count := checker.result.scope_stack.stack.count;
scope := *checker.result.scope_stack.stack[count - 1];
count := checker.result_file.scope_stack.stack.count;
scope := *checker.result_file.scope_stack.stack[count - 1];
scope.parent = checker.current_scope;
scope.name = name;
scope.kind = kind;
@@ -644,7 +628,7 @@ push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Glo
scope.builtin = true;
}
scope.children.allocator = checker.result.scope_stack.allocator;
scope.children.allocator = checker.result_file.scope_stack.allocator;
if checker.current_scope {
scope := get_current_scope(checker);
@@ -667,12 +651,12 @@ pop_scope :: (checker : *Semantic_Checker) -> Scope_Handle {
}
peek_scope :: (checker : *Semantic_Checker) -> *Scope, Scope_Handle {
if checker.result.scope_stack.stack.count == 0 {
if checker.result_file.scope_stack.stack.count == 0 {
return null, 0;
}
count := checker.result.scope_stack.stack.count;
scope := *checker.result.scope_stack.stack[count - 1];
count := checker.result_file.scope_stack.stack.count;
scope := *checker.result_file.scope_stack.stack[count - 1];
return scope, xx count;
}
@@ -689,7 +673,7 @@ get_scope :: (scope_stack : Scope_Stack, handle : Scope_Handle) -> *Scope {
}
get_scope :: (checker : *Semantic_Checker, handle : Scope_Handle) -> *Scope {
return get_scope(*checker.result.scope_stack, handle);
return get_scope(*checker.result_file.scope_stack, handle);
}
add_symbol_to_scope :: (state : Checker_State, scope_stack : *Scope_Stack, scope_handle : Scope_Handle, name : string, symbol : Defined_Symbol) -> *Defined_Symbol {
@@ -711,8 +695,8 @@ add_symbol_to_scope :: (state : Checker_State, scope_stack : *Scope_Stack, scope
new_type_variable :: (checker : *Semantic_Checker) -> *Type_Variable, Type_Variable_Handle {
variable : Type_Variable;
handle := cast(Type_Variable_Handle)checker.result.type_variables.count + 1;
array_add(*checker.result.type_variables, variable);
handle := cast(Type_Variable_Handle)checker.result_file.type_variables.count + 1;
array_add(*checker.result_file.type_variables, variable);
return from_handle(checker, handle), handle;
}
@@ -735,17 +719,16 @@ init_semantic_checker :: (checker : *Semantic_Checker, root : *AST_Node, path :
checker.current_sampler_index = 0;
checker.current_texture_index = 0;
array_reserve(*checker.result.messages, 16);
array_reserve(*checker.messages, 16);
checker.program_root = root;
checker.path = path;
// @Incomplete(niels): Use other allocator and/or add static array with convenience functions
checker.result.type_var_allocator = make_arena(*checker.result.type_var_arena);
array_reserve(*checker.result.type_variables, 2048);
array_reserve(*checker.result_file.type_variables, 2048);
checker.result.scope_stack.allocator = make_arena(*checker.result.scope_stack.arena);
array_reserve(*checker.result.scope_stack.stack, 256);
checker.result_file.scope_stack.allocator = make_arena(*checker.result_file.scope_stack.arena);
array_reserve(*checker.result_file.scope_stack.stack, 256);
global_scope, global_handle := push_scope(checker, kind = .Global);
array_reserve(*global_scope.children, 2048);
@@ -771,7 +754,7 @@ find_symbol :: (scope_stack : Scope_Stack, name : string, current_scope : Scope_
}
find_symbol :: (checker : *Semantic_Checker, name : string, current_scope : Scope_Handle, containing_scope : *Scope_Handle = null) -> *Defined_Symbol {
return find_symbol(checker.result.scope_stack, name, current_scope, containing_scope);
return find_symbol(checker.result_file.scope_stack, name, current_scope, containing_scope);
}
find_symbol :: (name : string, checker : *Semantic_Checker, containing_scope : *Scope_Handle = null) -> *Defined_Symbol {
@@ -784,7 +767,7 @@ from_handle :: (variables : []Type_Variable, handle : Type_Variable_Handle) -> *
}
from_handle :: (checker : *Semantic_Checker, handle : Type_Variable_Handle) -> *Type_Variable {
return from_handle(checker.result.type_variables, handle);
return from_handle(checker.result_file.type_variables, handle);
}
proper_type_to_string :: (builder : *String_Builder, variables : []Type_Variable, var : Type_Variable) {
@@ -915,7 +898,7 @@ declare_struct :: (checker : *Semantic_Checker, node : *AST_Node, name : string)
symbol.name = name;
symbol.source_node = node;
symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.result.scope_stack, checker.current_scope, name, symbol);
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, name, symbol);
} else {
symbol_redeclaration(checker, node, find_result);
return 0;
@@ -950,7 +933,7 @@ declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Va
name := ifx node.name.count == 0 then "properties" else node.name;
if node.name.count > 0 {
checker.result.property_name = name;
checker.result_file.property_name = name;
}
type_var := declare_struct(checker, node, name);
var := from_handle(checker, type_var);
@@ -967,7 +950,7 @@ declare_cbuffer :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Varia
var.type = .CBuffer;
var.resource_index = checker.current_buffer_index;
checker.current_buffer_index += 1;
array_add(*checker.result.constant_buffers, type_var);
array_add(*checker.result_file.constant_buffers, type_var);
return type_var;
}
@@ -1003,11 +986,11 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
name_to_check := get_actual_function_name(node);
if node.vertex_entry_point {
checker.result.vertex_entry_point = node;
checker.result_file.vertex_entry_point.node = node;
}
if node.pixel_entry_point {
checker.result.pixel_entry_point = node;
checker.result_file.pixel_entry_point.node = node;
}
find_result := find_symbol(checker, name_to_check, checker.current_scope);
@@ -1024,7 +1007,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
array_reserve(*symbol.functions, 32);
array_add(*symbol.functions, function);
add_symbol_to_scope(checker.state, *checker.result.scope_stack, checker.current_scope, name_to_check, symbol);
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, name_to_check, symbol);
} else {
//@Note(niels): This is some ugly code, but it's probably fine for now.
field_list := node.children[0];
@@ -1261,7 +1244,7 @@ create_field :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable
symbol.name = node.name;
symbol.source_node = node;
symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.result.scope_stack, checker.current_scope, node.name, symbol);
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, node.name, symbol);
} else {
symbol_redeclaration(checker, node, find_result);
return 0;
@@ -1569,7 +1552,7 @@ traverse :: (checker : *Semantic_Checker, root : *AST_Node) {
}
}
if checker.result.had_error {
if checker.had_error {
return;
}
@@ -1737,13 +1720,12 @@ add_hlsl_builtins :: (checker : *Semantic_Checker) {
}
type_check(checker, parse_result.root);
check_result := checker.result;
if check_result.had_error {
print("%\n", report_messages(check_result.messages));
if checker.had_error {
print("%\n", report_messages(checker.messages));
return;
}
for *type_var : check_result.type_variables {
for *type_var : checker.result_file.type_variables {
type_var.builtin = true;
}
@@ -1765,7 +1747,8 @@ check :: (result : *Compile_Result) {
checker.current_buffer_index = 0;
checker.current_sampler_index = 0;
checker.current_texture_index = 0;
array_reserve(*checker.result.messages, 16);
checker.result_file = file;
array_reserve(*checker.messages, 16);
init_semantic_checker(*checker, file.ast_root, file.file.path);
@@ -1774,44 +1757,29 @@ check :: (result : *Compile_Result) {
type_check(*checker, file.ast_root);
file.constant_buffers = array_copy(*checker.result.constant_buffers);
//@Incomplete: should just be a copy?
file.scope_stack.stack.allocator = file.allocator;
array_reserve(*file.scope_stack.stack, checker.result.scope_stack.stack.count);
for scope : checker.result.scope_stack.stack {
array_add(*file.scope_stack.stack, scope);
}
// file.vertex_entry_point.node = checker.result.vertex_entry_point;
// file.pixel_entry_point.node = checker.result.pixel_entry_point;
file.type_variables.allocator = file.allocator;
array_reserve(*file.type_variables, checker.result.type_variables.count);
for tv : checker.result.type_variables {
array_add(*file.type_variables, tv);
}
file.vertex_entry_point.node = checker.result.vertex_entry_point;
file.pixel_entry_point.node = checker.result.pixel_entry_point;
result.had_error |= checker.result.had_error;
copy_messages(checker.result.messages, *result.messages);
result.had_error |= checker.had_error;
copy_messages(checker.messages, *result.messages);
}
}
check :: (checker : *Semantic_Checker, root : *AST_Node) -> Semantic_Check_Result {
checker.current_buffer_index = 0;
checker.current_sampler_index = 0;
checker.current_texture_index = 0;
array_reserve(*checker.result.messages, 16);
add_hlsl_builtins(checker);
// check :: (checker : *Semantic_Checker, root : *AST_Node) -> Semantic_Check_Result {
// checker.current_buffer_index = 0;
// checker.current_sampler_index = 0;
// checker.current_texture_index = 0;
// array_reserve(*checker.messages, 16);
// add_hlsl_builtins(checker);
type_check(checker, root);
// type_check(checker, root);
return checker.result;
}
// return checker.result;
// }
check :: (checker : *Semantic_Checker) -> Semantic_Check_Result {
return check(checker, checker.program_root);
}
// check :: (checker : *Semantic_Checker) -> Semantic_Check_Result {
// return check(checker, checker.program_root);
// }
// ===========================================================
// Pretty printing
@@ -2090,7 +2058,7 @@ pretty_print_symbol_table :: (checker : *Semantic_Checker, allocator : Allocator
builder : String_Builder;
init_string_builder(*builder,, allocator);
pretty_print_scope(xx checker.current_scope, checker.result.scope_stack, checker.result.type_variables, *checker.result.scope_stack.stack[0], *builder);
pretty_print_scope(xx checker.current_scope, checker.result_file.scope_stack, checker.result_file.type_variables, *checker.result_file.scope_stack.stack[0], *builder);
return builder_to_string(*builder,, allocator);
}

296
Test.jai
View File

@@ -119,65 +119,6 @@ get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := contex
return final_path;
}
// run_lexer_test :: (file_path : string, lexer : *Lexer, output_type : Output_Type = 0) -> Result {
// ok := read_input_from_file(lexer, file_path);
// result_data : Result;
// result_data.path = file_path;
// result_data.stage = .Lexer;
// if !ok {
// result_data.type = .File_Read_Failed;
// result_data.info_text = tprint("Unable to read file: %\n", file_path);
// return result_data;
// } else {
// result_text : string;
// result := lex(lexer, *temp);
// if result.had_error {
// result_data.type = .Failed;
// result_text = report_messages(result.messages);
// } else {
// result_text = pretty_print_tokens(result.tokens, *temp);
// }
// if output_type & .StdOut {
// result_data.info_text = result_text;
// result_data.type = .StdOut;
// return result_data;
// }
// golden_path := get_golden_path(file_path, .Lexer);
// do_golden_comparison(golden_path, result_text, *result_data, output_type);
// return result_data;
// }
// }
run_parser_test :: (file_path : string, output_type : Output_Type = 0) -> Result, *AST_Node {
lexer : Lexer;
result_data : Result;
result_data.path = file_path;
ok := read_input_from_file(*lexer, file_path);
if !ok {
log_error("Unable to read file: %\n", file_path);
result_data.type = .File_Read_Failed;
result_data.stage = .Lexer;
return result_data, null;
}
result := lex(*lexer, *temp);
if result.had_error {
result_data.type = .Passed; //@Incomplete: Huh?
return result_data, null;
}
result_data =, root := run_parser_test(*lexer, output_type);
return result_data, root;
}
do_golden_comparison :: (golden_path : string, comparison_text : string, result_data : *Result, output_type : Output_Type) {
if output_type & .Golden {
// Output the comparison file
@@ -212,200 +153,49 @@ do_golden_comparison :: (golden_path : string, comparison_text : string, result_
}
}
run_parser_test :: (lexer : *Lexer, output_type : Output_Type = 0) -> Result, *AST_Node {
parse_state : Parse_State;
result_data : Result;
result_data.path = lexer.path;
result_data.stage = .Parser;
init_parse_state(*parse_state, lexer.result.tokens, lexer.path);
run_codegen_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
add_file(result, file_path);
result := parse(*parse_state);
result_node : *AST_Node;
result_text : string;
if result.had_error {
result_data.type = .Failed;
result_text = report_messages(result.messages,, temp);
} else {
result_text = pretty_print_ast(parse_state.result.root, *temp);
result_node = parse_state.result.root;
}
if output_type & .StdOut {
result_data.info_text = result_text;
result_data.type = .StdOut;
return result_data, result_node;
}
golden_path := get_golden_path(parse_state.path, .Parser);
do_golden_comparison(golden_path, result_text, *result_data, output_type);
return result_data, result_node;
}
run_semantic_analysis_test :: (file_path : string, output_type : Output_Type = 0) -> Result, Semantic_Check_Result {
lexer : Lexer;
result_data : Result;
result_data.path = file_path;
ok := read_input_from_file(*lexer, file_path);
if !ok {
log_error("Unable to read file: %\n", file_path);
result_data.type = .File_Read_Failed;
result_data.stage = .Lexer;
return result_data, .{};
}
lex_result := lex(*lexer, *temp);
if lex_result.had_error {
result_data.type = .Failed;
result_data.stage = .Lexer;
result_data.info_text = report_messages(lex_result.messages);
lex(result);
parse(result);
check(result);
if output_type & .StdOut {
result_data.type = .StdOut;
return result_data, .{};
}
golden_path := get_golden_path(file_path, .Semantic_Analysis);
do_golden_comparison(golden_path, result_data.info_text, *result_data, output_type);
return result_data, .{};
}
parse_state : Parse_State;
result_data.stage = .Parser;
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {
result_data.type = .Failed;
result_data.info_text = report_messages(parse_result.messages);
if output_type & .StdOut {
result_data.type = .StdOut;
return result_data, .{};
}
golden_path := get_golden_path(file_path, .Semantic_Analysis);
do_golden_comparison(golden_path, result_data.info_text, *result_data, output_type);
return result_data, .{};
}
result, check_result := run_semantic_analysis_test(file_path, parse_state.result.root, output_type);
return result, check_result;
}
run_semantic_analysis_test :: (file_path : string, root : *AST_Node, output_type : Output_Type = 0) -> Result, Semantic_Check_Result {
result_data : Result;
result_data.path = file_path;
result_data.stage = .Semantic_Analysis;
checker : Semantic_Checker;
init_semantic_checker(*checker, root, file_path);
result_text : string;
result := check(*checker);
if result.had_error {
result_data.type = .Failed;
result_text = report_messages(checker.result.messages);
} else {
result_text = pretty_print_symbol_table(*checker, temp);
return result_data;
}
result_data = run_codegen_test(result, output_type);
return result_data;
}
run_codegen_test :: (result : *Compile_Result, output_type : Output_Type = 0) -> Result {
result_data : Result;
result_data.path = result.files[0].file.path;
result_text : string;
codegen(result);
if result.had_error {
result_data.type = .Failed;
result_text = report_messages(result.messages);
return result_data;
}
result_text = result.files[0].codegen_result_text;
if output_type & .StdOut {
result_data.info_text = result_text;
result_data.type = .StdOut;
return result_data, .{};
return result_data;
}
golden_path := get_golden_path(checker.path, .Semantic_Analysis);
golden_path := get_golden_path(result.files[0].file.path, .Codegen);
do_golden_comparison(golden_path, result_text, *result_data, output_type);
return result_data, result;
}
run_codegen_test :: (path : string, root : *AST_Node, check_result : Semantic_Check_Result, output_type : Output_Type = 0) -> Result, Codegen_Result {
result_data : Result;
result_data.path = path;
result_data.stage = .Codegen;
state : Codegen_State;
init_codegen_state(*state, root, check_result, .HLSL);
result_text : string;
result := codegen(*state);
if result.had_error {
result_data.type = .Failed;
result_data.info_text = report_messages(result.messages);
return result_data, .{};
}
result_text = result.result_text;
if output_type & .StdOut {
result_data.info_text = result_text;
result_data.type = .StdOut;
return result_data, result;
}
golden_path := get_golden_path(path, .Codegen);
do_golden_comparison(golden_path, result_text, *result_data, output_type);
return result_data, result;
}
run_codegen_test :: (path : string, root : *AST_Node, output_type : Output_Type = 0) -> Result, Codegen_Result {
checker : Semantic_Checker;
init_semantic_checker(*checker, root, path);
result_data : Result;
result_data.path = path;
result_data.stage = .Semantic_Analysis;
check_result := check(*checker);
if check_result.had_error {
result_data.type = .Failed;
result_data.info_text = report_messages(check_result.messages);
return result_data, .{};
}
result, codegen_result := run_codegen_test(path, root, check_result, output_type);
return result, codegen_result;
}
run_codegen_test :: (path : string, output_type : Output_Type = 0) -> Result, Codegen_Result {
lexer : Lexer;
result_data : Result;
result_data.path = path;
ok := read_input_from_file(*lexer, path);
if !ok {
log_error("Unable to read file: %\n", path);
result_data.type = .File_Read_Failed;
result_data.stage = .Lexer;
return result_data, .{};
}
lex_result := lex(*lexer, *temp);
if lex_result.had_error {
result_data.type = .Failed;
result_data.stage = .Lexer;
return result_data, .{};
}
parse_state : Parse_State;
result_data.stage = .Parser;
init_parse_state(*parse_state, lex_result.tokens, lexer.path);
parse_result := parse(*parse_state);
if parse_result.had_error {
result_data.type = .Failed;
result_data.info_text = pretty_print_ast(parse_result.root, *temp);
return result_data, .{};
}
result, codegen_result := run_codegen_test(path, parse_result.root, output_type);
return result, codegen_result;
return result_data;
}
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result {
@@ -524,7 +314,7 @@ run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, out
lex(result);
parse(result);
if result.had_error {
result_data.type = .Passed;
result_data.type = .Failed;
return result_data;
}
@@ -554,34 +344,32 @@ run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]R
if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
result = run_parser_test(*compile_result, output_type);
} else {
result = run_parser_test(file_path, output_type);
result = run_parser_test(file_path, *compile_result, output_type);
}
record_result(results, result);
}
if stage_flags & .Semantic_Analysis {
if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) {
result = run_semantic_analysis_test(file_path, *compile_result, output_type);
result = run_semantic_analysis_test(*compile_result, output_type);
} else {
result = run_semantic_analysis_test(file_path, *compile_result, output_type);
}
record_result(results, result);
}
// if stage_flags & .Codegen {
// if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
// result = run_codegen_test(file_path, *compile_result, output_type);
// } else if compile_result.ast_root {
// result = run_codegen_test(file_path, *compile_result, output_type);
// } else {
// result = run_codegen_test(file_path, *compile_result, output_type);
// }
// record_result(results, result);
// }
if stage_flags & .Codegen {
if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
result = run_codegen_test(*compile_result, output_type);
} else {
result = run_codegen_test(file_path, *compile_result, output_type);
}
record_result(results, result);
}
// if stage_flags & .Compile {
// result = run_compile_test(file_path, output_type);
// }
if stage_flags & .Compile {
result = run_compile_test(file_path, output_type);
}
}
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) {

View File

@@ -397,7 +397,7 @@ type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope
}
type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field {
return type_variable_to_field(checker.result.type_variables, checker.result.scope_stack, variable);
return type_variable_to_field(checker.result_file.type_variables, checker.result_file.scope_stack, variable);
}
compile_file :: (compiler : *Shader_Compiler, paths : []string) -> Compile_Result {