Skip to content
This repository
Browse code

Merge branch 'master' of github.com:parrot/parrot

  • Loading branch information...
commit 0851b2cd102ab8e7c6c731645cac3fdaa853c6b2 2 parents 285b502 + 3cfeb72
Andrew Whitworth authored November 24, 2010

Showing 122 changed files with 1,132 additions and 44,647 deletions. Show diff stats Hide diff stats

  1. 14  .gitignore
  2. 23  DEPRECATED.pod
  3. 55  MANIFEST
  4. 24  MANIFEST.SKIP
  5. 5  NEWS
  6. 2  PBC_COMPAT
  7. 1  RESPONSIBLE_PARTIES
  8. 31  compilers/data_json/data_json.pir
  9. 87  compilers/data_json/data_json/pge2pir.tg
  10. 284  compilers/pge/PGE/Exp.pir
  11. 2  compilers/pge/PGE/Match.pir
  12. 3  compilers/pge/PGE/Perl6Regex.pir
  13. 18  compilers/pirc/Defines.mak
  14. 407  compilers/pirc/README.pod
  15. 244  compilers/pirc/Rules.mak
  16. 38  compilers/pirc/TODO
  17. 60  compilers/pirc/heredoc/heredocmain.c
  18. 32  compilers/pirc/macro/lexer.h
  19. 54  compilers/pirc/macro/macro.h
  20. 718  compilers/pirc/macro/macro.l
  21. 1,111  compilers/pirc/macro/macro.y
  22. 3,605  compilers/pirc/macro/macrolexer.c
  23. 490  compilers/pirc/macro/macrolexer.h
  24. 2,682  compilers/pirc/macro/macroparser.c
  25. 114  compilers/pirc/macro/macroparser.h
  26. 1,339  compilers/pirc/src/bcgen.c
  27. 315  compilers/pirc/src/bcgen.h
  28. 2,958  compilers/pirc/src/hdocprep.c
  29. 544  compilers/pirc/src/hdocprep.l
  30. 404  compilers/pirc/src/main.c
  31. 1,523  compilers/pirc/src/pir.l
  32. 3,501  compilers/pirc/src/pir.y
  33. 295  compilers/pirc/src/pircapi.c
  34. 67  compilers/pirc/src/pircapi.h
  35. 470  compilers/pirc/src/pircompiler.c
  36. 265  compilers/pirc/src/pircompiler.h
  37. 2,810  compilers/pirc/src/pircompunit.c
  38. 1,063  compilers/pirc/src/pircompunit.h
  39. 22  compilers/pirc/src/pirdefines.h
  40. 1,104  compilers/pirc/src/piremit.c
  41. 105  compilers/pirc/src/piremit.h
  42. 102  compilers/pirc/src/pirerr.c
  43. 47  compilers/pirc/src/pirerr.h
  44. 21  compilers/pirc/src/pirheredoc.h
  45. 5,349  compilers/pirc/src/pirlexer.c
  46. 16  compilers/pirc/src/pirlexer.h
  47. 375  compilers/pirc/src/pirmacro.c
  48. 199  compilers/pirc/src/pirmacro.h
  49. 333  compilers/pirc/src/pirop.c
  50. 30  compilers/pirc/src/pirop.h
  51. 6,380  compilers/pirc/src/pirparser.c
  52. 312  compilers/pirc/src/pirparser.h
  53. 984  compilers/pirc/src/pirpcc.c
  54. 55  compilers/pirc/src/pirpcc.h
  55. 694  compilers/pirc/src/pirregalloc.c
  56. 132  compilers/pirc/src/pirregalloc.h
  57. 875  compilers/pirc/src/pirsymbol.c
  58. 238  compilers/pirc/src/pirsymbol.h
  59. 36  compilers/pirc/src/piryy.h
  60. 131  compilers/pirc/t/basic.t
  61. 28  compilers/pirc/t/harness
  62. 23  compilers/pirc/t/heredoc.t
  63. 23  compilers/pirc/t/macro.t
  64. 103  compilers/pirc/t/stmts.t
  65. 23  compilers/pirc/t/subflags.t
  66. 11  compilers/tge/TGE/Compiler.pir
  67. 2  config/auto/ipv6.pm
  68. 8  config/auto/warnings.pm
  69. 24  config/gen/makefiles/root.in
  70. 6  config/gen/platform/win32/pid.c
  71. 4  config/init/defaults.pm
  72. 7  docs/book/draft/appa_glossary.pod
  73. 4  docs/book/draft/appd_build_options.pod
  74. 2  docs/book/draft/ch01_introduction.pod
  75. 2  docs/book/pct/ch01_introduction.pod
  76. 4  docs/embed.pod
  77. 2  docs/faq.pod
  78. 7  docs/glossary.pod
  79. 6  docs/imcc/imcfaq.pod
  80. 7  docs/optable.pod
  81. 2  docs/pdds/draft/pdd06_pasm.pod
  82. 13  docs/pdds/pdd19_pir.pod
  83. 28  examples/pir/sudoku.pir
  84. 19  include/parrot/datatypes.h
  85. 4  include/parrot/oplib/core_ops.h
  86. 274  include/parrot/oplib/ops.h
  87. 274  include/parrot/opsenum.h
  88. 1  include/parrot/pointer_array.h
  89. 22  lib/Parrot/Distribution.pm
  90. 1  lib/Parrot/Docs/Section/Compilers.pm
  91. 6  lib/Parrot/Harness/Smoke.pm
  92. 4  lib/Parrot/Pmc2c/Emitter.pm
  93. 4  lib/Parrot/Pmc2c/Method.pm
  94. 2  lib/Parrot/Pmc2c/Pmc2cMain.pm
  95. 9  lib/Parrot/Test.pm
  96. 56  runtime/parrot/library/PGE/Perl6Grammar.pir
  97. 84  runtime/parrot/library/PGE/Util.pir
  98. 1  runtime/parrot/library/SDL.pir
  99. 19  src/datatypes.c
  100. 1  src/gc/fixed_allocator.c
  101. 13  src/gc/gc_ms.c
  102. 4  src/multidispatch.c
  103. 660  src/ops/core_ops.c
  104. 29  src/ops/experimental.ops
  105. 29  src/ops/string.ops
  106. 14  src/packdump.c
  107. 11  src/packfile.c
  108. 2  src/pmc.c
  109. 4  src/pmc/boolean.pmc
  110. 397  src/pmc/codestring.pmc
  111. 1  src/pointer_array.c
  112. 15  t/codingstd/linelength.t
  113. 12  t/harness.pir
  114. 2  t/op/cc_state.t
  115. 4  t/op/gc-active-buffers.t
  116. 4  t/perl/Parrot_Test.t
  117. 232  t/pmc/codestring.t
  118. 2  t/pmc/sub.t
  119. 2  t/steps/auto/ipv6-01.t
  120. 2  t/steps/auto/warnings-01.t
  121. 2  t/tools/pbc_dump.t
  122. 20  tools/install/smoke.pl
14  .gitignore
@@ -79,7 +79,6 @@
79 79
 /pbc_to_exe
80 80
 /pbc_to_exe.*
81 81
 /perl6
82  
-/pirc
83 82
 /tags
84 83
 /temp.file
85 84
 /test
@@ -126,19 +125,6 @@
126 125
 /compilers/pge/PGE.pbc
127 126
 # generated from svn:ignore of 'compilers/pge/PGE/'
