Ticket #1345: pmc_freeze_push_shift.patch
File pmc_freeze_push_shift.patch, 6.1 KB (added by plobsing, 12 years ago) |
---|
-
src/pmc_freeze.c
87 87 __attribute__nonnull__(1) 88 88 __attribute__nonnull__(2); 89 89 90 static void push_opcode_pmc(PARROT_INTERP,91 ARGIN(IMAGE_IO *io),92 ARGIN(PMC* v))93 __attribute__nonnull__(1)94 __attribute__nonnull__(2)95 __attribute__nonnull__(3);96 97 90 static void push_opcode_string(PARROT_INTERP, 98 91 ARGIN(IMAGE_IO *io), 99 92 ARGIN(STRING *v)) … … 116 109 __attribute__nonnull__(2); 117 110 118 111 PARROT_WARN_UNUSED_RESULT 119 PARROT_CAN_RETURN_NULL120 static PMC* shift_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io))121 __attribute__nonnull__(1)122 __attribute__nonnull__(2);123 124 PARROT_WARN_UNUSED_RESULT125 112 PARROT_CANNOT_RETURN_NULL 126 113 static STRING* shift_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io)) 127 114 __attribute__nonnull__(1) … … 207 194 #define ASSERT_ARGS_push_opcode_number __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 208 195 PARROT_ASSERT_ARG(interp) \ 209 196 , PARROT_ASSERT_ARG(io)) 210 #define ASSERT_ARGS_push_opcode_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\211 PARROT_ASSERT_ARG(interp) \212 , PARROT_ASSERT_ARG(io) \213 , PARROT_ASSERT_ARG(v))214 197 #define ASSERT_ARGS_push_opcode_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 215 198 PARROT_ASSERT_ARG(interp) \ 216 199 , PARROT_ASSERT_ARG(io) \ … … 222 205 PARROT_ASSERT_ARG(io)) 223 206 #define ASSERT_ARGS_shift_opcode_number __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 224 207 PARROT_ASSERT_ARG(io)) 225 #define ASSERT_ARGS_shift_opcode_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\226 PARROT_ASSERT_ARG(interp) \227 , PARROT_ASSERT_ARG(io))228 208 #define ASSERT_ARGS_shift_opcode_string __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 229 209 PARROT_ASSERT_ARG(interp) \ 230 210 , PARROT_ASSERT_ARG(io)) … … 404 384 405 385 /* 406 386 407 =item C<static void push_opcode_pmc(PARROT_INTERP, IMAGE_IO *io, PMC* v)>408 409 Pushes the PMC C<*v> onto the end of the C<*io> "stream".410 411 =cut412 413 */414 415 static void416 push_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(PMC* v))417 {418 ASSERT_ARGS(push_opcode_pmc)419 UINTVAL size = sizeof (opcode_t);420 STRING *op = Parrot_str_new_init(interp, (char *)&v, size,421 Parrot_fixed_8_encoding_ptr, Parrot_binary_charset_ptr, 0);422 io->image = Parrot_str_append(interp, io->image, op);423 }424 425 426 /*427 428 387 =item C<static INTVAL shift_opcode_integer(PARROT_INTERP, IMAGE_IO *io)> 429 388 430 389 Removes and returns an integer from the start of the C<*io> "stream". … … 453 412 454 413 /* 455 414 456 =item C<static PMC* shift_opcode_pmc(PARROT_INTERP, IMAGE_IO *io)>457 458 Removes and returns an PMC from the start of the C<*io> "stream".459 460 Note that this actually reads a PMC id, not a PMC.461 462 =cut463 464 */465 466 PARROT_WARN_UNUSED_RESULT467 PARROT_CAN_RETURN_NULL468 static PMC*469 shift_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io))470 {471 ASSERT_ARGS(shift_opcode_pmc)472 INTVAL i = shift_opcode_integer(interp, io);473 return (PMC *)i;474 }475 476 477 /*478 479 415 =item C<static FLOATVAL shift_opcode_number(PARROT_INTERP, IMAGE_IO *io)> 480 416 481 417 Removes and returns an number from the start of the C<*io> "stream". … … 555 491 556 492 static image_funcs opcode_funcs = { 557 493 push_opcode_integer, 558 push_opcode_pmc,559 494 push_opcode_string, 560 495 push_opcode_number, 561 496 shift_opcode_integer, 562 shift_opcode_pmc,563 497 shift_opcode_string, 564 498 shift_opcode_number 565 499 }; … … 682 616 683 617 if (PMC_IS_NULL(pmc)) { 684 618 /* NULL + seen bit */ 685 VTABLE_push_ pmc(interp, io, (PMC*)PackID_new(NULL, enum_PackID_seen));619 VTABLE_push_integer(interp, io, PackID_new(NULL, enum_PackID_seen)); 686 620 return; 687 621 } 688 622 … … 694 628 if (seen) { 695 629 if (info->extra_flags) { 696 630 PackID_set_FLAGS(id, enum_PackID_extra_info); 697 VTABLE_push_ pmc(interp, io, (PMC *)id);631 VTABLE_push_integer(interp, io, id); 698 632 VTABLE_push_integer(interp, io, info->extra_flags); 699 633 return; 700 634 } … … 704 638 else if (type == info->last_type) 705 639 PackID_set_FLAGS(id, enum_PackID_prev_type); 706 640 707 VTABLE_push_ pmc(interp, io, (PMC*)id);641 VTABLE_push_integer(interp, io, id); 708 642 709 643 if (PackID_get_FLAGS(id) == enum_PackID_normal) { 710 644 /* write type */ … … 744 678 { 745 679 ASSERT_ARGS(thaw_pmc) 746 680 IMAGE_IO * const io = info->image_io; 747 PMC *n = VTABLE_shift_pmc(interp, io);681 UINTVAL n = VTABLE_shift_integer(interp, io); 748 682 int seen = 0; 749 683 750 684 info->extra_flags = EXTRA_IS_NULL; … … 778 712 break; 779 713 } 780 714 781 *id = (UINTVAL)n;715 *id = n; 782 716 return seen; 783 717 } 784 718 -
include/parrot/pmc_freeze.h
29 29 struct _image_io; 30 30 #define IMAGE_IO struct _image_io 31 31 typedef void (*push_integer_f) (PARROT_INTERP, IMAGE_IO*, INTVAL); 32 typedef void (*push_pmc_f) (PARROT_INTERP, IMAGE_IO*, PMC*);33 32 typedef void (*push_string_f) (PARROT_INTERP, IMAGE_IO*, STRING*); 34 33 typedef void (*push_number_f) (PARROT_INTERP, IMAGE_IO*, FLOATVAL); 35 typedef INTVAL (*shift_integer_f) (PARROT_INTERP, IMAGE_IO*); 36 typedef PMC* (*shift_pmc_f) (PARROT_INTERP, IMAGE_IO*); 37 typedef STRING* (*shift_string_f) (PARROT_INTERP, IMAGE_IO*); 38 typedef FLOATVAL (*shift_number_f) (PARROT_INTERP, IMAGE_IO*); 34 typedef INTVAL (*shift_integer_f) (PARROT_INTERP, IMAGE_IO*); 35 typedef STRING* (*shift_string_f) (PARROT_INTERP, IMAGE_IO*); 36 typedef FLOATVAL (*shift_number_f) (PARROT_INTERP, IMAGE_IO*); 39 37 40 38 typedef struct _image_funcs { 41 39 push_integer_f push_integer; 42 push_pmc_f push_pmc;43 40 push_string_f push_string; 44 41 push_number_f push_float; 45 42 shift_integer_f shift_integer; 46 shift_pmc_f shift_pmc;47 43 shift_string_f shift_string; 48 44 shift_number_f shift_float; 49 45 } image_funcs;