pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.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: operators.c,v 1.227 2008/02/27 23:59:18 grubba Exp $ + || $Id: operators.c,v 1.228 2008/03/22 13:50:23 grubba Exp $   */      #include "global.h"   #include <math.h>   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/operators.c:1634: Inside #if defined(AUTO_BIGNUM)
   size += sp[e].u.integer;    }    }    sp-=args;    push_int(size);   #else    size=0;    for(e=-args; e<0; e++) size+=sp[e].u.integer;    sp-=args-1;    sp[-1].u.integer=size; +  sp[-1].subtype = NUMBER_NUMBER;   #endif /* AUTO_BIGNUM */    break;       case BIT_FLOAT:    {    FLOAT_ARG_TYPE sum;    sum=0.0;    for(e=-args; e<0; e++) sum+=sp[e].u.float_number;    sp-=args-1;    sp[-1].u.float_number=sum;
pike.git/src/operators.c:2244: Inside #if defined(AUTO_BIGNUM)
  #ifdef AUTO_BIGNUM    if(INT_TYPE_SUB_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer))    {    convert_stack_top_to_bignum();    f_minus(2);    return;    }   #endif /* AUTO_BIGNUM */    sp--;    sp[-1].u.integer -= sp[0].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    return;       case T_STRING:    {    struct pike_string *s,*ret;    s=make_shared_string("");    ret=string_replace(sp[-2].u.string,sp[-1].u.string,s);    free_string(sp[-2].u.string);    free_string(sp[-1].u.string);    free_string(s);
