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.
50
1999/03/
05
02
:
15
:
01
hubbe
Exp $");
+
RCSID("$Id: operators.c,v 1.
51
1999/03/
12
22
:
22
:
55
per
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"
pike.git/src/operators.c:65:
#define CALL_OPERATOR(OP, args) \ if(!sp[-args].u.object->prog) \ PIKE_ERROR(lfun_names[OP], "Called in destructed object.\n", sp, args); \ if(FIND_LFUN(sp[-args].u.object->prog,OP) == -1) \ PIKE_ERROR(lfun_names[OP], "Operator not in object.\n", sp, args); \ apply_lfun(sp[-args].u.object, OP, args-1); \ free_svalue(sp-2); \ sp[-2]=sp[-1]; \ sp--;
-
+
void f_add(INT32 args) { INT_TYPE e,size; TYPE_FIELD types; types=0; for(e=-args;e<0;e++) types|=1<<sp[e].type; switch(types) {
pike.git/src/operators.c:264:
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; }
-
case BIT_FLOAT
|
BIT_INT:
+
case BIT_FLOAT|BIT_INT:
{ FLOAT_TYPE sum; sum=0.0; for(e=-args; e<0; e++) { if(sp[e].type==T_FLOAT) { sum+=sp[e].u.float_number; }else{ sum+=(FLOAT_TYPE)sp[e].u.integer;
pike.git/src/operators.c:311:
case BIT_ARRAY: { struct array *a; a=add_arrays(sp-args,args); pop_n_elems(args); push_array(a); break; }
+
case BIT_MAPPING|BIT_INT:
+
{
+
if(IS_UNDEFINED(sp-args))
+
{
+
int e;
+
struct mapping *a;
+
+
for(e=1;e<args;e++)
+
if(sp[e-args].type != T_MAPPING)
+
error("`+: trying to add integers and mappings.\n");
+
+
a=add_mappings(sp-args+1,args-1);
+
pop_n_elems(args);
+
push_mapping(a);
+
return;
+
}
+
error("`+: trying to add integers and mappings.\n");
+
}
+
case BIT_MAPPING: { struct mapping *m; m = add_mappings(sp - args, args); pop_n_elems(args); push_mapping(m); break; }