Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes that get .^parent working. Also .WHAT always now gives back thi…
…ngs wrapped in a scalar container. Why? So Iterable proto-objects don't go trying to flatten, and subsequently go KABOOM.
  • Loading branch information
jnthn committed Feb 18, 2010
1 parent bf29be0 commit 43909a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -1188,7 +1188,10 @@ method type_constraint($/) {
if $*PARAMETER.nom_type {
$/.CURSOR.panic('Parameter may only have one prefix type constraint');
}
$*PARAMETER.nom_type(PAST::Op.new( :pasttype('callmethod'), :name('WHAT'), $<value>.ast ));
$*PARAMETER.nom_type(PAST::Op.new(
:pirop('deobjectref__PP'),
PAST::Op.new( :pasttype('callmethod'), :name('WHAT'), $<value>.ast )
));
$*PARAMETER.cons_types.push($<value>.ast);
}
else {
Expand Down
16 changes: 11 additions & 5 deletions src/metamodel/ClassHOW.pir
Expand Up @@ -402,6 +402,9 @@ Gets a list of this class' parents.
# Get the parrot class.
parrot_class = self.'get_parrotclass'(obj)
unless null parrot_class goto got_parrotclass
parrot_class = getattribute self, 'parrotclass'
got_parrotclass:
# Fake top of Perl 6 hierarchy.
$S0 = parrot_class.'name'()
Expand Down Expand Up @@ -649,17 +652,20 @@ Gets a list of roles done by the class of this object.
=item WHAT

Overridden since WHAT inherited from P6metaclass doesn't quite work out.
XXX Work out exactly why.
Also we want to wrap it up to make it always a scalar (otherwise List
will try to flatten etc).
=cut
.sub 'WHAT' :method
$P0 = getattribute self, 'protoobject'
if null $P0 goto proto_of_how
.return ($P0)
proto_of_how:
unless null $P0 goto wrap_result
$P0 = self.'HOW'()
.tailcall $P0.'WHAT'()
$P0 = $P0.'WHAT'()
wrap_result:
$P0 = new ['ObjectRef'], $P0
setprop $P0, 'scalar', $P0
.return ($P0)
.end
Expand Down

0 comments on commit 43909a0

Please sign in to comment.