pike.git / src / program.c

version» Context lines:

pike.git/src/program.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: program.c,v 1.503 2003/06/03 18:02:28 mast Exp $ + || $Id: program.c,v 1.504 2003/06/04 09:09:23 grubba Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.503 2003/06/03 18:02:28 mast Exp $"); + RCSID("$Id: program.c,v 1.504 2003/06/04 09:09:23 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "language.h"   #include "lex.h"   #include "pike_macros.h"   #include "fsort.h"
pike.git/src/program.c:1837:    tmp.u.program=p;    id=add_constant(name, &tmp, flags & ~ID_EXTERN);   #if 0    fprintf(stderr,"Compiling class %s, depth=%d\n",name->str,compilation_depth);    }else{    fprintf(stderr,"Compiling file %s, depth=%d\n",    lex.current_file ? lex.current_file->str : "-",    compilation_depth);   #endif    } -  if(compilation_depth >= 1) -  add_ref(p->parent = Pike_compiler->new_program); +     }else{    tmp.u.program=p;    add_ref(p); -  if(name) +  if((pass == 2) && name)    {    struct identifier *i;    id=isidentifier(name);    if (id < 0)    Pike_fatal("Program constant disappeared in second pass.\n");    i=ID_FROM_INT(Pike_compiler->new_program, id);    free_type(i->type);    i->type=get_type_of_svalue(&tmp);    }    } -  +  if (pass == 1) { +  if(compilation_depth >= 1) +  add_ref(p->parent = Pike_compiler->new_program); +  }    p->flags &=~ PROGRAM_VIRGIN;    Pike_compiler->parent_identifier=id;    if(idp) *idp=id;       CDFPRINTF((stderr, "th(%ld) %p low_start_new_program() %s "    "pass=%d: threads_disabled:%d, compilation_depth:%d\n",    (long)th_self(), p, name ? name->str : "-",    Pike_compiler->compiler_pass,    threads_disabled, compilation_depth));   
pike.git/src/program.c:2314:    default: return ALIGNOF(void *);    }   }      #ifdef PIKE_DEBUG      void dump_program_tables (struct program *p, int indent)   {    int d;    +  if (!p) { +  fprintf(stderr, "%*sProgram: NULL\n\n", indent, ""); +  return; +  } +     fprintf(stderr,    "%*sProgram flags: 0x%04x\n\n",    indent, "", p->flags);       fprintf(stderr,    "%*sReference table:\n"    "%*s ####: Flags Inherit Identifier\n",    indent, "", indent, "");    for (d=0; d < p->num_identifier_references; d++) {    struct reference *ref = p->identifier_references + d;
pike.git/src/program.c:3903:   #endif    case T_FUNCTION:    case T_PROGRAM:    run_time_type = T_MIXED;    }       n=low_define_variable(name,type,flags,    low_add_storage(sizeof_variable(run_time_type),    alignof_variable(run_time_type),0),    run_time_type); +     ID_FROM_INT(Pike_compiler->new_program, n)->identifier_flags |= IDENTIFIER_NO_THIS_REF;       return n;   }      PMOD_EXPORT int simple_add_variable(const char *name,    const char *type,    INT32 flags)   {    INT32 ret;
pike.git/src/program.c:4502:    add_to_identifier_references(ref);      #ifdef PROGRAM_BUILD_DEBUG    fprintf(stderr, "%.*sadded new definition #%d\n",    compilation_depth, " ", i);   #endif       return i;   }    + #if 0 +  + int add_ext_ref(struct program_state *state, struct program *target, int i) + { +  struct reference ref, *r; +  int j; +  if (state->new_program == target) return i; +  i = add_ext_ref(state->previous, target, i); +  for (r = state->new_program->identifier_references, j = 0; +  j < state->new_program->num_identifier_references; +  j++, r++) { +  if (((r->id_flags & ID_PARENT_REF|ID_STATIC|ID_PRIVATE|ID_HIDDEN) == +  ID_PARENT_REF|ID_STATIC|ID_PRIVATE|ID_HIDDEN) && +  (r->identifier_offset == i) && +  (!(r->inherit_offset))) { +  return j; +  } +  } +  ref.id_flags = ID_PARENT_REF|ID_STATIC|ID_PRIVATE|ID_HIDDEN; +  ref.identifier_offset = i; +  ref.inherit_offset = 0; +  add_to_identifier_references(ref); +  state->new_program->flags |= PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT; +  return j; + } +  + #endif /* 0 */ +    /* Identifier lookup    *    * The search algorithm has changed several times during Pike 7.3.    *    * It now (Pike 7.3.33 and later) looks up the most recent definition    * in the most recent inherit.    *    * In Pike 7.3.23 -- 7.3.32 it looked up the most recent definition    * with the least inherit depth.    *