128 127
 /compilers/pge/PGE/builtins_gen.pir
129  
-# generated from svn:ignore of 'compilers/pirc/'
130  
-/compilers/pirc/*.o
131  
-/compilers/pirc/*.obj
132  
-/compilers/pirc/*.pbd
133  
-/compilers/pirc/pirc
134  
-/compilers/pirc/pirc.exe
135  
-# generated from svn:ignore of 'compilers/pirc/t/'
136  
-/compilers/pirc/t/basic_?.pir
137  
-/compilers/pirc/t/basic_??.pir
138  
-/compilers/pirc/t/heredoc_?.pir
139  
-/compilers/pirc/t/macro_?.pir
140  
-/compilers/pirc/t/stmts_?.pir
141  
-/compilers/pirc/t/subflags_?.pir
142 128
 # generated from svn:ignore of 'compilers/tge/'
143 129
 /compilers/tge/tgc.pbc
144 130
 # generated from svn:ignore of 'compilers/tge/TGE/'
23  DEPRECATED.pod
Source Rendered
@@ -49,10 +49,6 @@ L<https://trac.parrot.org/parrot/ticket/1580>
49 49
 
50 50
 L<https://trac.parrot.org/parrot/ticket/1599>
51 51
 
52  
-=item CodeString [eligible in 2.7]
53  
-
54  
-L<http://trac.parrot.org/parrot/ticket/1633>
55  
-
56 52
 =item multiple dispatch within core PMCs [eligible in 1.1]
57 53
 
58 54
 L<https://trac.parrot.org/parrot/ticket/452>
@@ -204,12 +200,6 @@ These will be changed to allow more flexibility in types.
204 200
 
205 201
 L<https://trac.parrot.org/parrot/ticket/1565>
206 202
 
207  
-=item find_lex [eligible in 2.4]
208  
-
209  
-find_lex will not throw exception for non-existing lexicals.
210  
-
211  
-L<https://trac.parrot.org/parrot/ticket/1207>
212  
-
213 203
 =item inplace string updates. [eligible in 2.4]
214 204
 
215 205
 All "inplace" string update ops are deprecated. E.g. "chopn_s", etc.
@@ -217,12 +207,6 @@ Part of COW removal.
217 207
 
218 208
 L<https://trac.parrot.org/parrot/ticket/1540>
219 209
 
220  
-=item find_codepoint [experimental]
221  
-
222  
-Intended to replace the CodeString charname_to_ord method.
223  
-
224  
-L<https://trac.parrot.org/parrot/ticket/1629>
225  
-
226 210
 =item finalize [experimental]
227 211
 
228 212
 Finalize exception handler, unrolling inner runloops if needed.
@@ -357,6 +341,13 @@ L<https://trac.parrot.org/parrot/ticket/1564>
357 341
 
358 342
 Load a .pbc file into the interpreter. Experimental.
359 343
 
  344
+=item GC timely destruction [eligible in 3.1]
  345
+
  346
+All PIR ops and internal semantics related to timely destruction of PMCs
  347
+is deprecated.
  348
+
  349
+L<http://trac.parrot.org/parrot/ticket/1800>
  350
+
360 351
 =back
361 352
 
362 353
 =head1 Compiler tools
55  MANIFEST
@@ -107,59 +107,6 @@ compilers/pge/PGE/builtins.pg                               [pge]
107 107
 compilers/pge/README.pod                                    []doc
108 108
 compilers/pge/Rules.mak                                     [pge]
109 109
 compilers/pge/STATUS                                        [pge]
110  
-compilers/pirc/Defines.mak                                  [pirc]
111  
-compilers/pirc/README.pod                                   []doc
112  
-compilers/pirc/Rules.mak                                    [pirc]
113  
-compilers/pirc/TODO                                         [pirc]
114  
-compilers/pirc/heredoc/heredocmain.c                        [pirc]
115  
-compilers/pirc/macro/lexer.h                                [pirc]
116  
-compilers/pirc/macro/macro.h                                [pirc]
117  
-compilers/pirc/macro/macro.l                                [pirc]
118  
-compilers/pirc/macro/macro.y                                [pirc]
119  
-compilers/pirc/macro/macrolexer.c                           [pirc]
120  
-compilers/pirc/macro/macrolexer.h                           [pirc]
121  
-compilers/pirc/macro/macroparser.c                          [pirc]
122  
-compilers/pirc/macro/macroparser.h                          [pirc]
123  
-compilers/pirc/src/bcgen.c                                  [pirc]
124  
-compilers/pirc/src/bcgen.h                                  [pirc]
125  
-compilers/pirc/src/hdocprep.c                               [pirc]
126  
-compilers/pirc/src/hdocprep.l                               [pirc]
127  
-compilers/pirc/src/main.c                                   [pirc]
128  
-compilers/pirc/src/pir.l                                    [pirc]
129  
-compilers/pirc/src/pir.y                                    [pirc]
130  
-compilers/pirc/src/pircapi.c                                [pirc]
131  
-compilers/pirc/src/pircapi.h                                [pirc]
132  
-compilers/pirc/src/pircompiler.c                            [pirc]
133  
-compilers/pirc/src/pircompiler.h                            [pirc]
134  
-compilers/pirc/src/pircompunit.c                            [pirc]
135  
-compilers/pirc/src/pircompunit.h                            [pirc]
136  
-compilers/pirc/src/pirdefines.h                             [pirc]
137  
-compilers/pirc/src/piremit.c                                [pirc]
138  
-compilers/pirc/src/piremit.h                                [pirc]
139  
-compilers/pirc/src/pirerr.c                                 [pirc]
140  
-compilers/pirc/src/pirerr.h                                 [pirc]
141  
-compilers/pirc/src/pirheredoc.h                             [pirc]
142  
-compilers/pirc/src/pirlexer.c                               [pirc]
143  
-compilers/pirc/src/pirlexer.h                               [pirc]
144  
-compilers/pirc/src/pirmacro.c                               [pirc]
145  
-compilers/pirc/src/pirmacro.h                               [pirc]
146  
-compilers/pirc/src/pirop.c                                  [pirc]
147  
-compilers/pirc/src/pirop.h                                  [pirc]
148  
-compilers/pirc/src/pirparser.c                              [pirc]
149  
-compilers/pirc/src/pirparser.h                              [pirc]
150  
-compilers/pirc/src/pirpcc.c                                 [pirc]
151  
-compilers/pirc/src/pirpcc.h                                 [pirc]
152  
-compilers/pirc/src/pirregalloc.c                            [pirc]
153  
-compilers/pirc/src/pirregalloc.h                            [pirc]
154  
-compilers/pirc/src/pirsymbol.c                              [pirc]
155  
-compilers/pirc/src/pirsymbol.h                              [pirc]
156  
-compilers/pirc/src/piryy.h                                  [pirc]
157  
-compilers/pirc/t/basic.t                                    [test]
158  
-compilers/pirc/t/harness                                    [test]
159  
-compilers/pirc/t/heredoc.t                                  [test]
160  
-compilers/pirc/t/macro.t                                    [test]
161  
-compilers/pirc/t/stmts.t                                    [test]
162  
-compilers/pirc/t/subflags.t                                 [test]
163 110
 compilers/tge/Defines.mak                                   [tge]
164 111
 compilers/tge/README                                        []doc
165 112
 compilers/tge/Rules.mak                                     [tge]
@@ -1384,7 +1331,6 @@ src/pmc/bytebuffer.pmc                                      []
1384 1331
 src/pmc/callcontext.pmc                                     []
1385 1332
 src/pmc/capture.pmc                                         []
1386 1333
 src/pmc/class.pmc                                           []
1387  
-src/pmc/codestring.pmc                                      []
1388 1334
 src/pmc/complex.pmc                                         []
1389 1335
 src/pmc/continuation.pmc                                    []
1390 1336
 src/pmc/coroutine.pmc                                       []
@@ -1877,7 +1823,6 @@ t/pmc/bytebuffer.t                                          [test]
1877 1823
 t/pmc/callcontext.t                                         [test]
1878 1824
 t/pmc/capture.t                                             [test]
1879 1825
 t/pmc/class.t                                               [test]
1880  
-t/pmc/codestring.t                                          [test]
1881 1826
 t/pmc/complex.t                                             [test]
1882 1827
 t/pmc/config.t                                              [test]
1883 1828
 t/pmc/context.t                                             [test]
24  MANIFEST.SKIP
@@ -116,28 +116,6 @@
116 116
 ^/compilers/pge/PGE/builtins_gen\.pir/
117 117
 ^/compilers/pge/PGE\.pbc$
118 118
 ^/compilers/pge/PGE\.pbc/
119  
-^/compilers/pirc/.*\.o$
120  
-^/compilers/pirc/.*\.o/
121  
-^/compilers/pirc/.*\.obj$
122  
-^/compilers/pirc/.*\.obj/
123  
-^/compilers/pirc/.*\.pbd$
124  
-^/compilers/pirc/.*\.pbd/
125  
-^/compilers/pirc/pirc$
126  
-^/compilers/pirc/pirc/
127  
-^/compilers/pirc/pirc\.exe$
128  
-^/compilers/pirc/pirc\.exe/
129  
-^/compilers/pirc/t/basic_??\.pir$
130  
-^/compilers/pirc/t/basic_??\.pir/
131  
-^/compilers/pirc/t/basic_?\.pir$
132  
-^/compilers/pirc/t/basic_?\.pir/
133  
-^/compilers/pirc/t/heredoc_?\.pir$
134  
-^/compilers/pirc/t/heredoc_?\.pir/
135  
-^/compilers/pirc/t/macro_?\.pir$
136  
-^/compilers/pirc/t/macro_?\.pir/
137  
-^/compilers/pirc/t/stmts_?\.pir$
138  
-^/compilers/pirc/t/stmts_?\.pir/
139  
-^/compilers/pirc/t/subflags_?\.pir$
140  
-^/compilers/pirc/t/subflags_?\.pir/
141 119
 ^/compilers/tge/TGE/Parser\.pir$
142 120
 ^/compilers/tge/TGE/Parser\.pir/
143 121
 ^/compilers/tge/tgc\.pbc$
@@ -446,8 +424,6 @@
446 424
 ^/pbc_to_exe\..*/
