cvsuser     03/01/30 23:47:30

  Modified:    include/parrot packfile.h
               .        packfile.c
               t/native_pbc number.t
  Log:
  packfile #6 - [perl #20597] + fups
  
  Revision  Changes    Path
  1.38      +5 -3      parrot/include/parrot/packfile.h
  
  Index: packfile.h
  ===================================================================
  RCS file: /cvs/public/parrot/include/parrot/packfile.h,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -w -r1.37 -r1.38
  --- packfile.h        28 Jan 2003 09:20:27 -0000      1.37
  +++ packfile.h        31 Jan 2003 07:47:18 -0000      1.38
  @@ -1,6 +1,6 @@
   /* packfile.h
   *
  -* $Id: packfile.h,v 1.37 2003/01/28 09:20:27 leo Exp $
  +* $Id: packfile.h,v 1.38 2003/01/31 07:47:18 leo Exp $
   *
   * History:
   *  Rework by Melvin; new bytecode format, make bytecode portable.
  @@ -319,11 +319,13 @@
   opcode_t * PackFile_Constant_unpack_key(struct Parrot_Interp *interpreter,
           struct PackFile * pf, struct PackFile_Constant *, opcode_t * packed);
   
  -opcode_t PackFile_fetch_op(struct PackFile *pf, opcode_t *stream);
  +opcode_t PackFile_fetch_op(struct PackFile *pf, opcode_t **stream);
   
  -INTVAL PackFile_fetch_iv(struct PackFile *pf, opcode_t *stream);
  +INTVAL PackFile_fetch_iv(struct PackFile *pf, opcode_t **stream);
   
   FLOATVAL PackFile_fetch_nv(struct PackFile *pf, opcode_t **stream);
  +
  +char * PackFile_fetch_cstring(struct PackFile *pf, opcode_t **stream);
   
   void PackFile_assign_transforms(struct PackFile *pf);
   
  
  
  
  1.69      +180 -84   parrot/packfile.c
  
  Index: packfile.c
  ===================================================================
  RCS file: /cvs/public/parrot/packfile.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -w -r1.68 -r1.69
  --- packfile.c        28 Jan 2003 09:20:22 -0000      1.68
  +++ packfile.c        31 Jan 2003 07:47:26 -0000      1.69
  @@ -7,7 +7,7 @@
   ** This program is free software. It is subject to the same
   ** license as Parrot itself.
   **
  -** $Id: packfile.c,v 1.68 2003/01/28 09:20:22 leo Exp $
  +** $Id: packfile.c,v 1.69 2003/01/31 07:47:26 leo Exp $
   **
   ** History:
   **  Rework by Melvin; new bytecode format, make bytecode portable.
  @@ -95,13 +95,16 @@
   ***************************************/
   
   opcode_t
  -PackFile_fetch_op(struct PackFile *pf, opcode_t *stream) {
  -    if(pf->fetch_op == NULL)
  -        return *stream;
  +PackFile_fetch_op(struct PackFile *pf, opcode_t **stream) {
  +    opcode_t o;
  +    if (!pf->fetch_op)
  +        return *(*stream)++;
   #if TRACE_PACKFILE == 2
       PIO_eprintf(NULL, "PackFile_fetch_op: Reordering.\n");
   #endif
  -    return (pf->fetch_op)(*stream);
  +    o = (pf->fetch_op)(**stream);
  +    ((unsigned char *) (*stream)) += pf->header->wordsize;
  +    return o;
   }
   
   /***************************************
  @@ -116,12 +119,70 @@
   ***************************************/
   
   INTVAL
  -PackFile_fetch_iv(struct PackFile *pf, opcode_t *stream) {
  +PackFile_fetch_iv(struct PackFile *pf, opcode_t **stream) {
  +    INTVAL i;
       if(pf->fetch_iv == NULL)
  -        return *stream;
  -    return (pf->fetch_iv)(*stream);
  +        return *(*stream++);
  +    i = (pf->fetch_iv)(**stream);
  +    /* XXX assume sizeof(opcode_t) == sizeof(INTVAL) on the
  +     * machine producing this PBC
  +     */
  +    ((unsigned char *) (*stream)) += pf->header->wordsize;
  +    return i;
   }
   
  +/* convert i386 LE 12 byte long double to IEEE 754 8 byte double
  + */
  +static void cvt_num12_num8(unsigned char *dest, unsigned char *src)
  +{
  +    int expo, i, s;
  +
  +    memset (dest, 0, 8);
  +    /* exponents 15 -> 11 bits */
  +    s = src[9] & 0x80; /* sign */
  +    expo = ((src[9] & 0x7f)<< 8 | src[8]);
  +    if (expo == 0) {
  +nul:
  +        if (s)
  +            dest[7] |= 0x80;
  +        return;
  +    }
  +    expo -= 16383;       /* - bias */
  +    expo += 1023;       /* + bias 8byte */
  +    if (expo <= 0)       /* underflow */
  +        goto nul;
  +    if (expo > 0x7ff) {      /* inf/nan */
  +        dest[7] = 0x7f;
  +        dest[6] = src[7] == 0xc0 ? 0xf8 : 0xf0 ;
  +        goto nul;
  +    }
  +    expo <<= 4;
  +    dest[6] = (expo & 0xff);
  +    dest[7] = (expo & 0x7f00) >> 8;
  +    if (s)
  +        dest[7] |= 0x80;
  +    /* long double frac 63 bits => 52 bits
  +       src[7] &= 0x7f; reset integer bit */
  +    for (i = 0; i < 6; i++) {
  +        dest[i+1] |= (i==5 ? src[7]&0x7f : src[i+2]) >> 3;
  +        dest[i] |= (src[i+2] & 0x1f) << 5;
  +    }
  +    dest[0] |= src[1] >> 3;
  +}
  +
  +static void cvt_num12_num8_be(unsigned char *dest, unsigned char *src)
  +{
  +    cvt_num12_num8(dest, src);
  +    /* TODO endianize */
  +    internal_exception(1, "TODO cvt_num12_num8_be\n");
  +}
  +
  +static void cvt_num12_num8_le(unsigned char *dest, unsigned char *src)
  +{
  +    cvt_num12_num8(dest, src);
  +    /* TODO endianize */
  +    internal_exception(1, "TODO cvt_num12_num8_le\n");
  +}
   /***************************************
   
   =item fetch_nv
  @@ -140,9 +201,8 @@
        * to use memcpy() for native byteorder.
        */
       FLOATVAL f;
  -    HUGEFLOATVAL g;
       double d;
  -    if(pf->fetch_nv == NULL) {
  +    if (!pf->fetch_nv) {
   #if TRACE_PACKFILE
           PIO_eprintf(NULL, "PackFile_fetch_nv: Native [%d bytes]..\n",
                   sizeof(FLOATVAL));
  @@ -153,15 +213,13 @@
           return f;
       }
       f = (FLOATVAL) 0;
  -    g = (HUGEFLOATVAL) 0;
   #if TRACE_PACKFILE
       PIO_eprintf(NULL, "PackFile_fetch_nv: Byteordering..\n");
   #endif
       /* Here is where the size transforms get messy */
       if (NUMVAL_SIZE == 8 && pf->header->floattype == 1) {
  -        (pf->fetch_nv)((unsigned char *)&g, (unsigned char *) *stream);
  +        (pf->fetch_nv)((unsigned char *)&f, (unsigned char *) *stream);
           ((unsigned char *) (*stream)) += 12;
  -        f = g;
       }
       else {
           (pf->fetch_nv)((unsigned char *)&d, (unsigned char *) *stream);
  @@ -171,42 +229,88 @@
       return f;
   }
   
  +static opcode_t
  +fetch_op_mixed(opcode_t b)
  +{
  +    union {
  +        unsigned char buf[8];
  +        opcode_t o[2];
  +    } u;
  +    opcode_t o;
  +
  +#if PARROT_BIGENDIAN
  +#  if OPCODE_T_SIZE == 4
  +     /* wordsize = 8 then */
  +     fetch_buf_le_8(u.buf, (unsigned char *) b);
  +     return u.o[1]; /* or u.o[0] */
  +#  else
  +     o = fetch_op_le(b);        /* or fetch_be_le_4 and convert? */
  +     return o >> 32;    /* or o & 0xffffffff */
  +#  endif
  +#else
  +#  if OPCODE_T_SIZE == 4
  +     /* wordsize = 8 then */
  +     fetch_buf_be_8(u.buf, (unsigned char *) b);
  +     return u.o[0]; /* or u.o[1] */
  +#  else
  +     o = fetch_op_be(b);
  +     return o & 0xffffffff;
  +#  endif
  +
  +#endif
  +}
   /*
    * Assign transform functions to vtable
    */
  -void PackFile_assign_transforms(struct PackFile *pf) {
  +void
  +PackFile_assign_transforms(struct PackFile *pf) {
   #if PARROT_BIGENDIAN
       if(pf->header->byteorder != PARROT_BIGENDIAN) {
           pf->need_endianize = 1;
  +        if (pf->header->wordsize == sizeof(opcode_t))
           pf->fetch_op = fetch_op_le;
  +        else {
  +            pf->need_wordsize = 1;
  +            pf->fetch_op = fetch_op_mixed;
  +        }
  +
           pf->fetch_iv = fetch_iv_le;
           if (pf->header->floattype == 0)
               pf->fetch_nv = fetch_buf_le_8;
           else if (pf->header->floattype == 1)
  -            pf->fetch_nv = fetch_buf_le_12;
  +            pf->fetch_nv = cvt_num12_num8_le;
       }
   #else
       if(pf->header->byteorder != PARROT_BIGENDIAN) {
           pf->need_endianize = 1;
  +        if (pf->header->wordsize == sizeof(opcode_t)) {
           pf->fetch_op = fetch_op_be;
  +        }
  +        else {
  +            pf->need_wordsize = 1;
  +            pf->fetch_op = fetch_op_mixed;
  +        }
           pf->fetch_iv = fetch_iv_be;
           if (pf->header->floattype == 0)
               pf->fetch_nv = fetch_buf_be_8;
           else if (pf->header->floattype == 1)
  -            pf->fetch_nv = fetch_buf_be_12;
  +            pf->fetch_nv = cvt_num12_num8_be;
       }
       else {
           if (NUMVAL_SIZE == 8 && pf->header->floattype == 1)
  -            pf->fetch_nv = fetch_buf_le_12;
  +            pf->fetch_nv = cvt_num12_num8;
           else if (NUMVAL_SIZE != 8 && pf->header->floattype == 0)
               pf->fetch_nv = fetch_buf_le_8;
  -        /* XXX else */
  +    }
   #  if TRACE_PACKFILE
           PIO_eprintf(NULL, "header->byteorder [%d] native byteorder [%d]\n",
               pf->header->byteorder, PARROT_BIGENDIAN);
   #  endif
  -    }
   #endif
  +    if (pf->header->wordsize != sizeof(opcode_t)) {
  +        pf->need_wordsize = 1;
  +        pf->fetch_op = fetch_op_mixed;
  +    }
   }
   
   /***************************************
  @@ -329,7 +433,7 @@
       memcpy(header, packed, PACKFILE_HEADER_BYTES);
       if(header->wordsize != sizeof(opcode_t)) {
           self->need_wordsize = 1;
  -        if(header->wordsize == 0) {
  +        if(header->wordsize != 4 && header->wordsize != 8) {
               PIO_eprintf(NULL, "PackFile_unpack: Invalid wordsize %d\n",
                           header->wordsize);
               return 0;
  @@ -343,16 +447,6 @@
       PIO_eprintf(NULL, "byteorder: %d\n", header->byteorder);
   #endif
   
  -    /*
  -     * FIXME
  -     */
  -    if(self->need_wordsize) {
  -        PIO_eprintf(NULL,
  -                "PackFile_unpack: Unimplemented wordsize transform.\n");
  -        PIO_eprintf(NULL, "File has wordsize: %d (native is %d)\n",
  -                header->wordsize,  sizeof(opcode_t));
  -        return 0;
  -    }
       if (header->major != PARROT_MAJOR_VERSION ||
               header->minor != (PARROT_MINOR_VERSION|PARROT_PATCH_VERSION)) {
           PIO_eprintf(NULL, "PackFile_unpack: Bytecode not valid for this "
  @@ -370,7 +464,7 @@
       /*
        * Unpack and verify the magic which is stored byteorder of the file:
        */
  -    header->magic = PackFile_fetch_op(self, cursor++);
  +    header->magic = PackFile_fetch_op(self, &cursor);
   
       /*
        * The magic and opcodetype fields are in native byteorder.
  @@ -384,7 +478,7 @@
           return 0;
       }
   
  -    header->opcodetype = PackFile_fetch_op(self, cursor++);
  +    header->opcodetype = PackFile_fetch_op(self, &cursor);
   
   #if TRACE_PACKFILE
       PIO_eprintf(NULL, "PackFile_unpack(): Magic verified.\n");
  @@ -394,7 +488,7 @@
        * Unpack the Fixup Table Segment:
        */
   
  -    header->dir_format = PackFile_fetch_op(self, cursor++);
  +    header->dir_format = PackFile_fetch_op(self, &cursor);
   
       /* old compat mode for assemble.pl */
       if (header->dir_format == 0) {
  @@ -402,7 +496,7 @@
           /*
            * Unpack the Constant Table Segment:
            */
  -        header->const_ss = PackFile_fetch_op(self, cursor++);
  +        header->const_ss = PackFile_fetch_op(self, &cursor);
           self->const_table->base.op_count = header->const_ss /
               sizeof(opcode_t);
           if (!PackFile_check_segment_size(header->const_ss,
  @@ -419,14 +513,14 @@
           }
   
           /* Segment size is in bytes */
  -        cursor += header->const_ss / sizeof(opcode_t);
  +        (char *)cursor += header->const_ss;
   
           /*
            * Unpack the Byte Code Segment:
            * PackFile new did generate already a default code segment
            */
   
  -        header->bytecode_ss = PackFile_fetch_op(self, cursor++);
  +        header->bytecode_ss = PackFile_fetch_op(self, &cursor);
   
           if (!PackFile_check_segment_size(header->bytecode_ss,
                       "bytecode")) {
  @@ -445,10 +539,10 @@
                       (int)header->dir_format);
               return 0;
           }
  -        cursor++;       /* pad */
  +        (void)PackFile_fetch_op(self, &cursor); /* pad */
           self->directory->base.file_offset = (size_t)(cursor - self->src);
  -        cursor = PackFile_Segment_unpack(interpreter, (struct PackFile_Segment *)
  -                self->directory, cursor);
  +        cursor = PackFile_Segment_unpack(interpreter,
  +                (struct PackFile_Segment *) self->directory, cursor);
       }
       self->byte_code = self->cur_cs->base.data;
       self->byte_code_size = self->cur_cs->base.size * sizeof(opcode_t);
  @@ -632,15 +726,12 @@
       pf->eval_nr = 0;
       pf_register_standard_funcs(pf);
       pf->directory = (struct PackFile_Directory *)
  -        PackFile_Segment_new_seg(pf, PF_DIR_SEG,
  -                DIRECTORY_SEGMENT_NAME, 0);
  +        PackFile_Segment_new_seg(pf, PF_DIR_SEG, DIRECTORY_SEGMENT_NAME, 0);
       /* add default segments */
       pf->const_table = (struct PackFile_ConstTable *)
  -        PackFile_Segment_new_seg(pf, PF_CONST_SEG,
  -                CONSTANT_SEGMENT_NAME, 1);
  +        PackFile_Segment_new_seg(pf, PF_CONST_SEG, CONSTANT_SEGMENT_NAME, 1);
       pf->cur_cs = (struct PackFile_ByteCode*)
  -        PackFile_Segment_new_seg(pf, PF_BYTEC_SEG,
  -                BYTE_CODE_SEGMENT_NAME, 1);
  +        PackFile_Segment_new_seg(pf, PF_BYTEC_SEG, BYTE_CODE_SEGMENT_NAME, 1);
       pf->need_wordsize = 0;
       pf->need_endianize = 0;
       pf->fetch_op = (opcode_t (*)(opcode_t)) NULL;
  @@ -662,10 +753,10 @@
           struct PackFile_Segment *self, opcode_t *cursor)
   {
       if (self->pf->header->dir_format) {
  -        self->op_count = PackFile_fetch_op(self->pf, cursor++);
  -        self->itype = PackFile_fetch_op(self->pf, cursor++);
  -        self->id = PackFile_fetch_op(self->pf, cursor++);
  -        self->size = PackFile_fetch_op(self->pf, cursor++);
  +        self->op_count = PackFile_fetch_op(self->pf, &cursor);
  +        self->itype = PackFile_fetch_op(self->pf, &cursor);
  +        self->id = PackFile_fetch_op(self->pf, &cursor);
  +        self->size = PackFile_fetch_op(self->pf, &cursor);
       }
       if (self->size == 0)
           return cursor;
  @@ -690,16 +781,14 @@
   
       if(!self->pf->need_endianize && !self->pf->need_wordsize) {
           mem_sys_memcopy(self->data, cursor, self->size * sizeof(opcode_t));
  -        /* Segment size is in bytes */
           cursor += self->size;
       }
       else {
           int i;
           for(i = 0; i < (int)self->size ; i++) {
  -            self->data[i] = PackFile_fetch_op(self->pf, cursor++);
  +            self->data[i] = PackFile_fetch_op(self->pf, &cursor);
   #if TRACE_PACKFILE
  -            PIO_eprintf(NULL, "op[%u]->[%u]\n", *(cursor-1),
  -                    self->data[i]);
  +            PIO_eprintf(NULL, "op[#%d] %u\n", i, self->data[i]);
   #endif
           }
       }
  @@ -928,8 +1017,10 @@
       size_t i;
       struct PackFile_Directory *dir = (struct PackFile_Directory *) segp;
       struct PackFile      * self = dir->base.pf;
  +    opcode_t *pos;
  +    int wordsize = self->header->wordsize;
   
  -    dir->num_segments = PackFile_fetch_op (self, cursor++);
  +    dir->num_segments = PackFile_fetch_op (self, &cursor);
       dir->segments = mem_sys_realloc (dir->segments,
               sizeof(struct PackFile_Segment *) * dir->num_segments);
   
  @@ -939,12 +1030,12 @@
           size_t tmp;
           UINTVAL type;
           const char *name;
  -        type = PackFile_fetch_op (self, cursor++);
  +        type = PackFile_fetch_op (self, &cursor);
           /* get name */
           str_len = strlen ((char *)cursor) + 1;
           name = (char *)cursor;
  +        cursor += ROUND_UP(str_len, wordsize) / sizeof(opcode_t);
   
  -        cursor += ROUND_UP(str_len, sizeof(opcode_t)) / sizeof(opcode_t);
           switch (type) {
               case PF_CONST_SEG:
                   seg = (struct PackFile_Segment *)self->const_table;
  @@ -969,10 +1060,11 @@
                   break;
           }
   
  -        seg->file_offset = PackFile_fetch_iv(self, cursor++);
  -        seg->op_count = PackFile_fetch_op(self, cursor++);
  +        seg->file_offset = PackFile_fetch_op(self, &cursor);
  +        seg->op_count = PackFile_fetch_op(self, &cursor);
   
  -        tmp = PackFile_fetch_op (self, self->src + seg->file_offset);
  +        pos = self->src + seg->file_offset;
  +        tmp = PackFile_fetch_op (self, &pos);
           if (seg->op_count != tmp) {
               fprintf (stderr,
                       "%s: Size in directory (%d) doesn't match size "
  @@ -994,7 +1086,6 @@
           cursor += 4 - (cursor - self->src) % 4;
       /* and now unpack contents of dir */
       for (i = 0; cursor && i < dir->num_segments; i++) {
  -        opcode_t *pos;
           size_t tmp = *cursor;       /* check len again */
           pos = PackFile_Segment_unpack (interpreter, dir->segments[i],
                   cursor);
  @@ -1246,8 +1337,9 @@
       char *name = (char *)cursor;
       char *code_name;
       struct PackFile_ByteCode *code;
  +    int wordsize = self->pf->header->wordsize;
   
  -    cursor += ROUND_UP(str_len, sizeof(opcode_t)) / sizeof(opcode_t);
  +    cursor += ROUND_UP(str_len, wordsize) / sizeof(opcode_t);
       str_len = strlen(self->name);
       code_name = mem_sys_allocate(str_len);
       strcpy(code_name, self->name);
  @@ -1500,7 +1592,7 @@
       PackFile_FixupTable_clear(self);
   
       pf = self->base.pf;
  -    self->fixup_count = PackFile_fetch_op(pf, cursor++);
  +    self->fixup_count = PackFile_fetch_op(pf, &cursor);
   
       if (self->fixup_count) {
           self->fixups = mem_sys_allocate_zeroed(self->fixup_count *
  @@ -1517,12 +1609,12 @@
   
       for (i = 0; i < self->fixup_count; i++) {
           self->fixups[i] = mem_sys_allocate(sizeof(struct PackFile_FixupEntry));
  -        self->fixups[i]->type = PackFile_fetch_op(pf, cursor++);
  +        self->fixups[i]->type = PackFile_fetch_op(pf, &cursor);
           switch (self->fixups[i]->type) {
               case 0:
                   self->fixups[i]->u.t0.code_seg =
  -                    PackFile_fetch_op(pf, cursor++);
  -                self->fixups[i]->u.t0.offset = PackFile_fetch_op(pf, cursor++);
  +                    PackFile_fetch_op(pf, &cursor);
  +                self->fixups[i]->u.t0.offset = PackFile_fetch_op(pf, &cursor);
                   break;
               default:
                   PIO_eprintf(interpreter,
  @@ -1618,7 +1710,7 @@
   
       PackFile_ConstTable_clear(self);
   
  -    self->const_count = PackFile_fetch_op(pf, cursor++);
  +    self->const_count = PackFile_fetch_op(pf, &cursor);
   
   #if TRACE_PACKFILE
       PIO_eprintf(interpreter,
  @@ -1799,8 +1891,8 @@
       opcode_t type;
       opcode_t size;
   
  -    type = PackFile_fetch_op(pf, cursor++);
  -    size = PackFile_fetch_op(pf, cursor++);
  +    type = PackFile_fetch_op(pf, &cursor);
  +    size = PackFile_fetch_op(pf, &cursor);
   
   #if TRACE_PACKFILE
       PIO_eprintf(NULL, "PackFile_Constant_unpack(): Type is %ld ('%c')...\n",
  @@ -1906,14 +1998,15 @@
       opcode_t encoding;
       opcode_t type;
       size_t size;
  +    int wordsize = pf->header->wordsize;
   
       /* don't let PBC mess our internals */
  -    flags = 0 ; cursor++;
  -    encoding = PackFile_fetch_op(pf, cursor++);
  -    type = PackFile_fetch_op(pf, cursor++);
  +    flags = 0; (void)PackFile_fetch_op(pf, &cursor);
  +    encoding = PackFile_fetch_op(pf, &cursor);
  +    type = PackFile_fetch_op(pf, &cursor);
   
       /* These may need to be separate */
  -    size = (size_t)PackFile_fetch_op(pf, cursor++);
  +    size = (size_t)PackFile_fetch_op(pf, &cursor);
   
   #if TRACE_PACKFILE
       PIO_eprintf(NULL, "Constant_unpack_string(): flags are 0x%04x...\n", flags);
  @@ -1930,7 +2023,7 @@
                                  flags | PObj_constant_FLAG,
                                  chartype_lookup_index(type));
   
  -    size = ROUND_UP(size, sizeof(opcode_t)) / sizeof(opcode_t);
  +    size = ROUND_UP(size, wordsize) / sizeof(opcode_t);
       return cursor + size;
   }
   
  @@ -1959,8 +2052,9 @@
       INTVAL components;
       PMC *head;
       PMC *tail;
  +    opcode_t type, op;
   
  -    components = *cursor++;
  +    components = (INTVAL)PackFile_fetch_op(pf, &cursor);
       head = tail = NULL;
   
       while (components-- > 0) {
  @@ -1974,29 +2068,31 @@
   
           tail->vtable->init(interpreter, tail);
   
  -        switch (*cursor++) {
  +        type = PackFile_fetch_op(pf, &cursor);
  +        op = PackFile_fetch_op(pf, &cursor);
  +        switch (type) {
           case PARROT_ARG_IC:
  -            key_set_integer(interpreter, tail, *cursor++);
  +            key_set_integer(interpreter, tail, op);
               break;
           case PARROT_ARG_NC:
               key_set_number(interpreter, tail,
  -                    pf->const_table->constants[*cursor++]->u.number);
  +                    pf->const_table->constants[op]->u.number);
               break;
           case PARROT_ARG_SC:
               key_set_string(interpreter, tail,
  -                pf->const_table->constants[*cursor++]->u.string);
  +                pf->const_table->constants[op]->u.string);
               break;
           case PARROT_ARG_I:
  -            key_set_register(interpreter, tail, *cursor++, KEY_integer_FLAG);
  +            key_set_register(interpreter, tail, op, KEY_integer_FLAG);
               break;
           case PARROT_ARG_N:
  -            key_set_register(interpreter, tail, *cursor++, KEY_number_FLAG);
  +            key_set_register(interpreter, tail, op, KEY_number_FLAG);
               break;
           case PARROT_ARG_S:
  -            key_set_register(interpreter, tail, *cursor++, KEY_string_FLAG);
  +            key_set_register(interpreter, tail, op, KEY_string_FLAG);
               break;
           case PARROT_ARG_P:
  -            key_set_register(interpreter, tail, *cursor++, KEY_pmc_FLAG);
  +            key_set_register(interpreter, tail, op, KEY_pmc_FLAG);
               break;
           default:
               return 0;
  
  
  
  1.2       +42 -3     parrot/t/native_pbc/number.t
  
  Index: number.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/native_pbc/number.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- number.t  28 Jan 2003 10:17:19 -0000      1.1
  +++ number.t  31 Jan 2003 07:47:30 -0000      1.2
  @@ -1,10 +1,42 @@
   #! perl -w
  +my $comment = <<'EOC';
  +
  +# these are PBC files generated from t/op/number_1.pasm with
  +# different architectures
  +# if your wordsize/floattype/endianess is not covered here
  +# please add it:
  +
  +$ cd languages/imcc
  +$ make clean && make -s
  +$ cd -
  +$ ln -s languages/imcc/imcc imcc
  +$ imcc -o n.pbc t/op/number_1.pasm
  +$ make pdump
  +$ pdump -h n.pbc
  +$ mv n.pbc t/native_pbc/number_$(N).pbc
  +
  +# then
  +# - increase number of tests
  +# - include the pdump header info for reference
  +# - put the file into MANIFEST
  +# - add the file as binary and commit it
  +# thanks -leo
  +
  +EOC
   
   use Parrot::Test tests => 2;
   use Test::More;
   
  -output_is(<<CODE, <<OUTPUT, "i386 double float 32 bit int");
  +output_is(<<CODE, <<OUTPUT, "i386 double float 32 bit opcode_t");
    # number_1.pbc
  +# HEADER => [
  +#        wordsize  = 4   (interpreter's wordsize    = 4)
  +#        byteorder = 0   (interpreter's byteorder   = 0)
  +#        floattype = 0   (interpreter's NUMVAL_SIZE = 8)
  +#        no endianize, no opcode, no numval transform
  +#        dirformat = 0
  +#]                #'
  +
   CODE
   1.000000
   4.000000
  @@ -34,8 +66,15 @@
   1125899906842620.000000
   OUTPUT
   
  -output_is(<<CODE, <<OUTPUT, "i386 long double float 32 bit int");
  +output_is(<<CODE, <<OUTPUT, "i386 long double float 32 bit opcode_t");
    # number_2.pbc
  +#HEADER => [
  +#        wordsize  = 4   (interpreter's wordsize    = 4)
  +#        byteorder = 0   (interpreter's byteorder   = 0)
  +#        floattype = 1   (interpreter's NUMVAL_SIZE = 8)
  +#        no endianize, no opcode, **need** numval transform
  +#        dirformat = 1
  +#]        #'
   CODE
   1.000000
   4.000000
  
  
  


Reply via email to