pike.git
/
src
/
operators.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/operators.c:1:
/*\ ||| This file a part of Pike, and is copyright by Fredrik Hubinette ||| Pike is distributed as GPL (General Public License) ||| See the files COPYING and DISCLAIMER for more information. \*/ /**/ #include "global.h" #include <math.h>
-
RCSID("$Id: operators.c,v 1.
60
1999/10/
01
20
:
45
:
06
hubbe
Exp $");
+
RCSID("$Id: operators.c,v 1.
61
1999/10/
08
16
:
35
:
18
noring
Exp $");
#include "interpret.h" #include "svalue.h" #include "multiset.h" #include "mapping.h" #include "array.h" #include "stralloc.h" #include "opcodes.h" #include "operators.h" #include "language.h" #include "pike_memory.h" #include "error.h" #include "docode.h" #include "constants.h" #include "peep.h" #include "lex.h" #include "program.h" #include "object.h" #include "pike_types.h" #include "module_support.h" #include "pike_macros.h"
-
+
#include "bignum.h"
#define OP_DIVISION_BY_ZERO_ERROR(FUNC) \ math_error(FUNC, sp-2, 2, 0, "Division by zero.\n") #define OP_MODULO_BY_ZERO_ERROR(FUNC) \ math_error(FUNC, sp-2, 2, 0, "Modulo by zero.\n") #define COMPARISON(ID,NAME,FUN) \ void ID(INT32 args) \ { \ int i; \
pike.git/src/operators.c:258:
} r->len=SUBTRACT_PCHARP(buf,MKPCHARP_STR(r)); low_set_index(r,r->len,0); r=end_shared_string(r); pop_n_elems(args); push_string(r); break; } case BIT_INT:
+
#ifdef AUTO_BIGNUM
+
/* FIXME: I believe this routine is somewhat buggy... */
+
{
+
struct object *o = 0;
+
ONERROR onerr;
+
+
size = 0;
+
for(e = -args; e < 0; e++)
+
{
+
if(o)
+
apply_lfun(o, LFUN_ADD, 1);
+
else if(INT_TYPE_ADD_OVERFLOW(sp[-1].u.integer, size))
+
{
+
push_int(size);
+
o = make_bignum_object();
+
SET_ONERROR(onerr, do_free_object, o);
+
apply_lfun(o, LFUN_ADD, 1);
+
}
+
else
+
{
+
size += sp[-1].u.integer;
+
sp--;
+
}
+
}
+
+
if(o)
+
CALL_AND_UNSET_ONERROR(onerr);
+
else
+
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;
-
+
#endif /* AUTO_BIGNUM */
break; case BIT_FLOAT: { FLOAT_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; break;
pike.git/src/operators.c:1241:
return; case TWO_TYPES(T_INT,T_FLOAT): sp--; sp[-1].u.float_number= (FLOAT_TYPE) sp[-1].u.integer * (FLOAT_TYPE)sp[0].u.float_number; sp[-1].type=T_FLOAT; return; case TWO_TYPES(T_INT,T_INT):
+
#ifdef AUTO_BIGNUM
+
{
+
static int ign = 1; /* FIXME: VERY UGLY PATCH, but since I cannot
+
get through the master while loading Gmp.mpz,
+
we have to ignore that the very first mul
+
will actually overflow. */
+
+
if(!ign && INT_TYPE_MUL_OVERFLOW(sp[-2].u.integer, sp[-1].u.integer))
+
{
+
struct object *o;
+
ONERROR tmp;
+
+
o = make_bignum_object();
+
+
SET_ONERROR(tmp, do_free_object, o);
+
apply_lfun(o, LFUN_MULTIPLY, 1);
+
CALL_AND_UNSET_ONERROR(tmp);
+
return;
+
}
+
ign = 0;
+
}
+
#endif /* AUTO_BIGNUM */
sp--; sp[-1].u.integer *= sp[0].u.integer; return; default: if(call_lfun(LFUN_MULTIPLY, LFUN_RMULTIPLY)) return; PIKE_ERROR("`*", "Bad arguments.\n", sp, 2); }