pike.git / src / program.h

version» Context lines:

pike.git/src/program.h: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: program.h,v 1.183 2003/08/02 01:07:18 mast Exp $ + || $Id: program.h,v 1.184 2003/08/03 01:02:04 mast Exp $   */      #ifndef PROGRAM_H   #define PROGRAM_H      #include <stdarg.h>   #include "global.h"   #include "pike_types.h"   #include "pike_macros.h" -  + #include "pike_error.h"   #include "svalue.h"   #include "time_stuff.h"   #include "program_id.h"   #include "block_alloc_h.h"      #define STRUCT   #include "compilation.h"      #define EXTERN   #include "compilation.h"
pike.git/src/program.h:157:    * For constants: Offset of the struct program_constant in    * program.constants in the program pointed to by prog in the struct    * inherit that corresponds to the identifier.    *    * For pike functions: Offset to the start of the function in    * program.program in the program pointed to by prog in the struct    * inherit that corresponds to the identifier. */    ptrdiff_t offset;   };    + #define IDENTIFIER_VARIABLE 0   #define IDENTIFIER_PIKE_FUNCTION 1   #define IDENTIFIER_C_FUNCTION 2   #define IDENTIFIER_FUNCTION 3   #define IDENTIFIER_CONSTANT 4 -  + #define IDENTIFIER_TYPE_MASK 7 +    #define IDENTIFIER_VARARGS 8 /* Used for functions only. */   #define IDENTIFIER_NO_THIS_REF 8 /* Used for variables only: Don't count refs to self. */   #define IDENTIFIER_HAS_BODY 16 /* Function has a body (set already in pass 1). */   #define IDENTIFIER_SCOPED 32 /* This is used for local functions only */   #define IDENTIFIER_SCOPE_USED 64 /* contains scoped local functions */   #define IDENTIFIER_ALIAS 128 /* This identifier is an alias. */      #define IDENTIFIER_IS_FUNCTION(X) ((X) & IDENTIFIER_FUNCTION)   #define IDENTIFIER_IS_PIKE_FUNCTION(X) ((X) & IDENTIFIER_PIKE_FUNCTION) -  + #define IDENTIFIER_IS_C_FUNCTION(X) ((X) & IDENTIFIER_C_FUNCTION)   #define IDENTIFIER_IS_CONSTANT(X) ((X) & IDENTIFIER_CONSTANT) - #define IDENTIFIER_IS_VARIABLE(X) (!((X) & (IDENTIFIER_FUNCTION | IDENTIFIER_CONSTANT))) + #define IDENTIFIER_IS_VARIABLE(X) (!((X) & IDENTIFIER_TYPE_MASK))   #define IDENTIFIER_IS_ALIAS(X) ((X) & IDENTIFIER_ALIAS)      #define IDENTIFIER_MASK 255      /*    * Every constant, class, function and variable    * gets exactly one of these.    */   struct identifier   {
pike.git/src/program.h:260:       /* Offset of the struct identifier in program.identifiers in the    * program pointed to by the struct inherit through inherit_offset    * above. See ID_FROM_PTR and ID_FROM_INT. */    unsigned INT16 identifier_offset;       /* ID_* flags - static, private etc.. */    INT16 id_flags;   };    + /* Magic value used as identifier reference integer to refer to this. */ + #define IDREF_MAGIC_THIS -1 +    /* Magic values in inherit.parent_offset; see below. */   #define OBJECT_PARENT -18   #define INHERIT_PARENT -17      /*    * Each program has an array of these,    * the first entry points to itself, the    * rest are from inherited programs.    * Note that when a program is inherited,    * all 'struct inherit' from that program are
pike.git/src/program.h:493:      #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) TYPE * NAME ;   #include "program_areas.h"      #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) NUMTYPE PIKE_CONCAT(num_,NAME) ;   #include "program_areas.h"       INT16 lfuns[NUM_LFUNS];   };    + #if 0 + static inline int CHECK_IDREF_RANGE (int x, const struct program *p) + { +  if (x < 0 || x >= p->num_identifier_references) +  debug_fatal ("Identifier reference index %d out of range 0..%d\n", x, +  p->num_identifier_references - 1); +  return x; + } + #else + #define CHECK_IDREF_RANGE(X,P) (X) + #endif +    #define INHERIT_FROM_PTR(P,X) (dmalloc_touch(struct program *,(P))->inherits + (X)->inherit_offset)   #define PROG_FROM_PTR(P,X) (dmalloc_touch(struct program *,INHERIT_FROM_PTR(P,X)->prog))   #define ID_FROM_PTR(P,X) (PROG_FROM_PTR(P,X)->identifiers+(X)->identifier_offset) - #define INHERIT_FROM_INT(P,X) INHERIT_FROM_PTR(P,(P)->identifier_references+(X)) - #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P,(P)->identifier_references+(X)) - #define ID_FROM_INT(P,X) ID_FROM_PTR(P,(P)->identifier_references+(X)) + #define INHERIT_FROM_INT(P,X) INHERIT_FROM_PTR(P,(P)->identifier_references+CHECK_IDREF_RANGE((X), (P))) + #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P,(P)->identifier_references+CHECK_IDREF_RANGE((X), (P))) + #define ID_FROM_INT(P,X) ID_FROM_PTR(P,(P)->identifier_references+CHECK_IDREF_RANGE((X), (P)))      #define FIND_LFUN(P,N) ( dmalloc_touch(struct program *,(P))->flags & PROGRAM_FIXED?((P)->lfuns[(N)]):low_find_lfun((P), (N)) )   #define QUICK_FIND_LFUN(P,N) (dmalloc_touch(struct program *,(P))->lfuns[N])      #define free_program(p) do{ struct program *_=(p); debug_malloc_touch(_); if(!sub_ref(_)) really_free_program(_); }while(0)      BLOCK_ALLOC_FILL_PAGES(program, n/a)         extern struct object *error_handler;