feat(opt): sabit katlama'ya mantıksal operatörler ekle (&&, ||)

canFoldOp ve computeOp'a AMPERSAND_AMPERSAND ve PIPE_PIPE eklendi.
false && false, true || false gibi sabit mantıksal ifadeler artık
derleme zamanında 0/1 literaline katlanır.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
abdussamedulutas 2026-06-18 21:16:35 +03:00
parent 044655d675
commit 3d5912f991
1 changed files with 6 additions and 2 deletions

View File

@ -65,6 +65,8 @@ private:
case TokenType::GREATER:
case TokenType::LESS_EQUAL:
case TokenType::GREATER_EQUAL:
case TokenType::AMPERSAND_AMPERSAND:
case TokenType::PIPE_PIPE:
return true;
default:
return false;
@ -83,8 +85,10 @@ private:
case TokenType::LESS: return l < r ? 1 : 0;
case TokenType::GREATER: return l > r ? 1 : 0;
case TokenType::LESS_EQUAL: return l <= r ? 1 : 0;
case TokenType::GREATER_EQUAL: return l >= r ? 1 : 0;
default: return 0;
case TokenType::GREATER_EQUAL: return l >= r ? 1 : 0;
case TokenType::AMPERSAND_AMPERSAND: return (l && r) ? 1 : 0;
case TokenType::PIPE_PIPE: return (l || r) ? 1 : 0;
default: return 0;
}
}