pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:11464:   }      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));   }    + static const struct pike_type *is_subtyped_object_type(struct pike_type *t) + { +  if ((t->type == T_OBJECT) && t->cdr) return t; +  return NULL; + } +  + PMOD_EXPORT struct program *program_from_type(const struct pike_type *t) + { +  t = find_type(t, is_subtyped_object_type); +  if (!t) return NULL; +  return id_to_program((int)(ptrdiff_t)t->cdr); + } +    /* NOTE: Does not add references to the return value! */   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;
pike.git/src/program.c:11503:    return p; /* We trust that there is a reference somewhere... */    }       case T_FUNCTION:    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; +  +  case PIKE_T_TYPE: +  return program_from_type(s->u.type); +     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;