[svn:parrot] r40611 - branches/pcc_arg_unify/src

allison at svn.parrot.org allison at svn.parrot.org
Tue Aug 18 00:13:40 UTC 2009


Author: allison
Date: Tue Aug 18 00:13:40 2009
New Revision: 40611
URL: https://trac.parrot.org/parrot/changeset/40611

Log:
[pcc] Convert an impossibly horrible assert to a condition. This means
it can't be turned off with a compile-time switch, but this check
shouldn't ever be turned off.

Modified:
   branches/pcc_arg_unify/src/hash.c

Modified: branches/pcc_arg_unify/src/hash.c
==============================================================================
--- branches/pcc_arg_unify/src/hash.c	Tue Aug 18 00:03:59 2009	(r40610)
+++ branches/pcc_arg_unify/src/hash.c	Tue Aug 18 00:13:40 2009	(r40611)
@@ -1282,18 +1282,19 @@
     const UINTVAL hashval = (hash->hash_val)(interp, key, hash->seed);
     HashBucket   *bucket  = hash->bi[hashval & hash->mask];
 
-    /* Very complex assert that we'll not put non-constant stuff into constant hash */
-    PARROT_ASSERT(
-        PMC_IS_NULL(hash->container)
-        || !(PObj_constant_TEST(hash->container))
-        || (
-            (
-                !(hash->key_type == Hash_key_type_STRING)
-                || PObj_constant_TEST((PObj *)key))
-            && (
-                !((hash->entry_type == enum_type_PMC) || (hash->entry_type == enum_type_STRING))
-                || PObj_constant_TEST((PObj *)value)))
-        || !"Use non-constant key or value in constant hash");
+    /* When the hash is constant, check that the key and value are also
+     * constant. */
+    if (!PMC_IS_NULL(hash->container)
+            && PObj_constant_TEST(hash->container)) {
+        if (hash->key_type == Hash_key_type_STRING
+                && !PObj_constant_TEST((PObj *)key))
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Used non-constant key in constant hash.");
+        if (((hash->entry_type == enum_type_PMC) || (hash->entry_type == enum_type_STRING))
+                && !PObj_constant_TEST((PObj *)value))
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Used non-constant value in constant hash.");
+    }
 
     while (bucket) {
         /* store hash_val or not */


More information about the parrot-commits mailing list