From 03ae9a397f6572f59d0d4adce5232330e859d5c8 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 30 Nov 2020 23:30:58 +0000 Subject: [PATCH] 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 --- src/ast/array_accessor_expression_test.cc | 2 +- src/ast/assignment_statement_test.cc | 32 +- src/ast/binary_expression_test.cc | 2 +- src/ast/bitcast_expression_test.cc | 2 +- src/ast/block_statement.h | 22 +- src/ast/bool_literal.cc | 2 +- src/ast/bool_literal.h | 2 +- src/ast/bool_literal_test.cc | 8 +- src/ast/builder.cc | 23 +- src/ast/builder.h | 260 +++++----- src/ast/call_expression_test.cc | 2 +- src/ast/call_statement_test.cc | 14 +- src/ast/case_statement_test.cc | 30 +- src/ast/decorated_variable_test.cc | 4 +- src/ast/else_statement_test.cc | 8 +- src/ast/expression_test.cc | 4 +- src/ast/float_literal.cc | 2 +- src/ast/float_literal.h | 2 +- src/ast/float_literal_test.cc | 8 +- src/ast/function.cc | 57 ++- src/ast/function.h | 8 +- src/ast/function_test.cc | 102 ++-- src/ast/identifier_expression_test.cc | 2 +- src/ast/int_literal.cc | 2 +- src/ast/int_literal.h | 2 +- src/ast/int_literal_test.cc | 4 +- src/ast/intrinsic.cc | 10 +- src/ast/intrinsic.h | 10 +- src/ast/intrinsic_texture_helper_test.cc | 454 +++++++++--------- src/ast/intrinsic_texture_helper_test.h | 12 +- src/ast/literal.cc | 2 +- src/ast/literal.h | 6 +- src/ast/member_accessor_expression_test.cc | 2 +- src/ast/module.cc | 26 +- src/ast/module.h | 33 +- src/ast/module_test.cc | 8 +- src/ast/null_literal.cc | 2 +- src/ast/null_literal.h | 2 +- src/ast/null_literal_test.cc | 6 +- src/ast/scalar_constructor_expression_test.cc | 8 +- src/ast/sint_literal.cc | 2 +- src/ast/sint_literal.h | 2 +- src/ast/sint_literal_test.cc | 10 +- src/ast/stage_decoration.cc | 2 +- src/ast/stage_decoration.h | 6 +- src/ast/stage_decoration_test.cc | 8 +- src/ast/struct_member.cc | 4 +- .../struct_member_offset_decoration_test.cc | 2 +- src/ast/struct_member_test.cc | 2 +- src/ast/switch_statement_test.cc | 26 +- src/ast/test_helper.h | 4 +- src/ast/type/access_control_type_test.cc | 8 +- src/ast/type/alias_type_test.cc | 8 +- src/ast/type/array_type.cc | 4 +- src/ast/type/array_type.h | 6 +- src/ast/type/storage_texture_type_test.cc | 6 +- src/ast/type/struct_type_test.cc | 48 +- src/ast/type_constructor_expression_test.cc | 2 +- src/ast/type_manager.cc | 2 +- src/ast/type_manager.h | 7 +- src/ast/type_manager_test.cc | 32 +- src/ast/uint_literal.cc | 2 +- src/ast/uint_literal.h | 2 +- src/ast/uint_literal_test.cc | 6 +- src/ast/unary_op_expression_test.cc | 2 +- 65 files changed, 684 insertions(+), 706 deletions(-) diff --git a/src/ast/array_accessor_expression_test.cc b/src/ast/array_accessor_expression_test.cc index e49ba8eba2..f657815d57 100644 --- a/src/ast/array_accessor_expression_test.cc +++ b/src/ast/array_accessor_expression_test.cc @@ -44,7 +44,7 @@ TEST_F(ArrayAccessorExpressionTest, CreateWithSource) { TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) { ArrayAccessorExpression exp; - EXPECT_TRUE(exp.Is()); + EXPECT_TRUE(exp.Is()); } TEST_F(ArrayAccessorExpressionTest, IsValid) { diff --git a/src/ast/assignment_statement_test.cc b/src/ast/assignment_statement_test.cc index ad430b70af..b804363821 100644 --- a/src/ast/assignment_statement_test.cc +++ b/src/ast/assignment_statement_test.cc @@ -24,8 +24,8 @@ namespace { using AssignmentStatementTest = TestHelper; TEST_F(AssignmentStatementTest, Creation) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create("lhs"); + auto* rhs = create("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("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create("lhs"); + auto* rhs = create("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("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create("lhs"); + auto* rhs = create("rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_TRUE(stmt.Is()); } TEST_F(AssignmentStatementTest, IsValid) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create("lhs"); + auto* rhs = create("rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_TRUE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_MissingLHS) { - auto* rhs = create("rhs"); + auto* rhs = create("rhs"); AssignmentStatement stmt; stmt.set_rhs(rhs); @@ -67,7 +67,7 @@ TEST_F(AssignmentStatementTest, IsValid_MissingLHS) { } TEST_F(AssignmentStatementTest, IsValid_MissingRHS) { - auto* lhs = create("lhs"); + auto* lhs = create("lhs"); AssignmentStatement stmt; stmt.set_lhs(lhs); @@ -75,22 +75,22 @@ TEST_F(AssignmentStatementTest, IsValid_MissingRHS) { } TEST_F(AssignmentStatementTest, IsValid_InvalidLHS) { - auto* lhs = create(""); - auto* rhs = create("rhs"); + auto* lhs = create(""); + auto* rhs = create("rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_InvalidRHS) { - auto* lhs = create("lhs"); - auto* rhs = create(""); + auto* lhs = create("lhs"); + auto* rhs = create(""); AssignmentStatement stmt(lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, ToStr) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create("lhs"); + auto* rhs = create("rhs"); AssignmentStatement stmt(lhs, rhs); std::ostringstream out; diff --git a/src/ast/binary_expression_test.cc b/src/ast/binary_expression_test.cc index d056ebcbe9..2242b24dda 100644 --- a/src/ast/binary_expression_test.cc +++ b/src/ast/binary_expression_test.cc @@ -48,7 +48,7 @@ TEST_F(BinaryExpressionTest, Creation_WithSource) { TEST_F(BinaryExpressionTest, IsBinaryal) { BinaryExpression r; - EXPECT_TRUE(r.Is()); + EXPECT_TRUE(r.Is()); } TEST_F(BinaryExpressionTest, IsValid) { diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc index 9810a2f064..a07eee71d5 100644 --- a/src/ast/bitcast_expression_test.cc +++ b/src/ast/bitcast_expression_test.cc @@ -45,7 +45,7 @@ TEST_F(BitcastExpressionTest, CreateWithSource) { TEST_F(BitcastExpressionTest, IsBitcast) { BitcastExpression exp; - EXPECT_TRUE(exp.Is()); + EXPECT_TRUE(exp.Is()); } TEST_F(BitcastExpressionTest, IsValid) { diff --git a/src/ast/block_statement.h b/src/ast/block_statement.h index 0b8dac5a76..f5803c3bfd 100644 --- a/src/ast/block_statement.h +++ b/src/ast/block_statement.h @@ -38,12 +38,12 @@ class BlockStatement : public Castable { /// 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(index); statements_.insert(statements_.begin() + offset, stmt); } @@ -54,36 +54,34 @@ class BlockStatement : public Castable { 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::const_iterator begin() const { + std::vector::const_iterator begin() const { return statements_.begin(); } /// @returns the ending iterator - std::vector::const_iterator end() const { + std::vector::const_iterator end() const { return statements_.end(); } @@ -98,7 +96,7 @@ class BlockStatement : public Castable { private: BlockStatement(const BlockStatement&) = delete; - std::vector statements_; + std::vector statements_; }; } // namespace ast diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc index a40d99a533..7f909a6017 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -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; diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h index 27005311b0..4b5acf36fe 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -28,7 +28,7 @@ class BoolLiteral : public Castable { /// 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 diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index 63fe6631cc..ca2ff785bf 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -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()); 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()); 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()); @@ -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}; diff --git a/src/ast/builder.cc b/src/ast/builder.cc index 0b27fd9780..eca0c04d0a 100644 --- a/src/ast/builder.cc +++ b/src/ast/builder.cc @@ -18,27 +18,26 @@ namespace tint { namespace ast { TypesBuilder::TypesBuilder(Module* mod) - : bool_(mod->create()), - f32(mod->create()), - i32(mod->create()), - u32(mod->create()), - void_(mod->create()), + : bool_(mod->create()), + f32(mod->create()), + i32(mod->create()), + u32(mod->create()), + void_(mod->create()), 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(name, storage, type); +Variable* Builder::Var(const std::string& name, + StorageClass storage, + type::Type* type) { + auto* var = create(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; diff --git a/src/ast/builder.h b/src/ast/builder.h index f80a4f671e..7ea60781c3 100644 --- a/src/ast/builder.h +++ b/src/ast/builder.h @@ -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 - ast::type::Type* Of() const { + type::Type* Of() const { return CToAST::get(this); } /// @return the tint AST type for a 2-element vector of the C type `T`. template - ast::type::VectorType* vec2() const { - return mod_->create(Of(), 2); + type::VectorType* vec2() const { + return mod_->create(Of(), 2); } /// @return the tint AST type for a 3-element vector of the C type `T`. template - ast::type::VectorType* vec3() const { - return mod_->create(Of(), 3); + type::VectorType* vec3() const { + return mod_->create(Of(), 3); } /// @return the tint AST type for a 4-element vector of the C type `T`. template - ast::type::Type* vec4() const { - return mod_->create(Of(), 4); + type::Type* vec4() const { + return mod_->create(Of(), 4); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - ast::type::MatrixType* mat2x2() const { - return mod_->create(Of(), 2, 2); + type::MatrixType* mat2x2() const { + return mod_->create(Of(), 2, 2); } /// @return the tint AST type for a 2x3 matrix of the C type `T`. template - ast::type::MatrixType* mat2x3() const { - return mod_->create(Of(), 3, 2); + type::MatrixType* mat2x3() const { + return mod_->create(Of(), 3, 2); } /// @return the tint AST type for a 2x4 matrix of the C type `T`. template - ast::type::MatrixType* mat2x4() const { - return mod_->create(Of(), 4, 2); + type::MatrixType* mat2x4() const { + return mod_->create(Of(), 4, 2); } /// @return the tint AST type for a 3x2 matrix of the C type `T`. template - ast::type::MatrixType* mat3x2() const { - return mod_->create(Of(), 2, 3); + type::MatrixType* mat3x2() const { + return mod_->create(Of(), 2, 3); } /// @return the tint AST type for a 3x3 matrix of the C type `T`. template - ast::type::MatrixType* mat3x3() const { - return mod_->create(Of(), 3, 3); + type::MatrixType* mat3x3() const { + return mod_->create(Of(), 3, 3); } /// @return the tint AST type for a 3x4 matrix of the C type `T`. template - ast::type::MatrixType* mat3x4() const { - return mod_->create(Of(), 4, 3); + type::MatrixType* mat3x4() const { + return mod_->create(Of(), 4, 3); } /// @return the tint AST type for a 4x2 matrix of the C type `T`. template - ast::type::MatrixType* mat4x2() const { - return mod_->create(Of(), 2, 4); + type::MatrixType* mat4x2() const { + return mod_->create(Of(), 2, 4); } /// @return the tint AST type for a 4x3 matrix of the C type `T`. template - ast::type::MatrixType* mat4x3() const { - return mod_->create(Of(), 3, 4); + type::MatrixType* mat4x3() const { + return mod_->create(Of(), 3, 4); } /// @return the tint AST type for a 4x4 matrix of the C type `T`. template - ast::type::MatrixType* mat4x4() const { - return mod_->create(Of(), 4, 4); + type::MatrixType* mat4x4() const { + return mod_->create(Of(), 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(subtype, n); + type::ArrayType* array(type::Type* subtype, uint32_t n) const { + return mod_->create(subtype, n); } /// @return the tint AST type for an array of size `N` of type `T` template - ast::type::ArrayType* array() const { + type::ArrayType* array() const { return array(Of(), 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 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(name); + IdentifierExpression* Expr(const std::string& name) { + return create(name); } /// @param name the identifier name /// @return an IdentifierExpression with the given name - ast::IdentifierExpression* Expr(const char* name) { - return create(name); + IdentifierExpression* Expr(const char* name) { + return create(name); } /// @param value the boolean value /// @return a Scalar constructor for the given value - ast::ScalarConstructorExpression* Expr(bool value) { - return create(Literal(value)); + ScalarConstructorExpression* Expr(bool value) { + return create(Literal(value)); } /// @param value the float value /// @return a Scalar constructor for the given value - ast::ScalarConstructorExpression* Expr(f32 value) { - return create(Literal(value)); + ScalarConstructorExpression* Expr(f32 value) { + return create(Literal(value)); } /// @param value the integer value /// @return a Scalar constructor for the given value - ast::ScalarConstructorExpression* Expr(i32 value) { - return create(Literal(value)); + ScalarConstructorExpression* Expr(i32 value) { + return create(Literal(value)); } /// @param value the unsigned int value /// @return a Scalar constructor for the given value - ast::ScalarConstructorExpression* Expr(u32 value) { - return create(Literal(value)); + ScalarConstructorExpression* Expr(u32 value) { + return create(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 - void Append(ast::ExpressionList& list, ARG&& arg) { + void Append(ExpressionList& list, ARG&& arg) { list.emplace_back(Expr(std::forward(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 - void Append(ast::ExpressionList& list, ARG0&& arg0, ARGS&&... args) { + void Append(ExpressionList& list, ARG0&& arg0, ARGS&&... args) { Append(list, std::forward(arg0)); Append(list, std::forward(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 - ast::ExpressionList ExprList(ARGS&&... args) { - ast::ExpressionList list; + ExpressionList ExprList(ARGS&&... args) { + ExpressionList list; list.reserve(sizeof...(args)); Append(list, std::forward(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(ty.bool_, val); - } + BoolLiteral* Literal(bool val) { return create(ty.bool_, val); } /// @param val the float value /// @return a float literal with the given value - ast::FloatLiteral* Literal(f32 val) { - return create(ty.f32, val); - } + FloatLiteral* Literal(f32 val) { return create(ty.f32, val); } /// @param val the unsigned int value /// @return a UintLiteral with the given value - ast::UintLiteral* Literal(u32 val) { - return create(ty.u32, val); - } + UintLiteral* Literal(u32 val) { return create(ty.u32, val); } /// @param val the integer value /// @return the SintLiteral with the given value - ast::SintLiteral* Literal(i32 val) { - return create(ty.i32, val); - } + SintLiteral* Literal(i32 val) { return create(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 - ast::TypeConstructorExpression* Construct(ARGS&&... args) { - return create( + TypeConstructorExpression* Construct(ARGS&&... args) { + return create( ty.Of(), ExprList(std::forward(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 - ast::TypeConstructorExpression* Construct(ast::type::Type* type, - ARGS&&... args) { - return create( + TypeConstructorExpression* Construct(type::Type* type, ARGS&&... args) { + return create( type, ExprList(std::forward(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 - ast::TypeConstructorExpression* vec2(ARGS&&... args) { - return create( + TypeConstructorExpression* vec2(ARGS&&... args) { + return create( ty.vec2(), ExprList(std::forward(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 - ast::TypeConstructorExpression* vec3(ARGS&&... args) { - return create( + TypeConstructorExpression* vec3(ARGS&&... args) { + return create( ty.vec3(), ExprList(std::forward(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 - ast::TypeConstructorExpression* vec4(ARGS&&... args) { - return create( + TypeConstructorExpression* vec4(ARGS&&... args) { + return create( ty.vec4(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat2x2(ARGS&&... args) { - return create( + TypeConstructorExpression* mat2x2(ARGS&&... args) { + return create( ty.mat2x2(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat2x3(ARGS&&... args) { - return create( + TypeConstructorExpression* mat2x3(ARGS&&... args) { + return create( ty.mat2x3(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat2x4(ARGS&&... args) { - return create( + TypeConstructorExpression* mat2x4(ARGS&&... args) { + return create( ty.mat2x4(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat3x2(ARGS&&... args) { - return create( + TypeConstructorExpression* mat3x2(ARGS&&... args) { + return create( ty.mat3x2(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat3x3(ARGS&&... args) { - return create( + TypeConstructorExpression* mat3x3(ARGS&&... args) { + return create( ty.mat3x3(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat3x4(ARGS&&... args) { - return create( + TypeConstructorExpression* mat3x4(ARGS&&... args) { + return create( ty.mat3x4(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat4x2(ARGS&&... args) { - return create( + TypeConstructorExpression* mat4x2(ARGS&&... args) { + return create( ty.mat4x2(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat4x3(ARGS&&... args) { - return create( + TypeConstructorExpression* mat4x3(ARGS&&... args) { + return create( ty.mat4x3(), ExprList(std::forward(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 - ast::TypeConstructorExpression* mat4x4(ARGS&&... args) { - return create( + TypeConstructorExpression* mat4x4(ARGS&&... args) { + return create( ty.mat4x4(), ExprList(std::forward(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 - ast::TypeConstructorExpression* array(ARGS&&... args) { - return create( + TypeConstructorExpression* array(ARGS&&... args) { + return create( ty.array(), ExprList(std::forward(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 - ast::CallExpression Call(const std::string& func, ARGS&&... args) { - return ast::CallExpression{Expr(func), - ExprList(std::forward(args)...)}; + CallExpression Call(const std::string& func, ARGS&&... args) { + return CallExpression{Expr(func), ExprList(std::forward(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 @@ -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 { - 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 { - 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 { - 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 { - 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 { - static ast::type::Type* get(const TypesBuilder* t) { return t->void_; } + static type::Type* get(const TypesBuilder* t) { return t->void_; } }; //! @endcond diff --git a/src/ast/call_expression_test.cc b/src/ast/call_expression_test.cc index 0da64ec59c..0d309533d3 100644 --- a/src/ast/call_expression_test.cc +++ b/src/ast/call_expression_test.cc @@ -49,7 +49,7 @@ TEST_F(CallExpressionTest, Creation_WithSource) { TEST_F(CallExpressionTest, IsCall) { auto* func = create("func"); CallExpression stmt(func, {}); - EXPECT_TRUE(stmt.Is()); + EXPECT_TRUE(stmt.Is()); } TEST_F(CallExpressionTest, IsValid) { diff --git a/src/ast/call_statement_test.cc b/src/ast/call_statement_test.cc index 528ecc10e7..4a6a5fec2c 100644 --- a/src/ast/call_statement_test.cc +++ b/src/ast/call_statement_test.cc @@ -25,8 +25,8 @@ namespace { using CallStatementTest = TestHelper; TEST_F(CallStatementTest, Creation) { - auto* expr = create( - create("func"), ExpressionList{}); + auto* expr = create(create("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( - create("func"), ExpressionList{})); + CallStatement c(create(create("func"), + ExpressionList{})); EXPECT_TRUE(c.IsValid()); } @@ -49,13 +49,13 @@ TEST_F(CallStatementTest, IsValid_MissingExpr) { } TEST_F(CallStatementTest, IsValid_InvalidExpr) { - CallStatement c(create()); + CallStatement c(create()); EXPECT_FALSE(c.IsValid()); } TEST_F(CallStatementTest, ToStr) { - CallStatement c(create( - create("func"), ExpressionList{})); + CallStatement c(create(create("func"), + ExpressionList{})); std::ostringstream out; c.to_str(out, 2); diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc index d5c77b64b8..8b6e6d945b 100644 --- a/src/ast/case_statement_test.cc +++ b/src/ast/case_statement_test.cc @@ -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(&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(&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(&i32, 2)); @@ -82,33 +82,33 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) { auto* body = create(); body->append(create()); - CaseStatement c(create()); + CaseStatement c(create()); 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(&i32, 2)); - CaseStatement c(create()); + CaseStatement c(create()); c.set_selectors(b); EXPECT_FALSE(c.IsDefault()); } TEST_F(CaseStatementTest, IsCase) { - CaseStatement c(create()); - EXPECT_TRUE(c.Is()); + CaseStatement c(create()); + EXPECT_TRUE(c.Is()); } TEST_F(CaseStatementTest, IsValid) { - CaseStatement c(create()); + CaseStatement c(create()); EXPECT_TRUE(c.IsValid()); } TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { - ast::type::I32Type i32; + type::I32Type i32; CaseSelectorList b; b.push_back(create(&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(&i32, 2)); auto* body = create(); - body->append(create(nullptr, create())); + body->append(create(nullptr, create())); 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(&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(&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(&i32, 1)); diff --git a/src/ast/decorated_variable_test.cc b/src/ast/decorated_variable_test.cc index 2b41652945..e9c2a523ff 100644 --- a/src/ast/decorated_variable_test.cc +++ b/src/ast/decorated_variable_test.cc @@ -77,7 +77,7 @@ TEST_F(DecoratedVariableTest, WithDecorations) { VariableDecorationList decos; decos.push_back(create(1, Source{})); - decos.push_back(create(ast::Builtin::kPosition, Source{})); + decos.push_back(create(Builtin::kPosition, Source{})); decos.push_back(create(1200, Source{})); dv.set_decorations(decos); @@ -108,7 +108,7 @@ TEST_F(DecoratedVariableTest, IsValid) { TEST_F(DecoratedVariableTest, IsDecorated) { DecoratedVariable dv; - EXPECT_TRUE(dv.Is()); + EXPECT_TRUE(dv.Is()); } TEST_F(DecoratedVariableTest, to_str) { diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index f90d7b54de..2e60b3952b 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -28,7 +28,7 @@ namespace { using ElseStatementTest = TestHelper; TEST_F(ElseStatementTest, Creation) { - ast::type::BoolType bool_type; + type::BoolType bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); @@ -55,7 +55,7 @@ TEST_F(ElseStatementTest, IsElse) { } TEST_F(ElseStatementTest, HasCondition) { - ast::type::BoolType bool_type; + type::BoolType bool_type; auto* cond = create( create(&bool_type, true)); ElseStatement e(cond, create()); @@ -97,14 +97,14 @@ TEST_F(ElseStatementTest, IsValid_InvalidCondition) { TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) { auto* body = create(); - body->append(create(nullptr, create())); + body->append(create(nullptr, create())); ElseStatement e(body); EXPECT_FALSE(e.IsValid()); } TEST_F(ElseStatementTest, ToStr) { - ast::type::BoolType bool_type; + type::BoolType bool_type; auto* cond = create( create(&bool_type, true)); auto* body = create(); diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc index b651b0158e..c6337a4904 100644 --- a/src/ast/expression_test.cc +++ b/src/ast/expression_test.cc @@ -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()); + EXPECT_TRUE(e.result_type()->Is()); } 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()); + EXPECT_TRUE(e.result_type()->Is()); } } // namespace diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index 70ba92e1d1..c781afa64c 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -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; diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h index 411deaaa48..f474c6773a 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -28,7 +28,7 @@ class FloatLiteral : public Castable { /// 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 diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index 568df88e77..ffc93613f1 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -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()); 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()); @@ -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"); } diff --git a/src/ast/function.cc b/src/ast/function.cc index 8c72209d55..b251a7d55c 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -62,13 +62,13 @@ std::tuple 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()) { 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> ret; for (auto* var : referenced_module_variables()) { - if (auto* decos = var->As()) { + if (auto* decos = var->As()) { for (auto* deco : decos->decorations()) { if (auto* location = deco->As()) { ret.push_back({var, location}); @@ -102,17 +102,17 @@ Function::referenced_uniform_variables() const { std::vector> ret; for (auto* var : referenced_module_variables()) { - if (!var->Is() || - var->storage_class() != ast::StorageClass::kUniform) { + if (!var->Is() || + var->storage_class() != StorageClass::kUniform) { continue; } BindingDecoration* binding = nullptr; SetDecoration* set = nullptr; - for (auto* deco : var->As()->decorations()) { - if (auto* b = deco->As()) { + for (auto* deco : var->As()->decorations()) { + if (auto* b = deco->As()) { binding = b; - } else if (auto* s = deco->As()) { + } else if (auto* s = deco->As()) { set = s; } } @@ -130,17 +130,17 @@ Function::referenced_storagebuffer_variables() const { std::vector> ret; for (auto* var : referenced_module_variables()) { - if (!var->Is() || - var->storage_class() != ast::StorageClass::kStorageBuffer) { + if (!var->Is() || + var->storage_class() != StorageClass::kStorageBuffer) { continue; } BindingDecoration* binding = nullptr; SetDecoration* set = nullptr; - for (auto* deco : var->As()->decorations()) { - if (auto* b = deco->As()) { + for (auto* deco : var->As()->decorations()) { + if (auto* b = deco->As()) { binding = b; - } else if (auto* s = deco->As()) { + } else if (auto* s = deco->As()) { set = s; } } @@ -158,10 +158,10 @@ Function::referenced_builtin_variables() const { std::vector> ret; for (auto* var : referenced_module_variables()) { - if (!var->Is()) { + if (!var->Is()) { continue; } - for (auto* deco : var->As()->decorations()) { + for (auto* deco : var->As()->decorations()) { if (auto* builtin = deco->As()) { 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() || - !unwrapped_type->Is() || - unwrapped_type->As()->kind() != kind) { + if (!var->Is() || + !unwrapped_type->Is() || + unwrapped_type->As()->kind() != kind) { continue; } BindingDecoration* binding = nullptr; SetDecoration* set = nullptr; - for (auto* deco : var->As()->decorations()) { - if (auto* b = deco->As()) { + for (auto* deco : var->As()->decorations()) { + if (auto* b = deco->As()) { binding = b; - } else if (auto* s = deco->As()) { + } else if (auto* s = deco->As()) { 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() || - !unwrapped_type->Is()) { + if (!var->Is() || + !unwrapped_type->Is()) { continue; } if ((multisampled && - !unwrapped_type->Is()) || - (!multisampled && - !unwrapped_type->Is())) { + !unwrapped_type->Is()) || + (!multisampled && !unwrapped_type->Is())) { continue; } BindingDecoration* binding = nullptr; SetDecoration* set = nullptr; - for (auto* deco : var->As()->decorations()) { - if (auto* b = deco->As()) { + for (auto* deco : var->As()->decorations()) { + if (auto* b = deco->As()) { binding = b; - } else if (auto* s = deco->As()) { + } else if (auto* s = deco->As()) { set = s; } } diff --git a/src/ast/function.h b/src/ast/function.h index acaf30cbd3..f539224eed 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -91,7 +91,7 @@ class Function : public Castable { /// 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 { std::tuple 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. diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index a305c96b1c..d94f9284f9 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -40,7 +40,7 @@ TEST_F(FunctionTest, Creation) { params.push_back(create("var", StorageClass::kNone, &i32)); auto* var = params[0]; - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); 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("var", StorageClass::kNone, &i32)); Function f(Source{Source::Location{20, 2}}, "func", params, &void_type, - create()); + create()); 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()); + Function f("func", VariableList{}, &void_type, create()); 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("loc1", StorageClass::kInput, &i32)); - loc1.set_decorations({create(0, Source{})}); + DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); + loc1.set_decorations({create(0, Source{})}); - DecoratedVariable loc2( - create("loc2", StorageClass::kInput, &i32)); - loc2.set_decorations({create(1, Source{})}); + DecoratedVariable loc2(create("loc2", StorageClass::kInput, &i32)); + loc2.set_decorations({create(1, Source{})}); DecoratedVariable builtin1( - create("builtin1", StorageClass::kInput, &i32)); + create("builtin1", StorageClass::kInput, &i32)); builtin1.set_decorations( - {create(ast::Builtin::kPosition, Source{})}); + {create(Builtin::kPosition, Source{})}); DecoratedVariable builtin2( - create("builtin2", StorageClass::kInput, &i32)); + create("builtin2", StorageClass::kInput, &i32)); builtin2.set_decorations( - {create(ast::Builtin::kFragDepth, Source{})}); + {create(Builtin::kFragDepth, Source{})}); - Function f("func", VariableList{}, &void_type, create()); + Function f("func", VariableList{}, &void_type, create()); 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("loc1", StorageClass::kInput, &i32)); - loc1.set_decorations({create(0, Source{})}); + DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); + loc1.set_decorations({create(0, Source{})}); - DecoratedVariable loc2( - create("loc2", StorageClass::kInput, &i32)); - loc2.set_decorations({create(1, Source{})}); + DecoratedVariable loc2(create("loc2", StorageClass::kInput, &i32)); + loc2.set_decorations({create(1, Source{})}); DecoratedVariable builtin1( - create("builtin1", StorageClass::kInput, &i32)); + create("builtin1", StorageClass::kInput, &i32)); builtin1.set_decorations( - {create(ast::Builtin::kPosition, Source{})}); + {create(Builtin::kPosition, Source{})}); DecoratedVariable builtin2( - create("builtin2", StorageClass::kInput, &i32)); + create("builtin2", StorageClass::kInput, &i32)); builtin2.set_decorations( - {create(ast::Builtin::kFragDepth, Source{})}); + {create(Builtin::kFragDepth, Source{})}); - Function f("func", VariableList{}, &void_type, create()); + Function f("func", VariableList{}, &void_type, create()); 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()); + type::VoidType void_type; + Function f("func", VariableList{}, &void_type, create()); 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("var", StorageClass::kNone, &i32)); - auto* block = create(); + auto* block = create(); block->append(create()); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); f.set_body(block); EXPECT_TRUE(f.IsValid()); } @@ -192,7 +188,7 @@ TEST_F(FunctionTest, IsValid_EmptyName) { VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); - Function f("", params, &void_type, create()); + Function f("", params, &void_type, create()); EXPECT_FALSE(f.IsValid()); } @@ -202,7 +198,7 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) { VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); - Function f("func", params, nullptr, create()); + Function f("func", params, nullptr, create()); EXPECT_FALSE(f.IsValid()); } @@ -214,7 +210,7 @@ TEST_F(FunctionTest, IsValid_NullParam) { params.push_back(create("var", StorageClass::kNone, &i32)); params.push_back(nullptr); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); EXPECT_FALSE(f.IsValid()); } @@ -224,7 +220,7 @@ TEST_F(FunctionTest, IsValid_InvalidParam) { VariableList params; params.push_back(create("var", StorageClass::kNone, nullptr)); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); EXPECT_FALSE(f.IsValid()); } @@ -235,11 +231,11 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) { VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); - auto* block = create(); + auto* block = create(); block->append(create()); block->append(nullptr); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); f.set_body(block); EXPECT_FALSE(f.IsValid()); } @@ -251,11 +247,11 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) { VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); - auto* block = create(); + auto* block = create(); block->append(create()); block->append(nullptr); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); 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(); + auto* block = create(); block->append(create()); - Function f("func", {}, &void_type, create()); + Function f("func", {}, &void_type, create()); 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(); + auto* block = create(); block->append(create()); - Function f("func", {}, &void_type, create()); + Function f("func", {}, &void_type, create()); f.set_body(block); f.add_decoration(create(2, 4, 6, Source{})); @@ -309,10 +305,10 @@ TEST_F(FunctionTest, ToStr_WithParams) { VariableList params; params.push_back(create("var", StorageClass::kNone, &i32)); - auto* block = create(); + auto* block = create(); block->append(create()); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); 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()); + Function f("func", {}, &void_type, create()); EXPECT_EQ(f.type_name(), "__func__void"); } @@ -347,7 +343,7 @@ TEST_F(FunctionTest, TypeName_WithParams) { params.push_back(create("var1", StorageClass::kNone, &i32)); params.push_back(create("var2", StorageClass::kNone, &f32)); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); 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(); + auto* body = create(); auto* stmt = create(); body->append(stmt); - Function f("func", params, &void_type, create()); + Function f("func", params, &void_type, create()); 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(); - Function f("func", params, &void_type, create()); + auto* body = create(); + Function f("func", params, &void_type, create()); 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()); + Function f("f", {}, &void_type, create()); 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()); + Function f("f", {}, &void_type, create()); f.add_decoration(create(2u, 4u, 6u, Source{})); uint32_t x = 0; diff --git a/src/ast/identifier_expression_test.cc b/src/ast/identifier_expression_test.cc index 1bef59daba..7ef416e550 100644 --- a/src/ast/identifier_expression_test.cc +++ b/src/ast/identifier_expression_test.cc @@ -38,7 +38,7 @@ TEST_F(IdentifierExpressionTest, Creation_WithSource) { TEST_F(IdentifierExpressionTest, IsIdentifier) { IdentifierExpression i("ident"); - EXPECT_TRUE(i.Is()); + EXPECT_TRUE(i.Is()); } TEST_F(IdentifierExpressionTest, IsValid) { diff --git a/src/ast/int_literal.cc b/src/ast/int_literal.cc index bb86821409..afb8a296f2 100644 --- a/src/ast/int_literal.cc +++ b/src/ast/int_literal.cc @@ -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; diff --git a/src/ast/int_literal.h b/src/ast/int_literal.h index e2f5c66dd5..5cf808d627 100644 --- a/src/ast/int_literal.h +++ b/src/ast/int_literal.h @@ -30,7 +30,7 @@ class IntLiteral : public Castable { protected: /// Constructor /// @param type the type of the literal - explicit IntLiteral(ast::type::Type* type); + explicit IntLiteral(type::Type* type); }; } // namespace ast diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc index f002d491b3..70d399a97b 100644 --- a/src/ast/int_literal_test.cc +++ b/src/ast/int_literal_test.cc @@ -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()); } TEST_F(IntLiteralTest, Uint_IsInt) { - ast::type::I32Type i32; + type::I32Type i32; UintLiteral i{&i32, 42}; EXPECT_TRUE(i.Is()); } diff --git a/src/ast/intrinsic.cc b/src/ast/intrinsic.cc index dc6c60a15c..6ebd412873 100644 --- a/src/ast/intrinsic.cc +++ b/src/ast/intrinsic.cc @@ -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 || diff --git a/src/ast/intrinsic.h b/src/ast/intrinsic.h index a122ad30c8..24650c24a2 100644 --- a/src/ast/intrinsic.h +++ b/src/ast/intrinsic.h @@ -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 diff --git a/src/ast/intrinsic_texture_helper_test.cc b/src/ast/intrinsic_texture_helper_test.cc index b1bd426f3e..9cb615017f 100644 --- a/src/ast/intrinsic_texture_helper_test.cc +++ b/src/ast/intrinsic_texture_helper_test.cc @@ -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 a) + std::function a) : overload(o), description(d), texture_kind(tk), @@ -49,11 +49,11 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : f32) -> vec4", 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::ValidCases() { " coords : f32,\n" " array_index : u32) -> vec4", 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::ValidCases() { " s : sampler,\n" " coords : vec2) -> vec4", 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(1.f, 2.f)); // coords @@ -101,13 +101,13 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -121,12 +121,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " array_index : u32) -> vec4", 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(1.f, 2.f), // coords @@ -141,13 +141,13 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -161,12 +161,12 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> vec4", 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(1.f, 2.f, 3.f)); // coords @@ -179,13 +179,13 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3\n" " offset : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -198,12 +198,12 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> vec4", 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(1.f, 2.f, 3.f)); // coords @@ -216,12 +216,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " array_index : u32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -234,12 +234,12 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec2) -> 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(1.f, 2.f)); // coords @@ -252,13 +252,13 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -272,12 +272,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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(1.f, 2.f), // coords @@ -292,13 +292,13 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -312,12 +312,12 @@ std::vector TextureOverloadCase::ValidCases() { " s : sampler,\n" " coords : vec3) -> 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(1.f, 2.f, 3.f)); // coords @@ -330,12 +330,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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(1.f, 2.f, 3.f), // coords @@ -349,12 +349,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " bias : f32) -> vec4", 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(1.f, 2.f), // coords @@ -369,13 +369,13 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -391,12 +391,12 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32,\n" " bias : f32) -> vec4", 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(1.f, 2.f), // coords @@ -413,13 +413,13 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -435,12 +435,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " bias : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -455,13 +455,13 @@ std::vector TextureOverloadCase::ValidCases() { " bias : f32,\n" " offset : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -476,12 +476,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " bias : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -496,12 +496,12 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32,\n" " bias : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -516,12 +516,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\n" " level : f32) -> vec4", 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(1.f, 2.f), // coords @@ -536,13 +536,13 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -558,12 +558,12 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32,\n" " level : f32) -> vec4", 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(1.f, 2.f), // coords @@ -580,13 +580,13 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -602,12 +602,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -622,13 +622,13 @@ std::vector TextureOverloadCase::ValidCases() { " level : f32,\n" " offset : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -643,12 +643,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\n" " level : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -663,12 +663,12 @@ std::vector TextureOverloadCase::ValidCases() { " array_index : u32,\n" " level : f32) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -683,12 +683,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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(1.f, 2.f), // coords @@ -703,13 +703,13 @@ std::vector TextureOverloadCase::ValidCases() { " level : u32,\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -725,12 +725,12 @@ std::vector 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(1.f, 2.f), // coords @@ -747,13 +747,13 @@ std::vector TextureOverloadCase::ValidCases() { " level : u32,\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -769,12 +769,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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(1.f, 2.f, 3.f), // coords @@ -789,12 +789,12 @@ std::vector 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(1.f, 2.f, 3.f), // coords @@ -810,12 +810,12 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec2,\n" " ddy : vec2) -> vec4", 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(1.0f, 2.0f), // coords @@ -832,13 +832,13 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec2,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -856,12 +856,12 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec2,\n" " ddy : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -880,13 +880,13 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec2,\n" " offset : vec2) -> vec4", 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(1.f, 2.f), // coords @@ -904,12 +904,12 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -926,13 +926,13 @@ std::vector TextureOverloadCase::ValidCases() { " ddy : vec3,\n" " offset : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -949,12 +949,12 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -971,12 +971,12 @@ std::vector TextureOverloadCase::ValidCases() { " ddx : vec3,\n" " ddy : vec3) -> vec4", 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(1.f, 2.f, 3.f), // coords @@ -992,12 +992,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec2,\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(1.f, 2.f), // coords @@ -1012,13 +1012,13 @@ std::vector TextureOverloadCase::ValidCases() { " depth_ref : f32,\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -1034,12 +1034,12 @@ std::vector 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(1.f, 2.f), // coords @@ -1056,13 +1056,13 @@ std::vector TextureOverloadCase::ValidCases() { " depth_ref : f32,\n" " offset : vec2) -> 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(1.f, 2.f), // coords @@ -1078,12 +1078,12 @@ std::vector TextureOverloadCase::ValidCases() { " coords : vec3,\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(1.f, 2.f, 3.f), // coords @@ -1098,12 +1098,12 @@ std::vector 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(1.f, 2.f, 3.f), // coords diff --git a/src/ast/intrinsic_texture_helper_test.h b/src/ast/intrinsic_texture_helper_test.h index 5e7da8aaf8..88bac80720 100644 --- a/src/ast/intrinsic_texture_helper_test.h +++ b/src/ast/intrinsic_texture_helper_test.h @@ -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); + std::function); /// 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 args; + std::function args; }; inline std::ostream& operator<<(std::ostream& out, diff --git a/src/ast/literal.cc b/src/ast/literal.cc index 9b7b892a72..19fa71758e 100644 --- a/src/ast/literal.cc +++ b/src/ast/literal.cc @@ -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; diff --git a/src/ast/literal.h b/src/ast/literal.h index 4e3ff0f63f..947ed38e96 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -29,7 +29,7 @@ class Literal : public Castable { ~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 { 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 diff --git a/src/ast/member_accessor_expression_test.cc b/src/ast/member_accessor_expression_test.cc index ddf5477840..331157fbe4 100644 --- a/src/ast/member_accessor_expression_test.cc +++ b/src/ast/member_accessor_expression_test.cc @@ -46,7 +46,7 @@ TEST_F(MemberAccessorExpressionTest, Creation_WithSource) { TEST_F(MemberAccessorExpressionTest, IsMemberAccessor) { MemberAccessorExpression stmt; - EXPECT_TRUE(stmt.Is()); + EXPECT_TRUE(stmt.Is()); } TEST_F(MemberAccessorExpressionTest, IsValid) { diff --git a/src/ast/module.cc b/src/ast/module.cc index aed71b272d..c11bbd7c1d 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -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()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); if (alias->type() == nullptr) { return false; } - if (alias->type()->Is() && - alias->type()->As()->name().empty()) { + if (alias->type()->Is() && + alias->type()->As()->name().empty()) { return false; } - } else if (ty->Is()) { - auto* str = ty->As(); + } else if (ty->Is()) { + auto* str = ty->As(); 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()) { - auto* alias = ty->As(); + if (ty->Is()) { + auto* alias = ty->As(); out << alias->name() << " -> " << alias->type()->type_name() << std::endl; - if (alias->type()->Is()) { - alias->type()->As()->impl()->to_str(out, indent); + if (alias->type()->Is()) { + alias->type()->As()->impl()->to_str(out, indent); } - } else if (ty->Is()) { - auto* str = ty->As(); + } else if (ty->Is()) { + auto* str = ty->As(); out << str->name() << " "; str->impl()->to_str(out, indent); } diff --git a/src/ast/module.h b/src/ast/module.h index a688cc9df3..ded2225bc2 100644 --- a/src/ast/module.h +++ b/src/ast/module.h @@ -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 - EnableIfIsType* create(ARGS&&... args) { - static_assert(std::is_base_of::value, - "T does not derive from ast::Node"); + EnableIfIsType* create(ARGS&&... args) { + static_assert(std::is_base_of::value, + "T does not derive from Node"); auto uptr = std::make_unique(std::forward(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 - EnableIfIsType* create(ARGS&&... args) { - static_assert(std::is_base_of::value, - "T does not derive from ast::type::Type"); + EnableIfIsType* create(ARGS&&... args) { + static_assert(std::is_base_of::value, + "T does not derive from type::Type"); return type_mgr_.Get(std::forward(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 - EnableIfIsType* unique_type(std::unique_ptr ty) { + EnableIfIsType* unique_type(std::unique_ptr ty) { return static_cast(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>& - types() { + const std::unordered_map>& types() { return type_mgr_.types(); } @@ -143,8 +142,8 @@ class Module { // The constructed types are owned by the type manager std::vector constructed_types_; FunctionList functions_; - std::vector> ast_nodes_; - ast::TypeManager type_mgr_; + std::vector> ast_nodes_; + TypeManager type_mgr_; }; } // namespace ast diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index f52f9d6b06..cf05d4efcd 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -48,8 +48,8 @@ TEST_F(ModuleTest, LookupFunction) { type::F32Type f32; Module m; - auto* func = create("main", VariableList{}, &f32, - create()); + auto* func = + create("main", VariableList{}, &f32, create()); 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("main", VariableList(), &f32, - create()); + auto* func = + create("main", VariableList(), &f32, create()); Module m; m.AddFunction(func); diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc index 54b9344a32..eb3d58942d 100644 --- a/src/ast/null_literal.cc +++ b/src/ast/null_literal.cc @@ -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; diff --git a/src/ast/null_literal.h b/src/ast/null_literal.h index 93b5f895b7..7cffcadd0b 100644 --- a/src/ast/null_literal.h +++ b/src/ast/null_literal.h @@ -27,7 +27,7 @@ class NullLiteral : public Castable { 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. diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc index d45b3e2bc8..8c151ee8b2 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -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()); @@ -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()); } diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index 61f1bd269e..d7184c6de3 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -25,14 +25,14 @@ namespace { using ScalarConstructorExpressionTest = TestHelper; TEST_F(ScalarConstructorExpressionTest, Creation) { - ast::type::BoolType bool_type; + type::BoolType bool_type; auto* b = create(&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(&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(&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(&bool_type, true); ScalarConstructorExpression c(b); std::ostringstream out; diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc index ab44c210f1..c94e7c9879 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -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; diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index 90e78c3c51..dd56fb35c2 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -28,7 +28,7 @@ class SintLiteral : public Castable { /// 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 diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index cc49ce6178..7a8972fadd 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -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()); 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()); @@ -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()); } diff --git a/src/ast/stage_decoration.cc b/src/ast/stage_decoration.cc index 4469c01178..af9676e5b6 100644 --- a/src/ast/stage_decoration.cc +++ b/src/ast/stage_decoration.cc @@ -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; diff --git a/src/ast/stage_decoration.h b/src/ast/stage_decoration.h index e70e94a898..1ae33727fb 100644 --- a/src/ast/stage_decoration.h +++ b/src/ast/stage_decoration.h @@ -27,11 +27,11 @@ class StageDecoration : public Castable { /// 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 { void to_str(std::ostream& out, size_t indent) const override; private: - ast::PipelineStage stage_ = ast::PipelineStage::kNone; + PipelineStage stage_ = PipelineStage::kNone; }; } // namespace ast diff --git a/src/ast/stage_decoration_test.cc b/src/ast/stage_decoration_test.cc index 83acb5b191..4bfdad94b7 100644 --- a/src/ast/stage_decoration_test.cc +++ b/src/ast/stage_decoration_test.cc @@ -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()); EXPECT_TRUE(d->Is()); } 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} diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc index ea5223ce36..0905557c7c 100644 --- a/src/ast/struct_member.cc +++ b/src/ast/struct_member.cc @@ -41,7 +41,7 @@ StructMember::~StructMember() = default; bool StructMember::has_offset_decoration() const { for (auto* deco : decorations_) { - if (deco->Is()) { + if (deco->Is()) { 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()) { + if (auto* offset = deco->As()) { return offset->offset(); } } diff --git a/src/ast/struct_member_offset_decoration_test.cc b/src/ast/struct_member_offset_decoration_test.cc index 51fab732fe..2197f03f73 100644 --- a/src/ast/struct_member_offset_decoration_test.cc +++ b/src/ast/struct_member_offset_decoration_test.cc @@ -29,7 +29,7 @@ TEST_F(StructMemberOffsetDecorationTest, Creation) { TEST_F(StructMemberOffsetDecorationTest, Is) { StructMemberOffsetDecoration d{2, Source{}}; - EXPECT_TRUE(d.Is()); + EXPECT_TRUE(d.Is()); } } // namespace diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc index 729c11afb4..18a71eb5c3 100644 --- a/src/ast/struct_member_test.cc +++ b/src/ast/struct_member_test.cc @@ -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()); + EXPECT_TRUE(st.decorations()[0]->Is()); EXPECT_EQ(st.source().range.begin.line, 0u); EXPECT_EQ(st.source().range.begin.column, 0u); EXPECT_EQ(st.source().range.end.line, 0u); diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index eadc87cc86..7627a0bbfd 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -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(&i32, 1)); auto* ident = create("ident"); CaseStatementList body; - auto* case_stmt = create(lit, create()); + auto* case_stmt = create(lit, create()); 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(&i32, 2)); auto* ident = create("ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back(create(lit, create())); 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(&i32, 2)); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back(create(lit, create())); 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(&i32, 2)); auto* ident = create(""); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back(create(lit, create())); 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(&i32, 2)); auto* ident = create("ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back(create(lit, create())); 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("ident"); - auto* case_body = create(); + auto* case_body = create(); 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(&i32, 2)); auto* ident = create("ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back(create(lit, create())); SwitchStatement stmt(ident, body); std::ostringstream out; diff --git a/src/ast/test_helper.h b/src/ast/test_helper.h index 18ad0cfc5d..bb558e2652 100644 --- a/src/ast/test_helper.h +++ b/src/ast/test_helper.h @@ -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 diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc index 9a9bacc2e7..ded04fbb70 100644 --- a/src/ast/type/access_control_type_test.cc +++ b/src/ast/type/access_control_type_test.cc @@ -136,9 +136,9 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) { deco.push_back(create(4, Source{})); members.push_back(create("bar", &u32, deco)); - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(4, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(decos, members); StructType struct_type("struct_type", str); AccessControlType at{AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc index 2a2d35b0b6..e2e5c6a342 100644 --- a/src/ast/type/alias_type_test.cc +++ b/src/ast/type/alias_type_test.cc @@ -201,9 +201,9 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) { deco.push_back(create(4, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(4, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(decos, members); StructType struct_type("struct_type", str); AliasType alias{"alias", &struct_type}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); diff --git a/src/ast/type/array_type.cc b/src/ast/type/array_type.cc index d46fcc58c2..2b4bb8006c 100644 --- a/src/ast/type/array_type.cc +++ b/src/ast/type/array_type.cc @@ -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()) { + if (auto* stride = deco->As()) { 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()) { + if (deco->Is()) { return true; } } diff --git a/src/ast/type/array_type.h b/src/ast/type/array_type.h index 5341bf5e15..c44393b341 100644 --- a/src/ast/type/array_type.h +++ b/src/ast/type/array_type.h @@ -57,9 +57,7 @@ class ArrayType : public Castable { /// 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 { private: Type* subtype_ = nullptr; uint32_t size_ = 0; - ast::ArrayDecorationList decos_; + ArrayDecorationList decos_; }; } // namespace type diff --git a/src/ast/type/storage_texture_type_test.cc b/src/ast/type/storage_texture_type_test.cc index 0f290999cf..2664f1d830 100644 --- a/src/ast/type/storage_texture_type_test.cc +++ b/src/ast/type/storage_texture_type_test.cc @@ -93,7 +93,7 @@ TEST_F(StorageTextureTypeTest, TypeName) { TEST_F(StorageTextureTypeTest, F32Type) { Context ctx; - ast::Module mod; + Module mod; Type* s = mod.create(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(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(TextureDimension::k2dArray, AccessControl::kReadOnly, ImageFormat::kRgba32Sint); diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc index d0ba1e806e..1f5587e2d2 100644 --- a/src/ast/type/struct_type_test.cc +++ b/src/ast/type/struct_type_test.cc @@ -85,9 +85,9 @@ TEST_F(StructTypeTest, MinBufferBindingSize) { deco.push_back(create(4, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(8, Source{})); members.push_back(create("bar", &arr, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(8, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec2, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec3, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec4, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(4, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(8, Source{})); members.push_back(create("bar", &arr, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(8, Source{})); members.push_back(create("bar", &u32, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec2, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec3, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(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(0, Source{})); members.push_back(create("foo", &vec4, deco)); } - ast::StructDecorationList decos; + StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(decos, members); StructType struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc index 24eb0e62d6..517b109226 100644 --- a/src/ast/type_constructor_expression_test.cc +++ b/src/ast/type_constructor_expression_test.cc @@ -53,7 +53,7 @@ TEST_F(TypeConstructorExpressionTest, Creation_WithSource) { TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) { TypeConstructorExpression t; - EXPECT_TRUE(t.Is()); + EXPECT_TRUE(t.Is()); } TEST_F(TypeConstructorExpressionTest, IsValid) { diff --git a/src/ast/type_manager.cc b/src/ast/type_manager.cc index bd841ef8db..3369692518 100644 --- a/src/ast/type_manager.cc +++ b/src/ast/type_manager.cc @@ -27,7 +27,7 @@ void TypeManager::Reset() { types_.clear(); } -ast::type::Type* TypeManager::Get(std::unique_ptr type) { +type::Type* TypeManager::Get(std::unique_ptr type) { auto name = type->type_name(); if (types_.find(name) == types_.end()) { diff --git a/src/ast/type_manager.h b/src/ast/type_manager.h index c9ca90f941..f580c1a618 100644 --- a/src/ast/type_manager.h +++ b/src/ast/type_manager.h @@ -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 type); + type::Type* Get(std::unique_ptr 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>& - types() { + const std::unordered_map>& types() { return types_; } private: - std::unordered_map> types_; + std::unordered_map> types_; }; } // namespace ast diff --git a/src/ast/type_manager_test.cc b/src/ast/type_manager_test.cc index 3d844d10b9..adced4bfc7 100644 --- a/src/ast/type_manager_test.cc +++ b/src/ast/type_manager_test.cc @@ -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()); + TypeManager tm; + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); } TEST_F(TypeManagerTest, GetSameTypeReturnsSamePtr) { - ast::TypeManager tm; - auto* t = tm.Get(std::make_unique()); + TypeManager tm; + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); EXPECT_EQ(t, t2); } TEST_F(TypeManagerTest, GetDifferentTypeReturnsDifferentPtr) { - ast::TypeManager tm; - auto* t = tm.Get(std::make_unique()); + TypeManager tm; + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); - EXPECT_TRUE(t->Is()); + EXPECT_TRUE(t->Is()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); ASSERT_NE(t2, nullptr); EXPECT_NE(t, t2); - EXPECT_TRUE(t2->Is()); + EXPECT_TRUE(t2->Is()); } TEST_F(TypeManagerTest, ResetClearsPreviousData) { - ast::TypeManager tm; - auto* t = tm.Get(std::make_unique()); + TypeManager tm; + auto* t = tm.Get(std::make_unique()); ASSERT_NE(t, nullptr); EXPECT_FALSE(tm.types().empty()); tm.Reset(); EXPECT_TRUE(tm.types().empty()); - auto* t2 = tm.Get(std::make_unique()); + auto* t2 = tm.Get(std::make_unique()); ASSERT_NE(t2, nullptr); } } // namespace +} // namespace ast } // namespace tint diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc index 201f17d91a..32bd0edcd1 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -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; diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h index 56936eec81..33b7faac57 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -28,7 +28,7 @@ class UintLiteral : public Castable { /// 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 diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index b066bcae41..218c64f2fe 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -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()); 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()); @@ -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"); diff --git a/src/ast/unary_op_expression_test.cc b/src/ast/unary_op_expression_test.cc index 3717a27162..ea6e516286 100644 --- a/src/ast/unary_op_expression_test.cc +++ b/src/ast/unary_op_expression_test.cc @@ -43,7 +43,7 @@ TEST_F(UnaryOpExpressionTest, Creation_WithSource) { TEST_F(UnaryOpExpressionTest, IsUnaryOp) { UnaryOpExpression u; - EXPECT_TRUE(u.Is()); + EXPECT_TRUE(u.Is()); } TEST_F(UnaryOpExpressionTest, IsValid) {