abdussamedulutas
|
9b486942c0
|
feat(ir-vm): fibonacci.sqt çalışıyor — IR üretici + bytecode VM
IR instruction seti (14 opcode): LOAD_CONST, LOAD_SLOT, ADD/SUB/MUL/DIV/MOD,
LESS/LEQ/GT/GEQ/EQ/NEQ, JMP, JIF_FALSE, CALL, RETURN, CALLHOST
IRGenerator (AST → IR):
- Slot tabanlı register: parametreler slot 0..n, lokaller/geçiciler sonrası
- freshSlot() monoton sayaç — slot asla geri verilmez
- Backpatch: ileri-jump için emitJumpIfFalse(-1) → patchJump(idx)
- Geri-jump: loopStart = currentInstrIndex() → emitJumpUnconditional(loopStart)
- Builtin tespiti: resolvedSymbol->isBuiltin → CALLHOST
Interpreter (bytecode VM):
- Her iterasyonda callStack.back() taze alınır (referans güvenliği)
- CALL: yeni frame + argüman kopyası + continue
- RETURN: değer caller slotuna, frame pop + continue
- ip CALL/RETURN'den önce ilerler — caller doğru noktadan devam eder
- DIV: sıfıra bölme → runtime_error
Doğrulama:
build/saqut run file:examples/fibonacci.sqt → 55 / 55 ✓
tests/run.sh → TUM TESTLER GECTI ✓
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
2026-06-18 19:17:30 +03:00 |