feat: Comprehensive interpreter improvements for control flow and operators#207
Merged
Conversation
…rators This commit consolidates multiple interpreter enhancements: Features: - Add negated regex match (!~) operator support - Implement last/next/redo operators with label support - Add proper do-while loop handling (prevent last/next/redo) - Implement ScalarSpecialVariable handling using addToScalar Fixes: - Use STRING bitwise operators by default instead of INTEGER operators - Evaluate while/if conditions in SCALAR context (was LIST context) - Fix context propagation for logical operators (&&, ||, //) - Fix context propagation for regex matches in LIST context Implementation Details: - BytecodeCompiler: Added BITWISE_AND_STR, BITWISE_OR_STR, BITWISE_XOR_STR opcodes - BytecodeCompiler: Added LAST, NEXT, REDO, LAST_LABEL, NEXT_LABEL, REDO_LABEL opcodes - BytecodeCompiler: Added REGEX_NOT_MATCH opcode for !~ operator - BytecodeCompiler: Improved control flow handling for loops - BytecodeInterpreter: Implemented loop control operators with label resolution - InterpretedCode: Added pushLoopLabels/popLoopLabels for label tracking - Opcodes: Extended with new operation codes for control flow and operators Files Modified: - BytecodeCompiler.java: +353/-53 lines - BytecodeInterpreter.java: +48/-8 lines - InterpretedCode.java: +19/-0 lines - Opcodes.java: +25/-3 lines Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates multiple interpreter enhancements for control flow and operators, improving compatibility with Perl semantics.
Features Added
Fixes
Implementation Details
Files Modified
BytecodeCompiler.java: +353/-53 linesBytecodeInterpreter.java: +48/-8 linesInterpretedCode.java: +19/-0 linesOpcodes.java: +25/-3 linesTotal: 4 files changed, 381 insertions(+), 64 deletions(-)
Test Results
makepasses (unit tests)re/regexp.t: 1786/2210 passing (80.8%)Test Plan
maketo verify build and unit testsperl dev/tools/perl_test_runner.pl perl5_t/t/re/regexp.t🤖 Generated with Claude Code