Author: fperrad Date: Thu Mar 27 02:05:30 2008 New Revision: 26575 Modified: trunk/compilers/pct/src/PCT/Node.pir
Log: [pct] add method 'clone' (needed by Lua) Modified: trunk/compilers/pct/src/PCT/Node.pir ============================================================================== --- trunk/compilers/pct/src/PCT/Node.pir (original) +++ trunk/compilers/pct/src/PCT/Node.pir Thu Mar 27 02:05:30 2008 @@ -102,6 +102,37 @@ .end +=item clone + +Create and returns a clone of a PAST node. + +=cut + +.sub 'clone' :vtable :method + .local pmc res + $S0 = typeof self + res = new $S0 + .local pmc iter + iter = self.'iterator'() + iter_child_loop: + unless iter goto iter_child_end + $P0 = shift iter + $P1 = clone $P0 + res.'push'($P1) + goto iter_child_loop + iter_child_end: + iter = new 'Iterator', self + iter_attr_loop: + unless iter goto iter_attr_end + $S0 = shift iter + $P0 = iter[$S0] + res[$S0] = $P0 + goto iter_attr_loop + iter_attr_end: + .return (res) +.end + + =item unshift(child) Add C<child> to the beginning of the invocant's list of children.
