pike.git / src / array.c

version» Context lines:

pike.git/src/array.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: array.c,v 1.177 2004/10/21 17:29:21 nilsson Exp $ + || $Id: array.c,v 1.178 2004/12/22 18:46:14 grubba Exp $   */      #include "global.h"   #include "svalue.h"   #include "array.h"   #include "object.h"   #include "las.h"   #include "stralloc.h"   #include "interpret.h"   #include "opcodes.h"
pike.git/src/array.c:799:    fun,    ITEM(v));       UNSET_ONERROR(tmp);    return current_order;   }      /* Returns 2 if no relation is established through lfun calls. */   static INLINE int lfun_cmp (const struct svalue *a, const struct svalue *b)   { +  struct program *p;    int fun;    -  if (a->type == T_OBJECT && a->u.object->prog) { -  if ((fun = FIND_LFUN(a->u.object->prog,LFUN_LT)) != -1) { +  if (a->type == T_OBJECT && (p = a->u.object->prog)) { +  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_LT)) != -1) {    push_svalue(b); -  apply_low (a->u.object, fun, 1); +  apply_low(a->u.object, +  fun + p->inherits[a->subtype].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return -1;    }    pop_stack();    }    -  if ((fun = FIND_LFUN(a->u.object->prog,LFUN_GT)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_GT)) != -1) {    push_svalue(b); -  apply_low (a->u.object, fun, 1); +  apply_low(a->u.object, +  fun + p->inherits[a->subtype].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return 1;    }    pop_stack();    }    -  if ((fun = FIND_LFUN(a->u.object->prog,LFUN_EQ)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[a->subtype].prog, LFUN_EQ)) != -1) {    push_svalue(b); -  apply_low (a->u.object, fun, 1); +  apply_low(a->u.object, +  fun + p->inherits[a->subtype].identifier_level, 1);    if (!UNSAFE_IS_ZERO(Pike_sp-1)) {    pop_stack();    return 0;    }    pop_stack();    }    }    -  if(b->type == T_OBJECT && b->u.object->prog) { -  if ((fun = FIND_LFUN(b->u.object->prog,LFUN_LT)) != -1) { +  if(b->type == T_OBJECT && (p = b->u.object->prog)) { +  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_LT)) != -1) {    push_svalue(a); -  apply_low (b->u.object, fun, 1); +  apply_low(b->u.object, +  fun + p->inherits[b->subtype].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return 1;    }    pop_stack();    }    -  if ((fun = FIND_LFUN(b->u.object->prog,LFUN_GT)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_GT)) != -1) {    push_svalue(a); -  apply_low (b->u.object, fun, 1); +  apply_low(b->u.object, +  fun + p->inherits[b->subtype].identifier_level, 1);    if(!UNSAFE_IS_ZERO(Pike_sp-1))    {    pop_stack();    return -1;    }    pop_stack();    }    -  if ((fun = FIND_LFUN(b->u.object->prog,LFUN_EQ)) != -1) { +  if ((fun = FIND_LFUN(p->inherits[b->subtype].prog, LFUN_EQ)) != -1) {    push_svalue(a); -  apply_low (b->u.object, fun, 1); +  apply_low(b->u.object, +  fun + p->inherits[b->subtype].identifier_level, 1);    if (!UNSAFE_IS_ZERO(Pike_sp-1)) {    pop_stack();    return 0;    }    pop_stack();    }    }       return 2;   }
pike.git/src/array.c:901:    if(a->u.integer < b->u.integer) return -1;    if(a->u.integer > b->u.integer) return 1;    return 0;       default:    if(a->u.refs < b->u.refs) return -1;    if(a->u.refs > b->u.refs) return 1;    return 0;       case T_OBJECT: -  if(a->u.object == b->u.object) return 0; +  if((a->u.object == b->u.object) && (a->subtype == b->subtype)) { +  return 0; +  }    break;    }    }       res = lfun_cmp (a, b);    if (res != 2) return res;       if (typediff) return typediff;      #ifdef PIKE_DEBUG    if (a->type != T_OBJECT)    Pike_fatal ("Expected objects when both types are the same.\n");   #endif -  +  +  /* FIXME: Take subtype into account! */ +     if(a->u.object->prog == b->u.object->prog) {    if (a->u.object->prog) {    if(a->u.object < b->u.object) {    return -1;    } else {    return 1;    }    } else {    /* Destructed objects are considered equal. */    return 0;
pike.git/src/array.c:1019:    return 1;    res = alpha_svalue_cmpfun (    use_multiset_index (a->u.multiset, a_pos, ind_a),    use_multiset_index (b->u.multiset, b_pos, ind_b));    sub_msnode_ref (a->u.multiset);    sub_msnode_ref (b->u.multiset);    return res;    }       case T_OBJECT: -  if(a->u.object == b->u.object) return 0; +  if((a->u.object == b->u.object) && (a->subtype == b->subtype)) { +  return 0; +  }    break;       default:   #if 1    /* I think it would be better to leave the order undefined in    * these cases since the addresses aren't observable    * properties in pike. /mast */    if(a->u.refs < b->u.refs) return -1;    if(a->u.refs > b->u.refs) return 1;   #endif
pike.git/src/array.c:1887:    case BIT_INT:    for(e=1; e<a->size; e++)    if(ITEM(a)[e].u.integer != ITEM(a)[0].u.integer)    break;    if(e==a->size && ITEM(a)[0].u.integer==0)    return mkefuncallnode("allocate",mkintnode(a->size));    break;       case BIT_STRING:    case BIT_PROGRAM: -  case BIT_OBJECT: +     for(e=1; e<a->size; e++)    if(ITEM(a)[e].u.refs != ITEM(a)[0].u.refs)    break;    break;    -  +  case BIT_OBJECT:    case BIT_FUNCTION:    for(e=1; e<a->size; e++)    if(ITEM(a)[e].u.object != ITEM(a)[0].u.object ||    ITEM(a)[e].subtype != ITEM(a)[0].subtype)    break;    break;    }    debug_malloc_touch(a);    if(e == a->size)    return mkefuncallnode("allocate",mknode(F_ARG_LIST,