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.634 2007/04/09 15:57:40 grubba Exp $ + || $Id: builtin_functions.c,v 1.635 2007/04/20 14:39:20 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:2215:    if( !args || Pike_sp[-1].type != T_STRING ||    Pike_sp[-1].u.string->size_shift )    Pike_error( "__parse_pike_type requires a 8bit string as its first argument\n" );    t = parse_type( (char *)STR0(Pike_sp[-1].u.string) );    pop_stack();       push_string(type_to_string(t));    free_type(t);   }    + /*! @decl type __soft_cast(type to, type from) +  *! +  *! Return the resulting type from a soft cast of @[from] to @[to]. +  */ + static void f___soft_cast(INT32 args) + { +  struct pike_type *res; +  if (args < 2) Pike_error("Bad number of arguments to __low_check_call().\n"); +  if (Pike_sp[-args].type != PIKE_T_TYPE) { +  Pike_error("Bad argument 1 to __low_check_call() expected type.\n"); +  } +  if (Pike_sp[1-args].type != PIKE_T_TYPE) { +  Pike_error("Bad argument 2 to __low_check_call() expected type.\n"); +  } +  if (!(res = soft_cast(Pike_sp[-args].u.type, +  Pike_sp[1-args].u.type, 0))) { +  pop_n_elems(args); +  push_undefined(); +  } else { +  pop_n_elems(args); +  push_type_value(res); +  } + } +    /*! @decl type __low_check_call(type fun_type, type arg_type)    *! @decl type __low_check_call(type fun_type, type arg_type, int flags)    *!    *! 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
pike.git/src/builtin_functions.c:9172:    tFunc(tStr tOr(tInt,tVoid),tStr8), OPT_TRY_OPTIMIZE);      /* function(string(8),int|void:string) */    ADD_EFUN("utf8_to_string", f_utf8_to_string,    tFunc(tStr8 tOr(tInt,tVoid),tStr), OPT_TRY_OPTIMIZE);          ADD_EFUN("__parse_pike_type", f_parse_pike_type,    tFunc(tStr8,tStr8),OPT_TRY_OPTIMIZE);    +  ADD_EFUN("__soft_cast", f___soft_cast, +  tFunc(tSetvar(0, tType(tMix)) tSetvar(1, tType(tMix)), +  tAnd(tVar(0), tVar(1))), +  OPT_TRY_OPTIMIZE); +     ADD_EFUN("__low_check_call", f___low_check_call,    tFunc(tType(tCallable) tType(tMix) tOr(tInt,tVoid),    tType(tCallable)),    OPT_TRY_OPTIMIZE);       /* FIXME: Could have a stricter type. */    ADD_EFUN("__get_return_type", f___get_return_type,    tFunc(tType(tCallable), tType(tMix)),    OPT_TRY_OPTIMIZE);   
pike.git/src/builtin_functions.c:9296:    ADD_FUNCTION2("diff_dyn_longest_sequence", f_diff_dyn_longest_sequence,    tFunc(tArray tArray,tArr(tInt)), 0, OPT_TRY_OPTIMIZE);    /* function(array,array:array(array)) */    ADD_FUNCTION2("diff_compare_table", f_diff_compare_table,    tFunc(tArray tArray, tArr(tArr(tInt))), 0, OPT_TRY_OPTIMIZE);    /* function(array:array(int)) */    ADD_FUNCTION2("longest_ordered_sequence", f_longest_ordered_sequence,    tFunc(tArray,tArr(tInt)), 0, OPT_TRY_OPTIMIZE);      #define tMapStuff(IN,SUB,OUTFUN,OUTSET,OUTPROG,OUTMIX,OUTARR,OUTMAP) \ -  tOr7( tFuncV(IN tFuncV(SUB,tSetvar(0,tZero),tSetvar(2,tAny)),tVar(0), \ +  tOr6( tFuncV(IN tFuncV(SUB,tSetvar(0,tMix),tSetvar(2,tAny)),tVar(0), \    OUTFUN), \ -  tIfnot(tFuncV(tNot(IN) tFunction, tNot(tZero),tMix), \ -  tOr(tFuncV(IN tPrg(tObj), tMix, OUTPROG), \ -  tFuncV(IN tObj, tMix, OUTMIX))), \ +     tFuncV(IN tSet(tMix),tMix,OUTSET), \    tFuncV(IN tMap(tMix, tSetvar(2,tMix)), tMix, OUTMAP), \    tFuncV(IN tArray, tMix, OUTARR), \    tFuncV(IN tInt0, tMix, OUTMIX), \    tFuncV(IN, tVoid, OUTMIX) )       ADD_EFUN2("map", f_map,    tOr7(tMapStuff(tArr(tSetvar(1,tMix)),tVar(1),    tArr(tVar(2)),    tArr(tInt01),