develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35810 - in trunk: . languages/pipp/src/pct languages/pipp/t/php

From:
bernhard
Date:
January 20, 2009 07:06
Subject:
[svn:parrot] r35810 - in trunk: . languages/pipp/src/pct languages/pipp/t/php
Message ID:
20090120150624.BE239CB9AE@x12.develooper.com
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 {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About