Permalink
Browse files

declare sigilless variables in method defterm, jnthn++

  • Loading branch information...
1 parent 6f4df39 commit 5533f75c7f1704122ab68bb889aafacf33d8e924 @moritz moritz committed Aug 13, 2012
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/Perl6/Actions.pm
View
@@ -2870,9 +2870,25 @@ class Perl6::Actions is HLL::Actions {
}
method defterm($/) {
- %*PARAM_INFO<variable_name> := ~$<identifier>;
- %*PARAM_INFO<desigilname> := ~$<identifier>;
+ my $name := ~$<identifier>;
+ %*PARAM_INFO<variable_name> := $name;
+ %*PARAM_INFO<desigilname> := $name;
%*PARAM_INFO<sigil> := '';
+ my $cur_pad := $*W.cur_lexpad();
+ if $cur_pad.symbol($name) {
+ $*W.throw($/, ['X', 'Redeclaration'], symbol => $name);
+ }
+ if nqp::existskey(%*PARAM_INFO, 'nominal_type') {
+ $cur_pad[0].push(QAST::Var.new( :$name, :scope('lexical'),
+ :decl('var'), :returns(%*PARAM_INFO<nominal_type>) ));
+ %*PARAM_INFO<container_descriptor> := $*W.create_container_descriptor(
+ %*PARAM_INFO<nominal_type>, 0, %*PARAM_INFO<variable_name>);
+ $cur_pad.symbol(%*PARAM_INFO<variable_name>, :descriptor(%*PARAM_INFO<container_descriptor>),
+ :type(%*PARAM_INFO<nominal_type>));
+ } else {
+ $cur_pad[0].push(QAST::Var.new( :name(~$/), :scope('lexical'), :decl('var') ));
+ }
+ $cur_pad.symbol(~$/, :scope('lexical'));
}
method default_value($/) {

0 comments on commit 5533f75

Please sign in to comment.