pike.git / src / operators.c

version» Context lines:

pike.git/src/operators.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: operators.c,v 1.229 2008/03/29 02:04:40 mast Exp $ + || $Id: operators.c,v 1.230 2008/04/14 10:14:40 grubba Exp $   */      #include "global.h"   #include <math.h>   #include "interpret.h"   #include "svalue.h"   #include "multiset.h"   #include "mapping.h"   #include "array.h"   #include "stralloc.h"
pike.git/src/operators.c:23:   #include "lex.h"   #include "program.h"   #include "object.h"   #include "pike_types.h"   #include "module_support.h"   #include "pike_macros.h"   #include "bignum.h"   #include "builtin_functions.h"   #include "cyclic.h"   #include "pike_security.h" + #include "pike_compiler.h"      #define sp Pike_sp      #define OP_DIVISION_BY_ZERO_ERROR(FUNC) \    math_error(FUNC, sp-2, 2, 0, "Division by zero.\n")   #define OP_MODULO_BY_ZERO_ERROR(FUNC) \    math_error(FUNC, sp-2, 2, 0, "Modulo by zero.\n")      void index_no_free(struct svalue *to,struct svalue *what,struct svalue *ind)   {
pike.git/src/operators.c:1730:    case BIT_MULTISET:    ADD (multiset, add_multisets, push_multiset);      #undef ADD_WITH_UNDEFINED   #undef ADD    }   }      static int generate_sum(node *n)   { +  struct compilation *c = THIS_COMPILATION;    node **first_arg, **second_arg, **third_arg;    int num_args;    switch(count_args(CDR(n)))    {    case 0: return 0;       case 1:    do_docode(CDR(n),0);    return 1;   
pike.git/src/operators.c:2039:    }   #endif /* 0 */    return 0;   }         static int generate_comparison(node *n)   {    if(count_args(CDR(n))==2)    { +  struct compilation *c = THIS_COMPILATION;    if(do_docode(CDR(n),DO_NOT_COPY) != 2)    Pike_fatal("Count args was wrong in generate_comparison.\n");       if(CAR(n)->u.sval.u.efun->function == f_eq)    emit0(F_EQ);    else if(CAR(n)->u.sval.u.efun->function == f_ne)    emit0(F_NE);    else if(CAR(n)->u.sval.u.efun->function == f_lt)    emit0(F_LT);    else if(CAR(n)->u.sval.u.efun->function == f_le)
pike.git/src/operators.c:2359:    o_subtract();    }    assign_svalue(s,sp-1);    pop_n_elems(sp-s-1);    }    }   }      static int generate_minus(node *n)   { +  struct compilation *c = THIS_COMPILATION;    switch(count_args(CDR(n)))    {    case 1:    do_docode(CDR(n),DO_NOT_COPY);    emit0(F_NEGATE);    return 1;       case 2:    do_docode(CDR(n),DO_NOT_COPY_TOPLEVEL);    emit0(F_SUBTRACT);
pike.git/src/operators.c:2696:    {    CALL_OPERATOR(LFUN_AND, args);    }else{    speedup(args, o_and);    }    }   }      static int generate_and(node *n)   { +  struct compilation *c = THIS_COMPILATION;    switch(count_args(CDR(n)))    {    case 1:    do_docode(CDR(n),0);    return 1;       case 2:    do_docode(CDR(n),0);    emit0(F_AND);    return 1;
pike.git/src/operators.c:2930:    {    CALL_OPERATOR(LFUN_OR, args);    } else {    speedup(args, o_or);    }    }   }      static int generate_or(node *n)   { +  struct compilation *c = THIS_COMPILATION;    switch(count_args(CDR(n)))    {    case 1:    do_docode(CDR(n),0);    return 1;       case 2:    do_docode(CDR(n),0);    emit0(F_OR);    return 1;
pike.git/src/operators.c:3169:    {    CALL_OPERATOR(LFUN_XOR, args);    } else {    speedup(args, o_xor);    }    }   }      static int generate_xor(node *n)   { +  struct compilation *c = THIS_COMPILATION;    switch(count_args(CDR(n)))    {    case 1:    do_docode(CDR(n),0);    return 1;       case 2:    do_docode(CDR(n),0);    emit0(F_XOR);    return 1;
pike.git/src/operators.c:3252:   {    if(args != 2) {    /* FIXME: Not appropriate if too many args. */    SIMPLE_TOO_FEW_ARGS_ERROR("`<<", 2);    }    o_lsh();   }      static int generate_lsh(node *n)   { +  struct compilation *c = THIS_COMPILATION;    if(count_args(CDR(n))==2)    {    do_docode(CDR(n),DO_NOT_COPY_TOPLEVEL);    emit0(F_LSH);    return 1;    }    return 0;   }      PMOD_EXPORT void o_rsh(void)
pike.git/src/operators.c:3335:    /* FIXME: Not appropriate if too many args. */    SIMPLE_TOO_FEW_ARGS_ERROR("`>>", 2);    }    o_rsh();   }      static int generate_rsh(node *n)   {    if(count_args(CDR(n))==2)    { +  struct compilation *c = THIS_COMPILATION;    do_docode(CDR(n),DO_NOT_COPY);    emit0(F_RSH);    return 1;    }    return 0;   }         #define TWO_TYPES(X,Y) (((X)<<8)|(Y))   PMOD_EXPORT void o_multiply(void)
pike.git/src/operators.c:3616:    /* Restore the order, and multiply */    stack_swap();    o_multiply();    }    }    }   }      static int generate_multiply(node *n)   { +  struct compilation *c = THIS_COMPILATION;    switch(count_args(CDR(n)))    {    case 1:    do_docode(CDR(n),0);    return 1;       case 2:    do_docode(CDR(n),0);    emit0(F_MULTIPLY);    return 1;
pike.git/src/operators.c:3986:    assign_svalue(s,sp-1);    pop_n_elems(sp-s-1);    }    }   }      static int generate_divide(node *n)   {    if(count_args(CDR(n))==2)    { +  struct compilation *c = THIS_COMPILATION;    do_docode(CDR(n),DO_NOT_COPY_TOPLEVEL);    emit0(F_DIVIDE);    return 1;    }    return 0;   }      PMOD_EXPORT void o_mod(void)   {    if(sp[-2].type != sp[-1].type && !float_promote())
pike.git/src/operators.c:4166:    /* FIXME: Not appropriate when too many args. */    SIMPLE_TOO_FEW_ARGS_ERROR("`%", 2);    }    o_mod();   }      static int generate_mod(node *n)   {    if(count_args(CDR(n))==2)    { +  struct compilation *c = THIS_COMPILATION;    do_docode(CDR(n),DO_NOT_COPY_TOPLEVEL);    emit0(F_MOD);    return 1;    }    return 0;   }      PMOD_EXPORT void o_not(void)   {    switch(sp[-1].type)
pike.git/src/operators.c:4245:    /* FIXME: Not appropriate with too many args. */    SIMPLE_TOO_FEW_ARGS_ERROR("`!", 1);    }    o_not();   }      static int generate_not(node *n)   {    if(count_args(CDR(n))==1)    { +  struct compilation *c = THIS_COMPILATION;    do_docode(CDR(n),DO_NOT_COPY);    emit0(F_NOT);    return 1;    }    return 0;   }      PMOD_EXPORT void o_compl(void)   {    switch(sp[-1].type)
pike.git/src/operators.c:4366:    /* FIXME: Not appropriate with too many args. */    SIMPLE_TOO_FEW_ARGS_ERROR("`~", 1);    }    o_compl();   }      static int generate_compl(node *n)   {    if(count_args(CDR(n))==1)    { +  struct compilation *c = THIS_COMPILATION;    do_docode(CDR(n),DO_NOT_COPY);    emit0(F_COMPL);    return 1;    }    return 0;   }      PMOD_EXPORT void o_negate(void)   {    switch(sp[-1].type)
pike.git/src/operators.c:5286:    mkintnode(1)))));    );    }    }    }    return NULL;   }      static int generate_sizeof(node *n)   { +  struct compilation *c = THIS_COMPILATION;    if(count_args(CDR(n)) != 1) return 0;    if(do_docode(CDR(n),DO_NOT_COPY) != 1)    Pike_fatal("Count args was wrong in sizeof().\n");    emit0(F_SIZEOF);    return 1;   }      extern int generate_call_function(node *n);      /*! @class string_assignment