Here's that op that replaces the header of one PMC with another's, if
people are interested.
Luke
Index: ops/ops.num
===================================================================
RCS file: /cvs/public/parrot/ops/ops.num,v
retrieving revision 1.15
diff -u -r1.15 ops.num
--- ops/ops.num 10 Dec 2003 11:44:07 -0000 1.15
+++ ops/ops.num 24 Dec 2003 20:09:54 -0000
@@ -1341,4 +1341,4 @@
ne_addr_sc_sc_ic 1314
ne_addr_p_p_ic 1315
isnull_p_ic 1316
-
+supplant_p_p 1317
Index: ops/set.ops
===================================================================
RCS file: /cvs/public/parrot/ops/set.ops,v
retrieving revision 1.9
diff -u -r1.9 set.ops
--- ops/set.ops 19 Dec 2003 10:01:40 -0000 1.9
+++ ops/set.ops 24 Dec 2003 20:09:54 -0000
@@ -80,6 +80,20 @@
########################################
+=item B<supplant>(in PMC, in PMC)
+
+Replace $1's header with $2's. Essentially makes all references to $1 now
+point to $2.
+
+=cut
+
+inline op supplant(in PMC, in PMC) {
+ *$1 = *$2;
+ goto NEXT();
+}
+
+########################################
+
=item B<set>(out INT, in INT)
=item B<set>(out INT, in NUM)
Index: t/op/hacks.t
===================================================================
RCS file: /cvs/public/parrot/t/op/hacks.t,v
retrieving revision 1.17
diff -u -r1.17 hacks.t
--- t/op/hacks.t 23 Dec 2003 09:57:40 -0000 1.17
+++ t/op/hacks.t 24 Dec 2003 20:09:55 -0000
@@ -1,6 +1,6 @@
#! perl -w
-use Parrot::Test tests => 2;
+use Parrot::Test tests => 3;
use Test::More;
use Parrot::Config;
use Config;
@@ -60,5 +60,27 @@
ok
OUT
}
+
+output_is(<<'CODE', <<OUT, "supplant op");
+ new P0, .PerlString
+ set P0, "Hello!\n"
+ set P1, P0
+
+ print P0
+ print P1
+
+ new P2, .PerlString
+ set P2, "Usurped!\n"
+ supplant P0, P2
+
+ print P0
+ print P1
+ end
+CODE
+Hello!
+Hello!
+Usurped!
+Usurped!
+OUT
1; # HONK