pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:2366:    p->identifiers[i].run_time_type = T_FUNCTION;    }    }       /* Fixup identifier overrides. */    for (i = 0; i < p->num_identifier_references; i++) {    struct reference *ref = p->identifier_references + i;    if (ref->id_flags & ID_HIDDEN) continue;    if (ref->inherit_offset != 0) continue;    override_identifier (ref, ID_FROM_PTR (p, ref)->name); -  -  if ((ref->id_flags & (ID_HIDDEN|ID_PRIVATE|ID_USED)) == ID_PRIVATE) { -  yywarning("%S is private but not used anywhere.", -  ID_FROM_PTR(p, ref)->name); +     } -  } +        /* Ok, sort for binsearch */    for(e=i=0;i<(int)p->num_identifier_references;i++)    {    struct reference *funp;    struct identifier *fun;    funp=p->identifier_references+i;    if(funp->id_flags & ID_HIDDEN) continue;    fun=ID_FROM_PTR(p, funp);    if(funp->id_flags & ID_INHERITED)
pike.git/src/program.c:2489:    id = probe;    }    p->num_identifier_index = i;    }       p->flags |= PROGRAM_FIXED;       /* Yes, it is supposed to start at 1 /Hubbe */    for(i=1;i<NUM_LFUNS;i++) {    int id = p->lfuns[i] = low_find_lfun(p, i); +  if (id >= 0) { +  // LFUNs are used. +  p->identifier_references[id].id_flags |= ID_USED;    } -  +  }    -  +  /* Complain about unused private symbols. */ +  for (i = 0; i < p->num_identifier_references; i++) { +  struct reference *ref = p->identifier_references + i; +  if (ref->id_flags & ID_HIDDEN) continue; +  if (ref->inherit_offset != 0) continue; +  +  if ((ref->id_flags & (ID_HIDDEN|ID_PRIVATE|ID_USED)) == ID_PRIVATE) { +  yywarning("%S is private but not used anywhere.", +  ID_FROM_PTR(p, ref)->name); +  } +  } +     /* Set the PROGRAM_LIVE_OBJ flag by looking for destroy() and    * inherited PROGRAM_LIVE_OBJ flags. This is done at fixation time    * to allow the user to set and clear that flag while the program is    * being built. */    if (!(p->flags & PROGRAM_LIVE_OBJ)) {    int e, destroy = p->lfuns[LFUN_DESTROY];    if (destroy > -1) {    struct identifier *id = ID_FROM_INT (p, destroy);    if (!IDENTIFIER_IS_PIKE_FUNCTION (id->identifier_flags) ||    id->func.offset != -1) {
pike.git/src/program.c:4757:       fun.id_flags |= ID_INHERITED;    add_to_identifier_references(fun);    }   }      PMOD_EXPORT void do_inherit(struct svalue *s,    INT32 flags,    struct pike_string *name)   { -  struct program *p=program_from_svalue(s); -  low_inherit(p, -  TYPEOF(*s) == T_FUNCTION ? s->u.object : 0, -  TYPEOF(*s) == T_FUNCTION ? SUBTYPEOF(*s) : -1, -  0, -  flags, -  name); +  struct object *parent_obj = NULL; +  int parent_id = -1; +  struct program *p = low_program_from_svalue(s, &parent_obj, &parent_id); +  low_inherit(p, parent_obj, parent_id, 0, flags, name);   }      void compiler_do_inherit(node *n,    INT32 flags,    struct pike_string *name)   {    struct program *p;    struct identifier *i;    INT32 numid=-1, offset=0;   
pike.git/src/program.c:11008:    if(id->func.const_info.offset==-1) return 0;    f = &PROG_FROM_INT(p,i)->constants[id->func.const_info.offset].sval;    if(TYPEOF(*f) != T_PROGRAM) return 0;    return f->u.program;   }      PMOD_EXPORT struct program *program_from_function(const struct svalue *f)   {    if(TYPEOF(*f) != T_FUNCTION) return 0;    if(SUBTYPEOF(*f) == FUNCTION_BUILTIN) return 0; +     return low_program_from_function(f->u.object, SUBTYPEOF(*f));   }      /* NOTE: Does not add references to the return value! */ - PMOD_EXPORT struct program *program_from_svalue(const struct svalue *s) + PMOD_EXPORT struct program *low_program_from_svalue(const struct svalue *s, +  struct object **parent_obj, +  int *parent_id)   {    switch(TYPEOF(*s))    {    case T_OBJECT:    {    struct program *p = s->u.object->prog;   #if 0    int call_fun;   #endif   
pike.git/src/program.c:11035: Inside #if 0
  #if 0    p = p->inherits[SUBTYPEOF(*s)].prog;    if ((call_fun = FIND_LFUN(p, LFUN_CALL)) >= 0) {    /* Get the program from the return type. */    struct identifier *id = ID_FROM_INT(p, call_fun);    /* FIXME: do it. */    return 0;    }   #endif    push_svalue(s); -  f_object_program(1); -  p=program_from_svalue(Pike_sp-1); +  o_cast(program_type_string, T_PROGRAM); +  p = low_program_from_svalue(Pike_sp-1, parent_obj, parent_id);    pop_stack();    return p; /* We trust that there is a reference somewhere... */    }       case T_FUNCTION: -  return program_from_function(s); +  if (SUBTYPEOF(*s) == FUNCTION_BUILTIN) return 0; +  return low_program_from_function(*parent_obj = s->u.object, +  *parent_id = SUBTYPEOF(*s)); +     case T_PROGRAM:    return s->u.program;    default:    return 0;    }   }    -  + /* NOTE: Does not add references to the return value! */ + PMOD_EXPORT struct program *program_from_svalue(const struct svalue *s) + { +  struct object *parent_obj = NULL; +  int parent_id = -1; +  return low_program_from_svalue(s, &parent_obj, &parent_id); + } +    #define FIND_CHILD_HASHSIZE 5003   struct find_child_cache_s   {    INT32 pid,cid,id;   };      #if 0   static struct find_child_cache_s find_child_cache[FIND_CHILD_HASHSIZE];      int find_child(struct program *parent, struct program *child)