Author: bernhard
Date: Sat Jan 3 05:03:27 2009
New Revision: 34875
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/t/php/superglobals.t
Log:
[Pipp] Declare package scope for superglobals for
the remaining scope boundaries.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Sat Jan 3 05:03:27 2009
@@ -21,6 +21,9 @@
method TOP($/, $key) {
our @?BLOCK; # A stack of PAST::Block
+ our @?SUPER_GLOBALS :=
+ ( '$_GET', '$_POST', '$_SERVER', '$_GLOBALS',
+ '$_FILES', '$_COOKIE', '$_SESSION', '$_REQUEST', '$_ENV' );
if $key eq 'open' {
my $block := PAST::Block.new(
@@ -28,13 +31,12 @@
:hll('pipp')
);
+ # by default all symbols are lexical
+ $block.symbol_defaults( :scope('lexical') );
# set up scope 'package' for the superglobals
- $block.symbol_defaults( :scope('lexical') );
- for ( '$_GET', '$_POST', '$_SERVER', '$_GLOBALS',
- '$_FILES', '$_COOKIE', '$_SESSION', '$_REQUEST', '$_ENV' ) {
- $block.symbol( :scope('package'), $_ );
- }
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
@?BLOCK.unshift($block);
}
else {
@@ -541,6 +543,10 @@
# note that $<param_list> creates a new PAST::Block.
my $block := $( $<param_list> );
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
# declare the bound vars a lexical
if +$<bind_list> == 1 {
for $<bind_list>[0]<VAR_NAME> {
@@ -564,7 +570,13 @@
if $key eq 'open' {
# note that $<param_list> creates a new PAST::Block.
- @?BLOCK.unshift( $( $<param_list> ) );
+ my $block := $( $<param_list> );
+
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
+ @?BLOCK.unshift( $block );
}
else {
my $block := @?BLOCK.shift();
@@ -583,6 +595,11 @@
if $key eq 'open' {
# note that $<param_list> creates a new PAST::Block.
my $block := $( $<param_list> );
+
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
$block.unshift(
PAST::Op.new(
:pasttype('bind'),
@@ -613,11 +630,7 @@
}
method param_list($/) {
- my $block :=
- PAST::Block.new(
- :blocktype('declaration'),
- :node($/)
- );
+ my $block := PAST::Block.new( :blocktype('declaration'), :node($/) );
my $arity := 0;
for $<VAR_NAME> {
$block.push(
@@ -659,13 +672,17 @@
our @?BLOCK; # A stack of PAST::Block
if $key eq 'open' {
- @?BLOCK.unshift(
- PAST::Block.new(
+ my $block := PAST::Block.new(
:node($/),
:blocktype('declaration'),
:pirflags( ':init :load' )
- )
- );
+ );
+
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
+ @?BLOCK.unshift( $block );
}
else {
my $block := @?BLOCK.shift();
Modified: trunk/languages/pipp/t/php/superglobals.t
==============================================================================
--- trunk/languages/pipp/t/php/superglobals.t (original)
+++ trunk/languages/pipp/t/php/superglobals.t Sat Jan 3 05:03:27 2009
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, The Perl Foundation.
+# Copyright (C) 2008-2009, The Perl Foundation.
# $Id$
=head1 NAME
@@ -68,7 +68,7 @@
outside function: as=df
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', '$_ENV in a function', todo =>
'superglobals in function broken' );
+language_output_is( 'Pipp', <<'CODE', <<'OUT', '$_GET in a function' );
<?php
echo 'outside function: ';