pike.git / src / interpret.c

version» Context lines:

pike.git/src/interpret.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: interpret.c,v 1.365 2005/12/31 03:37:14 nilsson Exp $ + || $Id: interpret.c,v 1.366 2006/01/20 17:55:50 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "object.h"   #include "program.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "pike_error.h"
pike.git/src/interpret.c:567:   #else   #define TRACE(X)   #endif      static struct inherit dummy_inherit   #ifdef PIKE_DEBUG    = {-4711, -4711, -4711, -4711, (size_t) -4711, -4711, NULL, NULL, NULL}   #endif   ;    + /* Find the lexical scope @[depth] levels out. +  * +  * @[loc]: +  * Input: +  * struct object *o // object to start from. +  * struct inherit *inherit // inherit in o->prog. +  * int parent_identifier // identifier in o to start from. +  * +  * Output: +  * struct object *o // object containing the scope. +  * struct inherit *inherit // inherit in o->prog being the scope. +  * int parent_identifier // identifier in o from the inherit. +  */   PMOD_EXPORT void find_external_context(struct external_variable_context *loc,    int depth)   {    struct program *p;       TRACE((4, "-find_external_context(%d, inherit=%ld)\n", depth,    DO_NOT_WARN((long)(loc->o->prog ? loc->inherit - loc->o->prog->inherits : 0))));      #ifdef PIKE_DEBUG    if(!loc->o)
pike.git/src/interpret.c:629:       TRACE((4,"- o->parent_identifier=%d inherit->identifier_level=%d\n",    (p->flags & PROGRAM_USES_PARENT) ?    LOW_PARENT_INFO(loc->o, p)->parent_identifier : -1,    inh->identifier_level));       switch(inh->parent_offset)    {    default:    { +  /* Find the program that inherited us. */    int my_level = inh->inherit_level;   #ifdef PIKE_DEBUG    if(!my_level)    Pike_fatal("Gahhh! inherit level zero in wrong place!\n");   #endif    while(loc->inherit->inherit_level >= my_level)    { -  TRACE((5,"- inherit-- (%d >= %d)\n",loc->inherit->inherit_level, my_level)); +  TRACE((5,"- inherit-- (%d >= %d)\n", +  loc->inherit->inherit_level, my_level));    loc->inherit--; -  +  TRACE((5, "- identifier_level: %d\n", +  loc->inherit->identifier_level));    }       find_external_context(loc, inh->parent_offset); -  +  TRACE((5, +  "- inh->parent_identifier: %d\n" +  "- inh->identifier_level: %d\n" +  "- loc->parent_identifier: %d\n" +  "- loc->inherit->parent_offset: %d\n" +  "- loc->inherit->identifier_level: %d\n", +  inh->parent_identifier, +  inh->identifier_level, +  loc->parent_identifier, +  loc->inherit->parent_offset, +  loc->inherit->identifier_level)); +     loc->parent_identifier =    inh->parent_identifier +    loc->inherit->identifier_level; -  +  TRACE((5, "- parent_identifier: %d\n", loc->parent_identifier));    }    break;       case INHERIT_PARENT:    TRACE((5,"- Following inherit->parent\n"));    loc->parent_identifier=inh->parent_identifier;    loc->o=inh->parent; -  + #ifdef PIKE_DEBUG +  TRACE((5, "- parent_identifier: %d\n" +  "- o: %p\n" +  "- inh: %d\n", +  loc->parent_identifier, +  loc->o, +  loc->inherit - loc->o->prog->inherits)); +  if(Pike_interpreter.trace_level>5) { +  dump_program_tables(loc->o->prog, 4); +  } + #endif    break;       case OBJECT_PARENT:    TRACE((5,"- Following o->parent\n"));      #ifdef PIKE_DEBUG    /* Can this happen legitimately? Well, someone will hopefully    * let me know in that case. /mast */    if (!(p->flags & PROGRAM_USES_PARENT))    Pike_fatal ("Attempting to access parent of object without parent pointer.\n");   #endif       loc->parent_identifier=LOW_PARENT_INFO(loc->o,p)->parent_identifier;    loc->o=LOW_PARENT_INFO(loc->o,p)->parent; -  + #ifdef PIKE_DEBUG +  TRACE((5, "- parent_identifier: %d\n" +  "- o: %p\n", +  loc->parent_identifier, +  loc->o)); +  if(Pike_interpreter.trace_level>5) { +  dump_program_tables(loc->o->prog, 4); +  } + #endif    break;    }      #ifdef PIKE_DEBUG    /* I don't think this should happen either. The gc doesn't zap the    * pointer even if the object is destructed, at least. /mast */    if (!loc->o) Pike_fatal ("No parent object.\n");   #endif       p = loc->o->prog;
pike.git/src/interpret.c:699:   #endif /* DEBUG_MALLOC */       if (p) {   #ifdef PIKE_DEBUG    if(loc->parent_identifier < 0 ||    loc->parent_identifier > p->num_identifier_references)    Pike_fatal("Identifier out of range, loc->parent_identifer=%d!\n",    loc->parent_identifier);   #endif    loc->inherit=INHERIT_FROM_INT(p, loc->parent_identifier); +  TRACE((5, "- loc->inherit: %d\n", +  loc->inherit - loc->o->prog->inherits));    }    else    /* Return a valid pointer to a dummy inherit for the convenience    * of the caller. Identifier offsets will be bogus but it'll    * never get to that since the object is destructed. */    loc->inherit = &dummy_inherit;       TRACE((5,"- Parent identifier = %d (%s), inherit # = %ld\n",    loc->parent_identifier,    p ? ID_FROM_INT(p, loc->parent_identifier)->name->str : "N/A",