Branch: Tag:

2020-08-20

2020-08-20 08:51:30 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Use match_types() where possible.

Preparation for having low_match_types() add a reference to
its return value.

5528:    free_type(a);    push_unlimited_array_type(T_ARRAY);    -  if (low_match_types(int_type_string, index_type, 0)) { +  if (match_types(int_type_string, index_type)) {    /* Also possible to index the array with an int. */    push_finished_type(t->cdr);    push_type(T_OR);    }    return pop_unfinished_type();    } -  if (low_match_types(int_type_string, index_type, 0)) { +  if (match_types(int_type_string, index_type)) {    /* Possible to index the array with an int. */    add_ref(t->cdr);    return t->cdr;
5709:    case T_STRING:    /* Check that the index types are compatible with int. */    { -  if (index1_type && !low_match_types(int_type_string, index1_type, 0)) { +  if (index1_type && !match_types(int_type_string, index1_type)) {    ref_push_type_value(t);    yytype_report(REPORT_WARNING, NULL, 0, int_type_string,    NULL, 0, index1_type,
5717:    /* Bad index1 type. */    return 0;    } -  if (index2_type && !low_match_types(int_type_string, index2_type, 0)) { +  if (index2_type && !match_types(int_type_string, index2_type)) {    ref_push_type_value(t);    yytype_report(REPORT_WARNING, NULL, 0, int_type_string,    NULL, 0, index2_type,
5966:    return low_check_indexing(type->cdr, index_type, n);       case T_ARRAY: -  if(low_match_types(string_type_string, index_type, 0) && +  if(match_types(string_type_string, index_type) &&    low_check_indexing(type->cdr, index_type, n))    return 1;    /* FALLTHRU */    case T_STRING: -  return !!low_match_types(int_type_string, index_type, 0); +  return match_types(int_type_string, index_type);       case T_OBJECT:    {
5996:    }    return 0;    } -  return !!low_match_types(string_type_string, index_type,0); +  return match_types(string_type_string, index_type);    }else{    return 1;    }
6009:    * - There were complaints when people got compilation errors    * for indexing operations that would always fail.    */ -  return low_match_types(type->car, index_type, 0) ? 1 : -1; +  return match_types(type->car, index_type) ? 1 : -1;       case T_FUNCTION:    while ((type = type->cdr) && (type->type == T_FUNCTION))
6030:       case T_INT:    case T_PROGRAM: -  return !!low_match_types(string_type_string, index_type, 0); +  return match_types(string_type_string, index_type);       case T_MIXED:    return 1;
8233:    case PIKE_T_FUNCTION:    if (!(flags & CALL_NOT_LAST_ARG) &&    (fun_type->cdr->type == PIKE_T_FUNCTION) && -  !low_match_types(fun_type->cdr->car, void_type_string, 0)) { +  !match_types(fun_type->cdr->car, void_type_string)) {    /* Last argument and more arguments required. */    res = NULL;    break;