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

[svn:parrot] r35996 - trunk/examples/pir

From:
julianalbo
Date:
January 25, 2009 07:54
Subject:
[svn:parrot] r35996 - trunk/examples/pir
Message ID:
20090125155354.908C5CB9AE@x12.develooper.com
Author: julianalbo
Date: Sun Jan 25 07:53:53 2009
New Revision: 35996

Modified:
   trunk/examples/pir/pirric.pir

Log:
[pirric] added GETPARROTINTERP function and -p command line option

Modified: trunk/examples/pir/pirric.pir
==============================================================================
--- trunk/examples/pir/pirric.pir	(original)
+++ trunk/examples/pir/pirric.pir	Sun Jan 25 07:53:53 2009
@@ -31,10 +31,13 @@
 # - Predefined string functions: CHR$, ASC, LEN, LEFT$, RIGHT$, MID$
 # - Parenthesis
 # - Indexing with [ ]
-# - Special functions: NEW, ISA, COMPREG
+# - Special functions: NEW, ISA, COMPREG, GETPARROTINTERP
 # - Calls to methods in foreign objects
 # - Calls to functions in foreign namespaces
-
+#
+# Command line options:
+# -t Trace on. Same as the TRON instruction
+# -p all remaining arguments are executed as PRINT instructions
 #-----------------------------------------------------------------------
 
 .include 'iterator.pasm'
@@ -126,6 +129,7 @@
     predefs = new 'Hash'
     setpredef(predefs, 'NEW')
     setpredef(predefs, 'ISA')
+    setpredef(predefs, 'GETPARROTINTERP')
     setpredef(predefs, 'CHR$', 'CHR_S')
     setpredef(predefs, 'ASC')
     setpredef(predefs, 'LEN')
@@ -204,6 +208,7 @@
     .local string arg
     arg = args[$I1]
     if arg == '-t' goto opt_tron
+    if arg == '-p' goto print_items
 
     #say arg
     program.'load'(arg)
@@ -216,6 +221,18 @@
     inc $I1
     goto read_args
 
+print_items:
+    .local pmc tokenizer
+    inc $I1
+    le $I0, $I1, print_end
+    $S9 = args [$I1]
+    tokenizer = newTokenizer($S9)
+    runner.'func_PRINT'(tokenizer)
+    null tokenizer
+    goto print_items
+print_end:
+    exit 0
+
 no_prog:
     $I0 = 0
 start:
@@ -606,6 +623,15 @@
 .end
 
 #-----------------------------------------------------------------------
+
+.sub predef_GETPARROTINTERP :method
+    .param pmc tokenizer
+
+    $P0 = getinterp
+    .return($P0)
+.end
+
+#-----------------------------------------------------------------------
 .sub predef_CHR_S :method
     .param pmc tokenizer
 



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