Skip to content

Commit

Permalink
Start to store attribute type constraints so we can introspect them.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 12, 2010
1 parent 6fe0817 commit 46e9ac2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -916,7 +916,8 @@ sub declare_variable($/, $past, $sigil, $twigil, $desigilname, $trait_list) {
}
my %attr_info;
%attr_info<name> := $attrname;
%attr_info<accessor> := $twigil eq '.' ?? 1 !! 0;
%attr_info<type> := $*TYPENAME;
%attr_info<accessor> := $twigil eq '.' ?? 1 !! 0;
%attr_info<rw> := $trait_list && has_compiler_trait_with_val($trait_list, '&trait_mod:<is>', 'rw') ?? 1 !! 0;
@PACKAGE[0].attributes.push(%attr_info);

Expand Down
4 changes: 4 additions & 0 deletions src/Perl6/Compiler/Package.pm
Expand Up @@ -177,6 +177,10 @@ method finish($block) {
$_<build>.named('build');
$attr.push($_<build>);
}
if $_<type> ~~ PAST::Node {
$_<type>.named('type');
$attr.push($_<type>);
}
$decl.push(PAST::Op.new(
:pasttype('callmethod'),
:name('add_attribute'),
Expand Down
1 change: 1 addition & 0 deletions src/metamodel/Attribute.nqp
Expand Up @@ -63,6 +63,7 @@ method compose($package) {
my $meth := $!rw ?? pir::find_lex__Ps('accessor_helper_rw') !! pir::find_lex__Ps('accessor_helper_ro');
my $meth_name := pir::substr__SSi($name, 2);
$meth := pir::clone($meth);

# introspection looks at the actual sub name, so set it
# to the value the user expects
# set $P0, $S0 is parrot's clunky PIR API for setting the sub name.
Expand Down

0 comments on commit 46e9ac2

Please sign in to comment.