Author: bernhard
Date: Thu Dec 4 11:29:04 2008
New Revision: 33485
Modified:
trunk/languages/pipp/src/pct/actions.pm
Log:
[Pipp] Simplify actions by using the nifty 'loadinit' node
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Thu Dec 4 11:29:04 2008
@@ -26,17 +26,6 @@
$past.push( $($_) );
}
- # subrules may have added stuff to $?INIT
- # execute it first
- our $?INIT;
- if pipp_defined( $?INIT ) {
- $?INIT.blocktype('declaration');
- $?INIT.pirflags(':init :load');
- $past.unshift( $?INIT );
- $?INIT := PAST::Block.new(); # For the next eval.
- }
- $past.unshift( PAST::Block.new( :name( 'INIT should have been added' ) ) );
-
make $past;
}
@@ -213,24 +202,22 @@
# class constants could probably also be set in a class init block
method class_constant_definition($/) {
- our $?INIT;
- unless pipp_defined( $?INIT ) {
- $?INIT := PAST::Block.new();
- }
- $?INIT.push(
- PAST::Op.new(
- :pasttype('call'),
- :name('define'),
- :node( $/ ),
- PAST::Val.new(
- :value( 'Foo::' ~ ~$<CONSTANT_NAME> ),
- :returns('PhpString'),
- ),
- $( $<literal> ),
- )
+ my $past := PAST::Block.new( :name( 'class_constant_definition' ) );
+ my $loadinit := $past.loadinit();
+ $loadinit.unshift(
+ PAST::Op.new(
+ :pasttype('call'),
+ :name('define'),
+ :node( $/ ),
+ PAST::Val.new(
+ :value( 'Foo::' ~ ~$<CONSTANT_NAME> ),
+ :returns('PhpString'),
+ ),
+ $( $<literal> ),
+ )
);
- make PAST::Block.new( :name( 'class_constant_definition' ) );
+ make $past;
}
method arguments($/) {
@@ -485,7 +472,7 @@
);
# nothing to do for $<const_definition,
- # setup of class constants is done in $?INIT
+ # setup of class constants is done in the 'loadinit' node
for $<class_constant_definition> {
$past.push($($_));
}