Branch: Tag:

1999-12-13

1999-12-13 20:18:00 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Implemented ~ on types.
! on types now compares against zero, just like with the other types.

Rev: src/operators.c:1.74

6:   /**/   #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"
1110:       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;    }   
1826:    }    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;
1878:    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;
2212:    /* 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);
2298:    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);