pike.git / src / las.cmod

version» Context lines:

pike.git/src/las.cmod:272:    }       case F_PUSH_ARRAY:    return -1;       case F_APPLY:    if(CAR(n)->token == F_CONSTANT &&    TYPEOF(CAR(n)->u.sval) == T_FUNCTION &&    SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN) {    if (!n->type) fix_type_field(n); -  return !pike_types_le(n->type, void_type_string); +  return !pike_types_le(n->type, void_type_string, 0, 0);    }    return 1;       case F_RANGE_FROM_BEG:    case F_RANGE_FROM_END:    return 1;    case F_RANGE_OPEN:    return 0;       default:
pike.git/src/las.cmod:449:    yytype_report(REPORT_ERROR, NULL, 0, t, NULL, 0, diff, 0, msg);    free_type(diff);    /* print_tree(n); */    return 0;    }    if (THIS_COMPILATION->lex.pragmas & ID_STRICT_TYPES) {    yytype_report(REPORT_WARNING, NULL, 0, t, NULL, 0, diff, 0, msg);    }    free_type(diff);   #else -  if (pike_types_le(n->type, t)) return 1; +  if (pike_types_le(n->type, t, 0, 0)) return 1;    if (!match_types(n->type, t)) {    yytype_report(REPORT_ERROR, NULL, 0, t, NULL, 0, n->type, 0, msg);    return 0;    }    if (THIS_COMPILATION->lex.pragmas & ID_STRICT_TYPES) {    yytype_report(REPORT_WARNING, NULL, 0, t, NULL, 0, n->type, 0, msg);    }   #endif    if (runtime_options & RUNTIME_CHECK_TYPES) {    node *p = n->parent;
pike.git/src/las.cmod:3243:   {    struct compilation *c = THIS_COMPILATION;    node *expression, *lvalues;       if (!val_lval || (val_lval->token != F_FOREACH_VAL_LVAL)) return;       fix_type_field(val_lval);    expression = CAR(val_lval);    lvalues = CDR(val_lval);    -  if (!expression || pike_types_le(expression->type, void_type_string)) { +  if (!expression || pike_types_le(expression->type, void_type_string, 0, 0)) {    yyerror("foreach(): Looping over a void expression.");    } else {    if(lvalues && lvalues->token == ':')    {    /* Check the iterator type */    struct pike_type *iterator_type;    struct pike_type *foreach_call_type;    MAKE_CONSTANT_TYPE(iterator_type,    tOr5(tArray, tStr, tObj,    tMapping, tMultiset));
pike.git/src/las.cmod:3295:    /* Should not happen. */    yytype_report(REPORT_ERROR,    NULL, 0, NULL,    NULL, 0, NULL,    0, "Bad iterator type for index in foreach().");    } else {    if( CAR(lvalues)->type->type == PIKE_T_AUTO )    {    fix_auto_node(CAR(lvalues), index_type);    } -  else if (!pike_types_le(index_type, CAR(lvalues)->type)) { +  else if (!pike_types_le(index_type, CAR(lvalues)->type, 0, 0)) {    int level = REPORT_NOTICE;    if (!match_types(CAR(lvalues)->type, index_type)) {    level = REPORT_ERROR;    } else if (c->lex.pragmas & ID_STRICT_TYPES) {    level = REPORT_WARNING;    }    yytype_report(level,    NULL, 0, index_type,    NULL, 0, CAR(lvalues)->type,    0, "Type mismatch for index in foreach().");
pike.git/src/las.cmod:3335:    /* Should not happen. */    yytype_report(REPORT_ERROR,    NULL, 0, NULL,    NULL, 0, NULL,    0, "Bad iterator type for value in foreach().");    } else {    if( CDR(lvalues)->type->type == PIKE_T_AUTO )    {    fix_auto_node(CDR(lvalues), value_type);    } -  else if (!pike_types_le(value_type, CDR(lvalues)->type)) { +  else if (!pike_types_le(value_type, CDR(lvalues)->type, 0, 0)) {    int level = REPORT_NOTICE;    if (!match_types(CDR(lvalues)->type, value_type)) {    level = REPORT_ERROR;    } else if (c->lex.pragmas & ID_STRICT_TYPES) {    level = REPORT_WARNING;    }    yytype_report(level,    NULL, 0, value_type,    NULL, 0, CDR(lvalues)->type,    0, "Type mismatch for value in foreach().");
pike.git/src/las.cmod:3357:    free_type(value_type);    }    free_type(value_fun_type);    }    free_type(foreach_call_type);    } else {    /* Old-style foreach */    struct pike_type *array_zero;    MAKE_CONSTANT_TYPE(array_zero, tLArr(tUnknown, tUnknown));    -  if (!pike_types_le(array_zero, expression->type)) { +  if (!pike_types_le(array_zero, expression->type, 0, 0)) {    yytype_report(REPORT_ERROR,    NULL, 0, array_zero,    NULL, 0, expression->type,    0, "Bad argument 1 to foreach().");    } else {    if ((c->lex.pragmas & ID_STRICT_TYPES) && -  !pike_types_le(expression->type, array_type_string)) { +  !pike_types_le(expression->type, array_type_string, 0, 0)) {    yytype_report(REPORT_WARNING,    NULL, 0, array_type_string,    NULL, 0, expression->type,    0,    "Argument 1 to foreach() is not always an array.");    }       if (!lvalues) {    /* No loop variable. Will be converted to a counted loop    * by treeopt. */    } else if( lvalues->type->type == PIKE_T_AUTO ) {    fix_auto_node(lvalues, expression->type->car); -  } else if (pike_types_le(lvalues->type, void_type_string)) { +  } else if (pike_types_le(lvalues->type, void_type_string, 0, 0)) {    yytype_report(REPORT_ERROR,    NULL, 0, expression->type->car,    NULL, 0, lvalues->type,    0,    "Bad argument 2 to foreach().");    } else {    struct pike_type *array_value_type;       type_stack_mark();    push_finished_type(lvalues->type);
pike.git/src/las.cmod:3693:    z = 1;    z= 10;       -> typeof(z) == int(1)|int(10)    */    }   #if 0    /* This test isn't sufficient, see below. */    check_node_type(CDR(n), CAR(n)->type, "Bad type in assignment.");   #else /* !0 */ -  if (!pike_types_le(CDR(n)->type, CAR(n)->type)) { +  if (!pike_types_le(CDR(n)->type, CAR(n)->type, 0, 0)) {    /* a["b"]=c and a->b=c can be valid when a is an array.    *    * FIXME: Exactly what case is the problem?    * /grubba 2005-02-15    *    * Example:    * array tmp = ({([]),([])});    * tmp->foo = 7; // Multi-assign.    * /grubba 2007-04-27    */
pike.git/src/las.cmod:3841:    if (f) {    struct pike_type *ret = new_get_return_type(f, 0);    free_type(f);    f = ret;    }       if (f) {    /* Check that the returned type is compatible with the    * variable type.    */ -  if (!pike_types_le(f, CAR(n)->type)) { +  if (!pike_types_le(f, CAR(n)->type, 0, 0)) {    /* a["b"]+=c and a->b+=c can be valid when a is an array.    *    * FIXME: Exactly what case is the problem?    * /grubba 2005-02-15    *    * Example:    * array tmp = ({([]),([])});    * tmp->foo += 7; // Multi-assign.    * /grubba 2007-04-27    */
pike.git/src/las.cmod:3980:    NULL : CAR (low)->type,    ((high->token == F_RANGE_OPEN) || !CAR(high)) ?    NULL : CAR (high)->type);    }    break;       case F_PUSH_ARRAY:    if (CAR(n)) {    struct pike_type *array_type;    MAKE_CONSTANT_TYPE(array_type, tArr(tZero)); -  if (!pike_types_le(array_type, CAR(n)->type)) { +  if (!pike_types_le(array_type, CAR(n)->type, 0, 0)) {    yytype_report(REPORT_ERROR, NULL, 0, array_type,    NULL, 0, CAR(n)->type,    0, "Bad argument to splice operator.");    }    free_type(array_type);    /* FIXME: The type field of the splice operator is not yet utilized.    *    * It probably ought to be something similar to MANY(..., VOID).    */    n->type = index_type(CAR(n)->type, int_type_string, n);
pike.git/src/las.cmod:4197:    if (!match_types(CAR(n)->type, int_type_string) ||    !match_types(CDR(n)->type, int_type_string)) {    yytype_report(REPORT_ERROR,    NULL, 0, CAR(n)->type,    NULL, 0, CDR(n)->type,    0, "Type mismatch in case range.");    }    } else if ((c->lex.pragmas & ID_STRICT_TYPES) &&    (CAR(n)->type != CDR(n)->type)) {    /* The type should be the same for both CAR & CDR. */ -  if (!pike_types_le(CDR(n)->type, CAR(n)->type)) { +  if (!pike_types_le(CDR(n)->type, CAR(n)->type, 0, 0)) {    /* Note that zero should be handled as int(0..0) here. */    if (!(CAR(n)->type == zero_type_string) || -  !(pike_types_le(CDR(n)->type, int_type_string))) { +  !(pike_types_le(CDR(n)->type, int_type_string, 0, 0))) {    yytype_report(REPORT_ERROR,    NULL, 0, CAR(n)->type,    NULL, 0, CDR(n)->type,    0, "Type mismatch in case range.");    } -  } else if (!pike_types_le(CAR(n)->type, CDR(n)->type)) { +  } else if (!pike_types_le(CAR(n)->type, CDR(n)->type, 0, 0)) {    if (!(CDR(n)->type == zero_type_string) || -  !(pike_types_le(CAR(n)->type, int_type_string))) { +  !(pike_types_le(CAR(n)->type, int_type_string, 0, 0))) {    yytype_report(REPORT_WARNING,    NULL, 0, CAR(n)->type,    NULL, 0, CDR(n)->type,    0, "Type mismatch in case range.");    }    }    }    }    if (CDR(n) && (Pike_compiler->compiler_pass == COMPILER_PASS_LAST)) {    fix_type_field(CDR(n));
pike.git/src/las.cmod:4282:    break;       case F_CONSTANT:    n->type = get_type_of_svalue(&n->u.sval);    break;       case F_FOREACH:    if (!CAR(n) || (CAR(n)->token != F_FOREACH_VAL_LVAL)) {    yyerror("foreach(): No expression to loop over.");    } else { -  if (!CAAR(n) || pike_types_le(CAAR(n)->type, void_type_string)) { +  if (!CAAR(n) || pike_types_le(CAAR(n)->type, void_type_string, 0, 0)) {    yyerror("foreach(): Looping over a void expression.");    } else {    fix_foreach_type(CAR(n));    }    }    copy_pike_type(n->type, void_type_string);    break;       case F_SSCANF:    if (!CAR(n) || (CAR(n)->token != F_ARG_LIST) || !CAAR(n))
pike.git/src/las.cmod:4833:    return n;    }    new = mksvaluenode(Pike_sp-1);    if (new->type &&    ((new->type->type == PIKE_T_INT) || (new->type->type == PIKE_T_TYPE))) {    /* Ok. */    } else if (n->type) {    if (!new->type) {    new->type = n->type;    add_ref(n->type); -  } else if (!pike_types_le(new->type, n->type)) { +  } else if (!pike_types_le(new->type, n->type, 0, 0)) {    /* Try consolidating the type information. */    struct pike_type *t = soft_cast(n->type, new->type, 0);    if (t) {    free_type(new->type);    new->type = t;    } else {    new = mksoftcastnode(n->type, new);    }    }    }