Branch: Tag:

2020-08-30

2020-08-30 11:37:36 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Port type matching changes to pike_types_le().

* Protect against infinite recursion.

* Perform proper checking of transitive types (via expand_transitive()).

4542:    * with a mapping(int:int) won't change the type of the mapping after the    * operation.    */ - #ifdef PIKE_TYPE_DEBUG +    static int low_pike_types_le2(struct pike_type *a, struct pike_type *b,    int array_cnt, unsigned int flags); - #endif /* PIKE_TYPE_DEBUG */ +    static int low_pike_types_le(struct pike_type *a, struct pike_type *b,    int array_cnt, unsigned int flags) - #ifdef PIKE_TYPE_DEBUG +    {    int res; -  +  DECLARE_CYCLIC();    -  + #ifdef PIKE_TYPE_DEBUG    if (l_flag>2) {   #if 0    struct compilation *c = MAYBE_THIS_COMPILATION;
4567:    indent*2 + 18, "", array_cnt, flags);    indent++;    } + #endif /* PIKE_TYPE_DEBUG */    -  +  if (!(res = (int)(ptrdiff_t)BEGIN_CYCLIC(a, b))) { +  SET_CYCLIC_RET(1); +     res = low_pike_types_le2(a, b, array_cnt, flags); -  +  } +  END_CYCLIC();    -  + #ifdef PIKE_TYPE_DEBUG    if (l_flag>2) {    indent--;       fprintf(stderr, "%*s= %d\n", indent*2, "", res);    } -  + #endif /* PIKE_TYPE_DEBUG */    return res;   }      static int low_pike_types_le2(struct pike_type *a, struct pike_type *b,    int array_cnt, unsigned int flags) - #endif /* PIKE_TYPE_DEBUG */ +    {    struct compilation *c = MAYBE_THIS_COMPILATION;    int ret;
4770:       case PIKE_T_TRANSITIVE:    { -  /* FIXME */ -  return 1; +  struct pike_type *t = +  expand_transitive(b, ((flags & LE_A_B_SWAPPED)?a_markers:b_markers), 0); +  ret = low_pike_types_le(a, t, array_cnt, flags); +  free_type(t); +  return ret;    }    }   
5002:       case PIKE_T_TRANSITIVE:    { -  /* FIXME */ -  return 1; +  struct pike_type *t = +  expand_transitive(a, ((flags & LE_A_B_SWAPPED)?b_markers:a_markers), 0); +  ret = low_pike_types_le(t, b, array_cnt, flags); +  free_type(t); +  return ret;    }    }