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.
90
2000/04/
12
16
:
55
:
56
grubba
Exp $");
+
RCSID("$Id: operators.c,v 1.
91
2000/04/
20
02
:
41
:
45
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:429:
static int generate_sum(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),0); return 1; case 2: do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_ADD);
+
emit0
(F_ADD);
return 1; default: return 0; } } static node *optimize_eq(node *n) { node **first_arg, **second_arg, *ret;
pike.git/src/operators.c:574:
static int generate_comparison(node *n) { if(count_args(CDR(n))==2) { if(do_docode(CDR(n),DO_NOT_COPY) != 2) fatal("Count args was wrong in generate_comparison.\n"); if(CAR(n)->u.sval.u.efun->function == f_eq)
-
emit2
(F_EQ);
+
emit0
(F_EQ);
else if(CAR(n)->u.sval.u.efun->function == f_ne)
-
emit2
(F_NE);
+
emit0
(F_NE);
else if(CAR(n)->u.sval.u.efun->function == f_lt)
-
emit2
(F_LT);
+
emit0
(F_LT);
else if(CAR(n)->u.sval.u.efun->function == f_le)
-
emit2
(F_LE);
+
emit0
(F_LE);
else if(CAR(n)->u.sval.u.efun->function == f_gt)
-
emit2
(F_GT);
+
emit0
(F_GT);
else if(CAR(n)->u.sval.u.efun->function == f_ge)
-
emit2
(F_GE);
+
emit0
(F_GE);
else fatal("Couldn't generate comparison!\n"); return 1; } return 0; } static int float_promote(void) { if(sp[-2].type==T_INT && sp[-1].type==T_FLOAT)
pike.git/src/operators.c:807:
} } } static int generate_minus(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_NEGATE);
+
emit0
(F_NEGATE);
return 1; case 2: do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_SUBTRACT);
+
emit0
(F_SUBTRACT);
return 1; } return 0; } void o_and(void) { if(sp[-1].type != sp[-2].type) { if(call_lfun(LFUN_AND, LFUN_RAND))
pike.git/src/operators.c:1111:
static int generate_and(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),0); return 1; case 2: do_docode(CDR(n),0);
-
emit2
(F_AND);
+
emit0
(F_AND);
return 1; default: return 0; } } void o_or(void) { if(sp[-1].type != sp[-2].type)
pike.git/src/operators.c:1285:
static int generate_or(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),0); return 1; case 2: do_docode(CDR(n),0);
-
emit2
(F_OR);
+
emit0
(F_OR);
return 1; default: return 0; } } void o_xor(void) {
pike.git/src/operators.c:1464:
static int generate_xor(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),0); return 1; case 2: do_docode(CDR(n),0);
-
emit2
(F_XOR);
+
emit0
(F_XOR);
return 1; default: return 0; } } void o_lsh(void) { #ifdef AUTO_BIGNUM
pike.git/src/operators.c:1507:
SIMPLE_TOO_FEW_ARGS_ERROR("`<<", 2); } o_lsh(); } static int generate_lsh(node *n) { if(count_args(CDR(n))==2) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_LSH);
+
emit0
(F_LSH);
return 1; } return 0; } void o_rsh(void) { if(sp[-2].type != T_INT || sp[-1].type != T_INT) { int args = 2;
pike.git/src/operators.c:1552:
SIMPLE_TOO_FEW_ARGS_ERROR("`>>", 2); } o_rsh(); } static int generate_rsh(node *n) { if(count_args(CDR(n))==2) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_RSH);
+
emit0
(F_RSH);
return 1; } return 0; } #define TWO_TYPES(X,Y) (((X)<<8)|(Y)) void o_multiply(void) { int args = 2;
pike.git/src/operators.c:1688:
static int generate_multiply(node *n) { switch(count_args(CDR(n))) { case 1: do_docode(CDR(n),0); return 1; case 2: do_docode(CDR(n),0);
-
emit2
(F_MULTIPLY);
+
emit0
(F_MULTIPLY);
return 1; default: return 0; } } void o_divide(void) { if(sp[-2].type!=sp[-1].type && !float_promote())
pike.git/src/operators.c:1980:
pop_n_elems(sp-s-1); } } } static int generate_divide(node *n) { if(count_args(CDR(n))==2) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_DIVIDE);
+
emit0
(F_DIVIDE);
return 1; } return 0; } void o_mod(void) { if(sp[-2].type != sp[-1].type && !float_promote()) { if(call_lfun(LFUN_MOD, LFUN_RMOD))
pike.git/src/operators.c:2103:
SIMPLE_TOO_FEW_ARGS_ERROR("`%", 2); } o_mod(); } static int generate_mod(node *n) { if(count_args(CDR(n))==2) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_MOD);
+
emit0
(F_MOD);
return 1; } return 0; } void o_not(void) { switch(sp[-1].type) { case T_INT:
pike.git/src/operators.c:2150:
SIMPLE_TOO_FEW_ARGS_ERROR("`!", 1); } o_not(); } static int generate_not(node *n) { if(count_args(CDR(n))==1) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_NOT);
+
emit0
(F_NOT);
return 1; } return 0; } void o_compl(void) { switch(sp[-1].type) { case T_OBJECT:
pike.git/src/operators.c:2242:
SIMPLE_TOO_FEW_ARGS_ERROR("`~", 1); } o_compl(); } static int generate_compl(node *n) { if(count_args(CDR(n))==1) { do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_COMPL);
+
emit0
(F_COMPL);
return 1; } return 0; } void o_negate(void) { switch(sp[-1].type) { case T_OBJECT:
pike.git/src/operators.c:2437:
pop_n_elems(args); push_int(tmp); } static int generate_sizeof(node *n) { node **arg; if(count_args(CDR(n)) != 1) return 0; if(do_docode(CDR(n),DO_NOT_COPY) != 1) fatal("Count args was wrong in sizeof().\n");
-
emit2
(F_SIZEOF);
+
emit0
(F_SIZEOF);
return 1; } static int generate_call_function(node *n) { node **arg;
-
emit2
(F_MARK);
+
emit0
(F_MARK);
do_docode(CDR(n),DO_NOT_COPY);
-
emit2
(F_CALL_FUNCTION);
+
emit0
(F_CALL_FUNCTION);
return 1; } struct program *string_assignment_program; #undef THIS #define THIS ((struct string_assignment_storage *)(CURRENT_STORAGE)) static void f_string_assignment_index(INT32 args) { INT32 i;