Author: bernhard
Date: Fri Nov 7 09:07:30 2008
New Revision: 32429
Modified:
trunk/languages/pipp/src/pct/actions.pm
Log:
Pipp: Try to use lexical scope for variables used within a function.
But do not succeed.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Fri Nov 7 09:07:30 2008
@@ -205,11 +205,12 @@
}
method VAR_NAME($/) {
+ our $?PIPP_SCOPE;
make PAST::Var.new(
- :scope('package'),
+ :scope( $?PIPP_SCOPE ?? $?PIPP_SCOPE !! 'package' ),
:name(~$/),
:viviself('Undef'),
- :lvalue(1)
+ :lvalue(1),
);
}
@@ -324,6 +325,9 @@
method function_definition($/) {
+ # PHP has two scopes: local to functions and global
+ our $?PIPP_SCOPE := 'lexical';
+
# note that $<param_list> creates a new PAST::Block.
my $past := $( $<param_list> );
@@ -331,6 +335,8 @@
$past.control('return_pir');
$past.push( $( $<block> ) );
+ $?PIPP_SCOPE := '';
+
make $past;
}