Branch: Tag:

2001-12-14

2001-12-14 04:09:07 by Martin Stjernholm <mast@lysator.liu.se>

Fixed cleanup of supporters. Look at force_resolve in
report_compiler_dependency.

Rev: src/program.c:1.390

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.389 2001/12/13 11:05:57 mast Exp $"); + RCSID("$Id: program.c,v 1.390 2001/12/14 04:09:07 mast Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
2536:    struct inherit inherit;      #if 0 -  fprintf(stderr,"LOW_INHERIT(pid=%d, parent=%p, parid=%d, paroff=%d, flags=0x%x, name=%s);\n", -  p->id, +  fprintf(stderr,"%p low_inherit(pid=%d, parent=%p, parid=%d, " +  "paroff=%d, flags=0x%x, name=%s);\n", +  Pike_compiler->new_program, +  p ? p->id : 0,    parent,    parent_identifier,    parent_offset,
2551:    return;    }    + #ifdef PIKE_DEBUG +  if (p == placeholder_program) +  fatal("Trying to inherit placeholder_program.\n"); + #endif +     if(p->flags & PROGRAM_NEEDS_PARENT)    {    struct program_state *state=Pike_compiler;
2562:    }      #if 0 -  /* FIXME: we don't really need to set thsi flag on ALL +  /* FIXME: we don't really need to set this flag on ALL    * previous compilations, but I'm too lazy to figure out    * exactly how deep down we need to go...    */
4442:   #endif      struct Supporter *current_supporter=0; + int force_resolve = 0;         #ifdef PIKE_DEBUG
4506:    if(m->verified) return;    m->verified = 1;    -  low_verify_supporters(s->previous); -  low_verify_supporters(s->depends_on); +     low_verify_supporters(s->dependants);    low_verify_supporters(s->next_dependant);      #if 0 -  fprintf(stderr, "low_verify_supporters %p, level %d: " +  fprintf(stderr, "low_verify_supporters %p%s, level %d: "    "previous %p, depends_on %p, dependants %p, next_dependant %p\n", -  s, m->level, s->previous, s->depends_on, s->dependants, s->next_dependant); +  s, s == current_supporter ? " == current_supporter" : "", +  m->level, s->previous, s->depends_on, s->dependants, s->next_dependant);   #endif       if(s->previous && SNUM(s->previous) <= m->level)
4523:    if(s->depends_on && SNUM(s->depends_on) <= m->level)    fatal("Que, numbers out of whack2\n");    -  for(ss=s->dependants;ss;ss=ss->next_dependant) +  for(ss=s->dependants;ss;ss=ss->next_dependant) { +  if (ss->depends_on != s) +  fatal("Dependant hasn't got depends_on set properly.\n");    if(SNUM(ss) >= m->level)    fatal("Que, numbers out of whack3\n");    }    -  +  low_verify_supporters(s->previous); +  low_verify_supporters(s->depends_on); + } +    void verify_supporters()   {    if(d_flag)
4592:    verify_supporters();    if(c->depends_on)    { + #ifdef PIKE_DEBUG +  struct Supporter *s; +  for (s = c->depends_on->dependants; s; s = s->next_dependant) +  if (s == c) fatal("Dependant already linked in.\n"); + #endif    ret++;    c->next_dependant = c->depends_on->dependants;    c->depends_on->dependants=c; -  c->depends_on=0; +     }    current_supporter=c->previous;    verify_supporters();    return ret;   }    -  + void free_supporter(struct Supporter *c) + { +  verify_supporters(); +  if (c->depends_on) { +  struct Supporter **s; +  for (s = &c->depends_on->dependants; *s; s = &(*s)->next_dependant) +  if (*s == c) {*s = c->next_dependant; break;} +  c->depends_on = 0; +  } +  verify_supporters(); + } +    int call_dependants(struct Supporter *s, int finish)   {    int ok = 1;
4625:    int ret=0;    struct Supporter *c,*cc;    verify_supporters(); +  if (force_resolve) return 0;    for(cc=current_supporter;cc;cc=cc->previous)    {    if(cc->prog &&
4678:    if(c->target) free_program(c->target);    if(c->placeholder) free_object(c->placeholder);    free_svalue(& c->default_module); +  free_supporter(&c->supporter);    free((char *)c);    verify_supporters();   }