Author: pmichaud
Date: Sat May 10 14:11:45 2008
New Revision: 27421
Modified:
branches/pgeupdates/compilers/pct/src/PCT/Grammar.pir
branches/pgeupdates/compilers/pge/PGE/Match.pir
branches/pgeupdates/runtime/parrot/library/PGE/Dumper.pir
branches/pgeupdates/runtime/parrot/library/PGE/Hs.pir
branches/pgeupdates/runtime/parrot/library/Parrot/Capture_PIR.pir
Log:
[pge]:
* More updates.
* Have PGE::Match use Capture_PIR as a base class (DRY).
Modified: branches/pgeupdates/compilers/pct/src/PCT/Grammar.pir
==============================================================================
--- branches/pgeupdates/compilers/pct/src/PCT/Grammar.pir (original)
+++ branches/pgeupdates/compilers/pct/src/PCT/Grammar.pir Sat May 10
14:11:45 2008
@@ -56,7 +56,7 @@
.sub 'item' :method
.local pmc obj
- obj = getattribute self, '$!result'
+ obj = getattribute self, '$!item'
unless null obj goto end
die "No result object"
end:
Modified: branches/pgeupdates/compilers/pge/PGE/Match.pir
==============================================================================
--- branches/pgeupdates/compilers/pge/PGE/Match.pir (original)
+++ branches/pgeupdates/compilers/pge/PGE/Match.pir Sat May 10 14:11:45 2008
@@ -12,11 +12,12 @@
.sub '__onload' :load
load_bytecode 'Protoobject.pbc'
+ load_bytecode 'Parrot/Capture_PIR.pbc'
load_bytecode 'PGE/Dumper.pir' # FIXME, XXX, etc.
.local pmc protomaker, hashclass, base
protomaker = new 'Protomaker'
- hashclass = get_class 'Hash'
- base = protomaker.'new_subclass'(hashclass, 'PGE::Match', '$.target',
'$.from', '$.pos', '&!corou', '@!capt', '$!result')
+ hashclass = get_class 'Capture_PIR'
+ base = protomaker.'new_subclass'(hashclass, 'PGE::Match', '$.target',
'$.from', '$.pos', '&!corou')
.return ()
.end
@@ -231,10 +232,10 @@
.param pmc obj :optional
.param int has_obj :opt_flag
if has_obj == 0 goto get_obj
- setattribute self, '$!result', obj
+ setattribute self, '$!item', obj
goto ret_obj
get_obj:
- obj = getattribute self, '$!result'
+ obj = getattribute self, '$!item'
ret_obj:
if null obj goto ret_null
.return (obj)
@@ -288,8 +289,8 @@
null $P0
setattribute self, '$.target', $P0
setattribute self, '&!corou', $P0
- setattribute self, '@!capt', $P0
- setattribute self, '$!result', $P0
+ setattribute self, '@!list', $P0
+ setattribute self, '$!item', $P0
.local pmc iter
iter = new 'Iterator', self
iter_loop:
@@ -349,107 +350,6 @@
.return ($S0)
.end
-=item C<__get_string_keyed_int(int key)>
-
-Returns the portion of the target string matched by C<key>,
-in string context. If the Match object contains an array of
-matches, a space seperated list of matches is returned.
-
-=cut
-
-.sub 'get_string_keyed_int' :vtable :method
- .param int key
- $P0 = getattribute self, '@!capt'
- $S0 = ''
- if_null $P0, get_1
- $P0 = $P0[key]
- $S0 = $P0
- get_1:
- .return ($S0)
-.end
-
-=item C<__get_pmc_keyed_int(int key)>
-
-Returns the subpattern capture associated with C<key>. This
-returns either a single Match object or an array of match
-objects depending on the rule.
-
-=cut
-
-.sub 'get_pmc_keyed_int' :vtable :method
- .param int key
- $P0 = getattribute self, '@!capt'
- if_null $P0, get_1
- $P0 = $P0[key]
- get_1:
- .return ($P0)
-.end
-
-.sub 'set_pmc_keyed_int' :vtable :method
- .param int key
- .param pmc val
- .local pmc capt
- capt = getattribute self, '@!capt'
- unless_null capt, set_1
- capt = new 'ResizablePMCArray'
- setattribute self, '@!capt', capt
- set_1:
- capt[key] = val
-.end
-
-.sub 'delete_keyed_int' :vtable :method
- .param int key
- .local pmc capt
- capt = getattribute self, '@!capt'
- delete capt[key]
-.end
-
-.sub 'defined_keyed_int' :vtable :method
- .param int key
- .local pmc capt
- $I0 = 0
- capt = getattribute self, '@!capt'
- if_null capt, end
- $I0 = defined capt[key]
- end:
- .return ($I0)
-.end
-
-.sub 'push_pmc' :vtable :method
- .param pmc val
- .local pmc capt
- capt = getattribute self, '@!capt'
- unless null capt goto push_1
- capt = new 'ResizablePMCArray'
- setattribute self, '@!capt', capt
- push_1:
- push capt, val
- .return ()
-.end
-
-
-=item C<hash()>
-
-Returns the hash component of the match object.
-
-=cut
-
-.sub 'hash' :method
- .return (self)
-.end
-
-=item C<list()>
-
-Returns the array component of the match object.
-
-=cut
-
-.sub 'list' :method
- .local pmc array
- array = getattribute self, '@!capt'
- .return (array)
-.end
-
=back
=head1 AUTHOR
Modified: branches/pgeupdates/runtime/parrot/library/PGE/Dumper.pir
==============================================================================
--- branches/pgeupdates/runtime/parrot/library/PGE/Dumper.pir (original)
+++ branches/pgeupdates/runtime/parrot/library/PGE/Dumper.pir Sat May 10
14:11:45 2008
@@ -123,7 +123,7 @@
$S0 = $I0
out .= $S0
out .= "\n"
- capt = getattribute self, '@!capt'
+ capt = self.'list'()
if_null capt, subrules
spi = 0
spc = elements capt
Modified: branches/pgeupdates/runtime/parrot/library/PGE/Hs.pir
==============================================================================
--- branches/pgeupdates/runtime/parrot/library/PGE/Hs.pir (original)
+++ branches/pgeupdates/runtime/parrot/library/PGE/Hs.pir Sat May 10
14:11:45 2008
@@ -51,8 +51,8 @@
.namespace [ "PGE::Hs" ]
.const string PGE_FAIL = "PGE_Fail"
-.const string PGE_SUB_POS = "@!capt"
-.const string PGE_SUB_NAMED = "%!capt"
+.const string PGE_SUB_POS = "@!list"
+.const string PGE_SUB_NAMED = "%!hash"
.sub "__onload" :load
.local pmc load
Modified: branches/pgeupdates/runtime/parrot/library/Parrot/Capture_PIR.pir
==============================================================================
--- branches/pgeupdates/runtime/parrot/library/Parrot/Capture_PIR.pir
(original)
+++ branches/pgeupdates/runtime/parrot/library/Parrot/Capture_PIR.pir Sat May
10 14:11:45 2008
@@ -17,15 +17,16 @@
.sub '__onload' :load :init
$P0 = subclass 'Hash', 'Capture_PIR'
- addattribute $P0, '@!array'
+ addattribute $P0, '$!item'
+ addattribute $P0, '@!list'
.end
.sub 'list' :method
- $P0 = getattribute self, '@!array'
+ $P0 = getattribute self, '@!list'
unless null $P0 goto end
$P0 = new 'ResizablePMCArray'
- setattribute self, '@!array', $P0
+ setattribute self, '@!list', $P0
end:
.return ($P0)
.end
@@ -65,11 +66,18 @@
.return ($P0)
.end
+=item C<get_string_keyed_int(int key)>
+
+Returns the portion of the target string matched by C<key>,
+in string context. If the Match object contains an array of
+matches, a space seperated list of matches is returned.
+
+=cut
.sub 'get_string_keyed_int' :vtable :method
.param int key
$S0 = ''
- $P0 = getattribute self, '@!array'
+ $P0 = getattribute self, '@!list'
if null $P0 goto end
$S0 = $P0[key]
end:
@@ -77,9 +85,17 @@
.end
+=item C<get_pmc_keyed_int(int key)>
+
+Returns the subpattern capture associated with C<key>. This
+returns either a single Match object or an array of match
+objects depending on the rule.
+
+=cut
+
.sub 'get_pmc_keyed_int' :vtable :method
.param int key
- $P0 = getattribute self, '@!array'
+ $P0 = getattribute self, '@!list'
if null $P0 goto end
$P0 = $P0[key]
end:
@@ -96,6 +112,26 @@
.end
+.sub 'delete_keyed_int' :vtable :method
+ .param int key
+ .local pmc list
+ list = getattribute self, '@!list'
+ delete list[key]
+.end
+
+
+.sub 'defined_keyed_int' :vtable :method
+ .param int key
+ .local pmc list
+ $I0 = 0
+ list = getattribute self, '@!list'
+ if null list goto end
+ $I0 = defined list[key]
+ end:
+ .return ($I0)
+.end
+
+
.sub '__dump' :method
.param pmc dumper
.param string label