pike.git / src / pike_types.cmod

version» Context lines:

pike.git/src/pike_types.cmod:4949:    return NULL;    }    } else {    tmp = low_type_binop(op, a->cdr, b, remap, aflags, bflags, remap_flags);       if (!tmp) {    if (c && (op == PT_BINOP_MINUS)) {    ref_push_string((struct pike_string *)a->car);    ref_push_type_value(a->cdr);    ref_push_type_value(b); +  if (remap) { +  if (!remap->state) { +  remap->state = allocate_mapping(4); +  } +  ref_push_mapping(remap->state); +  safe_apply_current2(PC_POP_TYPE_ATTRIBUTE_FUN_NUM, 4, +  "pop_type_attribute"); +  } else {    safe_apply_current2(PC_POP_TYPE_ATTRIBUTE_FUN_NUM, 3,    "pop_type_attribute"); -  +  }    if ((TYPEOF(Pike_sp[-1]) == T_INT) &&    (SUBTYPEOF(Pike_sp[-1]) == NUMBER_NUMBER) &&    (!Pike_sp[-1].u.integer)) {    /* Forced mismatch. */    pop_stack();    return remap_markers(a, remap, remap_flags);    } -  +  if (TYPEOF(Pike_sp[-1]) == PIKE_T_TYPE) { +  /* Alternative type for a. */ +  tmp = low_type_binop(op, Pike_sp[-1].u.type, b, remap, +  aflags, bflags, remap_flags);    pop_stack(); -  +  return tmp;    } -  +  pop_stack(); +  }    return NULL;    }    }       type_stack_mark();    push_finished_type(tmp);    if (op == PT_BINOP_AND) {    push_type_attribute((struct pike_string *)(a->car));    }    free_type(tmp);
pike.git/src/pike_types.cmod:5000:    push_type_name((struct pike_string *)(b->car));    free_type(tmp);    return pop_unfinished_type();    case PIKE_T_ATTRIBUTE:    tmp = low_type_binop(op, a, b->cdr, remap, aflags, bflags, remap_flags);    if (!tmp) {    if (a && c && (op == PT_BINOP_MINUS)) {    ref_push_string((struct pike_string *)b->car);    ref_push_type_value(a);    ref_push_type_value(b->cdr); +  if (remap) { +  if (!remap->state) { +  remap->state = allocate_mapping(4); +  } +  ref_push_mapping(remap->state); +  safe_apply_current2(PC_PUSH_TYPE_ATTRIBUTE_FUN_NUM, 4, +  "push_type_attribute"); +  } else {    safe_apply_current2(PC_PUSH_TYPE_ATTRIBUTE_FUN_NUM, 3,    "push_type_attribute"); -  +  }    if ((TYPEOF(Pike_sp[-1]) == T_INT) &&    (SUBTYPEOF(Pike_sp[-1]) == NUMBER_NUMBER) &&    (!Pike_sp[-1].u.integer)) {    /* Forced mismatch. */    pop_stack();    return remap_markers(a, remap, remap_flags);    } -  +  if (TYPEOF(Pike_sp[-1]) == PIKE_T_TYPE) { +  /* Alternative type for b. */ +  tmp = low_type_binop(op, a, Pike_sp[-1].u.type, remap, +  aflags, bflags, remap_flags);    pop_stack(); -  +  return tmp;    } -  +  pop_stack(); +  }    return NULL;    }       type_stack_mark();    push_finished_type(tmp);    if (op == PT_BINOP_AND) {    push_type_attribute((struct pike_string *)(b->car));    }    free_type(tmp);   
pike.git/src/pike_types.cmod:11845:       case PIKE_T_ATTRIBUTE:    res = lower_new_check_call(fun_type->cdr, arg_type, flags,    cs, sval CHECK_CALL_ARGS);    if (!res) return NULL;    if (c) {    if (!cs->m) {    cs->m = allocate_mapping(0);    }    ref_push_string((struct pike_string *)fun_type->car); -  ref_push_type_value(fun_type->cdr); -  ref_push_type_value(arg_type); +  ref_push_type_value(res);    ref_push_mapping(cs->m); -  safe_apply_current2(PC_APPLY_TYPE_ATTRIBUTE_FUN_NUM, 4, +  safe_apply_current2(PC_APPLY_TYPE_ATTRIBUTE_FUN_NUM, 3,    "apply_type_attribute");    if ((TYPEOF(Pike_sp[-1]) == T_INT) &&    (SUBTYPEOF(Pike_sp[-1]) == NUMBER_NUMBER) &&    (!Pike_sp[-1].u.integer)) {    pop_stack();    free_type(res);    return NULL;    }    pop_stack();    }
pike.git/src/pike_types.cmod:12111:    if (l_flag>2) {    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");    remap_flags |= PT_FLAG_REMAP_TRACE;    }   #endif /* PIKE_DEBUG */    +  if (!cs->m) { +  cs->m = allocate_mapping(4); +  } +  add_ref(remap.state = cs->m); +  +  push_int(cs->argno); +  push_constant_text("argno"); +  mapping_insert(cs->m, Pike_sp-1, Pike_sp-2); +  pop_n_elems(2); +     /* No need to perform advanced checking in the trivial case... */    if (arg_type != (tmp2 = fun_type->car)) {    if (tmp2 == void_type_string) {    /* No more arguments accepted. */    goto no_match;    }    if (flags & CALL_ARG_LVALUE) {    /* For lvalues (ie sscanf) the direction is reversed. */    struct pike_type *tmp3 = tmp2;    tmp2 = arg_type;
pike.git/src/pike_types.cmod:12233:    if (sval) {    push_svalue(sval);    } else {    push_undefined();    }    ref_push_type_value(arg_match);    ref_push_type_value(res);    ref_push_mapping(cs->m);    safe_apply_current(PC_APPLY_ATTRIBUTE_CONSTANT_FUN_NUM, 5);    if (TYPEOF(Pike_sp[-1]) == PIKE_T_TYPE) { +  /* Got an alternative type for fun_type. +  * +  * Merge the two types. +  */    type_stack_mark();    push_finished_type(Pike_sp[-1].u.type);    push_finished_type(res);    push_type(T_AND);    free_type(res);    res = pop_unfinished_type(); -  +  } else if ((TYPEOF(Pike_sp[-1]) == PIKE_T_INT) && +  !SUBTYPEOF(Pike_sp[-1])) { +  /* Attribute handler says mismatch. */ +  free_type(res); +  res = NULL; +  tmp2 = NULL;    }    pop_stack();    }    }    }       free_type(arg_match);    }   #ifdef PIKE_DEBUG    if (l_flag>2) {
pike.git/src/pike_types.cmod:12529:    case PIKE_T_SCOPE:    case T_ASSIGN:    case PIKE_T_NAME:    fun_type = fun_type->cdr;    goto loop;       case PIKE_T_ATTRIBUTE:    tmp = new_get_return_type(fun_type->cdr, cs, flags);    if (!tmp) break;    if (c) { +  if (!cs->m) { +  cs->m = allocate_mapping(0); +  }    ref_push_string((struct pike_string *)fun_type->car); -  ref_push_type_value(fun_type->cdr); -  safe_apply_current2(PC_APPLY_TYPE_ATTRIBUTE_FUN_NUM, 2, +  push_undefined(); +  ref_push_mapping(cs->m); +  safe_apply_current2(PC_APPLY_TYPE_ATTRIBUTE_FUN_NUM, 3,    "apply_type_attribute");    if ((TYPEOF(Pike_sp[-1]) == T_INT) &&    (SUBTYPEOF(Pike_sp[-1]) == NUMBER_NUMBER) &&    (!Pike_sp[-1].u.integer)) {    free_type(tmp);    pop_stack();    break;    }    pop_stack();    }
pike.git/src/pike_types.cmod:12728:   #endif /* PIKE_DEBUG */       type_stack_mark();       /* Get rid of any remaining markers. */    clear_markers();    push_finished_type_with_markers(res, a_markers, 0);       free_type(res);    +  for (tmp = peek_type_stack(); +  tmp && ((tmp->type == PIKE_T_NAME) || (tmp->type == PIKE_T_ATTRIBUTE)); +  tmp = tmp->cdr) { +  redo: +  if (tmp->type == PIKE_T_ATTRIBUTE) { +  if (!cs->m) { +  cs->m = allocate_mapping(0); +  } +  ref_push_string((struct pike_string *)tmp->car); +  ref_push_type_value(tmp->cdr); +  ref_push_mapping(cs->m); +  safe_apply_current2(PC_EVAL_TYPE_ATTRIBUTE_FUN_NUM, 3, +  "eval_type_attribute"); +  if (TYPEOF(Pike_sp[-1]) == PIKE_T_TYPE) { +  compiler_discard_top_type(); +  push_finished_type(Pike_sp[-1].u.type); +  pop_stack(); +  +  tmp = peek_type_stack(); +  goto redo; +  } +  pop_stack(); +  } +  } +     while(array_cnt--) {    push_unlimited_array_type(PIKE_T_ARRAY);    }      #ifdef PIKE_DEBUG    if (l_flag>2) {    fprintf(stderr, " Done. Return type is ");    simple_describe_type(peek_type_stack());    fprintf(stderr, "\n");    }