pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:3165:    int zero_implied);      /* Push either t1, t2 or the OR of t1 and t2.    * Returns -1 if t1 was pushed.    * 0 if the OR was pushed. (Successful join)    * 1 if t2 was pushed.    *    * zero_implied: One of:    * 0 the zero type (if any) must be explicit in the result.    * 1 the zero type is implicit. +  * 2 zero is explicit and integers are regarded as masks (cf enums).    * 3 zero is implicit and integers are regarded as masks (cf enums).    */   static int lower_or_pike_types(struct pike_type *t1,    struct pike_type *t2,    int zero_implied,    int elem_on_stack)   {    int ret = 0;    struct pike_type *t = NULL;    struct pike_type *top = NULL;
pike.git/src/pike_types.cmod:3190:    fprintf(stderr, ")\n");   #endif    if (t1 == t2) {    t = t1;    } else if (!t1) {    t = t2;    ret = 1;    } else if (!t2) {    t = t1;    ret = -1; -  } else if (zero_implied && (t1->type == T_ZERO)) { +  } else if ((zero_implied & 1) && (t1->type == T_ZERO)) {    t = t2; -  } else if (zero_implied && (t2->type == T_ZERO)) { +  } else if ((zero_implied & 1) && (t2->type == T_ZERO)) {    t = t1;    } else if ((t1->type == T_NOT) && pike_types_le(t1->car, t2, 0, 0)) {    t = mixed_type_string;    } else if ((t2->type == T_NOT) && pike_types_le(t2->car, t1, 0, 0)) {    t = mixed_type_string;    } else if ((t1->type ^ '0') < (t2->type ^ '0')) {    /* Note: Adjusted order to get markers first. */    t = t1;    ret = -1;    } else if ((t1->type ^ '0') > (t2->type ^ '0')) {
pike.git/src/pike_types.cmod:3374:    }    if (!elem_on_stack) {    if (t) {    push_finished_type(t);    } else {    push_type(PIKE_T_UNKNOWN);    }    } else if (!t) {    /* No need to do anything. */    } else if ((top = peek_type_stack())->type != t->type) { -  if (zero_implied && (top->type == T_ZERO)) { +  if ((zero_implied & 1) && (top->type == T_ZERO)) {    Pike_compiler->type_stackp--;    free_type(top);    push_finished_type(t); -  } else if (zero_implied && (t->type == T_ZERO)) { +  } else if ((zero_implied & 1) && (t->type == T_ZERO)) {    /* The zero is implied. */    } else {    push_finished_type(t);    }    } else if (t == top) {    /* No need to do anything. */    } else {    switch(t?t->type:PIKE_T_UNKNOWN) {    case T_FLOAT:    case T_MIXED:
pike.git/src/pike_types.cmod:3400:    case T_ZERO:    /* There can only be one. */    break;    case T_INT:    {    INT32 min1 = CAR_TO_INT(t);    INT32 max1 = CDR_TO_INT(t);    INT32 min2 = CAR_TO_INT(top);    INT32 max2 = CDR_TO_INT(top);    -  if (zero_implied) { +  if (zero_implied & 1) {    if (min1 == 1) min1 = 0;    if (min2 == 1) min2 = 0;    if (max1 == -1) max1 = 0;    if (max2 == -1) max2 = 0; -  +  }    -  if (zero_implied == 3) { +  if (zero_implied & 2) {    /* Or between integer masks.    * This is a bit more lenient than the default further below,    * and is used for generating the type for enums.    */       /* Ensure that zero is always in the range.    * This also ensures that there'll be an overlap.    */    if (max1 < 0) max1 = 0;    if (max2 < 0) max2 = 0;    if (min1 > 0) min1 = 0;    if (min2 > 0) min2 = 0;       /* Both max values are now >= 0, so this or is safe. */    max1 |= max2;       if ((min1 < 0) && (min2 < 0)) {    min1 &= min2;    }    } -  } +        if ((max2 < MAX_INT32) && (min1 > max2 + 1)) {    /* No overlap. */    push_finished_type(t);   #ifdef PIKE_DEBUG    } else if ((max1 < MAX_INT32) && (min2 > max1 + 1)) {    /* No overlap and wrong order! */    Pike_fatal("Bad integer ordering in lower_or_pike_types().\n");   #endif    } else {
pike.git/src/pike_types.cmod:3527:    fprintf(stderr, ", ");    simple_describe_type(t2);    fprintf(stderr, ")\n");   #endif    if(!t1)    {    push_finished_type(t2);    }    else if((!t2) ||    ((t2->type == T_ZERO) && -  (zero_implied || (t1->flags & PT_FLAG_NULLABLE)))) { +  ((zero_implied & 1) || (t1->flags & PT_FLAG_NULLABLE)))) {    push_finished_type(t1);    }    else if ((t1->type == T_ZERO) && -  (zero_implied || (t2->flags & PT_FLAG_NULLABLE))) { +  ((zero_implied & 1) || (t2->flags & PT_FLAG_NULLABLE))) {    push_finished_type(t2);    }    else if (t1 == t2) {    push_finished_type(t1);    }    else if ((t1->flags & (PT_FLAG_MIXED|PT_FLAG_VOIDABLE)) ==    (PT_FLAG_MIXED|PT_FLAG_VOIDABLE)) {    push_finished_type(t1);    }    else if ((t2->flags & (PT_FLAG_MIXED|PT_FLAG_VOIDABLE)) ==
pike.git/src/pike_types.cmod:3624:    }    }   }      struct pike_type *or_pike_types(struct pike_type *a,    struct pike_type *b,    int zero_implied)   {    struct pike_type *res;    type_stack_mark(); -  low_or_pike_types(a,b,1|zero_implied); +  low_or_pike_types(a, b, zero_implied);    res = pop_unfinished_type();   #if 0    fprintf(stderr, " ==> ");    simple_describe_type(res);    fprintf(stderr, "\n");   #endif    return res;   }      struct pike_type *and_pike_types(struct pike_type *a,