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.
68
1999/11/
05
01
:
31
:
41
hubbe
Exp $");
+
RCSID("$Id: operators.c,v 1.
69
1999/11/
11
15
:
20
:
56
grubba
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:439:
default: return 0; } } static node *optimize_eq(node *n) { node **first_arg, **second_arg, *ret; if(count_args(CDR(n))==2) {
-
first_arg=my_get_arg(&CDR(n), 0);
-
second_arg=my_get_arg(&
CDR
(n), 1);
+
first_arg=my_get_arg(&
_
CDR(n), 0);
+
second_arg=my_get_arg(&
_CAR
(n), 1);
#ifdef PIKE_DEBUG if(!first_arg || !second_arg) fatal("Couldn't find argument!\n"); #endif if(node_is_false(*first_arg) && !node_may_overload(*second_arg,LFUN_EQ)) { ret=*second_arg;
-
+
#ifndef SHARED_NODES
*second_arg=0;
-
+
#endif /* !SHARED_NODES */
return mkopernode("`!",ret,0); } if(node_is_false(*second_arg) && !node_may_overload(*first_arg,LFUN_EQ)) { ret=*first_arg;
-
+
#ifndef SHARED_NODES
*first_arg=0;
-
+
#endif /* !SHARED_NODES */
return mkopernode("`!",ret,0); } } return 0; } static node *optimize_not(node *n) { node **first_arg, **more_args; int e; if(count_args(CDR(n))==1) {
-
first_arg=my_get_arg(&CDR(n), 0);
+
first_arg=my_get_arg(&
_
CDR(n), 0);
#ifdef PIKE_DEBUG if(!first_arg) fatal("Couldn't find argument!\n"); #endif if(node_is_true(*first_arg)) return mkintnode(0); if(node_is_false(*first_arg)) return mkintnode(1);
-
+
#ifdef SHARED_NODES
#define TMP_OPT(X,Y) do { \ if((more_args=is_call_to(*first_arg, X))) \ { \ node *tmp=*more_args; \
-
+
return mkopernode(Y,tmp,0); \
+
} } while(0)
+
#else /* !SHARED_NODES */
+
#define TMP_OPT(X,Y) do { \
+
if((more_args=is_call_to(*first_arg, X))) \
+
{ \
+
node *tmp=*more_args; \
*more_args=0; \ return mkopernode(Y,tmp,0); \ } } while(0)
-
+
#endif /* SHARED_NODES */
TMP_OPT(f_eq, "`!="); TMP_OPT(f_ne, "`=="); TMP_OPT(f_lt, "`>="); TMP_OPT(f_gt, "`<="); TMP_OPT(f_le, "`>"); TMP_OPT(f_ge, "`<"); #undef TMP_OPT } return 0; } static node *optimize_binary(node *n) { node **first_arg, **second_arg, *ret; if(count_args(CDR(n))==2) {
-
first_arg=my_get_arg(&CDR(n), 0);
-
second_arg=my_get_arg(&CDR(n), 1);
+
first_arg=my_get_arg(&
_
CDR(n), 0);
+
second_arg=my_get_arg(&
_
CDR(n), 1);
#ifdef PIKE_DEBUG if(!first_arg || !second_arg) fatal("Couldn't find argument!\n"); #endif if((*second_arg)->type == (*first_arg)->type && compile_type_to_runtime_type((*second_arg)->type) != T_MIXED) { if((*first_arg)->token == F_APPLY && CAR(*first_arg)->token == F_CONSTANT && is_eq(& CAR(*first_arg)->u.sval, & CAR(n)->u.sval)) { ret=mknode(F_APPLY, CAR(n), mknode(F_ARG_LIST, CDR(*first_arg), *second_arg));
-
+
#ifndef SHARED_NODES
CAR(n)=0; CDR(*first_arg)=0; *second_arg=0;
-
+
#endif
/*
!SHARED_NODES
*/
return ret; } if((*second_arg)->token == F_APPLY && CAR(*second_arg)->token == F_CONSTANT && is_eq(& CAR(*second_arg)->u.sval, & CAR(n)->u.sval)) { ret=mknode(F_APPLY, CAR(n), mknode(F_ARG_LIST, *first_arg, CDR(*second_arg)));
-
+
#ifndef SHARED_NODES
CAR(n)=0; *first_arg=0; CDR(*second_arg)=0;
-
+
#endif
/*
SHARED_NODES
*/
return ret; } } } return 0; } static int generate_comparison(node *n) {