[svn:parrot] r35810 - in trunk: . languages/pipp/src/pct languages/pipp/t/php
[email protected] Tue, 20 Jan 2009 07:06:24 -0800 (PST)
| Newsgroups | perl.cvs.parrot |
|---|---|
| Message-ID | <[email protected]> |
Author: bernhard
Date: Tue Jan 20 07:06:23 2009
New Revision: 35810
Modified:
trunk/NEWS
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
trunk/languages/pipp/t/php/oo.t
Log:
[Pipp] initial support for static members
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Tue Jan 20 07:06:23 2009
@@ -35,6 +35,7 @@
- back to working state
- ported to pir
+ Pipp
+ - add initial support for static members
- add support for namespaced constants
- constants are now handled as package vars
- variables are now lexical variables
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Tue Jan 20 07:06:23 2009
@@ -282,6 +282,16 @@
}
}
+method static_member($/) {
+ our $?NS;
+ our $?CLASS;
+ make PAST::Var.new(
+ :scope('package'),
+ :namespace( $?NS ~'\\' ~ $?CLASS ~ '::'),
+ :name(~$<ident>)
+ );
+}
+
# TODO: merge with rule 'constant'
method class_constant($/) {
our $?NS;
@@ -646,7 +656,27 @@
}
method class_static_member_definition($/) {
- make PAST::Block.new();
+ our $?CLASS;
+ our $?NS;
+ my $past := PAST::Block.new(:blocktype('immediate'));
+ my $ns := $?CLASS eq '' ?? $?NS
+ !! $?NS ~ '\\' ~ $?CLASS ~ '::';
+ my $member_name := ~$<var_name><ident>;
+ $past.loadinit().push(
+ PAST::Op.new(
+ :pasttype('bind'),
+ PAST::Var.new(
+ :name($member_name),
+ :isdecl(1),
+ :scope('package'),
+ :viviself('PhpNull'),
+ :namespace($ns)
+ ),
+ $( $<literal> )
+ )
+ );
+
+ make $past;
}
method class_method_definition($/, $key) {
@@ -753,6 +783,9 @@
for $<class_member_definition> {
$block.push( $($_) );
}
+ for $<class_static_member_definition> {
+ $block.push( $($_) );
+ }
# It's a new class definition. Make proto-object.
$block.push(
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Tue Jan 20 07:06:23 2009
@@ -346,6 +346,11 @@
{*}
}
+token static_member {
+ 'self' '::' '$' <ident>
+ {*}
+}
+
rule this {
'$this'
{*}
@@ -391,6 +396,7 @@
| '(' <var_assign> ')' {*} #= var_assign
| '(' <expression> ')' {*} #= expression
| <literal> {*} #= literal
+ | <static_member> {*} #= static_member
| <class_constant> {*} #= class_constant
| <constant> {*} #= constant
| <member> {*} #= member
Modified: trunk/languages/pipp/t/php/oo.t
==============================================================================
--- trunk/languages/pipp/t/php/oo.t (original)
+++ trunk/languages/pipp/t/php/oo.t Tue Jan 20 07:06:23 2009
@@ -301,7 +301,7 @@
Foo
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'static member', todo => 'not yet' );
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'static member' );
<?php
class A {
@@ -320,7 +320,7 @@
static member $a
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'static member after function', todo => 'not yet' );
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'static member after function' );
<?php
class A {