Author: pmichaud
Date: Thu Oct  4 16:22:56 2007
New Revision: 21855

Modified:
   trunk/runtime/parrot/library/PGE/Text.pir

Log:
[pge]:
* Eliminate 'newfrom' in PGE::Text


Modified: trunk/runtime/parrot/library/PGE/Text.pir
==============================================================================
--- trunk/runtime/parrot/library/PGE/Text.pir   (original)
+++ trunk/runtime/parrot/library/PGE/Text.pir   Thu Oct  4 16:22:56 2007
@@ -37,20 +37,19 @@
     .param string delim        :optional           # optional delimiters
     .param int has_delim       :opt_flag
     .param pmc adverbs         :slurpy :named      # named options
-    .local pmc newfrom                             # newfrom sub
-    .local pmc mob, mfrom, mpos                    # return match object
+    .local pmc mob                                 # return match object
     .local string target                           # target as string
     .local string bal, bra, ket                    # balanced brackets
     .local string delim_bra, delim_ket             # delims for this match
     .local string lookket                          # closing bracket char
-    .local int pos                                 # current match position
+    .local int from, pos                           # current match position
     .local int balanced                            # in balanced match
     .local pmc stack                               # lookket backtracking
 
     stack = new 'ResizableStringArray'
-    newfrom = find_global "PGE::Match", "newfrom"
-    (mob, target, mfrom, mpos) = newfrom(tgt, 0)
-    pos = mfrom
+    $P0 = get_hll_global ['PGE'], 'Match'
+    (mob, pos, target) = $P0.'new'(tgt)
+    from = pos
 
     if has_delim goto mkdelims
     delim = "{}()[]<>"
@@ -63,7 +62,7 @@
     ket = '}}))]]>>'                               # balanced closers
     $I0 = length delim                             # length of delim string
   mkdelims_1:
-    dec $I0                          
+    dec $I0
     if $I0 < 0 goto extract
     $S0 = substr delim, $I0, 1
     $I1 = index bal, $S0
@@ -79,13 +78,13 @@
     goto mkdelims_1
 
   extract:
-    $S0 = substr target, pos, 1                    
+    $S0 = substr target, pos, 1
     if $S0 == "\\" goto end                        # leading escape fails
     $I0 = index delim_bra, $S0
     if $I0 < 0 goto end                            # no leading delim fails
     lookket = ''
     balanced = 1
-  next:                                       
+  next:
     $S0 = substr target, pos, 1                    # check current pos
     if $S0 == '' goto fail                         # end of string -> fail
     if $S0 == "\\" goto escape                     # skip escaped pos
@@ -112,10 +111,11 @@
     balanced = 1                                   # we're balancing again
     inc pos                                        # skip close char
     if lookket != '' goto next                     # still nested?
-    mpos = pos                                     # we have a match!
-    ($P0, $P1, $P2, $P3) = newfrom(mob, mfrom)     # create delim-less submatch
-    $P2 = mfrom + 1
-    $P3 = mpos - 1
+    mob.'to'(pos)                                  # set end of match
+    $I0 = from + 1                                # create delim-less submatch
+    $I1 = pos - 1
+    $P0 = mob.'new'(mob, 'pos' => $I0)
+    $P0.'to'($I1)
     mob[0] = $P0
   fail:                                            # fail match
   end:

Reply via email to