Branch: Tag:

2001-09-28

2001-09-28 23:18:56 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

fix for [bug 1858 (#1858)] (this_object() in constants) and [bug 721 (#721)] (bug with final and inherit) backported from Pike 7.3

Rev: src/array.c:1.104
Rev: src/array.h:1.32
Rev: src/compilation.h:1.22
Rev: src/mapping.c:1.122
Rev: src/mapping.h:1.36
Rev: src/multiset.c:1.33
Rev: src/multiset.h:1.17
Rev: src/program.c:1.304
Rev: src/svalue.c:1.104
Rev: src/svalue.h:1.77

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.303 2001/09/02 14:45:43 grubba Exp $"); + RCSID("$Id: program.c,v 1.304 2001/09/28 23:18:55 hubbe Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
628:       Pike_compiler->new_program->flags |= PROGRAM_FIXED;    +  if(Pike_compiler->check_final) +  { +  struct program *p=Pike_compiler->new_program; +  for(i=0;i<(int)p->num_identifier_references;i++) +  { +  struct identifier *id; +  if(p->identifier_references[i].id_flags & ID_NOMASK) +  { +  struct pike_string *name=ID_FROM_INT(p, i)->name; +  +  e=find_shared_string_identifier(name,p); +  if(e != i) +  { +  if(name->len < 1024 && !name->size_shift) +  my_yyerror("Illegal to redefine final identifier %s\n",name->str); +  else +  my_yyerror("Illegal to redefine final identifier (unable to output name of identifier).\n"); +  } +  } +  } +  } +    #ifdef DEBUG_MALLOC    {   #define DBSTR(X) ((X)?(X)->str:"")
1942:       if (fun.id_flags & ID_NOMASK)    { -  int n; -  n = isidentifier(name); -  if (n != -1 && ID_FROM_INT(Pike_compiler->new_program,n)->func.offset != -1) -  my_yyerror("Illegal to redefine 'nomask' function/variable \"%s\"",name->str); +  Pike_compiler->check_final++;    }       if(fun.id_flags & ID_PRIVATE) fun.id_flags|=ID_HIDDEN;
2348:    fatal("define_constant on nonshared string.\n");   #endif    +  do { +  struct identifier *id; +  if(c && +  c->type == T_FUNCTION && +  c->subtype != FUNCTION_BUILTIN && +  c->u.object->prog) +  { +  id=ID_FROM_INT(c->u.object->prog, c->subtype); +  if(c->u.object->prog == Pike_compiler->new_program && +  !c->u.object->prog->identifier_references[c->subtype].inherit_offset) +  { +  if(id->identifier_flags & IDENTIFIER_FUNCTION) +  { +  return define_function(name, +  id->type, +  flags, +  id->identifier_flags, +  & id->func, +  id->opt_flags); +  +  } +  else if((id->identifier_flags & IDENTIFIER_CONSTANT) && +  id->func.offset != -1) +  { +  c=& Pike_compiler->new_program->constants[id->func.offset].sval; +  break; +  } +  } +  else +  { +  if((id->identifier_flags & IDENTIFIER_CONSTANT) && +  id->func.offset != -1 && +  INHERIT_FROM_INT(c->u.object->prog, c->subtype)->prog-> +  constants[id->func.offset].sval.type == T_PROGRAM) +  { +  /* In this one case we allow fake objects to enter the +  * mainstream... +  */ +  break; +  } +  } +  } +  +  if(c && !svalues_are_constant(c,1,BIT_MIXED,0)) +  yyerror("Constant values may not references this_object()"); +  +  }while(0); +     n = isidentifier(name);       /*