Created
July 8, 2011 09:27
-
-
Save tadzik/1071441 to your computer and use it in GitHub Desktop.
Segmentation fun
This file contains 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
┌─[tadzik@yavin4]─[~/src/nom] (podparser) | |
└─[%]─> g diff | cat | |
diff --git a/src/core/Mu.pm b/src/core/Mu.pm | |
index 4e89251..e3cbb0f 100644 | |
--- a/src/core/Mu.pm | |
+++ b/src/core/Mu.pm | |
@@ -106,8 +106,17 @@ my class Mu { | |
multi method gist(Mu:D:) { self.Stringy } | |
proto method perl(|$) { * } | |
- multi method perl(Mu:D:) { self.Str } | |
multi method perl(Mu:U:) { self.HOW.name(self) } | |
+ multi method perl(Mu:D:) { | |
+ my $type = self.HOW.name(self); | |
+ $type ~ '.new(' ~ self.^attributes.map({ | |
+ substr($_.name, 2, nqp::chars($_.name)) | |
+ ~ ' => ' | |
+ ~ nqp::getattr( | |
+ pir::perl6_decontainerize__PP(self), $type, $_.name | |
+ ).perl | |
+ }).join(',') ~ ')'; | |
+ } | |
proto method DUMP(|$) { * } | |
multi method DUMP(Mu:D:) { self.perl } | |
┌─[tadzik@yavin4]─[~/src/nom] (podparser) | |
└─[%]─> ./perl6 -e 'class A { has $.a }; my $a = A.new(a => 7); $a.perl.say' | |
zsh: segmentation fault ./perl6 -e 'class A { has $.a }; my $a = A.new(a => 7); $a.perl.say' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment