I have somewhat a predicament. I want to create a continuation, and
have that continuation stored in the register stack that it closes over
(this is how I'm implementing a loop with continuations). Unless I'm
having a major braino, I don't think this is possible at the moment.
I got around this by adding two ops: new_noinit and init. I've included
a patch that implements them. Other solutions welcome.
Luke
Index: ops/pmc.ops
===================================================================
RCS file: /cvs/public/parrot/ops/pmc.ops,v
retrieving revision 1.16
diff -u -r1.16 pmc.ops
--- ops/pmc.ops 31 Dec 2003 11:54:38 -0000 1.16
+++ ops/pmc.ops 12 Jan 2004 19:54:45 -0000
@@ -52,6 +52,15 @@
Like above. The forth argument is a property hash - it isn't copied in,
only referended. The initializer may be NULL.
+=item B<new_noinit>(out PMC, in INT)
+
+Just like above, but doesn't initialize the PMC. You must call B<init>
+on it before using it.
+
+=item B<init>(in PMC)
+
+Initializes a PMC created with new_noinit.
+
=cut
op new(out PMC, in INT) {
@@ -60,9 +69,6 @@
abort(); /* Deserve to lose */
}
- /* Why?? If we're creating a continuation, the continuation PMC
- * needs to be in the destination register before its init method
- * copies the registers. */
$1 = pmc_new_noinit(interpreter, $2);
$1->vtable->init(interpreter, $1);
goto NEXT();
@@ -84,6 +90,19 @@
$1->vtable->init_pmc_props(interpreter, $1, $3, $4);
goto NEXT();
}
+# }
+
+op new_noinit(out PMC, in INT) {
+ if ($2 <= 0 || $2 >= enum_class_max) {
+ internal_exception(1, "Illegal PMC enum (%d) in new\n", (int)$2);
+ }
+ $1 = pmc_new_noinit(interpreter, $2);
+ goto NEXT();
+}
+
+op init(in PMC) {
+ $1->vtable->init(interpreter, $1);
+ goto NEXT();
}
########################################