WIP: Add Moo object system support#319
Merged
Merged
Conversation
Phase 1 - Replace Java-based Carp with Perl Carp.pm: - Delete Carp.java (only had basic functions) - Import full Carp.pm and Carp/Heavy.pm from perl5/dist/Carp - Update DBI.java to use WarnDie directly instead of Carp Phase 2 - Fix string interpolation bug with @;: - Added non-identifier characters to isNonInterpolatingCharacter() - Fixes: "\$@;" now correctly produces "$@;" instead of "$" Phase 3 - In progress: - Investigating Method::Generate::Constructor->new() returning undef - BUILDARGS works correctly, bless appears to return undef - Root cause still under investigation Pending: - Phase 4: Fix parser bug with x => syntax (treated as string rep operator) - Phase 5: End-to-end Moo testing See dev/design/moo_support.md for full details. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
This commit addresses two issues preventing Moo from working correctly:
1. Parser fix: `x =>` is now correctly autoquoted as a bareword
- In ListParser.looksLikeEmptyList(), `x` followed by `=>` was being
treated as an infix operator, causing empty list detection
- Added check: when `x` is followed by `=>`, don't treat it as empty list
- In Parser.parseExpression(), `x=` followed by `>` now breaks parsing
to allow `x` to be treated as a bareword
2. Tailcall trampoline for method calls (goto &$coderef fix)
- Added TAILCALL handling in Dereference.java for method calls
- When RuntimeCode.callCached() returns a TAILCALL marker, the
trampoline loop now processes it at the call site
- Made EmitSubroutine.emitBlockDispatcher() package-visible
These fixes allow Moo's `has x => (is => "ro")` syntax to work correctly.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
- Phase 1: Carp.pm replacement ✓ - Phase 2: @; string interpolation fix ✓ - Phase 3: goto &$coderef JVM fix ✓ - Phase 4: x => parser fix ✓ - Phase 5: End-to-end testing ✓ Added next steps for future enhancements: - Test Moo::Role support - Test more attribute options - Performance testing - Add Moo tests to test suite - Document in README Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
The jcpan wrapper was still referencing the obsolete jcpan.pl which was removed in commit 7606d38. Updated to use src/main/perl/bin/cpan like jcpan.bat does. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
The Storable.java deserializeFromYAML() method was using the default SnakeYAML limit of 3MB, causing "retrieve failed" errors when reading large CPAN metadata files. Added setCodePointLimit(50 * 1024 * 1024) to match YAMLPP.java. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Added current objectives: 1. Moo tests run inside jcpan 2. Moo tests pass (40/71 currently passing) Added test failure analysis and Phase 6 (jcpan/Storable fixes). Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Moo is not a goal in itself - it is a test case for CPAN integration. All Moo tests must pass to validate that: - jcpan can install CPAN modules correctly - jcpan can run module tests - Complex pure-Perl CPAN modules work in PerlOnJava Current status: 40/71 tests passing (BLOCKING) Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
The parser was incorrectly treating @{*{expr}} as hash subscript
on @* (the special variable). Now it correctly parses it as array
dereference of glob dereference: @{ *{expr} }
This fix consists of two parts:
1. In IdentifierParser.parseComplexIdentifierInner: When * is followed
by {, return null to force fallback to expression parsing
2. In Variable.parseBracedVariable: Only unwrap the * operator when
the operand is a simple IdentifierNode (for ${*F} -> $F), not when
it's a complex expression like *{$x}
This enables Moo's extends functionality which uses the pattern:
@{*{_getglob("${target}::ISA")}} = @_
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
1. IdentifierParser: Only apply *{ glob dereference fix when inside braces
- @{*{expr}} parses as array of glob deref (correct)
- @*{key} parses as hash slice on @* (correct, no longer broken)
2. StringSegmentParser: Fix @; interpolation without breaking $/
- Added isValidArrayVariableStart() to check valid array var chars
- @; is NOT interpolated (correct, not a valid array variable)
- $/ IS interpolated (correct, valid scalar variable)
- Reverted overly aggressive isNonInterpolatingCharacter changes
These fixes resolve the test regressions:
- op/chop.t: 137/148 (was 135, matches master)
- op/concat2.t: 3/4 (was 2, matches master)
- op/magic.t: 170/208 (was 169, matches master)
- re/regexp.t: 1786/2210 (was 1709, matches master)
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
Return 1 to indicate reference-counted stack behavior. This is appropriate for PerlOnJava since Java GC keeps objects alive as long as they are referenced, similar to Perl RC stack builds. This fix enables op/array.t tests 136-199 to run (they were being skipped or causing OOM due to the unimplemented function returning undef). Test results improved from 116 to 175 passing tests. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <noreply@cognition.ai>
Enhanced comments to prevent accidental reversion of critical fixes:
- IdentifierParser.java: Explain glob dereference fix for Moo extends
- Variable.java: Document when *{expr} should remain as glob dereference
- StringSegmentParser.java: Explain @; vs $/ interpolation distinction
- Parser.java/ListParser.java: Document x => autoquoting for Moo hashes
- Internals.java: Explain why stack_refcounted must return 1 for tests
All comments reference the specific tests or features that would break
if the code were reverted.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <noreply@cognition.ai>
- Added Issue 5: Parser bug with @{*{expr}} glob dereference (FIXED)
- Added Issue 6: Internals::stack_refcounted() not implemented (FIXED)
- Added Phase 7: Fix parser for @{*{expr}} enabling Moo extends
- Added Phase 8: Implement stack_refcounted (op/array.t 116->175)
- Updated test results table showing all baselines met
- Added inheritance example with extends keyword
- Updated commit list with all recent commits
- Changed status to TESTING (verify Moo extends works)
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
This PR adds support for the Moo object system in PerlOnJava.
Completed
Phase 1: Replaced Java-based Carp with Perl's full Carp.pm
Carp.java(only implemented basic functions)Carp.pmandCarp/Heavy.pmfrom perl5/dist/CarpDBI.javato use WarnDie directlyPhase 2: Fixed string interpolation bug with
@;"\$@;"now correctly produces "$@;" instead of "$"isNonInterpolatingCharacter()In Progress
Method::Generate::Constructor->new()returning undefblessappears to return undef in bootstrap contextPending
x =>syntax (treated as string repetition operator instead of autoquoted bareword)Test Plan
use Moo;loads successfullyhas x => (is => 'ro')syntax parses correctlyDesign Document
See
dev/design/moo_support.mdfor full details and progress tracking.Generated with Devin