pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:3035:    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }   }      /*! @decl type|zero low_check_call(type fun_type, type arg_type)    *! @decl type|zero low_check_call(type fun_type, type arg_type, int flags) +  *! @decl type|zero low_check_call(type fun_type, type arg_type, int flags, @ +  *! mapping state) +  *! @decl type|zero low_check_call(type fun_type, type arg_type, int flags, @ +  *! mapping state, mixed val)    *!    *! Check whether a function of type @[fun_type] may be called    *! with a first argument of type @[arg_type].    *!    *! @param flags    *! The following flags are currently defined:    *! @int    *! @value 1    *! Strict types. Fail if not all possible values in @[arg_type]    *! are valid as the first argument to @[fun_type].    *! @value 2    *! Last argument. @[arg_type] is the last argument to @[fun_type].    *! @value 3    *! Both strict types and last argument as above.    *! @endint    *! -  +  *! @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. +  *! +  *! @param val +  *! Value of the argument if known. +  *!    *! @returns    *! Returns a continuation type on success.    *!    *! Returns @tt{0@} (zero) on failure.    */   static void f___low_check_call(INT32 args)   {    struct pike_type *res;    INT32 flags = CALL_NOT_LAST_ARG;    struct call_state cs;    struct svalue *sval = NULL; -  +  struct mapping *state = NULL;    if (args < 2) Pike_error("Bad number of arguments to __low_check_call().\n");    if (TYPEOF(Pike_sp[-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 1 to __low_check_call() expected type.\n");    }    if (TYPEOF(Pike_sp[1-args]) != PIKE_T_TYPE) {    Pike_error("Bad argument 2 to __low_check_call() expected type.\n");    }    if (args > 2) {    if (TYPEOF(Pike_sp[2-args]) != PIKE_T_INT) {    Pike_error("Bad argument 3 to __low_check_call() expected int.\n");    }    flags = Pike_sp[2-args].u.integer ^ CALL_NOT_LAST_ARG;    } -  if (args > 3) sval = Pike_sp + 3 - args; -  LOW_INIT_CALL_STATE(cs, 1, NULL); +  if (args > 3) { +  switch(TYPEOF(Pike_sp[3-args])) { +  case T_MAPPING: +  state = Pike_sp[3-args].u.mapping; +  break; +  case T_INT: +  if (!Pike_sp[3-args].u.integer) break; +  /* FALLTHRU */ +  default: +  Pike_error("Bad argument 3 to __low_check_call() expected mapping.\n"); +  } +  } +  if (args > 4) sval = Pike_sp + 4 - args; +  LOW_INIT_CALL_STATE(cs, 1, state);    if (!(res = low_new_check_call(Pike_sp[-args].u.type,    Pike_sp[1-args].u.type,    flags, &cs, sval))) {    pop_n_elems(args);    push_undefined();    } else {    pop_n_elems(args);    push_type_value(res);    }    FREE_CALL_STATE(cs);