Ticket #375: const-freeze.patch

File const-freeze.patch, 4.7 KB (added by rurban, 13 years ago)

at first freeze could use some consting

  • src/pmc_freeze.c

     
    132132        __attribute__nonnull__(1) 
    133133        __attribute__nonnull__(2); 
    134134 
    135 static void push_ascii_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v) 
     135static void push_ascii_integer(PARROT_INTERP, 
     136    ARGIN(IMAGE_IO *io), 
     137    const INTVAL v) 
    136138        __attribute__nonnull__(1) 
    137139        __attribute__nonnull__(2); 
    138140 
    139141static void push_ascii_number(PARROT_INTERP, 
    140142    ARGIN(const IMAGE_IO *io), 
    141     FLOATVAL v) 
     143    const FLOATVAL v) 
    142144        __attribute__nonnull__(1) 
    143145        __attribute__nonnull__(2); 
    144146 
     
    158160 
    159161static void push_opcode_integer(PARROT_INTERP, 
    160162    ARGIN(IMAGE_IO *io), 
    161     INTVAL v) 
     163    const INTVAL v) 
    162164        __attribute__nonnull__(1) 
    163165        __attribute__nonnull__(2); 
    164166 
    165167static void push_opcode_number(PARROT_INTERP, 
    166168    ARGIN(IMAGE_IO *io), 
    167     FLOATVAL v) 
     169    const FLOATVAL v) 
    168170        __attribute__nonnull__(1) 
    169171        __attribute__nonnull__(2); 
    170172 
    171173static void push_opcode_pmc(PARROT_INTERP, 
    172174    ARGIN(IMAGE_IO *io), 
    173     ARGIN(PMC* v)) 
     175    ARGIN(const PMC* v)) 
    174176        __attribute__nonnull__(1) 
    175177        __attribute__nonnull__(2) 
    176178        __attribute__nonnull__(3); 
    177179 
    178180static void push_opcode_string(PARROT_INTERP, 
    179181    ARGIN(IMAGE_IO *io), 
    180     ARGIN(STRING *v)) 
     182    ARGIN(const STRING *v)) 
    181183        __attribute__nonnull__(1) 
    182184        __attribute__nonnull__(2) 
    183185        __attribute__nonnull__(3); 
     
    436438/* HEADERIZER END: static */ 
    437439 
    438440/* 
    439  * define this to 1 for testing. TODO: 1 is broken. 
     441 * define this to 1 for testing. TODO TT #375: 1 is broken. 
    440442 */ 
    441443#ifndef FREEZE_ASCII 
    442444#  define FREEZE_ASCII 0 
     
    510512*/ 
    511513 
    512514static void 
    513 push_ascii_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v) 
     515push_ascii_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), const INTVAL v) 
    514516{ 
    515517    ASSERT_ARGS(push_ascii_integer) 
    516518    char buffer[20]; 
     
    530532*/ 
    531533 
    532534static void 
    533 push_ascii_number(PARROT_INTERP, ARGIN(const IMAGE_IO *io), FLOATVAL v) 
     535push_ascii_number(PARROT_INTERP, ARGIN(const IMAGE_IO *io), const FLOATVAL v) 
    534536{ 
    535537    ASSERT_ARGS(push_ascii_number) 
    536538    char buffer[40]; 
     
    558560{ 
    559561    ASSERT_ARGS(push_ascii_string) 
    560562    const UINTVAL length = Parrot_str_byte_length(interp, s); 
    561     char * const buffer = (char *)malloc(4*length); /* XXX Why 4?  What does that mean? */ 
     563    char * const buffer = (char *)malloc(OPCODE_T_SIZE*length); 
    562564    char *cursor = buffer; 
    563565    UINTVAL idx = 0; 
    564566 
     
    777779*/ 
    778780 
    779781static void 
    780 push_opcode_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), INTVAL v) 
     782push_opcode_integer(PARROT_INTERP, ARGIN(IMAGE_IO *io), const INTVAL v) 
    781783{ 
    782784    ASSERT_ARGS(push_opcode_integer) 
    783785    PARROT_ASSERT(sizeof (opcode_t) == sizeof (INTVAL)); 
     
    795797*/ 
    796798 
    797799static void 
    798 push_opcode_number(PARROT_INTERP, ARGIN(IMAGE_IO *io), FLOATVAL v) 
     800push_opcode_number(PARROT_INTERP, ARGIN(IMAGE_IO *io), const FLOATVAL v) 
    799801{ 
    800802    ASSERT_ARGS(push_opcode_number) 
    801803    const size_t   len  = PF_size_number() * sizeof (opcode_t); 
     
    822824*/ 
    823825 
    824826static void 
    825 push_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(STRING *v)) 
     827push_opcode_string(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(const STRING *v)) 
    826828{ 
    827829    ASSERT_ARGS(push_opcode_string) 
    828830    const size_t len = PF_size_string(v) * sizeof (opcode_t); 
     
    849851*/ 
    850852 
    851853static void 
    852 push_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(PMC* v)) 
     854push_opcode_pmc(PARROT_INTERP, ARGIN(IMAGE_IO *io), ARGIN(const PMC* v)) 
    853855{ 
    854856    ASSERT_ARGS(push_opcode_pmc) 
    855857    op_append(interp, io->image, (opcode_t)v, sizeof (opcode_t)); 
  • include/parrot/pmc_freeze.h

     
    2828 
    2929struct _image_io; 
    3030#define IMAGE_IO struct _image_io 
    31 typedef void (*push_integer_f)       (PARROT_INTERP, IMAGE_IO*, INTVAL); 
    32 typedef void (*push_pmc_f)           (PARROT_INTERP, IMAGE_IO*, PMC*); 
    33 typedef void (*push_string_f)        (PARROT_INTERP, IMAGE_IO*, STRING*); 
    34 typedef void (*push_number_f)        (PARROT_INTERP, IMAGE_IO*, FLOATVAL); 
     31typedef void (*push_integer_f)       (PARROT_INTERP, IMAGE_IO*, const INTVAL); 
     32typedef void (*push_pmc_f)           (PARROT_INTERP, IMAGE_IO*, const PMC*); 
     33typedef void (*push_string_f)        (PARROT_INTERP, IMAGE_IO*, const STRING*); 
     34typedef void (*push_number_f)        (PARROT_INTERP, IMAGE_IO*, const FLOATVAL); 
    3535typedef INTVAL (*shift_integer_f)      (PARROT_INTERP, IMAGE_IO*); 
    3636typedef PMC*    (*shift_pmc_f)          (PARROT_INTERP, IMAGE_IO*); 
    3737typedef STRING* (*shift_string_f)       (PARROT_INTERP, IMAGE_IO*);