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 <math.h> #include "global.h"
-
RCSID("$Id: operators.c,v 1.
9
1997/
02
/
19
05
:
04
:
19
hubbe Exp $");
+
RCSID("$Id: operators.c,v 1.
10
1997/
03
/
08
12
:
54
:
07
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 "memory.h"
pike.git/src/operators.c:1210:
free_array(sp[-1].u.array); sp[-1].u.array=a; break; } default: error("[ .. ] on non-scalar type.\n"); } }
+
void f_index(INT32 args)
+
{
+
switch(args)
+
{
+
case 0:
+
case 1:
+
error("Too few arguments to `[]\n");
+
break;
+
case 2:
+
if(sp[-1].type==T_STRING) sp[-1].subtype=0;
+
o_index();
+
break;
+
case 3:
+
o_range();
+
break;
+
default:
+
error("Too manu arguments to `[]\n");
+
}
+
}
+
+
void f_arrow(INT32 args)
+
{
+
switch(args)
+
{
+
case 0:
+
case 1:
+
error("Too few arguments to `->\n");
+
break;
+
case 2:
+
if(sp[-1].type==T_STRING)
+
sp[-1].subtype=1;
+
o_index();
+
break;
+
default:
+
error("Too manu arguments to `->\n");
+
}
+
}
+
void f_sizeof(INT32 args) { INT32 tmp; if(args<1) error("Too few arguments to sizeof()\n"); tmp=pike_sizeof(sp-args); pop_n_elems(args); push_int(tmp);
pike.git/src/operators.c:1234:
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); return 1; } void init_operators() {
+
add_efun2("`[]",f_index,
+
"function(string,int:int)|function(object,string:mixed)|function(array,int:mixed)|function(mapping,mixed:mixed)|function(multiset,mixed:int)|function(string,int,int:string)|function(array,int,int:array)",OPT_TRY_OPTIMIZE,0,0);
+
+
add_efun2("`->",f_arrow,
+
"function(object|mapping|multiset,string:mixed)",OPT_TRY_OPTIMIZE,0,0);
+
add_efun2("`==",f_eq,"function(mixed,mixed:int)",OPT_TRY_OPTIMIZE,0,generate_comparison); add_efun2("`!=",f_ne,"function(mixed,mixed:int)",OPT_TRY_OPTIMIZE,0,generate_comparison); add_efun2("`!",f_not,"function(mixed:int)",OPT_TRY_OPTIMIZE,0,generate_not); #define CMP_TYPE "function(object,mixed:int)|function(mixed,object:int)|function(int|float,int|float:int)|function(string,string:int)" 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);