pike.git / src / encode.c

version» Context lines:

pike.git/src/encode.c:1:   /*   || 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.162 2003/06/01 18:35:12 mast Exp $ + || $Id: encode.c,v 1.163 2003/08/05 14:32:45 grubba Exp $   */      #include "global.h"   #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "mapping.h"   #include "array.h"   #include "multiset.h" -  + #include "language.h" + #include "lex.h"   #include "dynamic_buffer.h"   #include "pike_error.h"   #include "operators.h"   #include "builtin_functions.h"   #include "module_support.h"   #include "fsort.h"   #include "threads.h"   #include "stuff.h"   #include "version.h"   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.162 2003/06/01 18:35:12 mast Exp $"); + RCSID("$Id: encode.c,v 1.163 2003/08/05 14:32:45 grubba Exp $");      /* #define ENCODE_DEBUG */      /* Use the old encoding method for programs. */   #define OLD_PIKE_ENCODE_PROGRAM      #ifdef ENCODE_DEBUG   /* Pass a nonzero integer as the third arg to encode_value,    * encode_value_canonic and decode_value to activate this debug. */   #define EDB(N,X) do { debug_malloc_touch(data); if (data->debug>=N) {X;} } while (0)
pike.git/src/encode.c:1991:    low_decode_type(data); \    (X)=pop_unfinished_type(); \   } while(0)      static void cleanup_new_program_decode (int *orig_compilation_depth)   {    end_first_pass(0);    compilation_depth = *orig_compilation_depth;   }    + static void set_lex_pragmas(INT32 old_pragmas) + { +  lex.pragmas = old_pragmas; + } +    static void decode_value2(struct decode_data *data)      #ifdef PIKE_DEBUG   #undef decode_value2   #define decode_value2(X) do { struct svalue *_=Pike_sp; decode_value2_(X); if(Pike_sp!=_+1) Pike_fatal("decode_value2 failed!\n"); } while(0)   #endif         {    INT32 what, e, num, numh;
pike.git/src/encode.c:2997:    ref_push_program(p);    } else {    Pike_error("Failed to decode program.\n");    }    break;       case 4:    {    struct program *p;    ONERROR err; +  ONERROR err2;    int orig_compilation_depth;    int byteorder;    int bytecode_method;    int entry_type;    INT16 id_flags;    INT16 p_flags; -  +  INT32 old_pragmas = lex.pragmas;   #define FOO(NUMTYPE,Y,NAME) \    NUMTYPE PIKE_CONCAT(local_num_, NAME) = 0;   #include "program_areas.h"      #ifdef ENCODE_DEBUG    data->depth += 2;   #endif       /* Decode byte-order. */    decode_number(byteorder, data);
pike.git/src/encode.c:3037:    Pike_error("Unsupported byte-order. Native:%d Encoded:%d\n",    PIKE_BYTEORDER, byteorder);    }       /* Decode flags. */    decode_number(p_flags,data);    p_flags &= ~(PROGRAM_FINISHED | PROGRAM_OPTIMIZED |    PROGRAM_FIXED | PROGRAM_PASS_1_DONE);    p_flags |= PROGRAM_AVOID_CHECK;    +  /* We don't want to be affected by #pragma save_parent or +  * __pragma_save_parent__. +  */ +  lex.pragmas = (old_pragmas & ~ID_SAVE_PARENT)|ID_DONT_SAVE_PARENT; +  SET_ONERROR(err2, set_lex_pragmas, old_pragmas); +     /* Start the new program. */    orig_compilation_depth = compilation_depth;    compilation_depth = -1;    low_start_new_program(NULL, NULL, 0, NULL);    p = Pike_compiler->new_program;    -  +  /* We don't want to be affected by #pragma save_parent or +  * __pragma_save_parent__. +  */ +  lex.pragmas = (old_pragmas & ~ID_SAVE_PARENT)|ID_DONT_SAVE_PARENT; +     p->flags = p_flags;       /* Kludge to get end_first_pass() to free the program. */    Pike_compiler->num_parse_error++;       SET_ONERROR(err, cleanup_new_program_decode, &orig_compilation_depth);       debug_malloc_touch(p);       tmp.type=T_PROGRAM;
pike.git/src/encode.c:3501:    /* Fixate & optimize    *    * lfuns and identifier_index    */    if (!(p = end_first_pass(2))) {    Pike_error("Failed to decode program.\n");    }    compilation_depth = orig_compilation_depth;    push_program(p);    +  /* Restore lex.pragmas. */ +  CALL_AND_UNSET_ONERROR(err2); +     /* Verify... */   #define FOO(NUMTYPE,Y,NAME) \    if (PIKE_CONCAT(local_num_, NAME) != p->PIKE_CONCAT(num_,NAME)) { \    Pike_error("Value mismatch for num_" TOSTR(NAME) ": %d != %d\n", \    PIKE_CONCAT(local_num_, NAME), \    p->PIKE_CONCAT(num_, NAME)); \    }   #include "program_areas.h"       /* Decode the actual constants