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.187 2004/04/06 13:00:45 nilsson Exp $
+ || $Id: operators.c,v 1.188 2004/04/06 15:37:55 nilsson Exp $
*/
#include "global.h"
#include <math.h>
- RCSID("$Id: operators.c,v 1.187 2004/04/06 13:00:45 nilsson Exp $");
+ RCSID("$Id: operators.c,v 1.188 2004/04/06 15:37:55 nilsson 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:748:
{
struct pike_type *itype;
INT32 run_time_itype;
push_type_value(itype = key_type(type, 0));
run_time_itype = compile_type_to_runtime_type(itype);
if(run_time_itype != T_MIXED)
{
struct multiset *m;
- #ifdef PIKE_NEW_MULTISETS
+
struct multiset *tmp=sp[-2].u.multiset;
- #else
- struct array *tmp=sp[-2].u.multiset->ind;
- #endif
+
DECLARE_CYCLIC();
if((m=(struct multiset *)BEGIN_CYCLIC(tmp,0)))
{
ref_push_multiset(m);
}else{
#ifdef PIKE_DEBUG
struct svalue *save_sp=sp+1;
#endif
- #ifdef PIKE_NEW_MULTISETS
+
ptrdiff_t nodepos;
if (multiset_indval (tmp))
Pike_error ("FIXME: Casting not implemented for multisets with values.\n");
push_multiset (m = allocate_multiset (multiset_sizeof (tmp),
multiset_get_flags (tmp),
multiset_get_cmp_less (tmp)));
SET_CYCLIC_RET(m);
if ((nodepos = multiset_first (tmp)) >= 0) {
pike.git/src/operators.c:786: Inside #if defined(PIKE_NEW_MULTISETS)
do {
push_multiset_index (tmp, nodepos);
o_cast(itype, run_time_itype);
multiset_insert_2 (m, sp - 1, NULL, 0);
pop_stack();
} while ((nodepos = multiset_next (tmp, nodepos)) >= 0);
UNSET_ONERROR (uwp);
sub_msnode_ref (tmp);
}
- #else /* PIKE_NEW_MULTISETS */
- INT32 e;
- struct array *a;
- TYPE_FIELD types = 0;
- push_multiset(m=allocate_multiset(a=allocate_array(tmp->size)));
-
- SET_CYCLIC_RET(m);
-
- for(e=0;e<a->size;e++)
- {
- push_svalue(tmp->item+e);
- o_cast(itype, run_time_itype);
- stack_pop_to_no_free (ITEM(a) + e);
- types |= 1 << ITEM(a)[e].type;
- }
- a->type_field = types;
- order_multiset(m);
- #endif
-
+
#ifdef PIKE_DEBUG
if(save_sp!=sp)
Pike_fatal("o_cast left stack droppings.\n");
#endif
}
END_CYCLIC();
assign_svalue(sp-3,sp-1);
pop_stack();
}
pop_stack();
pike.git/src/operators.c:1859:
sp[-1].u.array,
PIKE_ARRAY_OP_SUB);
pop_n_elems(2);
push_mapping(m);
return;
}
case T_MULTISET:
{
struct mapping *m;
- #ifdef PIKE_NEW_MULTISETS
+
int got_cmp_less = !!multiset_get_cmp_less (sp[-1].u.multiset);
struct array *ind = multiset_indices (sp[-1].u.multiset);
pop_stack();
push_array (ind);
if (got_cmp_less)
m=merge_mapping_array_unordered(sp[-2].u.mapping,
sp[-1].u.array,
PIKE_ARRAY_OP_SUB);
else
m=merge_mapping_array_ordered(sp[-2].u.mapping,
sp[-1].u.array,
PIKE_ARRAY_OP_SUB);
- #else
- m=merge_mapping_array_ordered(sp[-2].u.mapping,
- sp[-1].u.multiset->ind,
- PIKE_ARRAY_OP_SUB);
- #endif
-
+
pop_n_elems(2);
push_mapping(m);
return;
}
}
bad_arg_error("`-", sp-2, 2, 2, get_name_of_type(sp[-2].type),
sp-1, "Subtract on different types.\n");
}
pike.git/src/operators.c:2125:
sp[-1].u.array,
PIKE_ARRAY_OP_AND);
pop_n_elems(2);
push_mapping(m);
return;
}
case T_MULTISET:
{
struct mapping *m;
- #ifdef PIKE_NEW_MULTISETS
+
int got_cmp_less = !!multiset_get_cmp_less (sp[-1].u.multiset);
struct array *ind = multiset_indices (sp[-1].u.multiset);
pop_stack();
push_array (ind);
if (got_cmp_less)
m=merge_mapping_array_unordered(sp[-2].u.mapping,
sp[-1].u.array,
PIKE_ARRAY_OP_AND);
else
m=merge_mapping_array_ordered(sp[-2].u.mapping,
sp[-1].u.array,
PIKE_ARRAY_OP_AND);
- #else
- m=merge_mapping_array_ordered(sp[-2].u.mapping,
- sp[-1].u.multiset->ind,
- PIKE_ARRAY_OP_AND);
- #endif
-
+
pop_n_elems(2);
push_mapping(m);
return;
}
default:
{
int args = 2;
SIMPLE_BAD_ARG_ERROR("`&", 2, "mapping");
}
}
pike.git/src/operators.c:2310:
r_speedup(args>>1,func);
UNSET_ONERROR(err);
sp++[0]=tmp;
func();
}
}
static void speedup(INT32 args, void (*func)(void))
{
switch(sp[-args].type)
{
- /* This method can be used for types where a op b === b op a */
- case T_MULTISET:
- #ifndef PIKE_NEW_MULTISETS
- {
- int e=-1;
- while(args > 1)
- {
- struct svalue tmp;
- func();
- args--;
- e++;
- if(e - args >= -1)
- {
- e=0;
- }else{
- tmp=sp[e-args];
- sp[e-args]=sp[-1];
- sp[-1]=tmp;
- }
- }
- return;
- }
- #endif
-
+
/* Binary balanced tree method for types where
* a op b may or may not be equal to b op a
*/
case T_ARRAY:
case T_MAPPING:
r_speedup(args,func);
return;
default:
while(--args > 0) func();