Branch: Tag:

2002-04-12

2002-04-12 09:30:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Fixed type for encode_value() and encode_value_canonic().
Added byte-code relocation info.
Added new program encoding method (2).
Encoded programs should now be portable across architectures.

Rev: src/builtin_functions.c:1.357
Rev: src/encode.c:1.87
Rev: src/peep.c:1.47
Rev: src/program.c:1.310
Rev: src/program_areas.h:1.8

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.309 2002/02/06 17:26:15 grubba Exp $"); + RCSID("$Id: program.c,v 1.310 2002/04/12 09:30:13 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
248:    }   }    + void add_relocated_int_to_program(INT32 i) + { +  add_to_relocations(Pike_compiler->new_program->num_program); +  ins_int(i, (void (*)(char))add_to_program); + } +    void use_module(struct svalue *s)   {    if( (1<<s->type) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))
1310:   }   #endif    + /* finish-states: +  * +  * 0: First pass. +  * 1: Last pass. +  * 2: Called from decode_value(). +  */   struct program *end_first_pass(int finish)   {    int e;
1351:    function_type_string,    ID_STATIC);    Pike_compiler->init_node=0; +  } else if (finish == 2) { +  /* Called from decode_value(). */ +  e = low_find_lfun(Pike_compiler->new_program, LFUN___INIT);    }else{    e=-1;    }
3199:   int get_small_number(char **q)   {    /* This is a workaround for buggy cc & Tru64 */ -  int ret; -  ret=*(signed char *)*q; -  (*q)++; +  unsigned char *addr = (unsigned char *)*q; +  int ret = *((signed char *)addr); +  addr++;    switch(ret)    {    case -127: -  ret=EXTRACT_WORD((unsigned char*)*q); -  *q+=2; -  return ret; +  ret = (((signed char *)addr)[0]<<8) | addr[1]; +  addr += 2; +  break;       case -128: -  ret=EXTRACT_INT((unsigned char*)*q); -  *q+=4; -  return ret; +  ret = (((signed char *)addr)[0]<<24) | (addr[1]<<16) | +  (addr[2]<<8) | addr[3]; +  addr += 4; +  break; +  }    -  default: +  *q = (char *)addr;    return ret;   } - } +       void start_line_numbering(void)   {
3236:    add_to_linenumbers(a);    }else if(a>=-32768 && a<32768){    add_to_linenumbers(-127); -  ins_short(a, add_to_linenumbers); +  add_to_linenumbers(a>>8); +  add_to_linenumbers(a);    }else{    add_to_linenumbers(-128); -  ins_int(a, add_to_linenumbers); +  add_to_linenumbers(a>>24); +  add_to_linenumbers(a>>16); +  add_to_linenumbers(a>>8); +  add_to_linenumbers(a);    }   }