예제 #1
0
파일: subtype.c 프로젝트: pengzj/ponyc
// The subtype is a nominal, the supertype could be anything.
static bool is_nominal_subtype(ast_t* sub, ast_t* super)
{
  // Special case Pointer[A]. It can only be a subtype of itself, because
  // in the code generator, a pointer has no vtable.
  if(is_pointer(sub))
    return is_pointer_subtype(sub, super);

  switch(ast_id(super))
  {
    case TK_NOMINAL:
      return is_nominal_sub_nominal(sub, super);

    case TK_TYPEPARAMREF:
      return is_nominal_sub_typeparam(sub, super);

    case TK_UNIONTYPE:
      return is_subtype_union(sub, super);

    case TK_ISECTTYPE:
      return is_subtype_isect(sub, super);

    case TK_ARROW:
      return is_subtype_arrow(sub, super);

    default: {}
  }

  return false;
}
예제 #2
0
파일: subtype.c 프로젝트: jersey99/ponyc
static bool is_nominal_sub_x(ast_t* sub, ast_t* super, errorframe_t* errors)
{
  // N k <: T
  switch(ast_id(super))
  {
    case TK_UNIONTYPE:
      return is_x_sub_union(sub, super, errors);

    case TK_ISECTTYPE:
      return is_x_sub_isect(sub, super, errors);

    case TK_TUPLETYPE:
      return is_single_sub_tuple(sub, super, errors);

    case TK_NOMINAL:
      return is_nominal_sub_nominal(sub, super, errors);

    case TK_TYPEPARAMREF:
      return is_nominal_sub_typeparam(sub, super, errors);

    case TK_ARROW:
      return is_nominal_sub_arrow(sub, super, errors);

    default: {}
  }

  assert(0);
  return false;
}