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

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

From:
julianalbo
Date:
January 23, 2009 14:56
Subject:
[svn:parrot] r35931 - trunk/examples/pir
Message ID:
20090123225558.D68E4CB9AE@x12.develooper.com
Author: julianalbo
Date: Fri Jan 23 14:55:58 2009
New Revision: 35931

Modified:
   trunk/examples/pir/pirric.pir

Log:
pirric: allow pass one argument to new

Modified: trunk/examples/pir/pirric.pir
==============================================================================
--- trunk/examples/pir/pirric.pir	(original)
+++ trunk/examples/pir/pirric.pir	Fri Jan 23 14:55:58 2009
@@ -544,15 +544,33 @@
 .sub predef_new :method
     .param pmc tokenizer
 
+    .local pmc args
+    .local int nargs
+    .local string name
+    .local pmc obj
+
     $P1 = tokenizer.'get'()
     ne $P1, '(', fail
-    $P1 = self.'get_1_arg'(tokenizer)
-    $S1 = $P1
+    args = self.'get_args'(tokenizer)
+    $I0 = defined args
+    unless $I0 goto fail
+    nargs = args
+    name = args [0]
     #print 'NEW: '
-    #say $S1
+    #say name
+    eq nargs, 1, noarg
 
-    $P2 = new $S1
-    .return($P2)
+    .local pmc arg1
+    arg1 = args [1]
+    #say arg1
+
+    obj = new name, arg1
+
+    goto done
+noarg:
+    obj = new name
+done:
+    .return(obj)
 fail:
     SyntaxError()
 .end



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