pike.git / src / operators.c

version» Context lines:

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.21 1997/12/03 22:46:17 hubbe Exp $"); + RCSID("$Id: operators.c,v 1.22 1998/01/13 22:56:47 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:42:   COMPARISON(f_ne,"`!=",!is_eq(sp-2,sp-1))   COMPARISON(f_lt,"`<" , is_lt(sp-2,sp-1))   COMPARISON(f_le,"`<=",!is_gt(sp-2,sp-1))   COMPARISON(f_gt,"`>" , is_gt(sp-2,sp-1))   COMPARISON(f_ge,"`>=",!is_lt(sp-2,sp-1))         #define CALL_OPERATOR(OP, args) \    if(!sp[-args].u.object->prog) \    error("Operator %s called in destructed object.\n",lfun_names[OP]); \ -  if(sp[-args].u.object->prog->lfuns[OP] == -1) \ +  if(FIND_LFUN(sp[-args].u.object->prog,OP) == -1) \    error("No operator %s in object.\n",lfun_names[OP]); \    apply_lfun(sp[-args].u.object, OP, args-1); \    free_svalue(sp-2); \    sp[-2]=sp[-1]; \    sp--;         void f_add(INT32 args)   {    INT32 e,size;
pike.git/src/operators.c:69:    {    default:    if(!args)    {    error("Too few arguments to `+()\n");    }else{    if(types & BIT_OBJECT)    {    if(sp[-args].type == T_OBJECT &&    sp[-args].u.object->prog && -  sp[-args].u.object->prog->lfuns[LFUN_ADD] != -1) +  FIND_LFUN(sp[-args].u.object->prog,LFUN_ADD) != -1)    {    apply_lfun(sp[-args].u.object, LFUN_ADD, args-1);    free_svalue(sp-2);    sp[-2]=sp[-1];    sp--;    return;    }    for(e=1;e<args;e++)    {    if(sp[e-args].type == T_OBJECT &&    sp[e-args].u.object->prog && -  sp[e-args].u.object->prog->lfuns[LFUN_RADD] != -1) +  FIND_LFUN(sp[e-args].u.object->prog,LFUN_RADD) != -1)    {    struct svalue *tmp=sp+e-args;    check_stack(e);    assign_svalues_no_free(sp, sp-args, e, -1);    sp+=e;    apply_lfun(tmp->u.object, LFUN_RADD, e);    if(args - e > 2)    {    assign_svalue(tmp, sp-1);    pop_stack();
pike.git/src/operators.c:384:    sp[-1].type=T_FLOAT;    return 1;    }    return 0;   }      static int call_lfun(int left, int right)   {    if(sp[-2].type == T_OBJECT &&    sp[-2].u.object->prog && -  sp[-2].u.object->prog->lfuns[left] != -1) +  FIND_LFUN(sp[-2].u.object->prog,left) != -1)    {    apply_lfun(sp[-2].u.object, left, 1);    free_svalue(sp-2);    sp[-2]=sp[-1];    sp--;    return 1;    }       if(sp[-1].type == T_OBJECT &&    sp[-1].u.object->prog && -  sp[-1].u.object->prog->lfuns[right] != -1) +  FIND_LFUN(sp[-1].u.object->prog,right) != -1)    {    push_svalue(sp-2);    apply_lfun(sp[-2].u.object, right, 1);    free_svalue(sp-3);    sp[-3]=sp[-1];    sp--;    pop_stack();    return 1;    }   
pike.git/src/operators.c:1411:   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);    return 1;   }    + void f_call_function(INT32 args) + { +  mega_apply(APPLY_STACK,args,0,0); + } +  + static int generate_call_function(node *n) + { +  node **arg; +  emit2(F_MARK); +  do_docode(CDR(n),DO_NOT_COPY); +  emit2(F_CALL_FUNCTION); +  return 1; + } +  +    void init_operators(void)   {    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(array(object|mapping|multiset|array)|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);
pike.git/src/operators.c:1455:    add_efun2("`>>",f_rsh,SHIFT_TYPE,OPT_TRY_OPTIMIZE,0,generate_rsh);       add_efun2("`*",f_multiply,"!function(!object...:mixed)&function(mixed...:mixed)|function(array(array),array:array)|function(int...:int)|!function(int...:mixed)&function(float|int...:float)|function(string*,string:string)",OPT_TRY_OPTIMIZE,optimize_binary,generate_multiply);       add_efun2("`/",f_divide,"function(mixed,object:mixed)|function(array,array:array(array))|function(object,mixed:mixed)|function(int,int:int)|function(float|int,float:float)|function(float,int:float)|function(string,string:string*)",OPT_TRY_OPTIMIZE,0,generate_divide);       add_efun2("`%",f_mod,"function(mixed,object:mixed)|function(object,mixed:mixed)|function(int,int:int)|!function(int,int:mixed)&function(int|float,int|float:float)",OPT_TRY_OPTIMIZE,0,generate_mod);       add_efun2("`~",f_compl,"function(object:mixed)|function(int:int)|function(float:float)|function(string:string)",OPT_TRY_OPTIMIZE,0,generate_compl);    add_efun2("sizeof", f_sizeof, "function(string|multiset|array|mapping|object:int)",0,0,generate_sizeof); +  +  add_efun2("`()",f_call_function,"function(mixed,mixed ...:mixed)",OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND,0,generate_call_function); +  +  /* This one should be removed */ +  add_efun2("call_function",f_call_function,"function(mixed,mixed ...:mixed)",OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND,0,generate_call_function);   }