develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r35895 - in trunk: . examples/pir

From:
julianalbo
Date:
January 22, 2009 12:48
Subject:
[svn:parrot] r35895 - in trunk: . examples/pir
Message ID:
20090122204757.349EDCB9AE@x12.develooper.com
Author: julianalbo
Date: Thu Jan 22 12:47:55 2009
New Revision: 35895

Added:
   trunk/examples/pir/perl6.bas   (contents, props changed)
Modified:
   trunk/MANIFEST
   trunk/examples/pir/pirric.pir

Log:
pirric: add capability to register HLLs and invoke code compiled with them, and example of perl6 usage

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	(original)
+++ trunk/MANIFEST	Thu Jan 22 12:47:55 2009
@@ -715,6 +715,7 @@
 examples/pir/local_label.pir                                [main]doc
 examples/pir/mandel.pir                                     [main]doc
 examples/pir/mysqltest.bas                                  [main]doc
+examples/pir/perl6.bas                                      [main]doc
 examples/pir/pirric.pir                                     [main]doc
 examples/pir/queens_r.pir                                   [main]doc
 examples/pir/quine_ord.pir                                  [main]doc

Added: trunk/examples/pir/perl6.bas
==============================================================================
--- (empty file)
+++ trunk/examples/pir/perl6.bas	Thu Jan 22 12:47:55 2009
@@ -0,0 +1,16 @@
+1 rem Copyright (C) 2009, The Perl Foundation.
+2 rem $Id$
+3 rem
+10 rem +----------------------------------------------------------------------+
+20 rem + perl6.bas                                                             +
+30 rem + A test of the pirric basic interpreter                               +
+40 rem + First build perl6                                                    +
+50 rem + Then do:                                                             +
+60 rem + ../../parrot -L /yourparrotdir/languages/perl6 pirric.pir perl6.bas  +
+70 rem +----------------------------------------------------------------------+
+80 rem
+1010 load "perl6.pbc",b
+1020 perl= compreg("Perl6")
+1030 t=perl.compile("say 'Perl6 called from pirric';")
+1040 n= t()
+1050 exit

Modified: trunk/examples/pir/pirric.pir
==============================================================================
--- trunk/examples/pir/pirric.pir	(original)
+++ trunk/examples/pir/pirric.pir	Thu Jan 22 12:47:55 2009
@@ -44,6 +44,15 @@
 
 #-----------------------------------------------------------------------
 
+.sub pirric_aux_loadbytecode
+    .param string bcname
+    load_bytecode bcname
+.end
+
+.HLL 'parrot'
+
+#-----------------------------------------------------------------------
+
 .const int PIRRIC_ERROR_NORMAL = 0
 .const int PIRRIC_ERROR_EXIT = 1
 .const int PIRRIC_ERROR_GOTO = 2
@@ -119,6 +128,7 @@
     setpredef(predefs, 'RIGHT$', 'right')
     setpredef(predefs, 'MID$', 'mid')
     setpredef(predefs, 'COMPLEX', 'complex')
+    setpredef(predefs, 'COMPREG', 'compreg')
     setpredef(predefs, 'EXP', 'exp')
     setpredef(predefs, 'LN', 'ln')
     setpredef(predefs, 'SIN', 'sin')
@@ -705,6 +715,20 @@
 .end
 
 #-----------------------------------------------------------------------
+.sub predef_compreg :method
+    .param pmc tokenizer
+
+    $P1 = tokenizer.'get'()
+    ne $P1, '(', fail
+    $P2 = self.'get_1_arg'(tokenizer)
+    $S1 = $P2
+    $P3 = compreg $S1
+    .return($P3)
+fail:
+    SyntaxError()
+.end
+
+#-----------------------------------------------------------------------
 .sub predef_exp :method
     .param pmc tokenizer
 
@@ -960,9 +984,16 @@
 getvar:
     $P2 = tokenizer.'get'()
     eq $P2, '.', dotted
+    eq $P2, '(', isfunctor
     tokenizer.'back'()
     .return(var)
 
+isfunctor:
+    #say 'Functor'
+    args = self.'get_args'(tokenizer)
+    $P3 = var()
+    .return($P3)
+
 dotted:
     $P3 = tokenizer.'get'()
     $P4 = tokenizer.'get'()
@@ -1799,7 +1830,7 @@
     upcase $S1
     ne $S1, 'B', fail
     $S1 = arg
-    load_bytecode $S1
+    pirric_aux_loadbytecode($S1)
     .return()
 notype:
     .local pmc program, newprogram



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