pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:3737:    }    default:    do_lfun_multiply:    if(call_lfun(LFUN_MULTIPLY, LFUN_RMULTIPLY))    return;       PIKE_ERROR("`*", "Bad arguments.\n", sp, 2);    }   }    +  +  +  + PMOD_EXPORT void f_exponent(INT32 args) + { +  double a, b; +  +  if(args != 2 ) +  SIMPLE_WRONG_NUM_ARGS_ERROR("`**",2); +  +  switch( TWO_TYPES(TYPEOF(sp[-2]), TYPEOF(sp[-1])) ) +  { +  case TWO_TYPES(T_FLOAT,T_FLOAT): +  a = sp[-2].u.float_number; +  b = sp[-1].u.float_number; +  goto res_is_powf; +  +  case TWO_TYPES(T_FLOAT,T_INT): +  a = sp[-2].u.float_number; +  b = (double)sp[-1].u.integer; +  goto res_is_powf; +  +  case TWO_TYPES(T_INT,T_FLOAT): +  a = (double)sp[-2].u.integer; +  b = (double)sp[-1].u.float_number; +  +  res_is_powf: +  { +  double r = pow( a, b ); +  if( r != HUGE_VAL ) +  { +  sp-=2; +  push_float( r ); +  return; +  } +  } +  /* When float overflows, switch to bignums. FIXME: mpf? */ +  /* fallthrough */ +  +  default: +  stack_swap(); +  convert_stack_top_to_bignum(); +  stack_swap(); +  /* fallthrough again (le slow path).. */ +  case TWO_TYPES(T_OBJECT,T_INT): +  case TWO_TYPES(T_OBJECT,T_OBJECT): +  if( !call_lfun( LFUN_POW, LFUN_POW ) ) +  Pike_error("Illegal argument 1 to `**.\n"); +  return; +  } +  + } +  +    /*! @decl mixed `*(mixed arg1)    *! @decl mixed `*(object arg1, mixed arg2, mixed ... extras)    *! @decl mixed `*(mixed arg1, object arg2)    *! @decl array `*(array arg1, int arg2)    *! @decl array `*(array arg1, float arg2)    *! @decl string `*(string arg1, int arg2)    *! @decl string `*(string arg1, float arg2)    *! @decl string `*(array(string) arg1, string arg2)    *! @decl array `*(array(array) arg1, array arg2)    *! @decl float `*(float arg1, int|float arg2)
pike.git/src/operators.c:5868:    /* !function(!object...:mixed)&function(mixed...:mixed)|"    "function(array(array(1=mixed)),array(1=mixed):array(1))|"    "function(int...:int)|"    "!function(int...:mixed)&function(float|int...:float)|"    "function(string*,string:string)|"    "function(array(0=mixed),int:array(0))|"    "function(array(0=mixed),float:array(0))|"    "function(string,int:string)    "function(string,float:string)    */ +  ADD_EFUN2("`**", f_exponent, +  tOr4(tFunc(tInt tInt,tInt), +  tFunc(tFloat tFloat, tFloat), +  tFunc(tInt tFloat, tFloat), +  tFunc(tFloat tInt, tFloat)), +  OPT_TRY_OPTIMIZE,0,0); +     ADD_EFUN2("`*", f_multiply,    tOr9(tIfnot(tFuncV(tNone,tNot(tOr(tObj,tMix)),tMix),    tFuncV(tNone,tOr(tMix,tVoid),tMix)),    tFunc(tArr(tArr(tSetvar(1,tMix)))    tArr(tSetvar(1,tMix)),tArr(tVar(1))),    tFuncV(tInt,tInt,tInt),    tIfnot(tFuncV(tNone,tNot(tFlt),tMix),    tFuncV(tOr(tFlt,tInt),tOr(tFlt,tInt),tFlt)),    tFunc(tArr(tStr) tStr,tStr),    tFunc(tArr(tSetvar(0,tMix)) tInt,tArr(tVar(0))),