Skip to content

Commit

Permalink
Implement accessor attribute for Attribute descriptor class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jul 22, 2009
1 parent 94b741a commit 8c79a13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/parrot/ClassHOW.pir
Expand Up @@ -82,16 +82,31 @@ Attribute descriptors.
unless attr_it goto attr_it_loop_end
$S0 = shift attr_it
cur_attr_hash = attributes[$S0]

# Name
$S0 = cur_attr_hash['name']

# Type
$P0 = cur_attr_hash['type']
unless null $P0 goto type_done
$P0 = get_root_global [.RAKUDO_HLL], 'Object'
type_done:

# Build
$P1 = cur_attr_hash['init_value']
unless null $P1 goto build_done
$P1 = root_new [.RAKUDO_HLL; 'Failure']
build_done:
cur_attr_info = attr_proto.'new'('name' => $S0, 'type' => $P0, 'build' => $P1)

# Accessor
$P2 = cur_attr_hash['accessor']
unless null $P2 goto accessor_done
$P2 = box 0
accessor_done:
$P3 = get_root_global [.RAKUDO_HLL], 'prefix:?'
$P2 = $P3($P2)

cur_attr_info = attr_proto.'new'('name' => $S0, 'type' => $P0, 'build' => $P1, 'accessor' => $P2)
result_list.'push'(cur_attr_info)
goto attr_it_loop
attr_it_loop_end:
Expand Down
3 changes: 3 additions & 0 deletions src/parser/actions.pm
Expand Up @@ -1737,6 +1737,9 @@ method scope_declarator($/) {
$init_value.named('init_value');
$has.push($init_value);
}
if $var<twigil> eq '.' {
$has.push(PAST::Val.new( :value(1), :named('accessor') ));
}
if $var<traitlist> {
# If we have a handles, then we pass that specially.
my $handles := has_compiler_trait($var<traitlist>, 'trait_mod:handles');
Expand Down
1 change: 1 addition & 0 deletions src/setting/Attribute.pm
Expand Up @@ -2,6 +2,7 @@ class Attribute {
has $.name;
has $.type;
has $.build;
has $.accessor;
}

# vim: ft=perl6

0 comments on commit 8c79a13

Please sign in to comment.