[svn:parrot] r43952 - branches/op_pmcs/src/pmc

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Sun Feb 14 14:40:35 UTC 2010


Author: whiteknight
Date: Sun Feb 14 14:40:34 2010
New Revision: 43952
URL: https://trac.parrot.org/parrot/changeset/43952

Log:
opcode can only be initialized once

Modified:
   branches/op_pmcs/src/pmc/opcode.pmc

Modified: branches/op_pmcs/src/pmc/opcode.pmc
==============================================================================
--- branches/op_pmcs/src/pmc/opcode.pmc	Sun Feb 14 14:38:04 2010	(r43951)
+++ branches/op_pmcs/src/pmc/opcode.pmc	Sun Feb 14 14:40:34 2010	(r43952)
@@ -7,7 +7,7 @@
 
     VTABLE void init() {
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
-                "Opcode must be created from OpLib.");
+            "Opcode must be created from OpLib.");
     }
 
     VTABLE void mark() {
@@ -18,8 +18,9 @@
 
     VTABLE void set_pointer(void *i) {
         Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
-        /* TODO: This should only be called once, from inside OpLib. If
-                 attrs->info already has a non-NULL value, throw an exception */
+        if (attrs->info)
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Opcode has already been initialized");
         attrs->info = (op_info_t *)i;
     }
 
@@ -43,8 +44,9 @@
     VTABLE void set_integer_native(INTVAL value) {
         const INTVAL opcount = INTERP->op_lib->op_count;
         Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
-        /* TODO: This should only be called once, from inside OpLib. If
-                 attrs->info already has a non-NULL value, throw an exception */
+        if (attrs->info)
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Opcode has already been initialized");
         if (value >= opcount || value < 0)
             Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
                 "Opcode: Opcode index %d out of bounds", value);


More information about the parrot-commits mailing list