Branch: Tag:

2004-05-11

2004-05-11 11:28:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Backported some cleanups from Pike 7.6.

Rev: src/encode.c:1.171

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: encode.c,v 1.170 2004/05/11 11:09:13 grubba Exp $ + || $Id: encode.c,v 1.171 2004/05/11 11:28:52 grubba Exp $   */      #include "global.h"
32:   #include "opcodes.h"   #include "peep.h"    - RCSID("$Id: encode.c,v 1.170 2004/05/11 11:09:13 grubba Exp $"); + RCSID("$Id: encode.c,v 1.171 2004/05/11 11:28:52 grubba Exp $");      /* #define ENCODE_DEBUG */   
732:    /* This doesn't let bignums through. That's necessary as    * long as they aren't handled deterministically by the    * sort function. */ -  /* They should be hanled deterministically now - Hubbe */ +  /* They should be handled deterministically now - Hubbe */    Pike_error("Canonical encoding requires basic types in indices.\n");    }    order = get_switch_order(Pike_sp[-2].u.array);
813: Inside #if defined(AUTO_BIGNUM)
   {    code_entry(TAG_OBJECT, 2, data);    /* 256 would be better, but then negative numbers -  * doesn't work... /Hubbe +  * won't work... /Hubbe    */    push_int(36);    apply(val->u.object,"digits",1);
923:       /* Put value back in cache */    mapping_insert(data->encoded, val, &tmp); - #ifdef ENCODE_DEBUG -  data->depth -= 2; - #endif -  return; +  goto encode_done;    }    } -  Pike_error("Encoding of efuns is not supported yet.\n"); +  Pike_error("Cannot encode builtin functions.\n");    }       code_entry(TAG_FUNCTION, 0, data);
981:       /* Put value back in cache */    mapping_insert(data->encoded, val, &tmp); - #ifdef ENCODE_DEBUG -  data->depth -= 2; - #endif -  return; +  goto encode_done;    }    if( p->event_handler )    Pike_error("Cannot encode programs with event handlers.\n");
992:    }       + #ifdef OLD_PIKE_ENCODE_PROGRAM +     EDB(1, -  fprintf(stderr, "%*sencode: encoding program\n", +  fprintf(stderr, "%*sencode: encoding program in old style\n",    data->depth, ""));    - #ifdef OLD_PIKE_ENCODE_PROGRAM -  +     /* Type 1 -- Old-style encoding. */       code_entry(TAG_PROGRAM, 1, data);
1020: Inside #if defined(OLD_PIKE_ENCODE_PROGRAM)
   encode_value2(Pike_sp-1,data, 0); /**/    pop_stack();    - #define FOO(X,Y,Z) \ -  code_number( p->PIKE_CONCAT(num_,Z), data); + #define FOO(NUMTYPE,TYPE,NAME) \ +  code_number( p->PIKE_CONCAT(num_,NAME), data);   #include "program_areas.h"       code_number(PIKE_BYTECODE_METHOD, data);
1131:   #else /* !OLD_PIKE_ENCODE_PROGRAM */       /* Type 4 -- Portable encoding. */ +  EDB(1, fprintf(stderr, "%*sencode: encoding program in new style\n", +  data->depth, ""));    code_entry(type_to_tag(val->type), 4, data);       /* Byte-order. */
1154:    pop_stack();       /* num_* */ - #define FOO(X,Y,Z) \ -  code_number( p->PIKE_CONCAT(num_,Z), data); + #define FOO(NUMTYPE,TYPE,NAME) \ +  code_number( p->PIKE_CONCAT(num_,NAME), data);   #include "program_areas.h"       /* Byte-code method
1237:    d_max = p->inherits[inherit_num].identifier_ref_offset;    }    +  EDB (4, fprintf (stderr, "%*sencode: inherit_num: %d, d_max: %d\n", +  data->depth, "", inherit_num, d_max);); +     /* Fix locally defined identifiers. */    for (; d < d_max; d++) {    struct reference *ref = p->identifier_references + d;
1489:    } else {    push_int(0);    encode_value2(Pike_sp-1, data, 0); +  dmalloc_touch_svalue(Pike_sp-1);    Pike_sp--;    }    }
1503:    }    }    + encode_done:; +    #ifdef ENCODE_DEBUG    data->depth -= 2;   #endif