447 425
 ^/perl6$
448 426
 ^/perl6/
449  
-^/pirc$
450  
-^/pirc/
451 427
 ^/ports$
452 428
 ^/ports/
453 429
 ^/runtime/parrot/dynext/.*\.bundle$
5  NEWS
... ...
@@ -1,6 +1,11 @@
1 1
 New in 2.11.0
2 2
 - Core
3 3
  + Just In Time native call frame generation using LibFFI
  4
+ + PIR op find_codepoint is no longer experimental, it is now supported
  5
+ + All public functions in src/datatypes.c have been renamed to Parrot_dt_*
  6
+- Languages
  7
+  + PIRC
  8
+    - left the nest and is currently at https://github.com/parrot/pirc/
4 9
 
5 10
 New in 2.10.0
6 11
 - Core
2  PBC_COMPAT
@@ -28,6 +28,8 @@
28 28
 
29 29
 # please insert tab separated entries at the top of the list
30 30
 
  31
+9.3	2010.11.24	NotFound	move op find_codepoint out of experimental TT #1629
  32
+9.2	2010.11.21	plobsing	remove CodeString PMC
31 33
 9.1	2010.10.27	nwellnhof	remove charset ops
32 34
 9.0	2010.10.19	gerd	released 2.9.0
33 35
 8.0	2010.07.20	coke	released 2.6.0
1  RESPONSIBLE_PARTIES
@@ -56,7 +56,6 @@ Core Developer                  Jonathan Worthington
56 56
 
57 57
 Compiler Developer              Patrick Michaud (PGE, PCT)
58 58
                                 Allison Randal (TGE)
59  
-                                Klaas-Jan Stol (PIRC)
60 59
 
61 60
 Platform Porter                 Allison Randal (Debian, Ubuntu)
62 61
                                 Francois Perrad (MinGW32)
31  compilers/data_json/data_json.pir
@@ -52,6 +52,7 @@ the documentation at L<http://www.json.org/>.
52 52
 
53 53
 .sub 'compile' :method
54 54
     .param string json_string
  55
+    .param pmc    opts :slurpy :named
55 56
 
56 57
     .local pmc parse, match
57 58
     parse = get_root_global ['parrot'; 'JSON'], 'value'
@@ -67,6 +68,14 @@ the documentation at L<http://www.json.org/>.
67 68
     pirbuilder = pirgrammar.'apply'(match)
68 69
     pir = pirbuilder.'get'('result')
69 70
 
  71
+    $I0 = exists opts['target']
  72
+    unless $I0 goto no_targ
  73
+        $S0 = opts['target']
  74
+        unless $S0 == 'pir' goto not_pir
  75
+            .return (pir)
  76
+        not_pir:
  77
+    no_targ:
  78
+
70 79
     .local pmc pirc, result
71 80
     pirc = compreg 'PIR'
72 81
     result = pirc(pir)
@@ -81,6 +90,28 @@ the documentation at L<http://www.json.org/>.
81 90
 
82 91
 .HLL 'parrot'
83 92
 
  93
+.sub unique_pmc_reg
  94
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
  95
+    $I0 = $P0()
  96
+    $S0 = $I0
  97
+    $S0 = concat "$P", $S0
  98
+    .return ($S0)
  99
+.end
  100
+
  101
+.sub appendln
  102
+    .param pmc sb
  103
+    .param string line
  104
+    push sb, line
  105
+    push sb, "\n"
  106
+.end
  107
+
  108
+.sub 'sprintf'
  109
+    .param string fmt
  110
+    .param pmc args :slurpy
  111
+    $S0 = sprintf fmt, args
  112
+    .return ($S0)
  113
+.end
  114
+
84 115
 .include 'compilers/data_json/data_json/grammar.pir'
85 116
 .include 'compilers/data_json/data_json/pge2pir.pir'
86 117
 
87  compilers/data_json/data_json/pge2pir.tg
@@ -6,12 +6,13 @@ transform result (ROOT) {
6 6
 
7 7
     $S0 = tree.'get'('pir', node, 'value')
8 8
 
9  
-    pir = new 'CodeString'
10  
-    pir.'emit'('.sub anon :anon')
11  
-    pir.'emit'($S0)
  9
+    pir = new 'StringBuilder'
  10
+    appendln(pir, '.sub anon :anon')
  11
+    appendln(pir, $S0)
12 12
     result = node['ret']
13  
-    pir.'emit'('    .return (%0)',result)
14  
-    pir.'emit'('.end')
  13
+    $S0 = 'sprintf'('     .return (%Ss)', result)
  14
+    appendln(pir, $S0)
  15
+    appendln(pir, '.end')
15 16
 
16 17
    .return(pir)
17 18
 }
