Author: bernhard
Date: Thu Nov 27 10:27:39 2008
New Revision: 33269
Modified:
trunk/languages/pipp/docs/overview.pod
trunk/languages/pipp/src/common/eval.pir
trunk/languages/pipp/src/common/php_basic.pir
trunk/languages/pipp/src/common/php_builtin.pir
trunk/languages/pipp/src/common/php_info.pir
trunk/languages/pipp/src/common/pipp.pir
trunk/languages/pipp/t/php/constant.t
Log:
[Pipp] Add predefined constant DEFAULT_INCLUDE_PATH and set it to '.'
Use DEFAULT_INCLUDE_PATH for includefile lookup
Move the function 'constant' into php_builtin.pir
Modified: trunk/languages/pipp/docs/overview.pod
==============================================================================
--- trunk/languages/pipp/docs/overview.pod (original)
+++ trunk/languages/pipp/docs/overview.pod Thu Nov 27 10:27:39 2008
@@ -27,8 +27,6 @@
=item Support for global variable $INC, list of included files
-=item Support for global variable $INCLUDE_PATH
-
=cut
=head1 Variants
Modified: trunk/languages/pipp/src/common/eval.pir
==============================================================================
--- trunk/languages/pipp/src/common/eval.pir (original)
+++ trunk/languages/pipp/src/common/eval.pir Thu Nov 27 10:27:39 2008
@@ -84,9 +84,7 @@
unless inc_it goto inc_end
.local string basename, realfilename
$S0 = shift inc_it
- # for some reason 0 is shifted for inc_it
- #basename = concat $S0, '/'
- basename = concat '.', '/'
+ basename = concat $S0, '/'
basename .= name
if ismodule goto try_module
realfilename = basename
Modified: trunk/languages/pipp/src/common/php_basic.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_basic.pir (original)
+++ trunk/languages/pipp/src/common/php_basic.pir Thu Nov 27 10:27:39 2008
@@ -85,33 +85,6 @@
not_implemented()
.end
-=item C<mixed constant(string const_name)>
-
-Given the name of a constant this function will return the constants
associated value
-
-=cut
-
-.sub 'constant'
- .param pmc args :slurpy
- .local int argc
- argc = args
- unless argc != 1 goto L1
- wrong_param_count()
- .RETURN_NULL()
- L1:
- $P1 = shift args
- $S1 = $P1
- .local pmc cst
- .GET_CONSTANTS(cst)
- $I0 = exists cst[$S1]
- unless $I0 goto L2
- $P0 = cst[$S1]
- .return ($P0)
- L2:
- error(E_WARNING, "Couldn't find constant ", $S1)
- .RETURN_NULL()
-.end
-
=item C<array error_get_last()>
Get the last occurred error as associative array. Returns NULL if there hasn't
been an error yet.
@@ -218,6 +191,7 @@
.sub 'getenv'
.param pmc args :slurpy
+
.local string varname
($I0, varname) = parse_parameters('s', args :flat)
if $I0 goto L1
@@ -597,6 +571,7 @@
.sub 'sleep'
.param pmc args :slurpy
+
.local int seconds
($I0, seconds) = parse_parameters('l', args :flat)
if $I0 goto L1
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 Thu Nov 27 10:27:39 2008
@@ -131,6 +131,7 @@
.sub 'defined'
.param pmc args :slurpy
+
.local int argc
argc = args
unless argc != 1 goto L1
@@ -145,6 +146,34 @@
.RETURN_BOOL($I0)
.end
+
+=item C<mixed constant(string const_name)>
+
+Given the name of a constant this function will return the constants
associated value
+
+=cut
+
+.sub 'constant'
+ .param pmc args :slurpy
+ .local int argc
+ argc = args
+ unless argc != 1 goto L1
+ wrong_param_count()
+ .RETURN_NULL()
+ L1:
+ $P1 = shift args
+ $S1 = $P1
+ .local pmc cst
+ .GET_CONSTANTS(cst)
+ $I0 = exists cst[$S1]
+ unless $I0 goto L2
+ $P0 = cst[$S1]
+ .return ($P0)
+ L2:
+ error(E_WARNING, "Couldn't find constant ", $S1)
+ .RETURN_NULL()
+.end
+
=item C<array each(array arr)>
Return the currently pointed key..value pair in the passed array, and advance
the pointer to the next element
@@ -392,6 +421,7 @@
.sub 'get_resource_type'
.param pmc args :slurpy
+
.local int argc
argc = args
unless argc != 1 goto L1
@@ -549,6 +579,7 @@
.sub 'strcmp'
.param pmc args :slurpy
+
.local int argc
argc = args
unless argc != 2 goto L1
@@ -571,6 +602,7 @@
.sub 'strlen'
.param pmc args :slurpy
+
.local int argc
argc = args
unless argc != 1 goto L1
Modified: trunk/languages/pipp/src/common/php_info.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_info.pir (original)
+++ trunk/languages/pipp/src/common/php_info.pir Thu Nov 27 10:27:39 2008
@@ -33,6 +33,8 @@
.REGISTER_STRING_CONSTANT(cst, 'PHP_EXTRA_VERSION', " on Parrot")
.REGISTER_LONG_CONSTANT(cst, 'PHP_VERSION_ID', 50300)
.REGISTER_LONG_CONSTANT(cst, 'PHP_ZTS', 0)
+
+ .REGISTER_STRING_CONSTANT(cst, 'DEFAULT_INCLUDE_PATH', '.')
.end
.sub 'logo_guid' :anon
Modified: trunk/languages/pipp/src/common/pipp.pir
==============================================================================
--- trunk/languages/pipp/src/common/pipp.pir (original)
+++ trunk/languages/pipp/src/common/pipp.pir Thu Nov 27 10:27:39 2008
@@ -394,13 +394,10 @@
included_files = new 'PhpArray'
set_hll_global '$INC', included_files
- .local pmc include_path, include_dir
- include_path = new 'PhpArray'
- include_dir = new 'PhpString'
- include_dir = '.'
- push include_path, include_dir
- set_hll_global '$INCLUDE_PATH', include_path
-
+ .local string default_include_path
+ default_include_path = constant('DEFAULT_INCLUDE_PATH')
+ $P0 = split ':', default_include_path
+ set_hll_global '$INCLUDE_PATH', $P0
.end
Modified: trunk/languages/pipp/t/php/constant.t
==============================================================================
--- trunk/languages/pipp/t/php/constant.t (original)
+++ trunk/languages/pipp/t/php/constant.t Thu Nov 27 10:27:39 2008
@@ -23,7 +23,7 @@
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
-use Parrot::Test tests => 21;
+use Parrot::Test tests => 22;
use Parrot::Config qw( %PConfig );
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'define() and constant(),
string' );
@@ -185,6 +185,10 @@
echo PHP_MAJOR_VERSION;
CODE
+language_output_is( 'Pipp', <<'CODE', '.', 'DEFAULT_INCLUDE_PATH' );
+<?php
+echo DEFAULT_INCLUDE_PATH;
+CODE
# Local Variables:
# mode: cperl