pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:3113:    res = low_new_check_call(Pike_sp[-args].u.type,    Pike_sp[1-args].u.type,    flags, &cs, sval);    FREE_CALL_STATE(cs);       pop_n_elems(args);    push_type_value(res);   }      /*! @decl type|zero get_return_type(type fun_type) +  *! @decl type|zero get_return_type(type fun_type, mapping state)    *!    *! Check what a function of the type @[fun_type] will -  *! return if called with no arguments. +  *! return if called with no further arguments.    *! -  +  *! @param state +  *! State mapping. This mapping may be used by attribute handlers +  *! to store state between different arguments. Note that attribute +  *! handlers may alter the contents of the mapping. +  *!    *! @returns    *! Returns the type of the returned value on success    *!    *! Returns @tt{0@} (zero) on failure.    */   static void f___get_return_type(INT32 args)   { -  +  struct call_state cs;    struct pike_type *res; -  if (args != 1) { +  struct mapping *state = NULL; +  if (args < 1) {    Pike_error("Bad number of arguments to __get_return_type().\n");    } -  if (TYPEOF(Pike_sp[-1]) != PIKE_T_TYPE) { +  if (TYPEOF(Pike_sp[-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __get_return_type() expected type.\n");    } -  if (!(res = new_get_return_type(Pike_sp[-1].u.type, 0))) { +  if (args > 1) { +  switch(TYPEOF(Pike_sp[1-args])) { +  case T_MAPPING: +  state = Pike_sp[1-args].u.mapping; +  break; +  case T_INT: +  if (!Pike_sp[1-args].u.integer) break; +  /* FALLTHRU */ +  default: +  Pike_error("Bad argument 2 to __get_return_type() expected mapping.\n"); +  } +  } +  +  LOW_INIT_CALL_STATE(cs, 1, state); +  res = new_get_return_type(Pike_sp[-args].u.type, &cs, 0); +  FREE_CALL_STATE(cs); +     pop_n_elems(args); -  push_undefined(); -  } else { -  pop_n_elems(args); +     push_type_value(res);   } - } +       /*! @decl type|zero get_first_arg_type(type fun_type)    *!    *! Check if a function of the type @[fun_type] may be called    *! with an argument, and return the type of that argument.    *!    *! @returns    *! Returns the expected type of the first argument to the function.    *!    *! Returns @tt{0@} (zero) if a function of the type @[fun_type]
pike.git/src/builtin_functions.c:10549:    OPT_TRY_OPTIMIZE);       ADD_EFUN("__low_check_call", f___low_check_call,    tFunc(tType(tCallable) tType(tMix) tOr(tInt, tVoid)    tOr(tMapping, tVoid) tOr(tMix, tVoid),    tOr(tType(tCallable), tZero)),    OPT_TRY_OPTIMIZE);       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_return_type", f___get_return_type, -  tFunc(tType(tCallable), tOr(tType(tMix), tZero)), +  tFunc(tType(tCallable) tOr(tMapping, tVoid), +  tOr(tType(tMix), tZero)),    OPT_TRY_OPTIMIZE);       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_first_arg_type", f___get_first_arg_type,    tFunc(tType(tCallable), tOr(tType(tMix), tZero)),    OPT_TRY_OPTIMIZE);       ADD_EFUN("__get_type_attributes", f___get_type_attributes,    tFunc(tType(tMix), tArr(tString)),    OPT_TRY_OPTIMIZE);