@@ -52,38 +53,37 @@ transform pir (value) {
52 53
     .return (pir)
53 54
 
54 55
   got_true:
55  
-    pir = new 'CodeString'
56  
-    result = pir.'unique'('$P')
57  
-    $S0 = node
58  
-    pir.'emit'("    %0 = new 'Boolean'", result)
59  
-    pir.'emit'('    %0 = 1', result, $S0)
  56
+    pir = new 'StringBuilder'
  57
+    result = unique_pmc_reg()
  58
+    $S0 = 'sprintf'("    %Ss = new 'Boolean', 1", result)
  59
+    appendln(pir, $S0)
60 60
     node['ret'] = result
61 61
     .return(pir)
62 62
 
63 63
   got_false:
64  
-    pir = new 'CodeString'
65  
-    result = pir.'unique'('$P')
66  
-    $S0 = node
67  
-    pir.'emit'("    %0 = new 'Boolean'", result)
68  
-    pir.'emit'('    %0 = 0', result, $S0)
  64
+    pir = new 'StringBuilder'
  65
+    result = unique_pmc_reg()
  66
+    $S0 = 'sprintf'("    %Ss = new 'Boolean', 0", result)
  67
+    appendln(pir, $S0)
69 68
     node['ret'] = result
70 69
     .return(pir)
71 70
 
72 71
   got_null:
73  
-    pir = new 'CodeString'
74  
-    result = pir.'unique'('$P')
75  
-    $S0 = node
76  
-    pir.'emit'('    null %0', result)
  72
+    pir = new 'StringBuilder'
  73
+    result = unique_pmc_reg()
  74
+    $S0 = 'sprintf'('    null %Ss', result)
  75
+    appendln(pir, $S0)
77 76
     node['ret'] = result
78 77
     .return(pir)
79 78
 }
80 79
 
