[svn:parrot] r42868 - in trunk: include/parrot src

cotto at svn.parrot.org cotto at svn.parrot.org
Thu Dec 3 06:37:44 UTC 2009


Author: cotto
Date: Thu Dec  3 06:37:41 2009
New Revision: 42868
URL: https://trac.parrot.org/parrot/changeset/42868

Log:
[freeze] when pushing/shifting to/from an IMAGE_IO, don't dress up an INTVAL as a PMC*
patch courtesy of plobsing++

Modified:
   trunk/include/parrot/pmc_freeze.h
   trunk/src/pmc_freeze.c

Modified: trunk/include/parrot/pmc_freeze.h
==============================================================================
--- trunk/include/parrot/pmc_freeze.h	Thu Dec  3 02:27:55 2009	(r42867)
+++ trunk/include/parrot/pmc_freeze.h	Thu Dec  3 06:37:41 2009	(r42868)
@@ -29,21 +29,17 @@
 struct _image_io;
 #define IMAGE_IO struct _image_io
 typedef void (*push_integer_f)       (PARROT_INTERP, IMAGE_IO*, INTVAL);
-typedef void (*push_pmc_f)           (PARROT_INTERP, IMAGE_IO*, PMC*);
 typedef void (*push_string_f)        (PARROT_INTERP, IMAGE_IO*, STRING*);
 typedef void (*push_number_f)        (PARROT_INTERP, IMAGE_IO*, FLOATVAL);
-typedef INTVAL (*shift_integer_f)      (PARROT_INTERP, IMAGE_IO*);
-typedef PMC*    (*shift_pmc_f)          (PARROT_INTERP, IMAGE_IO*);
-typedef STRING* (*shift_string_f)       (PARROT_INTERP, IMAGE_IO*);
-typedef FLOATVAL (*shift_number_f)       (PARROT_INTERP, IMAGE_IO*);
+typedef INTVAL (*shift_integer_f)    (PARROT_INTERP, IMAGE_IO*);
+typedef STRING* (*shift_string_f)    (PARROT_INTERP, IMAGE_IO*);
+typedef FLOATVAL (*shift_number_f)   (PARROT_INTERP, IMAGE_IO*);
 
 typedef struct _image_funcs {
     push_integer_f      push_integer;
-    push_pmc_f          push_pmc;
     push_string_f       push_string;
     push_number_f       push_float;
     shift_integer_f     shift_integer;
-    shift_pmc_f         shift_pmc;
     shift_string_f      shift_string;
     shift_number_f      shift_float;
 } image_funcs;

Modified: trunk/src/pmc_freeze.c
==============================================================================
--- trunk/src/pmc_freeze.c	Thu Dec  3 02:27:55 2009	(r42867)
+++ trunk/src/pmc_freeze.c	Thu Dec  3 06:37:41 2009	(r42868)
@@ -87,13 +87,6 @@
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
-static void push_opcode_pmc(PARROT_INTERP,
-    ARGIN(IMAGE_IO *io),
-    ARGIN(PMC* v))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        __attribute__nonnull__(3);
-
 static void push_opcode_string(PARROT_INTERP,
     ARGIN(IMAGE_IO *io),
     ARGIN(STRING *v))
@@ -116,12 +109,6 @@
         __attribute__nonnull__(2);
 
 PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static PMC* shift_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_WARN_UNUSED_RESULT
 PARROT_CANNOT_RETURN_NULL
 static STRING* shift_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io))
         __attribute__nonnull__(1)
@@ -207,10 +194,6 @@
 #define ASSERT_ARGS_push_opcode_number __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(io))
-#define ASSERT_ARGS_push_opcode_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(io) \
-    , PARROT_ASSERT_ARG(v))
 #define ASSERT_ARGS_push_opcode_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(io) \
@@ -222,9 +205,6 @@
        PARROT_ASSERT_ARG(io))
 #define ASSERT_ARGS_shift_opcode_number __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(io))
