diff --git a/build/.ninja_deps b/build/.ninja_deps index b3a166c..42530f5 100644 Binary files a/build/.ninja_deps and b/build/.ninja_deps differ diff --git a/build/.ninja_log b/build/.ninja_log index df570f4..0797c25 100644 --- a/build/.ninja_log +++ b/build/.ninja_log @@ -10,15 +10,15 @@ 3695 10921 1781873519336910172 CMakeFiles/saqut.dir/src/parser/nodes/statements.cpp.o 3c8869307381c930 9 9708 1781873515651752771 CMakeFiles/saqut.dir/src/parser/nodes/binary_expr.cpp.o 5cc8b697133bcf64 9 7206 1781873515651861333 CMakeFiles/saqut.dir/src/parser/nodes/declarations.cpp.o c3d262615ede4c95 -9 12161 1781873515651633537 CMakeFiles/saqut.dir/src/main.cpp.o 3cfef7a665d5bf87 -2668 2910 1781873910588652263 saqut f2e198803c4dbffb -0 22 1781873935785536816 build.ninja 1876a59d627a585 -0 22 1781873935784601625 /home/saqut/Masaüstü/saqutcompiler/build/cmake_install.cmake 1876a59d627a585 +9 4452 1781874491015670524 CMakeFiles/saqut.dir/src/main.cpp.o 3cfef7a665d5bf87 +4452 4694 1781874495457230305 saqut f2e198803c4dbffb +0 22 1781874572087843675 build.ninja 1876a59d627a585 +0 22 1781874572087777897 /home/saqut/Masaüstü/saqutcompiler/build/cmake_install.cmake 1876a59d627a585 8261 13474 1781873523902721486 CMakeFiles/saqut.dir/src/symbol/symbol_collector.cpp.o ec4e483b8ddb4007 5962 11851 1781873521603816495 CMakeFiles/saqut.dir/src/semantic/structural_validator.cpp.o 248faa3675024351 7206 12730 1781873522847765087 CMakeFiles/saqut.dir/src/semantic/type_checker.cpp.o b29c133293d988b0 9874 11363 1781873525515654821 CMakeFiles/saqut.dir/src/vm/interpreter.cpp.o b7dd80e002d68a1d 9 1858 1781873515651218159 CMakeFiles/saqut.dir/src/ir/ir_function.cpp.o 10f5e8dfd1461d69 9 1821 1781873515651428931 CMakeFiles/saqut.dir/src/ir/ir_program.cpp.o 9518231d970828da -9 2668 1781873907929763121 CMakeFiles/saqut.dir/src/ir/ir_generator.cpp.o 10a1ed4e1f52e530 -1 8 1781873907921763454 /home/saqut/Masaüstü/saqutcompiler/build/CMakeFiles/cmake.verify_globs 1813c41e0f312d7e +9 2803 1781874491014415953 CMakeFiles/saqut.dir/src/ir/ir_generator.cpp.o 10a1ed4e1f52e530 +0 8 1781874491005416329 /home/saqut/Masaüstü/saqutcompiler/build/CMakeFiles/cmake.verify_globs 1813c41e0f312d7e diff --git a/build/CMakeFiles/VerifyGlobs.cmake b/build/CMakeFiles/VerifyGlobs.cmake index 4a1e9f6..5409649 100644 --- a/build/CMakeFiles/VerifyGlobs.cmake +++ b/build/CMakeFiles/VerifyGlobs.cmake @@ -11,6 +11,9 @@ set(OLD_GLOB "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/basic.sqt" "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_once.sqt" "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_truthy.sqt" + "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/for_break_continue.sqt" + "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/nested_break.sqt" + "/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/while_break_continue.sqt" "/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.sqt" "/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.sqt" "/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.sqt" diff --git a/build/CTestTestfile.cmake b/build/CTestTestfile.cmake index 425fb78..bff65f5 100644 --- a/build/CTestTestfile.cmake +++ b/build/CTestTestfile.cmake @@ -20,6 +20,12 @@ add_test(golden_loops_do_while_once "/usr/bin/cmake" "-DBINARY=/home/saqut/Masa set_tests_properties(golden_loops_do_while_once PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;51;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") add_test(golden_loops_do_while_truthy "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_truthy.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_truthy.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") set_tests_properties(golden_loops_do_while_truthy PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;51;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") +add_test(golden_loops_for_break_continue "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/for_break_continue.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/for_break_continue.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") +set_tests_properties(golden_loops_for_break_continue PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;51;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") +add_test(golden_loops_nested_break "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/nested_break.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/nested_break.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") +set_tests_properties(golden_loops_nested_break PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;51;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") +add_test(golden_loops_while_break_continue "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/while_break_continue.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/while_break_continue.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") +set_tests_properties(golden_loops_while_break_continue PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;51;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") add_test(golden_opt_dce_ir_opt "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.ir_opt.expected" "-DCOMMAND=ir" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") set_tests_properties(golden_opt_dce_ir_opt PROPERTIES _BACKTRACE_TRIPLES "/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;64;add_test;/home/saqut/Masaüstü/saqutcompiler/CMakeLists.txt;0;") add_test(golden_opt_folding_ir_opt "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.ir_opt.expected" "-DCOMMAND=ir" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake") diff --git a/build/Testing/Temporary/CTestCostData.txt b/build/Testing/Temporary/CTestCostData.txt index bf4f5d0..5ff763f 100644 --- a/build/Testing/Temporary/CTestCostData.txt +++ b/build/Testing/Temporary/CTestCostData.txt @@ -1,16 +1,19 @@ -unit_tests 11 0.414572 -golden_arithmetic_basic 11 0.000844698 -golden_fibonacci_fib 11 0.000895261 -golden_string_hello 11 0.000806701 -golden_arithmetic_precedence 10 0.000871188 -golden_loops_basic 10 0.000887091 -golden_loops_do_while_once 10 0.000917601 +unit_tests 12 0.383222 +golden_arithmetic_basic 12 0.00103142 +golden_fibonacci_fib 12 0.000916418 +golden_string_hello 12 0.000742352 +golden_arithmetic_precedence 11 0.000902075 +golden_loops_basic 11 0.000863198 +golden_loops_do_while_once 11 0.000996616 golden_opt_dce 2 0.00441751 golden_opt_folding 2 0.00456844 -golden_opt_dce_ir_opt 8 0.00118146 -golden_opt_folding_ir_opt 8 0.00108412 -golden_opt_run_opt 6 0.00154088 -golden_opt_run_opt_run_opt 6 0.00158656 -golden_logic_short_circuit 2 0.00443116 -golden_loops_do_while_truthy 1 0.00964192 +golden_opt_dce_ir_opt 9 0.00109281 +golden_opt_folding_ir_opt 9 0.00105492 +golden_opt_run_opt 7 0.00244026 +golden_opt_run_opt_run_opt 7 0.0014659 +golden_logic_short_circuit 3 0.00318302 +golden_loops_do_while_truthy 2 0.00508981 +golden_loops_for_break_continue 1 0.0102576 +golden_loops_nested_break 1 0.00991625 +golden_loops_while_break_continue 1 0.00901491 --- diff --git a/build/Testing/Temporary/LastTest.log b/build/Testing/Temporary/LastTest.log index 2a9a0c9..14d83c1 100644 --- a/build/Testing/Temporary/LastTest.log +++ b/build/Testing/Temporary/LastTest.log @@ -1,10 +1,10 @@ -Start testing: Jun 19 15:58 +03 +Start testing: Jun 19 16:09 +03 ---------------------------------------------------------- -1/13 Testing: unit_tests -1/13 Test: unit_tests +1/16 Testing: unit_tests +1/16 Test: unit_tests Command: "/usr/bin/bash" "/home/saqut/Masaüstü/saqutcompiler/tests/run.sh" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"unit_tests" start time: Jun 19 15:58 +03 +"unit_tests" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- === test_type === @@ -21,191 +21,236 @@ test.sqt:12:1: uyarı [W001]: y kullanılmıyor test_diagnostic: TUM TESTLER GECTI === TUM TESTLER GECTI === -Test time = 4.56 sec +Test time = 4.60 sec ---------------------------------------------------------- Test Passed. -"unit_tests" end time: Jun 19 15:59 +03 +"unit_tests" end time: Jun 19 16:09 +03 "unit_tests" time elapsed: 00:00:04 ---------------------------------------------------------- -2/13 Testing: golden_arithmetic_basic -2/13 Test: golden_arithmetic_basic +2/16 Testing: golden_arithmetic_basic +2/16 Test: golden_arithmetic_basic Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/arithmetic/basic.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/arithmetic/basic.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_arithmetic_basic" start time: Jun 19 15:59 +03 +"golden_arithmetic_basic" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_arithmetic_basic" end time: Jun 19 15:59 +03 +"golden_arithmetic_basic" end time: Jun 19 16:09 +03 "golden_arithmetic_basic" time elapsed: 00:00:00 ---------------------------------------------------------- -3/13 Testing: golden_arithmetic_precedence -3/13 Test: golden_arithmetic_precedence +3/16 Testing: golden_arithmetic_precedence +3/16 Test: golden_arithmetic_precedence Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/arithmetic/precedence.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/arithmetic/precedence.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_arithmetic_precedence" start time: Jun 19 15:59 +03 +"golden_arithmetic_precedence" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_arithmetic_precedence" end time: Jun 19 15:59 +03 +"golden_arithmetic_precedence" end time: Jun 19 16:09 +03 "golden_arithmetic_precedence" time elapsed: 00:00:00 ---------------------------------------------------------- -4/13 Testing: golden_fibonacci_fib -4/13 Test: golden_fibonacci_fib +4/16 Testing: golden_fibonacci_fib +4/16 Test: golden_fibonacci_fib Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/fibonacci/fib.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/fibonacci/fib.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_fibonacci_fib" start time: Jun 19 15:59 +03 +"golden_fibonacci_fib" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_fibonacci_fib" end time: Jun 19 15:59 +03 +"golden_fibonacci_fib" end time: Jun 19 16:09 +03 "golden_fibonacci_fib" time elapsed: 00:00:00 ---------------------------------------------------------- -5/13 Testing: golden_logic_short_circuit -5/13 Test: golden_logic_short_circuit +5/16 Testing: golden_logic_short_circuit +5/16 Test: golden_logic_short_circuit Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/logic/short_circuit.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/logic/short_circuit.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_logic_short_circuit" start time: Jun 19 15:59 +03 +"golden_logic_short_circuit" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_logic_short_circuit" end time: Jun 19 15:59 +03 +"golden_logic_short_circuit" end time: Jun 19 16:09 +03 "golden_logic_short_circuit" time elapsed: 00:00:00 ---------------------------------------------------------- -6/13 Testing: golden_loops_basic -6/13 Test: golden_loops_basic +6/16 Testing: golden_loops_basic +6/16 Test: golden_loops_basic Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/basic.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/basic.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_loops_basic" start time: Jun 19 15:59 +03 +"golden_loops_basic" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_loops_basic" end time: Jun 19 15:59 +03 +"golden_loops_basic" end time: Jun 19 16:09 +03 "golden_loops_basic" time elapsed: 00:00:00 ---------------------------------------------------------- -7/13 Testing: golden_loops_do_while_once -7/13 Test: golden_loops_do_while_once +7/16 Testing: golden_loops_do_while_once +7/16 Test: golden_loops_do_while_once Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_once.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_once.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_loops_do_while_once" start time: Jun 19 15:59 +03 +"golden_loops_do_while_once" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_loops_do_while_once" end time: Jun 19 15:59 +03 +"golden_loops_do_while_once" end time: Jun 19 16:09 +03 "golden_loops_do_while_once" time elapsed: 00:00:00 ---------------------------------------------------------- -8/13 Testing: golden_loops_do_while_truthy -8/13 Test: golden_loops_do_while_truthy +8/16 Testing: golden_loops_do_while_truthy +8/16 Test: golden_loops_do_while_truthy Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_truthy.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/do_while_truthy.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_loops_do_while_truthy" start time: Jun 19 15:59 +03 +"golden_loops_do_while_truthy" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_loops_do_while_truthy" end time: Jun 19 15:59 +03 +"golden_loops_do_while_truthy" end time: Jun 19 16:09 +03 "golden_loops_do_while_truthy" time elapsed: 00:00:00 ---------------------------------------------------------- -9/13 Testing: golden_opt_dce_ir_opt -9/13 Test: golden_opt_dce_ir_opt -Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.ir_opt.expected" "-DCOMMAND=ir" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" +9/16 Testing: golden_loops_for_break_continue +9/16 Test: golden_loops_for_break_continue +Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/for_break_continue.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/for_break_continue.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_opt_dce_ir_opt" start time: Jun 19 15:59 +03 +"golden_loops_for_break_continue" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_opt_dce_ir_opt" end time: Jun 19 15:59 +03 +"golden_loops_for_break_continue" end time: Jun 19 16:09 +03 +"golden_loops_for_break_continue" time elapsed: 00:00:00 +---------------------------------------------------------- + +10/16 Testing: golden_loops_nested_break +10/16 Test: golden_loops_nested_break +Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/nested_break.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/nested_break.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" +Directory: /home/saqut/Masaüstü/saqutcompiler/build +"golden_loops_nested_break" start time: Jun 19 16:09 +03 +Output: +---------------------------------------------------------- + +Test time = 0.01 sec +---------------------------------------------------------- +Test Passed. +"golden_loops_nested_break" end time: Jun 19 16:09 +03 +"golden_loops_nested_break" time elapsed: 00:00:00 +---------------------------------------------------------- + +11/16 Testing: golden_loops_while_break_continue +11/16 Test: golden_loops_while_break_continue +Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/while_break_continue.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/loops/while_break_continue.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" +Directory: /home/saqut/Masaüstü/saqutcompiler/build +"golden_loops_while_break_continue" start time: Jun 19 16:09 +03 +Output: +---------------------------------------------------------- + +Test time = 0.01 sec +---------------------------------------------------------- +Test Passed. +"golden_loops_while_break_continue" end time: Jun 19 16:09 +03 +"golden_loops_while_break_continue" time elapsed: 00:00:00 +---------------------------------------------------------- + +12/16 Testing: golden_opt_dce_ir_opt +12/16 Test: golden_opt_dce_ir_opt +Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/dce.ir_opt.expected" "-DCOMMAND=ir" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" +Directory: /home/saqut/Masaüstü/saqutcompiler/build +"golden_opt_dce_ir_opt" start time: Jun 19 16:09 +03 +Output: +---------------------------------------------------------- + +Test time = 0.01 sec +---------------------------------------------------------- +Test Passed. +"golden_opt_dce_ir_opt" end time: Jun 19 16:09 +03 "golden_opt_dce_ir_opt" time elapsed: 00:00:00 ---------------------------------------------------------- -10/13 Testing: golden_opt_folding_ir_opt -10/13 Test: golden_opt_folding_ir_opt +13/16 Testing: golden_opt_folding_ir_opt +13/16 Test: golden_opt_folding_ir_opt Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.ir_opt.expected" "-DCOMMAND=ir" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_opt_folding_ir_opt" start time: Jun 19 15:59 +03 +"golden_opt_folding_ir_opt" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_opt_folding_ir_opt" end time: Jun 19 15:59 +03 +"golden_opt_folding_ir_opt" end time: Jun 19 16:09 +03 "golden_opt_folding_ir_opt" time elapsed: 00:00:00 ---------------------------------------------------------- -11/13 Testing: golden_opt_run_opt -11/13 Test: golden_opt_run_opt +14/16 Testing: golden_opt_run_opt +14/16 Test: golden_opt_run_opt Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_opt_run_opt" start time: Jun 19 15:59 +03 +"golden_opt_run_opt" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- -Test time = 0.01 sec +Test time = 0.02 sec ---------------------------------------------------------- Test Passed. -"golden_opt_run_opt" end time: Jun 19 15:59 +03 +"golden_opt_run_opt" end time: Jun 19 16:09 +03 "golden_opt_run_opt" time elapsed: 00:00:00 ---------------------------------------------------------- -12/13 Testing: golden_opt_run_opt_run_opt -12/13 Test: golden_opt_run_opt_run_opt +15/16 Testing: golden_opt_run_opt_run_opt +15/16 Test: golden_opt_run_opt_run_opt Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.run_opt.expected" "-DOPTIMIZED=1" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_opt_run_opt_run_opt" start time: Jun 19 15:59 +03 +"golden_opt_run_opt_run_opt" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_opt_run_opt_run_opt" end time: Jun 19 15:59 +03 +"golden_opt_run_opt_run_opt" end time: Jun 19 16:09 +03 "golden_opt_run_opt_run_opt" time elapsed: 00:00:00 ---------------------------------------------------------- -13/13 Testing: golden_string_hello -13/13 Test: golden_string_hello +16/16 Testing: golden_string_hello +16/16 Test: golden_string_hello Command: "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/saqutcompiler/build/saqut" "-DSOURCE=/home/saqut/Masaüstü/saqutcompiler/tests/golden/string/hello.sqt" "-DEXPECTED=/home/saqut/Masaüstü/saqutcompiler/tests/golden/string/hello.expected" "-P" "/home/saqut/Masaüstü/saqutcompiler/cmake/run_golden.cmake" Directory: /home/saqut/Masaüstü/saqutcompiler/build -"golden_string_hello" start time: Jun 19 15:59 +03 +"golden_string_hello" start time: Jun 19 16:09 +03 Output: ---------------------------------------------------------- Test time = 0.01 sec ---------------------------------------------------------- Test Passed. -"golden_string_hello" end time: Jun 19 15:59 +03 +"golden_string_hello" end time: Jun 19 16:09 +03 "golden_string_hello" time elapsed: 00:00:00 ---------------------------------------------------------- -End testing: Jun 19 15:59 +03 +End testing: Jun 19 16:09 +03 diff --git a/src/ir/ir_generator.cpp b/src/ir/ir_generator.cpp index b1ca33f..e4e4570 100644 --- a/src/ir/ir_generator.cpp +++ b/src/ir/ir_generator.cpp @@ -153,77 +153,101 @@ void IRGenerator::generateStatement(ASTNode* node) { case ASTKind::WhileStatement: { auto* ws = (WhileStatementNode*)node; - // Döngü başının konumu — geri-jump buraya gelecek int loopStart = currentInstrIndex(); + loopContextStack_.push_back({}); - int condSlot = generateExpression(ws->condition); - int exitJump = emitJumpIfFalse(condSlot); // ileri, backpatch bekliyor + int condSlot = generateExpression(ws->condition); + int exitJump = emitJumpIfFalse(condSlot); if (ws->body) generateStatement(ws->body); - // Geri-jump: hedef zaten biliniyor (loopStart) - emitJumpUnconditional(loopStart); + // continue → LOOP_START (hedef baştan beri biliniyor) + for (int idx : loopContextStack_.back().continueJumps) + currentFunction_->instructions[idx].jumpTarget = loopStart; - // Döngü çıkış noktası → exitJump'ı doldur - patchJump(exitJump); + emitJumpUnconditional(loopStart); + patchJump(exitJump); // OUT burası + + // break → OUT + int outTarget = currentInstrIndex(); + for (int idx : loopContextStack_.back().breakJumps) + currentFunction_->instructions[idx].jumpTarget = outTarget; + + loopContextStack_.pop_back(); break; } // ── for (init; koşul; güncelleme) { gövde } ───────────────────────── // - // Üretilen IR yapısı: + // IR yapısı (continue C_LABEL'a, break OUT'a atlar): // [init] // LOOP_START: - // [koşul] → condSlot - // JIF_FALSE condSlot → LOOP_END (ileri-jump, backpatch) + // [koşul] → JIF_FALSE OUT // [gövde] + // C_LABEL: // [güncelleme] - // JMP → LOOP_START (geri-jump, hedef biliniyor) - // LOOP_END: + // JMP LOOP_START + // OUT: // ───────────────────────────────────────────────────────────────────── case ASTKind::ForStatement: { auto* fs = (ForStatementNode*)node; - // Init: genellikle "int i = 0" gibi bir VariableDecl if (fs->init) generateStatement(fs->init); - // Döngü başı konumu — geri-jump'ın hedefi int loopStart = currentInstrIndex(); + loopContextStack_.push_back({}); - // Koşul int condSlot = fs->condition ? generateExpression(fs->condition) : -1; int exitJump = (condSlot != -1) ? emitJumpIfFalse(condSlot) : -1; - // Gövde if (fs->body) generateStatement(fs->body); - // Güncelleme (ör: i = i + 1) — ifade deyimi, sonuç önemsiz + // C_LABEL: güncelleme başlangıcı — continue buraya atlar + int cLabel = currentInstrIndex(); + for (int idx : loopContextStack_.back().continueJumps) + currentFunction_->instructions[idx].jumpTarget = cLabel; + if (fs->update) generateExpression(fs->update); - // Geri-jump: hedef loopStart, zaten biliniyor emitJumpUnconditional(loopStart); - // Döngü çıkışı → exitJump'ı doldur - if (exitJump != -1) patchJump(exitJump); + if (exitJump != -1) patchJump(exitJump); // OUT burası + + // break → OUT + int outTarget = currentInstrIndex(); + for (int idx : loopContextStack_.back().breakJumps) + currentFunction_->instructions[idx].jumpTarget = outTarget; + + loopContextStack_.pop_back(); break; } // ── do { gövde } while (koşul) ─────────────────────────────────────── case ASTKind::DoWhileStatement: { auto* dw = (DoWhileStatementNode*)node; + int loopStart = currentInstrIndex(); + loopContextStack_.push_back({}); if (dw->body) generateStatement(dw->body); + // COND_LABEL: koşul değerlendirmesi — continue buraya atlar + int condLabel = currentInstrIndex(); + for (int idx : loopContextStack_.back().continueJumps) + currentFunction_->instructions[idx].jumpTarget = condLabel; + int condSlot = generateExpression(dw->condition); - // truthy (sıfır-dışı herhangi bir değer) ise başa dön — JIF_TRUE. - // Eski "== 1" geçici çözümü kaldırıldı: koşul 2 gibi 1-olmayan - // truthy bir değer üretince yanlışlıkla çıkıyordu (B4). - // Geri-jump: hedef loopStart zaten biliniyor, backpatch gerekmez. Instruction jit(Opcode::JIF_TRUE); jit.cond = condSlot; jit.jumpTarget = loopStart; currentFunction_->instructions.push_back(std::move(jit)); + + // break → OUT (JIF_TRUE'dan sonraki konum) + int outTarget = currentInstrIndex(); + for (int idx : loopContextStack_.back().breakJumps) + currentFunction_->instructions[idx].jumpTarget = outTarget; + + loopContextStack_.pop_back(); break; } @@ -237,10 +261,18 @@ void IRGenerator::generateStatement(ASTNode* node) { break; } - case ASTKind::BreakStatement: - case ASTKind::ContinueStatement: - // TODO(vm-genişletme): break/continue için JMP + label mekanizması gerekir + case ASTKind::BreakStatement: { + int jumpIdx = emitJumpUnconditional(-1); + if (!loopContextStack_.empty()) + loopContextStack_.back().breakJumps.push_back(jumpIdx); break; + } + case ASTKind::ContinueStatement: { + int jumpIdx = emitJumpUnconditional(-1); + if (!loopContextStack_.empty()) + loopContextStack_.back().continueJumps.push_back(jumpIdx); + break; + } default: break; diff --git a/src/ir/ir_generator.hpp b/src/ir/ir_generator.hpp index eef4d7c..62ef77f 100644 --- a/src/ir/ir_generator.hpp +++ b/src/ir/ir_generator.hpp @@ -75,6 +75,15 @@ private: // Şu an kaç talimat üretildi? (jump hedefi belirlemek için) int currentInstrIndex() const; + // ── Döngü bağlamı yığını — break/continue hedefleri ───────────────── + // Her döngüye girerken bir giriş push'lanır, çıkınca pop'lanır. + // İç içe döngülerde en üstteki giriş en içteki döngüye aittir. + struct LoopContext { + std::vector breakJumps; // patch bekleyen break JMP indeksleri + std::vector continueJumps; // patch bekleyen continue JMP indeksleri + }; + std::vector loopContextStack_; + // ── Per-function üretim durumu ──────────────────────────────────────── IRFunction* currentFunction_ = nullptr; // şu an üretilen fonksiyon int nextSlot_ = 0; // sıradaki boş slot numarası diff --git a/tests/golden/loops/for_break_continue.expected b/tests/golden/loops/for_break_continue.expected new file mode 100644 index 0000000..3134c5a --- /dev/null +++ b/tests/golden/loops/for_break_continue.expected @@ -0,0 +1,5 @@ +1 +3 +5 +1 +2 diff --git a/tests/golden/loops/for_break_continue.sqt b/tests/golden/loops/for_break_continue.sqt new file mode 100644 index 0000000..961302f --- /dev/null +++ b/tests/golden/loops/for_break_continue.sqt @@ -0,0 +1,24 @@ +// for döngüsünde break ve continue golden testi. +// +// continue kanıtı: 2 ve 4 atlanır ama güncelleme (i++) hala çalışır. +// Eğer continue güncellemeyi atlasaydı i==2'de sonsuz döngüye girerdi. +// 5'in çıktıda görünmesi güncellemenin çalıştığını kanıtlar. +// +// break kanıtı: i==3'te erken çık — 3, 4, 5 görünmemeli. + +int main() { + int i = 0; + + for (i = 1; i <= 5; i = i + 1) { + if (i == 2) { continue; } + if (i == 4) { continue; } + print(i); + } + + for (i = 1; i <= 5; i = i + 1) { + if (i == 3) { break; } + print(i); + } + + return 0; +} diff --git a/tests/golden/loops/nested_break.expected b/tests/golden/loops/nested_break.expected new file mode 100644 index 0000000..570bd9e --- /dev/null +++ b/tests/golden/loops/nested_break.expected @@ -0,0 +1,6 @@ +1 +1 +2 +1 +3 +1 diff --git a/tests/golden/loops/nested_break.sqt b/tests/golden/loops/nested_break.sqt new file mode 100644 index 0000000..cf2b75c --- /dev/null +++ b/tests/golden/loops/nested_break.sqt @@ -0,0 +1,21 @@ +// İç içe döngü: içteki break sadece içteki döngüyü etkiler. +// Döngü bağlamı yığınının doğru çalıştığını kanıtlar. +// +// Beklenen: her dış iterasyonda j=1 yazdırılır, j=2'de inner break. +// Dış döngü i=1,2,3 boyunca devam eder — inner break dışarıya sızmaz. + +int main() { + int i = 1; + while (i <= 3) { + int j = 1; + while (j <= 3) { + if (j == 2) { break; } + print(i); + print(j); + j = j + 1; + } + i = i + 1; + } + + return 0; +} diff --git a/tests/golden/loops/while_break_continue.expected b/tests/golden/loops/while_break_continue.expected new file mode 100644 index 0000000..f71f392 --- /dev/null +++ b/tests/golden/loops/while_break_continue.expected @@ -0,0 +1,7 @@ +1 +2 +4 +5 +1 +2 +3 diff --git a/tests/golden/loops/while_break_continue.sqt b/tests/golden/loops/while_break_continue.sqt new file mode 100644 index 0000000..34d976d --- /dev/null +++ b/tests/golden/loops/while_break_continue.sqt @@ -0,0 +1,22 @@ +// while döngüsünde break ve continue golden testi. + +int main() { + int i = 0; + + // continue: 3'ü atla + while (i < 5) { + i = i + 1; + if (i == 3) { continue; } + print(i); + } + + // break: 4'te çık + i = 0; + while (i < 10) { + i = i + 1; + if (i == 4) { break; } + print(i); + } + + return 0; +}