aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-05-13 12:48:12 +0100
committergingerBill <bill@gingerbill.org>2021-05-13 12:48:12 +0100
commit63b54ce7c695fb1e204fe77db029cdebf7206b28 (patch)
treebcd4b30a071a79a71ef6f8e009fb23bcb047283d /src/check_expr.cpp
parentb8a35c658cf30a3f4f46ec40b38cdf478224a371 (diff)
Add minor ignoring hint on type assertions to get better code generation with no optimizations enabled
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 5784744d9..51dad8f79 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3949,6 +3949,16 @@ bool check_assignment_arguments(CheckerContext *ctx, Array<Operand> const &lhs,
add_type_and_value(&c->checker->info, o.expr, o.mode, tuple, o.value);
}
+ if (o.mode == Addressing_OptionalOk && expr->kind == Ast_TypeAssertion) {
+ // NOTE(bill): Used only for optimizations in the backend
+ if (is_blank_ident(lhs[0].expr)) {
+ expr->TypeAssertion.ignores[0] = true;
+ }
+ if (is_blank_ident(lhs[1].expr)) {
+ expr->TypeAssertion.ignores[1] = true;
+ }
+ }
+
array_add(operands, val0);
array_add(operands, val1);
optional_ok = true;
@@ -4063,6 +4073,16 @@ bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize lhs_count,
add_type_and_value(&c->checker->info, o.expr, o.mode, tuple, o.value);
}
+ if (o.mode == Addressing_OptionalOk && expr->kind == Ast_TypeAssertion) {
+ // NOTE(bill): Used only for optimizations in the backend
+ if (is_blank_ident(lhs[0]->token)) {
+ expr->TypeAssertion.ignores[0] = true;
+ }
+ if (is_blank_ident(lhs[1]->token)) {
+ expr->TypeAssertion.ignores[1] = true;
+ }
+ }
+
array_add(operands, val0);
array_add(operands, val1);
optional_ok = true;