pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.532 2004/03/02 20:45:47 nilsson Exp $ + || $Id: builtin_functions.c,v 1.533 2004/03/07 02:05:24 nilsson Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.532 2004/03/02 20:45:47 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.533 2004/03/07 02:05:24 nilsson Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:6884: Inside #if defined(PIKE_DEBUG)
   */   PMOD_EXPORT void f__dump_backlog(INT32 args)   {    ASSERT_SECURITY_ROOT("_dump_backlog");    pop_n_elems(args);    dump_backlog();   }      #endif    - /*! @decl array map_array(array arr, function fun, mixed ... args) -  *! @decl array map_array(array(object) arr, string fun, mixed ... args) -  *! @decl array map_array(array(function) arr, int(-1..-1) minus_one, @ -  *! mixed ... args) -  *! -  *! This function is similar to @[map()]. -  *! -  *! @note -  *! This function has been deprecated in favour of @[map()]. -  *! -  *! @seealso -  *! @[map()] -  */ - PMOD_EXPORT void f_map_array(INT32 args) - { -  ONERROR tmp; -  INT32 e; -  struct svalue *fun; -  struct array *ret,*foo; -  TYPE_FIELD types; -  -  if (args < 2) -  SIMPLE_TOO_FEW_ARGS_ERROR("map_array", 2); -  -  if(Pike_sp[-args].type != T_ARRAY) -  SIMPLE_BAD_ARG_ERROR("map_array", 1, "array"); -  -  foo=Pike_sp[-args].u.array; -  fun=Pike_sp-args+1; -  -  ret=allocate_array(foo->size); -  types = 0; -  SET_ONERROR(tmp, do_free_array, ret); -  for(e=0;e<foo->size;e++) -  { -  push_svalue(ITEM(foo)+e); -  assign_svalues_no_free(Pike_sp,fun+1,args-2,-1); -  Pike_sp+=args-2; -  apply_svalue(fun,args-1); -  stack_pop_to_no_free (ITEM(ret) + e); -  types |= 1 << ITEM(ret)[e].type; -  } -  ret->type_field = types; -  pop_n_elems(args); -  UNSET_ONERROR(tmp); -  push_array(ret); - } -  +    /*! @decl mixed map(mixed arr, void|mixed fun, mixed ... extra)    *!    *! Applies @[fun] to the elements in @[arr] and collects the results.    *!    *! @[arr] is treated as a set of elements, as follows:    *!    *! @dl    *! @item array    *! @item multiset    *! @item string
pike.git/src/builtin_functions.c:7579:    SIMPLE_BAD_ARG_ERROR("filter",1,    "...|object that can be cast to array, multiset or mapping");       default:    SIMPLE_BAD_ARG_ERROR("filter",1,    "array|mapping|program|function|"    "multiset|string|object");    }   }    - /* map(), map_array() and filter() inherit sideeffects from their + /* map() and filter() inherit sideeffects from their    * second argument.    */   static node *fix_map_node_info(node *n)   {    int argno;    node **cb_;    /* Assume worst case. */    int node_info = OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND;       /* Note: argument 2 has argno 1. */    for (argno = 1; (cb_ = my_get_arg(&_CDR(n), argno)); argno++) {    node *cb = *cb_;       if ((cb->token == F_CONSTANT) &&    (cb->u.sval.type == T_FUNCTION) &&    (cb->u.sval.subtype == FUNCTION_BUILTIN)) {    if (cb->u.sval.u.efun->optimize == fix_map_node_info) { -  /* map(), map_array() or filter(). */ +  /* map() or filter(). */    continue;    }    node_info &= cb->u.sval.u.efun->flags;    }    /* FIXME: Type-checking? */    break;    }       if (!cb_) {    yyerror("Too few arguments to map() or filter()!\n");