Navigation Menu

Skip to content

Commit

Permalink
Keep track of what code object we're in.
Browse files Browse the repository at this point in the history
Variable traits need to know the currently surrounding code object. We
cannot use $*DECLARAND safely for this, since that may not map to a
code object at all. This doesn't fix much, it's just a refactor to
allow a fix.
  • Loading branch information
jnthn committed Jun 23, 2015
1 parent 379ece6 commit 46caea2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -2514,7 +2514,7 @@ Compilation unit '$file' contained the following violations:
nqp::bindattr_s($varvar, $Variable, '$!name', $name);
nqp::bindattr_s($varvar, $Variable, '$!scope', $*SCOPE);
nqp::bindattr($varvar, $Variable, '$!var', $cont);
nqp::bindattr($varvar, $Variable, '$!block', $*DECLARAND);
nqp::bindattr($varvar, $Variable, '$!block', $*CODE_OBJECT);
nqp::bindattr($varvar, $Variable, '$!slash', $/);
for $trait_list {
my $applier := $_.ast;
Expand Down
7 changes: 7 additions & 0 deletions src/Perl6/Grammar.nqp
Expand Up @@ -1014,6 +1014,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*HAS_SELF := ''; # is 'self' available? (for $.foo style calls)
:my $*begin_compunit := 1; # whether we're at start of a compilation unit
:my $*DECLARAND; # the current thingy we're declaring, and subject of traits
:my $*CODE_OBJECT; # the code object we're currently inside
:my $*METHODTYPE; # the current type of method we're in, if any
:my $*PKGDECL; # what type of package we're in, if any
:my %*MYSTERY; # names we assume may be post-declared functions
Expand Down Expand Up @@ -1205,6 +1206,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {

token pblock($*IMPLICIT = 0) {
:my $*DECLARAND := $*W.stub_code_object('Block');
:my $*CODE_OBJECT := $*DECLARAND;
:my $*SIG_OBJ;
:my %*SIG_INFO;
:dba('block or pointy block')
Expand Down Expand Up @@ -1251,6 +1253,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {

token block($*IMPLICIT = 0) {
:my $*DECLARAND := $*W.stub_code_object('Block');
:my $*CODE_OBJECT := $*DECLARAND;
:dba('scoped block')
[ <?[{]> || <.missing: 'block'>]
<.newpad>
Expand Down Expand Up @@ -2388,6 +2391,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
:my $*DECLARAND := $*W.stub_code_object('Sub');
:my $*CODE_OBJECT := $*DECLARAND;
:my $*CURPAD;
:my $*SIG_OBJ;
:my %*SIG_INFO;
Expand Down Expand Up @@ -2458,6 +2462,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
:my $*DECLARAND := $*W.stub_code_object($d eq 'submethod' ?? 'Submethod' !! 'Method');
:my $*CODE_OBJECT := $*DECLARAND;
:my $*SIG_OBJ;
:my %*SIG_INFO;
{
Expand Down Expand Up @@ -2519,6 +2524,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
:my $*DECLARAND := $*W.stub_code_object('Macro');
:my $*CODE_OBJECT := $*DECLARAND;
{
if $*PRECEDING_DECL_LINE < $*LINE_NO {
$*PRECEDING_DECL_LINE := $*LINE_NO;
Expand Down Expand Up @@ -2797,6 +2803,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
{ $*DECLARATOR_DOCS := '' }
:my $*POD_BLOCK;
:my $*DECLARAND := $*W.stub_code_object('Regex');
:my $*CODE_OBJECT := $*DECLARAND;
{
if $*PRECEDING_DECL_LINE < $*LINE_NO {
$*PRECEDING_DECL_LINE := $*LINE_NO;
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/World.nqp
Expand Up @@ -367,7 +367,7 @@ class Perl6::World is HLL::World {
self.install_lexical_symbol($*UNIT, 'EXPORT', $*EXPORT);
self.install_lexical_symbol($*UNIT, '$?PACKAGE', $*PACKAGE);
self.install_lexical_symbol($*UNIT, '::?PACKAGE', $*PACKAGE);
$*DECLARAND := self.stub_code_object('Block');
$*CODE_OBJECT := $*DECLARAND := self.stub_code_object('Block');

# initialize %?INC if not in an eval
unless $in_eval {
Expand Down

0 comments on commit 46caea2

Please sign in to comment.