pike.git / src / svalue.c

version» Context lines:

pike.git/src/svalue.c:516:       /*    * This simple mixing function comes from the java HashMap implementation.    * It makes sure that the resulting hash value can be used for hash tables    * with power of 2 size and simple masking instead of modulo prime.    */    q ^= (q >> 20) ^ (q >> 12);    return q ^ (q >> 7) ^ (q >> 4);   }    - PMOD_EXPORT int svalue_is_true(const struct svalue *s) + int complex_svalue_is_true( const struct svalue *s )   { -  check_svalue_type (s); -  check_refs(s); -  -  switch(TYPEOF(*s)) +  if(TYPEOF(*s) == T_FUNCTION)    { -  case T_INT: -  if(s->u.integer) return 1; -  return 0; -  -  case T_FUNCTION: +     if (SUBTYPEOF(*s) == FUNCTION_BUILTIN) return 1;    if(!s->u.object->prog) return 0;    if (s->u.object->prog == pike_trampoline_program) {    /* Trampoline */    struct pike_trampoline *tramp = (struct pike_trampoline *)    get_storage(s->u.object, pike_trampoline_program);    if (!tramp || !tramp->frame || !tramp->frame->current_object ||    !tramp->frame->current_object->prog) {    /* Uninitialized trampoline, or trampoline to destructed object. */    return 0;
pike.git/src/svalue.c:551: Inside #if 0
   /* We should never get a function svalue for a prototype. */    struct identifier *i = ID_FROM_INT(s->u.object->prog, SUBTYPEOF(*s));    if (IDENTIFIER_IS_PIKE_FUNCTION(i->identifier_flags) &&    (i->func.offset == -1)) {    /* Prototype. */    return 0;    }   #endif    }    return 1; -  -  case T_OBJECT: +  }    {    struct program *p;    int fun;       if(!(p = s->u.object->prog)) return 0;    -  if((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*s)].prog, LFUN_NOT)) != -1) -  { +  if((fun = FIND_LFUN(p, LFUN_NOT)) == -1) +  return 1; +  +  if((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*s)].prog, LFUN_NOT)) == -1) +  return 1; +     apply_low(s->u.object,    fun + p->inherits[SUBTYPEOF(*s)].identifier_level, 0);    if(TYPEOF(sp[-1]) == T_INT && sp[-1].u.integer == 0)    {    pop_stack();    return 1;    } else {    pop_stack();    return 0;    }    } -  } -  /* FALL_THROUGH */ -  default: +     return 1;   }    -  + PMOD_EXPORT int svalue_is_true(const struct svalue *s) + { +  check_svalue_type (s); +  check_refs(s); +  switch(TYPEOF(*s)) +  { +  case T_FUNCTION: +  case T_OBJECT: +  return complex_svalue_is_true( s ); +  case T_INT: if(!s->u.integer) return 0;    } -  +  return 1; + }      PMOD_EXPORT int safe_svalue_is_true(const struct svalue *s)   {    check_svalue_type (s);    check_refs(s);       switch(TYPEOF(*s))    {    case T_INT:    if(s->u.integer) return 1;
pike.git/src/svalue.c:963:    }       return low_is_equal(&sa,&sb,p);   }      PMOD_EXPORT int is_equal(const struct svalue *a, const struct svalue *b)   {    return low_is_equal(a,b,0);   }    + static int complex_is_lt( const struct svalue *a, const struct svalue *b ); +    PMOD_EXPORT int is_lt(const struct svalue *a, const struct svalue *b)   {    check_type(TYPEOF(*a));    check_type(TYPEOF(*b));    check_refs(a);    check_refs(b);       if ((TYPEOF(*a) == TYPEOF(*b)) && (TYPEOF(*a) == T_INT)) {    /* Common case...    * Note: the case in the switch still needs to be kept,    * since a or b may be a destructed object.    */    return a->u.integer < b->u.integer;    } -  +  return complex_is_lt( a, b ); + }    -  + static int complex_is_lt( const struct svalue *a, const struct svalue *b ) + {    safe_check_destructed(a);    safe_check_destructed(b);       if (TYPEOF(*a) != TYPEOF(*b))    {    int a_is_obj_without_lt;       if(TYPEOF(*a) == T_FLOAT && TYPEOF(*b) == T_INT) {   #ifdef HAVE_ISLESS    return isless(a->u.float_number, (FLOAT_TYPE)b->u.integer);