Branch: Tag:

2011-01-15

2011-01-15 15:21:04 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added predef::types() in analogue with indices() and values().

Also adds lfun::_types() and ::_types().

159:    "`[..]",    /* NOTE: After this point there are only fake lfuns. */    "_search", +  "_types",   };      struct pike_string *lfun_strings[NELEM(lfun_names)];
216:    tFuncV(tZero tRangeBound tZero tRangeBound, tVoid, tMix), /* "`[..]" */    /* NOTE: After this point there are only fake lfuns. */    tFuncV(tZero tOr(tZero, tVoid), tVoid, tMix), /* "_search", */ +  tFuncV(tNone,tVoid,tArray), /* "_types", */   };      /* These two are not true LFUNs! */
924:    *! It's assumed that this function is side-effect free.    *!    *! @seealso -  *! @[predef::indices()], @[lfun::_values()] +  *! @[predef::indices()], @[lfun::_values()], @[lfun::_types()], +  *! @[::_indices()]    */      /*! @decl array lfun::_values()
939:    *! It's assumed that this function is side-effect free.    *!    *! @seealso -  *! @[predef::values()], @[lfun::_indices()] +  *! @[predef::values()], @[lfun::_indices()], @[lfun::_types()], +  *! @[::_values()]    */      /*! @decl mixed lfun::`()(zero ... args)
1124:    *! @[predef::search()]    */    + /*! @decl array lfun::_types() +  *! +  *! List types callback. +  *! +  *! This callback is typically called via @[predef::types()]. +  *! +  *! @returns +  *! Expected to return an array with the types corresponding to +  *! the indices returned by @[lfun::_indices()]. +  *! +  *! @note +  *! It's assumed that this function is side-effect free. +  *! +  *! @note +  *! @[predef::types()] was added in Pike 7.9. +  *! +  *! @seealso +  *! @[predef::types()], @[lfun::_indices()], @[lfun::_values()], +  *! @[::_types()] +  */ +    /*! @decl mixed lfun::`symbol()    *! @decl mixed lfun::`->symbol()    *!
1845:    } else if(ident == lfun_strings[LFUN__VALUES]) {    return mknode(F_MAGIC_VALUES, mknewintnode(inherit_num),    mknewintnode(state_depth)); +  } else if(ident == lfun_strings[LFUN__TYPES]) { +  return mknode(F_MAGIC_TYPES, mknewintnode(inherit_num), +  mknewintnode(state_depth));    }    }   
6472:    return(res);   }    + struct array *program_types(struct program *p) + { +  int e; +  int n = 0; +  struct array *res; +  for (e = p->num_identifier_references; e--; ) { +  struct identifier *id; +  if (p->identifier_references[e].id_flags & +  (ID_HIDDEN|ID_PROTECTED|ID_PRIVATE)) { +  continue; +  } +  id = ID_FROM_INT(p, e); +  if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) { +  /* FIXME! +  */ +  continue; +  } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) { +  if (id->func.const_info.offset >= 0) { +  struct program *p2 = PROG_FROM_INT(p, e); +  struct svalue *val = &p2->constants[id->func.const_info.offset].sval; +  if ((val->type != T_PROGRAM) || +  !(val->u.program->flags & PROGRAM_USES_PARENT)) { +  ref_push_type_value(ID_FROM_INT(p, e)->type); +  n++; +  } +  } else { +  /* Prototype constant. */ +  ref_push_type_value(ID_FROM_INT(p, e)->type); +  n++; +  } +  } +  } +  f_aggregate(n); +  res = Pike_sp[-1].u.array; +  add_ref(res); +  pop_stack(); +  return(res); + } +    int low_program_index_no_free(struct svalue *to, struct program *p, int e,    struct object *parent, int parent_identifier)   {