[svn:parrot] r46554 - trunk/compilers/pct/src/POST

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Thu May 13 00:36:50 UTC 2010


Author: pmichaud
Date: Thu May 13 00:36:48 2010
New Revision: 46554
URL: https://trac.parrot.org/parrot/changeset/46554

Log:
[pct]:  Switch POST::Compiler to have its own key_pir instead of CodeString.key

Modified:
   trunk/compilers/pct/src/POST/Compiler.pir

Modified: trunk/compilers/pct/src/POST/Compiler.pir
==============================================================================
--- trunk/compilers/pct/src/POST/Compiler.pir	Wed May 12 23:46:45 2010	(r46553)
+++ trunk/compilers/pct/src/POST/Compiler.pir	Thu May 13 00:36:48 2010	(r46554)
@@ -43,11 +43,43 @@
 =cut
 
 .sub 'escape' :method
-    .param pmc str
+    .param string str
     $P0 = get_hll_global ['PAST'], 'Compiler'
     .tailcall $P0.'escape'(str)
 .end
 
+=item C<key_pir( string name1 [, string name2, ...] )>
+
+Constructs a PIR key using the strings passed as arguments.
+For example, C<key('Foo', 'Bar')> returns C<["Foo";"Bar"]>.
+
+=cut
+
+.sub 'key_pir' :method
+    .param pmc args            :slurpy
+    .local string out, sep
+    out = '['
+    sep = ''
+  args_loop:
+    unless args goto args_done
+    $P0 = shift args
+    if null $P0 goto args_loop
+    $I0 = does $P0, 'array'
+    if $I0 goto args_array
+  args_string:
+    $S0 = self.'escape'($P0)
+    concat out, sep
+    concat out, $S0
+    sep = ';'
+    goto args_loop
+  args_array:
+    splice args, $P0, 0, 0
+    goto args_loop
+  args_done:
+    concat out, ']'
+    .return (out)
+.end
+
 
 .sub 'to_pir' :method
     .param pmc post
@@ -287,8 +319,7 @@
     ns = $P0
   have_ns:
     set_global '$?NAMESPACE', ns
-    $P0 = new ['CodeString']
-    nskey = $P0.'key'(ns)
+    nskey = self.'key_pir'(ns)
 
   subpir_start:
     $P0 = node['loadinit']


More information about the parrot-commits mailing list