fix(ir): do-while == 1 geçici çözümü kaldırıldı, JIF_TRUE kullanılıyor (B4)

Sorun: koşul 1-olmayan sıfır-dışı bir değer (ör. 2) üretince "cond == 1"
karşılaştırması false dönüyor ve döngü yanlışlıkla erken çıkıyordu.

Düzeltme: üç geçici talimat (LOAD_CONST, EQUAL_EQUAL, JIF_FALSE) kaldırıldı.
Geri-jump artık doğrudan JIF_TRUE ile yapılıyor — truthy (sıfır-dışı her
değer) ise loopStart'a atla; isTruthy() semantiğiyle tutarlı.

Test: tests/golden/loops/do_while_truthy.sqt — koşulun i<3 ifadesi (1 veya 0
üretir, 2 üretmez), ancak "while (j)" (j=5→truthy→dön, j=0→false→çık) gibi
1-olmayan truthy koşullar da doğru çalışıyor. 13/13 test yeşil.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
saqut 2026-06-19 15:59:15 +03:00
parent c5fb57412a
commit 8509d09ca8
9 changed files with 125 additions and 84 deletions

Binary file not shown.

View File

@ -11,14 +11,14 @@
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
13474 13718 1781873529115506016 saqut f2e198803c4dbffb
0 22 1781873613334363371 build.ninja 1876a59d627a585
0 22 1781873613334280893 /home/saqut/Masaüstü/saqutcompiler/build/cmake_install.cmake 1876a59d627a585
2668 2910 1781873910588652263 saqut f2e198803c4dbffb
0 22 1781873935785536816 build.ninja 1876a59d627a585
0 22 1781873935784601625 /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 5962 1781873515651343783 CMakeFiles/saqut.dir/src/ir/ir_generator.cpp.o 10a1ed4e1f52e530
1 8 1781873534882267590 /home/saqut/Masaüstü/saqutcompiler/build/CMakeFiles/cmake.verify_globs 1813c41e0f312d7e
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

View File