-#define ASSERT_ARGS_shift_opcode_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(io))
 #define ASSERT_ARGS_shift_opcode_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(io))
@@ -404,27 +384,6 @@
 
 /*
 
-=item C<static void push_opcode_pmc(PARROT_INTERP, IMAGE_IO *io, PMC* v)>
-
-Pushes the PMC C<*v> onto the end of the C<*io> "stream".
-
-=cut
-
-*/
-
-static void
-push_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(PMC* v))
-{
-    ASSERT_ARGS(push_opcode_pmc)
-    UINTVAL size = sizeof (opcode_t);
-    STRING   *op = Parrot_str_new_init(interp, (char *)&v, size,
-        Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);
-    io->image = Parrot_str_append(interp, io->image, op);
-}
-
-
-/*
-
 =item C<static INTVAL shift_opcode_integer(PARROT_INTERP, IMAGE_IO *io)>
 
 Removes and returns an integer from the start of the C<*io> "stream".
@@ -453,29 +412,6 @@
 
 /*
 
-=item C<static PMC* shift_opcode_pmc(PARROT_INTERP, IMAGE_IO *io)>
-
-Removes and returns an PMC from the start of the C<*io> "stream".
-
-Note that this actually reads a PMC id, not a PMC.
-
-=cut
-
-*/
-
-PARROT_WARN_UNUSED_RESULT
-PARROT_CAN_RETURN_NULL
-static PMC*
-shift_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io))
-{
-    ASSERT_ARGS(shift_opcode_pmc)
-    INTVAL i = shift_opcode_integer(interp, io);
-    return (PMC *)i;
-}
-
-
-/*
-
 =item C<static FLOATVAL shift_opcode_number(PARROT_INTERP, IMAGE_IO *io)>
 
 Removes and returns an number from the start of the C<*io> "stream".
@@ -555,11 +491,9 @@
 
 static image_funcs opcode_funcs = {
     push_opcode_integer,
-    push_opcode_pmc,
     push_opcode_string,
     push_opcode_number,
     shift_opcode_integer,
-    shift_opcode_pmc,
     shift_opcode_string,
     shift_opcode_number
 };
@@ -682,7 +616,7 @@
 
     if (PMC_IS_NULL(pmc)) {
         /* NULL + seen bit */
-        VTABLE_push_pmc(interp, io, (PMC*)PackID_new(NULL, enum_PackID_seen));
+        VTABLE_push_integer(interp, io, PackID_new(NULL, enum_PackID_seen));
         return;
     }
 
@@ -694,7 +628,7 @@
     if (seen) {
         if (info->extra_flags) {
             PackID_set_FLAGS(id, enum_PackID_extra_info);
-            VTABLE_push_pmc(interp, io, (PMC *)id);
+            VTABLE_push_integer(interp, io, id);
             VTABLE_push_integer(interp, io, info->extra_flags);
             return;
         }
@@ -704,7 +638,7 @@
     else if (type == info->last_type)
         PackID_set_FLAGS(id, enum_PackID_prev_type);
 
-    VTABLE_push_pmc(interp, io, (PMC*)id);
+    VTABLE_push_integer(interp, io, id);
 
     if (PackID_get_FLAGS(id) == enum_PackID_normal) {
         /* write type */
@@ -744,7 +678,7 @@
 {
     ASSERT_ARGS(thaw_pmc)
     IMAGE_IO * const io   = info->image_io;
-    PMC             *n    = VTABLE_shift_pmc(interp, io);
+    UINTVAL          n    = VTABLE_shift_integer(interp, io);
     int              seen = 0;
 
     info->extra_flags     = EXTRA_IS_NULL;
@@ -778,7 +712,7 @@
         break;
     }
 
-    *id = (UINTVAL)n;
+    *id = n;
     return seen;
 }
 


More information about the parrot-commits mailing list