pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:1157:    case PIKE_T_TRANSITIVE:    /* Make a new type of the top two types. */    --Pike_compiler->type_stackp;    *Pike_compiler->type_stackp = mk_type(type,    *(Pike_compiler->type_stackp+1),    *Pike_compiler->type_stackp,    PT_COPY_BOTH);    break;       case T_PROGRAM: -  if ((*Pike_compiler->type_stackp)->type != T_OBJECT) { +  if (!*Pike_compiler->type_stackp || +  (*Pike_compiler->type_stackp)->type != T_OBJECT) {    struct pike_type *t = (*Pike_compiler->type_stackp); -  while ((t->type == PIKE_T_NAME) || (t->type == PIKE_T_ATTRIBUTE)) { +  while (t && ((t->type == PIKE_T_NAME) || (t->type == PIKE_T_ATTRIBUTE))) {    t = t->cdr;    } -  if (t->type != T_OBJECT) { +  if (!t || (t->type != T_OBJECT)) {    /* Not a program type, convert it to a type type. */    type = T_TYPE;    }    }    /* FALLTHRU */    case T_MULTISET:    case T_TYPE:    case PIKE_T_AUTO:    /* Make a new type of the top type, and put it in car. */    *Pike_compiler->type_stackp = mk_type(type,
pike.git/src/pike_types.cmod:7810:    */    DECLARE_CYCLIC();       push_finished_type_with_markers(cont, markers, 0);       if (!BEGIN_CYCLIC(cont, trans)) {    SET_CYCLIC_RET(1);       /* Check many arg. */    push_finished_type_with_markers(cont->car, markers, 0); -  if (peek_type_stack()->type != T_VOID) { +  if (peek_type_stack() != void_type_string) {    push_finished_type(trans);    push_finished_type(cont);    push_type(PIKE_T_TRANSITIVE);    push_reverse_type(PIKE_T_FUNCTION);    push_type(T_OR);    } else {    compiler_discard_top_type();    }       push_finished_type_with_markers(cont->cdr, markers, 0);
pike.git/src/pike_types.cmod:7977:      #ifdef PIKE_TYPE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sa_markers[%d]=",    indent*2, "", m);    simple_describe_type(a_markers[m]);    fputc('\n', stderr);    }   #endif   #ifdef PIKE_DEBUG -  if(a_markers[m]->type == m+'0') +  if(a_markers[m] && (a_markers[m]->type == m+'0'))    Pike_fatal("Cyclic type!\n");   #endif    }    return ret;    }    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    {    int m = a->type - '0';    if(a_markers[m])
pike.git/src/pike_types.cmod:8132:    b_markers[m] = pop_unfinished_type();   #ifdef PIKE_TYPE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sb_markers[%d]=",    indent*2, "", m);    simple_describe_type(b_markers[m]);    fputc('\n', stderr);    }   #endif   #ifdef PIKE_DEBUG -  if(b_markers[m]->type == m+'0') +  if(b_markers[m] && (b_markers[m]->type == m+'0'))    Pike_fatal("Cyclic type!\n");   #endif    }    return ret;    }    case '0': case '1': case '2': case '3': case '4':    case '5': case '6': case '7': case '8': case '9':    {    int m = b->type - '0';    if(b_markers[m])
pike.git/src/pike_types.cmod:9576:       case T_ARRAY:    tmp = low_get_return_type(a->cdr, b);    if(!tmp) return 0;    push_unlimited_array_type(T_ARRAY);    return 1;       case PIKE_T_OPERATOR:    {    struct pike_type *t = apply_type_operator(a->type, a->car, a->cdr); +  if (!t) return 0;    tmp = low_get_return_type(t, b);    free_type(t);    return tmp;    }    }       t = low_match_types(a, b, NO_SHORTCUTS);    if(t)    {    a = t;
pike.git/src/pike_types.cmod:10593:    case PIKE_T_ATTRIBUTE:    case T_ASSIGN:    case T_SCOPE:    return low_count_arguments(q->cdr);       default: return MAX_INT32;       case PIKE_T_OPERATOR:    {    struct pike_type *t = apply_type_operator(q->type, q->car, q->cdr); +  if (!t) return 0;    num = low_count_arguments(t);    free_type(t);    return num;    }       case PIKE_T_TRANSITIVE:    num = low_count_arguments(q->car);    if (num == MAX_INT32) return num;    if (num < 0) return num;    return ~num;
pike.git/src/pike_types.cmod:10761:    case T_OR:    fun = or_pike_types(tmp = get_argument_type(fun->car, arg_no),    tmp2 = get_argument_type(fun->cdr, arg_no),    1);    free_type(tmp);    free_type(tmp2);    return fun;       case PIKE_T_OPERATOR:    tmp = apply_type_operator(fun->type, fun->car, fun->cdr); +  if (!tmp) return NULL;    tmp2 = get_argument_type(tmp, arg_no);    free_type(tmp);    return tmp2;       case PIKE_T_TRANSITIVE:    if (arg_no < 0) {    fun = fun->cdr;    goto loop;    }   
pike.git/src/pike_types.cmod:11800:    break;    }       if (!(tmp = lower_new_check_call(fun_type, arg_type,    flags & ~CALL_WEAK_VOID, sval   #ifdef PIKE_TYPE_DEBUG    , 0   #endif    ))) {    struct pike_type *tmp2; -  if (!(flags & CALL_STRICT) || (arg_type->type != T_INT) || +  if (!(flags & CALL_STRICT) || !arg_type || (arg_type->type != T_INT) ||    (CAR_TO_INT(arg_type) >= 0) || (CDR_TO_INT(arg_type) <= 0)) {    return NULL;    }    /* KLUDGE: Special case for integers spanning zero.    *    * Try splitting the argument at zero. The proper fix would be    * to split at all the integer range limits for the first    * declared argument to the function.    *    * Test the most likely problematic range first (ie negative).
pike.git/src/pike_types.cmod:12040:    /* Still too few arguments. */    break;    }    /* FALLTHRU */    case T_MANY:    copy_pike_type(res, fun_type->cdr);    break;       case PIKE_T_OPERATOR:    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. */    fun_type = fun_type->car;    goto loop;       case PIKE_T_UNKNOWN:
pike.git/src/pike_types.cmod:12235:    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    case PIKE_T_ATTRIBUTE:    case PIKE_T_RING:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_OPERATOR:    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:    tmp = new_get_return_type(fun_type->car, 0);       if (!tmp) {    fun_type = fun_type->car;    goto loop;
pike.git/src/pike_types.cmod:12807:    push_finished_type(fun_ret);    push_type(T_VOID);    push_type(T_MIXED);    push_type(T_OR);    push_type(T_MANY);    return pop_unfinished_type();       case PIKE_T_OPERATOR:    {    struct pike_type *tmp = apply_type_operator(a->type, a->car, a->cdr); +  if (!tmp) return NULL;    ret = zzap_function_return(tmp, fun_ret);    free_type(tmp);    return ret;    }       case PIKE_T_TRANSITIVE:    yytype_report(REPORT_WARNING, NULL, 0, NULL,    NULL, 0, a,    0, "Zapping the return value for a transitive "    "function is not supported.");