Interpreter fixes: lvalue assignment and JFFI warnings#289
Merged
Conversation
Add --sun-misc-unsafe-memory-access=allow JVM option to jperl and jperl.bat to suppress warnings from JFFI library about deprecated sun.misc.Unsafe methods. Also add comments explaining both JVM options and when they can be removed. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Use LValueVisitor.getContext() to properly determine RHS context for all
LHS patterns including $array[index] and $hash{key} assignments.
Previously, the interpreter used manual checks that only covered simple
scalar assignments ($x = ...) but not array/hash element assignments.
This caused `$_[0] = <$fh>` to incorrectly use LIST context for readline,
reading all lines instead of one line respecting $/.
This fix improves ExifTool.t in interpreter mode from ~3/35 to 8/35 passing.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
When compiling hash literals like { @list }, elements must be compiled
in LIST context so arrays are flattened to their elements. Previously,
the current context was used, which could be SCALAR, causing @list to
return its count instead of its elements.
This fixes "Odd number of elements in anonymous hash" warnings in
ExifTool tests.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
Modified ARRAY_SET and HASH_SET opcodes to return the lvalue (the actual
container element) in a destination register. This fixes operations like:
($hash{KEY} = $value) =~ s/pattern/replacement/;
($array[0] = $value) =~ s/pattern/replacement/;
Previously, the substitution would modify a copy of the value instead of
the actual hash/array element, because the assignment returned the original
RHS value rather than the stored element.
Changes:
- ARRAY_SET format: rd arrayReg indexReg valueReg (returns element in rd)
- HASH_SET format: rd hashReg keyReg valueReg (returns element in rd)
- Updated InlineOpcodeHandler, Disassemble, CompileAssignment, Opcodes
This improves ExifTool.t interpreter tests from 8/35 to 16/35 passing.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
Comprehensive plan for unifying backend compilation through a shared AST transformation pass that annotates: - Context resolution (scalar/list/void for each node) - Call context (wantarray propagation to subroutine calls) - Operator argument contexts (per-argument context requirements) - Lvalue detection (for s///, tr///, ++, etc.) - Variable binding (links uses to declarations, same $x detection) - Closure capture (collected captured variables) - Label resolution (goto/next/last/redo targets) - Pragma tracking (strict/warnings/features per scope) - Constant folding integration (existing ConstantFoldingVisitor) - Compile-time warnings Includes 10-milestone implementation plan with differential testing against native Perl at each step. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Point implementers to relevant skills for debugging and testing: - interpreter-parity (primary skill for this work) - debug-perlonjava (general debugging) - debug-exiftool (real-world module testing) - profile-perlonjava (performance validation) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Added Phase 3.5: BlockAnalyzer that integrates existing visitors: - FindDeclarationVisitor for 'local' operator tracking - RegexUsageDetector for regex state save/restore optimization This enables: - Correct dynamic scoping (save/restore at block boundaries) - Optimized regex state handling (only save when regex is used) - Both backends read annotations instead of duplicating detection Also added annotations: containsLocal, localDeclarations, containsRegex Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
- Create AGENTS.md with project rules including progress tracking requirement - Expand shared_ast_transformer.md with: - Existing AbstractNode annotation infrastructure analysis - Inventory of all 12 existing visitors (categorized as shared vs JVM-specific) - LValueVisitor integration notes for LvalueResolver phase - Progress Tracking section with current status and next steps - Mark DepthFirstLiteralRefactorVisitor as obsolete (compiler falls back to interpreter) - Update .gitignore to allow AGENTS.md Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
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
Details
JFFI Warnings
Added
--sun-misc-unsafe-memory-access=allowtojperlandjperl.batlaunchers to suppress the sun.misc.Unsafe deprecation warnings from JFFI library.Lvalue Assignment Fix
Modified ARRAY_SET and HASH_SET opcodes to return the lvalue (the actual container element) in a destination register. This fixes operations like:
Previously, the substitution would modify a copy of the value instead of the actual hash/array element.
Hash Literal Context Fix
Fixed hash literal elements like
{ @list }being compiled in the wrong context - arrays were returning their count instead of their elements.Test Results
Generated with Devin