pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:152:    "``%",    "`+=",    "_is_type",    "_sprintf",    "_equal",    "_m_delete",    "_get_iterator",    "`[..]",    /* NOTE: After this point there are only fake lfuns. */    "_search", +  "_types",   };      struct pike_string *lfun_strings[NELEM(lfun_names)];      static struct mapping *lfun_ids;      /* mapping(string:type) */   static struct mapping *lfun_types;      static const char *const raw_lfun_types[] = {
pike.git/src/program.c:209:    tFuncV(tNone,tZero,tMix), /* "``%", */    tFuncV(tZero,tZero,tMix), /* "`+=", */    tFuncV(tStr,tVoid,tInt), /* "_is_type", */    tFuncV(tInt tOr(tMap(tStr,tInt),tVoid),tVoid,tStr), /* "_sprintf", */    tFuncV(tMix,tVoid,tInt), /* "_equal", */    tFuncV(tZero,tVoid,tMix), /* "_m_delete", */    tFuncV(tNone,tVoid,tObj), /* "_get_iterator", */    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! */   static struct pike_type *lfun_getter_type_string = NULL;   static struct pike_type *lfun_setter_type_string = NULL;      /*! @namespace lfun::    *!    *! Callback functions used to overload various builtin functions.    *!
pike.git/src/program.c:917:    *!    *! List indices callback.    *!    *! @returns    *! Expected to return an array with the valid indices in the object.    *!    *! @note    *! 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()    *!    *! List values callback.    *!    *! @returns    *! Expected to return an array with the values corresponding to    *! the indices returned by @[lfun::_indices()].    *!    *! @note    *! 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)    *!    *! Apply callback.    *!    *! @seealso    *! @[predef::`()]    */   
pike.git/src/program.c:1117:    */      /*! @decl mixed lfun::_search(mixed needle, mixed|void start)    *!    *! Search callback.    *!    *! @seealso    *! @[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()    *!    *! Variable retrieval callback (aka "getter").    *!    *! @note    *! Note that the @expr{symbol@} in the name can be any symbol.    *!    *! @note    *! This is not a true LFUN, since it is even more low level!
pike.git/src/program.c:1838:    } else if(ident == lfun_strings[LFUN_ASSIGN_ARROW] ||    ident == lfun_strings[LFUN_ASSIGN_INDEX]) {    return mknode(F_MAGIC_SET_INDEX, mknewintnode(inherit_num),    mknewintnode(state_depth));    } else if(ident == lfun_strings[LFUN__INDICES]) {    return mknode(F_MAGIC_INDICES, mknewintnode(inherit_num),    mknewintnode(state_depth));    } 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));    }    }       return NULL;   }      /* Fixme: allow level=0 to return the current level */   struct program *parent_compilation(int level)   {    struct compilation *c = THIS_COMPILATION;
pike.git/src/program.c:6465:    }    }    }    f_aggregate(n);    res = Pike_sp[-1].u.array;    add_ref(res);    pop_stack();    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)   {    struct identifier *id;    id=ID_FROM_INT(p, e);       if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {    struct external_variable_context loc;    struct object fake_object;    struct parent_info parent_info;