develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34257 - in trunk/languages/pipp: src src/common src/pct t/embed

From:
bernhard
Date:
December 22, 2008 13:43
Subject:
[svn:parrot] r34257 - in trunk/languages/pipp: src src/common src/pct t/embed
Message ID:
20081222214257.3CA95CBA12@x12.develooper.com
Author: bernhard
Date: Mon Dec 22 13:42:55 2008
New Revision: 34257

Modified:
   trunk/languages/pipp/src/common/builtins.pir
   trunk/languages/pipp/src/common/eval.pir
   trunk/languages/pipp/src/common/guts.pir
   trunk/languages/pipp/src/common/php_base64.pir
   trunk/languages/pipp/src/common/php_ctype.pir
   trunk/languages/pipp/src/common/php_gmp.pir
   trunk/languages/pipp/src/common/php_pcre.pir
   trunk/languages/pipp/src/pct/actions.pm
   trunk/languages/pipp/src/pipp.pir
   trunk/languages/pipp/t/embed/eval.t

Log:
[Pipp] Put the builtin functions below the hll root namespace 'pipp'.
Funny workaround for setting ".HLL 'Pipp'" in generated PAST.
Break 'require_once'.


Modified: trunk/languages/pipp/src/common/builtins.pir
==============================================================================
--- trunk/languages/pipp/src/common/builtins.pir	(original)
+++ trunk/languages/pipp/src/common/builtins.pir	Mon Dec 22 13:42:55 2008
@@ -1,5 +1,7 @@
 # $Id$
 
+.HLL 'Pipp'
+
 .loadlib 'php_group'
 
 .include 'languages/pipp/src/common/php_MACRO.pir'

Modified: trunk/languages/pipp/src/common/eval.pir
==============================================================================
--- trunk/languages/pipp/src/common/eval.pir	(original)
+++ trunk/languages/pipp/src/common/eval.pir	Mon Dec 22 13:42:55 2008
@@ -16,22 +16,18 @@
 
 =cut
 
-.namespace [ 'Pipp' ]
+.HLL 'Pipp'
 
 .sub 'eval'
 
     .param pmc code
 
-    $P0 = get_hll_global 'Str'
-
     .local pmc compiler
     compiler = compreg 'Pipp'
 
     .tailcall compiler.'eval'(code)
 .end
 
-.namespace []
-
 .sub 'evalfile' :method :multi(_)
     .param pmc options         :slurpy :named
 
@@ -53,8 +49,6 @@
     .return (1)
 .end
 
-
-.namespace []
 .sub 'require' :multi(_)
     .param string name
     .param pmc options         :named :slurpy

Modified: trunk/languages/pipp/src/common/guts.pir
==============================================================================
--- trunk/languages/pipp/src/common/guts.pir	(original)
+++ trunk/languages/pipp/src/common/guts.pir	Mon Dec 22 13:42:55 2008
@@ -62,7 +62,6 @@
 
 =cut
 
-.namespace []
 .sub '!EXPORT'
     .param string symbols
     .param pmc from            :named('from')

Modified: trunk/languages/pipp/src/common/php_base64.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_base64.pir	(original)
+++ trunk/languages/pipp/src/common/php_base64.pir	Mon Dec 22 13:42:55 2008
@@ -36,7 +36,7 @@
     if $I0 goto L1
     .RETURN_NULL()
   L1:
-    $P0 = get_hll_global [ 'MIME'; 'Base64' ], 'decode_base64'
+    $P0 = get_root_global ['parrot';'MIME';'Base64'], 'decode_base64'
     $S0 = $P0(str)
     .RETURN_STRING($S0)
 .end
@@ -55,7 +55,7 @@
     if $I0 goto L1
     .RETURN_NULL()
   L1:
-    $P0 = get_hll_global ['MIME'; 'Base64'], 'encode_base64'
+    $P0 = get_root_global ['parrot';'MIME';'Base64'], 'encode_base64'
     $S0 = $P0(str)
     if $S0 == '' goto L2
     .RETURN_STRING($S0)

Modified: trunk/languages/pipp/src/common/php_ctype.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_ctype.pir	(original)
+++ trunk/languages/pipp/src/common/php_ctype.pir	Mon Dec 22 13:42:55 2008
@@ -13,6 +13,8 @@
 
 =cut
 
+.HLL 'Pipp'
+
 .include 'languages/pipp/src/common/php_MACRO.pir'
 .include 'cclass.pasm'
 

