diff --git a/AST.jai b/AST.jai index 7e71e6a..2f16603 100644 --- a/AST.jai +++ b/AST.jai @@ -283,7 +283,6 @@ pretty_print_variable :: (node : *AST_Node, indentation : int, builder : *String print_to_builder(builder, "%", node.name); for child : node.children { - print("%\n", child.kind); if child.kind == .Variable { append(builder, "."); pretty_print_variable(child, indentation, builder); diff --git a/Codegen.jai b/Codegen.jai index b35ca10..e6a5aa9 100644 --- a/Codegen.jai +++ b/Codegen.jai @@ -386,7 +386,11 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) { } case .Binary; { indent(*state.builder, indentation); - append(*state.builder, "("); + + if node.token.kind != .TOKEN_ASSIGN { + append(*state.builder, "("); + } + lhs := node.children[0]; rhs := node.children[1]; emit_node(state, lhs, 0); @@ -395,7 +399,9 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) { emit_operator(state, node.token.kind); append(*state.builder, " "); emit_node(state, rhs, 0); - append(*state.builder, ")"); + if node.token.kind != .TOKEN_ASSIGN { + append(*state.builder, ")"); + } } case .Unary; { assert(false, "Not implemented yet: unary"); diff --git a/Test.jai b/Test.jai index eb5d8ee..82ba0f3 100644 --- a/Test.jai +++ b/Test.jai @@ -310,8 +310,8 @@ run_semantic_analysis_test :: (file_path : string, root : *AST_Node, output_type result_text = pretty_print_symbol_table(*checker, temp); constraints := pretty_print_type_constraints(*checker, temp); type_vars := pretty_print_type_variables(*checker, temp); - print("Constraints\n%\n", constraints); - print("Solution\n%\n", type_vars); + // print("Constraints\n%\n", constraints); + // print("Solution\n%\n", type_vars); } if output_type & .StdOut { @@ -477,7 +477,23 @@ run_test :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Resul } run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) { - print("%Running test: %\n", cyan(), test_case.path); + print("%Running test: %......", cyan(), test_case.path); + + // path 30 + // len 35 + // == 5 + + + // path 20 + // len = 35 + // == 15 + + len := 50; + rest := len - test_case.path.count; + for i: 0..rest { + print(" "); + } + run_test(test_case.path, test_case.stage_flags, results, output_type); } @@ -525,7 +541,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) { } } - print("\n"); + // print("\n"); } print("\n"); @@ -620,26 +636,26 @@ evaluate_result :: (result : Result) { if #complete result.type == { case .File_Read_Failed; { - print("%", red()); - print("% failed with File_Read_Failed\n", result.path); + print(" %", red()); + print("failed with File_Read_Failed\n"); } case .Golden_File_Not_Found; { - print("%", red()); - print("% failed with Golden File Not Found for stage %\n", result.path, stage); + print(" %", red()); + print("failed with Golden File Not Found for stage %\n", stage); } case .StdOut; { } case .Golden_Output; { - print("%", yellow()); - print("% output new golden file at %\n", result.path, result.golden_path); + print(" %", yellow()); + print("output new golden file at %\n", result.golden_path); } case .Passed; { - print("%", green()); - print("% passed %\n", result.path, stage); + print(" %", green()); + print("passed %\n", stage); } case .Failed; { - print("%", red()); - print("% failed %\n", result.path, stage); + print(" %", red()); + print("failed %\n", stage); } } diff --git a/test/codegen/assign_arithmetic_expression.golden b/test/codegen/assign_arithmetic_expression.golden index 81b0e2f..5e3f49c 100644 --- a/test/codegen/assign_arithmetic_expression.golden +++ b/test/codegen/assign_arithmetic_expression.golden @@ -1,5 +1,5 @@ void vs_main() { - float x = 2.0f + 5.0f; + float x = (2.0f + 5.0f); } diff --git a/test/codegen/complicated_computation.golden b/test/codegen/complicated_computation.golden index 964ff54..901e40e 100644 --- a/test/codegen/complicated_computation.golden +++ b/test/codegen/complicated_computation.golden @@ -2,6 +2,6 @@ void vs_main() { float x = 5.0f; float y = 3000.0f; - float z = y * y + x; + float z = ((y * y) + x); } diff --git a/test/codegen/empty_struct.golden b/test/codegen/empty_struct.golden index 24d298a..7cf84fd 100644 --- a/test/codegen/empty_struct.golden +++ b/test/codegen/empty_struct.golden @@ -1,4 +1,2 @@ -struct Foo; - -struct Foo {} +struct Foo {}; diff --git a/test/codegen/meta_block.golden b/test/codegen/meta_block.golden index 756d482..62a3b98 100644 --- a/test/codegen/meta_block.golden +++ b/test/codegen/meta_block.golden @@ -4,7 +4,7 @@ cbuffer __PROPERTIES : register(b0) } -float3 vs_main(float3 pos : POSITION, float2 uv) : SV_POSITION +float3 vs_main(float3 pos : POSITION, float2 uv : TEXCOORD0) : SV_POSITION { return pos; } diff --git a/test/codegen/multiple_functions.golden b/test/codegen/multiple_functions.golden index a2a8be4..047de23 100644 --- a/test/codegen/multiple_functions.golden +++ b/test/codegen/multiple_functions.golden @@ -8,7 +8,7 @@ int foo() float bar() { - return 1235.0f * 500; + return (1235.0f * 500); } void vs_main() diff --git a/test/codegen/pass_and_access_struct_fields_in_functions.golden b/test/codegen/pass_and_access_struct_fields_in_functions.golden index 4bab942..e54492e 100644 --- a/test/codegen/pass_and_access_struct_fields_in_functions.golden +++ b/test/codegen/pass_and_access_struct_fields_in_functions.golden @@ -1,15 +1,13 @@ -struct Foo; - float foo(Foo f); struct Foo { float some_data; -} +}; float foo(Foo f) { - return f.some_data * 2.0f; + return (f.some_data * 2.0f); } void vs_main() diff --git a/test/codegen/simple_struct_access.golden b/test/codegen/simple_struct_access.golden index 98d6e5f..b32d99e 100644 --- a/test/codegen/simple_struct_access.golden +++ b/test/codegen/simple_struct_access.golden @@ -1,9 +1,7 @@ -struct Data; - struct Data { float4 color; -} +}; void vs_main() { diff --git a/test/codegen/struct_within_struct.golden b/test/codegen/struct_within_struct.golden index 8685c7f..8794381 100644 --- a/test/codegen/struct_within_struct.golden +++ b/test/codegen/struct_within_struct.golden @@ -1,15 +1,12 @@ -struct Foo; -struct Bar; - struct Foo { float4 color; -} +}; struct Bar { Foo t; -} +}; void vs_main() {