pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:5620:    * function(__unknown__...:mixed) or function(__unknown__...:mixed|void)    */    if (op == PT_BINOP_AND) {    return remap_markers(b, remap,    remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS);    }    add_ref(a);    return a;    }    +  if ((aflags|bflags) & PT_FLAG_CMP_INEXACT_FUN) { +  avoidable |= PT_FLAG_CMP_INEXACT_ARG; +  bvoidable |= PT_FLAG_CMP_INEXACT_ARG; +  +  aret = mixed_type_string; +  bret = mixed_type_string; +  } +     type_stack_mark();       switch(op) {    case PT_BINOP_AND:    /* NB: For simplicity in the (common case)    * many(assign(m, mixed), m),    * we expand the many node (as required) to    * function(assign(m, mixed), many(assign(m, mixed), m)),    * and leave it to the evaluator to join the multiple    * assignments with or. The alternative (and stricter) would
pike.git/src/pike_types.cmod:6238:    pop_stack_mark();    return NULL;    }    push_remap_markers(b, remap,    remap_flags ^ PT_FLAG_REMAP_SWAP_MARKERS);    push_remap_markers(a, remap, remap_flags);    push_type(T_OR);    push_type(T_NOT);    break;    } +     return pop_unfinished_type();    }       /* Invariant: a->type == b->type. */    -  +  if ((aflags|bflags) & PT_FLAG_CMP_NO_SUBTYPES) { +  /* No need to look at the subtypes or ranges. */ +  goto done; +  } +     switch(a->type) {    case T_NOT:    /* Reverse the order of the bits.    *    * 1 <=> 8 AND <=> NOR    * 2 <=> 4 MINUS <=> INVERSE_MINUS    *    * This inverts both A and B.    */    {
pike.git/src/pike_types.cmod:6449:    simple_describe_type(peek_type_stack());    fprintf(stderr, "\n");    }       return pop_unfinished_type();    }       case T_ARRAY:    case T_MAPPING:    case T_STRING: +  { +  enum pt_cmp_flags subflags = 0; +  +  if ((aflags|bflags) & PT_FLAG_CMP_INEXACT_ARG) { +  subflags = PT_FLAG_CMP_NO_SUBTYPES; +  } +     /* FIXME: Handle PT_FLAG_CMP_INSEPARABLE. */    /* FIXME: The recursive op should probably be inverted. */    tmp = low_type_binop(op, a->car, b->car, remap, -  0, 0, remap_flags); -  if (!tmp && (op == PT_BINOP_AND) && a->car && b->car) return NULL; -  if ((a->type == T_STRING) || (op == PT_BINOP_AND)) { -  tmp2 = low_type_binop(op, a->cdr, b->cdr, remap, -  PT_FLAG_CMP_VOID_IS_ZERO, -  PT_FLAG_CMP_VOID_IS_ZERO, -  remap_flags); -  } else { +  subflags, subflags, remap_flags); +  if (!tmp && (op == PT_BINOP_AND) && a->car && b->car) { +  return NULL; +  } +  +  subflags |= PT_FLAG_CMP_VOID_IS_ZERO; +  +  if ((a->type != T_STRING) && (op != PT_BINOP_AND)) {    /* Mappings may always result in UNDEFINED on indexing.    * Arrays are typically initialized to all zeroes.    * Any void values have been up-converted to zeroes.    */ -  tmp2 = low_type_binop(op, a->cdr, b->cdr, remap, -  PT_FLAG_CMP_NULLABLE|PT_FLAG_CMP_VOID_IS_ZERO, -  PT_FLAG_CMP_NULLABLE|PT_FLAG_CMP_VOID_IS_ZERO, -  remap_flags); +  subflags |= PT_FLAG_CMP_NULLABLE;    } -  +  +  tmp2 = low_type_binop(op, a->cdr, b->cdr, remap, +  subflags, subflags, remap_flags); +     if (!tmp2 && (op == PT_BINOP_MINUS || (a->cdr && b->cdr))) {    if (op == PT_BINOP_AND) {    free_type(tmp);    return NULL;    } else if (!tmp) {    return NULL;    }    } -  +  }    type_stack_mark();    if (op == PT_BINOP_MINUS) {    if (tmp) {    push_finished_type(a->cdr);    push_finished_type(tmp);    push_type(a->type);    free_type(tmp);    }    if (tmp2) {    push_finished_type(tmp2);
pike.git/src/pike_types.cmod:6512:    push_finished_type(tmp2);    push_reverse_type(a->type);    free_type(tmp);    free_type(tmp2);    }    return pop_unfinished_type();       case T_MULTISET:    case T_PROGRAM:    case T_TYPE: +  { +  enum pt_cmp_flags subflags = 0; +  +  if ((a->type == T_MULTISET) && +  ((aflags|bflags) & PT_FLAG_CMP_INEXACT_ARG)) { +  subflags = PT_FLAG_CMP_NO_SUBTYPES; +  } +     /* FIXME: Handle PT_FLAG_CMP_INSEPARABLE. */    tmp = low_type_binop(op, a->car, b->car, remap, -  0, 0, remap_flags); +  subflags, subflags, remap_flags);    if (!tmp && ((op != PT_BINOP_AND) || (a->car && b->car))) {    return NULL;    } -  +  } +     type_stack_mark();    push_finished_type(tmp);    push_type(a->type);    free_type(tmp); -  +     return pop_unfinished_type();       case T_OBJECT:    /* FIXME: Handle PT_FLAG_CMP_INSEPARABLE. */    switch(op) {    case PT_BINOP_AND:    if (!a->cdr) {    add_ref(b);    return b;    }
pike.git/src/pike_types.cmod:6612:    break;    }       type_stack_mark();    push_finished_type(b);    push_finished_type(a);    push_binop(op);    return pop_unfinished_type();    }    +  done:    /* Leaf type. Most likely not reached. */    if (op & PT_BINOP_AND) {    add_ref(a);    return a;    }    return NULL;   }      struct pike_type *type_binop(enum pt_binop op,    struct pike_type *a,
pike.git/src/pike_types.cmod:10282:    * b: function(__unknown__ ...:mixed)    *    * ie    *    * a: "The set of functions that accept 0 arguments."    * b: "The set of functions that accept any number of arguments."    *    * b - a will then result in Ø, even though b actually can handle    * some cases that a can't.    */ -  struct pike_type *diff = type_binop(PT_BINOP_MINUS, a, b, 0, 0, 0); +  struct pike_type *diff = +  type_binop(PT_BINOP_MINUS, a, b, +  PT_FLAG_CMP_INEXACT_FUN, PT_FLAG_CMP_INEXACT_FUN, 0);    if (diff) {    free_type(diff);    return 1;    }    return 0;   }         /* FIXME, add the index */   static struct pike_type *low_index_type(struct pike_type *t,
pike.git/src/pike_types.cmod:11545:    if (flags & CALL_INVERTED_TYPES) return !res;    return res;   }      /**    * Check whether sval is a valid first argument to fun_type.    *    * Returns NULL on failure.    *    * Returns continuation function type on success. +  * +  * Used by the variant dispatcher.    */   struct pike_type *check_call_svalue(struct pike_type *fun_type,    INT32 flags,    struct svalue *sval)   {    struct pike_type *res = NULL;    struct pike_type *tmp;    struct pike_type *tmp2;    INT32 array_cnt = 0;