Branch: Tag:

1999-08-20

1999-08-20 05:08:28 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

some bugfixes for modifiers

Rev: src/.cvsignore:1.17
Rev: src/Makefile.in:1.148
Rev: src/language.yacc:1.122
Rev: src/program.c:1.133
Rev: src/program.h:1.55
Rev: src/testsuite.in:1.189

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.132 1999/07/01 22:14:56 grubba Exp $"); + RCSID("$Id: program.c,v 1.133 1999/08/20 05:08:25 hubbe Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
244:    }    }    + /* fprintf(stderr,"index_module: %s\n",ident->str); */    -  +     if(SETJMP(tmp))    {    ONERROR tmp;
279:    }    UNSETJMP(tmp);    + /* fprintf(stderr,"***Undefined.\n"); */ +     return 0;   }   
294:    int n;    for(n=0;n<compilation_depth;n++,p=p->previous)    { -  int i=really_low_find_shared_string_identifier(ident, p->new_program,1); +  int i=really_low_find_shared_string_identifier(ident, +  p->new_program, +  SEE_STATIC);    if(i!=-1)    {    struct identifier *id;
496:    new_program->lfuns[i]=really_low_find_shared_string_identifier(    tmp,    new_program, -  1); +  SEE_STATIC);    }else{    new_program->lfuns[i]=-1;    }
917:    {    int id;    if(new_program->inherits[e].inherit_level!=1) continue; -  id=low_reference_inherited_identifier(0, e, s); +  id=low_reference_inherited_identifier(0, e, s, SEE_STATIC);    if(id!=-1)    {    init_node=mknode(F_ARG_LIST,
1073:      int low_reference_inherited_identifier(struct program_state *q,    int e, -  struct pike_string *name) +  struct pike_string *name, +  int flags)   {    struct program *np=q?q->new_program:new_program;    struct reference funp;
1084:    i=find_shared_string_identifier(name,p);    if(i==-1)    { -  i=really_low_find_shared_string_identifier(name,p,1); +  i=really_low_find_shared_string_identifier(name,p, flags);    if(i==-1) return -1;    }       if(p->identifier_references[i].id_flags & ID_HIDDEN)    return -1;    -  +  if(p->identifier_references[i].id_flags & ID_PRIVATE) +  if(!(flags & SEE_PRIVATE)) +  return -1; +     funp=p->identifier_references[i];    funp.inherit_offset+=e;    funp.id_flags|=ID_HIDDEN;
1135:    if(super_name != p->inherits[e].name)    continue;    -  id=low_reference_inherited_identifier(0,e,function_name); +  id=low_reference_inherited_identifier(0, +  e, +  function_name, +  SEE_STATIC);       if(id!=-1)    return mkidentifiernode(id);
1167:    if(super_name != p->inherits[e].name)    continue;    -  id=low_reference_inherited_identifier(state,e,function_name); +  id=low_reference_inherited_identifier(state,e,function_name,SEE_STATIC);       if(id!=-1)    return mkexternalnode(n,id,ID_FROM_INT(state->new_program, id));
1560:       if(n != -1)    { -  +     if (IDENTIFIERP(n)->id_flags & ID_NOMASK) -  my_yyerror("Illegal to redefine 'nomask' variable/functions \"%s\"", name->str); +  my_yyerror("Illegal to redefine 'nomask/final' variable/functions \"%s\"", name->str);       if(PROG_FROM_INT(new_program, n) == new_program)    my_yyerror("Variable '%s' defined twice.",name->str);
1572:    if(ID_FROM_INT(new_program, n)->type != type)    my_yyerror("Illegal to redefine inherited variable with different type.");    -  if(ID_FROM_INT(new_program, n)->identifier_flags != flags) +  if(!IDENTIFIER_IS_VARIABLE(ID_FROM_INT(new_program, n)->identifier_flags)) +  {    my_yyerror("Illegal to redefine inherited variable with different type."); -  +  } +  +  IDENTIFIERP(n)->id_flags = flags;    return n;    }    }
1871:    }    }    -  if((ref.id_flags & ID_NOMASK) && !(funp->func.offset == -1)) -  { -  my_yyerror("Illegal to redefine 'nomask' function %s.",name->str); -  } +        /* We modify the old definition if it is in this program */   
1887:       funp->identifier_flags=function_flags;    }else{ +  if((ref.id_flags & ID_NOMASK) + #if 0 +  && !(funp->func.offset == -1) + #endif +  ) +  { +  my_yyerror("Illegal to redefine 'nomask' function %s.",name->str); +  } +     if(ref.id_flags & ID_INLINE)    {    goto make_a_new_def;
1954:    return i;   }    -  +    int really_low_find_shared_string_identifier(struct pike_string *name,    struct program *prog, -  int see_static) +  int flags)   {    struct reference *funp;    struct identifier *fun;    int i,t;    -  CDFPRINTF((stderr,"th(%ld) Trying to find %s see_static=%d\n", -  (long)th_self(),name->str, see_static)); +  CDFPRINTF((stderr,"th(%ld) Trying to find %s flags=%d\n", +  (long)th_self(),name->str, flags));      #ifdef PIKE_DEBUG    if (!prog) {    fatal("really_low_find_shared_string_identifier(\"%s\", NULL, %d)\n" -  "prog is NULL!\n", name->str, see_static); +  "prog is NULL!\n", name->str, flags);    }   #endif /* PIKE_DEBUG */   
1978:    funp = prog->identifier_references + i;    if(funp->id_flags & ID_HIDDEN) continue;    if(funp->id_flags & ID_STATIC) -  if(!see_static) +  if(!(flags & SEE_STATIC))    continue;    fun = ID_FROM_PTR(prog, funp);    /* if(fun->func.offset == -1) continue; * Prototype */
1994:    if(t==i) continue;    funpb=prog->identifier_references+t;    if(funpb->id_flags & ID_HIDDEN) continue; -  if(funpb->id_flags & ID_STATIC) if(!see_static) continue; +  if(funpb->id_flags & ID_STATIC) +  if(!(flags & SEE_STATIC)) +  continue;    if((funpb->id_flags & ID_INHERITED) && t<i) continue;    funb=ID_FROM_PTR(prog,funpb);    /* if(funb->func.offset == -1) continue; * prototype */
2544:    int ret;    struct pike_string *name_tmp,*type_tmp;    union idptr tmp; -  + /* fprintf(stderr,"ADD_FUNC: %s\n",name); */    name_tmp=make_shared_binary_string(name,name_length);    type_tmp=make_shared_binary_string(type,type_length);