Author: bernhard
Date: Tue Dec 23 06:19:44 2008
New Revision: 34274
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pipp.pir
Log:
[Pipp] Set the scope of the superglobals to 'package' in the TOP-Block.
Beware that there are still local symbol scope declarations the override the
declaration in TOP.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Tue Dec 23 06:19:44 2008
@@ -24,6 +24,19 @@
:node($/),
:hll('pipp')
);
+
+ # set up scope 'package' for the superglobals
+ $past.symbol( :scope('package'), '$_GET' );
+ $past.symbol( :scope('package'), '$_POST' );
+ $past.symbol( :scope('package'), '$_SERVER' );
+ $past.symbol( :scope('package'), '$_GLOBALS' );
+ $past.symbol( :scope('package'), '$_FILES' );
+ $past.symbol( :scope('package'), '$_COOKIE' );
+ $past.symbol( :scope('package'), '$_SESSION' );
+ $past.symbol( :scope('package'), '$_REQUEST' );
+ $past.symbol( :scope('package'), '$_ENV' );
+
+ # a PHP script consists of a list of statements
for $<sea_or_code> {
$past.push( $($_) );
}
@@ -492,6 +505,7 @@
$past.push($param);
# enter the parameter as a lexical into the block's symbol table
+ # TODO: lexical by default
$past.symbol(
:scope('lexical'),
$param.name()
@@ -524,12 +538,12 @@
$past.push( $($_) );
}
- my $methods_block
- := PAST::Block.new(
- :blocktype('immediate'),
- );
+ my $methods_block := PAST::Block.new( :blocktype('immediate') );
for $<class_member_definition> {
- $methods_block.symbol( ~$_<VAR_NAME><ident>, :scope('attribute') );
+ $methods_block.symbol(
+ ~$_<VAR_NAME><ident>,
+ :scope('attribute')
+ );
}
for $<class_method_definition> {
$methods_block.push( $($_) );
Modified: trunk/languages/pipp/src/pipp.pir
==============================================================================
--- trunk/languages/pipp/src/pipp.pir (original)
+++ trunk/languages/pipp/src/pipp.pir Tue Dec 23 06:19:44 2008
@@ -280,6 +280,7 @@
# there is a distinction between predefined variables and superglobals
.sub set_predefined_variables
+ # TODO: these should probably be lexicals
.local pmc php_errormsg
php_errormsg = new 'PhpString'
php_errormsg = ''
@@ -298,6 +299,7 @@
.end
# Most of the superglobals are not initialized yet
+# When adding superglobals, please alse add then in the rule TOP of actions.pm
.sub set_superglobals
# the superglobals _GET and _POST need to be set up