Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Track down a couple of issues relating to enums and role punning, whi…
…ch were causing test fails, plus track down a bug with .perl on roles.
  • Loading branch information
jnthn committed Jun 1, 2009
1 parent ff312ab commit 03e90ad
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/builtins/guts.pir
Expand Up @@ -495,7 +495,7 @@ and putting it in the namespace if it doesn't already exist.
transform_to_p6opaque role_obj
set_root_global ns, short_name, role_obj
$P0 = box short_name
setprop role_obj, "$!shortname", $P0
setattribute role_obj, "$!shortname", $P0
have_role_obj:

# Add this variant.
Expand Down Expand Up @@ -1318,7 +1318,7 @@ Internal helper method to create a role with a single parameterless variant.
transform_to_p6opaque role

$P0 = box name
setprop role, '$!shortname', $P0
setattribute role, '$!shortname', $P0
role.'!add_variant'(helper)

# Store it in the namespace.
Expand Down
7 changes: 6 additions & 1 deletion src/classes/List.pir
Expand Up @@ -214,11 +214,16 @@ layer. It will likely change substantially when we have lazy lists.
elem = self[i]
$I0 = isa elem, 'Perl6Scalar'
if $I0 goto flat_next
# always treat a Junction and Whatever as one item, whether they can !flatten or not
# always treat a Junction, Role and Whatever as one item, whether they can !flatten or not
# XXX this is due to can giving dubious answers due to auto-thread/pun/closure creation
$I0 = isa elem, 'Junction'
if $I0 goto flat_next
$I0 = isa elem, 'Whatever'
if $I0 goto flat_next
$I0 = isa elem, 'Perl6Role'
if $I0 goto flat_next
$I0 = isa elem, 'P6role'
if $I0 goto flat_next
$I0 = can elem, '!flatten'
if $I0 goto flat_elem
$I0 = does elem, 'array'
Expand Down
9 changes: 5 additions & 4 deletions src/classes/Role.pir
Expand Up @@ -23,7 +23,7 @@ short name for a particular set of parameters.
.sub 'onload' :anon :init :load
.local pmc p6meta, roleproto
p6meta = get_hll_global ['Perl6Object'], '$!P6META'
roleproto = p6meta.'new_class'('Perl6Role', 'parent'=>'Any', 'name'=>'Role', 'attr'=>'$!selector $!created')
roleproto = p6meta.'new_class'('Perl6Role', 'parent'=>'Object', 'name'=>'Role', 'attr'=>'$!selector $!created $!shortname')
p6meta.'register'('P6role', 'proto'=>'roleproto')
.end

Expand Down Expand Up @@ -212,7 +212,8 @@ just here so postcircumfix:[ ] doesn't explode).
=cut

.sub 'perl' :method
$P0 = getprop '$!shortname', self
$P0 = getattribute self, '$!shortname'
$S0 = $P0
.return ($S0)
.end

Expand Down Expand Up @@ -241,7 +242,7 @@ just here so postcircumfix:[ ] doesn't explode).
=cut

.sub 'Str' :method :vtable('get_string')
$P0 = getprop '$!shortname', self
$P0 = getattribute self, '$!shortname'
$S0 = $P0
concat $S0, '()'
.return ($S0)
Expand All @@ -255,7 +256,7 @@ just here so postcircumfix:[ ] doesn't explode).
.param pmc named_args :slurpy :named
$I0 = isa role, 'P6role'
if $I0 goto already_selected
role = role.'!select'(pos_args :flat, named_args :flat :named)
role = role.'!select'()
already_selected:
$P0 = interpinfo .INTERPINFO_CURRENT_SUB
$P0 = getprop 'name', $P0
Expand Down
2 changes: 2 additions & 0 deletions src/pmc/p6role.pmc
Expand Up @@ -37,6 +37,8 @@ pmclass P6role extends Role need_ext dynpmc group perl6_group {
return SUPER(name);
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "WHAT")))
return SUPER(name);
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "Scalar")))
return SUPER(name);
first_char = Parrot_str_substr(interp, name, 0, 1, NULL, 0);
if (Parrot_str_equal(interp, first_char, CONST_STRING(interp, "!")))
return SUPER(name);
Expand Down

0 comments on commit 03e90ad

Please sign in to comment.