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.
39
1998/
07
/
31
20
:
15
:
11
grubba
Exp $");
+
RCSID("$Id: operators.c,v 1.
40
1998/
09
/
18
21
:
34
:
28
hubbe
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:675:
PIKE_ERROR("`&", "Bitwise and on illegal type.\n", sp, 2); } } /* This function is used to speed up or/xor/and on * arrays multisets and mappings. This is done by * calling the operator for each pair of arguments * first, then recursively doing the same on the * results until only one value remains. */
+
static void r_speedup(INT32 args, void (*func)(void))
+
{
+
int num;
+
struct svalue tmp;
+
ONERROR err;
+
+
switch(args)
+
{
+
case 3: func();
+
case 2: func();
+
case 1: return;
+
+
default:
+
r_speedup((args+1)>>1,func);
+
tmp=*--sp;
+
SET_ONERROR(err,do_free_svalue,&tmp);
+
r_speedup(args>>1,func);
+
UNSET_ONERROR(err);
+
sp++[0]=tmp;
+
func();
+
}
+
}
static void speedup(INT32 args, void (*func)(void)) { switch(sp[-args].type) {
-
case T_MAPPING:
+
case T_ARRAY: case T_MULTISET: { int e=-1; while(args > 1) { struct svalue tmp; func(); args--; e++;
pike.git/src/operators.c:702:
e=0; }else{ tmp=sp[e-args]; sp[e-args]=sp[-1]; sp[-1]=tmp; } } return; }
+
case T_MAPPING:
+
r_speedup(args,func);
+
return;
+
default: while(--args > 0) func(); } } void f_and(INT32 args) { switch(args) { case 0: PIKE_ERROR("`&", "Too few arguments.\n", sp, 0);