pike.git / src / program.h

version» Context lines:

pike.git/src/program.h:418:    *    * Note that the struct inherit for the program that directly    * inherited the program represented by this struct inherit can be    * found by going backwards in program.inherits from this struct    * until one is found with an inherit_level less than this one. */    INT16 inherit_level;       /* All the identifier references in the inherited program have been    * copied to this program with the first one at this offset. */    INT16 identifier_level; +  /* TODO: why is this signed. */       /* The index of the identifier reference in the parent program for    * the identifier from which this inherit was done. -1 if there's no    * such thing. It's always -1 in the inherit struct for the top    * level program. */    INT16 parent_identifier;       /* Describes how to find the parent object for the external    * identifier references associated with this inherit:    *
pike.git/src/program.h:659:   #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];   };      PMOD_EXPORT void dump_program_tables (const struct program *p, int indent); +  + PIKE_UNUSED_ATTRIBUTE + static inline unsigned INT16 CHECK_IDREF_RANGE(unsigned INT16 x, const struct program *p) {   #ifdef PIKE_DEBUG - static inline int PIKE_UNUSED_ATTRIBUTE CHECK_IDREF_RANGE (int x, const struct program *p) - { -  if (x < 0 || x >= p->num_identifier_references) { +  if (x >= p->num_identifier_references) {    dump_program_tables(p, 4);    debug_fatal ("Identifier reference index %d out of range 0..%d\n", x,    p->num_identifier_references - 1);    } -  + #endif    return x;   } - #else - #define CHECK_IDREF_RANGE(X, P) (X) - #endif +     - #define PTR_FROM_INT(P, X) ((P)->identifier_references + \ -  CHECK_IDREF_RANGE((X), (P))) + static inline struct reference *PTR_FROM_INT(const struct program *p, unsigned INT16 x) { +  x = CHECK_IDREF_RANGE(x, p); +  return p->identifier_references + x; + }    - #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, PTR_FROM_INT(P, X)) - #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P, PTR_FROM_INT(P, X)) - #define ID_FROM_INT(P,X) ID_FROM_PTR(P, PTR_FROM_INT(P, X)) + static inline struct inherit *INHERIT_FROM_PTR(const struct program *p, const struct reference *x) { +  return dmalloc_touch(struct program *,p)->inherits + x->inherit_offset; + }    -  + static inline struct program *PROG_FROM_PTR(const struct program *p, const struct reference *x) { +  return dmalloc_touch(struct program *, INHERIT_FROM_PTR(p,x)->prog); + } +  + static inline struct identifier *ID_FROM_PTR(const struct program *p, const struct reference *x) { +  return PROG_FROM_PTR(p,x)->identifiers + x->identifier_offset; + } +  + static inline struct inherit *INHERIT_FROM_INT(const struct program *p, const unsigned INT16 x) { +  struct reference *ref = PTR_FROM_INT(p, x); +  return INHERIT_FROM_PTR(p, ref); + } +  + static inline struct program *PROG_FROM_INT(const struct program *p, const unsigned INT16 x) { +  struct reference *ref = PTR_FROM_INT(p, x); +  return PROG_FROM_PTR(p, ref); + } +  + static inline struct identifier *ID_FROM_INT(const struct program *p, unsigned INT16 x) { +  struct reference *ref = PTR_FROM_INT(p, x); +  return ID_FROM_PTR(p, ref); + } +    #define QUICK_FIND_LFUN(P,N) (dmalloc_touch(struct program *,(P))->lfuns[N])      #ifdef DO_PIKE_CLEANUP   PMOD_EXPORT extern int gc_external_refs_zapped;   PMOD_EXPORT void gc_check_zapped (void *a, TYPE_T type, const char *file, INT_TYPE line);   #endif      #if defined (USE_DLL) && defined (DYNAMIC_MODULE)   /* Use the function in modules so we don't have to export the block    * alloc stuff. */