pike.git/src/operators.c:2467:       switch(sp[-2].type)    {    case T_OBJECT:    CALL_OPERATOR(LFUN_AND,2);    break;       case T_INT:    sp--;    sp[-1].u.integer &= sp[0].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    break;       case T_MAPPING:    {    struct mapping *m;    m=merge_mappings(sp[-2].u.mapping, sp[-1].u.mapping, PIKE_ARRAY_OP_AND);    pop_n_elems(2);    push_mapping(m);    return;    }
pike.git/src/operators.c:2758:       switch(sp[-2].type)    {    case T_OBJECT:    CALL_OPERATOR(LFUN_OR,2);    break;       case T_INT:    sp--;    sp[-1].u.integer |= sp[0].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    break;       case T_MAPPING:    {    struct mapping *m;    m=merge_mappings(sp[-2].u.mapping, sp[-1].u.mapping, PIKE_ARRAY_OP_OR);    pop_n_elems(2);    push_mapping(m);    return;    }
pike.git/src/operators.c:2992:       switch(sp[-2].type)    {    case T_OBJECT:    CALL_OPERATOR(LFUN_XOR,2);    break;       case T_INT:    sp--;    sp[-1].u.integer ^= sp[0].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    break;       case T_MAPPING:    {    struct mapping *m;    m=merge_mappings(sp[-2].u.mapping, sp[-1].u.mapping, PIKE_ARRAY_OP_XOR);    pop_n_elems(2);    push_mapping(m);    return;    }
pike.git/src/operators.c:3202:    return;       if(sp[-2].type != T_INT)    SIMPLE_BAD_ARG_ERROR("`<<", 1, "int|object");    SIMPLE_BAD_ARG_ERROR("`<<", 2, "int(0..)|object");    }   #ifndef AUTO_BIGNUM    if (sp[-1].u.integer > 31) {    sp--;    sp[-1].u.integer = 0; +  sp[-1].subtype = NUMBER_NUMBER;    return;    }   #endif /* !AUTO_BIGNUM */    if (sp[-1].u.integer < 0) {    int args = 2;    SIMPLE_BAD_ARG_ERROR("`<<", 2, "int(0..)|object");    }    sp--;    sp[-1].u.integer = sp[-1].u.integer << sp->u.integer; -  +  sp[-1].subtype = NUMBER_NUMBER;   }      /*! @decl int `<<(int arg1, int arg2)    *! @decl mixed `<<(object arg1, int|object arg2)    *! @decl mixed `<<(int arg1, object arg2)    *!    *! Left shift.    *!    *! Every expression with the @expr{<<@} operator becomes a call to    *! this function, i.e. @expr{a<<b@} is the same as
pike.git/src/operators.c:3285:    (sp[-1].u.integer > 31)   #endif /* AUTO_BIGNUM */    )    {    sp--;    if (sp[-1].u.integer < 0) {    sp[-1].u.integer = -1;    } else {    sp[-1].u.integer = 0;    } +  sp[-1].subtype = NUMBER_NUMBER;    return;    }       sp--;    sp[-1].u.integer = sp[-1].u.integer >> sp->u.integer; -  +  sp[-1].subtype = NUMBER_NUMBER;   }      /*! @decl int `>>(int arg1, int arg2)    *! @decl mixed `>>(object arg1, int|object arg2)    *! @decl mixed `>>(int arg1, object arg2)    *!    *! Right shift.    *!    *! Every expression with the @expr{>>@} operator becomes a call to    *! this function, i.e. @expr{a>>b@} is the same as
pike.git/src/operators.c:3508: Inside #if defined(AUTO_BIGNUM)
   case TWO_TYPES(T_INT,T_INT):   #ifdef AUTO_BIGNUM    if(INT_TYPE_MUL_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer))    {    convert_stack_top_to_bignum();    goto do_lfun_multiply;    }   #endif /* AUTO_BIGNUM */    sp--;    sp[-1].u.integer *= sp[0].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    return;       default:    do_lfun_multiply:    if(call_lfun(LFUN_MULTIPLY, LFUN_RMULTIPLY))    return;       PIKE_ERROR("`*", "Bad arguments.\n", sp, 2);    }   }
pike.git/src/operators.c:3872:    else    tmp = sp[-2].u.integer/sp[-1].u.integer;    sp--;       /* What is this trying to solve? /Noring */    /* It fixes rounding towards negative infinity. /mast */    if((sp[-1].u.integer<0) != (sp[0].u.integer<0))    if(tmp*sp[0].u.integer!=sp[-1].u.integer)    tmp--;    sp[-1].u.integer=tmp; +  sp[-1].subtype = NUMBER_NUMBER;    return;    }       default:    PIKE_ERROR("`/", "Bad argument 1.\n", sp, 2);    }   }      /*! @decl mixed `/(object arg1, mixed arg2)    *! @decl mixed `/(mixed arg1, object arg2)
pike.git/src/operators.c:4079:    sp[-1].u.integer=((sp[-1].u.integer+~sp[0].u.integer)%-sp[0].u.integer)-~sp[0].u.integer;    }    }else{    if(sp[0].u.integer>=0)    {    sp[-1].u.integer=sp[0].u.integer+~((~sp[-1].u.integer) % sp[0].u.integer);    }else{    sp[-1].u.integer=-(-sp[-1].u.integer % -sp[0].u.integer);    }    } +  sp[-1].subtype = NUMBER_NUMBER;    return;       default:    PIKE_ERROR("`%", "Bad argument 1.\n", sp, 2);    }   }      /*! @decl mixed `%(object arg1, mixed arg2)    *! @decl mixed `%(mixed arg1, object arg2)    *! @decl string `%(string arg1, int arg2)
pike.git/src/operators.c:4167:    }    return 0;   }      PMOD_EXPORT void o_not(void)   {    switch(sp[-1].type)    {    case T_INT:    sp[-1].u.integer = !sp[-1].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    break;       case T_FUNCTION:    case T_OBJECT:    if(UNSAFE_IS_ZERO(sp-1))    {    pop_stack();    push_int(1);    }else{    pop_stack();
pike.git/src/operators.c:4249:   PMOD_EXPORT void o_compl(void)   {    switch(sp[-1].type)    {    case T_OBJECT:    CALL_OPERATOR(LFUN_COMPL,1);    break;       case T_INT:    sp[-1].u.integer = ~ sp[-1].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    break;       case T_FLOAT:    sp[-1].u.float_number = -1.0 - sp[-1].u.float_number;    break;       case T_TYPE:    type_stack_mark();    if (sp[-1].u.type->type == T_NOT) {    push_finished_type(sp[-1].u.type->car);
pike.git/src/operators.c:4381:       case T_INT:   #ifdef AUTO_BIGNUM    if(INT_TYPE_NEG_OVERFLOW(sp[-1].u.integer))    {    convert_stack_top_to_bignum();    goto do_lfun_negate;    }   #endif /* AUTO_BIGNUM */    sp[-1].u.integer = - sp[-1].u.integer; +  sp[-1].subtype = NUMBER_NUMBER;    return;       default:    PIKE_ERROR("`-", "Bad argument to unary minus.\n", sp, 1);    }   }      static void string_or_array_range (int bound_types,    struct svalue *ind,    INT_TYPE low,