Author: bernhard Date: Wed Jan 28 06:34:02 2009 New Revision: 36092 Modified: trunk/languages/pipp/src/common/php_array.pir trunk/languages/pipp/src/common/php_builtin.pir trunk/languages/pipp/src/common/php_string.pir trunk/languages/pipp/t/php/info.t trunk/languages/pipp/t/php/string.t
Log: [Pipp] Implement 'implode'. Return 'standard' from get_loaded_extensions() Modified: trunk/languages/pipp/src/common/php_array.pir ============================================================================== --- trunk/languages/pipp/src/common/php_array.pir (original) +++ trunk/languages/pipp/src/common/php_array.pir Wed Jan 28 06:34:02 2009 @@ -1,4 +1,4 @@ -# Copyright (C) 2008, The Perl Foundation. +# Copyright (C) 2008-2009, The Perl Foundation. # $Id$ =head1 NAME @@ -67,6 +67,7 @@ .sub 'array' .param pmc args :slurpy + .local pmc array, iter array = new 'PhpArray' iter = new 'Iterator', args Modified: trunk/languages/pipp/src/common/php_builtin.pir ============================================================================== --- trunk/languages/pipp/src/common/php_builtin.pir (original) +++ trunk/languages/pipp/src/common/php_builtin.pir Wed Jan 28 06:34:02 2009 @@ -371,7 +371,15 @@ =cut .sub 'get_loaded_extensions' - not_implemented() + .local pmc array + array = new ['PhpArray'] + + .local pmc extension + extension = new ['PhpString'] + extension = 'standard' + push array, extension + + .return(array) .end =item C<array get_object_vars(object obj)> Modified: trunk/languages/pipp/src/common/php_string.pir ============================================================================== --- trunk/languages/pipp/src/common/php_string.pir (original) +++ trunk/languages/pipp/src/common/php_string.pir Wed Jan 28 06:34:02 2009 @@ -296,7 +296,34 @@ =cut .sub 'implode' - not_implemented() + .param string glue + .param pmc pieces + + .local int num_elems + num_elems = elements pieces + + unless num_elems == 0 goto L1 + .RETURN_STRING('') + L1: + + .local string res + .local pmc iter + iter = new ['Iterator'], pieces + + $P0 = shift iter + $S0 = $P0 + concat res, $S0 + $I1 = 0 + args_loop: + unless iter goto args_end + concat res, glue + $P0 = shift iter + $S0 = $P0 + concat res, $S0 + goto args_loop + args_end: + + .RETURN_STRING(res) .end =item C<string join(array src, string glue)> @@ -378,6 +405,7 @@ .sub 'ord' .param pmc args :slurpy + .local int argc argc = args unless argc != 1 goto L1 Modified: trunk/languages/pipp/t/php/info.t ============================================================================== --- trunk/languages/pipp/t/php/info.t (original) +++ trunk/languages/pipp/t/php/info.t Wed Jan 28 06:34:02 2009 @@ -1,4 +1,4 @@ -# Copyright (C) 2008, The Perl Foundation. +# Copyright (C) 2008-2009, The Perl Foundation. # $Id$ =head1 NAME @@ -23,7 +23,7 @@ use FindBin; use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib"; -use Parrot::Test tests => 9; +use Parrot::Test tests => 10; language_output_is( 'Pipp', <<'CODE', <<'OUT', 'php_egg_logo_guid()' ); @@ -96,6 +96,15 @@ ?> CODE +language_output_is( 'Pipp', <<'CODE', <<'OUT', 'get_loaded_extensions()' ); +<?php + print join( ';', get_loaded_extensions()); + echo "\n"; +?> +CODE +standard +OUT + # Local Variables: # mode: cperl Modified: trunk/languages/pipp/t/php/string.t ============================================================================== --- trunk/languages/pipp/t/php/string.t (original) +++ trunk/languages/pipp/t/php/string.t Wed Jan 28 06:34:02 2009 @@ -23,7 +23,7 @@ use FindBin; use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib"; -use Parrot::Test tests => 38; +use Parrot::Test tests => 40; language_output_is( 'Pipp', <<'CODE', <<'OUT', 'bin2hex' ); @@ -498,6 +498,28 @@ 123? ?456? ?789? ?012? ?345? ?678? ?90? ? OUT +language_output_is( 'Pipp', <<'CODE', <<"OUT", 'implode' ); +<?php + +$pieces = array( '1a', '2b', '3c' ); +echo implode( '? ?', $pieces ), "\n"; + +?> +CODE +1a? ?2b? ?3c +OUT + +language_output_is( 'Pipp', <<'CODE', <<"OUT", 'join' ); +<?php + +$pieces = array( '1a', '2b', '3c', '4c' ); +echo join( '? ?', $pieces ), "\n"; + +?> +CODE +1a? ?2b? ?3c? ?4c +OUT + # Local Variables: # mode: cperl # cperl-indent-level: 4