Skip to content

Commit

Permalink
[mm] Rip out PRE-INIT
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Sep 19, 2010
1 parent ad61227 commit 2abfd12
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
8 changes: 0 additions & 8 deletions src/Niecza/Actions.pm
Expand Up @@ -2443,14 +2443,6 @@ sub statement_prefix__S_gather { my ($cl, $M) = @_;
$M->{_ast} = Op::Gather->new(node($M), var => $cl->gensym,
body => $M->{blast}{_ast});
}
sub statement_prefix__S_PREMinusINIT { my ($cl, $M) = @_;
my $var = $cl->gensym;

$M->{blast}{_ast}->type('phaser');

$M->{_ast} = Op::PreInit->new(var => $var, body => $M->{blast}{_ast},
node($M));
}

sub statement_prefix__S_START { my ($cl, $M) = @_;
my $cv = $cl->gensym;
Expand Down
3 changes: 0 additions & 3 deletions src/Niecza/Grammar.pm6
Expand Up @@ -11,9 +11,6 @@ grammar P6 is STD::P6 {
%*LANG<MAIN> = ::Niecza::Grammar::P6 ;
self;
}

token statement_prefix:sym<PRE-INIT>
{ :my %*MYSTERY; <sym> <.spacey> <blast> <.explain_mystery> }
}

grammar Q is STD::Q {
Expand Down
22 changes: 0 additions & 22 deletions src/Op.pm
Expand Up @@ -678,28 +678,6 @@ use CgOp;
no Moose;
}

{
package Op::PreInit;
use Moose;
extends 'Op';

has var => (isa => 'Str', is => 'ro', predicate => 'has_var');
has body => (isa => 'Body', is => 'ro', required => 1);

sub lift_decls {
my ($self) = @_;
Decl::PreInit->new(var => $self->var, code => $self->body);
}

sub code {
my ($self, $body) = @_;
CgOp::scopedlex($self->var);
}

__PACKAGE__->meta->make_immutable;
no Moose;
}

{
package Op::Super;
use Moose;
Expand Down
6 changes: 3 additions & 3 deletions test.pl
Expand Up @@ -65,13 +65,13 @@

{
my $x;
PRE-INIT {
INIT {
$x = 1;
}
ok $x, "changes made in the protolexpad are visible at runtime";
}

ok PRE-INIT { 1 }, "preinit blocks can return values";
ok INIT { 1 }, "init blocks can return values";

{
sub foo() { 42 }
Expand Down Expand Up @@ -230,7 +230,7 @@

{
my $x;
my $unclonable-sub = PRE-INIT { sub () { $x } };
my $unclonable-sub = INIT { sub () { $x } };
$x = 42;
ok $unclonable-sub() == 42, "mainlines are not cloned";
}
Expand Down

0 comments on commit 2abfd12

Please sign in to comment.