[svn:parrot] r37824 - in trunk: compilers/nqp/src/Grammar compilers/nqp/t compilers/pct/src/PCT compilers/pge/PGE runtime/parrot/library/PGE runtime/parrot/library/Tcl

pmichaud at svn.parrot.org pmichaud at svn.parrot.org
Tue Mar 31 01:24:47 UTC 2009


Author: pmichaud
Date: Tue Mar 31 01:24:46 2009
New Revision: 37824
URL: https://trac.parrot.org/parrot/changeset/37824

Log:
Merge pge1 branch back into trunk (partial resolution of TT #460).
Specific changes:
* Retrieve text of a Match is now .Str (was .text)
* Setting a result object in a Match is now match.'!make'(obj) (was .result_object)
* Retrieving the result object is now match.'ast'() (was .item)
* NQP's $(...) now calls '.ast' instead of '.item'
* get_string/integer/number on Match objects now work from .Str instead of result object

Modified:
   trunk/compilers/nqp/src/Grammar/Actions.pir
   trunk/compilers/nqp/t/24-scalar_context.t
   trunk/compilers/pct/src/PCT/Grammar.pir
   trunk/compilers/pge/PGE/Exp.pir
   trunk/compilers/pge/PGE/Match.pir
   trunk/compilers/pge/PGE/OPTable.pir
   trunk/compilers/pge/PGE/P5Regex.pir
   trunk/compilers/pge/PGE/Perl6Regex.pir
   trunk/runtime/parrot/library/PGE/Glob.pir
   trunk/runtime/parrot/library/Tcl/Glob.pir

Modified: trunk/compilers/nqp/src/Grammar/Actions.pir
==============================================================================
--- trunk/compilers/nqp/src/Grammar/Actions.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/nqp/src/Grammar/Actions.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -40,9 +40,9 @@
     .param pmc match
     .local pmc past
     $P0 = match['statement_block']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     past.'blocktype'('declaration')
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -83,9 +83,9 @@
     $P1 = $P0[0]
     set_global '$?BLOCK', $P1
     $P2 = match['statement_list']
-    $P3 = $P2.'item'()
+    $P3 = $P2.'ast'()
     past.'push'($P3)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -108,11 +108,11 @@
   iter_loop:
     unless iter goto iter_end
     $P2 = shift iter
-    $P2 = $P2.'item'()
+    $P2 = $P2.'ast'()
     past.'push'($P2)
     goto iter_loop
   iter_end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -123,8 +123,8 @@
     .param pmc match
     .param string key
     $P0 = match[key]
-    $P1 = $P0.'item'()
-    match.'result_object'($P1)
+    $P1 = $P0.'ast'()
+    match.'!make'($P1)
 .end
 
 
@@ -163,7 +163,7 @@
     unless $I0 goto while
     block = match['else']
     block = block[0]
-    block = block.'item'()
+    block = block.'ast'()
     past.'push'( block )
 
   while:
@@ -180,15 +180,15 @@
   get_expr:
     expr = match['EXPR']
     expr = expr[cond]
-    expr = expr.'item'()
+    expr = expr.'ast'()
     ret
   get_block:
     block = match['block']
     block = block[cond]
-    block = block.'item'()
+    block = block.'ast'()
     ret
   end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -205,13 +205,13 @@
     .local pmc expr, block, past
     expr = match['EXPR']
     expr = expr
-    expr = expr.'item'()
+    expr = expr.'ast'()
     block = match['block']
     block = block
-    block = block.'item'()
+    block = block.'ast'()
     $P0 = get_hll_global ['PAST'], 'Op'
     past = $P0.'new'(expr, block, 'pasttype'=>'unless', 'node'=>match)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -225,14 +225,14 @@
 .sub 'repeat_statement' :method
     .param pmc match
     $P1 = match['EXPR']
-    $P1 = $P1.'item'()
+    $P1 = $P1.'ast'()
     $P2 = match['block']
-    $P2 = $P2.'item'()
+    $P2 = $P2.'ast'()
     $S0 = match['sym']
     $S0 = concat 'repeat_', $S0
     $P0 = get_hll_global ['PAST'], 'Op'
     $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
-    match.'result_object'($P5)
+    match.'!make'($P5)
 .end
 
 
@@ -246,13 +246,13 @@
 .sub 'while_statement' :method
     .param pmc match
     $P1 = match['EXPR']
-    $P1 = $P1.'item'()
+    $P1 = $P1.'ast'()
     $P2 = match['block']
-    $P2 = $P2.'item'()
+    $P2 = $P2.'ast'()
     $S0 = match['sym']
     $P0 = get_hll_global ['PAST'], 'Op'
     $P5 = $P0.'new'( $P1, $P2, 'pasttype'=>$S0, 'node'=>match)
-    match.'result_object'($P5)
+    match.'!make'($P5)
 .end
 
 
@@ -271,9 +271,9 @@
     .param pmc match
     .local pmc block, past
     $P0  = match['EXPR']
-    $P0  = $P0.'item'()
+    $P0  = $P0.'ast'()
     $P1  = match['block']
-    block = $P1.'item'()
+    block = $P1.'ast'()
     block.'blocktype'('immediate')
     .local pmc params, topic_var
     params = block[0]
@@ -285,7 +285,7 @@
     $P2  = get_hll_global ['PAST'], 'Op'
     $S1  = match['sym']
     past = $P2.'new'($P0, block, 'pasttype'=>$S1, 'node'=>match)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -297,11 +297,11 @@
 .sub 'return_statement' :method
     .param pmc match
     $P0 = match['EXPR']
-    $P0 = $P0.'item'()
+    $P0 = $P0.'ast'()
 
     $P1 = get_hll_global ['PAST'], 'Op'
     $P1 = $P1.'new'( $P0, 'pasttype'=>'return', 'node'=>match)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -309,7 +309,7 @@
 ##        make PAST::Op.new( PAST::Var.new( :name('$/'),
 ##                                          :scope('lexical') ),
 ##                           $($<EXPR>),
-##                           :name('result_object'),
+##                           :name('!make'),
 ##                           :pasttype('callmethod') );
 ##    }
 .sub 'make_statement' :method
@@ -317,10 +317,10 @@
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = $P0.'new'( 'name'=>'$/', 'scope'=>'lexical' )
     $P2 = match['EXPR']
-    $P3 = $P2.'item'()
+    $P3 = $P2.'ast'()
     $P4 = get_hll_global ['PAST'], 'Op'
-    $P5 = $P4.'new'($P1, $P3, 'name'=>'result_object', 'pasttype'=>'callmethod')
-    match.'result_object'($P5)
+    $P5 = $P4.'new'($P1, $P3, 'name'=>'!make', 'pasttype'=>'callmethod')
+    match.'!make'($P5)
 .end
 
 
@@ -341,7 +341,7 @@
     if key != 'quote' goto not_quote
     $P0 = match['quote']
     $P0 = $P0['string_literal']
-    inline = $P0.'item'()
+    inline = $P0.'ast'()
     goto make
   not_quote:
     if key != 'heredoc' goto not_heredoc
@@ -351,7 +351,7 @@
   make:
     $P1 = get_hll_global ['PAST'], 'Op'
     $P2 = $P1.'new'( 'inline'=>inline, 'pasttype'=>'inline', 'node'=>match)
-    match.'result_object'($P2)
+    match.'!make'($P2)
 .end
 
 
@@ -361,8 +361,8 @@
 .sub 'block' :method
     .param pmc match
     $P0 = match['statement_block']
-    $P0 = $P0.'item'()
-    match.'result_object'($P0)
+    $P0 = $P0.'ast'()
+    match.'!make'($P0)
 .end
 
 
@@ -389,7 +389,7 @@
     .param pmc match
     .local pmc past
     $P0 = match['block']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     $S0 = match['ident']
     past.'name'($S0)
     past.'node'(match)
@@ -412,13 +412,13 @@
     $P1 = shift iter
     .local pmc parameter
     $P2 = $P1['parameter']
-    parameter = $P2.'item'()
+    parameter = $P2.'ast'()
     $S0 = parameter.'name'()
     past.'symbol'($S0, 'scope'=>'lexical')
     params.'push'(parameter)
     goto param_loop
   param_end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -449,7 +449,7 @@
     .param pmc key
     .local pmc past, sigil
     past = match['param_var']
-    past = past.'item'()
+    past = past.'ast'()
     sigil = match['param_var';'sigil']
     if key != 'slurp' goto not_slurp
     if sigil != '@' goto not_slurpy_array
@@ -474,7 +474,7 @@
     if $S0 != '?' goto make_past
     past.'viviself'('Undef')
   make_past:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -488,7 +488,7 @@
     $S0 = match
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = $P0.'new'('name'=>$S0, 'scope'=>'parameter', 'node'=>match)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -508,7 +508,7 @@
     .param pmc key
     .local pmc past
     $P0 = match['noun']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     $P1 = match['postfix']
     if null $P1 goto end
     .local pmc iter, term
@@ -517,11 +517,11 @@
     unless iter goto end
     $P2 = shift iter
     term = past
-    past = $P2.'item'()
+    past = $P2.'ast'()
     past.'unshift'(term)
     goto iter_loop
   end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -532,8 +532,8 @@
     .param pmc match
     .param string key
     $P0 = match[key]
-    $P1 = $P0.'item'()
-    match.'result_object'($P1)
+    $P1 = $P0.'ast'()
+    match.'!make'($P1)
 .end
 
 
@@ -549,12 +549,12 @@
     .param string key
     .local pmc past
     $P0 = match['arglist']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     $S0 = match['ident']
     past.'name'($S0)
     past.'pasttype'('callmethod')
     past.'node'(match)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -598,26 +598,26 @@
   keyed_hash:
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = match['EXPR']
-    $P2 = $P1.'item'()
+    $P2 = $P1.'ast'()
     $P3 = $P0.'new'( $P2, 'scope'=>scope, 'vivibase'=>vivibase, 'viviself'=>'Undef', 'node'=>match )
-    match.'result_object'($P3)
+    match.'!make'($P3)
     .return ()
   subcall:
     $P0 = match['arglist']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     past.'pasttype'('call')
     past.'node'(match)
-    match.'result_object'(past)
+    match.'!make'(past)
     .return ()
   keyed_const:
     $P0 = get_hll_global ['PAST'], 'Val'
     $P1 = match['string_literal']
-    $P2 = $P1.'item'()
+    $P2 = $P1.'ast'()
     .local pmc value
     value = $P0.'new'( 'value' => $P2, 'node'=> $P1 )
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = $P0.'new'( value, 'scope'=>'keyed', 'vivibase'=>'Hash', 'viviself'=>'Undef', 'node'=>match)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -631,7 +631,7 @@
 ##    }
 ##    if $key eq '$( )' {
 ##        make PAST::Op.new( $expr,
-##                           :name('item'),
+##                           :name('ast'),
 ##                           :pasttype('callmethod'),
 ##                           :node($/) );
 ##    }
@@ -648,20 +648,20 @@
   have_expr:
     $P1 = $P0[0]
   get_past:
-    $P1 = $P1.'item'()
+    $P1 = $P1.'ast'()
     $P0 = get_hll_global ['PAST'], 'Op'
     if key == '@( )' goto list_context
     if key == '$( )' goto scalar_context
   parenthetical:
-    match.'result_object'($P1)
+    match.'!make'($P1)
     .return ()
   list_context:
     past = $P0.'new'($P1, 'name' => 'list',  'pasttype'=>'callmethod', 'node'=>match)
-    match.'result_object'(past)
+    match.'!make'(past)
     .return ()
   scalar_context:
-    past = $P0.'new'($P1, 'name' => 'item', 'pasttype'=>'callmethod', 'node'=>match)
-    match.'result_object'(past)
+    past = $P0.'new'($P1, 'name' => 'ast', 'pasttype'=>'callmethod', 'node'=>match)
+    match.'!make'(past)
 .end
 
 
@@ -697,7 +697,7 @@
     if null $P1 goto end
     .local pmc expr, iter
     $P2 = $P1[0]
-    expr = $P2.'item'()
+    expr = $P2.'ast'()
     $S0 = expr.'name'()
     if $S0 != 'infix:,' goto one_arg
   comma_arg:
@@ -713,7 +713,7 @@
     $P0 = 'callarg'(expr)
     past.'push'($P0)
   end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 .sub 'callarg'
@@ -736,8 +736,8 @@
     .param pmc match
     .param pmc key
     $P0 = match[key]
-    $P1 = $P0.'item'()
-    match.'result_object'($P1)
+    $P1 = $P0.'ast'()
+    match.'!make'($P1)
 .end
 
 
@@ -757,10 +757,10 @@
     $P9 = get_hll_global ['PAST'], 'Val'
     $P1 = $P9.'new'('value'=>$S0, 'node'=>$P0)
     $P2 = match['EXPR']
-    $P2 = $P2.'item'()
+    $P2 = $P2.'ast'()
     $P9 = get_hll_global ['PAST'], 'Op'
     $P3 = $P9.'new'($P1, $P2, 'name'=>'infix:=>', 'returns'=>'Pair', 'node'=>match)
-    match.'result_object'($P3)
+    match.'!make'($P3)
 .end
 
 
@@ -777,7 +777,7 @@
     .param pmc key
     .local pmc past
     $P0 = match[key]
-    past = $P0.'item'()
+    past = $P0.'ast'()
     $P1 = match['name']
     $P1 = $P1['ident']
     past.'namespace'($P1)
@@ -803,7 +803,7 @@
     $P2 = past[0]
     $P2.'push'($P1)
   class_done:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -823,7 +823,7 @@
     .local pmc past, block
     .local string name
     $P0 = match['variable']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     name = past.'name'()
     block = get_global '$?BLOCK'
     $P0 = block.'symbol'(name)
@@ -837,7 +837,7 @@
   have_scope:
     block.'symbol'(name, 'scope'=>scope)
   end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -864,7 +864,7 @@
     $S0 = match[0]
     $P3 = $P2.'new'('value'=>$S0)
     $P4 = $P0.'new'($P1, $P3, 'scope'=>'keyed', 'viviself'=>'Undef')
-    match.'result_object'($P4)
+    match.'!make'($P4)
     .return ()
   past_var:
     $S0 = match
@@ -880,7 +880,7 @@
   past_sigil:
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = $P0.'new'('node'=>match, 'name'=>$S0, 'viviself'=>$S2)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -891,8 +891,8 @@
     .param pmc match
     .param pmc key
     $P0 = match[key]
-    $P1 = $P0.'item'()
-    match.'result_object'($P1)
+    $P1 = $P0.'ast'()
+    match.'!make'($P1)
 .end
 
 
@@ -904,10 +904,10 @@
     .param pmc key             :optional
     .local string value
     $P0 = match['string_literal']
-    value = $P0.'item'()
+    value = $P0.'ast'()
     $P0 = get_hll_global ['PAST'], 'Val'
     $P1 = $P0.'new'('node'=>match, 'value'=>value)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -930,7 +930,7 @@
     name = pop ns
     $P0 = get_hll_global ['PAST'], 'Var'
     $P1 = $P0.'new'('node'=>match, 'scope'=>'package', 'name'=>name, 'namespace'=>ns)
-    match.'result_object'($P1)
+    match.'!make'($P1)
 .end
 
 
@@ -944,7 +944,7 @@
     $I0 = match
     $P0 = get_hll_global ['PAST'], 'Val'
     past = $P0.'new'('node'=>match, 'value'=>$I0)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -960,12 +960,12 @@
     .param pmc key             :optional
     .local pmc past
     $P0 = match['arglist']
-    past = $P0.'item'()
+    past = $P0.'ast'()
     $S0 = match['ident']
     past.'name'($S0)
     past.'pasttype'('call')
     past.'node'(match)
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 
@@ -988,8 +988,8 @@
     if key != 'end' goto expr_reduce
   expr_end:
     $P0 = match['expr']
-    $P1 = $P0.'item'()
-    match.'result_object'($P1)
+    $P1 = $P0.'ast'()
+    match.'!make'($P1)
     .return ()
   expr_reduce:
     .local pmc past, opattr
@@ -1008,11 +1008,11 @@
     $I0 = $P2.'from'()
     $I1 = $P2.'to'()
     if $I0 == $I1 goto iter_loop
-    $P2 = $P2.'item'()
+    $P2 = $P2.'ast'()
     past.'push'($P2)
     goto iter_loop
   iter_end:
-    match.'result_object'(past)
+    match.'!make'(past)
 .end
 
 # Local Variables:

Modified: trunk/compilers/nqp/t/24-scalar_context.t
==============================================================================
--- trunk/compilers/nqp/t/24-scalar_context.t	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/nqp/t/24-scalar_context.t	Tue Mar 31 01:24:46 2009	(r37824)
@@ -5,7 +5,7 @@
 plan(1);
 
 class XYZ {
-    method item() {
+    method ast() {
         'ok 1';
     }
 }

Modified: trunk/compilers/pct/src/PCT/Grammar.pir
==============================================================================
--- trunk/compilers/pct/src/PCT/Grammar.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pct/src/PCT/Grammar.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -80,9 +80,9 @@
 
 =cut
 
-.sub 'item' :method
+.sub 'ast' :method
     .local pmc obj
-    obj = getattribute self, '$!item'
+    obj = getattribute self, '$!ast'
     unless null obj goto end
     die "No result object"
   end:
@@ -223,7 +223,7 @@
 
   literal_end:
     mob.'to'(pos)
-    mob.'result_object'(literal)
+    mob.'!make'(literal)
     .return (mob)
 
   fail:

Modified: trunk/compilers/pge/PGE/Exp.pir
==============================================================================
--- trunk/compilers/pge/PGE/Exp.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pge/PGE/Exp.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -353,7 +353,7 @@
     args = self.'getargs'(label, next)
     .local string literal
     .local int litlen
-    literal = self
+    literal = self.'ast'()
     litlen = length literal
 
     args['I'] = ''
@@ -414,10 +414,10 @@
     $I0 = exp0['ignorecase']
     $I1 = exp1['ignorecase']
     if $I0 != $I1 goto concat_lit_shift
-    $S0 = exp0
-    $S1 = exp1
+    $S0 = exp0.'ast'()
+    $S1 = exp1.'ast'()
     concat $S0, $S1
-    exp0.'result_object'($S0)
+    exp0.'!make'($S0)
     goto concat_lit_loop
   concat_lit_shift:
     inc j
@@ -963,7 +963,7 @@
     .param pmc label
     .param pmc next
     .local string token, test
-    token = self
+    token = self.'ast'()
 
     if token == '^' goto anchor_bos
     if token == '$' goto anchor_eos
@@ -1071,7 +1071,7 @@
     .param pmc next
 
     .local string token
-    token = self
+    token = self.'ast'()
     self['negate'] = 1
     if token == '\D' goto digit
     if token == '\S' goto space
@@ -1106,7 +1106,7 @@
     .param string next
     .local int cclass, negate
 
-    $S0 = self
+    $S0 = self.'ast'()
     code.'emit'("        %0: # cclass %1", label, $S0)
     code.'emit'("          if pos >= lastpos goto fail")
     cclass = self['cclass']
@@ -1304,7 +1304,7 @@
     .param string next
 
     .local string charlist
-    $S0 = self
+    $S0 = self.'ast'()
     charlist = code.'escape'($S0)
 
     .local string test
@@ -1428,7 +1428,7 @@
     .param string label
     .param string next
     .local string value, lang
-    value = self
+    value = self.'ast'()
     lang = self['lang']
     value = code.'escape'(value)
     lang = code.'escape'(lang)
@@ -1455,12 +1455,12 @@
           mpos = pos
           ($P0 :optional, $I0 :opt_flag) = $P1(mob)
           if $I0 == 0 goto %0
-          mob.'result_object'($P0)
+          mob.'!make'($P0)
           push ustack, pos
           local_branch cstack, succeed
           pos = pop ustack
           null $P0
-          mob.'result_object'($P0)
+          mob.'!make'($P0)
           goto fail
         CODE
     .return ()

Modified: trunk/compilers/pge/PGE/Match.pir
==============================================================================
--- trunk/compilers/pge/PGE/Match.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pge/PGE/Match.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -15,7 +15,7 @@
     load_bytecode 'PGE/Dumper.pir'                 # FIXME, XXX, etc.
     .local pmc p6meta
     p6meta = new 'P6metaclass'
-    $P0 = p6meta.'new_class'('PGE::Match', 'parent'=>'Capture', 'attr'=>'$.target $.from $.pos &!corou $!item')
+    $P0 = p6meta.'new_class'('PGE::Match', 'parent'=>'Capture', 'attr'=>'$.target $.from $.pos &!corou $!ast')
     set_hll_global ['PGE'], '$!MATCH', $P0
     .return ()
 .end
@@ -212,13 +212,13 @@
 .end
 
 
-=item C<text()>
+=item C<Str()>
 
 Returns the portion of the target string matched by this object.
 
 =cut
 
-.sub 'text' :method
+.sub 'Str' :method
     $P0 = getattribute self, '$.target'
     $P1 = getattribute self, '$.from'
     $P2 = getattribute self, '$.pos'
@@ -233,6 +233,10 @@
     .return ('')
 .end
 
+.sub 'text' :method
+    .tailcall self.'Str'()
+.end
+
 
 =item C<item()>
 
@@ -243,29 +247,41 @@
 =cut
 
 .sub 'item' :method
-    .tailcall self.'result_object'()
+    .tailcall self.'ast'()
 .end
 
+.sub 'result_object' :method
+    .param pmc obj
+    .tailcall self.'!make'(obj)
+.end
 
-=item C<result_object([pmc obj])>
+=item C<!make(pmc obj)>
 
-Returns or sets the "result object" for the match object.
+Sets the "ast object" for the Match invocant.
 
 =cut
 
-.sub 'result_object' :method
-    .param pmc obj             :optional
-    .param int has_obj         :opt_flag
-    if has_obj == 0 goto get_obj
-    setattribute self, '$!item', obj
-    goto ret_obj
-  get_obj:
-    obj = getattribute self, '$!item'
-  ret_obj:
+.sub '!make' :method
+    .param pmc obj
+    setattribute self, '$!ast', obj
+    .return (obj)
+.end
+
+
+=item C<ast([pmc obj])>
+
+Returns the "ast object" for the match object.  If no ast object
+has been set, then it returns the string between C<.from> and C<.to>.
+
+=cut
+
+.sub 'ast' :method
+    .local pmc obj
+    obj = getattribute self, '$!ast'
     if null obj goto ret_null
     .return (obj)
   ret_null:
-    .tailcall self.'text'()
+    .tailcall self.'Str'()
 .end
 
 
@@ -314,7 +330,7 @@
     null $P0
     setattribute self, '$.target', $P0
     setattribute self, '&!corou', $P0
-    setattribute self, '$!item', $P0
+    setattribute self, '$!ast', $P0
     setref self, $P0
     .return ()
 .end
@@ -340,8 +356,8 @@
 
 =cut
 
-.sub 'get_integer' :vtable :method
-    $I0 = self.'result_object'()
+.sub '' :vtable('get_integer') :method
+    $I0 = self.'Str'()
     .return ($I0)
 .end
 
@@ -351,8 +367,8 @@
 
 =cut
 
-.sub 'get_number' :vtable :method
-    $N0 = self.'result_object'()
+.sub '' :vtable('get_number') :method
+    $N0 = self.'Str'()
     .return ($N0)
 .end
 
@@ -362,8 +378,8 @@
 
 =cut
 
-.sub 'get_string' :vtable :method
-    $S0 = self.'result_object'()
+.sub '' :vtable('get_string') :method
+    $S0 = self.'Str'()
     .return ($S0)
 .end
 

Modified: trunk/compilers/pge/PGE/OPTable.pir
==============================================================================
--- trunk/compilers/pge/PGE/OPTable.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pge/PGE/OPTable.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -526,7 +526,7 @@
     unless rulename goto reduce_saveterm_1
     ($P0 :optional, $I0 :opt_flag) = action.rulename($P1, 'reduce')
     unless $I0 goto reduce_saveterm_1
-    $P1.'result_object'($P0)
+    $P1.'!make'($P0)
   reduce_saveterm_1:
     push termstack, $P1
   reduce_end:
@@ -608,7 +608,7 @@
     unless rulename goto end_all
     ($P0 :optional, $I0 :opt_flag) = action.rulename(mob, 'end')
     unless $I0 goto end_all
-    mob.'result_object'($P0)
+    mob.'!make'($P0)
   end_all:
     .return (mob)
 

Modified: trunk/compilers/pge/PGE/P5Regex.pir
==============================================================================
--- trunk/compilers/pge/PGE/P5Regex.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pge/PGE/P5Regex.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -200,7 +200,7 @@
     $I0 = pos - litstart
     $S0 = substr target, litstart, $I0
     $S0 = concat initchar, $S0
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
     goto end
   end:
     mob.'to'(pos)
@@ -344,7 +344,7 @@
     mob["isnegated"] = 1
   end:
     mob.'to'(pos)
-    mob.'result_object'(charlist)
+    mob.'!make'(charlist)
     .return (mob)
 
   err_close:

Modified: trunk/compilers/pge/PGE/Perl6Regex.pir
==============================================================================
--- trunk/compilers/pge/PGE/Perl6Regex.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/compilers/pge/PGE/Perl6Regex.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -333,7 +333,7 @@
     $S0 = substr target, pos, litlen
     pos += litlen
     mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
     mob.'to'(pos)
     .return (mob)
 
@@ -376,7 +376,7 @@
   quoted_metachar:
     inc pos
     mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
-    mob.'result_object'(initchar)
+    mob.'!make'(initchar)
     mob.'to'(pos)
     .return (mob)
 
@@ -401,13 +401,13 @@
 
   term_literal:
     mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
-    mob.'result_object'(charlist)
+    mob.'!make'(charlist)
     mob.'to'(pos)
     .return (mob)
 
   term_charlist:
     mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::EnumCharList')
-    mob.'result_object'(charlist)
+    mob.'!make'(charlist)
     mob['isnegated'] = isnegated
     mob.'to'(pos)
     .return (mob)
@@ -921,7 +921,7 @@
     ##   create a node for the charlist
     term = mob.'new'(mob, 'grammar'=>'PGE::Exp::EnumCharList')
     term.'to'(pos)
-    term.'result_object'(charlist)
+    term.'!make'(charlist)
     goto combine
 
   subrule:
@@ -948,7 +948,7 @@
     ##   token is '<-', we need to match a char by concat dot
     $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
     $P0.'to'(pos)
-    $P0.'result_object'('.')
+    $P0.'!make'('.')
     mob = mob.'new'(mob, 'grammar'=>'PGE::Exp::Concat')
     mob.'to'(pos)
     mob[0] = term
@@ -1032,7 +1032,7 @@
     goto literal_iter
   literal_end:
     inc pos
-    mob.'result_object'(lit)
+    mob.'!make'(lit)
     mob.'to'(pos)
     .return (mob)
   literal_error:
@@ -1118,14 +1118,14 @@
     if $I1 == 0 goto fail
     $S0 = substr target, $I0, $I1
     mob['key'] = $S0
-    mob.'result_object'(value)
+    mob.'!make'(value)
     $S0 = substr target, pos, 1
     if $S0 != '(' goto end
     $I0 = pos + 1
     pos = index target, ')', pos
     $I1 = pos - $I0
     $S0 = substr target, $I0, $I1
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
     inc pos
   end:
     ### XXX pos = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
@@ -1167,7 +1167,7 @@
     if $I0 < pos goto err_noclose
     $I1 = $I0 - pos
     $S1 = substr target, pos, $I1
-    mob.'result_object'($S1)
+    mob.'!make'($S1)
     pos = $I0 + len
     mob.'to'(pos)
     .return (mob)
@@ -1584,7 +1584,7 @@
     .local string key
     .local string value
     key = self['key']
-    value = self
+    value = self.'ast'()
     if key == 'words' goto sigspace
     if key == 's' goto sigspace
     if key == 'w' goto sigspace
@@ -1634,9 +1634,9 @@
     $I0 = defined closure_pp[lang]
     if $I0 == 0 goto end
     closure_fn = closure_pp[lang]
-    $S1 = self
+    $S1 = self.'ast'()
     $S1 = closure_fn($S1)
-    self.'result_object'($S1)
+    self.'!make'($S1)
   end:
     .return (self)
 .end
@@ -1683,7 +1683,7 @@
 
 .sub 'perl6exp' :method
     .param pmc pad
-    $S0 = self
+    $S0 = self.'ast'()
     if $S0 == ':::' goto cut_rule
     if $S0 == '<commit>' goto cut_match
     self['cutmark'] = PGE_CUT_GROUP

Modified: trunk/runtime/parrot/library/PGE/Glob.pir
==============================================================================
--- trunk/runtime/parrot/library/PGE/Glob.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/runtime/parrot/library/PGE/Glob.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -55,7 +55,7 @@
     exp = new ['PGE';'Exp';'Concat']
     $I0 = 1
     $P0 = new ['PGE';'Exp';'Anchor']
-    $P0.'result_object'('^')
+    $P0.'!make'('^')
     exp[0] = $P0
     if null match goto analyze_1
     $P0 = match['expr']
@@ -63,7 +63,7 @@
     inc $I0
   analyze_1:
     $P0 = new ['PGE';'Exp';'Anchor']
-    $P0.'result_object'('$')
+    $P0.'!make'('$')
     exp[$I0] = $P0
 
     .tailcall exp.'compile'(adverbs :flat :named)
@@ -165,7 +165,7 @@
 =item C<glob_literal(PMC mob, PMC adverbs)>
 
 Scan a literal from a string, stopping at any metacharacters such
-as C<*> or C<[>.  Return the matched portion, with the C<result_object>
+as C<*> or C<[>.  Return the matched portion, with the I<ast object>
 set to the decoded literal.
 
 =cut
@@ -180,7 +180,7 @@
     ($S0, $I0) = 'scan_literal'(target, pos, '*?[{')
     if $I0 <= pos goto end
     mob.'to'($I0)
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
   end:
     .return (mob)
 .end
@@ -199,7 +199,7 @@
     ##   The '?' is already in mob['KEY'], so we don't need to find it here.
     (mob, $I0) = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
     mob.'to'($I0)
-    mob.'result_object'('.')
+    mob.'!make'('.')
     .return (mob)
 .end
 
@@ -223,7 +223,7 @@
     mob['max'] = GLOB_INF
     $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
     $P0.'to'(pos)
-    $P0.'result_object'('.')
+    $P0.'!make'('.')
     mob[0] = $P0
     .return (mob)
 .end
@@ -285,7 +285,7 @@
   scan_end:
     inc pos
     mob.'to'(pos)
-    mob.'result_object'(charlist)
+    mob.'!make'(charlist)
     .return (mob)
 
   err_noclose:
@@ -311,7 +311,7 @@
 
     ($S0, pos) = 'scan_literal'(target, pos, ',}')
     mob.'to'(pos)
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
   alt_loop:
     if pos >= lastpos goto err_noclose
     $S0 = substr target, pos, 1
@@ -324,7 +324,7 @@
     $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
     ($S0, pos) = 'scan_literal'(target, pos, ',}')
     mob.'to'(pos)
-    $P0.'result_object'($S0)
+    $P0.'!make'($S0)
     mob[1] = $P0
     goto alt_loop
   end:

Modified: trunk/runtime/parrot/library/Tcl/Glob.pir
==============================================================================
--- trunk/runtime/parrot/library/Tcl/Glob.pir	Tue Mar 31 01:11:41 2009	(r37823)
+++ trunk/runtime/parrot/library/Tcl/Glob.pir	Tue Mar 31 01:24:46 2009	(r37824)
@@ -55,7 +55,7 @@
     exp = new ['PGE';'Exp';'Concat']
     $I0 = 1
     $P0 = new ['PGE';'Exp';'Anchor']
-    $P0.'result_object'('^')
+    $P0.'!make'('^')
     exp[0] = $P0
     if null match goto analyze_1
     $P0 = match['expr']
@@ -63,7 +63,7 @@
     inc $I0
   analyze_1:
     $P0 = new ['PGE';'Exp';'Anchor']
-    $P0.'result_object'('$')
+    $P0.'!make'('$')
     exp[$I0] = $P0
 
     .tailcall exp.'compile'(adverbs :flat :named)
@@ -162,7 +162,7 @@
 =item C<glob_literal(PMC mob, PMC adverbs)>
 
 Scan a literal from a string, stopping at any metacharacters such
-as C<*> or C<[>.  Return the matched portion, with the C<result_object>
+as C<*> or C<[>.  Return the matched portion, with the I<ast object>
 set to the decoded literal.
 
 =cut
@@ -177,7 +177,7 @@
     ($S0, $I0) = 'scan_literal'(target, pos, '*?[')
     if $I0 <= pos goto end
     mob.'to'($I0)
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
   end:
     .return (mob)
 .end
@@ -197,7 +197,7 @@
     ##   The '?' is already in mob['KEY'], so we don't need to find it here.
     (mob, pos) = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
     mob.'to'(pos)
-    mob.'result_object'('.')
+    mob.'!make'('.')
     .return (mob)
 .end
 
@@ -221,7 +221,7 @@
     mob['max'] = GLOB_INF
     ($P0, $I0) = mob.'new'(mob, 'grammar'=>'PGE::Exp::CCShortcut')
     $P0.'to'($I0)
-    $P0.'result_object'('.')
+    $P0.'!make'('.')
     mob[0] = $P0
     .return (mob)
 .end
@@ -277,7 +277,7 @@
   scan_end:
     inc pos
     mob.'to'(pos)
-    mob.'result_object'(charlist)
+    mob.'!make'(charlist)
     .return (mob)
 
   err_noclose:
@@ -302,7 +302,7 @@
     lastpos = length target
 
     ($S0, pos) = 'scan_literal'(target, pos, ',}')
-    mob.'result_object'($S0)
+    mob.'!make'($S0)
     mob.'to'(pos)
   alt_loop:
     if pos >= lastpos goto err_noclose
@@ -316,7 +316,7 @@
     $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::Literal')
     ($S0, pos) = 'scan_literal'(target, pos, ',}')
     $P0.'to'(pos)
-    $P0.'result_object'($S0)
+    $P0.'!make'($S0)
     mob[1] = $P0
     goto alt_loop
   end:


More information about the parrot-commits mailing list