Front page | perl.cvs.parrot |
Postings from December 2008
[svn:parrot] r34427 - in trunk/languages/pipp: src/pct t/php
From:
bernhard
Date:
December 27, 2008 08:32
Subject:
[svn:parrot] r34427 - in trunk/languages/pipp: src/pct t/php
Message ID:
20081227163216.BCC78CBA12@x12.develooper.com
Author: bernhard
Date: Sat Dec 27 08:32:15 2008
New Revision: 34427
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/t/php/oo.t
Log:
[Pipp] Support for methods with parameters.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Sat Dec 27 08:32:15 2008
@@ -219,12 +219,10 @@
}
method method_call($/) {
- my $past := PAST::Op.new(
- :name( ~$<METHOD_NAME> ),
- :pasttype( 'callmethod' ),
- :name( ~$<METHOD_NAME> ),
- $( $<var> )
- );
+ my $past := $( $<arguments> );
+ $past.name( ~$<METHOD_NAME> );
+ $past.pasttype( 'callmethod' );
+ $past.unshift( $( $<var> ) );
make $past;
}
@@ -547,7 +545,23 @@
if $key eq 'open' {
# note that $<param_list> creates a new PAST::Block.
- @?BLOCK.unshift( $( $<param_list> ) );
+ my $block := $( $<param_list> );
+ $block.unshift(
+ PAST::Op.new(
+ :pasttype('bind'),
+ PAST::Var.new(
+ :name('$this'),
+ :scope('lexical'),
+ :isdecl(1)
+ ),
+ PAST::Var.new(
+ :name('self'),
+ :scope('register')
+ )
+ )
+ );
+
+ @?BLOCK.unshift( $block );
}
else {
my $block := @?BLOCK.shift();
Modified: trunk/languages/pipp/t/php/oo.t
==============================================================================
--- trunk/languages/pipp/t/php/oo.t (original)
+++ trunk/languages/pipp/t/php/oo.t Sat Dec 27 08:32:15 2008
@@ -20,7 +20,7 @@
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
-use Parrot::Test tests => 6;
+use Parrot::Test tests => 8;
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'definition of a class' );
<?php
@@ -159,3 +159,63 @@
a member of Foo
OUT
+
+=for perl6
+
+class Foo {
+ method one_arg($arg_1) {
+ print $arg_1;
+ print "\n";
+ }
+}
+
+my $foo = Foo.new();
+$foo.one_arg('the first argument');
+
+=cut
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'method with one parameter' );
+<?php
+
+class Foo {
+ function one_arg($arg_1) {
+ echo $arg_1;
+ echo "\n";
+ }
+}
+
+$foo = new Foo;
+$foo->one_arg('the first argument');
+
+?>
+CODE
+the first argument
+OUT
+
+language_output_is( 'Pipp', <<'CODE', <<'OUT', 'method with one parameter' );
+<?php
+
+class Foo {
+ function four_args($arg_1, $arg_2, $arg_3, $arg_4) {
+ echo $arg_1;
+ echo "\n";
+ echo $arg_2;
+ echo "\n";
+ echo $arg_3;
+ echo "\n";
+ echo $arg_4;
+ echo "\n";
+ }
+}
+
+$foo = new Foo;
+$foo->four_args( 'one', 'two', 'three', 'four' );
+
+?>
+CODE
+one
+two
+three
+four
+OUT
+
-
[svn:parrot] r34427 - in trunk/languages/pipp: src/pct t/php
by bernhard