Author: bernhard
Date: Fri Jan 16 10:47:58 2009
New Revision: 35642
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/t/php/oo.t
Log:
[Pipp] track the current class in $?CLASS
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Fri Jan 16 10:47:58 2009
@@ -20,7 +20,8 @@
class Pipp::Grammar::Actions;
method TOP($/, $key) {
- our $?NS := '';
+ our $?NS := '';
+ our $?CLASS := '';
our @?BLOCK; # A stack of PAST::Block
our @?SUPER_GLOBALS :=
( '$_GET', '$_POST', '$_SERVER', '$_GLOBALS',
@@ -295,6 +296,7 @@
# class constants could probably also be set in a class init block
method class_constant_definition($/) {
+ our $?CLASS;
my $past := PAST::Block.new( :name('class_constant_definition') );
my $loadinit := $past.loadinit();
$loadinit.unshift(
@@ -303,7 +305,7 @@
:name('define'),
:node( $/ ),
PAST::Val.new(
- :value( 'Foo::' ~ ~$<CONSTANT_NAME> ),
+ :value( $?CLASS ~ '::' ~ ~$<CONSTANT_NAME> ),
:returns('PhpString'),
),
$( $<literal> ),
@@ -707,12 +709,15 @@
method class_definition($/, $key) {
our @?BLOCK; # A stack of PAST::Block
+ our $?CLASS; # for namespacing of constants
if $key eq 'open' {
+ $?CLASS := ~$<CLASS_NAME>;
my $block := PAST::Block.new(
:node($/),
:blocktype('declaration'),
- :pirflags( ':init :load' )
+ :pirflags( ':init :load' ),
+ :namespace( $?CLASS )
);
# set up scope 'package' for the superglobals
@@ -723,8 +728,6 @@
}
else {
my $block := @?BLOCK.shift();
- my $class_name := ~$<CLASS_NAME><ident>;
- $block.namespace( $class_name );
$block.push(
# Start of class definition; make PAST to create class object if
# we're creating a new class.
@@ -738,7 +741,7 @@
PAST::Op.new(
:pasttype('call'),
:name('pipp_create_class'),
- PAST::Val.new( :value($class_name) )
+ PAST::Val.new( :value($?CLASS) )
)
)
);
@@ -837,6 +840,8 @@
$block.push( $methods_block );
+ $?CLASS := '';
+
make $block;
}
}
Modified: trunk/languages/pipp/t/php/oo.t
==============================================================================
--- trunk/languages/pipp/t/php/oo.t (original)
+++ trunk/languages/pipp/t/php/oo.t Fri Jan 16 10:47:58 2009
@@ -54,7 +54,7 @@
constant bar in class Foo
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'class constant in Bar', todo => 'Foo is hardwired' );
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'class constant in Bar' );
<?php
class Bar {
@@ -66,7 +66,7 @@
?>
CODE
-constant bar in class Foo
+constant bar in class Bar
OUT
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'calling an instance method' );
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.