mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix #2188
This commit is contained in:
+6
-5
@@ -2291,8 +2291,6 @@ void check_matrix_type(CheckerContext *ctx, Type **type, Ast *node) {
|
|||||||
i64 row_count = check_array_count(ctx, &row, mt->row_count);
|
i64 row_count = check_array_count(ctx, &row, mt->row_count);
|
||||||
i64 column_count = check_array_count(ctx, &column, mt->column_count);
|
i64 column_count = check_array_count(ctx, &column, mt->column_count);
|
||||||
|
|
||||||
Type *elem = check_type_expr(ctx, mt->elem, nullptr);
|
|
||||||
|
|
||||||
Type *generic_row = nullptr;
|
Type *generic_row = nullptr;
|
||||||
Type *generic_column = nullptr;
|
Type *generic_column = nullptr;
|
||||||
|
|
||||||
@@ -2304,23 +2302,26 @@ void check_matrix_type(CheckerContext *ctx, Type **type, Ast *node) {
|
|||||||
generic_column = column.type;
|
generic_column = column.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_count < MATRIX_ELEMENT_COUNT_MIN && generic_row == nullptr) {
|
if (generic_row == nullptr && row_count < MATRIX_ELEMENT_COUNT_MIN) {
|
||||||
gbString s = expr_to_string(row.expr);
|
gbString s = expr_to_string(row.expr);
|
||||||
error(row.expr, "Invalid matrix row count, expected %d+ rows, got %s", MATRIX_ELEMENT_COUNT_MIN, s);
|
error(row.expr, "Invalid matrix row count, expected %d+ rows, got %s", MATRIX_ELEMENT_COUNT_MIN, s);
|
||||||
gb_string_free(s);
|
gb_string_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column_count < MATRIX_ELEMENT_COUNT_MIN && generic_column == nullptr) {
|
if (generic_column == nullptr && column_count < MATRIX_ELEMENT_COUNT_MIN) {
|
||||||
gbString s = expr_to_string(column.expr);
|
gbString s = expr_to_string(column.expr);
|
||||||
error(column.expr, "Invalid matrix column count, expected %d+ rows, got %s", MATRIX_ELEMENT_COUNT_MIN, s);
|
error(column.expr, "Invalid matrix column count, expected %d+ rows, got %s", MATRIX_ELEMENT_COUNT_MIN, s);
|
||||||
gb_string_free(s);
|
gb_string_free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (row_count*column_count > MATRIX_ELEMENT_COUNT_MAX) {
|
if ((generic_row == nullptr && generic_column == nullptr) && row_count*column_count > MATRIX_ELEMENT_COUNT_MAX) {
|
||||||
i64 element_count = row_count*column_count;
|
i64 element_count = row_count*column_count;
|
||||||
error(column.expr, "Matrix types are limited to a maximum of %d elements, got %lld", MATRIX_ELEMENT_COUNT_MAX, cast(long long)element_count);
|
error(column.expr, "Matrix types are limited to a maximum of %d elements, got %lld", MATRIX_ELEMENT_COUNT_MAX, cast(long long)element_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Type *elem = check_type_expr(ctx, mt->elem, nullptr);
|
||||||
|
|
||||||
if (!is_type_valid_for_matrix_elems(elem)) {
|
if (!is_type_valid_for_matrix_elems(elem)) {
|
||||||
if (elem == t_typeid) {
|
if (elem == t_typeid) {
|
||||||
Entity *e = entity_of_node(mt->elem);
|
Entity *e = entity_of_node(mt->elem);
|
||||||
|
|||||||
@@ -3916,13 +3916,7 @@ i64 type_size_of_internal(Type *t, TypePath *path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Type_Matrix: {
|
case Type_Matrix: {
|
||||||
bool pop = type_path_push(path, t->Matrix.elem);
|
|
||||||
if (path->failure) {
|
|
||||||
return FAILURE_SIZE;
|
|
||||||
}
|
|
||||||
i64 stride_in_bytes = matrix_type_stride_in_bytes(t, path);
|
i64 stride_in_bytes = matrix_type_stride_in_bytes(t, path);
|
||||||
if (pop) type_path_pop(path);
|
|
||||||
|
|
||||||
return stride_in_bytes * t->Matrix.column_count;
|
return stride_in_bytes * t->Matrix.column_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user