Cleanup: Remove unnecessary namespace prefixes
No need to prefix with `ast::` when you're in the ast namespace already. Change-Id: Iac6cd3a215c05a80ee2035d582500f1d6c882a06 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34320 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
acf7643518
commit
03ae9a397f
|
@ -44,7 +44,7 @@ TEST_F(ArrayAccessorExpressionTest, CreateWithSource) {
|
|||
|
||||
TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) {
|
||||
ArrayAccessorExpression exp;
|
||||
EXPECT_TRUE(exp.Is<ast::ArrayAccessorExpression>());
|
||||
EXPECT_TRUE(exp.Is<ArrayAccessorExpression>());
|
||||
}
|
||||
|
||||
TEST_F(ArrayAccessorExpressionTest, IsValid) {
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace {
|
|||
using AssignmentStatementTest = TestHelper;
|
||||
|
||||
TEST_F(AssignmentStatementTest, Creation) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
EXPECT_EQ(stmt.lhs(), lhs);
|
||||
|
@ -33,8 +33,8 @@ TEST_F(AssignmentStatementTest, Creation) {
|
|||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, CreationWithSource) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt(Source{Source::Location{20, 2}}, lhs, rhs);
|
||||
auto src = stmt.source();
|
||||
|
@ -43,23 +43,23 @@ TEST_F(AssignmentStatementTest, CreationWithSource) {
|
|||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsAssign) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
EXPECT_TRUE(stmt.Is<AssignmentStatement>());
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsValid) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
EXPECT_TRUE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsValid_MissingLHS) {
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt;
|
||||
stmt.set_rhs(rhs);
|
||||
|
@ -67,7 +67,7 @@ TEST_F(AssignmentStatementTest, IsValid_MissingLHS) {
|
|||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsValid_MissingRHS) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
|
||||
AssignmentStatement stmt;
|
||||
stmt.set_lhs(lhs);
|
||||
|
@ -75,22 +75,22 @@ TEST_F(AssignmentStatementTest, IsValid_MissingRHS) {
|
|||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsValid_InvalidLHS) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
EXPECT_FALSE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, IsValid_InvalidRHS) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("");
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
EXPECT_FALSE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, ToStr) {
|
||||
auto* lhs = create<ast::IdentifierExpression>("lhs");
|
||||
auto* rhs = create<ast::IdentifierExpression>("rhs");
|
||||
auto* lhs = create<IdentifierExpression>("lhs");
|
||||
auto* rhs = create<IdentifierExpression>("rhs");
|
||||
|
||||
AssignmentStatement stmt(lhs, rhs);
|
||||
std::ostringstream out;
|
||||
|
|
|
@ -48,7 +48,7 @@ TEST_F(BinaryExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(BinaryExpressionTest, IsBinaryal) {
|
||||
BinaryExpression r;
|
||||
EXPECT_TRUE(r.Is<ast::BinaryExpression>());
|
||||
EXPECT_TRUE(r.Is<BinaryExpression>());
|
||||
}
|
||||
|
||||
TEST_F(BinaryExpressionTest, IsValid) {
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(BitcastExpressionTest, CreateWithSource) {
|
|||
|
||||
TEST_F(BitcastExpressionTest, IsBitcast) {
|
||||
BitcastExpression exp;
|
||||
EXPECT_TRUE(exp.Is<ast::BitcastExpression>());
|
||||
EXPECT_TRUE(exp.Is<BitcastExpression>());
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, IsValid) {
|
||||
|
|
|
@ -38,12 +38,12 @@ class BlockStatement : public Castable<BlockStatement, Statement> {
|
|||
|
||||
/// Appends a statement to the block
|
||||
/// @param stmt the statement to append
|
||||
void append(ast::Statement* stmt) { statements_.push_back(stmt); }
|
||||
void append(Statement* stmt) { statements_.push_back(stmt); }
|
||||
|
||||
/// Insert a statement to the block
|
||||
/// @param index the index to insert at
|
||||
/// @param stmt the statement to insert
|
||||
void insert(size_t index, ast::Statement* stmt) {
|
||||
void insert(size_t index, Statement* stmt) {
|
||||
auto offset = static_cast<decltype(statements_)::difference_type>(index);
|
||||
statements_.insert(statements_.begin() + offset, stmt);
|
||||
}
|
||||
|
@ -54,36 +54,34 @@ class BlockStatement : public Castable<BlockStatement, Statement> {
|
|||
size_t size() const { return statements_.size(); }
|
||||
|
||||
/// @returns the last statement in the block or nullptr if block empty
|
||||
const ast::Statement* last() const {
|
||||
const Statement* last() const {
|
||||
return statements_.empty() ? nullptr : statements_.back();
|
||||
}
|
||||
/// @returns the last statement in the block or nullptr if block empty
|
||||
ast::Statement* last() {
|
||||
Statement* last() {
|
||||
return statements_.empty() ? nullptr : statements_.back();
|
||||
}
|
||||
|
||||
/// Retrieves the statement at |idx|
|
||||
/// @param idx the index. The index is not bounds checked.
|
||||
/// @returns the statement at |idx|
|
||||
const ast::Statement* get(size_t idx) const { return statements_[idx]; }
|
||||
const Statement* get(size_t idx) const { return statements_[idx]; }
|
||||
|
||||
/// Retrieves the statement at |idx|
|
||||
/// @param idx the index. The index is not bounds checked.
|
||||
/// @returns the statement at |idx|
|
||||
ast::Statement* operator[](size_t idx) { return statements_[idx]; }
|
||||
Statement* operator[](size_t idx) { return statements_[idx]; }
|
||||
/// Retrieves the statement at |idx|
|
||||
/// @param idx the index. The index is not bounds checked.
|
||||
/// @returns the statement at |idx|
|
||||
const ast::Statement* operator[](size_t idx) const {
|
||||
return statements_[idx];
|
||||
}
|
||||
const Statement* operator[](size_t idx) const { return statements_[idx]; }
|
||||
|
||||
/// @returns the beginning iterator
|
||||
std::vector<ast::Statement*>::const_iterator begin() const {
|
||||
std::vector<Statement*>::const_iterator begin() const {
|
||||
return statements_.begin();
|
||||
}
|
||||
/// @returns the ending iterator
|
||||
std::vector<ast::Statement*>::const_iterator end() const {
|
||||
std::vector<Statement*>::const_iterator end() const {
|
||||
return statements_.end();
|
||||
}
|
||||
|
||||
|
@ -98,7 +96,7 @@ class BlockStatement : public Castable<BlockStatement, Statement> {
|
|||
private:
|
||||
BlockStatement(const BlockStatement&) = delete;
|
||||
|
||||
std::vector<ast::Statement*> statements_;
|
||||
std::vector<Statement*> statements_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BoolLiteral::BoolLiteral(ast::type::Type* type, bool value)
|
||||
BoolLiteral::BoolLiteral(type::Type* type, bool value)
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
|
|
@ -28,7 +28,7 @@ class BoolLiteral : public Castable<BoolLiteral, Literal> {
|
|||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
/// @param value the bool literals value
|
||||
BoolLiteral(ast::type::Type* type, bool value);
|
||||
BoolLiteral(type::Type* type, bool value);
|
||||
~BoolLiteral() override;
|
||||
|
||||
/// @returns true if the bool literal is true
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using BoolLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(BoolLiteralTest, True) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
BoolLiteral b{&bool_type, true};
|
||||
ASSERT_TRUE(b.Is<BoolLiteral>());
|
||||
ASSERT_TRUE(b.IsTrue());
|
||||
|
@ -36,7 +36,7 @@ TEST_F(BoolLiteralTest, True) {
|
|||
}
|
||||
|
||||
TEST_F(BoolLiteralTest, False) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
BoolLiteral b{&bool_type, false};
|
||||
ASSERT_TRUE(b.Is<BoolLiteral>());
|
||||
ASSERT_FALSE(b.IsTrue());
|
||||
|
@ -44,7 +44,7 @@ TEST_F(BoolLiteralTest, False) {
|
|||
}
|
||||
|
||||
TEST_F(BoolLiteralTest, Is) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
BoolLiteral b{&bool_type, false};
|
||||
Literal* l = &b;
|
||||
EXPECT_TRUE(l->Is<BoolLiteral>());
|
||||
|
@ -56,7 +56,7 @@ TEST_F(BoolLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(BoolLiteralTest, ToStr) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
BoolLiteral t{&bool_type, true};
|
||||
BoolLiteral f{&bool_type, false};
|
||||
|
||||
|
|
|
@ -18,27 +18,26 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
TypesBuilder::TypesBuilder(Module* mod)
|
||||
: bool_(mod->create<ast::type::BoolType>()),
|
||||
f32(mod->create<ast::type::F32Type>()),
|
||||
i32(mod->create<ast::type::I32Type>()),
|
||||
u32(mod->create<ast::type::U32Type>()),
|
||||
void_(mod->create<ast::type::VoidType>()),
|
||||
: bool_(mod->create<type::BoolType>()),
|
||||
f32(mod->create<type::F32Type>()),
|
||||
i32(mod->create<type::I32Type>()),
|
||||
u32(mod->create<type::U32Type>()),
|
||||
void_(mod->create<type::VoidType>()),
|
||||
mod_(mod) {}
|
||||
|
||||
Builder::Builder(tint::Context* c, tint::ast::Module* m)
|
||||
: ctx(c), mod(m), ty(m) {}
|
||||
Builder::Builder(Context* c, Module* m) : ctx(c), mod(m), ty(m) {}
|
||||
Builder::~Builder() = default;
|
||||
|
||||
ast::Variable* Builder::Var(const std::string& name,
|
||||
ast::StorageClass storage,
|
||||
ast::type::Type* type) {
|
||||
auto* var = create<ast::Variable>(name, storage, type);
|
||||
Variable* Builder::Var(const std::string& name,
|
||||
StorageClass storage,
|
||||
type::Type* type) {
|
||||
auto* var = create<Variable>(name, storage, type);
|
||||
OnVariableBuilt(var);
|
||||
return var;
|
||||
}
|
||||
|
||||
BuilderWithContextAndModule::BuilderWithContextAndModule()
|
||||
: Builder(new Context(), new ast::Module()) {}
|
||||
: Builder(new Context(), new Module()) {}
|
||||
BuilderWithContextAndModule::~BuilderWithContextAndModule() {
|
||||
delete ctx;
|
||||
delete mod;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
/// TypesBuilder holds basic `ast::tint` types and methods for constructing
|
||||
/// TypesBuilder holds basic `tint` types and methods for constructing
|
||||
/// complex types.
|
||||
class TypesBuilder {
|
||||
public:
|
||||
|
@ -52,104 +52,104 @@ class TypesBuilder {
|
|||
explicit TypesBuilder(Module* mod);
|
||||
|
||||
/// A boolean type
|
||||
ast::type::BoolType* const bool_;
|
||||
type::BoolType* const bool_;
|
||||
/// A f32 type
|
||||
ast::type::F32Type* const f32;
|
||||
type::F32Type* const f32;
|
||||
/// A i32 type
|
||||
ast::type::I32Type* const i32;
|
||||
type::I32Type* const i32;
|
||||
/// A u32 type
|
||||
ast::type::U32Type* const u32;
|
||||
type::U32Type* const u32;
|
||||
/// A void type
|
||||
ast::type::VoidType* const void_;
|
||||
type::VoidType* const void_;
|
||||
|
||||
/// @return the tint AST type for the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::Type* Of() const {
|
||||
type::Type* Of() const {
|
||||
return CToAST<T>::get(this);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::VectorType* vec2() const {
|
||||
return mod_->create<ast::type::VectorType>(Of<T>(), 2);
|
||||
type::VectorType* vec2() const {
|
||||
return mod_->create<type::VectorType>(Of<T>(), 2);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::VectorType* vec3() const {
|
||||
return mod_->create<ast::type::VectorType>(Of<T>(), 3);
|
||||
type::VectorType* vec3() const {
|
||||
return mod_->create<type::VectorType>(Of<T>(), 3);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::Type* vec4() const {
|
||||
return mod_->create<ast::type::VectorType>(Of<T>(), 4);
|
||||
type::Type* vec4() const {
|
||||
return mod_->create<type::VectorType>(Of<T>(), 4);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat2x2() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 2);
|
||||
type::MatrixType* mat2x2() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 2, 2);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat2x3() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 2);
|
||||
type::MatrixType* mat2x3() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 3, 2);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 2x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat2x4() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 2);
|
||||
type::MatrixType* mat2x4() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 4, 2);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x2 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat3x2() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 3);
|
||||
type::MatrixType* mat3x2() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 2, 3);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat3x3() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 3);
|
||||
type::MatrixType* mat3x3() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 3, 3);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 3x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat3x4() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 3);
|
||||
type::MatrixType* mat3x4() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 4, 3);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x2 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat4x2() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 2, 4);
|
||||
type::MatrixType* mat4x2() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 2, 4);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x3 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat4x3() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 3, 4);
|
||||
type::MatrixType* mat4x3() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 3, 4);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for a 4x4 matrix of the C type `T`.
|
||||
template <typename T>
|
||||
ast::type::MatrixType* mat4x4() const {
|
||||
return mod_->create<ast::type::MatrixType>(Of<T>(), 4, 4);
|
||||
type::MatrixType* mat4x4() const {
|
||||
return mod_->create<type::MatrixType>(Of<T>(), 4, 4);
|
||||
}
|
||||
|
||||
/// @param subtype the array element type
|
||||
/// @param n the array size. 0 represents unbounded
|
||||
/// @return the tint AST type for a array of size `n` of type `T`
|
||||
ast::type::ArrayType* array(ast::type::Type* subtype, uint32_t n) const {
|
||||
return mod_->create<ast::type::ArrayType>(subtype, n);
|
||||
type::ArrayType* array(type::Type* subtype, uint32_t n) const {
|
||||
return mod_->create<type::ArrayType>(subtype, n);
|
||||
}
|
||||
|
||||
/// @return the tint AST type for an array of size `N` of type `T`
|
||||
template <typename T, int N = 0>
|
||||
ast::type::ArrayType* array() const {
|
||||
type::ArrayType* array() const {
|
||||
return array(Of<T>(), N);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ class TypesBuilder {
|
|||
/// contains a single static `get()` method for obtaining the corresponding
|
||||
/// AST type for the C type `T`.
|
||||
/// `get()` has the signature:
|
||||
/// `static ast::type::Type* get(Types* t)`
|
||||
/// `static type::Type* get(Types* t)`
|
||||
template <typename T>
|
||||
struct CToAST {};
|
||||
|
||||
|
@ -188,78 +188,78 @@ class Builder {
|
|||
/// Constructor
|
||||
/// @param ctx the context to use in the builder
|
||||
/// @param mod the module to use in the builder
|
||||
explicit Builder(tint::Context* ctx, tint::ast::Module* mod);
|
||||
explicit Builder(Context* ctx, Module* mod);
|
||||
virtual ~Builder();
|
||||
|
||||
/// @param expr the expression
|
||||
/// @return expr
|
||||
ast::Expression* Expr(ast::Expression* expr) { return expr; }
|
||||
Expression* Expr(Expression* expr) { return expr; }
|
||||
|
||||
/// @param name the identifier name
|
||||
/// @return an IdentifierExpression with the given name
|
||||
ast::IdentifierExpression* Expr(const std::string& name) {
|
||||
return create<ast::IdentifierExpression>(name);
|
||||
IdentifierExpression* Expr(const std::string& name) {
|
||||
return create<IdentifierExpression>(name);
|
||||
}
|
||||
|
||||
/// @param name the identifier name
|
||||
/// @return an IdentifierExpression with the given name
|
||||
ast::IdentifierExpression* Expr(const char* name) {
|
||||
return create<ast::IdentifierExpression>(name);
|
||||
IdentifierExpression* Expr(const char* name) {
|
||||
return create<IdentifierExpression>(name);
|
||||
}
|
||||
|
||||
/// @param value the boolean value
|
||||
/// @return a Scalar constructor for the given value
|
||||
ast::ScalarConstructorExpression* Expr(bool value) {
|
||||
return create<ast::ScalarConstructorExpression>(Literal(value));
|
||||
ScalarConstructorExpression* Expr(bool value) {
|
||||
return create<ScalarConstructorExpression>(Literal(value));
|
||||
}
|
||||
|
||||
/// @param value the float value
|
||||
/// @return a Scalar constructor for the given value
|
||||
ast::ScalarConstructorExpression* Expr(f32 value) {
|
||||
return create<ast::ScalarConstructorExpression>(Literal(value));
|
||||
ScalarConstructorExpression* Expr(f32 value) {
|
||||
return create<ScalarConstructorExpression>(Literal(value));
|
||||
}
|
||||
|
||||
/// @param value the integer value
|
||||
/// @return a Scalar constructor for the given value
|
||||
ast::ScalarConstructorExpression* Expr(i32 value) {
|
||||
return create<ast::ScalarConstructorExpression>(Literal(value));
|
||||
ScalarConstructorExpression* Expr(i32 value) {
|
||||
return create<ScalarConstructorExpression>(Literal(value));
|
||||
}
|
||||
|
||||
/// @param value the unsigned int value
|
||||
/// @return a Scalar constructor for the given value
|
||||
ast::ScalarConstructorExpression* Expr(u32 value) {
|
||||
return create<ast::ScalarConstructorExpression>(Literal(value));
|
||||
ScalarConstructorExpression* Expr(u32 value) {
|
||||
return create<ScalarConstructorExpression>(Literal(value));
|
||||
}
|
||||
|
||||
/// Converts `arg` to an `ast::Expression` using `Expr()`, then appends it to
|
||||
/// Converts `arg` to an `Expression` using `Expr()`, then appends it to
|
||||
/// `list`.
|
||||
/// @param list the list to append too
|
||||
/// @param arg the arg to create
|
||||
template <typename ARG>
|
||||
void Append(ast::ExpressionList& list, ARG&& arg) {
|
||||
void Append(ExpressionList& list, ARG&& arg) {
|
||||
list.emplace_back(Expr(std::forward<ARG>(arg)));
|
||||
}
|
||||
|
||||
/// Converts `arg0` and `args` to `ast::Expression`s using `Expr()`,
|
||||
/// Converts `arg0` and `args` to `Expression`s using `Expr()`,
|
||||
/// then appends them to `list`.
|
||||
/// @param list the list to append too
|
||||
/// @param arg0 the first argument
|
||||
/// @param args the rest of the arguments
|
||||
template <typename ARG0, typename... ARGS>
|
||||
void Append(ast::ExpressionList& list, ARG0&& arg0, ARGS&&... args) {
|
||||
void Append(ExpressionList& list, ARG0&& arg0, ARGS&&... args) {
|
||||
Append(list, std::forward<ARG0>(arg0));
|
||||
Append(list, std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// @return an empty list of expressions,
|
||||
ast::ExpressionList ExprList() { return {}; }
|
||||
ExpressionList ExprList() { return {}; }
|
||||
|
||||
/// @param args the list of expressions
|
||||
/// @return the list of expressions converted to `ast::Expression`s using
|
||||
/// @return the list of expressions converted to `Expression`s using
|
||||
/// `Expr()`,
|
||||
template <typename... ARGS>
|
||||
ast::ExpressionList ExprList(ARGS&&... args) {
|
||||
ast::ExpressionList list;
|
||||
ExpressionList ExprList(ARGS&&... args) {
|
||||
ExpressionList list;
|
||||
list.reserve(sizeof...(args));
|
||||
Append(list, std::forward<ARGS>(args)...);
|
||||
return list;
|
||||
|
@ -267,185 +267,175 @@ class Builder {
|
|||
|
||||
/// @param val the boolan value
|
||||
/// @return a boolean literal with the given value
|
||||
ast::BoolLiteral* Literal(bool val) {
|
||||
return create<ast::BoolLiteral>(ty.bool_, val);
|
||||
}
|
||||
BoolLiteral* Literal(bool val) { return create<BoolLiteral>(ty.bool_, val); }
|
||||
|
||||
/// @param val the float value
|
||||
/// @return a float literal with the given value
|
||||
ast::FloatLiteral* Literal(f32 val) {
|
||||
return create<ast::FloatLiteral>(ty.f32, val);
|
||||
}
|
||||
FloatLiteral* Literal(f32 val) { return create<FloatLiteral>(ty.f32, val); }
|
||||
|
||||
/// @param val the unsigned int value
|
||||
/// @return a UintLiteral with the given value
|
||||
ast::UintLiteral* Literal(u32 val) {
|
||||
return create<ast::UintLiteral>(ty.u32, val);
|
||||
}
|
||||
UintLiteral* Literal(u32 val) { return create<UintLiteral>(ty.u32, val); }
|
||||
|
||||
/// @param val the integer value
|
||||
/// @return the SintLiteral with the given value
|
||||
ast::SintLiteral* Literal(i32 val) {
|
||||
return create<ast::SintLiteral>(ty.i32, val);
|
||||
}
|
||||
SintLiteral* Literal(i32 val) { return create<SintLiteral>(ty.i32, val); }
|
||||
|
||||
/// @param args the arguments for the type constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of type `ty`, with the values
|
||||
/// of `args` converted to `ast::Expression`s using `Expr()`
|
||||
/// @return an `TypeConstructorExpression` of type `ty`, with the values
|
||||
/// of `args` converted to `Expression`s using `Expr()`
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* Construct(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* Construct(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.Of<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param type the type to construct
|
||||
/// @param args the arguments for the constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of `type` constructed with the
|
||||
/// @return an `TypeConstructorExpression` of `type` constructed with the
|
||||
/// values `args`.
|
||||
template <typename... ARGS>
|
||||
ast::TypeConstructorExpression* Construct(ast::type::Type* type,
|
||||
ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* Construct(type::Type* type, ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
type, ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 2-element vector of type
|
||||
/// @return an `TypeConstructorExpression` of a 2-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* vec2(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* vec2(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.vec2<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 3-element vector of type
|
||||
/// @return an `TypeConstructorExpression` of a 3-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* vec3(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* vec3(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.vec3<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the vector constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 4-element vector of type
|
||||
/// @return an `TypeConstructorExpression` of a 4-element vector of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* vec4(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* vec4(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.vec4<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 2x2 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 2x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat2x2(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat2x2(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat2x2<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 2x3 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 2x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat2x3(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat2x3(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat2x3<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 2x4 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 2x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat2x4(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat2x4(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat2x4<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 3x2 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 3x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat3x2(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat3x2(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat3x2<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 3x3 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 3x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat3x3(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat3x3(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat3x3<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 3x4 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 3x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat3x4(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat3x4(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat3x4<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 4x2 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 4x2 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat4x2(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat4x2(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat4x2<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 4x3 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 4x3 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat4x3(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat4x3(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat4x3<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the matrix constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 4x4 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 4x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, typename... ARGS>
|
||||
ast::TypeConstructorExpression* mat4x4(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* mat4x4(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.mat4x4<T>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param args the arguments for the array constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of a 4x4 matrix of type
|
||||
/// @return an `TypeConstructorExpression` of a 4x4 matrix of type
|
||||
/// `T`, constructed with the values `args`.
|
||||
template <typename T, int N = 0, typename... ARGS>
|
||||
ast::TypeConstructorExpression* array(ARGS&&... args) {
|
||||
return create<ast::TypeConstructorExpression>(
|
||||
TypeConstructorExpression* array(ARGS&&... args) {
|
||||
return create<TypeConstructorExpression>(
|
||||
ty.array<T, N>(), ExprList(std::forward<ARGS>(args)...));
|
||||
}
|
||||
|
||||
/// @param name the variable name
|
||||
/// @param storage the variable storage class
|
||||
/// @param type the variable type
|
||||
/// @returns a `ast::Variable` with the given name, storage and type
|
||||
ast::Variable* Var(const std::string& name,
|
||||
ast::StorageClass storage,
|
||||
ast::type::Type* type);
|
||||
/// @returns a `Variable` with the given name, storage and type
|
||||
Variable* Var(const std::string& name,
|
||||
StorageClass storage,
|
||||
type::Type* type);
|
||||
|
||||
/// @param func the function name
|
||||
/// @param args the function call arguments
|
||||
/// @returns a `ast::CallExpression` to the function `func`, with the
|
||||
/// arguments of `args` converted to `ast::Expression`s using `Expr()`.
|
||||
/// @returns a `CallExpression` to the function `func`, with the
|
||||
/// arguments of `args` converted to `Expression`s using `Expr()`.
|
||||
template <typename... ARGS>
|
||||
ast::CallExpression Call(const std::string& func, ARGS&&... args) {
|
||||
return ast::CallExpression{Expr(func),
|
||||
ExprList(std::forward<ARGS>(args)...)};
|
||||
CallExpression Call(const std::string& func, ARGS&&... args) {
|
||||
return CallExpression{Expr(func), ExprList(std::forward<ARGS>(args)...)};
|
||||
}
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// Creates a new `Node` owned by the Module. When the Module is
|
||||
/// destructed, the `Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
|
@ -454,15 +444,15 @@ class Builder {
|
|||
}
|
||||
|
||||
/// The builder module
|
||||
tint::Context* const ctx;
|
||||
Context* const ctx;
|
||||
/// The builder module
|
||||
tint::ast::Module* const mod;
|
||||
Module* const mod;
|
||||
/// The builder types
|
||||
const TypesBuilder ty;
|
||||
|
||||
protected:
|
||||
/// Called whenever a new variable is built with `Var()`.
|
||||
virtual void OnVariableBuilt(ast::Variable*) {}
|
||||
virtual void OnVariableBuilt(Variable*) {}
|
||||
};
|
||||
|
||||
/// BuilderWithContextAndModule is a `Builder` that constructs and owns its
|
||||
|
@ -477,23 +467,23 @@ class BuilderWithContextAndModule : public Builder {
|
|||
// Various template specializations for TypesBuilder::CToAST.
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::i32> {
|
||||
static ast::type::Type* get(const TypesBuilder* t) { return t->i32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->i32; }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::u32> {
|
||||
static ast::type::Type* get(const TypesBuilder* t) { return t->u32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->u32; }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::f32> {
|
||||
static ast::type::Type* get(const TypesBuilder* t) { return t->f32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->f32; }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<bool> {
|
||||
static ast::type::Type* get(const TypesBuilder* t) { return t->bool_; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->bool_; }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<void> {
|
||||
static ast::type::Type* get(const TypesBuilder* t) { return t->void_; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->void_; }
|
||||
};
|
||||
//! @endcond
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ TEST_F(CallExpressionTest, Creation_WithSource) {
|
|||
TEST_F(CallExpressionTest, IsCall) {
|
||||
auto* func = create<IdentifierExpression>("func");
|
||||
CallExpression stmt(func, {});
|
||||
EXPECT_TRUE(stmt.Is<ast::CallExpression>());
|
||||
EXPECT_TRUE(stmt.Is<CallExpression>());
|
||||
}
|
||||
|
||||
TEST_F(CallExpressionTest, IsValid) {
|
||||
|
|
|
@ -25,8 +25,8 @@ namespace {
|
|||
using CallStatementTest = TestHelper;
|
||||
|
||||
TEST_F(CallStatementTest, Creation) {
|
||||
auto* expr = create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("func"), ExpressionList{});
|
||||
auto* expr = create<CallExpression>(create<IdentifierExpression>("func"),
|
||||
ExpressionList{});
|
||||
|
||||
CallStatement c(expr);
|
||||
EXPECT_EQ(c.expr(), expr);
|
||||
|
@ -38,8 +38,8 @@ TEST_F(CallStatementTest, IsCall) {
|
|||
}
|
||||
|
||||
TEST_F(CallStatementTest, IsValid) {
|
||||
CallStatement c(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("func"), ExpressionList{}));
|
||||
CallStatement c(create<CallExpression>(create<IdentifierExpression>("func"),
|
||||
ExpressionList{}));
|
||||
EXPECT_TRUE(c.IsValid());
|
||||
}
|
||||
|
||||
|
@ -49,13 +49,13 @@ TEST_F(CallStatementTest, IsValid_MissingExpr) {
|
|||
}
|
||||
|
||||
TEST_F(CallStatementTest, IsValid_InvalidExpr) {
|
||||
CallStatement c(create<ast::CallExpression>());
|
||||
CallStatement c(create<CallExpression>());
|
||||
EXPECT_FALSE(c.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(CallStatementTest, ToStr) {
|
||||
CallStatement c(create<ast::CallExpression>(
|
||||
create<ast::IdentifierExpression>("func"), ExpressionList{}));
|
||||
CallStatement c(create<CallExpression>(create<IdentifierExpression>("func"),
|
||||
ExpressionList{}));
|
||||
|
||||
std::ostringstream out;
|
||||
c.to_str(out, 2);
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace {
|
|||
using CaseStatementTest = TestHelper;
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_i32) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(&i32, 2);
|
||||
|
@ -47,7 +47,7 @@ TEST_F(CaseStatementTest, Creation_i32) {
|
|||
}
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_u32) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(&u32, 2);
|
||||
|
@ -65,7 +65,7 @@ TEST_F(CaseStatementTest, Creation_u32) {
|
|||
}
|
||||
|
||||
TEST_F(CaseStatementTest, Creation_WithSource) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
|
@ -82,33 +82,33 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) {
|
|||
auto* body = create<BlockStatement>();
|
||||
body->append(create<DiscardStatement>());
|
||||
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
CaseStatement c(create<BlockStatement>());
|
||||
c.set_body(body);
|
||||
EXPECT_TRUE(c.IsDefault());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
CaseStatement c(create<BlockStatement>());
|
||||
c.set_selectors(b);
|
||||
EXPECT_FALSE(c.IsDefault());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsCase) {
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
EXPECT_TRUE(c.Is<ast::CaseStatement>());
|
||||
CaseStatement c(create<BlockStatement>());
|
||||
EXPECT_TRUE(c.Is<CaseStatement>());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsValid) {
|
||||
CaseStatement c(create<ast::BlockStatement>());
|
||||
CaseStatement c(create<BlockStatement>());
|
||||
EXPECT_TRUE(c.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
|
@ -121,19 +121,19 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
|||
}
|
||||
|
||||
TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<IfStatement>(nullptr, create<ast::BlockStatement>()));
|
||||
body->append(create<IfStatement>(nullptr, create<BlockStatement>()));
|
||||
|
||||
CaseStatement c({b}, body);
|
||||
EXPECT_FALSE(c.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, -2));
|
||||
|
||||
|
@ -150,7 +150,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
|||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<UintLiteral>(&u32, 2));
|
||||
|
||||
|
@ -167,7 +167,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
|||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(&i32, 1));
|
||||
|
|
|
@ -77,7 +77,7 @@ TEST_F(DecoratedVariableTest, WithDecorations) {
|
|||
|
||||
VariableDecorationList decos;
|
||||
decos.push_back(create<LocationDecoration>(1, Source{}));
|
||||
decos.push_back(create<BuiltinDecoration>(ast::Builtin::kPosition, Source{}));
|
||||
decos.push_back(create<BuiltinDecoration>(Builtin::kPosition, Source{}));
|
||||
decos.push_back(create<ConstantIdDecoration>(1200, Source{}));
|
||||
|
||||
dv.set_decorations(decos);
|
||||
|
@ -108,7 +108,7 @@ TEST_F(DecoratedVariableTest, IsValid) {
|
|||
|
||||
TEST_F(DecoratedVariableTest, IsDecorated) {
|
||||
DecoratedVariable dv;
|
||||
EXPECT_TRUE(dv.Is<ast::DecoratedVariable>());
|
||||
EXPECT_TRUE(dv.Is<DecoratedVariable>());
|
||||
}
|
||||
|
||||
TEST_F(DecoratedVariableTest, to_str) {
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using ElseStatementTest = TestHelper;
|
||||
|
||||
TEST_F(ElseStatementTest, Creation) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
auto* body = create<BlockStatement>();
|
||||
|
@ -55,7 +55,7 @@ TEST_F(ElseStatementTest, IsElse) {
|
|||
}
|
||||
|
||||
TEST_F(ElseStatementTest, HasCondition) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
ElseStatement e(cond, create<BlockStatement>());
|
||||
|
@ -97,14 +97,14 @@ TEST_F(ElseStatementTest, IsValid_InvalidCondition) {
|
|||
|
||||
TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) {
|
||||
auto* body = create<BlockStatement>();
|
||||
body->append(create<IfStatement>(nullptr, create<ast::BlockStatement>()));
|
||||
body->append(create<IfStatement>(nullptr, create<BlockStatement>()));
|
||||
|
||||
ElseStatement e(body);
|
||||
EXPECT_FALSE(e.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(ElseStatementTest, ToStr) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* cond = create<ScalarConstructorExpression>(
|
||||
create<BoolLiteral>(&bool_type, true));
|
||||
auto* body = create<BlockStatement>();
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(ExpressionTest, set_result_type) {
|
|||
Expr e;
|
||||
e.set_result_type(&i32);
|
||||
ASSERT_NE(e.result_type(), nullptr);
|
||||
EXPECT_TRUE(e.result_type()->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(e.result_type()->Is<type::I32Type>());
|
||||
}
|
||||
|
||||
TEST_F(ExpressionTest, set_result_type_alias) {
|
||||
|
@ -49,7 +49,7 @@ TEST_F(ExpressionTest, set_result_type_alias) {
|
|||
Expr e;
|
||||
e.set_result_type(&b);
|
||||
ASSERT_NE(e.result_type(), nullptr);
|
||||
EXPECT_TRUE(e.result_type()->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(e.result_type()->Is<type::I32Type>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
FloatLiteral::FloatLiteral(ast::type::Type* type, float value)
|
||||
FloatLiteral::FloatLiteral(type::Type* type, float value)
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
|
|
@ -28,7 +28,7 @@ class FloatLiteral : public Castable<FloatLiteral, Literal> {
|
|||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
/// @param value the float literals value
|
||||
FloatLiteral(ast::type::Type* type, float value);
|
||||
FloatLiteral(type::Type* type, float value);
|
||||
~FloatLiteral() override;
|
||||
|
||||
/// @returns the float literal value
|
||||
|
|
|
@ -28,14 +28,14 @@ namespace {
|
|||
using FloatLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(FloatLiteralTest, Value) {
|
||||
ast::type::F32Type f32;
|
||||
type::F32Type f32;
|
||||
FloatLiteral f{&f32, 47.2f};
|
||||
ASSERT_TRUE(f.Is<FloatLiteral>());
|
||||
EXPECT_EQ(f.value(), 47.2f);
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, Is) {
|
||||
ast::type::F32Type f32;
|
||||
type::F32Type f32;
|
||||
FloatLiteral f{&f32, 42.f};
|
||||
Literal* l = &f;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
|
@ -47,14 +47,14 @@ TEST_F(FloatLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToStr) {
|
||||
ast::type::F32Type f32;
|
||||
type::F32Type f32;
|
||||
FloatLiteral f{&f32, 42.1f};
|
||||
|
||||
EXPECT_EQ(f.to_str(), "42.099998");
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToName) {
|
||||
ast::type::F32Type f32;
|
||||
type::F32Type f32;
|
||||
FloatLiteral f{&f32, 42.1f};
|
||||
EXPECT_EQ(f.name(), "__float42.0999985");
|
||||
}
|
||||
|
|
|
@ -62,13 +62,13 @@ std::tuple<uint32_t, uint32_t, uint32_t> Function::workgroup_size() const {
|
|||
return {1, 1, 1};
|
||||
}
|
||||
|
||||
ast::PipelineStage Function::pipeline_stage() const {
|
||||
PipelineStage Function::pipeline_stage() const {
|
||||
for (auto* deco : decorations_) {
|
||||
if (auto* stage = deco->As<StageDecoration>()) {
|
||||
return stage->value();
|
||||
}
|
||||
}
|
||||
return ast::PipelineStage::kNone;
|
||||
return PipelineStage::kNone;
|
||||
}
|
||||
|
||||
void Function::add_referenced_module_variable(Variable* var) {
|
||||
|
@ -85,7 +85,7 @@ Function::referenced_location_variables() const {
|
|||
std::vector<std::pair<Variable*, LocationDecoration*>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (auto* decos = var->As<ast::DecoratedVariable>()) {
|
||||
if (auto* decos = var->As<DecoratedVariable>()) {
|
||||
for (auto* deco : decos->decorations()) {
|
||||
if (auto* location = deco->As<LocationDecoration>()) {
|
||||
ret.push_back({var, location});
|
||||
|
@ -102,17 +102,17 @@ Function::referenced_uniform_variables() const {
|
|||
std::vector<std::pair<Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<ast::DecoratedVariable>() ||
|
||||
var->storage_class() != ast::StorageClass::kUniform) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
var->storage_class() != StorageClass::kUniform) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<ast::DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<ast::SetDecoration>()) {
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
|
@ -130,17 +130,17 @@ Function::referenced_storagebuffer_variables() const {
|
|||
std::vector<std::pair<Variable*, Function::BindingInfo>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<ast::DecoratedVariable>() ||
|
||||
var->storage_class() != ast::StorageClass::kStorageBuffer) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
var->storage_class() != StorageClass::kStorageBuffer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<ast::DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<ast::SetDecoration>()) {
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
|
@ -158,10 +158,10 @@ Function::referenced_builtin_variables() const {
|
|||
std::vector<std::pair<Variable*, BuiltinDecoration*>> ret;
|
||||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
if (!var->Is<ast::DecoratedVariable>()) {
|
||||
if (!var->Is<DecoratedVariable>()) {
|
||||
continue;
|
||||
}
|
||||
for (auto* deco : var->As<ast::DecoratedVariable>()->decorations()) {
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* builtin = deco->As<BuiltinDecoration>()) {
|
||||
ret.push_back({var, builtin});
|
||||
break;
|
||||
|
@ -282,18 +282,18 @@ Function::ReferencedSamplerVariablesImpl(type::SamplerKind kind) const {
|
|||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||
if (!var->Is<ast::DecoratedVariable>() ||
|
||||
!unwrapped_type->Is<ast::type::SamplerType>() ||
|
||||
unwrapped_type->As<ast::type::SamplerType>()->kind() != kind) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
!unwrapped_type->Is<type::SamplerType>() ||
|
||||
unwrapped_type->As<type::SamplerType>()->kind() != kind) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<ast::DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<ast::SetDecoration>()) {
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
|
@ -312,24 +312,23 @@ Function::ReferencedSampledTextureVariablesImpl(bool multisampled) const {
|
|||
|
||||
for (auto* var : referenced_module_variables()) {
|
||||
auto* unwrapped_type = var->type()->UnwrapIfNeeded();
|
||||
if (!var->Is<ast::DecoratedVariable>() ||
|
||||
!unwrapped_type->Is<ast::type::TextureType>()) {
|
||||
if (!var->Is<DecoratedVariable>() ||
|
||||
!unwrapped_type->Is<type::TextureType>()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((multisampled &&
|
||||
!unwrapped_type->Is<ast::type::MultisampledTextureType>()) ||
|
||||
(!multisampled &&
|
||||
!unwrapped_type->Is<ast::type::SampledTextureType>())) {
|
||||
!unwrapped_type->Is<type::MultisampledTextureType>()) ||
|
||||
(!multisampled && !unwrapped_type->Is<type::SampledTextureType>())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BindingDecoration* binding = nullptr;
|
||||
SetDecoration* set = nullptr;
|
||||
for (auto* deco : var->As<ast::DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<ast::BindingDecoration>()) {
|
||||
for (auto* deco : var->As<DecoratedVariable>()->decorations()) {
|
||||
if (auto* b = deco->As<BindingDecoration>()) {
|
||||
binding = b;
|
||||
} else if (auto* s = deco->As<ast::SetDecoration>()) {
|
||||
} else if (auto* s = deco->As<SetDecoration>()) {
|
||||
set = s;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ class Function : public Castable<Function, Node> {
|
|||
/// Sets the function decorations
|
||||
/// @param decos the decorations to set. This will overwrite any existing
|
||||
/// decorations
|
||||
void set_decorations(ast::FunctionDecorationList decos) {
|
||||
void set_decorations(FunctionDecorationList decos) {
|
||||
decorations_ = std::move(decos);
|
||||
}
|
||||
/// Adds a decoration to the function
|
||||
|
@ -107,12 +107,10 @@ class Function : public Castable<Function, Node> {
|
|||
std::tuple<uint32_t, uint32_t, uint32_t> workgroup_size() const;
|
||||
|
||||
/// @returns the functions pipeline stage or None if not set
|
||||
ast::PipelineStage pipeline_stage() const;
|
||||
PipelineStage pipeline_stage() const;
|
||||
|
||||
/// @returns true if this function is an entry point
|
||||
bool IsEntryPoint() const {
|
||||
return pipeline_stage() != ast::PipelineStage::kNone;
|
||||
}
|
||||
bool IsEntryPoint() const { return pipeline_stage() != PipelineStage::kNone; }
|
||||
|
||||
/// Adds the given variable to the list of referenced module variables if it
|
||||
/// is not already included.
|
||||
|
|
|
@ -40,7 +40,7 @@ TEST_F(FunctionTest, Creation) {
|
|||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
auto* var = params[0];
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
EXPECT_EQ(f.name(), "func");
|
||||
ASSERT_EQ(f.params().size(), 1u);
|
||||
EXPECT_EQ(f.return_type(), &void_type);
|
||||
|
@ -55,7 +55,7 @@ TEST_F(FunctionTest, Creation_WithSource) {
|
|||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f(Source{Source::Location{20, 2}}, "func", params, &void_type,
|
||||
create<ast::BlockStatement>());
|
||||
create<BlockStatement>());
|
||||
auto src = f.source();
|
||||
EXPECT_EQ(src.range.begin.line, 20u);
|
||||
EXPECT_EQ(src.range.begin.column, 2u);
|
||||
|
@ -66,7 +66,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
|
|||
type::I32Type i32;
|
||||
|
||||
Variable v("var", StorageClass::kInput, &i32);
|
||||
Function f("func", VariableList{}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
|
||||
|
||||
f.add_referenced_module_variable(&v);
|
||||
ASSERT_EQ(f.referenced_module_variables().size(), 1u);
|
||||
|
@ -85,25 +85,23 @@ TEST_F(FunctionTest, GetReferenceLocations) {
|
|||
type::VoidType void_type;
|
||||
type::I32Type i32;
|
||||
|
||||
DecoratedVariable loc1(
|
||||
create<ast::Variable>("loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
|
||||
|
||||
DecoratedVariable loc2(
|
||||
create<ast::Variable>("loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
DecoratedVariable loc2(create<Variable>("loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<LocationDecoration>(1, Source{})});
|
||||
|
||||
DecoratedVariable builtin1(
|
||||
create<ast::Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
create<Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
builtin1.set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kPosition, Source{})});
|
||||
{create<BuiltinDecoration>(Builtin::kPosition, Source{})});
|
||||
|
||||
DecoratedVariable builtin2(
|
||||
create<ast::Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
create<Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
builtin2.set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
{create<BuiltinDecoration>(Builtin::kFragDepth, Source{})});
|
||||
|
||||
Function f("func", VariableList{}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
|
||||
|
||||
f.add_referenced_module_variable(&loc1);
|
||||
f.add_referenced_module_variable(&builtin1);
|
||||
|
@ -123,25 +121,23 @@ TEST_F(FunctionTest, GetReferenceBuiltins) {
|
|||
type::VoidType void_type;
|
||||
type::I32Type i32;
|
||||
|
||||
DecoratedVariable loc1(
|
||||
create<ast::Variable>("loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<ast::LocationDecoration>(0, Source{})});
|
||||
DecoratedVariable loc1(create<Variable>("loc1", StorageClass::kInput, &i32));
|
||||
loc1.set_decorations({create<LocationDecoration>(0, Source{})});
|
||||
|
||||
DecoratedVariable loc2(
|
||||
create<ast::Variable>("loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<ast::LocationDecoration>(1, Source{})});
|
||||
DecoratedVariable loc2(create<Variable>("loc2", StorageClass::kInput, &i32));
|
||||
loc2.set_decorations({create<LocationDecoration>(1, Source{})});
|
||||
|
||||
DecoratedVariable builtin1(
|
||||
create<ast::Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
create<Variable>("builtin1", StorageClass::kInput, &i32));
|
||||
builtin1.set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kPosition, Source{})});
|
||||
{create<BuiltinDecoration>(Builtin::kPosition, Source{})});
|
||||
|
||||
DecoratedVariable builtin2(
|
||||
create<ast::Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
create<Variable>("builtin2", StorageClass::kInput, &i32));
|
||||
builtin2.set_decorations(
|
||||
{create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth, Source{})});
|
||||
{create<BuiltinDecoration>(Builtin::kFragDepth, Source{})});
|
||||
|
||||
Function f("func", VariableList{}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
|
||||
|
||||
f.add_referenced_module_variable(&loc1);
|
||||
f.add_referenced_module_variable(&builtin1);
|
||||
|
@ -152,14 +148,14 @@ TEST_F(FunctionTest, GetReferenceBuiltins) {
|
|||
auto ref_locs = f.referenced_builtin_variables();
|
||||
ASSERT_EQ(ref_locs.size(), 2u);
|
||||
EXPECT_EQ(ref_locs[0].first, &builtin1);
|
||||
EXPECT_EQ(ref_locs[0].second->value(), ast::Builtin::kPosition);
|
||||
EXPECT_EQ(ref_locs[0].second->value(), Builtin::kPosition);
|
||||
EXPECT_EQ(ref_locs[1].first, &builtin2);
|
||||
EXPECT_EQ(ref_locs[1].second->value(), ast::Builtin::kFragDepth);
|
||||
EXPECT_EQ(ref_locs[1].second->value(), Builtin::kFragDepth);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, AddDuplicateEntryPoints) {
|
||||
ast::type::VoidType void_type;
|
||||
Function f("func", VariableList{}, &void_type, create<ast::BlockStatement>());
|
||||
type::VoidType void_type;
|
||||
Function f("func", VariableList{}, &void_type, create<BlockStatement>());
|
||||
|
||||
f.add_ancestor_entry_point("main");
|
||||
ASSERT_EQ(1u, f.ancestor_entry_points().size());
|
||||
|
@ -177,10 +173,10 @@ TEST_F(FunctionTest, IsValid) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
EXPECT_TRUE(f.IsValid());
|
||||
}
|
||||
|
@ -192,7 +188,7 @@ TEST_F(FunctionTest, IsValid_EmptyName) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f("", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("", params, &void_type, create<BlockStatement>());
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
||||
|
@ -202,7 +198,7 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
Function f("func", params, nullptr, create<ast::BlockStatement>());
|
||||
Function f("func", params, nullptr, create<BlockStatement>());
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
||||
|
@ -214,7 +210,7 @@ TEST_F(FunctionTest, IsValid_NullParam) {
|
|||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
params.push_back(nullptr);
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
||||
|
@ -224,7 +220,7 @@ TEST_F(FunctionTest, IsValid_InvalidParam) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, nullptr));
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
||||
|
@ -235,11 +231,11 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
block->append(nullptr);
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
@ -251,11 +247,11 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
block->append(nullptr);
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
EXPECT_FALSE(f.IsValid());
|
||||
}
|
||||
|
@ -264,10 +260,10 @@ TEST_F(FunctionTest, ToStr) {
|
|||
type::VoidType void_type;
|
||||
type::I32Type i32;
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
||||
Function f("func", {}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", {}, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
|
||||
std::ostringstream out;
|
||||
|
@ -284,10 +280,10 @@ TEST_F(FunctionTest, ToStr_WithDecoration) {
|
|||
type::VoidType void_type;
|
||||
type::I32Type i32;
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
||||
Function f("func", {}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", {}, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
f.add_decoration(create<WorkgroupDecoration>(2, 4, 6, Source{}));
|
||||
|
||||
|
@ -309,10 +305,10 @@ TEST_F(FunctionTest, ToStr_WithParams) {
|
|||
VariableList params;
|
||||
params.push_back(create<Variable>("var", StorageClass::kNone, &i32));
|
||||
|
||||
auto* block = create<ast::BlockStatement>();
|
||||
auto* block = create<BlockStatement>();
|
||||
block->append(create<DiscardStatement>());
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(block);
|
||||
|
||||
std::ostringstream out;
|
||||
|
@ -334,7 +330,7 @@ TEST_F(FunctionTest, ToStr_WithParams) {
|
|||
TEST_F(FunctionTest, TypeName) {
|
||||
type::VoidType void_type;
|
||||
|
||||
Function f("func", {}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", {}, &void_type, create<BlockStatement>());
|
||||
EXPECT_EQ(f.type_name(), "__func__void");
|
||||
}
|
||||
|
||||
|
@ -347,7 +343,7 @@ TEST_F(FunctionTest, TypeName_WithParams) {
|
|||
params.push_back(create<Variable>("var1", StorageClass::kNone, &i32));
|
||||
params.push_back(create<Variable>("var2", StorageClass::kNone, &f32));
|
||||
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
EXPECT_EQ(f.type_name(), "__func__void__i32__f32");
|
||||
}
|
||||
|
||||
|
@ -355,10 +351,10 @@ TEST_F(FunctionTest, GetLastStatement) {
|
|||
type::VoidType void_type;
|
||||
|
||||
VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
auto* body = create<BlockStatement>();
|
||||
auto* stmt = create<DiscardStatement>();
|
||||
body->append(stmt);
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(body);
|
||||
|
||||
EXPECT_EQ(f.get_last_statement(), stmt);
|
||||
|
@ -368,8 +364,8 @@ TEST_F(FunctionTest, GetLastStatement_nullptr) {
|
|||
type::VoidType void_type;
|
||||
|
||||
VariableList params;
|
||||
auto* body = create<ast::BlockStatement>();
|
||||
Function f("func", params, &void_type, create<ast::BlockStatement>());
|
||||
auto* body = create<BlockStatement>();
|
||||
Function f("func", params, &void_type, create<BlockStatement>());
|
||||
f.set_body(body);
|
||||
|
||||
EXPECT_EQ(f.get_last_statement(), nullptr);
|
||||
|
@ -377,7 +373,7 @@ TEST_F(FunctionTest, GetLastStatement_nullptr) {
|
|||
|
||||
TEST_F(FunctionTest, WorkgroupSize_NoneSet) {
|
||||
type::VoidType void_type;
|
||||
Function f("f", {}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("f", {}, &void_type, create<BlockStatement>());
|
||||
uint32_t x = 0;
|
||||
uint32_t y = 0;
|
||||
uint32_t z = 0;
|
||||
|
@ -389,7 +385,7 @@ TEST_F(FunctionTest, WorkgroupSize_NoneSet) {
|
|||
|
||||
TEST_F(FunctionTest, WorkgroupSize) {
|
||||
type::VoidType void_type;
|
||||
Function f("f", {}, &void_type, create<ast::BlockStatement>());
|
||||
Function f("f", {}, &void_type, create<BlockStatement>());
|
||||
f.add_decoration(create<WorkgroupDecoration>(2u, 4u, 6u, Source{}));
|
||||
|
||||
uint32_t x = 0;
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(IdentifierExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(IdentifierExpressionTest, IsIdentifier) {
|
||||
IdentifierExpression i("ident");
|
||||
EXPECT_TRUE(i.Is<ast::IdentifierExpression>());
|
||||
EXPECT_TRUE(i.Is<IdentifierExpression>());
|
||||
}
|
||||
|
||||
TEST_F(IdentifierExpressionTest, IsValid) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IntLiteral::IntLiteral(ast::type::Type* type) : Base(type) {}
|
||||
IntLiteral::IntLiteral(type::Type* type) : Base(type) {}
|
||||
|
||||
IntLiteral::~IntLiteral() = default;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class IntLiteral : public Castable<IntLiteral, Literal> {
|
|||
protected:
|
||||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
explicit IntLiteral(ast::type::Type* type);
|
||||
explicit IntLiteral(type::Type* type);
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -30,13 +30,13 @@ namespace {
|
|||
using IntLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(IntLiteralTest, Sint_IsInt) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
SintLiteral i{&i32, 47};
|
||||
ASSERT_TRUE(i.Is<IntLiteral>());
|
||||
}
|
||||
|
||||
TEST_F(IntLiteralTest, Uint_IsInt) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
UintLiteral i{&i32, 42};
|
||||
EXPECT_TRUE(i.Is<IntLiteral>());
|
||||
}
|
||||
|
|
|
@ -240,28 +240,28 @@ TextureSignature::~TextureSignature() = default;
|
|||
TextureSignature::Parameters::Index::Index() = default;
|
||||
TextureSignature::Parameters::Index::Index(const Index&) = default;
|
||||
|
||||
bool IsCoarseDerivative(ast::Intrinsic i) {
|
||||
bool IsCoarseDerivative(Intrinsic i) {
|
||||
return i == Intrinsic::kDpdxCoarse || i == Intrinsic::kDpdyCoarse ||
|
||||
i == Intrinsic::kFwidthCoarse;
|
||||
}
|
||||
|
||||
bool IsFineDerivative(ast::Intrinsic i) {
|
||||
bool IsFineDerivative(Intrinsic i) {
|
||||
return i == Intrinsic::kDpdxFine || i == Intrinsic::kDpdyFine ||
|
||||
i == Intrinsic::kFwidthFine;
|
||||
}
|
||||
|
||||
bool IsDerivative(ast::Intrinsic i) {
|
||||
bool IsDerivative(Intrinsic i) {
|
||||
return i == Intrinsic::kDpdx || i == Intrinsic::kDpdy ||
|
||||
i == Intrinsic::kFwidth || IsCoarseDerivative(i) ||
|
||||
IsFineDerivative(i);
|
||||
}
|
||||
|
||||
bool IsFloatClassificationIntrinsic(ast::Intrinsic i) {
|
||||
bool IsFloatClassificationIntrinsic(Intrinsic i) {
|
||||
return i == Intrinsic::kIsFinite || i == Intrinsic::kIsInf ||
|
||||
i == Intrinsic::kIsNan || i == Intrinsic::kIsNormal;
|
||||
}
|
||||
|
||||
bool IsTextureIntrinsic(ast::Intrinsic i) {
|
||||
bool IsTextureIntrinsic(Intrinsic i) {
|
||||
return i == Intrinsic::kTextureLoad || i == Intrinsic::kTextureSample ||
|
||||
i == Intrinsic::kTextureSampleLevel ||
|
||||
i == Intrinsic::kTextureSampleBias ||
|
||||
|
|
|
@ -161,27 +161,27 @@ struct TextureSignature : public Signature {
|
|||
/// Determines if the given |name| is a coarse derivative
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given derivative is coarse.
|
||||
bool IsCoarseDerivative(ast::Intrinsic i);
|
||||
bool IsCoarseDerivative(Intrinsic i);
|
||||
|
||||
/// Determines if the given |name| is a fine derivative
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given derivative is fine.
|
||||
bool IsFineDerivative(ast::Intrinsic i);
|
||||
bool IsFineDerivative(Intrinsic i);
|
||||
|
||||
/// Determine if the given |name| is a derivative intrinsic
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given |name| is a derivative intrinsic
|
||||
bool IsDerivative(ast::Intrinsic i);
|
||||
bool IsDerivative(Intrinsic i);
|
||||
|
||||
/// Determines if the given |name| is a float classification intrinsic
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given |name| is a float intrinsic
|
||||
bool IsFloatClassificationIntrinsic(ast::Intrinsic i);
|
||||
bool IsFloatClassificationIntrinsic(Intrinsic i);
|
||||
|
||||
/// Determines if the given |name| is a texture operation intrinsic
|
||||
/// @param i the intrinsic
|
||||
/// @returns true if the given |name| is a texture operation intrinsic
|
||||
bool IsTextureIntrinsic(ast::Intrinsic i);
|
||||
bool IsTextureIntrinsic(Intrinsic i);
|
||||
|
||||
} // namespace intrinsic
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,11 +26,11 @@ TextureOverloadCase::TextureOverloadCase(
|
|||
ValidTextureOverload o,
|
||||
const char* d,
|
||||
TextureKind tk,
|
||||
ast::type::SamplerKind sk,
|
||||
ast::type::TextureDimension td,
|
||||
type::SamplerKind sk,
|
||||
type::TextureDimension td,
|
||||
TextureDataType tdt,
|
||||
const char* f,
|
||||
std::function<ast::ExpressionList(ast::Builder*)> a)
|
||||
std::function<ExpressionList(Builder*)> a)
|
||||
: overload(o),
|
||||
description(d),
|
||||
texture_kind(tk),
|
||||
|
@ -49,11 +49,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k1d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k1d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
[](Builder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
1.0f); // coords
|
||||
|
@ -66,11 +66,11 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : f32,\n"
|
||||
" array_index : u32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k1dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k1dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
[](Builder* b) {
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
1.0f, // coords
|
||||
|
@ -83,12 +83,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : vec2<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f)); // coords
|
||||
|
@ -101,13 +101,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -121,12 +121,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" array_index : u32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -141,13 +141,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -161,12 +161,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : vec3<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
||||
|
@ -179,13 +179,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>\n"
|
||||
" offset : vec3<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -198,12 +198,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : vec3<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
||||
|
@ -216,12 +216,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" array_index : u32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -234,12 +234,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : vec2<f32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f)); // coords
|
||||
|
@ -252,13 +252,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -272,12 +272,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" array_index : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -292,13 +292,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -312,12 +312,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" s : sampler,\n"
|
||||
" coords : vec3<f32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f)); // coords
|
||||
|
@ -330,12 +330,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" array_index : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSample",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -349,12 +349,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" bias : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -369,13 +369,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" bias : f32,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -391,12 +391,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" bias : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -413,13 +413,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" bias : f32,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -435,12 +435,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" bias : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -455,13 +455,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" bias : f32,\n"
|
||||
" offset : vec3<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -476,12 +476,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" bias : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -496,12 +496,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" bias : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleBias",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -516,12 +516,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" level : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -536,13 +536,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" level : f32,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -558,12 +558,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" level : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -580,13 +580,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" level : f32,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -602,12 +602,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" level : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -622,13 +622,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" level : f32,\n"
|
||||
" offset : vec3<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -643,12 +643,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" level : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -663,12 +663,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" level : f32) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -683,12 +683,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" level : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -703,13 +703,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" level : u32,\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -725,12 +725,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" level : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -747,13 +747,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" level : u32,\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -769,12 +769,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" level : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -789,12 +789,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" level : u32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleLevel",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -810,12 +810,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddx : vec2<f32>,\n"
|
||||
" ddy : vec2<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.0f, 2.0f), // coords
|
||||
|
@ -832,13 +832,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddy : vec2<f32>,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -856,12 +856,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddx : vec2<f32>,\n"
|
||||
" ddy : vec2<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -880,13 +880,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddy : vec2<f32>,\n"
|
||||
" offset : vec2<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -904,12 +904,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddx : vec3<f32>,\n"
|
||||
" ddy : vec3<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -926,13 +926,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddy : vec3<f32>,\n"
|
||||
" offset : vec3<i32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::k3d,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::k3d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -949,12 +949,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddx : vec3<f32>,\n"
|
||||
" ddy : vec3<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -971,12 +971,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" ddx : vec3<f32>,\n"
|
||||
" ddy : vec3<f32>) -> vec4<f32>",
|
||||
TextureKind::kRegular,
|
||||
ast::type::SamplerKind::kSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleGrad",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -992,12 +992,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec2<f32>,\n"
|
||||
" depth_ref : f32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -1012,13 +1012,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" depth_ref : f32,\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::k2d,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::k2d,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -1034,12 +1034,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" depth_ref : f32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -1056,13 +1056,13 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" depth_ref : f32,\n"
|
||||
" offset : vec2<i32>) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::k2dArray,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::k2dArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
using i32 = ast::Builder::i32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
using i32 = Builder::i32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec2<f32>(1.f, 2.f), // coords
|
||||
|
@ -1078,12 +1078,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" coords : vec3<f32>,\n"
|
||||
" depth_ref : f32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::kCube,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::kCube,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
@ -1098,12 +1098,12 @@ std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {
|
|||
" array_index : u32,\n"
|
||||
" depth_ref : f32) -> f32",
|
||||
TextureKind::kDepth,
|
||||
ast::type::SamplerKind::kComparisonSampler,
|
||||
ast::type::TextureDimension::kCubeArray,
|
||||
type::SamplerKind::kComparisonSampler,
|
||||
type::TextureDimension::kCubeArray,
|
||||
TextureDataType::kF32,
|
||||
"textureSampleCompare",
|
||||
[](ast::Builder* b) {
|
||||
using f32 = ast::Builder::f32;
|
||||
[](Builder* b) {
|
||||
using f32 = Builder::f32;
|
||||
return b->ExprList("texture", // t
|
||||
"sampler", // s
|
||||
b->vec3<f32>(1.f, 2.f, 3.f), // coords
|
||||
|
|
|
@ -121,11 +121,11 @@ struct TextureOverloadCase {
|
|||
TextureOverloadCase(ValidTextureOverload,
|
||||
const char*,
|
||||
TextureKind,
|
||||
ast::type::SamplerKind,
|
||||
ast::type::TextureDimension,
|
||||
type::SamplerKind,
|
||||
type::TextureDimension,
|
||||
TextureDataType,
|
||||
const char*,
|
||||
std::function<ast::ExpressionList(ast::Builder*)>);
|
||||
std::function<ExpressionList(Builder*)>);
|
||||
/// Copy constructor
|
||||
TextureOverloadCase(const TextureOverloadCase&);
|
||||
/// Destructor
|
||||
|
@ -141,15 +141,15 @@ struct TextureOverloadCase {
|
|||
/// The texture kind for the texture parameter
|
||||
TextureKind texture_kind;
|
||||
/// The sampler kind for the sampler parameter
|
||||
ast::type::SamplerKind sampler_kind;
|
||||
type::SamplerKind sampler_kind;
|
||||
/// The dimensions of the texture parameter
|
||||
ast::type::TextureDimension texture_dimension;
|
||||
type::TextureDimension texture_dimension;
|
||||
/// The data type of the texture parameter
|
||||
TextureDataType texture_data_type;
|
||||
/// Name of the function. e.g. `textureSample`, `textureSampleGrad`, etc
|
||||
const char* function;
|
||||
/// A function that builds the AST arguments for the overload
|
||||
std::function<ast::ExpressionList(ast::Builder*)> args;
|
||||
std::function<ExpressionList(Builder*)> args;
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Literal::Literal(ast::type::Type* type) : type_(type) {}
|
||||
Literal::Literal(type::Type* type) : type_(type) {}
|
||||
|
||||
Literal::~Literal() = default;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Literal : public Castable<Literal, Node> {
|
|||
~Literal() override;
|
||||
|
||||
/// @returns the type of the literal
|
||||
ast::type::Type* type() const { return type_; }
|
||||
type::Type* type() const { return type_; }
|
||||
|
||||
/// @returns true if the node is valid
|
||||
bool IsValid() const override;
|
||||
|
@ -48,10 +48,10 @@ class Literal : public Castable<Literal, Node> {
|
|||
protected:
|
||||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
explicit Literal(ast::type::Type* type);
|
||||
explicit Literal(type::Type* type);
|
||||
|
||||
private:
|
||||
ast::type::Type* type_ = nullptr;
|
||||
type::Type* type_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(MemberAccessorExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(MemberAccessorExpressionTest, IsMemberAccessor) {
|
||||
MemberAccessorExpression stmt;
|
||||
EXPECT_TRUE(stmt.Is<ast::MemberAccessorExpression>());
|
||||
EXPECT_TRUE(stmt.Is<MemberAccessorExpression>());
|
||||
}
|
||||
|
||||
TEST_F(MemberAccessorExpressionTest, IsValid) {
|
||||
|
|
|
@ -37,7 +37,7 @@ Function* Module::FindFunctionByName(const std::string& name) const {
|
|||
}
|
||||
|
||||
Function* Module::FindFunctionByNameAndStage(const std::string& name,
|
||||
ast::PipelineStage stage) const {
|
||||
PipelineStage stage) const {
|
||||
for (auto* func : functions_) {
|
||||
if (func->name() == name && func->pipeline_stage() == stage) {
|
||||
return func;
|
||||
|
@ -56,17 +56,17 @@ bool Module::IsValid() const {
|
|||
if (ty == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (ty->Is<ast::type::AliasType>()) {
|
||||
auto* alias = ty->As<ast::type::AliasType>();
|
||||
if (ty->Is<type::AliasType>()) {
|
||||
auto* alias = ty->As<type::AliasType>();
|
||||
if (alias->type() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
if (alias->type()->Is<ast::type::StructType>() &&
|
||||
alias->type()->As<ast::type::StructType>()->name().empty()) {
|
||||
if (alias->type()->Is<type::StructType>() &&
|
||||
alias->type()->As<type::StructType>()->name().empty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (ty->Is<ast::type::StructType>()) {
|
||||
auto* str = ty->As<ast::type::StructType>();
|
||||
} else if (ty->Is<type::StructType>()) {
|
||||
auto* str = ty->As<type::StructType>();
|
||||
if (str->name().empty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -91,14 +91,14 @@ std::string Module::to_str() const {
|
|||
for (size_t i = 0; i < indent; ++i) {
|
||||
out << " ";
|
||||
}
|
||||
if (ty->Is<ast::type::AliasType>()) {
|
||||
auto* alias = ty->As<ast::type::AliasType>();
|
||||
if (ty->Is<type::AliasType>()) {
|
||||
auto* alias = ty->As<type::AliasType>();
|
||||
out << alias->name() << " -> " << alias->type()->type_name() << std::endl;
|
||||
if (alias->type()->Is<ast::type::StructType>()) {
|
||||
alias->type()->As<ast::type::StructType>()->impl()->to_str(out, indent);
|
||||
if (alias->type()->Is<type::StructType>()) {
|
||||
alias->type()->As<type::StructType>()->impl()->to_str(out, indent);
|
||||
}
|
||||
} else if (ty->Is<ast::type::StructType>()) {
|
||||
auto* str = ty->As<ast::type::StructType>();
|
||||
} else if (ty->Is<type::StructType>()) {
|
||||
auto* str = ty->As<type::StructType>();
|
||||
out << str->name() << " ";
|
||||
str->impl()->to_str(out, indent);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class Module {
|
|||
/// @param stage the pipeline stage
|
||||
/// @returns the associated function or nullptr if none exists
|
||||
Function* FindFunctionByNameAndStage(const std::string& name,
|
||||
ast::PipelineStage stage) const;
|
||||
PipelineStage stage) const;
|
||||
|
||||
/// @returns true if all required fields in the AST are present.
|
||||
bool IsValid() const;
|
||||
|
@ -84,23 +84,23 @@ class Module {
|
|||
/// @returns a string representation of the module
|
||||
std::string to_str() const;
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// Creates a new `Node` owned by the Module. When the Module is
|
||||
/// destructed, the `Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
EnableIfIsType<T, ast::Node>* create(ARGS&&... args) {
|
||||
static_assert(std::is_base_of<ast::Node, T>::value,
|
||||
"T does not derive from ast::Node");
|
||||
EnableIfIsType<T, Node>* create(ARGS&&... args) {
|
||||
static_assert(std::is_base_of<Node, T>::value,
|
||||
"T does not derive from Node");
|
||||
auto uptr = std::make_unique<T>(std::forward<ARGS>(args)...);
|
||||
auto ptr = uptr.get();
|
||||
ast_nodes_.emplace_back(std::move(uptr));
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/// Creates a new `ast::Type` owned by the Module.
|
||||
/// Creates a new `Type` owned by the Module.
|
||||
/// When the Module is destructed, owned Module and the returned
|
||||
/// `ast::Type` will also be destructed.
|
||||
/// `Type` will also be destructed.
|
||||
/// Types are unique (de-aliased), and so calling create() for the same `T`
|
||||
/// and arguments will return the same pointer.
|
||||
/// @warning Use this method to acquire a type only if all of its type
|
||||
|
@ -111,28 +111,27 @@ class Module {
|
|||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the de-aliased type pointer
|
||||
template <typename T, typename... ARGS>
|
||||
EnableIfIsType<T, ast::type::Type>* create(ARGS&&... args) {
|
||||
static_assert(std::is_base_of<ast::type::Type, T>::value,
|
||||
"T does not derive from ast::type::Type");
|
||||
EnableIfIsType<T, type::Type>* create(ARGS&&... args) {
|
||||
static_assert(std::is_base_of<type::Type, T>::value,
|
||||
"T does not derive from type::Type");
|
||||
return type_mgr_.Get<T>(std::forward<ARGS>(args)...);
|
||||
}
|
||||
|
||||
/// Moves the type `ty` to the Module, returning a pointer to the unique
|
||||
/// (de-aliased) type.
|
||||
/// When the Module is destructed, the returned `ast::Type` will also be
|
||||
/// When the Module is destructed, the returned `Type` will also be
|
||||
/// destructed.
|
||||
/// @see create()
|
||||
/// @param ty the type to add to the module
|
||||
/// @returns the de-aliased type pointer
|
||||
template <typename T>
|
||||
EnableIfIsType<T, ast::type::Type>* unique_type(std::unique_ptr<T> ty) {
|
||||
EnableIfIsType<T, type::Type>* unique_type(std::unique_ptr<T> ty) {
|
||||
return static_cast<T*>(type_mgr_.Get(std::move(ty)));
|
||||
}
|
||||
|
||||
/// Returns all the declared types in the module
|
||||
/// @returns the mapping from name string to type.
|
||||
const std::unordered_map<std::string, std::unique_ptr<ast::type::Type>>&
|
||||
types() {
|
||||
const std::unordered_map<std::string, std::unique_ptr<type::Type>>& types() {
|
||||
return type_mgr_.types();
|
||||
}
|
||||
|
||||
|
@ -143,8 +142,8 @@ class Module {
|
|||
// The constructed types are owned by the type manager
|
||||
std::vector<type::Type*> constructed_types_;
|
||||
FunctionList functions_;
|
||||
std::vector<std::unique_ptr<ast::Node>> ast_nodes_;
|
||||
ast::TypeManager type_mgr_;
|
||||
std::vector<std::unique_ptr<Node>> ast_nodes_;
|
||||
TypeManager type_mgr_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -48,8 +48,8 @@ TEST_F(ModuleTest, LookupFunction) {
|
|||
type::F32Type f32;
|
||||
Module m;
|
||||
|
||||
auto* func = create<Function>("main", VariableList{}, &f32,
|
||||
create<ast::BlockStatement>());
|
||||
auto* func =
|
||||
create<Function>("main", VariableList{}, &f32, create<BlockStatement>());
|
||||
m.AddFunction(func);
|
||||
EXPECT_EQ(func, m.FindFunctionByName("main"));
|
||||
}
|
||||
|
@ -124,8 +124,8 @@ TEST_F(ModuleTest, IsValid_Struct_EmptyName) {
|
|||
|
||||
TEST_F(ModuleTest, IsValid_Function) {
|
||||
type::F32Type f32;
|
||||
auto* func = create<Function>("main", VariableList(), &f32,
|
||||
create<ast::BlockStatement>());
|
||||
auto* func =
|
||||
create<Function>("main", VariableList(), &f32, create<BlockStatement>());
|
||||
|
||||
Module m;
|
||||
m.AddFunction(func);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
NullLiteral::NullLiteral(ast::type::Type* type) : Base(type) {}
|
||||
NullLiteral::NullLiteral(type::Type* type) : Base(type) {}
|
||||
|
||||
NullLiteral::~NullLiteral() = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class NullLiteral : public Castable<NullLiteral, Literal> {
|
|||
public:
|
||||
/// Constructor
|
||||
/// @param type the type
|
||||
explicit NullLiteral(ast::type::Type* type);
|
||||
explicit NullLiteral(type::Type* type);
|
||||
~NullLiteral() override;
|
||||
|
||||
/// @returns the name for this literal. This name is unique to this value.
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using NullLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(NullLiteralTest, Is) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
NullLiteral i{&i32};
|
||||
Literal* l = &i;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
|
@ -40,14 +40,14 @@ TEST_F(NullLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(NullLiteralTest, ToStr) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
NullLiteral i{&i32};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "null __i32");
|
||||
}
|
||||
|
||||
TEST_F(NullLiteralTest, Name_I32) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
NullLiteral i{&i32};
|
||||
EXPECT_EQ("__null__i32", i.name());
|
||||
}
|
||||
|
|
|
@ -25,14 +25,14 @@ namespace {
|
|||
using ScalarConstructorExpressionTest = TestHelper;
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, Creation) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
EXPECT_EQ(c.literal(), b);
|
||||
}
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
ScalarConstructorExpression c(Source{Source::Location{20, 2}}, b);
|
||||
auto src = c.source();
|
||||
|
@ -41,7 +41,7 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
|||
}
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, IsValid) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
EXPECT_TRUE(c.IsValid());
|
||||
|
@ -53,7 +53,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) {
|
|||
}
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, ToStr) {
|
||||
ast::type::BoolType bool_type;
|
||||
type::BoolType bool_type;
|
||||
auto* b = create<BoolLiteral>(&bool_type, true);
|
||||
ScalarConstructorExpression c(b);
|
||||
std::ostringstream out;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SintLiteral::SintLiteral(ast::type::Type* type, int32_t value)
|
||||
SintLiteral::SintLiteral(type::Type* type, int32_t value)
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
SintLiteral::~SintLiteral() = default;
|
||||
|
|
|
@ -28,7 +28,7 @@ class SintLiteral : public Castable<SintLiteral, IntLiteral> {
|
|||
/// Constructor
|
||||
/// @param type the type
|
||||
/// @param value the signed int literals value
|
||||
SintLiteral(ast::type::Type* type, int32_t value);
|
||||
SintLiteral(type::Type* type, int32_t value);
|
||||
~SintLiteral() override;
|
||||
|
||||
/// Updates the literals value
|
||||
|
|
|
@ -29,14 +29,14 @@ namespace {
|
|||
using SintLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(SintLiteralTest, Value) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
SintLiteral i{&i32, 47};
|
||||
ASSERT_TRUE(i.Is<SintLiteral>());
|
||||
EXPECT_EQ(i.value(), 47);
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Is) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
SintLiteral i{&i32, 42};
|
||||
Literal* l = &i;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
|
@ -47,20 +47,20 @@ TEST_F(SintLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(SintLiteralTest, ToStr) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
SintLiteral i{&i32, -42};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "-42");
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Name_I32) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
SintLiteral i{&i32, 2};
|
||||
EXPECT_EQ("__sint__i32_2", i.name());
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Name_U32) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
SintLiteral i{&u32, 2};
|
||||
EXPECT_EQ("__sint__u32_2", i.name());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StageDecoration::StageDecoration(ast::PipelineStage stage, const Source& source)
|
||||
StageDecoration::StageDecoration(PipelineStage stage, const Source& source)
|
||||
: Base(source), stage_(stage) {}
|
||||
|
||||
StageDecoration::~StageDecoration() = default;
|
||||
|
|
|
@ -27,11 +27,11 @@ class StageDecoration : public Castable<StageDecoration, FunctionDecoration> {
|
|||
/// constructor
|
||||
/// @param stage the pipeline stage
|
||||
/// @param source the source of this decoration
|
||||
StageDecoration(ast::PipelineStage stage, const Source& source);
|
||||
StageDecoration(PipelineStage stage, const Source& source);
|
||||
~StageDecoration() override;
|
||||
|
||||
/// @returns the stage
|
||||
ast::PipelineStage value() const { return stage_; }
|
||||
PipelineStage value() const { return stage_; }
|
||||
|
||||
/// Outputs the decoration to the given stream
|
||||
/// @param out the stream to write to
|
||||
|
@ -39,7 +39,7 @@ class StageDecoration : public Castable<StageDecoration, FunctionDecoration> {
|
|||
void to_str(std::ostream& out, size_t indent) const override;
|
||||
|
||||
private:
|
||||
ast::PipelineStage stage_ = ast::PipelineStage::kNone;
|
||||
PipelineStage stage_ = PipelineStage::kNone;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -26,19 +26,19 @@ namespace {
|
|||
using StageDecorationTest = TestHelper;
|
||||
|
||||
TEST_F(StageDecorationTest, Creation_1param) {
|
||||
StageDecoration d{ast::PipelineStage::kFragment, Source{}};
|
||||
EXPECT_EQ(d.value(), ast::PipelineStage::kFragment);
|
||||
StageDecoration d{PipelineStage::kFragment, Source{}};
|
||||
EXPECT_EQ(d.value(), PipelineStage::kFragment);
|
||||
}
|
||||
|
||||
TEST_F(StageDecorationTest, Is) {
|
||||
StageDecoration sd{ast::PipelineStage::kFragment, Source{}};
|
||||
StageDecoration sd{PipelineStage::kFragment, Source{}};
|
||||
Decoration* d = &sd;
|
||||
EXPECT_FALSE(d->Is<WorkgroupDecoration>());
|
||||
EXPECT_TRUE(d->Is<StageDecoration>());
|
||||
}
|
||||
|
||||
TEST_F(StageDecorationTest, ToStr) {
|
||||
StageDecoration d{ast::PipelineStage::kFragment, Source{}};
|
||||
StageDecoration d{PipelineStage::kFragment, Source{}};
|
||||
std::ostringstream out;
|
||||
d.to_str(out, 0);
|
||||
EXPECT_EQ(out.str(), R"(StageDecoration{fragment}
|
||||
|
|
|
@ -41,7 +41,7 @@ StructMember::~StructMember() = default;
|
|||
|
||||
bool StructMember::has_offset_decoration() const {
|
||||
for (auto* deco : decorations_) {
|
||||
if (deco->Is<ast::StructMemberOffsetDecoration>()) {
|
||||
if (deco->Is<StructMemberOffsetDecoration>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ bool StructMember::has_offset_decoration() const {
|
|||
|
||||
uint32_t StructMember::offset() const {
|
||||
for (auto* deco : decorations_) {
|
||||
if (auto* offset = deco->As<ast::StructMemberOffsetDecoration>()) {
|
||||
if (auto* offset = deco->As<StructMemberOffsetDecoration>()) {
|
||||
return offset->offset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ TEST_F(StructMemberOffsetDecorationTest, Creation) {
|
|||
|
||||
TEST_F(StructMemberOffsetDecorationTest, Is) {
|
||||
StructMemberOffsetDecoration d{2, Source{}};
|
||||
EXPECT_TRUE(d.Is<ast::StructMemberOffsetDecoration>());
|
||||
EXPECT_TRUE(d.Is<StructMemberOffsetDecoration>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -36,7 +36,7 @@ TEST_F(StructMemberTest, Creation) {
|
|||
EXPECT_EQ(st.name(), "a");
|
||||
EXPECT_EQ(st.type(), &i32);
|
||||
EXPECT_EQ(st.decorations().size(), 1u);
|
||||
EXPECT_TRUE(st.decorations()[0]->Is<ast::StructMemberOffsetDecoration>());
|
||||
EXPECT_TRUE(st.decorations()[0]->Is<StructMemberOffsetDecoration>());
|
||||
EXPECT_EQ(st.source().range.begin.line, 0u);
|
||||
EXPECT_EQ(st.source().range.begin.column, 0u);
|
||||
EXPECT_EQ(st.source().range.end.line, 0u);
|
||||
|
|
|
@ -29,14 +29,14 @@ namespace {
|
|||
using SwitchStatementTest = TestHelper;
|
||||
|
||||
TEST_F(SwitchStatementTest, Creation) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 1));
|
||||
|
||||
auto* ident = create<IdentifierExpression>("ident");
|
||||
CaseStatementList body;
|
||||
auto* case_stmt = create<CaseStatement>(lit, create<ast::BlockStatement>());
|
||||
auto* case_stmt = create<CaseStatement>(lit, create<BlockStatement>());
|
||||
body.push_back(case_stmt);
|
||||
|
||||
SwitchStatement stmt(ident, body);
|
||||
|
@ -61,27 +61,27 @@ TEST_F(SwitchStatementTest, IsSwitch) {
|
|||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, IsValid) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
auto* ident = create<IdentifierExpression>("ident");
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<ast::BlockStatement>()));
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
|
||||
SwitchStatement stmt(ident, body);
|
||||
EXPECT_TRUE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<ast::BlockStatement>()));
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
|
||||
SwitchStatement stmt;
|
||||
stmt.set_body(body);
|
||||
|
@ -89,28 +89,28 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
|
|||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
auto* ident = create<IdentifierExpression>("");
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<ast::BlockStatement>()));
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
|
||||
SwitchStatement stmt(ident, body);
|
||||
EXPECT_FALSE(stmt.IsValid());
|
||||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
auto* ident = create<IdentifierExpression>("ident");
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<ast::BlockStatement>()));
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
body.push_back(nullptr);
|
||||
|
||||
SwitchStatement stmt(ident, body);
|
||||
|
@ -120,7 +120,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) {
|
|||
TEST_F(SwitchStatementTest, IsValid_Invalid_BodyStatement) {
|
||||
auto* ident = create<IdentifierExpression>("ident");
|
||||
|
||||
auto* case_body = create<ast::BlockStatement>();
|
||||
auto* case_body = create<BlockStatement>();
|
||||
case_body->append(nullptr);
|
||||
|
||||
CaseStatementList body;
|
||||
|
@ -145,14 +145,14 @@ TEST_F(SwitchStatementTest, ToStr_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(SwitchStatementTest, ToStr) {
|
||||
ast::type::I32Type i32;
|
||||
type::I32Type i32;
|
||||
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(&i32, 2));
|
||||
|
||||
auto* ident = create<IdentifierExpression>("ident");
|
||||
CaseStatementList body;
|
||||
body.push_back(create<CaseStatement>(lit, create<ast::BlockStatement>()));
|
||||
body.push_back(create<CaseStatement>(lit, create<BlockStatement>()));
|
||||
|
||||
SwitchStatement stmt(ident, body);
|
||||
std::ostringstream out;
|
||||
|
|
|
@ -31,8 +31,8 @@ class TestHelperBase : public BASE {
|
|||
TestHelperBase() {}
|
||||
~TestHelperBase() = default;
|
||||
|
||||
/// Creates a new `ast::Node` owned by the Module. When the Module is
|
||||
/// destructed, the `ast::Node` will also be destructed.
|
||||
/// Creates a new `Node` owned by the Module. When the Module is
|
||||
/// destructed, the `Node` will also be destructed.
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
/// @returns the node pointer
|
||||
template <typename T, typename... ARGS>
|
||||
|
|
|
@ -136,9 +136,9 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -185,9 +185,9 @@ TEST_F(AccessControlTypeTest, BaseAlignmentStruct) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
|
|
|
@ -201,9 +201,9 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
AliasType alias{"alias", &struct_type};
|
||||
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -250,9 +250,9 @@ TEST_F(AliasTypeTest, BaseAlignmentStruct) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
AliasType alias{"alias", &struct_type};
|
||||
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
|
|
|
@ -65,7 +65,7 @@ uint64_t ArrayType::BaseAlignment(MemoryLayout mem_layout) const {
|
|||
|
||||
uint32_t ArrayType::array_stride() const {
|
||||
for (auto* deco : decos_) {
|
||||
if (auto* stride = deco->As<ast::StrideDecoration>()) {
|
||||
if (auto* stride = deco->As<StrideDecoration>()) {
|
||||
return stride->stride();
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ uint32_t ArrayType::array_stride() const {
|
|||
|
||||
bool ArrayType::has_array_stride() const {
|
||||
for (auto* deco : decos_) {
|
||||
if (deco->Is<ast::StrideDecoration>()) {
|
||||
if (deco->Is<StrideDecoration>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,9 +57,7 @@ class ArrayType : public Castable<ArrayType, Type> {
|
|||
|
||||
/// Sets the array decorations
|
||||
/// @param decos the decorations to set
|
||||
void set_decorations(ast::ArrayDecorationList decos) {
|
||||
decos_ = std::move(decos);
|
||||
}
|
||||
void set_decorations(ArrayDecorationList decos) { decos_ = std::move(decos); }
|
||||
/// @returns the array decorations
|
||||
const ArrayDecorationList& decorations() const { return decos_; }
|
||||
|
||||
|
@ -79,7 +77,7 @@ class ArrayType : public Castable<ArrayType, Type> {
|
|||
private:
|
||||
Type* subtype_ = nullptr;
|
||||
uint32_t size_ = 0;
|
||||
ast::ArrayDecorationList decos_;
|
||||
ArrayDecorationList decos_;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
|
|
@ -93,7 +93,7 @@ TEST_F(StorageTextureTypeTest, TypeName) {
|
|||
|
||||
TEST_F(StorageTextureTypeTest, F32Type) {
|
||||
Context ctx;
|
||||
ast::Module mod;
|
||||
Module mod;
|
||||
Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
|
||||
AccessControl::kReadOnly,
|
||||
ImageFormat::kRgba32Float);
|
||||
|
@ -108,7 +108,7 @@ TEST_F(StorageTextureTypeTest, F32Type) {
|
|||
|
||||
TEST_F(StorageTextureTypeTest, U32Type) {
|
||||
Context ctx;
|
||||
ast::Module mod;
|
||||
Module mod;
|
||||
Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
|
||||
AccessControl::kReadOnly,
|
||||
ImageFormat::kRg32Uint);
|
||||
|
@ -122,7 +122,7 @@ TEST_F(StorageTextureTypeTest, U32Type) {
|
|||
|
||||
TEST_F(StorageTextureTypeTest, I32Type) {
|
||||
Context ctx;
|
||||
ast::Module mod;
|
||||
Module mod;
|
||||
Type* s = mod.create<StorageTextureType>(TextureDimension::k2dArray,
|
||||
AccessControl::kReadOnly,
|
||||
ImageFormat::kRgba32Sint);
|
||||
|
|
|
@ -85,9 +85,9 @@ TEST_F(StructTypeTest, MinBufferBindingSize) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -119,9 +119,9 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &arr, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(32u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -154,9 +154,9 @@ TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(12u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||
|
@ -172,9 +172,9 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec2, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -191,9 +191,9 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec3, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -211,9 +211,9 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec4, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u,
|
||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
|
@ -235,9 +235,9 @@ TEST_F(StructTypeTest, BaseAlignment) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
|
@ -268,9 +268,9 @@ TEST_F(StructTypeTest, BaseAlignmentArray) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &arr, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
|
@ -301,9 +301,9 @@ TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||
members.push_back(create<StructMember>("bar", &u32, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
}
|
||||
|
@ -318,9 +318,9 @@ TEST_F(StructTypeTest, BaseAlignmentVec2) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec2, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
|
@ -336,9 +336,9 @@ TEST_F(StructTypeTest, BaseAlignmentVec3) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec3, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
|
@ -354,9 +354,9 @@ TEST_F(StructTypeTest, BaseAlignmentVec4) {
|
|||
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||
members.push_back(create<StructMember>("foo", &vec4, deco));
|
||||
}
|
||||
ast::StructDecorationList decos;
|
||||
StructDecorationList decos;
|
||||
|
||||
auto* str = create<ast::Struct>(decos, members);
|
||||
auto* str = create<Struct>(decos, members);
|
||||
StructType struct_type("struct_type", str);
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
|
|
|
@ -53,7 +53,7 @@ TEST_F(TypeConstructorExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) {
|
||||
TypeConstructorExpression t;
|
||||
EXPECT_TRUE(t.Is<ast::TypeConstructorExpression>());
|
||||
EXPECT_TRUE(t.Is<TypeConstructorExpression>());
|
||||
}
|
||||
|
||||
TEST_F(TypeConstructorExpressionTest, IsValid) {
|
||||
|
|
|
@ -27,7 +27,7 @@ void TypeManager::Reset() {
|
|||
types_.clear();
|
||||
}
|
||||
|
||||
ast::type::Type* TypeManager::Get(std::unique_ptr<ast::type::Type> type) {
|
||||
type::Type* TypeManager::Get(std::unique_ptr<type::Type> type) {
|
||||
auto name = type->type_name();
|
||||
|
||||
if (types_.find(name) == types_.end()) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class TypeManager {
|
|||
/// Get the given type from the type manager
|
||||
/// @param type The type to register
|
||||
/// @return the pointer to the registered type
|
||||
ast::type::Type* Get(std::unique_ptr<ast::type::Type> type);
|
||||
type::Type* Get(std::unique_ptr<type::Type> type);
|
||||
|
||||
/// Get the given type `T` from the type manager
|
||||
/// @param args the arguments to pass to the type constructor
|
||||
|
@ -52,13 +52,12 @@ class TypeManager {
|
|||
|
||||
/// Returns the type map
|
||||
/// @returns the mapping from name string to type.
|
||||
const std::unordered_map<std::string, std::unique_ptr<ast::type::Type>>&
|
||||
types() {
|
||||
const std::unordered_map<std::string, std::unique_ptr<type::Type>>& types() {
|
||||
return types_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<ast::type::Type>> types_;
|
||||
std::unordered_map<std::string, std::unique_ptr<type::Type>> types_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -20,51 +20,53 @@
|
|||
#include "src/ast/type/u32_type.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
namespace {
|
||||
|
||||
using TypeManagerTest = testing::Test;
|
||||
|
||||
TEST_F(TypeManagerTest, GetUnregistered) {
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(t->Is<type::I32Type>());
|
||||
}
|
||||
|
||||
TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) {
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(t->Is<type::I32Type>());
|
||||
|
||||
auto* t2 = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
auto* t2 = tm.Get(std::make_unique<type::I32Type>());
|
||||
EXPECT_EQ(t, t2);
|
||||
}
|
||||
|
||||
TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) {
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
EXPECT_TRUE(t->Is<ast::type::I32Type>());
|
||||
EXPECT_TRUE(t->Is<type::I32Type>());
|
||||
|
||||
auto* t2 = tm.Get(std::make_unique<ast::type::U32Type>());
|
||||
auto* t2 = tm.Get(std::make_unique<type::U32Type>());
|
||||
ASSERT_NE(t2, nullptr);
|
||||
EXPECT_NE(t, t2);
|
||||
EXPECT_TRUE(t2->Is<ast::type::U32Type>());
|
||||
EXPECT_TRUE(t2->Is<type::U32Type>());
|
||||
}
|
||||
|
||||
TEST_F(TypeManagerTest, ResetClearsPreviousData) {
|
||||
ast::TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
TypeManager tm;
|
||||
auto* t = tm.Get(std::make_unique<type::I32Type>());
|
||||
ASSERT_NE(t, nullptr);
|
||||
|
||||
EXPECT_FALSE(tm.types().empty());
|
||||
tm.Reset();
|
||||
EXPECT_TRUE(tm.types().empty());
|
||||
|
||||
auto* t2 = tm.Get(std::make_unique<ast::type::I32Type>());
|
||||
auto* t2 = tm.Get(std::make_unique<type::I32Type>());
|
||||
ASSERT_NE(t2, nullptr);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
UintLiteral::UintLiteral(ast::type::Type* type, uint32_t value)
|
||||
UintLiteral::UintLiteral(type::Type* type, uint32_t value)
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
UintLiteral::~UintLiteral() = default;
|
||||
|
|
|
@ -28,7 +28,7 @@ class UintLiteral : public Castable<UintLiteral, IntLiteral> {
|
|||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
/// @param value the uint literals value
|
||||
UintLiteral(ast::type::Type* type, uint32_t value);
|
||||
UintLiteral(type::Type* type, uint32_t value);
|
||||
~UintLiteral() override;
|
||||
|
||||
/// Updates the literals value
|
||||
|
|
|
@ -28,14 +28,14 @@ namespace {
|
|||
using UintLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(UintLiteralTest, Value) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
UintLiteral u{&u32, 47};
|
||||
ASSERT_TRUE(u.Is<UintLiteral>());
|
||||
EXPECT_EQ(u.value(), 47u);
|
||||
}
|
||||
|
||||
TEST_F(UintLiteralTest, Is) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
UintLiteral u{&u32, 42};
|
||||
Literal* l = &u;
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
|
@ -46,7 +46,7 @@ TEST_F(UintLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(UintLiteralTest, ToStr) {
|
||||
ast::type::U32Type u32;
|
||||
type::U32Type u32;
|
||||
UintLiteral i{&u32, 42};
|
||||
|
||||
EXPECT_EQ(i.to_str(), "42");
|
||||
|
|
|
@ -43,7 +43,7 @@ TEST_F(UnaryOpExpressionTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(UnaryOpExpressionTest, IsUnaryOp) {
|
||||
UnaryOpExpression u;
|
||||
EXPECT_TRUE(u.Is<ast::UnaryOpExpression>());
|
||||
EXPECT_TRUE(u.Is<UnaryOpExpression>());
|
||||
}
|
||||
|
||||
TEST_F(UnaryOpExpressionTest, IsValid) {
|
||||
|
|
Loading…
Reference in New Issue