aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-19 21:05:23 +0000
committergingerBill <bill@gingerbill.org>2024-03-19 21:05:23 +0000
commita750fc0ba63c9f1461bba4cc0446b1b4c2d2b3a9 (patch)
treeb60c41fc88da2c4af2ac1b23639cdafd8e3bcf0f /src/parser.cpp
parent433109ff52d2db76069273cd53b7aebf6aea9be0 (diff)
Add `#row_major matrix[R, C]T`
As well as `#column_major matrix[R, C]T` as an alias for just `matrix[R, C]T`. This is because some libraries require a row_major internal layout but still want to be used with row or major oriented vectors.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 1aa40ccbf..eb9e73342 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -2329,6 +2329,19 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
break;
}
return original_type;
+ } else if (name.string == "row_major" ||
+ name.string == "column_major") {
+ Ast *original_type = parse_type(f);
+ Ast *type = unparen_expr(original_type);
+ switch (type->kind) {
+ case Ast_MatrixType:
+ type->MatrixType.is_row_major = (name.string == "row_major");
+ break;
+ default:
+ syntax_error(type, "Expected a matrix type after #%.*s, got %.*s", LIT(name.string), LIT(ast_strings[type->kind]));
+ break;
+ }
+ return original_type;
} else if (name.string == "partial") {
Ast *tag = ast_basic_directive(f, token, name);
Ast *original_expr = parse_expr(f, lhs);