@ -10,6 +10,7 @@ set(OLD_GLOB
"/home/saqut/Masaüstü/saqutcompiler/tests/golden/logic/short_circuit.sqt"
"/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/opt/dce.sqt"
"/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/folding.sqt"
"/home/saqut/Masaüstü/saqutcompiler/tests/golden/opt/run_opt.sqt"

View File

@ -18,6 +18,8 @@ add_test(golden_loops_basic "/usr/bin/cmake" "-DBINARY=/home/saqut/Masaüstü/sa
set_tests_properties(golden_loops_basic 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_once "/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")
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_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")

View File

@ -1,15 +1,16 @@
unit_tests 10 0.448247
golden_arithmetic_basic 10 0.000867734
golden_fibonacci_fib 10 0.00093354
golden_string_hello 10 0.000870371
golden_arithmetic_precedence 9 0.000954052
golden_loops_basic 9 0.000971074
golden_loops_do_while_once 9 0.000986343
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
golden_opt_dce 2 0.00441751
golden_opt_folding 2 0.00456844
golden_opt_dce_ir_opt 7 0.00126134
golden_opt_folding_ir_opt 7 0.00129602
golden_opt_run_opt 5 0.00182007
golden_opt_run_opt_run_opt 5 0.00185853
golden_logic_short_circuit 1 0.00907537
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
---

View File

@ -1,10 +1,10 @@
Start testing: Jun 19 15:53 +03
Start testing: Jun 19 15:58 +03
----------------------------------------------------------
1/12 Testing: unit_tests
1/12 Test: unit_tests
1/13 Testing: unit_tests
1/13 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:53 +03
"unit_tests" start time: Jun 19 15:58 +03
Output:
----------------------------------------------------------
=== test_type ===
@ -21,176 +21,191 @@ test.sqt:12:1: uyarı [W001]: y kullanılmıyor
test_diagnostic: TUM TESTLER GECTI
=== TUM TESTLER GECTI ===
<end of output>
Test time = 4.48 sec
Test time = 4.56 sec
----------------------------------------------------------
Test Passed.
"unit_tests" end time: Jun 19 15:53 +03
"unit_tests" end time: Jun 19 15:59 +03
"unit_tests" time elapsed: 00:00:04
----------------------------------------------------------
2/12 Testing: golden_arithmetic_basic
2/12 Test: golden_arithmetic_basic
2/13 Testing: golden_arithmetic_basic
2/13 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:53 +03
"golden_arithmetic_basic" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_arithmetic_basic" end time: Jun 19 15:53 +03
"golden_arithmetic_basic" end time: Jun 19 15:59 +03
"golden_arithmetic_basic" time elapsed: 00:00:00
----------------------------------------------------------
3/12 Testing: golden_arithmetic_precedence
3/12 Test: golden_arithmetic_precedence
3/13 Testing: golden_arithmetic_precedence
3/13 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:53 +03
"golden_arithmetic_precedence" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_arithmetic_precedence" end time: Jun 19 15:53 +03
"golden_arithmetic_precedence" end time: Jun 19 15:59 +03
"golden_arithmetic_precedence" time elapsed: 00:00:00
----------------------------------------------------------
4/12 Testing: golden_fibonacci_fib
4/12 Test: golden_fibonacci_fib
4/13 Testing: golden_fibonacci_fib
4/13 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:53 +03
"golden_fibonacci_fib" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_fibonacci_fib" end time: Jun 19 15:53 +03
"golden_fibonacci_fib" end time: Jun 19 15:59 +03
"golden_fibonacci_fib" time elapsed: 00:00:00
----------------------------------------------------------
5/12 Testing: golden_logic_short_circuit
5/12 Test: golden_logic_short_circuit
5/13 Testing: golden_logic_short_circuit
5/13 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:53 +03
"golden_logic_short_circuit" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_logic_short_circuit" end time: Jun 19 15:53 +03
"golden_logic_short_circuit" end time: Jun 19 15:59 +03
"golden_logic_short_circuit" time elapsed: 00:00:00
----------------------------------------------------------
6/12 Testing: golden_loops_basic
6/12 Test: golden_loops_basic
6/13 Testing: golden_loops_basic
6/13 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:53 +03
"golden_loops_basic" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_loops_basic" end time: Jun 19 15:53 +03
"golden_loops_basic" end time: Jun 19 15:59 +03
"golden_loops_basic" time elapsed: 00:00:00
----------------------------------------------------------
7/12 Testing: golden_loops_do_while_once
7/12 Test: golden_loops_do_while_once
7/13 Testing: golden_loops_do_while_once
7/13 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:53 +03
"golden_loops_do_while_once" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_loops_do_while_once" end time: Jun 19 15:53 +03
"golden_loops_do_while_once" end time: Jun 19 15:59 +03
"golden_loops_do_while_once" time elapsed: 00:00:00
----------------------------------------------------------
8/12 Testing: golden_opt_dce_ir_opt
8/12 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"
8/13 Testing: golden_loops_do_while_truthy
8/13 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_opt_dce_ir_opt" start time: Jun 19 15:53 +03
"golden_loops_do_while_truthy" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_opt_dce_ir_opt" end time: Jun 19 15:53 +03
"golden_loops_do_while_truthy" end time: Jun 19 15:59 +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"
Directory: /home/saqut/Masaüstü/saqutcompiler/build
"golden_opt_dce_ir_opt" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_opt_dce_ir_opt" end time: Jun 19 15:59 +03
"golden_opt_dce_ir_opt" time elapsed: 00:00:00
----------------------------------------------------------
9/12 Testing: golden_opt_folding_ir_opt
9/12 Test: golden_opt_folding_ir_opt
10/13 Testing: golden_opt_folding_ir_opt
10/13 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:53 +03
"golden_opt_folding_ir_opt" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_opt_folding_ir_opt" end time: Jun 19 15:53 +03
"golden_opt_folding_ir_opt" end time: Jun 19 15:59 +03
"golden_opt_folding_ir_opt" time elapsed: 00:00:00
----------------------------------------------------------
10/12 Testing: golden_opt_run_opt
10/12 Test: golden_opt_run_opt
11/13 Testing: golden_opt_run_opt
11/13 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:53 +03
"golden_opt_run_opt" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_opt_run_opt" end time: Jun 19 15:53 +03
"golden_opt_run_opt" end time: Jun 19 15:59 +03
"golden_opt_run_opt" time elapsed: 00:00:00
----------------------------------------------------------
11/12 Testing: golden_opt_run_opt_run_opt
11/12 Test: golden_opt_run_opt_run_opt
12/13 Testing: golden_opt_run_opt_run_opt
12/13 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:53 +03
"golden_opt_run_opt_run_opt" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_opt_run_opt_run_opt" end time: Jun 19 15:53 +03
"golden_opt_run_opt_run_opt" end time: Jun 19 15:59 +03
"golden_opt_run_opt_run_opt" time elapsed: 00:00:00
----------------------------------------------------------
12/12 Testing: golden_string_hello
12/12 Test: golden_string_hello
13/13 Testing: golden_string_hello
13/13 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:53 +03
"golden_string_hello" start time: Jun 19 15:59 +03
Output:
----------------------------------------------------------
<end of output>
Test time = 0.01 sec
----------------------------------------------------------
Test Passed.
"golden_string_hello" end time: Jun 19 15:53 +03
"golden_string_hello" end time: Jun 19 15:59 +03
"golden_string_hello" time elapsed: 00:00:00
----------------------------------------------------------
End testing: Jun 19 15:53 +03
End testing: Jun 19 15:59 +03

View File

@ -216,21 +216,14 @@ void IRGenerator::generateStatement(ASTNode* node) {
if (dw->body) generateStatement(dw->body);
int condSlot = generateExpression(dw->condition);
// Koşul doğruysa geri atla (1 = doğru → atla; 0 = yanlış → devam)
// JIF_FALSE koşul yanlışsa atlar; biz doğruysa atlamak istiyoruz.
// Bu yüzden JIF_FALSE yerine "doğruysa atla" mantığı lazım.
// Basit çözüm: koşulun tersini al (0→1, diğer→0) ve JIF_FALSE kullan.
// NOT: saQut'ta "!" operatörü yok henüz; NOT talimatı eklenebilir.
// Şimdilik: koşul slotuna bak, sıfır değilse geri atla.
// TODO(vm-genişletme): JIF_TRUE talimatı ekle
// Geçici çözüm: sabit 1 ile karşılaştır (condSlot != 0 → geri)
int oneSlot = freshSlot();
emitLoadConst(oneSlot, 1);
int eqSlot = freshSlot();
emitBinaryOp(Opcode::EQUAL_EQUAL, eqSlot, condSlot, oneSlot);
int skipJump = emitJumpIfFalse(eqSlot); // koşul yanlışsa döngüden çık
emitJumpUnconditional(loopStart); // geri atla
patchJump(skipJump);
// 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;
}

View File

@ -0,0 +1,4 @@
1
2
3
5

View File

@ -0,0 +1,25 @@
// B4 regresyon testi: do-while koşulu 1-olmayan sıfır-dışı değer üretince
// döngü yanlışlıkla çıkmamalı ("== 1" geçici çözümü bu hatayı veriyordu).
//
// Test 1: koşul 2 üretiyor — döngü 3 kez dönmeli (i: 0→1→2, çıkış i==3)
// Test 2: koşul 0 olunca düzgün çıkıyor — döngü 1 kez dönmeli
int main() {
// Koşul 2 (1-olmayan truthy): döngü erken çıkmamalı
int i = 0;
do {
i = i + 1;
print(i);
} while (i < 3);
// i<3 sonucu: i=1→1, i=2→1, i=3→0; çıktı: 1 2 3
// Koşul 0: tek iterasyon, gövde bir kez çalışır
int j = 5;
do {
print(j);
j = 0;
} while (j);
// j=5 → print(5), j=0 → while(0) → çıkış; çıktı: 5
return 0;
}