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.
73
1999/12/13
19
:
58
:
44
grubba Exp $");
+
RCSID("$Id: operators.c,v 1.
74
1999/12/13
20
:
18
:
00
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:1103:
{ struct array *a; a=merge_array_with_order(sp[-2].u.array, sp[-1].u.array, PIKE_ARRAY_OP_XOR); pop_n_elems(2); push_array(a); return; } case T_TYPE: {
-
/* a ^ b == (a&
!
b)|(
!
a&b) */
+
/* a ^ b == (a&
~
b)|(
~
a&b) */
struct pike_string *a; struct pike_string *b; copy_shared_string(a, sp[-2].u.string); copy_shared_string(b, sp[-1].u.string);
-
o_
not
();
/*
!
b */
-
o_and(); /* a&
!
b */
+
o_
compl
(); /*
~
b */
+
o_and(); /* a&
~
b */
push_string(a); sp[-1].type = T_TYPE;
-
o_
not
();
/*
!
a */
+
o_
compl
(); /*
~
a */
push_string(b); sp[-1].type = T_TYPE;
-
o_and(); /*
!
a&b */
-
o_or(); /* (a&
!
b)|(
!
a&b) */
+
o_and(); /*
~
a&b */
+
o_or(); /* (a&
~
b)|(
~
a&b) */
return; } STRING_BITOP(^,"XOR") default: PIKE_ERROR("`^", "Bitwise XOR on illegal type.\n", sp, 2); } }
pike.git/src/operators.c:1819:
if(IS_ZERO(sp-1)) { pop_stack(); push_int(1); }else{ pop_stack(); push_int(0); } break;
-
case T_TYPE:
-
type_stack_mark();
-
push_unfinished_type(sp[-1].u.string);
-
push_type(T_NOT);
-
pop_stack();
-
push_string(pop_unfinished_type());
-
sp[-1].type = T_TYPE;
-
break;
-
+
default: free_svalue(sp-1); sp[-1].type=T_INT; sp[-1].u.integer=0; } } void f_not(INT32 args) { if(args != 1) {
pike.git/src/operators.c:1871:
break; case T_INT: sp[-1].u.integer = ~ sp[-1].u.integer; break; case T_FLOAT: sp[-1].u.float_number = -1.0 - sp[-1].u.float_number; break;
+
case T_TYPE:
+
type_stack_mark();
+
push_unfinished_type(sp[-1].u.string);
+
push_type(T_NOT);
+
pop_stack();
+
push_string(pop_unfinished_type());
+
sp[-1].type = T_TYPE;
+
break;
+
case T_STRING: { struct pike_string *s; INT32 len, i; if(sp[-1].u.string->size_shift) { bad_arg_error("`~", sp-1, 1, 1, "string(0)", sp-1, "Expected 8-bit string.\n"); }
pike.git/src/operators.c:2205:
tOr3(tFunc(tArr(tOr4(tArray,tObj,tMultiset,tMapping)) tStr tSetvar(0,tMix), tVar(0)), tFunc(tOr(tObj, tMultiset) tStr tSetvar(1,tMix), tVar(1)), tFunc(tMap(tMix, tSetvar(2,tMix)) tStr tVar(2), tVar(2))), 0); /* OPT_ASSIGNMENT|OPT_TRY_OPTIMIZE); ? */ /* function(mixed...:int) */ ADD_EFUN2("`==",f_eq,tFuncV(tNone,tMix,tInt01),OPT_TRY_OPTIMIZE,optimize_eq,generate_comparison); /* function(mixed...:int) */ ADD_EFUN2("`!=",f_ne,tFuncV(tNone,tMix,tInt01),OPT_TRY_OPTIMIZE,0,generate_comparison); /* function(mixed:int) */
-
add_efun2("`!",f_not,"function(
!type
:int(0..1))
|function(type:type)
",OPT_TRY_OPTIMIZE,optimize_not,generate_not);
+
add_efun2("`!",f_not,"function(
mixed
:int(0..1))",OPT_TRY_OPTIMIZE,
+
optimize_not,generate_not);
#define CMP_TYPE "!function(!(object|mixed)...:mixed)&function(mixed...:int(0..1))|function(int|float...:int(0..1))|function(string...:int(0..1))|function(type,type,type...:int(0..1))" add_efun2("`<", f_lt,CMP_TYPE,OPT_TRY_OPTIMIZE,0,generate_comparison); add_efun2("`<=",f_le,CMP_TYPE,OPT_TRY_OPTIMIZE,0,generate_comparison); add_efun2("`>", f_gt,CMP_TYPE,OPT_TRY_OPTIMIZE,0,generate_comparison); add_efun2("`>=",f_ge,CMP_TYPE,OPT_TRY_OPTIMIZE,0,generate_comparison); ADD_EFUN2("`+",f_add, tOr7(tIfnot(tFuncV(tNone,tNot(tOr(tObj,tMix)),tMix),tFunction), tFuncV(tInt,tInt,tInt),
pike.git/src/operators.c:2291:
/* function(mixed,object:mixed)|" "function(object,mixed:mixed)|" "function(int,int:int)|" "function(string,int:string)|" "function(array(0=mixed),int:array(0))|" "!function(int,int:mixed)&function(int|float,int|float:float) */ ADD_EFUN2("`%",f_mod,tOr6(tFunc(tMix tObj,tMix),tFunc(tObj tMix,tMix),tFunc(tInt tInt,tInt),tFunc(tStr tInt,tStr),tFunc(tArr(tSetvar(0,tMix)) tInt,tArr(tVar(0))),tIfnot(tFunc(tInt tInt,tMix),tFunc(tOr(tInt,tFlt) tOr(tInt,tFlt),tFlt))), OPT_TRY_OPTIMIZE,0,generate_mod); /* function(object:mixed)|function(int:int)|function(float:float)|function(string:string) */
-
ADD_EFUN2("`~",f_compl,
tOr4
(tFunc(tObj,tMix),tFunc(tInt,tInt),tFunc(tFlt,tFlt),tFunc(tStr,tStr)),OPT_TRY_OPTIMIZE,0,generate_compl);
+
ADD_EFUN2("`~",f_compl,
+
tOr5
(tFunc(tObj,tMix),
+
tFunc(tInt,tInt),
+
tFunc(tFlt,tFlt),
+
tFunc(tStr,tStr)
,
+
tFunc(tType,tType
)
)
,
+
OPT_TRY_OPTIMIZE,0,generate_compl);
/* function(string|multiset|array|mapping|object:int) */ ADD_EFUN2("sizeof", f_sizeof,tFunc(tOr5(tStr,tMultiset,tArray,tMapping,tObj),tInt),0,0,generate_sizeof); /* function(mixed,mixed ...:mixed) */ ADD_EFUN2("`()",f_call_function,tFuncV(tMix,tMix,tMix),OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND,0,generate_call_function); /* This one should be removed */ /* function(mixed,mixed ...:mixed) */ ADD_EFUN2("call_function",f_call_function,tFuncV(tMix,tMix,tMix),OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND,0,generate_call_function);