Skip to content

Commit

Permalink
[Yapsi] made labels globally unique
Browse files Browse the repository at this point in the history
Because they were only unique for each block, the label lookup (which
traverses the whole SIC) accidentally the whole call stack in some cases.
  • Loading branch information
Carl Masak committed Sep 1, 2010
1 parent c65b333 commit 96ca8f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Yapsi.pm
Expand Up @@ -157,6 +157,7 @@ class Yapsi::Compiler {
my @sic = "This is SIC v$VERSION";
my $INDENT = ' ';
my %package-variables;
my $*l = 0; # unique label counter
traverse-top-down($/, :action(-> $m, $key {
if $key eq 'TOP'|'block'|'else' {
push @sic, '';
Expand All @@ -167,7 +168,6 @@ class Yapsi::Compiler {
}
my @blocksic;
my $*c = 0; # unique register counter
my $*l = 0; # unique label counter
my @skip = 'block', 'statement_control_if',
'statement_control_while_until',
'statement_control_unless';
Expand Down
2 changes: 2 additions & 0 deletions t/runtime.t
Expand Up @@ -45,6 +45,8 @@ my @tests =
'my $a = 42; { { say $a; } }', "42\n", 'var lookup >1 block up',
'our $a; { my $a = 1; { our $a; $a = 5 } }; say $a',
"5\n", 'our lookup',
'my $a = 0; my $b = 0; until $a { if $b { $a = 1 }; say ++$b }',
"1\n2\n", 'nested jumps in SIC',
;

for @tests -> $program, $expected, $message {
Expand Down

0 comments on commit 96ca8f0

Please sign in to comment.