[svn:parrot] r46199 - in trunk: include/parrot src/interp

NotFound at svn.parrot.org NotFound at svn.parrot.org
Fri Apr 30 17:32:39 UTC 2010


Author: NotFound
Date: Fri Apr 30 17:32:38 2010
New Revision: 46199
URL: https://trac.parrot.org/parrot/changeset/46199

Log:
Don't return NULL in interpinfo_p, TT #1602, Coke++

Modified:
   trunk/include/parrot/interpreter.h
   trunk/src/interp/inter_misc.c

Modified: trunk/include/parrot/interpreter.h
==============================================================================
--- trunk/include/parrot/interpreter.h	Fri Apr 30 13:36:57 2010	(r46198)
+++ trunk/include/parrot/interpreter.h	Fri Apr 30 17:32:38 2010	(r46199)
@@ -465,7 +465,7 @@
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
+PARROT_CANNOT_RETURN_NULL
 PMC* interpinfo_p(PARROT_INTERP, INTVAL what)
         __attribute__nonnull__(1);
 

Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c	Fri Apr 30 13:36:57 2010	(r46198)
+++ trunk/src/interp/inter_misc.c	Fri Apr 30 17:32:38 2010	(r46199)
@@ -266,27 +266,33 @@
 
 PARROT_EXPORT
 PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
+PARROT_CANNOT_RETURN_NULL
 PMC*
 interpinfo_p(PARROT_INTERP, INTVAL what)
 {
     ASSERT_ARGS(interpinfo_p)
+
+    PMC *result;
     switch (what) {
       case CURRENT_SUB:
-        return Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
+        result = Parrot_pcc_get_sub(interp, CURRENT_CONTEXT(interp));
+        break;
       case CURRENT_CONT:
-        {
-            PMC * const cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
-            return cont;
-        }
+        result = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
+        break;
       case CURRENT_OBJECT:
-        return Parrot_pcc_get_object(interp, CURRENT_CONTEXT(interp));
+        result = Parrot_pcc_get_object(interp, CURRENT_CONTEXT(interp));
+        break;
       case CURRENT_LEXPAD:
-        return Parrot_pcc_get_lex_pad(interp, CURRENT_CONTEXT(interp));
+        result = Parrot_pcc_get_lex_pad(interp, CURRENT_CONTEXT(interp));
+        break;
       default:        /* or a warning only? */
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
                 "illegal argument in interpinfo");
     }
+
+    /* Don't send NULL values to P registers */
+    return result ? result : PMCNULL;
 }
 
 /*


More information about the parrot-commits mailing list