pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:1169:      /* Pop one level of types. This is the inverse of push_type() */   void debug_pop_type_stack(unsigned int expected)   {    struct pike_type *top;    if(Pike_compiler->type_stackp<type_stack)    Pike_fatal("Type stack underflow\n");       top = *(Pike_compiler->type_stackp);    /* Special case... */ -  if (top->type == T_MIXED) return; /* Probably due to an earlier error */ +  if (!top || top->type == T_MIXED) return; /* Probably due to an earlier error */       Pike_compiler->type_stackp--;   #ifdef PIKE_DEBUG    if ((top->type != expected) &&    (top->type != PIKE_T_NAME) &&    (top->type != PIKE_T_ATTRIBUTE)) {    Pike_fatal("Unexpected type on stack: %d (expected %d)\n", top->type, expected);    }   #endif /* PIKE_DEBUG */    /* OPTIMIZE: It looks like this function is always called with
pike.git/src/pike_types.cmod:2727:    }    break;       case T_FUNCTION:    case T_MANY:    {    if(t->type == T_MANY &&    t->cdr->type == T_OR &&    ((t->cdr->car->type == T_MIXED && t->cdr->cdr->type == T_VOID) ||    (t->cdr->cdr->type == T_MIXED && t->cdr->car->type == T_VOID)) && -  (t->car->type == T_ZERO || +  (!t->car || +  t->car->type == T_ZERO ||    (t->car->type == T_OR &&    ((t->car->car->type == T_ZERO && t->car->cdr->type == T_VOID) ||    (t->car->cdr->type == T_ZERO && t->car->car->type == T_VOID)))))    {    /* function == function(zero...:mixed|void) or    * function(zero|void...:mixed|void)    */    string_builder_strcat(s, "function");    /* done */    break;
pike.git/src/pike_types.cmod:2750:    string_builder_strcat(s, "function(");    while(t->type == T_FUNCTION)    {    if(arg++) string_builder_strcat(s, ", ");    low_describe_type(s, t->car);    t = t->cdr;    }    if (t->type != T_MANY) {    string_builder_sprintf(s, ", @%T)", t);    } else { -  if(t->car->type != T_VOID) +  if(!t->car || (t->car->type != T_VOID))    {    if(arg++) string_builder_strcat(s, ", "); -  low_describe_type(s, t->car); +  if (t->car) low_describe_type(s, t->car);    string_builder_strcat(s, " ...");    }    t = t->cdr;    string_builder_sprintf(s, " : %T)", t);    }    }    break;    }       case T_ARRAY:
pike.git/src/pike_types.cmod:3852:    SET_SVAL(key, T_INT, NUMBER_NUMBER, integer, marker);    SET_SVAL(val, T_TYPE, 0, type, value);    mapping_insert(markers, &key, &val);   }      static void push_remap_markers(struct pike_type *t,    struct mapping *markers,    struct remap_state *remap,    enum pt_remap_flags flags)   { -  if (!remap && !markers && !(flags & PT_FLAG_REMAP_EVAL_MARKERS)) { +  if (!t || (!remap && !markers && !(flags & PT_FLAG_REMAP_EVAL_MARKERS))) {    push_finished_type(t);    return;    }       /* FIXME: Use the type flags to detect whether we can just push    * the type verbatim.    */       switch(t->type & PIKE_T_MASK) {    case T_ASSIGN:
pike.git/src/pike_types.cmod:9731:    if (num2 < 0) {    num += ~num2;    return ~num;    }    return num + num2;    }       /* FALLTHRU */    case T_MANY:    q = q->car; -  if(q->type != T_VOID) return ~num; +  if(!q || (q->type != T_VOID)) return ~num;    return num;    }   }      /* Count the number of arguments for a funciton type.    * return -1-n if the function can take number of arguments    * >= n (varargs)    */   int count_arguments(struct pike_type *s)   {
pike.git/src/pike_types.cmod:9884:    arg_no--;    fun = fun->cdr;    goto loop;    }    /* FALLTHRU */    case T_MANY:    if (arg_no < 0) {    add_ref(fun->cdr);    return fun->cdr;    } -  add_ref(fun->car); +  safe_add_ref(fun->car);    return fun->car;       case T_MIXED:    add_ref(fun);    return fun;       case T_ARRAY:    if (arg_no < 0) {    type_stack_mark();    push_finished_type(fun = get_argument_type(fun->cdr, arg_no));
pike.git/src/pike_types.cmod:11059:    return tmp2;       case PIKE_T_FUNCTION:    case T_MANY:    /* Special case to detect workarounds for the old    * function call checker.    */    tmp = NULL;    if (((arg_type->type != T_NOT) ||    (arg_type->car->type != T_MIXED)) && +  fun_type->car &&    (fun_type->car->type == T_NOT) &&    (fun_type->car->car->type == T_OR) &&    ((fun_type->car->car->car->type == T_MIXED) ||    (fun_type->car->car->cdr->type == T_MIXED))) {    /* Rebuild the function type without the negated mixed    * in the first argument.    */    type_stack_mark();    push_finished_type(fun_type->cdr);    if (fun_type->car->car->car->type == T_MIXED) {
pike.git/src/pike_types.cmod:11091:    fprintf(stderr, "%*sChecking argument type ", indent*2+2, "");    simple_describe_type(arg_type);    fprintf(stderr, " against function type ");    simple_describe_type(fun_type);    fprintf(stderr, ".\n");    }   #endif /* PIKE_DEBUG */    /* No need to perform advanced checking in the trivial case... */    if (arg_type != (tmp2 = fun_type->car)) {    struct pike_type *t = NULL; -  if (!((flags & CALL_INVERTED_TYPES)? +  if (!tmp2) { +  if (flags & CALL_STRICT) goto no_match; +  } else if (!((flags & CALL_INVERTED_TYPES)?    low_pike_types_le(tmp2, arg_type, 0,    LE_A_B_SWAPPED|LE_EXPLICIT_ZERO):    low_pike_types_le(arg_type, tmp2, 0, 0)) &&    ((flags & CALL_STRICT) ||    !(t = low_match_types(arg_type, tmp2, NO_SHORTCUTS)))) { -  +  no_match:    /* No match. */   #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, "%*sNo match.\n", indent*2+2, "");    }   #endif /* PIKE_DEBUG */    res = NULL;    if (tmp) free_type(tmp);    break;    }