Author: bernhard
Date: Wed Nov 26 13:14:20 2008
New Revision: 33240
Modified:
trunk/languages/pipp/ (props changed)
trunk/languages/pipp/config/makefiles/root.in
trunk/languages/pipp/docs/overview.pod
trunk/languages/pipp/src/common/eval.pir
trunk/languages/pipp/src/common/pipp.pir
trunk/languages/pipp/src/pct/grammar.pg
trunk/languages/pipp/t/in_php/02_sanity.t
Log:
[Pipp] quirky suupport for 'require_once'
Modified: trunk/languages/pipp/config/makefiles/root.in
==============================================================================
--- trunk/languages/pipp/config/makefiles/root.in (original)
+++ trunk/languages/pipp/config/makefiles/root.in Wed Nov 26 13:14:20 2008
@@ -176,7 +176,8 @@
build-all: build-pct build-phc build-antlr3
-build-common: pmc src/common/pipplib.pbc pipp.pbc $(PHP_EXT) Test.pir
+#build-common: pmc src/common/pipplib.pbc pipp.pbc $(PHP_EXT) Test.pir
+build-common: pmc src/common/pipplib.pbc pipp.pbc $(PHP_EXT)
build-pct: build-common
Modified: trunk/languages/pipp/docs/overview.pod
==============================================================================
--- trunk/languages/pipp/docs/overview.pod (original)
+++ trunk/languages/pipp/docs/overview.pod Wed Nov 26 13:14:20 2008
@@ -25,6 +25,10 @@
=item Loading of Parrot libs will be supported
+=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 Wed Nov 26 13:14:20 2008
@@ -34,7 +34,7 @@
lang = options['lang']
if lang == 'Parrot' goto lang_parrot
if lang goto lang_compile
- lang = 'PHP'
+ lang = 'Pipp'
lang_compile:
.local pmc compiler
compiler = compreg lang
@@ -68,28 +68,30 @@
have_name:
## see if we loaded this already
- .local pmc inc_hash
- inc_hash = get_hll_global '%INC'
- $I0 = exists inc_hash[name]
+ .local pmc included_files
+ included_files = get_hll_global '$INC'
+ $I0 = exists included_files[name]
unless $I0 goto require_name
- $I0 = defined inc_hash[name]
+ $I0 = defined included_files[name]
.return ($I0)
require_name:
- ## loop through @INC
+ ## loop through $INCLUDE_PATH
.local pmc inc_it
- $P0 = get_hll_global '@INC'
+ $P0 = get_hll_global '$INCLUDE_PATH'
inc_it = iter $P0
inc_loop:
unless inc_it goto inc_end
.local string basename, realfilename
$S0 = shift inc_it
- basename = concat $S0, '/'
+ # for some reason 0 is shifted for inc_it
+ #basename = concat $S0, '/'
+ basename = concat '.', '/'
basename .= name
if ismodule goto try_module
realfilename = basename
$I0 = stat realfilename, 0
- if $I0 goto eval_perl6
+ if $I0 goto eval_pipp
goto inc_loop
try_module:
realfilename = concat basename, '.pbc'
@@ -100,23 +102,23 @@
if $I0 goto eval_parrot
realfilename = concat basename, '.pm'
$I0 = stat realfilename, 0
- if $I0 goto eval_perl6
+ if $I0 goto eval_pipp
goto inc_loop
inc_end:
$S0 = concat "Can't find ", basename
- concat $S0, ' in @INC'
+ concat $S0, ' in $INCLUDE_PATH'
'die'($S0)
.return (0)
eval_parrot:
.local pmc result
- inc_hash[name] = realfilename
+ included_files[name] = realfilename
result = 'evalfile'(realfilename, 'lang'=>'Parrot')
goto done
- eval_perl6:
- inc_hash[name] = realfilename
- result = 'evalfile'(realfilename, 'lang'=>'PHP')
+ eval_pipp:
+ included_files[name] = realfilename
+ result = 'evalfile'(realfilename, 'lang'=>'Pipp')
done:
.return (result)
Modified: trunk/languages/pipp/src/common/pipp.pir
==============================================================================
--- trunk/languages/pipp/src/common/pipp.pir (original)
+++ trunk/languages/pipp/src/common/pipp.pir Wed Nov 26 13:14:20 2008
@@ -105,6 +105,7 @@
# import PGE::Util::die into Pipp::Grammar
$P0 = get_hll_global ['PGE';'Util'], 'die'
set_hll_global ['Pipp';'Grammar'], 'die', $P0
+ set_hll_global ['Pipp'], 'die', $P0
# register and set up the the HLLCompiler
$P1 = new [ 'PCT';'HLLCompiler' ]
@@ -381,7 +382,7 @@
set_hll_global 'pipp_ini', pipp_ini
.end
-# there is a distinction between predifined vars and superglobals
+# there is a distinction between predefined variables and superglobals
.sub set_predefined_variables
.local pmc php_errormsg
@@ -389,6 +390,18 @@
php_errormsg = ''
set_hll_global '$php_errormsg', php_errormsg
+ .local pmc included_files
+ 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
+
+
.end
# Most of the superglobals are not initialized yet
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Wed Nov 26 13:14:20 2008
@@ -145,7 +145,7 @@
}
token require_once_statement {
- 'require_once' <.ws_char> <quote> <ws> <.statement_delimiter>
+ 'require_once' <.ws_char>+ <quote> <ws> <.statement_delimiter>
{*}
}
Modified: trunk/languages/pipp/t/in_php/02_sanity.t
==============================================================================
--- trunk/languages/pipp/t/in_php/02_sanity.t (original)
+++ trunk/languages/pipp/t/in_php/02_sanity.t Wed Nov 26 13:14:20 2008
@@ -1,32 +1,6 @@
<?php
-# This file is for checking whether the test functions are working.
-
-function plan( $number_of_tests ) {
- echo "1..$number_of_tests\n";
-}
-
-function ok($cond, $desc, $count) {
- proclaim($cond, $desc, $count);
-}
-
-function nok($cond, $desc, $count) {
- proclaim(!$cond, $desc, $count);
-}
-
-function is($got, $expected, $desc, $count) {
- proclaim($got == $expected, $desc, $count );
-}
-
-function isnt($got, $expected, $desc, $count) {
- proclaim($got != $expected, $desc, $count );
-}
-
-function proclaim($cond, $desc, $count) {
- if ( $cond ) {
- echo "ok $count - $desc\n";
- }
-}
+require_once 'Test.php';
plan( 4 );
$count = 1;