diff --git a/BUILD.gn b/BUILD.gn index 2ba732581a..5407a7e6e1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -378,6 +378,8 @@ source_set("libtint_core_src") { "src/reader/reader.cc", "src/reader/reader.h", "src/scope_stack.h", + "src/semantic/info.h", + "src/semantic/sem_info.cc", "src/source.cc", "src/source.h", "src/symbol.cc", @@ -778,7 +780,6 @@ source_set("tint_unittests_core_src") { "src/ast/decoration_test.cc", "src/ast/discard_statement_test.cc", "src/ast/else_statement_test.cc", - "src/ast/expression_test.cc", "src/ast/fallthrough_statement_test.cc", "src/ast/float_literal_test.cc", "src/ast/function_test.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7000c712b1..207fe4af28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,8 @@ set(TINT_LIB_SRCS reader/reader.cc reader/reader.h scope_stack.h + semantic/info.h + semantic/sem_info.cc source.cc source.h symbol.cc @@ -408,7 +410,6 @@ if(${TINT_BUILD_TESTS}) ast/decoration_test.cc ast/discard_statement_test.cc ast/else_statement_test.cc - ast/expression_test.cc ast/fallthrough_statement_test.cc ast/float_literal_test.cc ast/function_test.cc diff --git a/src/ast/access_decoration.cc b/src/ast/access_decoration.cc index c53516056e..976ffe266f 100644 --- a/src/ast/access_decoration.cc +++ b/src/ast/access_decoration.cc @@ -27,7 +27,9 @@ AccessDecoration::AccessDecoration(const Source& source, AccessControl val) AccessDecoration::~AccessDecoration() = default; -void AccessDecoration::to_str(std::ostream& out, size_t indent) const { +void AccessDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "AccessDecoration{" << value_ << "}" << std::endl; } diff --git a/src/ast/access_decoration.h b/src/ast/access_decoration.h index e58c13a228..2a50e2c2c2 100644 --- a/src/ast/access_decoration.h +++ b/src/ast/access_decoration.h @@ -36,9 +36,12 @@ class AccessDecoration : public Castable { AccessControl value() const { return value_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/access_decoration_test.cc b/src/ast/access_decoration_test.cc index 55295fcebc..e48fe71ced 100644 --- a/src/ast/access_decoration_test.cc +++ b/src/ast/access_decoration_test.cc @@ -37,7 +37,7 @@ TEST_F(AccessDecorationTest, Is) { TEST_F(AccessDecorationTest, ToStr) { auto* d = create(ast::AccessControl::kReadOnly); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(AccessDecoration{read_only} )"); } diff --git a/src/ast/array_accessor_expression.cc b/src/ast/array_accessor_expression.cc index be763db1fd..b8855b081b 100644 --- a/src/ast/array_accessor_expression.cc +++ b/src/ast/array_accessor_expression.cc @@ -47,11 +47,13 @@ bool ArrayAccessorExpression::IsValid() const { return true; } -void ArrayAccessorExpression::to_str(std::ostream& out, size_t indent) const { +void ArrayAccessorExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "ArrayAccessor[" << result_type_str() << "]{" << std::endl; - array_->to_str(out, indent + 2); - idx_expr_->to_str(out, indent + 2); + out << "ArrayAccessor[" << result_type_str(sem) << "]{" << std::endl; + array_->to_str(sem, out, indent + 2); + idx_expr_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/array_accessor_expression.h b/src/ast/array_accessor_expression.h index ebcf9c63c0..32911b2fc1 100644 --- a/src/ast/array_accessor_expression.h +++ b/src/ast/array_accessor_expression.h @@ -57,9 +57,12 @@ class ArrayAccessorExpression bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: ArrayAccessorExpression(const ArrayAccessorExpression&) = delete; diff --git a/src/ast/array_accessor_expression_test.cc b/src/ast/array_accessor_expression_test.cc index be29266afb..b86266b4e7 100644 --- a/src/ast/array_accessor_expression_test.cc +++ b/src/ast/array_accessor_expression_test.cc @@ -93,7 +93,7 @@ TEST_F(ArrayAccessorExpressionTest, ToStr) { auto* exp = create(ary, idx); std::ostringstream out; - exp->to_str(out, 2); + exp->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( ArrayAccessor[not set]{ Identifier[not set]{ary} diff --git a/src/ast/assignment_statement.cc b/src/ast/assignment_statement.cc index a92c6e3c28..aec1d6457a 100644 --- a/src/ast/assignment_statement.cc +++ b/src/ast/assignment_statement.cc @@ -45,11 +45,13 @@ bool AssignmentStatement::IsValid() const { return true; } -void AssignmentStatement::to_str(std::ostream& out, size_t indent) const { +void AssignmentStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Assignment{" << std::endl; - lhs_->to_str(out, indent + 2); - rhs_->to_str(out, indent + 2); + lhs_->to_str(sem, out, indent + 2); + rhs_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/assignment_statement.h b/src/ast/assignment_statement.h index 01b5ac5265..294b8e1ee2 100644 --- a/src/ast/assignment_statement.h +++ b/src/ast/assignment_statement.h @@ -54,9 +54,12 @@ class AssignmentStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: AssignmentStatement(const AssignmentStatement&) = delete; diff --git a/src/ast/assignment_statement_test.cc b/src/ast/assignment_statement_test.cc index 2d7055d65f..cbf1813f7e 100644 --- a/src/ast/assignment_statement_test.cc +++ b/src/ast/assignment_statement_test.cc @@ -93,7 +93,7 @@ TEST_F(AssignmentStatementTest, ToStr) { auto* stmt = create(lhs, rhs); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Assignment{ Identifier[not set]{lhs} diff --git a/src/ast/binary_expression.cc b/src/ast/binary_expression.cc index 5c59cbd463..c1fc0d6bca 100644 --- a/src/ast/binary_expression.cc +++ b/src/ast/binary_expression.cc @@ -47,15 +47,17 @@ bool BinaryExpression::IsValid() const { return op_ != BinaryOp::kNone; } -void BinaryExpression::to_str(std::ostream& out, size_t indent) const { +void BinaryExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "Binary[" << result_type_str() << "]{" << std::endl; - lhs_->to_str(out, indent + 2); + out << "Binary[" << result_type_str(sem) << "]{" << std::endl; + lhs_->to_str(sem, out, indent + 2); make_indent(out, indent + 2); out << op_ << std::endl; - rhs_->to_str(out, indent + 2); + rhs_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/binary_expression.h b/src/ast/binary_expression.h index 9bce5489e5..71a18599ff 100644 --- a/src/ast/binary_expression.h +++ b/src/ast/binary_expression.h @@ -120,9 +120,12 @@ class BinaryExpression : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: BinaryExpression(const BinaryExpression&) = delete; diff --git a/src/ast/binary_expression_test.cc b/src/ast/binary_expression_test.cc index 432bc45fc2..5a8f7bf237 100644 --- a/src/ast/binary_expression_test.cc +++ b/src/ast/binary_expression_test.cc @@ -106,7 +106,7 @@ TEST_F(BinaryExpressionTest, ToStr) { auto* r = create(BinaryOp::kEqual, lhs, rhs); std::ostringstream out; - r->to_str(out, 2); + r->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Binary[not set]{ Identifier[not set]{lhs} equal diff --git a/src/ast/binding_decoration.cc b/src/ast/binding_decoration.cc index 10a6bffd1b..a8714dcfa5 100644 --- a/src/ast/binding_decoration.cc +++ b/src/ast/binding_decoration.cc @@ -27,7 +27,9 @@ BindingDecoration::BindingDecoration(const Source& source, uint32_t val) BindingDecoration::~BindingDecoration() = default; -void BindingDecoration::to_str(std::ostream& out, size_t indent) const { +void BindingDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "BindingDecoration{" << value_ << "}" << std::endl; } diff --git a/src/ast/binding_decoration.h b/src/ast/binding_decoration.h index e4d73e3698..6f9f2bbdeb 100644 --- a/src/ast/binding_decoration.h +++ b/src/ast/binding_decoration.h @@ -36,9 +36,12 @@ class BindingDecoration uint32_t value() const { return value_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/binding_decoration_test.cc b/src/ast/binding_decoration_test.cc index ddeff33f80..a50a0481e5 100644 --- a/src/ast/binding_decoration_test.cc +++ b/src/ast/binding_decoration_test.cc @@ -40,7 +40,7 @@ TEST_F(BindingDecorationTest, Is) { TEST_F(BindingDecorationTest, ToStr) { auto* d = create(2); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(BindingDecoration{2} )"); } diff --git a/src/ast/bitcast_expression.cc b/src/ast/bitcast_expression.cc index 26e52307da..df2811910a 100644 --- a/src/ast/bitcast_expression.cc +++ b/src/ast/bitcast_expression.cc @@ -41,11 +41,13 @@ bool BitcastExpression::IsValid() const { return type_ != nullptr; } -void BitcastExpression::to_str(std::ostream& out, size_t indent) const { +void BitcastExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "Bitcast[" << result_type_str() << "]<" << type_->type_name() << ">{" - << std::endl; - expr_->to_str(out, indent + 2); + out << "Bitcast[" << result_type_str(sem) << "]<" << type_->type_name() + << ">{" << std::endl; + expr_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/bitcast_expression.h b/src/ast/bitcast_expression.h index d1376f2e76..734be10cc8 100644 --- a/src/ast/bitcast_expression.h +++ b/src/ast/bitcast_expression.h @@ -54,9 +54,12 @@ class BitcastExpression : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: BitcastExpression(const BitcastExpression&) = delete; diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc index 56e2568b69..2dce4b9685 100644 --- a/src/ast/bitcast_expression_test.cc +++ b/src/ast/bitcast_expression_test.cc @@ -79,7 +79,7 @@ TEST_F(BitcastExpressionTest, ToStr) { auto* exp = create(ty.f32(), expr); std::ostringstream out; - exp->to_str(out, 2); + exp->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Bitcast[not set]<__f32>{ Identifier[not set]{expr} diff --git a/src/ast/block_statement.cc b/src/ast/block_statement.cc index 07ff30f217..6e4b3f2dc3 100644 --- a/src/ast/block_statement.cc +++ b/src/ast/block_statement.cc @@ -44,12 +44,14 @@ bool BlockStatement::IsValid() const { return true; } -void BlockStatement::to_str(std::ostream& out, size_t indent) const { +void BlockStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Block{" << std::endl; for (auto* stmt : *this) { - stmt->to_str(out, indent + 2); + stmt->to_str(sem, out, indent + 2); } make_indent(out, indent); diff --git a/src/ast/block_statement.h b/src/ast/block_statement.h index 08e4b066bf..2af2cf6ebe 100644 --- a/src/ast/block_statement.h +++ b/src/ast/block_statement.h @@ -76,9 +76,12 @@ class BlockStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: BlockStatement(const BlockStatement&) = delete; diff --git a/src/ast/block_statement_test.cc b/src/ast/block_statement_test.cc index 02c536ef61..5290be8cc2 100644 --- a/src/ast/block_statement_test.cc +++ b/src/ast/block_statement_test.cc @@ -87,7 +87,7 @@ TEST_F(BlockStatementTest, ToStr) { }); std::ostringstream out; - b->to_str(out, 2); + b->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Block{ Discard{} } diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc index e162d1cf87..9a9f180024 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -27,7 +27,7 @@ BoolLiteral::BoolLiteral(const Source& source, type::Type* type, bool value) BoolLiteral::~BoolLiteral() = default; -std::string BoolLiteral::to_str() const { +std::string BoolLiteral::to_str(const semantic::Info&) const { return value_ ? "true" : "false"; } diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h index 2896913d33..05eb137235 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -40,8 +40,9 @@ class BoolLiteral : public Castable { /// @returns the name for this literal. This name is unique to this value. std::string name() const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - std::string to_str() const override; + std::string to_str(const semantic::Info& sem) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index e07e66ea89..01c6eac5be 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -59,8 +59,8 @@ TEST_F(BoolLiteralTest, ToStr) { auto* t = create(&bool_type, true); auto* f = create(&bool_type, false); - EXPECT_EQ(t->to_str(), "true"); - EXPECT_EQ(f->to_str(), "false"); + EXPECT_EQ(t->to_str(Sem()), "true"); + EXPECT_EQ(f->to_str(Sem()), "false"); } } // namespace diff --git a/src/ast/break_statement.cc b/src/ast/break_statement.cc index 6bf034c3a5..15a8e1c1bd 100644 --- a/src/ast/break_statement.cc +++ b/src/ast/break_statement.cc @@ -36,7 +36,9 @@ bool BreakStatement::IsValid() const { return true; } -void BreakStatement::to_str(std::ostream& out, size_t indent) const { +void BreakStatement::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Break{}" << std::endl; } diff --git a/src/ast/break_statement.h b/src/ast/break_statement.h index 7c9bd917a2..23f50e5057 100644 --- a/src/ast/break_statement.h +++ b/src/ast/break_statement.h @@ -42,9 +42,12 @@ class BreakStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: BreakStatement(const BreakStatement&) = delete; diff --git a/src/ast/break_statement_test.cc b/src/ast/break_statement_test.cc index 10063a4648..ffad482acb 100644 --- a/src/ast/break_statement_test.cc +++ b/src/ast/break_statement_test.cc @@ -42,7 +42,7 @@ TEST_F(BreakStatementTest, IsValid) { TEST_F(BreakStatementTest, ToStr) { auto* stmt = create(); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Break{} )"); } diff --git a/src/ast/builtin_decoration.cc b/src/ast/builtin_decoration.cc index 1c33150bc1..e275752946 100644 --- a/src/ast/builtin_decoration.cc +++ b/src/ast/builtin_decoration.cc @@ -27,7 +27,9 @@ BuiltinDecoration::BuiltinDecoration(const Source& source, Builtin builtin) BuiltinDecoration::~BuiltinDecoration() = default; -void BuiltinDecoration::to_str(std::ostream& out, size_t indent) const { +void BuiltinDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "BuiltinDecoration{" << builtin_ << "}" << std::endl; } diff --git a/src/ast/builtin_decoration.h b/src/ast/builtin_decoration.h index 7c437d50e4..cbe700e7ca 100644 --- a/src/ast/builtin_decoration.h +++ b/src/ast/builtin_decoration.h @@ -35,9 +35,12 @@ class BuiltinDecoration Builtin value() const { return builtin_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/builtin_decoration_test.cc b/src/ast/builtin_decoration_test.cc index df10ec7313..b115425d47 100644 --- a/src/ast/builtin_decoration_test.cc +++ b/src/ast/builtin_decoration_test.cc @@ -40,7 +40,7 @@ TEST_F(BuiltinDecorationTest, Is) { TEST_F(BuiltinDecorationTest, ToStr) { auto* d = create(Builtin::kFragDepth); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(BuiltinDecoration{frag_depth} )"); } diff --git a/src/ast/call_expression.cc b/src/ast/call_expression.cc index 674350ac7b..a54f9a7e37 100644 --- a/src/ast/call_expression.cc +++ b/src/ast/call_expression.cc @@ -48,15 +48,17 @@ bool CallExpression::IsValid() const { return true; } -void CallExpression::to_str(std::ostream& out, size_t indent) const { +void CallExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "Call[" << result_type_str() << "]{" << std::endl; - func_->to_str(out, indent + 2); + out << "Call[" << result_type_str(sem) << "]{" << std::endl; + func_->to_str(sem, out, indent + 2); make_indent(out, indent + 2); out << "(" << std::endl; for (auto* param : params_) - param->to_str(out, indent + 4); + param->to_str(sem, out, indent + 4); make_indent(out, indent + 2); out << ")" << std::endl; diff --git a/src/ast/call_expression.h b/src/ast/call_expression.h index d52ab4e5d7..d84f074169 100644 --- a/src/ast/call_expression.h +++ b/src/ast/call_expression.h @@ -53,9 +53,12 @@ class CallExpression : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: CallExpression(const CallExpression&) = delete; diff --git a/src/ast/call_expression_test.cc b/src/ast/call_expression_test.cc index 8769a52bc3..f8f3ee7854 100644 --- a/src/ast/call_expression_test.cc +++ b/src/ast/call_expression_test.cc @@ -97,7 +97,7 @@ TEST_F(CallExpressionTest, ToStr_NoParams) { auto* func = Expr("func"); auto* stmt = create(func, ExpressionList{}); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( @@ -114,7 +114,7 @@ TEST_F(CallExpressionTest, ToStr_WithParams) { auto* stmt = create(func, params); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( diff --git a/src/ast/call_statement.cc b/src/ast/call_statement.cc index 66b94e59cb..1e485387d7 100644 --- a/src/ast/call_statement.cc +++ b/src/ast/call_statement.cc @@ -39,8 +39,10 @@ bool CallStatement::IsValid() const { return call_ != nullptr && call_->IsValid(); } -void CallStatement::to_str(std::ostream& out, size_t indent) const { - call_->to_str(out, indent); +void CallStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { + call_->to_str(sem, out, indent); } } // namespace ast diff --git a/src/ast/call_statement.h b/src/ast/call_statement.h index c8aa837010..dfbb06be6c 100644 --- a/src/ast/call_statement.h +++ b/src/ast/call_statement.h @@ -50,9 +50,12 @@ class CallStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: CallStatement(const CallStatement&) = delete; diff --git a/src/ast/call_statement_test.cc b/src/ast/call_statement_test.cc index a9545e2f81..844d1cbcb2 100644 --- a/src/ast/call_statement_test.cc +++ b/src/ast/call_statement_test.cc @@ -58,7 +58,7 @@ TEST_F(CallStatementTest, ToStr) { create(Expr("func"), ExpressionList{})); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( diff --git a/src/ast/case_statement.cc b/src/ast/case_statement.cc index ac1a267e8e..5f5934dc29 100644 --- a/src/ast/case_statement.cc +++ b/src/ast/case_statement.cc @@ -40,7 +40,9 @@ bool CaseStatement::IsValid() const { return body_ != nullptr && body_->IsValid(); } -void CaseStatement::to_str(std::ostream& out, size_t indent) const { +void CaseStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); if (IsDefault()) { @@ -53,14 +55,14 @@ void CaseStatement::to_str(std::ostream& out, size_t indent) const { out << ", "; first = false; - out << selector->to_str(); + out << selector->to_str(sem); } out << "{" << std::endl; } if (body_ != nullptr) { for (auto* stmt : *body_) { - stmt->to_str(out, indent + 2); + stmt->to_str(sem, out, indent + 2); } } diff --git a/src/ast/case_statement.h b/src/ast/case_statement.h index b7933422cb..5b5d664be8 100644 --- a/src/ast/case_statement.h +++ b/src/ast/case_statement.h @@ -66,9 +66,12 @@ class CaseStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: CaseStatement(const CaseStatement&) = delete; diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc index ad54986f5f..2a9779bfe7 100644 --- a/src/ast/case_statement_test.cc +++ b/src/ast/case_statement_test.cc @@ -135,7 +135,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { auto* c = create(CaseSelectorList{b}, body); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Case -2{ Discard{} } @@ -152,7 +152,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) { auto* c = create(CaseSelectorList{b}, body); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Case 2{ Discard{} } @@ -170,7 +170,7 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { auto* c = create(b, body); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Case 1, 2{ Discard{} } @@ -184,7 +184,7 @@ TEST_F(CaseStatementTest, ToStr_WithoutSelectors) { auto* c = create(CaseSelectorList{}, body); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Default{ Discard{} } diff --git a/src/ast/constant_id_decoration.cc b/src/ast/constant_id_decoration.cc index 463e5b3677..fec8fe8b91 100644 --- a/src/ast/constant_id_decoration.cc +++ b/src/ast/constant_id_decoration.cc @@ -27,7 +27,9 @@ ConstantIdDecoration::ConstantIdDecoration(const Source& source, uint32_t val) ConstantIdDecoration::~ConstantIdDecoration() = default; -void ConstantIdDecoration::to_str(std::ostream& out, size_t indent) const { +void ConstantIdDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "ConstantIdDecoration{" << value_ << "}" << std::endl; } diff --git a/src/ast/constant_id_decoration.h b/src/ast/constant_id_decoration.h index 0d2b407769..11acca6324 100644 --- a/src/ast/constant_id_decoration.h +++ b/src/ast/constant_id_decoration.h @@ -35,9 +35,12 @@ class ConstantIdDecoration uint32_t value() const { return value_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/constant_id_decoration_test.cc b/src/ast/constant_id_decoration_test.cc index ea38af33cb..b536ee6a7a 100644 --- a/src/ast/constant_id_decoration_test.cc +++ b/src/ast/constant_id_decoration_test.cc @@ -39,7 +39,7 @@ TEST_F(ConstantIdDecorationTest, Is) { TEST_F(ConstantIdDecorationTest, ToStr) { auto* d = create(1200); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(ConstantIdDecoration{1200} )"); } diff --git a/src/ast/continue_statement.cc b/src/ast/continue_statement.cc index 58edfbac57..3b066a43d9 100644 --- a/src/ast/continue_statement.cc +++ b/src/ast/continue_statement.cc @@ -36,7 +36,9 @@ bool ContinueStatement::IsValid() const { return true; } -void ContinueStatement::to_str(std::ostream& out, size_t indent) const { +void ContinueStatement::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Continue{}" << std::endl; } diff --git a/src/ast/continue_statement.h b/src/ast/continue_statement.h index 1d4de2442a..ab2e8707d4 100644 --- a/src/ast/continue_statement.h +++ b/src/ast/continue_statement.h @@ -45,9 +45,12 @@ class ContinueStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: ContinueStatement(const ContinueStatement&) = delete; diff --git a/src/ast/continue_statement_test.cc b/src/ast/continue_statement_test.cc index ab725b171d..31c859a48a 100644 --- a/src/ast/continue_statement_test.cc +++ b/src/ast/continue_statement_test.cc @@ -42,7 +42,7 @@ TEST_F(ContinueStatementTest, IsValid) { TEST_F(ContinueStatementTest, ToStr) { auto* stmt = create(); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Continue{} )"); } diff --git a/src/ast/discard_statement.cc b/src/ast/discard_statement.cc index 3d4ae665d4..ec2bf653ba 100644 --- a/src/ast/discard_statement.cc +++ b/src/ast/discard_statement.cc @@ -36,7 +36,9 @@ bool DiscardStatement::IsValid() const { return true; } -void DiscardStatement::to_str(std::ostream& out, size_t indent) const { +void DiscardStatement::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Discard{}" << std::endl; } diff --git a/src/ast/discard_statement.h b/src/ast/discard_statement.h index 8f17fd7cfa..bb6e95a531 100644 --- a/src/ast/discard_statement.h +++ b/src/ast/discard_statement.h @@ -42,9 +42,12 @@ class DiscardStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: DiscardStatement(const DiscardStatement&) = delete; diff --git a/src/ast/discard_statement_test.cc b/src/ast/discard_statement_test.cc index 545d732aec..43e077141c 100644 --- a/src/ast/discard_statement_test.cc +++ b/src/ast/discard_statement_test.cc @@ -54,7 +54,7 @@ TEST_F(DiscardStatementTest, IsValid) { TEST_F(DiscardStatementTest, ToStr) { auto* stmt = create(); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Discard{} )"); } diff --git a/src/ast/else_statement.cc b/src/ast/else_statement.cc index 63201a3201..30e18a6362 100644 --- a/src/ast/else_statement.cc +++ b/src/ast/else_statement.cc @@ -43,14 +43,16 @@ bool ElseStatement::IsValid() const { return condition_ == nullptr || condition_->IsValid(); } -void ElseStatement::to_str(std::ostream& out, size_t indent) const { +void ElseStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Else{" << std::endl; if (condition_ != nullptr) { make_indent(out, indent + 2); out << "(" << std::endl; - condition_->to_str(out, indent + 4); + condition_->to_str(sem, out, indent + 4); make_indent(out, indent + 2); out << ")" << std::endl; @@ -61,7 +63,7 @@ void ElseStatement::to_str(std::ostream& out, size_t indent) const { if (body_ != nullptr) { for (auto* stmt : *body_) { - stmt->to_str(out, indent + 4); + stmt->to_str(sem, out, indent + 4); } } diff --git a/src/ast/else_statement.h b/src/ast/else_statement.h index 7b08fa53ed..a432c49eae 100644 --- a/src/ast/else_statement.h +++ b/src/ast/else_statement.h @@ -62,9 +62,12 @@ class ElseStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: ElseStatement(const ElseStatement&) = delete; diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index 0855fecdd9..f37fe56145 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -115,7 +115,7 @@ TEST_F(ElseStatementTest, ToStr) { }); auto* e = create(cond, body); std::ostringstream out; - e->to_str(out, 2); + e->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Else{ ( ScalarConstructor[not set]{true} @@ -133,7 +133,7 @@ TEST_F(ElseStatementTest, ToStr_NoCondition) { }); auto* e = create(nullptr, body); std::ostringstream out; - e->to_str(out, 2); + e->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Else{ { Discard{} diff --git a/src/ast/expression.h b/src/ast/expression.h index 853a57c523..f46d461cd7 100644 --- a/src/ast/expression.h +++ b/src/ast/expression.h @@ -38,7 +38,7 @@ class Expression : public Castable { /// @returns a string representation of the result type or 'not set' if no /// result type present - std::string result_type_str() const { + std::string result_type_str(const semantic::Info&) const { return result_type_ ? result_type_->type_name() : "not set"; } diff --git a/src/ast/expression_test.cc b/src/ast/expression_test.cc deleted file mode 100644 index 9dde377a3c..0000000000 --- a/src/ast/expression_test.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2020 The Tint Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/ast/expression.h" - -#include "src/ast/test_helper.h" -#include "src/type/alias_type.h" -#include "src/type/i32_type.h" - -namespace tint { -namespace ast { -namespace { - -class FakeExpr : public Expression { - public: - FakeExpr() : Expression(Source{}) {} - - FakeExpr* Clone(CloneContext*) const override { return nullptr; } - bool IsValid() const override { return true; } - void to_str(std::ostream&, size_t) const override {} -}; - -using ExpressionTest = TestHelper; - -TEST_F(ExpressionTest, set_result_type) { - FakeExpr e; - e.set_result_type(ty.i32()); - ASSERT_NE(e.result_type(), nullptr); - EXPECT_TRUE(e.result_type()->Is()); -} - -TEST_F(ExpressionTest, set_result_type_alias) { - auto* a = ty.alias("a", ty.i32()); - auto* b = ty.alias("b", a); - - FakeExpr e; - e.set_result_type(b); - ASSERT_NE(e.result_type(), nullptr); - EXPECT_TRUE(e.result_type()->Is()); -} - -} // namespace -} // namespace ast -} // namespace tint diff --git a/src/ast/fallthrough_statement.cc b/src/ast/fallthrough_statement.cc index ede2ca6737..dcdc26a874 100644 --- a/src/ast/fallthrough_statement.cc +++ b/src/ast/fallthrough_statement.cc @@ -37,7 +37,9 @@ bool FallthroughStatement::IsValid() const { return true; } -void FallthroughStatement::to_str(std::ostream& out, size_t indent) const { +void FallthroughStatement::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Fallthrough{}" << std::endl; } diff --git a/src/ast/fallthrough_statement.h b/src/ast/fallthrough_statement.h index 25d5870631..2db9546cc2 100644 --- a/src/ast/fallthrough_statement.h +++ b/src/ast/fallthrough_statement.h @@ -42,9 +42,12 @@ class FallthroughStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: FallthroughStatement(const FallthroughStatement&) = delete; diff --git a/src/ast/fallthrough_statement_test.cc b/src/ast/fallthrough_statement_test.cc index a17131afe4..4021bba7f9 100644 --- a/src/ast/fallthrough_statement_test.cc +++ b/src/ast/fallthrough_statement_test.cc @@ -50,7 +50,7 @@ TEST_F(FallthroughStatementTest, IsValid) { TEST_F(FallthroughStatementTest, ToStr) { auto* stmt = create(); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Fallthrough{} )"); } diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index 6e481991c8..f7b54f483e 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -30,7 +30,7 @@ FloatLiteral::FloatLiteral(const Source& source, type::Type* type, float value) FloatLiteral::~FloatLiteral() = default; -std::string FloatLiteral::to_str() const { +std::string FloatLiteral::to_str(const semantic::Info&) const { return std::to_string(value_); } diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h index bbf58f838d..b3deb9c616 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -38,8 +38,9 @@ class FloatLiteral : public Castable { /// @returns the name for this literal. This name is unique to this value. std::string name() const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - std::string to_str() const override; + std::string to_str(const semantic::Info& sem) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index fd4dfe709c..b329035053 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -46,7 +46,7 @@ TEST_F(FloatLiteralTest, Is) { TEST_F(FloatLiteralTest, ToStr) { auto* f = create(ty.f32(), 42.1f); - EXPECT_EQ(f->to_str(), "42.099998"); + EXPECT_EQ(f->to_str(Sem()), "42.099998"); } TEST_F(FloatLiteralTest, ToName) { diff --git a/src/ast/function.cc b/src/ast/function.cc index ceb2d3df2b..f17421a19b 100644 --- a/src/ast/function.cc +++ b/src/ast/function.cc @@ -247,13 +247,15 @@ bool Function::IsValid() const { return true; } -void Function::to_str(std::ostream& out, size_t indent) const { +void Function::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Function " << symbol_.to_str() << " -> " << return_type_->type_name() << std::endl; for (auto* deco : decorations()) { - deco->to_str(out, indent); + deco->to_str(sem, out, indent); } make_indent(out, indent); @@ -263,7 +265,7 @@ void Function::to_str(std::ostream& out, size_t indent) const { out << std::endl; for (auto* param : params_) - param->to_str(out, indent + 2); + param->to_str(sem, out, indent + 2); make_indent(out, indent); } @@ -274,7 +276,7 @@ void Function::to_str(std::ostream& out, size_t indent) const { if (body_ != nullptr) { for (auto* stmt : *body_) { - stmt->to_str(out, indent + 2); + stmt->to_str(sem, out, indent + 2); } } diff --git a/src/ast/function.h b/src/ast/function.h index 0f635c1efd..ff72b14b38 100644 --- a/src/ast/function.h +++ b/src/ast/function.h @@ -184,9 +184,12 @@ class Function : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// @returns the type name for this function std::string type_name() const; diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index 1181efa706..39b6c62e3c 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -245,7 +245,7 @@ TEST_F(FunctionTest, ToStr) { FunctionDecorationList{}); std::ostringstream out; - f->to_str(out, 2); + f->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Function func -> __void () { @@ -262,7 +262,7 @@ TEST_F(FunctionTest, ToStr_WithDecoration) { FunctionDecorationList{create(2, 4, 6)}); std::ostringstream out; - f->to_str(out, 2); + f->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Function func -> __void WorkgroupDecoration{2 4 6} () @@ -283,7 +283,7 @@ TEST_F(FunctionTest, ToStr_WithParams) { FunctionDecorationList{}); std::ostringstream out; - f->to_str(out, 2); + f->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Function func -> __void ( Variable{ diff --git a/src/ast/group_decoration.cc b/src/ast/group_decoration.cc index 019cc3697e..5c8171d88d 100644 --- a/src/ast/group_decoration.cc +++ b/src/ast/group_decoration.cc @@ -27,7 +27,9 @@ GroupDecoration::GroupDecoration(const Source& source, uint32_t val) GroupDecoration::~GroupDecoration() = default; -void GroupDecoration::to_str(std::ostream& out, size_t indent) const { +void GroupDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "GroupDecoration{" << value_ << "}" << std::endl; } diff --git a/src/ast/group_decoration.h b/src/ast/group_decoration.h index 323012d3e8..1ff24be569 100644 --- a/src/ast/group_decoration.h +++ b/src/ast/group_decoration.h @@ -35,9 +35,12 @@ class GroupDecoration : public Castable { uint32_t value() const { return value_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/group_decoration_test.cc b/src/ast/group_decoration_test.cc index 95625d3551..5052c850de 100644 --- a/src/ast/group_decoration_test.cc +++ b/src/ast/group_decoration_test.cc @@ -40,7 +40,7 @@ TEST_F(GroupDecorationTest, Is) { TEST_F(GroupDecorationTest, ToStr) { auto* d = create(2); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(GroupDecoration{2} )"); } diff --git a/src/ast/identifier_expression.cc b/src/ast/identifier_expression.cc index c6c0779a55..ba05e64444 100644 --- a/src/ast/identifier_expression.cc +++ b/src/ast/identifier_expression.cc @@ -38,9 +38,11 @@ bool IdentifierExpression::IsValid() const { return sym_.IsValid(); } -void IdentifierExpression::to_str(std::ostream& out, size_t indent) const { +void IdentifierExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "Identifier[" << result_type_str() << "]{" << sym_.to_str() << "}" + out << "Identifier[" << result_type_str(sem) << "]{" << sym_.to_str() << "}" << std::endl; } diff --git a/src/ast/identifier_expression.h b/src/ast/identifier_expression.h index d1a2b77d1c..1021bdd837 100644 --- a/src/ast/identifier_expression.h +++ b/src/ast/identifier_expression.h @@ -76,9 +76,12 @@ class IdentifierExpression : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: IdentifierExpression(const IdentifierExpression&) = delete; diff --git a/src/ast/identifier_expression_test.cc b/src/ast/identifier_expression_test.cc index 1059af2dd9..3d504ca093 100644 --- a/src/ast/identifier_expression_test.cc +++ b/src/ast/identifier_expression_test.cc @@ -49,7 +49,7 @@ TEST_F(IdentifierExpressionTest, IsValid) { TEST_F(IdentifierExpressionTest, ToStr) { auto* i = Expr("ident"); std::ostringstream out; - i->to_str(out, 2); + i->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Identifier[not set]{ident} )"); } diff --git a/src/ast/if_statement.cc b/src/ast/if_statement.cc index 16a677d55a..0b018ef6d8 100644 --- a/src/ast/if_statement.cc +++ b/src/ast/if_statement.cc @@ -67,7 +67,9 @@ bool IfStatement::IsValid() const { return true; } -void IfStatement::to_str(std::ostream& out, size_t indent) const { +void IfStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "If{" << std::endl; @@ -75,7 +77,7 @@ void IfStatement::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent + 2); out << "(" << std::endl; - condition_->to_str(out, indent + 4); + condition_->to_str(sem, out, indent + 4); // Close if conditional make_indent(out, indent + 2); @@ -87,7 +89,7 @@ void IfStatement::to_str(std::ostream& out, size_t indent) const { if (body_ != nullptr) { for (auto* stmt : *body_) { - stmt->to_str(out, indent + 4); + stmt->to_str(sem, out, indent + 4); } } @@ -100,7 +102,7 @@ void IfStatement::to_str(std::ostream& out, size_t indent) const { out << "}" << std::endl; for (auto* e : else_statements_) { - e->to_str(out, indent); + e->to_str(sem, out, indent); } } diff --git a/src/ast/if_statement.h b/src/ast/if_statement.h index 11515abd57..10ee4a1c1b 100644 --- a/src/ast/if_statement.h +++ b/src/ast/if_statement.h @@ -67,9 +67,12 @@ class IfStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: IfStatement(const IfStatement&) = delete; diff --git a/src/ast/if_statement_test.cc b/src/ast/if_statement_test.cc index 6e4bf62264..d071f7feb5 100644 --- a/src/ast/if_statement_test.cc +++ b/src/ast/if_statement_test.cc @@ -168,7 +168,7 @@ TEST_F(IfStatementTest, ToStr) { auto* stmt = create(cond, body, ElseStatementList{}); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( If{ ( Identifier[not set]{cond} @@ -196,7 +196,7 @@ TEST_F(IfStatementTest, ToStr_WithElseStatements) { }); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( If{ ( Identifier[not set]{cond} diff --git a/src/ast/literal.cc b/src/ast/literal.cc index 05375ad2d3..4c365da207 100644 --- a/src/ast/literal.cc +++ b/src/ast/literal.cc @@ -28,9 +28,11 @@ bool Literal::IsValid() const { return true; } -void Literal::to_str(std::ostream& out, size_t indent) const { +void Literal::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << to_str(); + out << to_str(sem); } } // namespace ast diff --git a/src/ast/literal.h b/src/ast/literal.h index 2b08eea39a..96779d7690 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -35,12 +35,16 @@ class Literal : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - virtual std::string to_str() const = 0; + virtual std::string to_str(const semantic::Info& sem) const = 0; /// @returns the name for this literal. This name is unique to this value. virtual std::string name() const = 0; diff --git a/src/ast/location_decoration.cc b/src/ast/location_decoration.cc index 1eff8a6f74..8e25036a18 100644 --- a/src/ast/location_decoration.cc +++ b/src/ast/location_decoration.cc @@ -27,7 +27,9 @@ LocationDecoration::LocationDecoration(const Source& source, uint32_t val) LocationDecoration::~LocationDecoration() = default; -void LocationDecoration::to_str(std::ostream& out, size_t indent) const { +void LocationDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "LocationDecoration{" << value_ << "}" << std::endl; } diff --git a/src/ast/location_decoration.h b/src/ast/location_decoration.h index fc2496369d..3d28c69241 100644 --- a/src/ast/location_decoration.h +++ b/src/ast/location_decoration.h @@ -36,9 +36,12 @@ class LocationDecoration uint32_t value() const { return value_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/location_decoration_test.cc b/src/ast/location_decoration_test.cc index b8084e3e3f..349e73088a 100644 --- a/src/ast/location_decoration_test.cc +++ b/src/ast/location_decoration_test.cc @@ -42,7 +42,7 @@ TEST_F(LocationDecorationTest, Is) { TEST_F(LocationDecorationTest, ToStr) { auto* d = create(2); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(LocationDecoration{2} )"); } diff --git a/src/ast/loop_statement.cc b/src/ast/loop_statement.cc index 68730c4adf..74cb698400 100644 --- a/src/ast/loop_statement.cc +++ b/src/ast/loop_statement.cc @@ -46,13 +46,15 @@ bool LoopStatement::IsValid() const { return true; } -void LoopStatement::to_str(std::ostream& out, size_t indent) const { +void LoopStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Loop{" << std::endl; if (body_ != nullptr) { for (auto* stmt : *body_) { - stmt->to_str(out, indent + 2); + stmt->to_str(sem, out, indent + 2); } } @@ -61,7 +63,7 @@ void LoopStatement::to_str(std::ostream& out, size_t indent) const { out << "continuing {" << std::endl; for (auto* stmt : *continuing_) { - stmt->to_str(out, indent + 4); + stmt->to_str(sem, out, indent + 4); } make_indent(out, indent + 2); diff --git a/src/ast/loop_statement.h b/src/ast/loop_statement.h index e80eb943b2..b4f7f74618 100644 --- a/src/ast/loop_statement.h +++ b/src/ast/loop_statement.h @@ -64,9 +64,12 @@ class LoopStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: LoopStatement(const LoopStatement&) = delete; diff --git a/src/ast/loop_statement_test.cc b/src/ast/loop_statement_test.cc index d3dca64809..0f0b4f4fbc 100644 --- a/src/ast/loop_statement_test.cc +++ b/src/ast/loop_statement_test.cc @@ -171,7 +171,7 @@ TEST_F(LoopStatementTest, ToStr) { auto* l = create(body, nullptr); std::ostringstream out; - l->to_str(out, 2); + l->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Loop{ Discard{} } @@ -187,7 +187,7 @@ TEST_F(LoopStatementTest, ToStr_WithContinuing) { auto* l = create(body, continuing); std::ostringstream out; - l->to_str(out, 2); + l->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Loop{ Discard{} continuing { diff --git a/src/ast/member_accessor_expression.cc b/src/ast/member_accessor_expression.cc index 20e6ee6fc0..e58ad9863f 100644 --- a/src/ast/member_accessor_expression.cc +++ b/src/ast/member_accessor_expression.cc @@ -48,11 +48,13 @@ bool MemberAccessorExpression::IsValid() const { return true; } -void MemberAccessorExpression::to_str(std::ostream& out, size_t indent) const { +void MemberAccessorExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "MemberAccessor[" << result_type_str() << "]{" << std::endl; - struct_->to_str(out, indent + 2); - member_->to_str(out, indent + 2); + out << "MemberAccessor[" << result_type_str(sem) << "]{" << std::endl; + struct_->to_str(sem, out, indent + 2); + member_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/member_accessor_expression.h b/src/ast/member_accessor_expression.h index d9aef791e9..3e6fd9bb55 100644 --- a/src/ast/member_accessor_expression.h +++ b/src/ast/member_accessor_expression.h @@ -57,9 +57,12 @@ class MemberAccessorExpression bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: MemberAccessorExpression(const MemberAccessorExpression&) = delete; diff --git a/src/ast/member_accessor_expression_test.cc b/src/ast/member_accessor_expression_test.cc index c7d1dd5d88..cc17106fc7 100644 --- a/src/ast/member_accessor_expression_test.cc +++ b/src/ast/member_accessor_expression_test.cc @@ -78,7 +78,7 @@ TEST_F(MemberAccessorExpressionTest, ToStr) { auto* stmt = create(Expr("structure"), Expr("member")); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( MemberAccessor[not set]{ Identifier[not set]{structure} Identifier[not set]{member} diff --git a/src/ast/module.cc b/src/ast/module.cc index 9d99c17901..e9e3a63c7d 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -81,7 +81,9 @@ Module* Module::Clone(CloneContext* ctx) const { ctx->Clone(global_variables_)); } -void Module::to_str(std::ostream& out, size_t indent) const { +void Module::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Module{" << std::endl; indent += 2; @@ -91,25 +93,25 @@ void Module::to_str(std::ostream& out, size_t indent) const { out << alias->symbol().to_str() << " -> " << alias->type()->type_name() << std::endl; if (auto* str = alias->type()->As()) { - str->impl()->to_str(out, indent); + str->impl()->to_str(sem, out, indent); } } else if (auto* str = ty->As()) { out << str->symbol().to_str() << " "; - str->impl()->to_str(out, indent); + str->impl()->to_str(sem, out, indent); } } for (auto* var : global_variables_) { - var->to_str(out, indent); + var->to_str(sem, out, indent); } for (auto* func : functions_) { - func->to_str(out, indent); + func->to_str(sem, out, indent); } out << "}" << std::endl; } -std::string Module::to_str() const { +std::string Module::to_str(const semantic::Info& sem) const { std::ostringstream out; - to_str(out, 0); + to_str(sem, out, 0); return out.str(); } diff --git a/src/ast/module.h b/src/ast/module.h index bbc3c0b48d..c094c7cfb2 100644 --- a/src/ast/module.h +++ b/src/ast/module.h @@ -89,12 +89,16 @@ class Module : public Castable { Module* Clone(CloneContext* ctx) const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; + /// @param sem the semantic info for the program /// @returns a string representation of the Builder - std::string to_str() const; + std::string to_str(const semantic::Info& sem) const; private: std::vector constructed_types_; diff --git a/src/ast/module_clone_test.cc b/src/ast/module_clone_test.cc index d2d72a1a53..8fa8350815 100644 --- a/src/ast/module_clone_test.cc +++ b/src/ast/module_clone_test.cc @@ -122,8 +122,8 @@ fn main() -> void { // Expect the AST printed with to_str() to match Demangler demanger; - EXPECT_EQ(demanger.Demangle(src.Symbols(), src.AST().to_str()), - demanger.Demangle(dst.Symbols(), dst.AST().to_str())); + EXPECT_EQ(demanger.Demangle(src.Symbols(), src.AST().to_str(src.Sem())), + demanger.Demangle(dst.Symbols(), dst.AST().to_str(dst.Sem()))); // Check that none of the AST nodes or type pointers in dst are found in src std::unordered_set src_nodes; @@ -135,7 +135,7 @@ fn main() -> void { src_types.emplace(src_type); } for (auto* dst_node : dst.Nodes().Objects()) { - ASSERT_EQ(src_nodes.count(dst_node), 0u) << dst_node->str(); + ASSERT_EQ(src_nodes.count(dst_node), 0u) << dst_node->str(dst.Sem()); } for (auto* dst_type : dst.Types()) { ASSERT_EQ(src_types.count(dst_type), 0u) << dst_type->type_name(); diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index f9870233e4..2f62568322 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -36,7 +36,7 @@ TEST_F(ModuleTest, Creation) { } TEST_F(ModuleTest, ToStrEmitsPreambleAndPostamble) { - const auto str = Program(std::move(*this)).AST().to_str(); + const auto str = Program(std::move(*this)).to_str(); auto* const expected = "Module{\n}\n"; EXPECT_EQ(str, expected); } diff --git a/src/ast/node.cc b/src/ast/node.cc index 8d0f1e02df..41480b2a06 100644 --- a/src/ast/node.cc +++ b/src/ast/node.cc @@ -32,9 +32,9 @@ void Node::make_indent(std::ostream& out, size_t indent) const { out << " "; } -std::string Node::str() const { +std::string Node::str(const semantic::Info& sem) const { std::ostringstream out; - to_str(out, 0); + to_str(sem, out, 0); return out.str(); } diff --git a/src/ast/node.h b/src/ast/node.h index 1c215e40a8..e7b92625c4 100644 --- a/src/ast/node.h +++ b/src/ast/node.h @@ -29,6 +29,9 @@ class CloneContext; namespace type { class Type; } +namespace semantic { +class Info; +} namespace ast { @@ -52,13 +55,17 @@ class Node : public Castable { virtual bool IsValid() const = 0; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - virtual void to_str(std::ostream& out, size_t indent) const = 0; + virtual void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const = 0; /// Convenience wrapper around the to_str() method. + /// @param sem the semantic info for the program /// @returns the node as a string - std::string str() const; + std::string str(const semantic::Info& sem) const; protected: /// Create a new node diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc index edcf896ca9..835ae2952b 100644 --- a/src/ast/null_literal.cc +++ b/src/ast/null_literal.cc @@ -27,7 +27,7 @@ NullLiteral::NullLiteral(const Source& source, type::Type* type) NullLiteral::~NullLiteral() = default; -std::string NullLiteral::to_str() const { +std::string NullLiteral::to_str(const semantic::Info&) const { return "null " + type()->type_name(); } diff --git a/src/ast/null_literal.h b/src/ast/null_literal.h index 31ada3bfaa..de6f7fc0e5 100644 --- a/src/ast/null_literal.h +++ b/src/ast/null_literal.h @@ -34,8 +34,9 @@ class NullLiteral : public Castable { /// @returns the name for this literal. This name is unique to this value. std::string name() const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - std::string to_str() const override; + std::string to_str(const semantic::Info& sem) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc index e50bd42f56..eac5bb0dea 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -40,7 +40,7 @@ TEST_F(NullLiteralTest, Is) { TEST_F(NullLiteralTest, ToStr) { auto* i = create(ty.i32()); - EXPECT_EQ(i->to_str(), "null __i32"); + EXPECT_EQ(i->to_str(Sem()), "null __i32"); } TEST_F(NullLiteralTest, Name_I32) { diff --git a/src/ast/return_statement.cc b/src/ast/return_statement.cc index 38133c2a2b..2f85773755 100644 --- a/src/ast/return_statement.cc +++ b/src/ast/return_statement.cc @@ -44,7 +44,9 @@ bool ReturnStatement::IsValid() const { return true; } -void ReturnStatement::to_str(std::ostream& out, size_t indent) const { +void ReturnStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Return{"; @@ -54,7 +56,7 @@ void ReturnStatement::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent + 2); out << "{" << std::endl; - value_->to_str(out, indent + 4); + value_->to_str(sem, out, indent + 4); make_indent(out, indent + 2); out << "}" << std::endl; diff --git a/src/ast/return_statement.h b/src/ast/return_statement.h index 5a56ba6a55..31c4fb57c9 100644 --- a/src/ast/return_statement.h +++ b/src/ast/return_statement.h @@ -55,9 +55,12 @@ class ReturnStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: ReturnStatement(const ReturnStatement&) = delete; diff --git a/src/ast/return_statement_test.cc b/src/ast/return_statement_test.cc index 68506c005c..d09352a7ce 100644 --- a/src/ast/return_statement_test.cc +++ b/src/ast/return_statement_test.cc @@ -76,7 +76,7 @@ TEST_F(ReturnStatementTest, ToStr_WithValue) { auto* expr = Expr("expr"); auto* r = create(expr); std::ostringstream out; - r->to_str(out, 2); + r->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Return{ { Identifier[not set]{expr} @@ -88,7 +88,7 @@ TEST_F(ReturnStatementTest, ToStr_WithValue) { TEST_F(ReturnStatementTest, ToStr_WithoutValue) { auto* r = create(); std::ostringstream out; - r->to_str(out, 2); + r->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( Return{} )"); } diff --git a/src/ast/scalar_constructor_expression.cc b/src/ast/scalar_constructor_expression.cc index ebbecc67e9..4c90f19678 100644 --- a/src/ast/scalar_constructor_expression.cc +++ b/src/ast/scalar_constructor_expression.cc @@ -41,11 +41,12 @@ bool ScalarConstructorExpression::IsValid() const { return literal_ != nullptr; } -void ScalarConstructorExpression::to_str(std::ostream& out, +void ScalarConstructorExpression::to_str(const semantic::Info& sem, + std::ostream& out, size_t indent) const { make_indent(out, indent); - out << "ScalarConstructor[" << result_type_str() << "]{" << literal_->to_str() - << "}" << std::endl; + out << "ScalarConstructor[" << result_type_str(sem) << "]{" + << literal_->to_str(sem) << "}" << std::endl; } } // namespace ast diff --git a/src/ast/scalar_constructor_expression.h b/src/ast/scalar_constructor_expression.h index 5c96ef9b3a..052eb05d55 100644 --- a/src/ast/scalar_constructor_expression.h +++ b/src/ast/scalar_constructor_expression.h @@ -51,9 +51,12 @@ class ScalarConstructorExpression bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: ScalarConstructorExpression(const ScalarConstructorExpression&) = delete; diff --git a/src/ast/scalar_constructor_expression_test.cc b/src/ast/scalar_constructor_expression_test.cc index c4a455978e..46fde36574 100644 --- a/src/ast/scalar_constructor_expression_test.cc +++ b/src/ast/scalar_constructor_expression_test.cc @@ -50,7 +50,7 @@ TEST_F(ScalarConstructorExpressionTest, IsValid_MissingLiteral) { TEST_F(ScalarConstructorExpressionTest, ToStr) { auto* c = Expr(true); std::ostringstream out; - c->to_str(out, 2); + c->to_str(Sem(), out, 2); EXPECT_EQ(out.str(), R"( ScalarConstructor[not set]{true} )"); } diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc index bc78d50b06..3c946acd24 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -27,7 +27,7 @@ SintLiteral::SintLiteral(const Source& source, type::Type* type, int32_t value) SintLiteral::~SintLiteral() = default; -std::string SintLiteral::to_str() const { +std::string SintLiteral::to_str(const semantic::Info&) const { return std::to_string(value_); } diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index 2df717df91..61fa7404fb 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -38,8 +38,9 @@ class SintLiteral : public Castable { /// @returns the name for this literal. This name is unique to this value. std::string name() const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - std::string to_str() const override; + std::string to_str(const semantic::Info& sem) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index 2fc5993ba9..a6d39a4354 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -46,7 +46,7 @@ TEST_F(SintLiteralTest, Is) { TEST_F(SintLiteralTest, ToStr) { auto* i = create(ty.i32(), -42); - EXPECT_EQ(i->to_str(), "-42"); + EXPECT_EQ(i->to_str(Sem()), "-42"); } TEST_F(SintLiteralTest, Name_I32) { diff --git a/src/ast/stage_decoration.cc b/src/ast/stage_decoration.cc index 53cb362551..bd68fe2bdf 100644 --- a/src/ast/stage_decoration.cc +++ b/src/ast/stage_decoration.cc @@ -27,7 +27,9 @@ StageDecoration::StageDecoration(const Source& source, PipelineStage stage) StageDecoration::~StageDecoration() = default; -void StageDecoration::to_str(std::ostream& out, size_t indent) const { +void StageDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "StageDecoration{" << stage_ << "}" << std::endl; } diff --git a/src/ast/stage_decoration.h b/src/ast/stage_decoration.h index 4208c7da16..f34bd219d8 100644 --- a/src/ast/stage_decoration.h +++ b/src/ast/stage_decoration.h @@ -34,9 +34,12 @@ class StageDecoration : public Castable { PipelineStage value() const { return stage_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/stage_decoration_test.cc b/src/ast/stage_decoration_test.cc index 82a5ccd7fa..142f26d287 100644 --- a/src/ast/stage_decoration_test.cc +++ b/src/ast/stage_decoration_test.cc @@ -39,7 +39,7 @@ TEST_F(StageDecorationTest, Is) { TEST_F(StageDecorationTest, ToStr) { auto* d = create(PipelineStage::kFragment); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(StageDecoration{fragment} )"); } diff --git a/src/ast/stride_decoration.cc b/src/ast/stride_decoration.cc index 0dd1990a66..52f3ef5ba5 100644 --- a/src/ast/stride_decoration.cc +++ b/src/ast/stride_decoration.cc @@ -27,7 +27,9 @@ StrideDecoration::StrideDecoration(const Source& source, uint32_t stride) StrideDecoration::~StrideDecoration() = default; -void StrideDecoration::to_str(std::ostream& out, size_t indent) const { +void StrideDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "stride " << stride_; } diff --git a/src/ast/stride_decoration.h b/src/ast/stride_decoration.h index ad9977833d..7e4031f5a6 100644 --- a/src/ast/stride_decoration.h +++ b/src/ast/stride_decoration.h @@ -35,9 +35,12 @@ class StrideDecoration : public Castable { uint32_t stride() const { return stride_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/struct.cc b/src/ast/struct.cc index cf696c5716..0493e3aa1e 100644 --- a/src/ast/struct.cc +++ b/src/ast/struct.cc @@ -66,16 +66,18 @@ bool Struct::IsValid() const { return true; } -void Struct::to_str(std::ostream& out, size_t indent) const { +void Struct::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { out << "Struct{" << std::endl; for (auto* deco : decorations_) { make_indent(out, indent + 2); out << "[["; - deco->to_str(out, 0); + deco->to_str(sem, out, 0); out << "]]" << std::endl; } for (auto* member : members_) { - member->to_str(out, indent + 2); + member->to_str(sem, out, indent + 2); } make_indent(out, indent); out << "}" << std::endl; diff --git a/src/ast/struct.h b/src/ast/struct.h index 9b4cb38440..36b00628d3 100644 --- a/src/ast/struct.h +++ b/src/ast/struct.h @@ -67,9 +67,12 @@ class Struct : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: Struct(const Struct&) = delete; diff --git a/src/ast/struct_block_decoration.cc b/src/ast/struct_block_decoration.cc index 2e1cf92cfb..5c69f81815 100644 --- a/src/ast/struct_block_decoration.cc +++ b/src/ast/struct_block_decoration.cc @@ -27,7 +27,9 @@ StructBlockDecoration::StructBlockDecoration(const Source& source) StructBlockDecoration::~StructBlockDecoration() = default; -void StructBlockDecoration::to_str(std::ostream& out, size_t indent) const { +void StructBlockDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "block"; } diff --git a/src/ast/struct_block_decoration.h b/src/ast/struct_block_decoration.h index 732fa5ecbc..c9e7d8af9c 100644 --- a/src/ast/struct_block_decoration.h +++ b/src/ast/struct_block_decoration.h @@ -34,9 +34,12 @@ class StructBlockDecoration ~StructBlockDecoration() override; /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/struct_member.cc b/src/ast/struct_member.cc index 0cc7a71dae..b6aa6420b8 100644 --- a/src/ast/struct_member.cc +++ b/src/ast/struct_member.cc @@ -72,13 +72,15 @@ bool StructMember::IsValid() const { return true; } -void StructMember::to_str(std::ostream& out, size_t indent) const { +void StructMember::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "StructMember{"; if (decorations_.size() > 0) { out << "[[ "; for (auto* deco : decorations_) - out << deco->str() << " "; + out << deco->str(sem) << " "; out << "]] "; } diff --git a/src/ast/struct_member.h b/src/ast/struct_member.h index 9f06562c39..c087b2be0b 100644 --- a/src/ast/struct_member.h +++ b/src/ast/struct_member.h @@ -70,9 +70,12 @@ class StructMember : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: StructMember(const StructMember&) = delete; diff --git a/src/ast/struct_member_offset_decoration.cc b/src/ast/struct_member_offset_decoration.cc index 09ebef6202..87f13a6de1 100644 --- a/src/ast/struct_member_offset_decoration.cc +++ b/src/ast/struct_member_offset_decoration.cc @@ -28,7 +28,8 @@ StructMemberOffsetDecoration::StructMemberOffsetDecoration(const Source& source, StructMemberOffsetDecoration::~StructMemberOffsetDecoration() = default; -void StructMemberOffsetDecoration::to_str(std::ostream& out, +void StructMemberOffsetDecoration::to_str(const semantic::Info&, + std::ostream& out, size_t indent) const { make_indent(out, indent); out << "offset " << std::to_string(offset_); diff --git a/src/ast/struct_member_offset_decoration.h b/src/ast/struct_member_offset_decoration.h index 445483b891..031a758e9f 100644 --- a/src/ast/struct_member_offset_decoration.h +++ b/src/ast/struct_member_offset_decoration.h @@ -36,9 +36,12 @@ class StructMemberOffsetDecoration uint32_t offset() const { return offset_; } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/struct_member_test.cc b/src/ast/struct_member_test.cc index 55ffc646e2..44c2bb9021 100644 --- a/src/ast/struct_member_test.cc +++ b/src/ast/struct_member_test.cc @@ -75,14 +75,14 @@ TEST_F(StructMemberTest, IsValid_Null_Decoration) { TEST_F(StructMemberTest, ToStr) { auto* st = Member("a", ty.i32(), {MemberOffset(4)}); std::ostringstream out; - st->to_str(out, 2); + st->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), " StructMember{[[ offset 4 ]] a: __i32}\n"); } TEST_F(StructMemberTest, ToStrNoDecorations) { auto* st = Member("a", ty.i32()); std::ostringstream out; - st->to_str(out, 2); + st->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), " StructMember{a: __i32}\n"); } diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc index 8274c5a6e5..103c22b332 100644 --- a/src/ast/struct_test.cc +++ b/src/ast/struct_test.cc @@ -93,7 +93,7 @@ TEST_F(StructTest, ToStr) { auto* s = create(StructMemberList{Member("a", ty.i32())}, decos); std::ostringstream out; - s->to_str(out, 2); + s->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"(Struct{ [[block]] StructMember{a: __i32} diff --git a/src/ast/switch_statement.cc b/src/ast/switch_statement.cc index 4bc34b3d84..89dc22d703 100644 --- a/src/ast/switch_statement.cc +++ b/src/ast/switch_statement.cc @@ -49,16 +49,18 @@ bool SwitchStatement::IsValid() const { return true; } -void SwitchStatement::to_str(std::ostream& out, size_t indent) const { +void SwitchStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Switch{" << std::endl; - condition_->to_str(out, indent + 2); + condition_->to_str(sem, out, indent + 2); make_indent(out, indent + 2); out << "{" << std::endl; for (auto* stmt : body_) { - stmt->to_str(out, indent + 4); + stmt->to_str(sem, out, indent + 4); } make_indent(out, indent + 2); diff --git a/src/ast/switch_statement.h b/src/ast/switch_statement.h index b964724746..6c180cdbb4 100644 --- a/src/ast/switch_statement.h +++ b/src/ast/switch_statement.h @@ -60,9 +60,12 @@ class SwitchStatement : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: SwitchStatement(const SwitchStatement&) = delete; diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index d51eb5526b..86d0b90420 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -137,7 +137,7 @@ TEST_F(SwitchStatementTest, ToStr_Empty) { auto* stmt = create(ident, CaseStatementList{}); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Switch{ Identifier[not set]{ident} { @@ -157,7 +157,7 @@ TEST_F(SwitchStatementTest, ToStr) { auto* stmt = create(ident, body); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Switch{ Identifier[not set]{ident} { diff --git a/src/ast/type_constructor_expression.cc b/src/ast/type_constructor_expression.cc index 2afde7be4a..532e0d0831 100644 --- a/src/ast/type_constructor_expression.cc +++ b/src/ast/type_constructor_expression.cc @@ -53,14 +53,16 @@ bool TypeConstructorExpression::IsValid() const { return true; } -void TypeConstructorExpression::to_str(std::ostream& out, size_t indent) const { +void TypeConstructorExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "TypeConstructor[" << result_type_str() << "]{" << std::endl; + out << "TypeConstructor[" << result_type_str(sem) << "]{" << std::endl; make_indent(out, indent + 2); out << type_->type_name() << std::endl; for (auto* val : values_) { - val->to_str(out, indent + 2); + val->to_str(sem, out, indent + 2); } make_indent(out, indent); out << "}" << std::endl; diff --git a/src/ast/type_constructor_expression.h b/src/ast/type_constructor_expression.h index 1fdbeec1dc..9190a84083 100644 --- a/src/ast/type_constructor_expression.h +++ b/src/ast/type_constructor_expression.h @@ -56,9 +56,12 @@ class TypeConstructorExpression bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: TypeConstructorExpression(const TypeConstructorExpression&) = delete; diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc index 4f1b3b1f06..e4421a43d5 100644 --- a/src/ast/type_constructor_expression_test.cc +++ b/src/ast/type_constructor_expression_test.cc @@ -107,7 +107,7 @@ TEST_F(TypeConstructorExpressionTest, ToStr) { auto* t = create(&vec, expr); std::ostringstream out; - t->to_str(out, 2); + t->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( TypeConstructor[not set]{ __vec_3__f32 Identifier[not set]{expr_1} diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc index 076b8969c1..e9dd464503 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -27,7 +27,7 @@ UintLiteral::UintLiteral(const Source& source, type::Type* type, uint32_t value) UintLiteral::~UintLiteral() = default; -std::string UintLiteral::to_str() const { +std::string UintLiteral::to_str(const semantic::Info&) const { return std::to_string(value_); } diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h index 3464a88d0d..c3ff8cfded 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -38,8 +38,9 @@ class UintLiteral : public Castable { /// @returns the name for this literal. This name is unique to this value. std::string name() const override; + /// @param sem the semantic info for the program /// @returns the literal as a string - std::string to_str() const override; + std::string to_str(const semantic::Info& sem) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index 1216bb2e79..662826953b 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -44,7 +44,7 @@ TEST_F(UintLiteralTest, Is) { TEST_F(UintLiteralTest, ToStr) { auto* u = create(ty.u32(), 42); - EXPECT_EQ(u->to_str(), "42"); + EXPECT_EQ(u->to_str(Sem()), "42"); } } // namespace diff --git a/src/ast/unary_op_expression.cc b/src/ast/unary_op_expression.cc index 890e1edf30..495e49a127 100644 --- a/src/ast/unary_op_expression.cc +++ b/src/ast/unary_op_expression.cc @@ -40,12 +40,14 @@ bool UnaryOpExpression::IsValid() const { return expr_ != nullptr && expr_->IsValid(); } -void UnaryOpExpression::to_str(std::ostream& out, size_t indent) const { +void UnaryOpExpression::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); - out << "UnaryOp[" << result_type_str() << "]{" << std::endl; + out << "UnaryOp[" << result_type_str(sem) << "]{" << std::endl; make_indent(out, indent + 2); out << op_ << std::endl; - expr_->to_str(out, indent + 2); + expr_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/unary_op_expression.h b/src/ast/unary_op_expression.h index 0a9d352643..c7d80175cc 100644 --- a/src/ast/unary_op_expression.h +++ b/src/ast/unary_op_expression.h @@ -54,9 +54,12 @@ class UnaryOpExpression : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: UnaryOpExpression(const UnaryOpExpression&) = delete; diff --git a/src/ast/unary_op_expression_test.cc b/src/ast/unary_op_expression_test.cc index 9b0717ae3c..6abc1bb62f 100644 --- a/src/ast/unary_op_expression_test.cc +++ b/src/ast/unary_op_expression_test.cc @@ -69,7 +69,7 @@ TEST_F(UnaryOpExpressionTest, ToStr) { auto* ident = Expr("ident"); auto* u = create(UnaryOp::kNot, ident); std::ostringstream out; - u->to_str(out, 2); + u->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( UnaryOp[not set]{ not Identifier[not set]{ident} diff --git a/src/ast/variable.cc b/src/ast/variable.cc index 52e869bd76..cc0e676491 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -110,7 +110,9 @@ bool Variable::IsValid() const { return true; } -void Variable::info_to_str(std::ostream& out, size_t indent) const { +void Variable::info_to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << symbol_.to_str() << std::endl; make_indent(out, indent); @@ -119,20 +121,24 @@ void Variable::info_to_str(std::ostream& out, size_t indent) const { out << type_->type_name() << std::endl; } -void Variable::constructor_to_str(std::ostream& out, size_t indent) const { +void Variable::constructor_to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { if (constructor_ == nullptr) return; make_indent(out, indent); out << "{" << std::endl; - constructor_->to_str(out, indent + 2); + constructor_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } -void Variable::to_str(std::ostream& out, size_t indent) const { +void Variable::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "Variable"; if (is_const()) { @@ -144,14 +150,14 @@ void Variable::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent + 2); out << "Decorations{" << std::endl; for (auto* deco : decorations_) { - deco->to_str(out, indent + 4); + deco->to_str(sem, out, indent + 4); } make_indent(out, indent + 2); out << "}" << std::endl; } - info_to_str(out, indent + 2); - constructor_to_str(out, indent + 2); + info_to_str(sem, out, indent + 2); + constructor_to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/variable.h b/src/ast/variable.h index e721ad0afb..fb337b1f56 100644 --- a/src/ast/variable.h +++ b/src/ast/variable.h @@ -150,19 +150,28 @@ class Variable : public Castable { bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; protected: /// Output information for this variable. + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void info_to_str(std::ostream& out, size_t indent) const; + void info_to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const; /// Output constructor for this variable. + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void constructor_to_str(std::ostream& out, size_t indent) const; + void constructor_to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const; private: Variable(const Variable&) = delete; diff --git a/src/ast/variable_decl_statement.cc b/src/ast/variable_decl_statement.cc index 8bdddcb001..2dd0a771a2 100644 --- a/src/ast/variable_decl_statement.cc +++ b/src/ast/variable_decl_statement.cc @@ -39,10 +39,12 @@ bool VariableDeclStatement::IsValid() const { return variable_ != nullptr && variable_->IsValid(); } -void VariableDeclStatement::to_str(std::ostream& out, size_t indent) const { +void VariableDeclStatement::to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "VariableDeclStatement{" << std::endl; - variable_->to_str(out, indent + 2); + variable_->to_str(sem, out, indent + 2); make_indent(out, indent); out << "}" << std::endl; } diff --git a/src/ast/variable_decl_statement.h b/src/ast/variable_decl_statement.h index bc2bed7622..5acafd4ad8 100644 --- a/src/ast/variable_decl_statement.h +++ b/src/ast/variable_decl_statement.h @@ -52,9 +52,12 @@ class VariableDeclStatement bool IsValid() const override; /// Writes a representation of the node to the output stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; private: VariableDeclStatement(const VariableDeclStatement&) = delete; diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc index 62294fa2cf..6524c0e2ba 100644 --- a/src/ast/variable_decl_statement_test.cc +++ b/src/ast/variable_decl_statement_test.cc @@ -71,7 +71,7 @@ TEST_F(VariableDeclStatementTest, ToStr) { auto* stmt = create(Source{Source::Location{20, 2}}, var); std::ostringstream out; - stmt->to_str(out, 2); + stmt->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( VariableDeclStatement{ Variable{ a diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc index a7d2319c5a..15a930f7de 100644 --- a/src/ast/variable_test.cc +++ b/src/ast/variable_test.cc @@ -103,7 +103,7 @@ TEST_F(VariableTest, to_str) { auto* v = Var("my_var", StorageClass::kFunction, ty.f32(), nullptr, ast::VariableDecorationList{}); std::ostringstream out; - v->to_str(out, 2); + v->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Variable{ my_var function @@ -146,7 +146,7 @@ TEST_F(VariableTest, Decorated_to_str) { }); std::ostringstream out; - var->to_str(out, 2); + var->to_str(Sem(), out, 2); EXPECT_EQ(demangle(out.str()), R"( Variable{ Decorations{ BindingDecoration{2} diff --git a/src/ast/workgroup_decoration.cc b/src/ast/workgroup_decoration.cc index 914278a065..0d49f10fd9 100644 --- a/src/ast/workgroup_decoration.cc +++ b/src/ast/workgroup_decoration.cc @@ -38,7 +38,9 @@ WorkgroupDecoration::WorkgroupDecoration(const Source& source, WorkgroupDecoration::~WorkgroupDecoration() = default; -void WorkgroupDecoration::to_str(std::ostream& out, size_t indent) const { +void WorkgroupDecoration::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "WorkgroupDecoration{" << x_ << " " << y_ << " " << z_ << "}" << std::endl; diff --git a/src/ast/workgroup_decoration.h b/src/ast/workgroup_decoration.h index d39421513d..af6e949600 100644 --- a/src/ast/workgroup_decoration.h +++ b/src/ast/workgroup_decoration.h @@ -51,9 +51,12 @@ class WorkgroupDecoration } /// Outputs the decoration to the given stream + /// @param sem the semantic info for the program /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. diff --git a/src/ast/workgroup_decoration_test.cc b/src/ast/workgroup_decoration_test.cc index 4a749f1c0f..df28db1e69 100644 --- a/src/ast/workgroup_decoration_test.cc +++ b/src/ast/workgroup_decoration_test.cc @@ -66,7 +66,7 @@ TEST_F(WorkgroupDecorationTest, Is) { TEST_F(WorkgroupDecorationTest, ToStr) { auto* d = create(2, 4, 6); std::ostringstream out; - d->to_str(out, 0); + d->to_str(Sem(), out, 0); EXPECT_EQ(out.str(), R"(WorkgroupDecoration{2 4 6} )"); } diff --git a/src/clone_context_test.cc b/src/clone_context_test.cc index 6460eaec92..55d0f522fd 100644 --- a/src/clone_context_test.cc +++ b/src/clone_context_test.cc @@ -39,7 +39,7 @@ struct Cloneable : public Castable { } bool IsValid() const override { return true; } - void to_str(std::ostream&, size_t) const override {} + void to_str(const semantic::Info&, std::ostream&, size_t) const override {} }; struct Replaceable : public Castable { diff --git a/src/demangler.cc b/src/demangler.cc index aca97a0dba..cdfcaa52a2 100644 --- a/src/demangler.cc +++ b/src/demangler.cc @@ -59,7 +59,7 @@ std::string Demangler::Demangle(const SymbolTable& symbols, } std::string Demangler::Demangle(const Program& program) const { - return Demangle(program.Symbols(), program.AST().to_str()); + return Demangle(program.Symbols(), program.AST().to_str(program.Sem())); } } // namespace tint diff --git a/src/program.cc b/src/program.cc index 6b25bdfdb7..39bf5a05b3 100644 --- a/src/program.cc +++ b/src/program.cc @@ -30,6 +30,7 @@ Program::Program(Program&& program) : types_(std::move(program.types_)), nodes_(std::move(program.nodes_)), ast_(std::move(program.ast_)), + sem_(std::move(program.sem_)), symbols_(std::move(program.symbols_)), diagnostics_(std::move(program.diagnostics_)), is_valid_(program.is_valid_) { @@ -53,6 +54,7 @@ Program::Program(ProgramBuilder&& builder) { ast_ = nodes_.Create(Source{}, builder.AST().ConstructedTypes(), builder.AST().Functions(), builder.AST().GlobalVariables()); + sem_ = std::move(builder.Sem()); symbols_ = std::move(builder.Symbols()); diagnostics_ = std::move(builder.Diagnostics()); builder.MarkAsMoved(); @@ -73,6 +75,7 @@ Program& Program::operator=(Program&& program) { types_ = std::move(program.types_); nodes_ = std::move(program.nodes_); ast_ = std::move(program.ast_); + sem_ = std::move(program.sem_); symbols_ = std::move(program.symbols_); is_valid_ = program.is_valid_; return *this; @@ -97,7 +100,7 @@ bool Program::IsValid() const { std::string Program::to_str() const { AssertNotMoved(); - return ast_->to_str(); + return ast_->to_str(Sem()); } void Program::AssertNotMoved() const { diff --git a/src/program.h b/src/program.h index bddc73d69d..0e624e7d89 100644 --- a/src/program.h +++ b/src/program.h @@ -19,6 +19,7 @@ #include "src/ast/function.h" #include "src/diagnostic/diagnostic.h" +#include "src/semantic/info.h" #include "src/symbol_table.h" #include "src/type/type_manager.h" @@ -76,6 +77,12 @@ class Program { return *ast_; } + /// @returns a reference to the program's semantic info + const semantic::Info& Sem() const { + AssertNotMoved(); + return sem_; + } + /// @returns a reference to the program's SymbolTable const SymbolTable& Symbols() const { AssertNotMoved(); @@ -110,6 +117,7 @@ class Program { type::Manager types_; ASTNodes nodes_; ast::Module* ast_; + semantic::Info sem_; SymbolTable symbols_; diag::List diagnostics_; bool is_valid_ = true; diff --git a/src/program_builder.cc b/src/program_builder.cc index af61240d1f..5f217432cd 100644 --- a/src/program_builder.cc +++ b/src/program_builder.cc @@ -31,6 +31,7 @@ ProgramBuilder::ProgramBuilder(ProgramBuilder&& rhs) types_(std::move(rhs.types_)), nodes_(std::move(rhs.nodes_)), ast_(rhs.ast_), + sem_(std::move(rhs.sem_)), symbols_(std::move(rhs.symbols_)) { rhs.MarkAsMoved(); } @@ -44,6 +45,7 @@ ProgramBuilder& ProgramBuilder::operator=(ProgramBuilder&& rhs) { types_ = std::move(rhs.types_); nodes_ = std::move(rhs.nodes_); ast_ = rhs.ast_; + sem_ = std::move(rhs.sem_); symbols_ = std::move(rhs.symbols_); return *this; } diff --git a/src/program_builder.h b/src/program_builder.h index dfac2c9e7f..582717daab 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -37,6 +37,7 @@ #include "src/ast/variable.h" #include "src/diagnostic/diagnostic.h" #include "src/program.h" +#include "src/semantic/info.h" #include "src/symbol_table.h" #include "src/type/alias_type.h" #include "src/type/array_type.h" @@ -101,18 +102,48 @@ class ProgramBuilder { return types_; } + /// @returns a reference to the program's types + const type::Manager& Types() const { + AssertNotMoved(); + return types_; + } + /// @returns a reference to the program's AST nodes storage ASTNodes& Nodes() { AssertNotMoved(); return nodes_; } + /// @returns a reference to the program's AST nodes storage + const ASTNodes& Nodes() const { + AssertNotMoved(); + return nodes_; + } + /// @returns a reference to the program's AST root Module ast::Module& AST() { AssertNotMoved(); return *ast_; } + /// @returns a reference to the program's AST root Module + const ast::Module& AST() const { + AssertNotMoved(); + return *ast_; + } + + /// @returns a reference to the program's semantic info + semantic::Info& Sem() { + AssertNotMoved(); + return sem_; + } + + /// @returns a reference to the program's semantic info + const semantic::Info& Sem() const { + AssertNotMoved(); + return sem_; + } + /// @returns a reference to the program's SymbolTable SymbolTable& Symbols() { AssertNotMoved(); @@ -125,6 +156,12 @@ class ProgramBuilder { return diagnostics_; } + /// @returns a reference to the program's diagnostics + const diag::List& Diagnostics() const { + AssertNotMoved(); + return diagnostics_; + } + /// Controls whether the TypeDeterminer will be run on the program when it is /// built. /// @param enable the new flag value (defaults to true) @@ -853,6 +890,7 @@ class ProgramBuilder { type::Manager types_; ASTNodes nodes_; ast::Module* ast_; + semantic::Info sem_; SymbolTable symbols_; diag::List diagnostics_; diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index d00da551c2..fd3aff38b9 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -709,7 +709,9 @@ bool StatementBuilder::IsValid() const { ast::Node* StatementBuilder::Clone(CloneContext*) const { return nullptr; } -void StatementBuilder::to_str(std::ostream& out, size_t indent) const { +void StatementBuilder::to_str(const semantic::Info&, + std::ostream& out, + size_t indent) const { make_indent(out, indent); out << "StatementBuilder" << std::endl; } diff --git a/src/reader/spirv/function.h b/src/reader/spirv/function.h index acc01d9526..eaafa6852f 100644 --- a/src/reader/spirv/function.h +++ b/src/reader/spirv/function.h @@ -353,7 +353,9 @@ class StatementBuilder : public Castable { private: bool IsValid() const override; Node* Clone(CloneContext*) const override; - void to_str(std::ostream& out, size_t indent) const override; + void to_str(const semantic::Info& sem, + std::ostream& out, + size_t indent) const override; }; /// A FunctionEmitter emits a SPIR-V function onto a Tint AST module. diff --git a/src/reader/spirv/function_arithmetic_test.cc b/src/reader/spirv/function_arithmetic_test.cc index dd17a2d746..cfe77bc8cf 100644 --- a/src/reader/spirv/function_arithmetic_test.cc +++ b/src/reader/spirv/function_arithmetic_test.cc @@ -139,7 +139,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -151,7 +151,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { @@ -166,7 +166,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -180,7 +180,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { @@ -195,7 +195,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -209,7 +209,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { @@ -224,7 +224,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -240,7 +240,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { @@ -255,7 +255,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -271,7 +271,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { @@ -286,7 +286,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -304,7 +304,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { @@ -319,7 +319,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -337,7 +337,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { @@ -352,7 +352,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -372,7 +372,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, FNegate_Scalar) { @@ -387,7 +387,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -399,7 +399,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, FNegate_Vector) { @@ -414,7 +414,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -430,7 +430,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } struct BinaryData { @@ -478,8 +478,7 @@ TEST_P(SpvBinaryArithTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(ss.str())) + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(ss.str())) << assembly; } @@ -702,7 +701,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -737,7 +736,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -760,7 +759,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P( @@ -848,7 +847,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -883,7 +882,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -906,7 +905,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P( @@ -936,8 +935,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __vec_2__f32 @@ -949,7 +947,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { @@ -966,8 +964,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -979,7 +976,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { @@ -996,8 +993,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1009,7 +1005,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { @@ -1026,8 +1022,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1039,7 +1034,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { @@ -1056,8 +1051,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1069,7 +1063,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, Dot) { @@ -1086,8 +1080,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_3 none __f32 @@ -1101,7 +1094,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, OuterProduct) { @@ -1120,7 +1113,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ x_3 none diff --git a/src/reader/spirv/function_bit_test.cc b/src/reader/spirv/function_bit_test.cc index 57d400a3c0..000ef597c5 100644 --- a/src/reader/spirv/function_bit_test.cc +++ b/src/reader/spirv/function_bit_test.cc @@ -163,8 +163,7 @@ TEST_P(SpvBinaryBitTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(ss.str())) + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(ss.str())) << assembly; } @@ -402,7 +401,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -414,7 +413,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Int_Uint) { @@ -429,7 +428,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -443,7 +442,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Uint_Int) { @@ -458,7 +457,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -472,7 +471,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { @@ -487,7 +486,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -499,7 +498,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { @@ -514,7 +513,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -530,7 +529,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { @@ -545,7 +544,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -563,7 +562,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { @@ -578,7 +577,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -596,7 +595,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { const auto assembly = CommonTypes() + R"( @@ -610,7 +609,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -626,7 +625,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } std::string BitTestPreamble() { @@ -665,7 +664,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -693,7 +692,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -723,7 +722,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -753,7 +752,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -781,7 +780,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -809,7 +808,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -839,7 +838,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -869,7 +868,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -897,7 +896,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -925,7 +924,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -955,7 +954,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -985,7 +984,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1013,7 +1012,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1041,7 +1040,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1071,7 +1070,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1101,7 +1100,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 diff --git a/src/reader/spirv/function_call_test.cc b/src/reader/spirv/function_call_test.cc index 5b8ce72f50..0184d16571 100644 --- a/src/reader/spirv/function_call_test.cc +++ b/src/reader/spirv/function_call_test.cc @@ -46,7 +46,7 @@ TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) { OpFunctionEnd )")); ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error(); - const auto got = p->program().AST().to_str(); + const auto got = p->program().to_str(); const char* expect = R"(Module{ Function tint_symbol_1 -> __void () @@ -91,7 +91,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) { { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -107,18 +107,17 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) { } } Return{})")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Return{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ { ScalarConstructor[not set]{42} } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } } @@ -149,7 +148,7 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) { { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_10 @@ -180,17 +179,16 @@ Assignment{ Identifier[not set]{x_1} } Return{})")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Return{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Return{ { ScalarConstructor[not set]{42} } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } } diff --git a/src/reader/spirv/function_cfg_test.cc b/src/reader/spirv/function_cfg_test.cc index 57af7e9bd7..2cc9a84ecb 100644 --- a/src/reader/spirv/function_cfg_test.cc +++ b/src/reader/spirv/function_cfg_test.cc @@ -7361,7 +7361,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7473,7 +7473,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromElse_ForwardWithinElse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7600,7 +7600,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly; - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7791,7 +7791,7 @@ TEST_F(SpvParserTest, EmitBody_If_Empty) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -7827,7 +7827,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_NoElse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7875,7 +7875,7 @@ TEST_F(SpvParserTest, EmitBody_If_NoThen_Else) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7931,7 +7931,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7998,7 +7998,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8070,7 +8070,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8134,7 +8134,7 @@ TEST_F(SpvParserTest, EmitBody_If_Else_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8219,7 +8219,7 @@ TEST_F(SpvParserTest, EmitBody_If_Nest_If) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8309,7 +8309,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_TrueBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8364,7 +8364,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_FalseBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8415,7 +8415,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_BothBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8458,7 +8458,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_UnconditionalBackege) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8509,7 +8509,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_SingleBlockContinue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8574,7 +8574,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_MultiBlockContinue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8648,7 +8648,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_ContinueNestIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8720,7 +8720,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_MultiBlockContinueIsEntireLoop) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8778,7 +8778,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Never) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8838,7 +8838,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_TrueToBody_FalseBreaks) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8905,7 +8905,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_FalseToBody_TrueBreaks) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8979,7 +8979,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_NestedIfContinue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ If{ ( @@ -9037,7 +9037,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyAlwaysBreaks) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9086,7 +9086,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9142,7 +9142,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9204,7 +9204,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue_Early) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9266,7 +9266,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse_Early) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9319,7 +9319,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_NoCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9364,7 +9364,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_OneCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9418,7 +9418,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_TwoCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9478,7 +9478,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_CasesWithDup) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9544,7 +9544,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_NoDupCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9615,7 +9615,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_WithDupCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9687,7 +9687,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_SintValue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9757,7 +9757,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_UintValue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9809,7 +9809,7 @@ TEST_F(SpvParserTest, EmitBody_Return_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Return{} )"; ASSERT_EQ(expect, got); @@ -9835,7 +9835,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -9875,7 +9875,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Return{} } @@ -9905,7 +9905,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Return{ { ScalarConstructor[not set]{2} @@ -9944,7 +9944,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10001,7 +10001,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_Loop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Return{ { @@ -10031,7 +10031,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Discard{} )"; ASSERT_EQ(expect, got); @@ -10057,7 +10057,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10097,7 +10097,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Discard{} } @@ -10119,7 +10119,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Return{} )"; ASSERT_EQ(expect, got); @@ -10145,7 +10145,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10185,7 +10185,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Return{} } @@ -10215,7 +10215,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InNonVoidFunction) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Return{ { ScalarConstructor[not set]{0} @@ -10249,7 +10249,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_MultiBlockLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ continuing { Assignment{ @@ -10284,7 +10284,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_SingleBlockLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10321,7 +10321,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_LastInCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10381,7 +10381,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_NotLastInCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10452,7 +10452,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopBreak_MultiBlockLoop_FromBody) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10534,7 +10534,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ continuing { Assignment{ @@ -10576,7 +10576,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_LastInLoopConstruct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10630,7 +10630,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_BeforeLast) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ If{ ( @@ -10699,7 +10699,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_FromSwitch) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10769,7 +10769,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromThen) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10812,7 +10812,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromElse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10864,7 +10864,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Fallthrough) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10915,7 +10915,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Forward) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11019,7 +11019,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Back_SingleBlock_Back) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11062,7 +11062,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11113,7 +11113,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11171,7 +11171,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11227,7 +11227,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11287,7 +11287,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11348,7 +11348,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11431,7 +11431,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnTrue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11526,7 +11526,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnFalse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11611,7 +11611,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11680,7 +11680,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11747,7 +11747,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11821,7 +11821,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11890,7 +11890,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11948,7 +11948,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12021,7 +12021,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12117,7 +12117,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12256,7 +12256,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12337,7 +12337,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12405,7 +12405,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Continue_FromHeader) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12462,7 +12462,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12534,7 +12534,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12622,7 +12622,7 @@ TEST_F( ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12701,7 +12701,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopContinue_FromSwitch) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -12789,7 +12789,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12886,7 +12886,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12982,7 +12982,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13091,7 +13091,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13188,7 +13188,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13269,7 +13269,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13333,7 +13333,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_IfBreak_IfBreak_Same) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13418,7 +13418,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Fallthrough_Fallthrough_Same) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -13509,7 +13509,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Forward_Forward_Same) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -13578,7 +13578,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = "unhandled case"; ASSERT_EQ(expect, got); } @@ -13613,7 +13613,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = "unhandled case"; ASSERT_EQ(expect, got); } diff --git a/src/reader/spirv/function_composite_test.cc b/src/reader/spirv/function_composite_test.cc index e6070767f4..e5ff9b499d 100644 --- a/src/reader/spirv/function_composite_test.cc +++ b/src/reader/spirv/function_composite_test.cc @@ -87,7 +87,7 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -129,7 +129,7 @@ VariableDeclStatement{ } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Matrix) { @@ -144,7 +144,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -170,7 +170,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Array) { @@ -185,7 +185,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -201,7 +201,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Struct) { @@ -216,7 +216,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -234,7 +234,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } using SpvParserTest_CompositeExtract = SpvParserTest; @@ -251,7 +251,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -267,7 +267,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) { @@ -302,7 +302,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -314,7 +314,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) { @@ -353,7 +353,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -368,7 +368,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Array) { @@ -387,7 +387,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -399,7 +399,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) { @@ -438,7 +438,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -450,7 +450,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { @@ -481,7 +481,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); auto got = fe.ast_body(); - EXPECT_THAT(ToString(p->builder().Symbols(), got), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), got), HasSubstr(R"( VariableConst{ x_2 none @@ -493,8 +493,8 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { } } })")) - << ToString(p->builder().Symbols(), got); - EXPECT_THAT(ToString(p->builder().Symbols(), got), HasSubstr(R"( + << ToString(p->builder(), got); + EXPECT_THAT(ToString(p->builder(), got), HasSubstr(R"( VariableConst{ x_4 none @@ -506,7 +506,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { } } })")) - << ToString(p->builder().Symbols(), got); + << ToString(p->builder(), got); } TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) { @@ -547,7 +547,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -568,7 +568,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } using SpvParserTest_CopyObject = SpvParserTest; @@ -586,7 +586,7 @@ TEST_F(SpvParserTest_CopyObject, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -606,7 +606,7 @@ VariableDeclStatement{ Identifier[not set]{x_1} } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_CopyObject, Pointer) { @@ -625,7 +625,7 @@ TEST_F(SpvParserTest_CopyObject, Pointer) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -645,7 +645,7 @@ VariableDeclStatement{ Identifier[not set]{x_1} } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } using SpvParserTest_VectorShuffle = SpvParserTest; @@ -666,8 +666,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __vec_4__u32 @@ -693,7 +692,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { @@ -709,8 +708,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __vec_4__u32 @@ -752,7 +750,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { @@ -769,8 +767,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_10 none __vec_2__u32 @@ -785,7 +782,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) { @@ -822,7 +819,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, SignedIndex) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto got = ToString(p->builder().Symbols(), fe.ast_body()); + const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ x_10 none @@ -852,7 +849,7 @@ TEST_F(SpvParserTest_VectorExtractDynamic, UnsignedIndex) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto got = ToString(p->builder().Symbols(), fe.ast_body()); + const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(VariableConst{ x_10 none diff --git a/src/reader/spirv/function_conversion_test.cc b/src/reader/spirv/function_conversion_test.cc index 352ee995c0..ec1bf40492 100644 --- a/src/reader/spirv/function_conversion_test.cc +++ b/src/reader/spirv/function_conversion_test.cc @@ -82,7 +82,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -93,7 +93,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { @@ -108,7 +108,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -123,7 +123,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) { @@ -238,8 +238,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -250,7 +249,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { @@ -266,8 +265,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -280,7 +278,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { @@ -296,8 +294,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -308,7 +305,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { @@ -324,8 +321,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -338,7 +334,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) { @@ -387,8 +383,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -401,7 +396,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { @@ -417,8 +412,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -429,7 +423,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { @@ -445,8 +439,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -459,7 +452,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { @@ -475,8 +468,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -487,7 +479,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) { @@ -537,8 +529,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __i32 @@ -549,7 +540,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { @@ -565,8 +556,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __u32 @@ -579,7 +569,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { @@ -595,8 +585,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__i32 @@ -607,7 +596,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { @@ -623,8 +612,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__u32 @@ -637,7 +625,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) { @@ -687,8 +675,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __i32 @@ -701,7 +688,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { @@ -717,8 +704,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __u32 @@ -729,7 +715,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { @@ -745,8 +731,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__i32 @@ -759,7 +744,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { @@ -775,8 +760,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableConst{ x_1 none __vec_2__u32 @@ -787,7 +771,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } // TODO(dneto): OpSConvert // only if multiple widths diff --git a/src/reader/spirv/function_glsl_std_450_test.cc b/src/reader/spirv/function_glsl_std_450_test.cc index 9158de91a5..83523965f5 100644 --- a/src/reader/spirv/function_glsl_std_450_test.cc +++ b/src/reader/spirv/function_glsl_std_450_test.cc @@ -183,7 +183,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -191,14 +191,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { @@ -212,7 +212,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -220,14 +220,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { @@ -241,7 +241,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -249,7 +249,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -257,7 +257,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { @@ -271,7 +271,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -279,7 +279,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -287,7 +287,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { @@ -301,7 +301,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -309,14 +309,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { @@ -330,7 +330,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -338,14 +338,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { @@ -359,7 +359,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -367,7 +367,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -375,7 +375,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { @@ -389,7 +389,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -397,7 +397,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -405,7 +405,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { @@ -419,7 +419,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -427,7 +427,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -436,7 +436,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { @@ -451,7 +451,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -459,7 +459,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -468,7 +468,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { @@ -482,7 +482,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -490,7 +490,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{u1} @@ -498,7 +498,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { @@ -513,7 +513,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -521,7 +521,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2u1} @@ -529,7 +529,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { @@ -543,7 +543,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -551,7 +551,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{i1} @@ -559,7 +559,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { @@ -574,7 +574,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -582,7 +582,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2i1} @@ -590,7 +590,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { @@ -605,7 +605,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -613,7 +613,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v3f1} Identifier[not set]{v3f2} @@ -621,7 +621,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -709,7 +709,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -717,14 +717,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { @@ -739,7 +739,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -747,14 +747,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} ) } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { @@ -769,7 +769,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -777,7 +777,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} Identifier[not set]{i2} @@ -785,7 +785,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { @@ -800,7 +800,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -808,7 +808,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} Identifier[not set]{v2i2} @@ -816,7 +816,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { @@ -831,7 +831,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -839,7 +839,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} Identifier[not set]{i2} @@ -848,7 +848,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { @@ -863,7 +863,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -871,7 +871,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} Identifier[not set]{v2i2} @@ -880,7 +880,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -907,7 +907,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -915,7 +915,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{u1} Identifier[not set]{u2} @@ -923,7 +923,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { @@ -938,7 +938,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -946,7 +946,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2u1} Identifier[not set]{v2u2} @@ -954,7 +954,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { @@ -968,7 +968,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -976,7 +976,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{u1} Identifier[not set]{u2} @@ -985,7 +985,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { @@ -1000,7 +1000,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1008,7 +1008,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2u1} Identifier[not set]{v2u2} @@ -1017,7 +1017,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -1043,7 +1043,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1095,7 +1095,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1153,7 +1153,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1211,7 +1211,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1271,7 +1271,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1329,7 +1329,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1387,7 +1387,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(p->builder().Symbols(), fe.ast_body()); + auto body = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 diff --git a/src/reader/spirv/function_logical_test.cc b/src/reader/spirv/function_logical_test.cc index dc40f0c291..e1c12c8b02 100644 --- a/src/reader/spirv/function_logical_test.cc +++ b/src/reader/spirv/function_logical_test.cc @@ -206,7 +206,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -218,7 +218,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { @@ -233,7 +233,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -249,7 +249,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } struct BinaryData { @@ -296,8 +296,7 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(ss.str())) + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(ss.str())) << assembly; } @@ -703,7 +702,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -719,7 +718,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordEqual_Vector) { @@ -734,7 +733,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -758,7 +757,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { @@ -773,7 +772,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -789,7 +788,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { @@ -804,7 +803,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -828,7 +827,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { @@ -843,7 +842,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -859,7 +858,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { @@ -874,7 +873,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -898,7 +897,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { @@ -913,7 +912,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -929,7 +928,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { @@ -944,7 +943,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -968,7 +967,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { @@ -983,7 +982,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -999,7 +998,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { @@ -1014,7 +1013,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1038,7 +1037,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { @@ -1053,7 +1052,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1069,7 +1068,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { @@ -1084,7 +1083,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1108,7 +1107,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { @@ -1123,7 +1122,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1140,7 +1139,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { @@ -1155,7 +1154,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1172,7 +1171,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { @@ -1187,7 +1186,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1204,7 +1203,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { @@ -1219,7 +1218,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1244,7 +1243,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { @@ -1259,7 +1258,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1288,7 +1287,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } using SpvLogicalTest = SpvParserTestBase<::testing::Test>; @@ -1305,7 +1304,7 @@ TEST_F(SpvLogicalTest, Any) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1324,7 +1323,7 @@ TEST_F(SpvLogicalTest, Any) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvLogicalTest, All) { @@ -1339,7 +1338,7 @@ TEST_F(SpvLogicalTest, All) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1358,7 +1357,7 @@ TEST_F(SpvLogicalTest, All) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsNan_Scalar) { @@ -1373,7 +1372,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1388,7 +1387,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsNan_Vector) { @@ -1403,7 +1402,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1422,7 +1421,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsInf_Scalar) { @@ -1437,7 +1436,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1452,7 +1451,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsInf_Vector) { @@ -1467,7 +1466,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1486,7 +1485,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } // TODO(dneto): Kernel-guarded instructions. diff --git a/src/reader/spirv/function_memory_test.cc b/src/reader/spirv/function_memory_test.cc index 379286cf77..89cfe2ba9a 100644 --- a/src/reader/spirv/function_memory_test.cc +++ b/src/reader/spirv/function_memory_test.cc @@ -51,8 +51,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{true} } @@ -84,8 +83,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} } @@ -113,8 +111,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} } @@ -142,8 +139,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42.000000} } @@ -172,7 +168,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -201,7 +197,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 @@ -243,7 +239,7 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 @@ -281,8 +277,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} })")); @@ -349,14 +344,13 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{z} } ScalarConstructor[not set]{42} -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) { @@ -413,8 +407,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{x_11} @@ -451,8 +444,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} ScalarConstructor[not set]{2} @@ -495,8 +487,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} ScalarConstructor[not set]{2} @@ -538,8 +529,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{age} @@ -587,8 +577,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{age} @@ -601,7 +590,7 @@ Assignment{ Identifier[not set]{ancientness} } ScalarConstructor[not set]{420.000000} -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) { @@ -698,8 +687,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -739,8 +727,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ ArrayAccessor[not set]{ Identifier[not set]{myvar} @@ -848,7 +835,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto got = ToString(p->builder().Symbols(), fe.ast_body()); + const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -865,8 +852,7 @@ Assignment{ ScalarConstructor[not set]{1} } ScalarConstructor[not set]{0} -})")) << got - << p->error(); +})")); } TEST_F(SpvParserTest, @@ -891,7 +877,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto got = ToString(p->builder().Symbols(), fe.ast_body()); + const auto got = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(got, HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -931,8 +917,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), - HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -941,7 +926,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) { ScalarConstructor[not set]{1} } ScalarConstructor[not set]{0} -})")) << ToString(p->builder().Symbols(), fe.ast_body()) +})")) << ToString(p->builder(), fe.ast_body()) << p->error(); } @@ -965,7 +950,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 @@ -985,7 +970,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) { Assignment{ Identifier[not set]{x_2} ScalarConstructor[not set]{0} -})")) << ToString(p->builder().Symbols(), fe.ast_body()) +})")) << ToString(p->builder(), fe.ast_body()) << p->error(); } @@ -1021,7 +1006,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), Eq(R"(VariableDeclStatement{ Variable{ x_2 @@ -1056,7 +1041,7 @@ Assignment{ ScalarConstructor[not set]{0} } Return{} -)")) << ToString(p->builder().Symbols(), fe.ast_body()) +)")) << ToString(p->builder(), fe.ast_body()) << p->error(); } @@ -1109,7 +1094,7 @@ TEST_F(SpvParserTest, ArrayLength) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body_str = ToString(p->builder().Symbols(), fe.ast_body()); + const auto body_str = ToString(p->builder(), fe.ast_body()); EXPECT_THAT(body_str, HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 diff --git a/src/reader/spirv/function_misc_test.cc b/src/reader/spirv/function_misc_test.cc index 6df487a117..809cf38c36 100644 --- a/src/reader/spirv/function_misc_test.cc +++ b/src/reader/spirv/function_misc_test.cc @@ -68,7 +68,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 @@ -108,7 +108,7 @@ VariableDeclStatement{ ScalarConstructor[not set]{0.000000} } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) { @@ -129,7 +129,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 @@ -171,7 +171,7 @@ VariableDeclStatement{ } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { @@ -190,7 +190,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 @@ -212,7 +212,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { @@ -232,7 +232,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 @@ -246,7 +246,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { @@ -265,7 +265,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 @@ -281,7 +281,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { } } } -})")) << ToString(p->builder().Symbols(), fe.ast_body()); +})")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpNop) { @@ -297,8 +297,8 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) { << p->error() << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), Eq(R"(Return{} -)")) << ToString(p->builder().Symbols(), fe.ast_body()); + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), Eq(R"(Return{} +)")) << ToString(p->builder(), fe.ast_body()); } // Test swizzle generation. @@ -325,11 +325,12 @@ TEST_P(SpvParserSwizzleTest, Sample) { auto* result = fe.Swizzle(GetParam().index); if (GetParam().expected_error.empty()) { + Program program(p->program()); EXPECT_TRUE(fe.success()); ASSERT_NE(result, nullptr); std::ostringstream ss; - result->to_str(ss, 0); - auto str = Demangler().Demangle(p->program().Symbols(), ss.str()); + result->to_str(program.Sem(), ss, 0); + auto str = Demangler().Demangle(program.Symbols(), ss.str()); EXPECT_THAT(str, Eq(GetParam().expected_expr)); } else { EXPECT_EQ(result, nullptr); diff --git a/src/reader/spirv/function_var_test.cc b/src/reader/spirv/function_var_test.cc index 288dbe2857..ca6f49a2e5 100644 --- a/src/reader/spirv/function_var_test.cc +++ b/src/reader/spirv/function_var_test.cc @@ -91,7 +91,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_1 @@ -130,7 +130,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ a @@ -169,7 +169,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ a @@ -211,7 +211,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ a @@ -285,7 +285,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ a @@ -345,7 +345,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -360,7 +360,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) { @@ -384,7 +384,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -431,7 +431,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -446,7 +446,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { @@ -466,7 +466,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); const char* expect = R"(VariableDeclStatement{ Variable{ x_200 @@ -501,7 +501,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -516,7 +516,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { @@ -536,7 +536,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -551,7 +551,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { @@ -571,7 +571,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -591,7 +591,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { @@ -611,7 +611,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), + EXPECT_THAT(ToString(p->builder(), fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 @@ -631,7 +631,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { } } } -)")) << ToString(p->builder().Symbols(), fe.ast_body()); +)")) << ToString(p->builder(), fe.ast_body()); } TEST_F(SpvParserTest, @@ -656,7 +656,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ Variable{ @@ -704,7 +704,7 @@ TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ Variable{ x_25 @@ -776,7 +776,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ Variable{ x_25 @@ -875,7 +875,7 @@ TEST_F( FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{0} @@ -993,7 +993,7 @@ TEST_F( // We don't hoist x_1 into its own mutable variable. It is emitted as // a const definition. - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1078,7 +1078,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{true} @@ -1165,7 +1165,7 @@ TEST_F( FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{true} @@ -1248,7 +1248,7 @@ TEST_F(SpvParserTest, // We don't hoist x_1 into its own mutable variable. It is emitted as // a const definition. - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ VariableConst{ x_1 @@ -1322,7 +1322,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ VariableDeclStatement{ Variable{ @@ -1466,7 +1466,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(Loop{ VariableDeclStatement{ Variable{ @@ -1624,7 +1624,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ VariableConst{ x_101 @@ -1793,7 +1793,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ VariableConst{ x_101 @@ -1915,7 +1915,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ VariableConst{ x_101 @@ -2023,7 +2023,7 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(p->builder().Symbols(), fe.ast_body()); + auto got = ToString(p->builder(), fe.ast_body()); auto* expect = R"(VariableDeclStatement{ Variable{ x_101_phi diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 8c0b629a5c..3173fd64d0 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -1504,7 +1504,8 @@ TypedExpression ParserImpl::RectifyOperandSignedness( } auto* type = expr.type; if (!type) { - Fail() << "internal error: unmapped type for: " << expr.expr->str() << "\n"; + Fail() << "internal error: unmapped type for: " + << expr.expr->str(builder_.Sem()) << "\n"; return {}; } if (requires_unsigned) { diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc index 12d67b9b35..02dead28d4 100644 --- a/src/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/reader/spirv/parser_impl_convert_type_test.cc @@ -564,10 +564,12 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); + + Program program = p->program(); + std::stringstream ss; - type->As()->impl()->to_str(ss, 0); - EXPECT_THAT(Demangler().Demangle(p->program().Symbols(), ss.str()), - Eq(R"(Struct{ + type->As()->impl()->to_str(program.Sem(), ss, 0); + EXPECT_THAT(Demangler().Demangle(program.Symbols(), ss.str()), Eq(R"(Struct{ StructMember{field0: __u32} StructMember{field1: __f32} } @@ -586,10 +588,12 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); + + Program program = p->program(); + std::stringstream ss; - type->As()->impl()->to_str(ss, 0); - EXPECT_THAT(Demangler().Demangle(p->program().Symbols(), ss.str()), - Eq(R"(Struct{ + type->As()->impl()->to_str(program.Sem(), ss, 0); + EXPECT_THAT(Demangler().Demangle(program.Symbols(), ss.str()), Eq(R"(Struct{ [[block]] StructMember{field0: __u32} } @@ -612,10 +616,12 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); EXPECT_TRUE(type->Is()); + + Program program = p->program(); + std::stringstream ss; - type->As()->impl()->to_str(ss, 0); - EXPECT_THAT(Demangler().Demangle(p->program().Symbols(), ss.str()), - Eq(R"(Struct{ + type->As()->impl()->to_str(program.Sem(), ss, 0); + EXPECT_THAT(Demangler().Demangle(program.Symbols(), ss.str()), Eq(R"(Struct{ StructMember{[[ offset 0 ]] field0: __f32} StructMember{[[ offset 8 ]] field1: __vec_2__f32} StructMember{[[ offset 16 ]] field2: __mat_2_2__f32} diff --git a/src/reader/spirv/parser_impl_function_decl_test.cc b/src/reader/spirv/parser_impl_function_decl_test.cc index d9f5458ac2..80c47be43e 100644 --- a/src/reader/spirv/parser_impl_function_decl_test.cc +++ b/src/reader/spirv/parser_impl_function_decl_test.cc @@ -55,7 +55,7 @@ TEST_F(SpvParserTest, EmitFunctions_NoFunctions) { EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, Not(HasSubstr("Function{"))); } @@ -67,7 +67,7 @@ TEST_F(SpvParserTest, EmitFunctions_FunctionWithoutBody) { EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, Not(HasSubstr("Function{"))); } @@ -83,7 +83,7 @@ OpFunctionEnd)"; ASSERT_TRUE(p->BuildAndParseInternalModule()); ASSERT_TRUE(p->error().empty()) << p->error(); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, HasSubstr(R"( Function )" + program.Symbols().Get("main").to_str() + R"( -> __void @@ -104,7 +104,7 @@ OpFunctionEnd)"; ASSERT_TRUE(p->BuildAndParseInternalModule()); ASSERT_TRUE(p->error().empty()) << p->error(); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, HasSubstr(R"( Function )" + program.Symbols().Get("main").to_str() + R"( -> __void @@ -125,7 +125,7 @@ OpFunctionEnd)"; ASSERT_TRUE(p->BuildAndParseInternalModule()); ASSERT_TRUE(p->error().empty()) << p->error(); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, HasSubstr(R"( Function )" + program.Symbols().Get("main").to_str() + R"( -> __void @@ -148,7 +148,7 @@ OpFunctionEnd)"; ASSERT_TRUE(p->BuildAndParseInternalModule()); ASSERT_TRUE(p->error().empty()) << p->error(); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, HasSubstr(R"( Function )" + program.Symbols().Get("frag_main").to_str() + R"( -> __void @@ -173,7 +173,7 @@ TEST_F(SpvParserTest, EmitFunctions_VoidFunctionWithoutParams) { EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); Program program = p->program(); - const auto program_ast = program.AST().to_str(); + const auto program_ast = program.to_str(); EXPECT_THAT(program_ast, HasSubstr(R"( Function )" + program.Symbols().Get("main").to_str() + R"( -> __void diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc index 29779585e0..78422fd810 100644 --- a/src/reader/spirv/parser_impl_handle_test.cc +++ b/src/reader/spirv/parser_impl_handle_test.cc @@ -3788,7 +3788,7 @@ TEST_P(SpvParserTest_ImageCoordsTest, MakeCoordinateOperandsForImageAccess) { for (auto* expr : result) { ASSERT_NE(expr, nullptr); result_strings.push_back( - Demangler().Demangle(program.Symbols(), expr->str())); + Demangler().Demangle(program.Symbols(), expr->str(program.Sem()))); } EXPECT_THAT(result_strings, ::testing::ContainerEq(GetParam().expected_expressions)); diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index 13e6c0fed5..1acf2d1228 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -71,7 +71,7 @@ TEST_F(SpvModuleScopeVarParserTest, NoVar) { auto p = parser(test::Assemble("")); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); - const auto module_ast = p->program().AST().to_str(); + const auto module_ast = p->program().to_str(); EXPECT_THAT(module_ast, Not(HasSubstr("Variable"))); } @@ -2002,7 +2002,10 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(p->error().empty()); - EXPECT_THAT(ToString(p->builder().Symbols(), fe.ast_body()), HasSubstr(R"( + + Program program = p->program(); + + EXPECT_THAT(ToString(program, fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -2015,7 +2018,7 @@ TEST_F(SpvModuleScopeVarParserTest, ScalarSpecConstant_UsedInFunction) { } } })")) - << ToString(p->builder().Symbols(), fe.ast_body()); + << ToString(program, fe.ast_body()); } } // namespace diff --git a/src/reader/spirv/parser_impl_test_helper.h b/src/reader/spirv/parser_impl_test_helper.h index 3a3acad484..89aa2af533 100644 --- a/src/reader/spirv/parser_impl_test_helper.h +++ b/src/reader/spirv/parser_impl_test_helper.h @@ -62,16 +62,29 @@ class SpvParserTestBase : public T { using SpvParserTest = SpvParserTestBase<::testing::Test>; /// Returns the string dump of a statement list. -/// @param symbols the SymbolTable +/// @param program the Program /// @param stmts the statement list /// @returns the string dump of a statement list. -inline std::string ToString(const SymbolTable& symbols, +inline std::string ToString(const Program& program, const ast::StatementList& stmts) { std::ostringstream outs; for (const auto* stmt : stmts) { - stmt->to_str(outs, 0); + stmt->to_str(program.Sem(), outs, 0); } - return Demangler().Demangle(symbols, outs.str()); + return Demangler().Demangle(program.Symbols(), outs.str()); +} + +/// Returns the string dump of a statement list. +/// @param builder the ProgramBuilder +/// @param stmts the statement list +/// @returns the string dump of a statement list. +inline std::string ToString(ProgramBuilder& builder, + const ast::StatementList& stmts) { + std::ostringstream outs; + for (const auto* stmt : stmts) { + stmt->to_str(builder.Sem(), outs, 0); + } + return Demangler().Demangle(builder.Symbols(), outs.str()); } } // namespace spirv diff --git a/src/reader/wgsl/parser_impl_for_stmt_test.cc b/src/reader/wgsl/parser_impl_for_stmt_test.cc index 42af07d128..ad2a0b7b40 100644 --- a/src/reader/wgsl/parser_impl_for_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_for_stmt_test.cc @@ -37,8 +37,8 @@ class ForStmtTest : public ParserImplTest { EXPECT_FALSE(e_for.errored); EXPECT_FALSE(p_for->has_error()) << p_for->error(); - std::string loop = ast::BlockStatement({}, e_loop.value).str(); - std::string for_ = ast::BlockStatement({}, e_for.value).str(); + std::string loop = ast::BlockStatement({}, e_loop.value).str(Sem()); + std::string for_ = ast::BlockStatement({}, e_for.value).str(Sem()); EXPECT_EQ(loop, for_); } }; diff --git a/src/reader/wgsl/parser_impl_switch_body_test.cc b/src/reader/wgsl/parser_impl_switch_body_test.cc index ba98d01896..b596149d4f 100644 --- a/src/reader/wgsl/parser_impl_switch_body_test.cc +++ b/src/reader/wgsl/parser_impl_switch_body_test.cc @@ -116,8 +116,8 @@ TEST_F(ParserImplTest, SwitchBody_Case_MultipleSelectors) { EXPECT_FALSE(e->IsDefault()); ASSERT_EQ(e->body()->size(), 0u); ASSERT_EQ(e->selectors().size(), 2u); - ASSERT_EQ(e->selectors()[0]->to_str(), "1"); - ASSERT_EQ(e->selectors()[1]->to_str(), "2"); + ASSERT_EQ(e->selectors()[0]->to_str(Sem()), "1"); + ASSERT_EQ(e->selectors()[1]->to_str(Sem()), "2"); } TEST_F(ParserImplTest, SwitchBody_Case_MultipleSelectorsMissingColon) { diff --git a/src/semantic/info.h b/src/semantic/info.h new file mode 100644 index 0000000000..fff6558944 --- /dev/null +++ b/src/semantic/info.h @@ -0,0 +1,43 @@ +// Copyright 2021 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SRC_SEMANTIC_INFO_H_ +#define SRC_SEMANTIC_INFO_H_ + +namespace tint { + +namespace semantic { + +/// Info will hold all the resolved semantic information for a Program. +class Info { + public: + /// Constructor + Info(); + + /// Move constructor + Info(Info&&); + + /// Destructor + ~Info(); + + /// Move assignment operator + /// @param rhs the Program to move + /// @return this Program + Info& operator=(Info&& rhs); +}; + +} // namespace semantic +} // namespace tint + +#endif // SRC_SEMANTIC_INFO_H_ diff --git a/src/semantic/sem_info.cc b/src/semantic/sem_info.cc new file mode 100644 index 0000000000..ddd3de58fd --- /dev/null +++ b/src/semantic/sem_info.cc @@ -0,0 +1,29 @@ +// Copyright 2021 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/semantic/info.h" + +namespace tint { +namespace semantic { + +Info::Info() = default; + +Info::Info(Info&&) = default; + +Info::~Info() = default; + +Info& Info::operator=(Info&&) = default; + +} // namespace semantic +} // namespace tint diff --git a/src/type_determiner.cc b/src/type_determiner.cc index 518f5c9d59..65ec83f9a1 100644 --- a/src/type_determiner.cc +++ b/src/type_determiner.cc @@ -288,8 +288,8 @@ bool TypeDeterminer::DetermineResultType(ast::Statement* stmt) { return DetermineResultType(v->variable()->constructor()); } - set_error(stmt->source(), - "unknown statement type for type determination: " + stmt->str()); + set_error(stmt->source(), "unknown statement type for type determination: " + + stmt->str(builder_->Sem())); return false; } diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 1dd3d6ebe2..50d3f2725c 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -76,7 +76,9 @@ class FakeStmt : public ast::Statement { explicit FakeStmt(Source source) : ast::Statement(source) {} FakeStmt* Clone(CloneContext*) const override { return nullptr; } bool IsValid() const override { return true; } - void to_str(std::ostream& out, size_t) const override { out << "Fake"; } + void to_str(const semantic::Info&, std::ostream& out, size_t) const override { + out << "Fake"; + } }; class FakeExpr : public ast::Expression { @@ -84,7 +86,7 @@ class FakeExpr : public ast::Expression { explicit FakeExpr(Source source) : ast::Expression(source) {} FakeExpr* Clone(CloneContext*) const override { return nullptr; } bool IsValid() const override { return true; } - void to_str(std::ostream&, size_t) const override {} + void to_str(const semantic::Info&, std::ostream&, size_t) const override {} }; class TypeDeterminerHelper : public ProgramBuilder { diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index 6beadbf7d1..0c418a1433 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -360,9 +360,10 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { ? selector->As()->value() : selector->As()->value()); if (selector_set.count(v)) { - auto v_str = selector->type()->Is() - ? selector->As()->to_str() - : selector->As()->to_str(); + auto v_str = + selector->type()->Is() + ? selector->As()->to_str(program_->Sem()) + : selector->As()->to_str(program_->Sem()); add_error(case_stmt->source(), "v-0027", "a literal value must not appear more than once in " "the case selectors for a switch statement: '" + diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index ac24076114..e7ec1ce04f 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1141,7 +1141,7 @@ bool GeneratorImpl::EmitExpression(std::ostream& pre, return EmitUnaryOp(pre, out, u); } - error_ = "unknown expression type: " + expr->str(); + error_ = "unknown expression type: " + expr->str(program_->Sem()); return false; } @@ -2179,7 +2179,7 @@ bool GeneratorImpl::EmitStatement(std::ostream& out, ast::Statement* stmt) { return EmitVariable(out, v->variable(), false); } - error_ = "unknown statement type: " + stmt->str(); + error_ = "unknown statement type: " + stmt->str(program_->Sem()); return false; } diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 34a1390ccb..eaae6c0e3c 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1177,7 +1177,7 @@ bool GeneratorImpl::EmitExpression(ast::Expression* expr) { return EmitUnaryOp(u); } - error_ = "unknown expression type: " + expr->str(); + error_ = "unknown expression type: " + expr->str(program_->Sem()); return false; } @@ -1844,7 +1844,7 @@ bool GeneratorImpl::EmitStatement(ast::Statement* stmt) { return EmitVariable(v->variable(), false); } - error_ = "unknown statement type: " + stmt->str(); + error_ = "unknown statement type: " + stmt->str(program_->Sem()); return false; } @@ -2032,7 +2032,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) { } current_offset = offset; } else { - error_ = "unsupported member decoration: " + deco->str(); + error_ = "unsupported member decoration: " + deco->str(program_->Sem()); return false; } } diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 3d1b0717d0..4fb1b76d81 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -533,7 +533,7 @@ uint32_t Builder::GenerateExpression(ast::Expression* expr) { return GenerateUnaryOpExpression(u); } - error_ = "unknown expression type: " + expr->str(); + error_ = "unknown expression type: " + expr->str(program_->Sem()); return 0; } @@ -1091,7 +1091,7 @@ uint32_t Builder::GenerateAccessorExpression(ast::Expression* expr) { } } else { - error_ = "invalid accessor in list: " + accessor->str(); + error_ = "invalid accessor in list: " + accessor->str(program_->Sem()); return 0; } } @@ -2763,7 +2763,7 @@ bool Builder::GenerateStatement(ast::Statement* stmt) { return GenerateVariableDeclStatement(v); } - error_ = "Unknown statement: " + stmt->str(); + error_ = "Unknown statement: " + stmt->str(program_->Sem()); return false; } diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index e2add776de..20561e19de 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -550,7 +550,7 @@ bool GeneratorImpl::EmitStructType(const type::Struct* str) { auto* impl = str->impl(); for (auto* deco : impl->decorations()) { out_ << "[["; - deco->to_str(out_, 0); + deco->to_str(program_->Sem(), out_, 0); out_ << "]]" << std::endl; } out_ << "struct " << program_->Symbols().NameFor(str->symbol()) << " {" @@ -817,7 +817,7 @@ bool GeneratorImpl::EmitStatement(ast::Statement* stmt) { return EmitVariable(v->variable()); } - error_ = "unknown statement type: " + stmt->str(); + error_ = "unknown statement type: " + stmt->str(program_->Sem()); return false; }