Skip to content

Commit

Permalink
Generate control exn records for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Sep 15, 2010
1 parent a413960 commit 2d649c9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Kernel.cs
Expand Up @@ -155,7 +155,8 @@ public class SubInfo {
// records: $start-ip, $end-ip, $type, $goto, $lid
public const int ON_NEXT = 1;
public const int ON_LAST = 2;
public const int ON_RETURN = 3;
public const int ON_REDO = 3;
public const int ON_RETURN = 4;
public int[] edata;
public string[] label_names;

Expand Down
4 changes: 4 additions & 0 deletions src/CgOp.pm
Expand Up @@ -399,6 +399,10 @@ use warnings;
CgOp::Span->new(lstart => $ls, lend => $le, zyg => [prog(@r)]);
}

sub ehspan {
CgOp::Primitive->new(op => [ ehspan => @_ ]);
}

sub wrap {
newscalar(rawnew('CLRImportObject', $_[0]));
}
Expand Down
1 change: 1 addition & 0 deletions src/Niecza/Actions.pm
Expand Up @@ -2227,6 +2227,7 @@ sub routine_declarator__S_method { my ($cl, $M) = @_;

my $next_anon_id = 0;
sub gensym { 'anon_' . ($next_anon_id++) }
sub genid { ($next_anon_id++) }

sub blockcheck { my ($cl) = @_;
}
Expand Down
10 changes: 9 additions & 1 deletion src/Op.pm
Expand Up @@ -468,13 +468,21 @@ use CgOp;

sub code {
my ($self, $body) = @_;
my $id = Niecza::Actions->genid;

CgOp::prog(
CgOp::whileloop($self->until, $self->once,
CgOp::unbox('Boolean',
CgOp::fetch(
CgOp::methodcall($self->check->cgop($body), "Bool"))),
CgOp::sink($self->body->cgop($body))),
CgOp::prog(
CgOp::label("redo$id"),
CgOp::sink($self->body->cgop($body)),
CgOp::label("next$id"),
CgOp::ehspan(1, undef, 0, "redo$id", "next$id", "next$id"),
CgOp::ehspan(2, undef, 0, "redo$id", "next$id", "last$id"),
CgOp::ehspan(3, undef, 0, "redo$id", "next$id", "redo$id"))),
CgOp::label("last$id"),
CgOp::null('Variable'));
}

Expand Down

0 comments on commit 2d649c9

Please sign in to comment.