Modified: trunk/languages/pipp/src/common/php_gmp.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_gmp.pir	(original)
+++ trunk/languages/pipp/src/common/php_gmp.pir	Mon Dec 22 13:42:55 2008
@@ -17,6 +17,8 @@
 
 =cut
 
+.HLL 'Pipp'
+
 .include 'languages/pipp/src/common/php_MACRO.pir'
 
 .const string GMP_PMC          = 'BigInt'

Modified: trunk/languages/pipp/src/common/php_pcre.pir
==============================================================================
--- trunk/languages/pipp/src/common/php_pcre.pir	(original)
+++ trunk/languages/pipp/src/common/php_pcre.pir	Mon Dec 22 13:42:55 2008
@@ -13,6 +13,8 @@
 
 =cut
 
+.HLL 'Pipp'
+
 .include 'languages/pipp/src/common/php_MACRO.pir'
 .include 'cclass.pasm'
 

Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm	(original)
+++ trunk/languages/pipp/src/pct/actions.pm	Mon Dec 22 13:42:55 2008
@@ -20,13 +20,12 @@
 class Pipp::Grammar::Actions;
 
 method TOP($/) {
-    my $past := PAST::Stmts.new( :node($/) );
-
+    my $past := PAST::Block.new( :node($/) );
     for $<sea_or_code> {
         $past.push( $($_) );
     }
 
-    make $past;
+    make PAST::Stmts.new( $past, PAST::Op.new( :inline( "_block11()\n.end\n.HLL 'Pipp'\n.sub 'anon'" ) ));
 }
 
 method sea_or_code($/,$key) {
@@ -257,13 +256,13 @@
                 my $eif := $($<elseif_clause>[$count]);
                 $count--;
                 my $eifchild := $($<elseif_clause>[$count]);
-                if($else) {
-                        $eif.push($else);
+                if ($else) {
+                   $eif.push($else);
                 }
                 $eif.push($eifchild);
         }
-        if($else && +$<elseif_clause> == 1) {
-                $firsteif.push($else);
+        if ($else && +$<elseif_clause> == 1) {
+            $firsteif.push($else);
         }
      }
 
@@ -496,7 +495,7 @@
                     :pirflags( ':init :load' ),
                     PAST::Stmts.new(
                         PAST::Op.new(
-                            :inline(   "$P0 = get_hll_global 'P6metaclass'\n"
+                            :inline(   "$P0 = get_root_global ['parrot'], 'P6metaclass'\n"
                                      ~ "$P2 = $P0.'new_class'('" ~ $<CLASS_NAME> ~ "')\n" ),
                             :pasttype( 'inline' )
                         )

Modified: trunk/languages/pipp/src/pipp.pir
==============================================================================
--- trunk/languages/pipp/src/pipp.pir	(original)
+++ trunk/languages/pipp/src/pipp.pir	Mon Dec 22 13:42:55 2008
@@ -28,8 +28,7 @@
 
 =cut
 
-
-.namespace [ 'PAST';'Compiler' ]
+.namespace [ 'Pipp' ]
 
 .sub '__onload' :anon :load :init
 
@@ -40,12 +39,10 @@
     #  be used as a constant.  The 'e' flag indicates that the
     #  value must be quoted+escaped in PIR code.
     .local pmc valflags
-    valflags = get_global '%valflags'
+    valflags = get_hll_global ['PAST';'Compiler'], '%valflags'
     valflags['PhpString']   = 's~*e'
 .end
 
-.namespace [ 'Pipp' ]
-
 .const string VERSION = "0.0.1"
 
 .sub '__onload' :load :init
@@ -277,7 +274,7 @@
 .sub set_ini
     .param pmc pipp_ini
 
-    set_hll_global 'pipp_ini', pipp_ini
+    set_root_global ['pipp'], 'pipp_ini', pipp_ini
 .end
 
 # there is a distinction between predefined variables and superglobals
@@ -286,16 +283,17 @@
     .local pmc php_errormsg
     php_errormsg = new 'PhpString'
     php_errormsg = ''
-    set_hll_global '$php_errormsg', php_errormsg
+    set_root_global ['pipp'], '$php_errormsg', php_errormsg
 
     .local pmc included_files
     included_files = new 'PhpArray'
-    set_hll_global '$INC', included_files
+    set_root_global ['pipp'], '$INC', included_files
 
     .local string default_include_path
-    default_include_path = constant('DEFAULT_INCLUDE_PATH')
+    $P0 = get_root_global ['pipp'], 'constant'
+    default_include_path = $P0('DEFAULT_INCLUDE_PATH')
     $P0 = split ':', default_include_path
-    set_hll_global '$INCLUDE_PATH', $P0
+    set_root_global ['pipp'], '$INCLUDE_PATH', $P0
 
 .end
 
@@ -306,40 +304,40 @@
     .local pmc parse_get_sub, superglobal_GET
     parse_get_sub       = get_hll_global [ 'CGI'; 'QueryHash' ], 'parse_get'
     ( superglobal_GET ) = parse_get_sub()
-    set_hll_global '$_GET', superglobal_GET
+    set_root_global ['pipp'], '$_GET', superglobal_GET
 
     .local pmc parse_post_sub, superglobal_POST
     parse_post_sub       = get_hll_global [ 'CGI'; 'QueryHash' ], 'parse_post'
     ( superglobal_POST ) = parse_post_sub()
-    set_hll_global '$_POST', superglobal_POST
+    set_root_global ['pipp'], '$_POST', superglobal_POST
 
     .local pmc superglobal_SERVER
     superglobal_SERVER = new 'PhpArray'
-    set_hll_global '$_SERVER', superglobal_SERVER
+    set_root_global ['pipp'], '$_SERVER', superglobal_SERVER
 
     .local pmc superglobal_GLOBALS
     superglobal_GLOBALS = new 'PhpArray'
-    set_hll_global '$_GLOBALS', superglobal_GLOBALS
+    set_root_global ['pipp'], '$_GLOBALS', superglobal_GLOBALS
 
     .local pmc superglobal_FILES
     superglobal_FILES = new 'PhpArray'
-    set_hll_global '$_FILES', superglobal_FILES
+    set_root_global ['pipp'], '$_FILES', superglobal_FILES
 
     .local pmc superglobal_COOKIE
     superglobal_COOKIE = new 'PhpArray'
-    set_hll_global '$_COOKIE', superglobal_COOKIE
+    set_root_global ['pipp'], '$_COOKIE', superglobal_COOKIE
 
     .local pmc superglobal_SESSION
     superglobal_SESSION = new 'PhpArray'
-    set_hll_global '$_SESSION', superglobal_SESSION
+    set_root_global ['pipp'], '$_SESSION', superglobal_SESSION
 
     .local pmc superglobal_REQUEST
     superglobal_REQUEST = new 'PhpArray'
-    set_hll_global '$_REQUEST', superglobal_REQUEST
+    set_root_global ['pipp'], '$_REQUEST', superglobal_REQUEST
 
     .local pmc superglobal_ENV
     superglobal_ENV = new 'PhpArray'
-    set_hll_global '$_ENV', superglobal_ENV
+    set_root_global ['pipp'], '$_ENV', superglobal_ENV
 
 .end
 

Modified: trunk/languages/pipp/t/embed/eval.t
==============================================================================
--- trunk/languages/pipp/t/embed/eval.t	(original)
+++ trunk/languages/pipp/t/embed/eval.t	Mon Dec 22 13:42:55 2008
@@ -28,21 +28,21 @@
     ok( 1, 'no tests implemented yet')
     # TODO:
     # find sub 'eval_string'
-    .local pmc eval_sub, no_args_sub
-    .local int ret
-    eval_sub = get_root_global [ 'parrot'; 'Pipp' ], 'eval'
+    #.local pmc eval_sub, no_args_sub
+    #.local int ret
+    #eval_sub = get_root_global ['pipp'], 'eval'
     # call it with TAP diagnostics
-    eval_sub("# only sea, not islands\n")
+    #eval_sub("# only sea, not islands\n")
 
-    eval_sub('<?php function no_args () { echo "# no_args was called\n"; } no_args(); ?>')
+    #eval_sub('<?php function no_args () { echo "# no_args was called\n"; } no_args(); ?>')
 
     # define a function
     # call it from here
-    no_args_sub = get_hll_global 'no_args'
-    no_args_sub()
+    #no_args_sub = get_hll_global 'no_args'
+    #no_args_sub()
 
-    no_args_sub = get_root_global [ 'parrot' ], 'no_args'
-    no_args_sub()
+    #no_args_sub = get_root_global [ 'parrot' ], 'no_args'
+    #no_args_sub()
     # $P3 = get_namespace
     # say $P3
 



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