aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-10-21 01:14:44 +0100
committergingerBill <bill@gingerbill.org>2021-10-21 01:14:44 +0100
commite0b9475378f4d69ebaf3e141ed941674b2c0d3f3 (patch)
tree15147d229ca88cd43a62051129e3804a374bded0 /src/check_expr.cpp
parentc561de33eec802578b2f56b303b0909a346e897c (diff)
Allow casting between square matrices of the same element type
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 498bf78c7..ad12e00c8 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2460,6 +2460,24 @@ bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y) {
if (is_type_quaternion(src) && is_type_quaternion(dst)) {
return true;
}
+
+ if (is_type_matrix(src) && is_type_matrix(dst)) {
+ GB_ASSERT(src->kind == Type_Matrix);
+ GB_ASSERT(dst->kind == Type_Matrix);
+ if (!are_types_identical(src->Matrix.elem, dst->Matrix.elem)) {
+ return false;
+ }
+
+ if (src->Matrix.row_count != src->Matrix.column_count) {
+ return false;
+ }
+
+ if (dst->Matrix.row_count != dst->Matrix.column_count) {
+ return false;
+ }
+
+ return true;
+ }
// Cast between pointers
@@ -8838,6 +8856,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
case Ast_EnumType:
case Ast_MapType:
case Ast_BitSetType:
+ case Ast_MatrixType:
o->mode = Addressing_Type;
o->type = check_type(c, node);
break;