Пример #1
0
static bool is_typeparam_sub_x(ast_t* sub, ast_t* super, errorframe_t* errors)
{
  if(is_typeparam_base_sub_x(sub, super, false))
    return true;

  // upperbound(A k) <: T
  // ---
  // A k <: T
  ast_t* sub_upper = typeparam_upper(sub);

  if(sub_upper == NULL)
  {
    if(errors != NULL)
    {
      ast_error_frame(errors, sub,
        "%s is not a subtype of %s: the subtype has no constraint",
        ast_print_type(sub), ast_print_type(super));
    }

    return false;
  }

  bool ok = is_subtype(sub_upper, super, errors);
  ast_free_unattached(sub_upper);
  return ok;
}
Пример #2
0
static matchtype_t is_x_match_typeparam(ast_t* operand, ast_t* pattern)
{
  ast_t* pattern_upper = typeparam_upper(pattern);

  // An unconstrained typeparam can match anything.
  if(pattern_upper == NULL)
    return MATCHTYPE_ACCEPT;

  // Otherwise, match the constraint.
  matchtype_t ok = is_matchtype(operand, pattern_upper);
  ast_free_unattached(pattern_upper);
  return ok;
}
Пример #3
0
static matchtype_t is_typeparam_match_x(ast_t* operand, ast_t* pattern)
{
  ast_t* operand_upper = typeparam_upper(operand);

  // An unconstrained typeparam could match anything.
  if(operand_upper == NULL)
    return MATCHTYPE_ACCEPT;

  // Check if the constraint can match the pattern.
  matchtype_t ok = is_matchtype(operand_upper, pattern);
  ast_free_unattached(operand_upper);
  return ok;
}
Пример #4
0
static matchtype_t is_x_match_typeparam(ast_t* operand, ast_t* pattern,
  errorframe_t* errorf, bool report_reject, pass_opt_t* opt)
{
  ast_t* pattern_upper = typeparam_upper(pattern);

  // An unconstrained typeparam can match anything.
  if(pattern_upper == NULL)
    return MATCHTYPE_ACCEPT;

  // Otherwise, match the constraint.
  matchtype_t ok = is_x_match_x(operand, pattern_upper, errorf, report_reject,
    opt);
  ast_free_unattached(pattern_upper);
  return ok;
}
Пример #5
0
static matchtype_t is_typeparam_match_x(ast_t* operand, ast_t* pattern,
  errorframe_t* errorf, bool report_reject, pass_opt_t* opt)
{
  ast_t* operand_upper = typeparam_upper(operand);

  // An unconstrained typeparam could match anything.
  if(operand_upper == NULL)
    return MATCHTYPE_ACCEPT;

  // Check if the constraint can match the pattern.
  matchtype_t ok = is_x_match_x(operand_upper, pattern, errorf, report_reject,
    opt);
  ast_free_unattached(operand_upper);
  return ok;
}