[svn:parrot] r44943 - branches/pcc_hackathon_6Mar10/src/call

bacek at svn.parrot.org bacek at svn.parrot.org
Mon Mar 15 19:45:24 UTC 2010


Author: bacek
Date: Mon Mar 15 19:45:22 2010
New Revision: 44943
URL: https://trac.parrot.org/parrot/changeset/44943

Log:
Add assertions in Parrot_pcc_get_foo_constant to prevent access to wrong constant and catch it early.

Modified:
   branches/pcc_hackathon_6Mar10/src/call/context_accessors.c

Modified: branches/pcc_hackathon_6Mar10/src/call/context_accessors.c
==============================================================================
--- branches/pcc_hackathon_6Mar10/src/call/context_accessors.c	Mon Mar 15 18:53:42 2010	(r44942)
+++ branches/pcc_hackathon_6Mar10/src/call/context_accessors.c	Mon Mar 15 19:45:22 2010	(r44943)
@@ -746,6 +746,7 @@
 {
     ASSERT_ARGS(Parrot_pcc_get_int_constant_func)
     Parrot_Context const * c = get_context_struct_fast(interp, ctx);
+    PARROT_ASSERT(c->constants[idx]->type == 'i');
     return c->constants[idx]->u.integer;
 }
 
@@ -756,6 +757,7 @@
 {
     ASSERT_ARGS(Parrot_pcc_get_num_constant_func)
     Parrot_Context const * c = get_context_struct_fast(interp, ctx);
+    PARROT_ASSERT(c->constants[idx]->type == 'n');
     return c->constants[idx]->u.number;
 }
 
@@ -766,6 +768,7 @@
 {
     ASSERT_ARGS(Parrot_pcc_get_string_constant_func)
     Parrot_Context const * c = get_context_struct_fast(interp, ctx);
+    PARROT_ASSERT(c->constants[idx]->type == 's');
     return c->constants[idx]->u.string;
 }
 
@@ -776,6 +779,8 @@
 {
     ASSERT_ARGS(Parrot_pcc_get_pmc_constant_func)
     Parrot_Context const * c = get_context_struct_fast(interp, ctx);
+    PARROT_ASSERT((c->constants[idx]->type == 'k')
+            || (c->constants[idx]->type == 'p'));
     return c->constants[idx]->u.key;
 }
 


More information about the parrot-commits mailing list