The below patches are my guess as to how to fix PGE and TGE for the recent
change in .namespace.  (That is, C<.namespace ['']> now means what it says,
and the HLL root is reachable by C<.namespace> w/o parameters.)

The TGE patch seems to work, but I got test failure from my PGE patch.
Patrick?  Allison?

=== compilers/tge/TGE/Compiler.pir
==================================================================
--- compilers/tge/TGE/Compiler.pir      (revision 13181)
+++ compilers/tge/TGE/Compiler.pir      (local)
@@ -380,6 +380,9 @@
     .return (code)
 .end
 
+# NOTE - this code assumes that a type of '' is impossible
+#        (in older versions of Parrot, it was)
+
 .sub 'grammar_string' :method
     .param pmc grammar
     .local string code
@@ -387,9 +390,13 @@
     .local string inherit
     type = grammar["type"]
     inherit = grammar["inherit"]
-    code = "\n.namespace [ '"
+    code = "\n.namespace"
+    if type == '' goto no_type
+    code .= " [ '"
     code .= type
-    code .= "' ]\n\n"
+    code .= "' ]"
+  no_type:
+    code .= "\n\n"
     code .= ".sub '__onload' :load\n"
     code .= "    load_bytecode 'TGE.pbc'\n"
     code .= "    $I0 = find_type '"

=== compilers/pge/PGE/P6Regex.pir
==================================================================
--- compilers/pge/PGE/P6Regex.pir       (revision 13181)
+++ compilers/pge/PGE/P6Regex.pir       (local)
@@ -117,9 +117,14 @@
   pir:
     .local pmc code
     .local string grammar
+    .local string nsformat
     grammar = adverbs['grammar']
+    nsformat = ".namespace"
+    if grammar == '' goto pir_emit
+    nsformat = ".namespace [ '%0' ]"
+  pir_emit:
     code = new 'PGE::CodeString'
-    code.emit(".namespace [ '%0' ]", grammar)
+    code.emit(nsformat, grammar)
     $P0 = exp.root_pir(adverbs :flat :named)
     code .= $P0
     if target != 'PIR' goto bytecode


-- 
Chip Salzenberg <[EMAIL PROTECTED]>

Reply via email to