Skip to content

feat: Comprehensive interpreter improvements for control flow and operators#207

Merged
fglock merged 1 commit into
masterfrom
feature/interpreter-only
Feb 18, 2026
Merged

feat: Comprehensive interpreter improvements for control flow and operators#207
fglock merged 1 commit into
masterfrom
feature/interpreter-only

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Feb 18, 2026

Summary

This PR consolidates multiple interpreter enhancements for control flow and operators, improving compatibility with Perl semantics.

Features Added

  • ✅ Negated regex match (!~) operator support
  • ✅ last/next/redo operators with label support
  • ✅ Proper do-while loop handling (prevent last/next/redo)
  • ✅ 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

Total: 4 files changed, 381 insertions(+), 64 deletions(-)

Test Results

  • make passes (unit tests)
  • re/regexp.t: 1786/2210 passing (80.8%)

Test Plan

  • Run make to verify build and unit tests
  • Run perl dev/tools/perl_test_runner.pl perl5_t/t/re/regexp.t
  • Merge after approval and CI passes

🤖 Generated with Claude Code

…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>
@fglock fglock merged commit 37df70c into master Feb 18, 2026
2 checks passed
@fglock fglock deleted the feature/interpreter-only branch February 18, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant