Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen committed Jan 22, 2025
1 parent 01d24a5 commit 4e4a55c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/libponyc/codegen/genmatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ LLVMValueRef gen_match(compile_t* c, ast_t* ast)
ast_t* pattern_type = deferred_reify(reify, ast_type(the_case), c->opt);
bool ok = true;

matchtype_t match = is_matchtype(match_type, pattern_type, NULL, c->opt);
matchtype_t match = is_matchtype_with_consumed_pattern(match_type, pattern_type, NULL, c->opt);

ast_free_unattached(pattern_type);

Expand Down
6 changes: 3 additions & 3 deletions src/libponyc/codegen/gentrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static int trace_cap_nominal(pass_opt_t* opt, ast_t* type, ast_t* orig,
// val and tag in that order.
if(orig_cap == TK_ISO)
{
if(is_astype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
if(is_matchtype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
{
return PONY_TRACE_MUTABLE;
} else {
Expand All @@ -556,7 +556,7 @@ static int trace_cap_nominal(pass_opt_t* opt, ast_t* type, ast_t* orig,

if(ast_id(cap) == TK_VAL)
{
if(is_astype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
if(is_matchtype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
{
ast_setid(cap, orig_cap);
return PONY_TRACE_IMMUTABLE;
Expand All @@ -568,7 +568,7 @@ static int trace_cap_nominal(pass_opt_t* opt, ast_t* type, ast_t* orig,
pony_assert(ast_id(cap) == TK_TAG);

int ret = -1;
if(is_astype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
if(is_matchtype(orig, type, NULL, opt) == MATCHTYPE_ACCEPT)
ret = PONY_TRACE_OPAQUE;

ast_setid(cap, orig_cap);
Expand Down
2 changes: 1 addition & 1 deletion src/libponyc/expr/match.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ bool expr_case(pass_opt_t* opt, ast_t* ast)
bool ok = true;
errorframe_t info = NULL;

switch(is_matchtype(match_type, pattern_type, &info, opt))
switch(is_matchtype_with_consumed_pattern(match_type, pattern_type, &info, opt))
{
case MATCHTYPE_ACCEPT:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libponyc/expr/operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static bool add_as_type(pass_opt_t* opt, ast_t* ast, ast_t* expr,

ast_t* expr_type = ast_type(expr);
errorframe_t info = NULL;
matchtype_t is_match = is_astype(expr_type, type, &info, opt);
matchtype_t is_match = is_matchtype(expr_type, type, &info, opt);
if(is_match == MATCHTYPE_DENY_CAP)
{
errorframe_t frame = NULL;
Expand Down
12 changes: 6 additions & 6 deletions src/libponyc/type/matchtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,12 @@ static matchtype_t is_x_match_x(ast_t* operand, ast_t* pattern,

matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
pass_opt_t* opt)
{
return is_x_match_x(operand, pattern, errorf, true, opt);
}

matchtype_t is_matchtype_with_consumed_pattern(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
pass_opt_t* opt)
{
ast_t* consumed_pattern = consume_type(pattern, TK_NONE, false);
if (consumed_pattern == NULL)
Expand All @@ -942,9 +948,3 @@ matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,

return rslt;
}

matchtype_t is_astype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
pass_opt_t* opt)
{
return is_x_match_x(operand, pattern, errorf, true, opt);
}
6 changes: 2 additions & 4 deletions src/libponyc/type/matchtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
pass_opt_t* opt);

/**
* Same as is_matchtype() but specifically designed to work with `as` which
* under the steed model, needs to act differently than matchwith respect
* to iso.
* Same as is_matchtype() but it consumes the pattern type and then sees if a match works. Used in match.c and genmatch.c to close issue #4579.
*/
matchtype_t is_astype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
matchtype_t is_matchtype_with_consumed_pattern(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
pass_opt_t* opt);

PONY_EXTERN_C_END
Expand Down

0 comments on commit 4e4a55c

Please sign in to comment.