mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 21:35:19 +00:00
Do naive compound literal comparison for $ parameters to parapoly procedures
This commit is contained in:
@@ -12103,6 +12103,25 @@ gb_internal bool is_exact_value_zero(ExactValue const &v) {
|
||||
|
||||
|
||||
|
||||
gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y, bool *do_break_) {
|
||||
ast_node(x_cl, CompoundLit, x.value_compound);
|
||||
ast_node(y_cl, CompoundLit, y.value_compound);
|
||||
|
||||
if (x_cl->elems.count != y_cl->elems.count) {
|
||||
if (do_break_) *do_break_ = true;
|
||||
}
|
||||
|
||||
bool test = op == Token_CmpEq;
|
||||
|
||||
for (isize i = 0; i < x_cl->elems.count; i++) {
|
||||
Ast *lhs = x_cl->elems[i];
|
||||
Ast *rhs = y_cl->elems[i];
|
||||
if (compare_exact_values(op, lhs->tav.value, rhs->tav.value) != test) {
|
||||
return !test;
|
||||
}
|
||||
}
|
||||
return test;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -947,6 +947,8 @@ gb_internal gb_inline i32 cmp_f64(f64 a, f64 b) {
|
||||
return (a > b) - (a < b);
|
||||
}
|
||||
|
||||
gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y, bool *do_break_);
|
||||
|
||||
gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) {
|
||||
match_exact_values(&x, &y);
|
||||
|
||||
@@ -1055,9 +1057,24 @@ gb_internal bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y)
|
||||
case Token_NotEq: return x.value_typeid != y.value_typeid;
|
||||
}
|
||||
break;
|
||||
|
||||
case ExactValue_Compound:
|
||||
if (op != Token_CmpEq && op != Token_NotEq) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (x.kind != y.kind) {
|
||||
break;
|
||||
}
|
||||
bool do_break = false;
|
||||
bool res = compare_exact_values_compound_lit(op, x, y, &do_break);
|
||||
if (do_break) {
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
GB_PANIC("Invalid comparison");
|
||||
GB_PANIC("Invalid comparison: %d", x.kind);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user