pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:7790:    return ret;   }      static void push_expand_transitive_type(struct pike_type *cont,    struct pike_type *trans,    struct pike_type **markers,    int num_args)   {    struct pike_type *tmp;    TYPE_STACK_DEBUG("expand_transitive"); -  switch(cont->type) { +  switch(cont?(cont->type & PIKE_T_MASK):PIKE_T_UNKNOWN) { +  case PIKE_T_UNKNOWN: +  if (!trans) { +  push_type(PIKE_T_UNKNOWN); +  } else { +  /* A car of __unknown__ is short-hand for having it identical +  * to the cdr. +  */ +  push_expand_transitive_type(trans, trans, markers, num_args); +  } +  break;    case T_OR: case T_AND:    push_expand_transitive_type(cont->cdr, trans, markers, num_args);    push_expand_transitive_type(cont->car, trans, markers, num_args);    push_type(cont->type);    break;    case PIKE_T_FUNCTION:    /*    * transitive(function(a, b, ...:c), X)    *    * ==>
pike.git/src/pike_types.cmod:11526:    * but this leads to a combinatorial explosion.    */    tmp = expand_transitive(fun_type, a_markers, 0);    res = lower_new_check_call(tmp, arg_type, flags, sval CHECK_CALL_ARGS);    free_type(tmp);   #else    /* There are two cases here; arg_type can belong to either    * fun_type->car, or (if fun_type->car can return here) the    * second argument to fun_type->cdr (or both).    */ +  if (fun_type->car) {    tmp = new_get_return_type(fun_type->car, 0); -  +  } else { +  tmp = new_get_return_type(fun_type->cdr, 0); +  }    if (tmp) {    tmp2 = low_new_check_call(fun_type->cdr, tmp, 0, NULL);    free_type(tmp);    tmp = NULL;    if (tmp2) {    /* tmp is a valid argument to fun_type->cdr,    * so check if arg_type is also valid. */    tmp = lower_new_check_call(tmp2, arg_type, flags,    sval CHECK_CALL_ARGS);    free_type(tmp2);    }    }    -  +  if (fun_type->car) {    tmp2 = lower_new_check_call(fun_type->car, arg_type,    flags, sval CHECK_CALL_ARGS); -  +  } else { +  tmp2 = lower_new_check_call(fun_type->cdr, arg_type, +  flags, sval CHECK_CALL_ARGS); +  }    if (tmp2) {    if (!tmp) {    tmp = tmp2;    } else {    /* NB: Using arg_type as a temporary variable. */    arg_type = or_pike_types(tmp, tmp2, 1);    free_type(tmp);    free_type(tmp2);    tmp = arg_type;    }
pike.git/src/pike_types.cmod:12087:    tmp = apply_type_operator(fun_type->type, fun_type->car, fun_type->cdr);    if (!tmp) {    return NULL;    }    res = new_get_return_type(tmp, flags);    free_type(tmp);    break;       case PIKE_T_TRANSITIVE:    /* NB: Not 100% correct, but good enough for most purposes. */ +  if (fun_type->car) {    fun_type = fun_type->car; -  +  } else { +  fun_type = fun_type->cdr; +  }    goto loop;       case PIKE_T_UNKNOWN:    default:    /* Not a callable. */    break;    }       if (!res) {   #ifdef PIKE_DEBUG
pike.git/src/pike_types.cmod:12285:    tmp = apply_type_operator(fun_type->type, fun_type->car, fun_type->cdr);    if (!tmp) {    res = NULL;    break;    }    res = get_first_arg_type(tmp, flags);    free_type(tmp);    break;       case PIKE_T_TRANSITIVE: +  if (!fun_type->car) { +  fun_type = fun_type->cdr; +  goto loop; +  } +     tmp = new_get_return_type(fun_type->car, 0);       if (!tmp) {    fun_type = fun_type->car;    goto loop;    }       tmp2 = low_new_check_call(fun_type->cdr, tmp, 0, NULL);    free_type(tmp);    tmp = NULL;