Branch: Tag:

2002-04-26

2002-04-26 16:51:03 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Improved PROGRAM_BUILD_DEBUG.
Use ref.id_flags & ID_INHERITED instead of ref.inherit_offset to determine if a reference is inherited.
Don't overload local prototypes.
Fixes [bug 2991 (#2991)].

Rev: src/program.c:1.416

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.415 2002/04/25 10:47:40 grubba Exp $"); + RCSID("$Id: program.c,v 1.416 2002/04/26 16:51:03 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
1283:    if(fun->name==funb->name)    {    found_better=t; -  if(funa_is_prototype && funb->func.offset != -1) +  +  /* FIXME: Is this stuff needed? +  * It looks like it already is done by define_function(). +  */ +  if(funa_is_prototype && (funb->func.offset != -1) && +  !(funp->id_flags & ID_INLINE))    {    funp->inherit_offset = funpb->inherit_offset;    funp->identifier_offset = funpb->identifier_offset;
3729:       i=isidentifier(name);    + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*sexisted as identifier #%d\n", compilation_depth, "", i); + #endif +     if(i >= 0)    {    /* already defined */
3736:    funp=ID_FROM_INT(Pike_compiler->new_program, i);    ref=Pike_compiler->new_program->identifier_references[i];    -  if(ref.inherit_offset == 0) /* not inherited */ +  if(!(ref.id_flags & ID_INHERITED)) /* not inherited */    {       if( !( IDENTIFIER_IS_FUNCTION(funp->identifier_flags) &&
3757:       /* We modify the old definition if it is in this program */    -  if(ref.inherit_offset==0) +  if(!(ref.id_flags & ID_INHERITED))    {    if(func)    funp->func = *func;
3773:    free_type(funp->type);    copy_pike_type(funp->type, type);    }else{ + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*sidentifier was inherited\n", compilation_depth, ""); + #endif       if((ref.id_flags & ID_NOMASK)   #if 0
3786:       if(ref.id_flags & ID_INLINE)    { + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*sidentifier is local\n", compilation_depth, ""); + #endif +     goto make_a_new_def;    }    -  /* Otherwise we make a new definition */ +  /* Otherwise we alter the existing definition */ + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*saltering the existing definition\n", +  compilation_depth, ""); + #endif +     copy_shared_string(fun.name, name);    copy_pike_type(fun.type, type);   
3829:    if(Pike_compiler->new_program->identifier_references[z].id_flags & ID_HIDDEN)    continue;    -  /* Do not zapp inline ('local') identifiers */ -  if(Pike_compiler->new_program->identifier_references[z].inherit_offset && -  (Pike_compiler->new_program->identifier_references[z].id_flags & ID_INLINE)) +  /* Do not zapp inherited inline ('local') identifiers */ +  if((Pike_compiler->new_program->identifier_references[z].id_flags & +  (ID_INLINE|ID_INHERITED)) == (ID_INLINE|ID_INHERITED))    continue;       /* Do not zapp functions with the wrong name... */    if(ID_FROM_INT(Pike_compiler->new_program, z)->name != name)    continue;    -  + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*soverloaded reference %d (id_flags:0x%04x)\n", +  compilation_depth, "", z, +  Pike_compiler->new_program->identifier_references[z].id_flags); + #endif +     Pike_compiler->new_program->identifier_references[z]=ref;    }   
3852:    }   make_a_new_def:    + #ifdef PROGRAM_BUILD_DEBUG +  fprintf(stderr, "%.*smaking a new definition\n", compilation_depth, ""); + #endif      #ifdef PIKE_DEBUG    if(Pike_compiler->compiler_pass==2)