81 80
 transform pir (object) {
82 81
     .local pmc pir
83  
-    pir = new 'CodeString'
  82
+    pir = new 'StringBuilder'
84 83
     .local string result, child_result, key_result
85  
-    result = pir.'unique'('$P')
86  
-    pir.'emit'("    %0 = new 'Hash'", result)
  84
+    result = unique_pmc_reg()
  85
+    $S0 = 'sprintf'("    %Ss = new 'Hash'", result)
  86
+    appendln(pir, $S0)
87 87
 
88 88
     .local pmc items
89 89
 
@@ -106,16 +106,17 @@ loop:
106 106
     child = shift it
107 107
     $P0 = tree.'get'('pir', child, 'value')
108 108
     $S0 = $P0
109  
-    pir .= $S0
  109
+    push pir, $S0
110 110
     child_result = child['ret']
111 111
 
112 112
     key   = shift key_iter
113 113
     $P0 = tree.'get'('pir', key, 'string')
114 114
     $S0 = $P0
115  
-    pir .= $S0
  115
+    push pir, $S0
116 116
     key_result = key['ret']
117 117
 
118  
-    pir.'emit'('    %0[%1] = %2', result, key_result, child_result)
  118
+    $S0 = 'sprintf'('    %Ss[%Ss] = %Ss', result, key_result, child_result)
  119
+    appendln(pir, $S0)
119 120
 
120 121
 
121 122
     goto loop
@@ -127,10 +128,11 @@ end:
127 128
 
128 129
 transform pir (array) {
129 130
     .local pmc pir
130  
-    pir = new 'CodeString'
  131
+    pir = new 'StringBuilder'
131 132
     .local string result, child_result
132  
-    result = pir.'unique'('$P')
133  
-    pir.'emit'("    %0 = new 'ResizablePMCArray'", result)
  133
+    result = unique_pmc_reg()
  134
+    $S0 = 'sprintf'("    %Ss = new 'ResizablePMCArray'", result)
  135
+    appendln(pir, $S0)
134 136
 
135 137
     .local pmc items
136 138
 
@@ -147,10 +149,11 @@ loop:
147 149
     child = shift it
148 150
     $P0 = tree.'get'('pir', child, 'value')
149 151
     $S0 = $P0
150  
-    pir .= $S0
  152
+    push pir, $S0
151 153
 
152 154
     child_result = child['ret']
153  
-    pir.'emit'('    push %0, %1', result, child_result)
  155
+    $S0 = 'sprintf'('    push %Ss, %Ss', result, child_result)
  156
+    appendln(pir, $S0)
154 157
     goto loop
155 158
 end:
156 159
     node['ret'] = result
@@ -162,7 +165,7 @@ transform pir (string) {
162 165
     .local pmc pir, result, children, it, child
163 166
     .local string tmp
164 167
     tmp = ''
165  
-    pir = new 'CodeString'
  168
+    pir = new 'StringBuilder'
166 169
     children = node['char']
167 170
     if null children goto loop_end
168 171
     it = iter children
@@ -190,21 +193,25 @@ transform pir (string) {
190 193
     goto loop
191 194
   loop_end:
192 195
 
193  
-    result = pir.'unique'('$P')
194  
-    $S1 = pir.'escape'(tmp)
195  
-    pir.'emit'("    %0 = new 'String'", result)
196  
-    pir.'emit'('    %0 = %1', result, $S1)
  196
+    result = unique_pmc_reg()
  197
+    $S0 = 'sprintf'("    %Ss = new 'String'", result)
  198
+    appendln(pir, $S0)
  199
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'pir_str_escape'
  200
+    tmp = $P0(tmp)
  201
+    $S0 = 'sprintf'('    %Ss = %Ss', result, tmp)
  202
+    appendln(pir, $S0)
197 203
     node['ret'] = result
198 204
    .return(pir)
199 205
 }
200 206
 
201 207
 transform pir (number) {
202 208
     .local pmc pir, result
203  
-    pir = new 'CodeString'
204  
-    result = pir.'unique'('$P')
205  
-    $S0 = node
206  
-    pir.'emit'("    %0 = new 'Integer'", result)
207  
-    pir.'emit'('    %0 = %1', result, $S0)
  209
+    pir = new 'StringBuilder'
  210
+    result = unique_pmc_reg()
  211
+    $S0 = 'sprintf'("    %Ss = new 'Integer'", result)
  212
+    appendln(pir, $S0)
  213
+    $S0 = 'sprintf'('    %Ss = %Ss', result, node)
  214
+    appendln(pir, $S0)
208 215
     node['ret'] = result
209 216
    .return(pir)
210 217
 }
284  compilers/pge/PGE/Exp.pir
@@ -43,6 +43,8 @@ PGE::Exp - base class for expressions
43 43
     p6meta.'new_class'('PGE::Exp::Modifier',     'parent'=>expproto)
44 44
     p6meta.'new_class'('PGE::Exp::Closure',      'parent'=>expproto)
45 45
     p6meta.'new_class'('PGE::Exp::Action',       'parent'=>expproto)
  46
+
  47
+    load_bytecode 'PGE/Util.pbc'
46 48
 .end
47 49
 
48 50
 
@@ -65,7 +67,7 @@ C<target> adverbs.
65 67
     if target == 'pge::exp' goto return_exp
66 68
 
67 69
     .local pmc code
68  
-    code = new 'CodeString'
  70
+    code = new 'StringBuilder'
69 71
 
70 72
     .local pmc ns
71 73
     ns = adverbs['namespace']
@@ -75,8 +77,9 @@ C<target> adverbs.
75 77
     grammar = adverbs['grammar']
76 78
     ns = split '::', grammar
77 79
   ns_emit:
78  
-    $P0 = code.'key'(ns)
79  
-    code.'emit'('.namespace %0', $P0)
  80
+    $P1 = get_root_global ['parrot';'PGE';'Util'], 'pir_key_escape'
  81
+    $P0 = $P1(ns :flat)
  82
+    code.'append_format'(".namespace %0\n", $P0)
80 83
   ns_done:
81 84
 
82 85
     $P0 = self.'root_pir'(adverbs :flat :named)
@@ -104,7 +107,7 @@ C<target> adverbs.
104 107
 
105 108
 =item C<root_pir(PMC adverbs)>
106 109
 
107  
-Return a CodeString object containing the entire expression
  110
+Return a StringBuilder object containing the entire expression
108 111
 tree as a PIR code object that can be compiled.
109 112
 
110 113
 =cut
@@ -113,17 +116,20 @@ tree as a PIR code object that can be compiled.
113 116
     .param pmc adverbs         :slurpy :named
114 117
 
115 118
     .local pmc code
116  
-    code = new 'CodeString'
  119
+    code = new 'StringBuilder'
117 120
 
118 121
     .local string name, namecorou
119 122
     name = adverbs['name']
120 123
     namecorou = concat name, '_corou'
121 124
     if name > '' goto have_name
122  
-    name = code.'unique'('_regex')
  125
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
  126
+    name = $P0('_regex')
123 127
     namecorou = concat name, '_corou'
124 128
   have_name:
125  
-    name = code.'escape'(name)
126  
-    namecorou = code.'escape'(namecorou)
  129
+    .local pmc escape
  130
+    escape = get_root_global ['parrot';'PGE';'Util'], 'pir_str_escape'
  131
+    name      = escape(name)
  132
+    namecorou = escape(namecorou)
127 133
 
128 134
     .local string pirflags
129 135
     pirflags = adverbs['pirflags']
@@ -132,7 +138,7 @@ tree as a PIR code object that can be compiled.
132 138
     if $I0 >= 0 goto have_subid
133 139
     $P0 = adverbs['subid']
134 140
     if null $P0 goto have_subid
135  
-    $S0 = code.'escape'($P0)
  141
+    $S0 = escape($P0)
136 142
     pirflags = concat pirflags, ' :subid('
137 143
     concat pirflags, $S0
138 144
     concat pirflags, ')'
@@ -153,7 +159,7 @@ tree as a PIR code object that can be compiled.
153 159
 
154 160
     ##   generate the PIR for the expression tree.
155 161
     .local pmc expcode
156  
-    expcode = new 'CodeString'
  162
+    expcode = new 'StringBuilder'
157 163
     explabel = 'R'
158 164
     exp.'pir'(expcode, explabel, 'succeed')
159 165
 
@@ -161,7 +167,7 @@ tree as a PIR code object that can be compiled.
161 167
     ##   Generate the initial PIR code for a backtracking (uncut) rule.
162 168
     .local string returnop
163 169
     returnop = '.yield'
164  
-    code.'emit'(<<"        CODE", name, pirflags, namecorou, .INTERPINFO_CURRENT_SUB)
  170
+    code.'append_format'(<<"        CODE", name, pirflags, namecorou, .INTERPINFO_CURRENT_SUB)
165 171
       .sub %0 :method :nsentry %1
166 172
           .param pmc adverbs   :slurpy :named
167 173
           .local pmc mob
@@ -190,7 +196,7 @@ tree as a PIR code object that can be compiled.
190 196
   code_cutrule:
191 197
     ##   Initial code for a rule that cannot be backtracked into.
192 198
     returnop = '.return'
193  
-    code.'emit'(<<"        CODE", name, pirflags)
  199
+    code.'append_format'(<<"        CODE", name, pirflags)
194 200
       .sub %0 :method :nsentry %1
195 201
           .param pmc adverbs      :slurpy :named
196 202
           .local pmc mob
@@ -208,27 +214,27 @@ tree as a PIR code object that can be compiled.
208 214
     ##   generate the ustack only if we need it
209 215
     .local string expstr
210 216
     expstr = expcode
211  
-    code.'emit'("          .local pmc cstack")
212  
-    code.'emit'("          cstack = root_new ['parrot';'ResizableIntegerArray']")
  217
+    code.'append_format'("          .local pmc cstack\n")
  218
+    code.'append_format'("          cstack = root_new ['parrot';'ResizableIntegerArray']\n")
213 219
     $I0 = index expstr, 'ustack'
214 220
     if $I0 < 0 goto code_body_1
215  
-    code.'emit'("          .local pmc ustack")
216  
-    code.'emit'("          ustack = root_new ['parrot';'ResizablePMCArray']")
  221
+    code.'append_format'("          .local pmc ustack\n")
  222
+    code.'append_format'("          ustack = root_new ['parrot';'ResizablePMCArray']\n")
217 223
   code_body_1:
218 224
     ##   generate the gpad only if we need it
219 225
     $I0 = index expstr, 'gpad'
220 226
     if $I0 < 0 goto code_body_2
221  
-    code.'emit'("          .local pmc gpad")
222  
-    code.'emit'("          gpad = root_new ['parrot';'ResizablePMCArray']")
  227
+    code.'append_format'("          .local pmc gpad\n")
  228
+    code.'append_format'("          gpad = root_new ['parrot';'ResizablePMCArray']\n")
223 229
   code_body_2:
224 230
     ##   set the captscope if we need it
225 231
     $I0 = index expstr, 'captscope'
226 232
     if $I0 < 0 goto code_body_3
227  
-    code.'emit'("          .local pmc captscope, captob")
228  
-    code.'emit'("          captscope = mob")
  233
+    code.'append_format'("          .local pmc captscope, captob\n")
  234
+    code.'append_format'("          captscope = mob\n")
229 235
   code_body_3:
230 236
 
231  
-    code.'emit'(<<"        CODE", PGE_CUT_RULE, returnop)
  237
+    code.'append_format'(<<"        CODE", PGE_CUT_RULE, returnop)
232 238
           .local int pos, rep, cutmark
233 239
         try_match:
234 240
           if cpos > lastpos goto fail_rule
@@ -255,7 +261,7 @@ tree as a PIR code object that can be compiled.
255 261
     ##   add the "fail_match" target if we need it
256 262
     $I0 = index expstr, 'fail_match'
257 263
     if $I0 < 0 goto add_expcode
258  
-    code.'emit'(<<"        CODE", PGE_CUT_MATCH)
  264
+    code.'append_format'(<<"        CODE", PGE_CUT_MATCH)
259 265
         fail_match:
260 266
           cutmark = %0
261 267
           goto fail_cut
@@ -264,7 +270,7 @@ tree as a PIR code object that can be compiled.
264 270
   add_expcode:
265 271
     ##   add the expression code, then close off the sub
266 272
     code .= expcode
267  
-    code.'emit'("      .end")
  273
+    code.'append_format'("      .end\n")
268 274
     .return (code)
269 275
 .end
270 276
 
@@ -312,28 +318,47 @@ tree as a PIR code object that can be compiled.
312 318
     .local int iscapture, isarray
313 319
     cname = self['cname']
314 320
     iscapture = self['iscapture']
315  
-    isarray = self['isarray']
316  
-    captgen = new 'CodeString'
317  
-    captsave = new 'CodeString'
318  
-    captback = new 'CodeString'
  321
+    isarray   = self['isarray']
  322
+    captgen   = new 'StringBuilder'
  323
+    captsave  = new 'StringBuilder'
  324
+    captback  = new 'StringBuilder'
319 325
     if iscapture == 0 goto end
320 326
     if isarray != 0 goto capt_array
321  
-    captsave.'emit'("captscope[%0] = captob", cname)
322  
-    captback.'emit'("delete captscope[%0]", cname)
  327
+    push captsave, 'captscope['
  328
+        push captsave, cname
  329
+        push captsave, "] = captob\n"
  330
+    push captback, 'delete captscope['
  331
+        push captback, cname
  332
+        push captback, "]\n"
323 333
     goto end
324 334
   capt_array:
325  
-    captsave.'emit'("$P2 = captscope[%0]\n          push $P2, captob", cname)
326  
-    captback.'emit'("$P2 = captscope[%0]\n          $P2 = pop $P2", cname)
327  
-    captgen.'emit'(<<"        CODE", cname, label)
328  
-          $I0 = defined captscope[%0]
329  
-          if $I0 goto %1_cgen
330  
-          $P0 = root_new ['parrot';'ResizablePMCArray']
331  
-          captscope[%0] = $P0
332  
-          local_branch cstack, %1_cgen
333  
-          delete captscope[%0]
334  
-          goto fail
335  
-        %1_cgen:
336  
-        CODE
  335
+    push captsave, '$P2 = captscope['
  336
+        push captsave, cname
  337
+        push captsave, "]\n"
  338
+    push captsave, 'push $P2, captob'
  339
+    push captback, '$P2 = captscope['
  340
+        push captback, cname
  341
+        push captback, "]\n"
  342
+    push captback, '$P2 = pop $P2'
  343
+    push captgen, '$I0 = defined captscope['
  344
+        push captgen, cname
  345
+        push captgen, "]\n"
  346
+    push captgen, 'if $I0 goto '
  347
+        push captgen, label
  348
+        push captgen, "_cgen\n"
  349
+     push captgen, "$P0 = root_new ['parrot';'ResizablePMCArray']\n"
  350
+     push captgen, 'captscope['
  351
+         push captgen, cname
  352
+         push captgen, "] = $P0\n"
  353
+     push captgen, 'local_branch cstack, '
  354
+         push captgen, label
  355
+         push captgen, "_cgen\n"
  356
+     push captgen, 'delete captscope['
  357
+         push captgen, cname
  358
+         push captgen, "]\n"
  359
+     push captgen, "goto fail\n"
  360
+     push captgen, label
  361
+         push captgen, "_cgen:\n"
337 362
   end:
338 363
     .return (captgen, captsave, captback)
339 364
 .end
@@ -365,9 +390,10 @@ tree as a PIR code object that can be compiled.
365 390
     literal = downcase literal
366 391
   ignorecase_end:
367 392
 
368  
-    literal = code.'escape'(literal)
  393
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'pir_str_escape'
  394
+    literal = $P0(literal)
369 395
 
370  
-    code.'emit'(<<"        CODE", litlen, literal, args :named :flat)
  396
+    code.'append_format'(<<"        CODE", litlen, literal, args :named :flat)
371 397
         %L: # literal
372 398
           $I0 = pos + %0
373 399
           if $I0 > lastpos goto fail
@@ -441,17 +467,19 @@ tree as a PIR code object that can be compiled.
441 467
     .param pmc code
442 468
     .param string label
443 469
     .param string next
  470
+    .local pmc unique
  471
+    unique = get_root_global ['parrot';'PGE';'Util'], 'unique'
444 472
 
445 473
     .local pmc it, exp
446  
-    code.'emit'('        %0: # concat', label)
  474
+    code.'append_format'("        %0: # concat\n", label)
447 475
     $P0 = self.'list'()
448 476
     it  = iter $P0
449 477
     exp = shift it
450  
-    $S0 = code.'unique'('R')
  478
+    $S0 = unique('R')
451 479
   iter_loop:
452 480
     unless it goto iter_end
453 481
     $P1 = shift it
454  
-    $S1 = code.'unique'('R')
  482
+    $S1 = unique('R')
455 483
     exp.'pir'(code, $S0, $S1)
456 484
     exp = $P1
457 485
     $S0 = $S1
@@ -502,6 +530,9 @@ tree as a PIR code object that can be compiled.
502 530
     .param string label
503 531
     .param string next
504 532
 
  533
+    .local pmc unique
  534
+    unique = get_root_global ['parrot';'PGE';'Util'], 'unique'
  535
+
505 536
     .local pmc exp, sep
506 537
     .local string explabel, seplabel, replabel, nextlabel
507 538
     exp = self[0]
@@ -521,11 +552,11 @@ tree as a PIR code object that can be compiled.
521 552
     .local int backtrack
522 553
     backtrack = self['backtrack']
523 554
 
524  
-    explabel = code.'unique'('R')
  555
+    explabel = unique('R')
525 556
     nextlabel = explabel
526 557
     replabel = concat label, '_repeat'
527 558
     if null sep goto outer_quant_1
528  
-    seplabel = code.'unique'('R')
  559
+    seplabel = unique('R')
529 560
     nextlabel = concat label, '_sep'
530 561
   outer_quant_1:
531 562
 
@@ -540,7 +571,7 @@ tree as a PIR code object that can be compiled.
540 571
     if $I0 != 0 goto bt_greedy_none
541 572
     $I0 = self['max']
542 573
     if $I0 != PGE_INF goto bt_greedy_none
543  
-    code.'emit'(<<"        CODE", replabel, nextlabel, args :flat :named)
  574
+    code.'append_format'(<<"        CODE", replabel, nextlabel, args :flat :named)
544 575
         %L:  # quant 0..Inf greedy
545 576
         %0:
546 577
           push ustack, pos
@@ -552,7 +583,7 @@ tree as a PIR code object that can be compiled.
552 583
     goto end
553 584
 
554 585
   bt_none:
555  
-    $S0 = code.'unique'()
  586
+    $S0 = unique()
556 587
     args['c'] = $S0
557 588
     args['C'] = ''
558 589
     ##   handle 0..Inf as a special case
@@ -560,7 +591,7 @@ tree as a PIR code object that can be compiled.
560 591
     if $I0 != 0 goto bt_greedy_none
561 592
     $I0 = self['max']
562 593
     if $I0 != PGE_INF goto bt_greedy_none
563  
-    code.'emit'(<<"        CODE", replabel, nextlabel, args :flat :named)
  594
+    code.'append_format'(<<"        CODE", replabel, nextlabel, args :flat :named)
564 595
         %L:  # quant 0..Inf none
565 596
           local_branch cstack, %0
566 597
           if cutmark != %c goto fail
@@ -580,7 +611,7 @@ tree as a PIR code object that can be compiled.
580 611
 
581 612
   bt_greedy_none:
582 613
     ##   handle greedy or none
583  
-    code.'emit'(<<"        CODE", replabel, nextlabel, args :flat :named)
  614
+    code.'append_format'(<<"        CODE", replabel, nextlabel, args :flat :named)
584 615
         %L:  # quant %Q greedy/none
585 616
           push gpad, 0
586 617
           local_branch cstack, %0
@@ -615,7 +646,7 @@ tree as a PIR code object that can be compiled.
615 646
 
616 647
   bt_eager:
617 648
     ##   handle eager backtracking
618  
-    code.'emit'(<<"        CODE", replabel, nextlabel, args :flat :named)
  649
+    code.'append_format'(<<"        CODE", replabel, nextlabel, args :flat :named)
619 650
         %L:  # quant %Q eager
620 651
           push gpad, 0
621 652
           local_branch cstack, %0
@@ -640,7 +671,7 @@ tree as a PIR code object that can be compiled.
640 671
 
641 672
   end:
642 673
     if null sep goto sep_done
643  
-    code.'emit'(<<"        CODE", nextlabel, explabel, seplabel)
  674
+    code.'append_format'(<<"        CODE", nextlabel, explabel, seplabel)
644 675
         %0:
645 676
           if rep == 1 goto %1
646 677
           goto %2
@@ -703,8 +734,9 @@ tree as a PIR code object that can be compiled.
703 734
 
704 735
   has_cutmark:
705 736
     .local string exp0label
706  
-    exp0label = code.'unique'('R')
707  
-    code.'emit'(<<"        CODE", label, exp0label, cutmark)
  737
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
  738
+    exp0label = $P0('R')
  739
+    code.'append_format'(<<"        CODE", label, exp0label, cutmark)
708 740
         %0:  # group %2
709 741
           local_branch cstack, %1
710 742
           if cutmark != %2 goto fail
@@ -723,7 +755,8 @@ tree as a PIR code object that can be compiled.
723 755
     .param string next
724 756
 
725 757
     .local string explabel, expnext
726  
-    explabel = code.'unique'('R')
  758
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
  759
+    explabel = $P0('R')
727 760
     expnext = concat label, '_close'
728 761
 
729 762
     .local pmc args
@@ -747,7 +780,7 @@ tree as a PIR code object that can be compiled.
747 780
     args['X'] = '### '
748 781
   isscope_end:
749 782
 
750  
-    code.'emit'(<<"        CODE", captgen, captsave, captback, 'E'=>explabel, args :flat :named)
  783
+    code.'append_format'(<<"        CODE", captgen, captsave, captback, 'E'=>explabel, args :flat :named)
751 784
         %L: # capture
752 785
           %0
753 786
           captob = captscope.'new'(captscope, 'pos'=>pos)
@@ -798,19 +831,22 @@ tree as a PIR code object that can be compiled.
798 831
     .local pmc args
799 832
     args = self.'getargs'(label, next)
800 833
 
  834
+    .local pmc escape
  835
+    escape = get_root_global ['parrot';'PGE';'Util'], 'pir_str_escape'
  836
+
801 837
     .local string subarg
802 838
     subarg = ''
803 839
     $I0 = exists self['arg']
804 840
     if $I0 == 0 goto subarg_dba
805 841
     subarg = self['arg']
806  
-    subarg = code.'escape'(subarg)
  842
+    subarg = escape(subarg)
807 843
     subarg = concat ', ', subarg
808 844
     args['A'] = $S0
809 845
   subarg_dba:
810 846
     $I0 = exists self['dba']
811 847
     if $I0 == 0 goto subarg_end
812 848
     $S0 = self['dba']
813  
-    $S0 = code.'escape'($S0)
  849
+    $S0 = escape($S0)
814 850
     subarg .= ", 'dba'=>"
815 851
     subarg .= $S0
816 852
   subarg_end:
@@ -836,8 +872,9 @@ tree as a PIR code object that can be compiled.
836 872
     $I0 -= 2
837 873
     grammar = substr subname, 0, $I0
838 874
     $P0 = split '::', grammar
839  
-    $P0 = code.'key'($P0)
840  
-    code.'emit'(<<"        CODE", grammar, rname, $P0, args :flat :named)
  875
+    $P1 = get_root_global ['parrot';'PGE';'Util'], 'pir_key_escape'
  876
+    $P0 = $P1($P0 :flat)
  877
+    code.'append_format'(<<"        CODE", grammar, rname, $P0, args :flat :named)
841 878
         %L: # grammar subrule %0::%1
842 879
           captob = captscope.'new'(captscope, 'grammar'=>'%0')
843 880
           captob.'to'(pos)
@@ -849,7 +886,7 @@ tree as a PIR code object that can be compiled.
849 886
     ##   The subrule is of the form <rule>, which means we first look
850 887
     ##   for a method on the current match object, otherwise we do a
851 888
     ##   normal name lookup.
852  
-    code.'emit'(<<"        CODE", subname, args :flat :named)
  889
+    code.'append_format'(<<"        CODE", subname, args :flat :named)
853 890
         %L: # subrule %0
854 891
           captob = captscope
855 892
           $P0 = getattribute captob, '$.pos'
@@ -877,7 +914,7 @@ tree as a PIR code object that can be compiled.
877 914
     ##   We either branch directly to the next node (PGE_BACKTRACK_NONE)
878 915
     ##   or to a small subroutine below that will keep backtracking into
879 916
     ##   the subrule until it no longer produces a match.
880  
-    code.'emit'(<<"        CODE", PGE_CUT_MATCH, $S0, captgen, captsave, captback, subarg)
  917
+    code.'append_format'(<<"        CODE", PGE_CUT_MATCH, $S0, captgen, captsave, captback, subarg)
881 918
           $P2 = adverbs['action']
882 919
           captob = $P0(captob%5, 'action'=>$P2)
883 920
           $P1 = getattribute captob, '$.pos'
@@ -892,7 +929,7 @@ tree as a PIR code object that can be compiled.
892 929
         CODE
893 930
     if $I0 == PGE_BACKTRACK_NONE goto end
894 931
     ##   Repeatedly backtrack into the subrule until there are no matches.
895  
-    code.'emit'(<<"        CODE", PGE_CUT_MATCH, $S0, next)
  932
+    code.'append_format'(<<"        CODE", PGE_CUT_MATCH, $S0, next)
896 933
         %1:
897 934
           pos = $P1
898 935
           $P1 = getattribute captob, '&!corou'
@@ -919,7 +956,7 @@ tree as a PIR code object that can be compiled.
919 956
     unless $I0 goto have_test
920 957
     test = 'unless'
921 958
   have_test:
922  
-    code.'emit'(<<"        CODE", PGE_CUT_MATCH, test, next, subarg)
  959
+    code.'append_format'(<<"        CODE", PGE_CUT_MATCH, test, next, subarg)
923 960
           captob = $P0(captob%3)
924 961
           $P1 = getattribute captob, '$.pos'
925 962
           if $P1 <= %0 goto fail_match
@@ -955,9 +992,10 @@ tree as a PIR code object that can be compiled.
955 992
     .param string next
956 993
     .local pmc exp0, exp1
957 994
     .local string exp0label, exp1label
958  
-    exp0label = code.'unique'('R')
959  
-    exp1label = code.'unique'('R')
960  
-    code.'emit'(<<"        CODE", label, exp0label, exp1label)
  995
+    $P0 = get_root_global ['parrot';'PGE';'Util'], 'unique'
  996
+    exp0label = $P0('R')
  997
+    exp1label = $P0('R')
  998
+    code.'append_format'(<<"        CODE", label, exp0label, exp1label)
961 999
         %0:  # alt %1, %2
962 1000
           push ustack, pos
963 1001
           local_branch cstack, %1
@@ -1002,29 +1040,29 @@ tree as a PIR code object that can be compiled.
1002 1040
     if token == '\B' goto anchor_word
1003 1041
 
1004 1042
   anchor_fail:
1005  
-    code.'emit'("        %0: # anchor fail %1", label, token)
1006  
-    code.'emit'("          goto fail")
  1043
+    code.'append_format'("        %0: # anchor fail %1\n", label, token)
  1044
+    code.'append_format'("          goto fail\n")
1007 1045
     .return ()
1008 1046
 
1009 1047
   anchor_null:
1010  
-    code.'emit'("        %0: # anchor null %1", label, token)
1011  
-    code.'emit'("          goto %0", next)
  1048
+    code.'append_format'("        %0: # anchor null %1\n", label, token)
  1049
+    code.'append_format'("          goto %0\n", next)
1012 1050
     .return ()
1013 1051
 
1014 1052
   anchor_bos:
1015  
-    code.'emit'("        %0: # anchor bos", label)
1016  
-    code.'emit'("          if pos == 0 goto %0", next)
1017  
-    code.'emit'("          goto fail")
  1053
+    code.'append_format'("        %0: # anchor bos\n", label)
  1054
+    code.'append_format'("          if pos == 0 goto %0\n", next)
  1055
+    code.'append_format'("          goto fail\n")
1018 1056
     .return ()
1019 1057
 
1020 1058
   anchor_eos:
1021  
-    code.'emit'("        %0: # anchor eos", label)
1022  
-    code.'emit'("          if pos == lastpos goto %0", next)
1023  
-    code.'emit'("          goto fail")
  1059
+    code.'append_format'("        %0: # anchor eos\n", label)
  1060
+    code.'append_format'("          if pos == lastpos goto %0\n", next)
  1061
+    code.'append_format'("          goto fail\n")
1024 1062
     .return ()
1025 1063
 
1026 1064
   anchor_bol:
1027  
-    code.'emit'(<<"        CODE", label, next, .CCLASS_NEWLINE)
  1065
+    code.'append_format'(<<"        CODE", label, next, .CCLASS_NEWLINE)
1028 1066
         %0: # anchor bol
1029 1067
           if pos == 0 goto %1
1030 1068
           if pos == lastpos goto fail
@@ -1036,7 +1074,7 @@ tree as a PIR code object that can be compiled.
1036 1074
     .return ()
1037 1075
 
1038 1076
   anchor_eol:
1039  
-    code.'emit'(<<"        CODE", label, next, .CCLASS_NEWLINE)
  1077
+    code.'append_format'(<<"        CODE", label, next, .CCLASS_NEWLINE)
1040 1078
         %0: # anchor eol
1041 1079
           $I1 = is_cclass %2, target, pos
1042 1080
           if $I1 goto %1
@@ -1050,7 +1088,7 @@ tree as a PIR code object that can be compiled.
1050 1088
     .return ()
1051 1089
 
1052 1090
   anchor_word:
1053  
-    code.'emit'(<<"        CODE", label, next, .CCLASS_WORD, test)
  1091
+    code.'append_format'(<<"        CODE", label, next, .CCLASS_WORD, test)
1054 1092
         %0: # anchor word
1055 1093
           $I0 = 0
1056 1094
           if pos == 0 goto %0_1
@@ -1067,7 +1105,7 @@ tree as a PIR code object that can be compiled.
1067 1105
     .return ()
1068 1106
 
1069 1107
   anchor_word_left:
1070  
-    code.'emit'(<<"        CODE", label, next, .CCLASS_WORD)
  1108
+    code.'append_format'(<<"        CODE", label, next, .CCLASS_WORD)
1071 1109
         %0: # left word boundary
1072 1110
           if pos >= lastpos goto fail
1073 1111
           $I0 = is_cclass %2, target, pos
@@ -1081,7 +1119,7 @@ tree as a PIR code object that can be compiled.
1081 1119
     .return ()
1082 1120
 
1083 1121
   anchor_word_right:
1084  
-    code.'emit'(<<"        CODE", label, next, .CCLASS_WORD)
  1122
+    code.'append_format'(<<"        CODE", label, next, .CCLASS_WORD)
1085 1123
         %0: # right word boundary
1086 1124
           if pos == 0 goto fail
1087 1125
           $I0 = pos - 1
@@ -1139,16 +1177,16 @@ tree as a PIR code object that can be compiled.
1139 1177
     .local int cclass, negate
1140 1178
 
1141 1179
     $S0 = self.'ast'()
1142  
-    code.'emit'("        %0: # cclass %1", label, $S0)
1143  
-    code.'emit'("          if pos >= lastpos goto fail")
  1180
+    code.'append_format'("        %0: # cclass %1\n", label, $S0)
  1181
+    code.'append_format'("          if pos >= lastpos goto fail\n")
1144 1182
     cclass = self['cclass']
1145 1183
     negate = self['negate']
1146 1184
     if cclass == .CCLASS_ANY goto end
1147  
-    code.'emit'("          $I0 = is_cclass %0, target, pos", cclass)
1148  
-    code.'emit'("          if $I0 == %0 goto fail", negate)
  1185
+    code.'append_format'("          $I0 = is_cclass %0, target, pos\n", cclass)
  1186
+    code.'append_format'("          if $I0 == %0 goto fail\n", negate)
1149 1187
   end:
1150  
-    code.'emit'("          inc pos")
1151  
-    code.'emit'("          goto %0", next)
  1188
+    code.'append_format'("          inc pos\n")
  1189
+    code.'append_format'("          goto %0\n", next)
1152 1190
     .return ()
1153 1191
 .end
1154 1192
 
@@ -1167,7 +1205,7 @@ tree as a PIR code object that can be compiled.
1167 1205
     backtrack = quant['backtrack']
1168 1206
 
1169 1207
     ##  output initial label
1170  
-    code.'emit'("        %L: # cclass %0 %Q", self, args :flat :named)
  1208
+    code.'append_format'("        %L: # cclass %0 %Q\n", self, args :flat :named)
1171 1209
 
1172 1210
     .local int cclass, negate
1173 1211
     cclass = self['cclass']
@@ -1178,16 +1216,16 @@ tree as a PIR code object that can be compiled.
1178 1216
     if negate == 0 goto emit_find
1179 1217
     negstr = ''
1180 1218
   emit_find:
1181  
-    code.'emit'(<<"        CODE", negstr, cclass)
  1219
+    code.'append_format'(<<"        CODE", negstr, cclass)
1182 1220
           $I0 = find%0_cclass %1, target, pos, lastpos
1183 1221
           rep = $I0 - pos
1184 1222
         CODE
1185 1223
     goto emit_pir
1186 1224
   emit_dot:
1187  
-    code.'emit'("          rep = lastpos - pos")
  1225
+    code.'append_format'("          rep = lastpos - pos\n")
1188 1226
 
1189 1227
   emit_pir:
1190  
-    code.'emit'(<<"        CODE", args :flat :named)
  1228
+    code.'append_format'(<<"        CODE", args :flat :named)
1191 1229
           %Mif rep < %m goto fail
1192 1230
           %Nif rep <= %n goto %L_1
1193 1231
           %Nrep = %n