ast: Remove to_str() and type_name()
This is no longer used. Fixed: tint:1225 Change-Id: I0cfe9955687a2b7ded3e645c573f3bffbc2f1f84 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66380 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
a5b3f07ec7
commit
d1ee47a1cd
|
@ -69,8 +69,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
// Clone the src program to dst
|
||||
tint::Program dst(src.Clone());
|
||||
|
||||
// Expect the demangled AST printed with to_str() to match
|
||||
ASSERT_EQ(src.to_str(), dst.to_str());
|
||||
// Expect the printed strings to match
|
||||
ASSERT_EQ(tint::Program::printer(&src), tint::Program::printer(&dst));
|
||||
|
||||
// Check that none of the AST nodes or type pointers in dst are found in src
|
||||
std::unordered_set<tint::ast::Node*> src_nodes;
|
||||
|
|
|
@ -69,7 +69,6 @@ struct Options {
|
|||
std::string output_file = "-"; // Default to stdout
|
||||
|
||||
bool parse_only = false;
|
||||
bool dump_ast = false;
|
||||
bool disable_workgroup_init = false;
|
||||
bool validate = false;
|
||||
bool demangle = false;
|
||||
|
@ -409,8 +408,6 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
|
|||
opts->transforms = split_transform_names(args[i]);
|
||||
} else if (arg == "--parse-only") {
|
||||
opts->parse_only = true;
|
||||
} else if (arg == "--dump-ast") {
|
||||
opts->dump_ast = true;
|
||||
} else if (arg == "--disable-workgroup-init") {
|
||||
opts->disable_workgroup_init = true;
|
||||
} else if (arg == "--demangle") {
|
||||
|
@ -1021,10 +1018,6 @@ int main(int argc, const char** argv) {
|
|||
diag_formatter.format(program->Diagnostics(), diag_printer.get());
|
||||
}
|
||||
|
||||
if (options.dump_ast) {
|
||||
std::cout << std::endl << program->to_str(options.demangle) << std::endl;
|
||||
}
|
||||
|
||||
if (!program->IsValid()) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,7 @@ Alias::Alias(ProgramID program_id,
|
|||
const Source& source,
|
||||
const Symbol& name,
|
||||
Type* subtype)
|
||||
: Base(program_id, source, name),
|
||||
subtype_(subtype),
|
||||
type_name_("__alias_" + name.to_str() + subtype->type_name()) {
|
||||
: Base(program_id, source, name), subtype_(subtype) {
|
||||
TINT_ASSERT(AST, subtype_);
|
||||
}
|
||||
|
||||
|
@ -35,10 +33,6 @@ Alias::Alias(Alias&&) = default;
|
|||
|
||||
Alias::~Alias() = default;
|
||||
|
||||
std::string Alias::type_name() const {
|
||||
return type_name_;
|
||||
}
|
||||
|
||||
Alias* Alias::Clone(CloneContext* ctx) const {
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
|
|
|
@ -45,9 +45,6 @@ class Alias : public Castable<Alias, TypeDecl> {
|
|||
/// @returns the alias type
|
||||
Type* type() const { return subtype_; }
|
||||
|
||||
/// @returns the type_name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// Clones this type and all transitive types using the `CloneContext` `ctx`.
|
||||
/// @param ctx the clone context
|
||||
/// @return the newly cloned type
|
||||
|
@ -55,7 +52,6 @@ class Alias : public Castable<Alias, TypeDecl> {
|
|||
|
||||
private:
|
||||
Type* const subtype_;
|
||||
std::string const type_name_;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -40,24 +40,6 @@ TEST_F(AstAliasTest, Create) {
|
|||
EXPECT_EQ(a->type(), u32);
|
||||
}
|
||||
|
||||
// Check for linear-time evaluation of Alias::type_name().
|
||||
// If type_name() is non-linear, this test should noticeably stall.
|
||||
// See: crbug.com/1200936
|
||||
TEST_F(AstAliasTest, TypeName_LinearTime) {
|
||||
Type* type = ty.i32();
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
type = ty.Of(Alias(Symbols().New(), type));
|
||||
}
|
||||
for (int i = 0; i < 16384; i++) {
|
||||
type->type_name();
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AstAliasTest, TypeName) {
|
||||
auto* at = Alias("Particle", create<I32>());
|
||||
EXPECT_EQ(at->type_name(), "__alias_$1__i32");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -30,10 +30,10 @@ std::string SizeExprToString(const ast::Expression* size,
|
|||
if (auto* ident = size->As<ast::IdentifierExpression>()) {
|
||||
if (symbols) {
|
||||
return symbols->NameFor(ident->symbol());
|
||||
} else {
|
||||
return ident->symbol().to_str();
|
||||
}
|
||||
} else if (auto* scalar = size->As<ast::ScalarConstructorExpression>()) {
|
||||
return "<unknown>";
|
||||
}
|
||||
if (auto* scalar = size->As<ast::ScalarConstructorExpression>()) {
|
||||
auto* literal = scalar->literal()->As<ast::IntLiteral>();
|
||||
if (literal) {
|
||||
return std::to_string(literal->value_as_u32());
|
||||
|
@ -59,22 +59,6 @@ Array::Array(Array&&) = default;
|
|||
|
||||
Array::~Array() = default;
|
||||
|
||||
std::string Array::type_name() const {
|
||||
TINT_ASSERT(AST, subtype_);
|
||||
|
||||
std::string type_name = "__array" + subtype_->type_name();
|
||||
if (!IsRuntimeArray()) {
|
||||
type_name += "_" + SizeExprToString(size_);
|
||||
}
|
||||
for (auto* deco : decos_) {
|
||||
if (auto* stride = deco->As<ast::StrideDecoration>()) {
|
||||
type_name += "_stride_" + std::to_string(stride->stride());
|
||||
}
|
||||
}
|
||||
|
||||
return type_name;
|
||||
}
|
||||
|
||||
std::string Array::FriendlyName(const SymbolTable& symbols) const {
|
||||
std::ostringstream out;
|
||||
for (auto* deco : decos_) {
|
||||
|
|
|
@ -58,9 +58,6 @@ class Array : public Castable<Array, Type> {
|
|||
/// @returns the array size, or nullptr for a runtime array
|
||||
ast::Expression* Size() const { return size_; }
|
||||
|
||||
/// @returns the name for the type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -46,16 +46,5 @@ ArrayAccessorExpression* ArrayAccessorExpression::Clone(
|
|||
return ctx->dst->create<ArrayAccessorExpression>(src, arr, idx);
|
||||
}
|
||||
|
||||
void ArrayAccessorExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -49,14 +49,6 @@ class ArrayAccessorExpression
|
|||
/// @return the newly cloned node
|
||||
ArrayAccessorExpression* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
ArrayAccessorExpression(const ArrayAccessorExpression&) = delete;
|
||||
|
||||
|
|
|
@ -87,18 +87,6 @@ TEST_F(ArrayAccessorExpressionTest, Assert_DifferentProgramID_Index) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(ArrayAccessorExpressionTest, ToStr) {
|
||||
auto* ary = Expr("ary");
|
||||
auto* idx = Expr("idx");
|
||||
|
||||
auto* exp = create<ArrayAccessorExpression>(ary, idx);
|
||||
EXPECT_EQ(str(exp), R"(ArrayAccessor[not set]{
|
||||
Identifier[not set]{ary}
|
||||
Identifier[not set]{idx}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -41,12 +41,6 @@ TEST_F(AstArrayTest, CreateRuntimeArray) {
|
|||
EXPECT_TRUE(arr->IsRuntimeArray());
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, TypeName) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, nullptr, DecorationList{});
|
||||
EXPECT_EQ(arr->type_name(), "__array__i32");
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, FriendlyName_RuntimeSized) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, nullptr, DecorationList{});
|
||||
|
@ -72,31 +66,6 @@ TEST_F(AstArrayTest, FriendlyName_WithStride) {
|
|||
EXPECT_EQ(arr->FriendlyName(Symbols()), "[[stride(32)]] array<i32, 5>");
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, TypeName_RuntimeSized) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, nullptr, DecorationList{});
|
||||
EXPECT_EQ(arr->type_name(), "__array__i32");
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, TypeName_LiteralSized) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, Expr(3), DecorationList{});
|
||||
EXPECT_EQ(arr->type_name(), "__array__i32_3");
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, TypeName_ConstantSized) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr = create<Array>(i32, Expr("size"), DecorationList{});
|
||||
EXPECT_EQ(arr->type_name(), "__array__i32_$1");
|
||||
}
|
||||
|
||||
TEST_F(AstArrayTest, TypeName_WithStride) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* arr =
|
||||
create<Array>(i32, Expr(3), DecorationList{create<StrideDecoration>(16)});
|
||||
EXPECT_EQ(arr->type_name(), "__array__i32_3_stride_16");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -44,16 +44,5 @@ AssignmentStatement* AssignmentStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<AssignmentStatement>(src, l, r);
|
||||
}
|
||||
|
||||
void AssignmentStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Assignment{" << std::endl;
|
||||
lhs_->to_str(sem, out, indent + 2);
|
||||
rhs_->to_str(sem, out, indent + 2);
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -48,14 +48,6 @@ class AssignmentStatement : public Castable<AssignmentStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
AssignmentStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
AssignmentStatement(const AssignmentStatement&) = delete;
|
||||
|
||||
|
|
|
@ -89,18 +89,6 @@ TEST_F(AssignmentStatementTest, Assert_DifferentProgramID_RHS) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(AssignmentStatementTest, ToStr) {
|
||||
auto* lhs = Expr("lhs");
|
||||
auto* rhs = Expr("rhs");
|
||||
|
||||
auto* stmt = create<AssignmentStatement>(lhs, rhs);
|
||||
EXPECT_EQ(str(stmt), R"(Assignment{
|
||||
Identifier[not set]{lhs}
|
||||
Identifier[not set]{rhs}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "src/ast/texture.h"
|
||||
#include "src/ast/u32.h"
|
||||
#include "src/ast/vector.h"
|
||||
#include "src/symbol_table.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::Type);
|
||||
|
||||
|
@ -109,10 +110,5 @@ bool Type::is_handle() const {
|
|||
return IsAnyOf<Sampler, Texture>();
|
||||
}
|
||||
|
||||
void Type::to_str(const sem::Info&, std::ostream& out, size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << type_name();
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -24,12 +24,6 @@ namespace ast {
|
|||
Atomic::Atomic(ProgramID program_id, const Source& source, Type* const subtype)
|
||||
: Base(program_id, source), subtype_(subtype) {}
|
||||
|
||||
std::string Atomic::type_name() const {
|
||||
std::ostringstream out;
|
||||
out << "__atomic" << subtype_->type_name();
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string Atomic::FriendlyName(const SymbolTable& symbols) const {
|
||||
std::ostringstream out;
|
||||
out << "atomic<" << subtype_->FriendlyName(symbols) << ">";
|
||||
|
|
|
@ -37,9 +37,6 @@ class Atomic : public Castable<Atomic, Type> {
|
|||
/// @returns the pointee type
|
||||
Type* type() const { return const_cast<Type*>(subtype_); }
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -29,12 +29,6 @@ TEST_F(AstAtomicTest, Creation) {
|
|||
EXPECT_EQ(p->type(), i32);
|
||||
}
|
||||
|
||||
TEST_F(AstAtomicTest, TypeName) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* p = create<Atomic>(i32);
|
||||
EXPECT_EQ(p->type_name(), "__atomic__i32");
|
||||
}
|
||||
|
||||
TEST_F(AstAtomicTest, FriendlyName) {
|
||||
auto* i32 = create<I32>();
|
||||
auto* p = create<Atomic>(i32);
|
||||
|
|
|
@ -46,20 +46,5 @@ BinaryExpression* BinaryExpression::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<BinaryExpression>(src, op_, l, r);
|
||||
}
|
||||
|
||||
void BinaryExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
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(sem, out, indent + 2);
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -120,14 +120,6 @@ class BinaryExpression : public Castable<BinaryExpression, Expression> {
|
|||
/// @return the newly cloned node
|
||||
BinaryExpression* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
BinaryExpression(const BinaryExpression&) = delete;
|
||||
|
||||
|
|
|
@ -90,19 +90,6 @@ TEST_F(BinaryExpressionTest, Assert_DifferentProgramID_RHS) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(BinaryExpressionTest, ToStr) {
|
||||
auto* lhs = Expr("lhs");
|
||||
auto* rhs = Expr("rhs");
|
||||
|
||||
auto* r = create<BinaryExpression>(BinaryOp::kEqual, lhs, rhs);
|
||||
EXPECT_EQ(str(r), R"(Binary[not set]{
|
||||
Identifier[not set]{lhs}
|
||||
equal
|
||||
Identifier[not set]{rhs}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -34,13 +34,6 @@ std::string BindingDecoration::name() const {
|
|||
return "binding";
|
||||
}
|
||||
|
||||
void BindingDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "BindingDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
||||
BindingDecoration* BindingDecoration::Clone(CloneContext* ctx) const {
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
|
|
|
@ -38,14 +38,6 @@ class BindingDecoration : public Castable<BindingDecoration, Decoration> {
|
|||
/// @returns the WGSL name for the decoration
|
||||
std::string name() const 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
|
@ -26,12 +26,6 @@ TEST_F(BindingDecorationTest, Creation) {
|
|||
EXPECT_EQ(2u, d->value());
|
||||
}
|
||||
|
||||
TEST_F(BindingDecorationTest, ToStr) {
|
||||
auto* d = create<BindingDecoration>(2);
|
||||
EXPECT_EQ(str(d), R"(BindingDecoration{2}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -42,16 +42,5 @@ BitcastExpression* BitcastExpression::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<BitcastExpression>(src, ty, e);
|
||||
}
|
||||
|
||||
void BitcastExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
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;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -50,14 +50,6 @@ class BitcastExpression : public Castable<BitcastExpression, Expression> {
|
|||
/// @return the newly cloned node
|
||||
BitcastExpression* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
BitcastExpression(const BitcastExpression&) = delete;
|
||||
|
||||
|
|
|
@ -76,16 +76,6 @@ TEST_F(BitcastExpressionTest, Assert_DifferentProgramID_Expr) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, ToStr) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), expr);
|
||||
EXPECT_EQ(str(exp), R"(Bitcast[not set]<__f32>{
|
||||
Identifier[not set]{expr}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -42,19 +42,5 @@ BlockStatement* BlockStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<BlockStatement>(src, stmts);
|
||||
}
|
||||
|
||||
void BlockStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Block{" << std::endl;
|
||||
|
||||
for (auto* stmt : *this) {
|
||||
stmt->to_str(sem, out, indent + 2);
|
||||
}
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -77,14 +77,6 @@ class BlockStatement : public Castable<BlockStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
BlockStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
BlockStatement(const BlockStatement&) = delete;
|
||||
|
||||
|
|
|
@ -66,17 +66,6 @@ TEST_F(BlockStatementTest, Assert_DifferentProgramID_Statement) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(BlockStatementTest, ToStr) {
|
||||
auto* b = create<BlockStatement>(ast::StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
|
||||
EXPECT_EQ(str(b), R"(Block{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -28,10 +28,6 @@ Bool::Bool(Bool&&) = default;
|
|||
|
||||
Bool::~Bool() = default;
|
||||
|
||||
std::string Bool::type_name() const {
|
||||
return "__bool";
|
||||
}
|
||||
|
||||
std::string Bool::FriendlyName(const SymbolTable&) const {
|
||||
return "bool";
|
||||
}
|
||||
|
|
|
@ -39,9 +39,6 @@ class Bool : public Castable<Bool, Type> {
|
|||
Bool(Bool&&);
|
||||
~Bool() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -26,10 +26,6 @@ BoolLiteral::BoolLiteral(ProgramID program_id, const Source& source, bool value)
|
|||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
||||
std::string BoolLiteral::to_str(const sem::Info&) const {
|
||||
return value_ ? "true" : "false";
|
||||
}
|
||||
|
||||
std::string BoolLiteral::name() const {
|
||||
return value_ ? "__bool_true" : "__bool_false";
|
||||
}
|
||||
|
|
|
@ -40,10 +40,6 @@ class BoolLiteral : public Castable<BoolLiteral, Literal> {
|
|||
/// @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 sem::Info& sem) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
|
@ -34,14 +34,6 @@ TEST_F(BoolLiteralTest, False) {
|
|||
ASSERT_TRUE(b->IsFalse());
|
||||
}
|
||||
|
||||
TEST_F(BoolLiteralTest, ToStr) {
|
||||
auto* t = create<BoolLiteral>(true);
|
||||
auto* f = create<BoolLiteral>(false);
|
||||
|
||||
EXPECT_EQ(str(t), "true");
|
||||
EXPECT_EQ(str(f), "false");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -22,11 +22,6 @@ namespace {
|
|||
|
||||
using AstBoolTest = TestHelper;
|
||||
|
||||
TEST_F(AstBoolTest, TypeName) {
|
||||
auto* b = create<Bool>();
|
||||
EXPECT_EQ(b->type_name(), "__bool");
|
||||
}
|
||||
|
||||
TEST_F(AstBoolTest, FriendlyName) {
|
||||
auto* b = create<Bool>();
|
||||
EXPECT_EQ(b->FriendlyName(Symbols()), "bool");
|
||||
|
|
|
@ -34,12 +34,5 @@ BreakStatement* BreakStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<BreakStatement>(src);
|
||||
}
|
||||
|
||||
void BreakStatement::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Break{}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -37,14 +37,6 @@ class BreakStatement : public Castable<BreakStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
BreakStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
BreakStatement(const BreakStatement&) = delete;
|
||||
};
|
||||
|
|
|
@ -34,12 +34,6 @@ TEST_F(BreakStatementTest, IsBreak) {
|
|||
EXPECT_TRUE(stmt->Is<BreakStatement>());
|
||||
}
|
||||
|
||||
TEST_F(BreakStatementTest, ToStr) {
|
||||
auto* stmt = create<BreakStatement>();
|
||||
EXPECT_EQ(str(stmt), R"(Break{}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -34,13 +34,6 @@ std::string BuiltinDecoration::name() const {
|
|||
return "builtin";
|
||||
}
|
||||
|
||||
void BuiltinDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "BuiltinDecoration{" << builtin_ << "}" << std::endl;
|
||||
}
|
||||
|
||||
BuiltinDecoration* BuiltinDecoration::Clone(CloneContext* ctx) const {
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
|
|
|
@ -41,14 +41,6 @@ class BuiltinDecoration : public Castable<BuiltinDecoration, Decoration> {
|
|||
/// @returns the WGSL name for the decoration
|
||||
std::string name() const 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
|
@ -26,12 +26,6 @@ TEST_F(BuiltinDecorationTest, Creation) {
|
|||
EXPECT_EQ(Builtin::kFragDepth, d->value());
|
||||
}
|
||||
|
||||
TEST_F(BuiltinDecorationTest, ToStr) {
|
||||
auto* d = create<BuiltinDecoration>(Builtin::kFragDepth);
|
||||
EXPECT_EQ(str(d), R"(BuiltinDecoration{frag_depth}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -46,24 +46,5 @@ CallExpression* CallExpression::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<CallExpression>(src, fn, p);
|
||||
}
|
||||
|
||||
void CallExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
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* arg : args_)
|
||||
arg->to_str(sem, out, indent + 4);
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << ")" << std::endl;
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -50,14 +50,6 @@ class CallExpression : public Castable<CallExpression, Expression> {
|
|||
/// @return the newly cloned node
|
||||
CallExpression* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
CallExpression(const CallExpression&) = delete;
|
||||
|
||||
|
|
|
@ -94,34 +94,6 @@ TEST_F(CallExpressionTest, Assert_DifferentProgramID_Param) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(CallExpressionTest, ToStr_NoParams) {
|
||||
auto* func = Expr("func");
|
||||
auto* stmt = create<CallExpression>(func, ExpressionList{});
|
||||
EXPECT_EQ(str(stmt), R"(Call[not set]{
|
||||
Identifier[not set]{func}
|
||||
(
|
||||
)
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(CallExpressionTest, ToStr_WithParams) {
|
||||
auto* func = Expr("func");
|
||||
ExpressionList params;
|
||||
params.push_back(Expr("param1"));
|
||||
params.push_back(Expr("param2"));
|
||||
|
||||
auto* stmt = create<CallExpression>(func, params);
|
||||
EXPECT_EQ(str(stmt), R"(Call[not set]{
|
||||
Identifier[not set]{func}
|
||||
(
|
||||
Identifier[not set]{param1}
|
||||
Identifier[not set]{param2}
|
||||
)
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -40,11 +40,5 @@ CallStatement* CallStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<CallStatement>(src, call);
|
||||
}
|
||||
|
||||
void CallStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
call_->to_str(sem, out, indent);
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -44,14 +44,6 @@ class CallStatement : public Castable<CallStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
CallStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
CallStatement(const CallStatement&) = delete;
|
||||
|
||||
|
|
|
@ -55,18 +55,6 @@ TEST_F(CallStatementTest, Assert_DifferentProgramID_Call) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(CallStatementTest, ToStr) {
|
||||
auto* c = create<CallStatement>(
|
||||
create<CallExpression>(Expr("func"), ExpressionList{}));
|
||||
|
||||
EXPECT_EQ(str(c), R"(Call[not set]{
|
||||
Identifier[not set]{func}
|
||||
(
|
||||
)
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -46,35 +46,5 @@ CaseStatement* CaseStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<CaseStatement>(src, sel, b);
|
||||
}
|
||||
|
||||
void CaseStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
|
||||
if (IsDefault()) {
|
||||
out << "Default{" << std::endl;
|
||||
} else {
|
||||
out << "Case ";
|
||||
bool first = true;
|
||||
for (auto* selector : selectors_) {
|
||||
if (!first)
|
||||
out << ", ";
|
||||
|
||||
first = false;
|
||||
out << selector->to_str(sem);
|
||||
}
|
||||
out << "{" << std::endl;
|
||||
}
|
||||
|
||||
if (body_ != nullptr) {
|
||||
for (auto* stmt : *body_) {
|
||||
stmt->to_str(sem, out, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -58,14 +58,6 @@ class CaseStatement : public Castable<CaseStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
CaseStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
CaseStatement(const CaseStatement&) = delete;
|
||||
|
||||
|
|
|
@ -131,64 +131,6 @@ TEST_F(CaseStatementTest, Assert_DifferentProgramID_Selector) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(-2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* c = create<CaseStatement>(CaseSelectorList{b}, body);
|
||||
|
||||
EXPECT_EQ(str(c), R"(Case -2{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<UintLiteral>(2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* c = create<CaseStatement>(CaseSelectorList{b}, body);
|
||||
|
||||
EXPECT_EQ(str(c), R"(Case 2u{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(1));
|
||||
b.push_back(create<SintLiteral>(2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* c = create<CaseStatement>(b, body);
|
||||
|
||||
EXPECT_EQ(str(c), R"(Case 1, 2{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(CaseStatementTest, ToStr_WithoutSelectors) {
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* c = create<CaseStatement>(CaseSelectorList{}, body);
|
||||
|
||||
EXPECT_EQ(str(c), R"(Default{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -34,12 +34,5 @@ ContinueStatement* ContinueStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<ContinueStatement>(src);
|
||||
}
|
||||
|
||||
void ContinueStatement::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Continue{}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -37,14 +37,6 @@ class ContinueStatement : public Castable<ContinueStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
ContinueStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
ContinueStatement(const ContinueStatement&) = delete;
|
||||
};
|
||||
|
|
|
@ -34,12 +34,6 @@ TEST_F(ContinueStatementTest, IsContinue) {
|
|||
EXPECT_TRUE(stmt->Is<ContinueStatement>());
|
||||
}
|
||||
|
||||
TEST_F(ContinueStatementTest, ToStr) {
|
||||
auto* stmt = create<ContinueStatement>();
|
||||
EXPECT_EQ(str(stmt), R"(Continue{}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -40,12 +40,6 @@ DepthMultisampledTexture::DepthMultisampledTexture(DepthMultisampledTexture&&) =
|
|||
|
||||
DepthMultisampledTexture::~DepthMultisampledTexture() = default;
|
||||
|
||||
std::string DepthMultisampledTexture::type_name() const {
|
||||
std::ostringstream out;
|
||||
out << "__depth_multisampled_texture_" << dim();
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string DepthMultisampledTexture::FriendlyName(const SymbolTable&) const {
|
||||
std::ostringstream out;
|
||||
out << "texture_depth_multisampled_" << dim();
|
||||
|
|
|
@ -37,9 +37,6 @@ class DepthMultisampledTexture
|
|||
DepthMultisampledTexture(DepthMultisampledTexture&&);
|
||||
~DepthMultisampledTexture() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -27,11 +27,6 @@ TEST_F(AstDepthMultisampledTextureTest, Dim) {
|
|||
EXPECT_EQ(d->dim(), TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(AstDepthMultisampledTextureTest, TypeName) {
|
||||
auto* d = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
EXPECT_EQ(d->type_name(), "__depth_multisampled_texture_2d");
|
||||
}
|
||||
|
||||
TEST_F(AstDepthMultisampledTextureTest, FriendlyName) {
|
||||
auto* d = create<DepthMultisampledTexture>(TextureDimension::k2d);
|
||||
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_multisampled_2d");
|
||||
|
|
|
@ -40,12 +40,6 @@ DepthTexture::DepthTexture(DepthTexture&&) = default;
|
|||
|
||||
DepthTexture::~DepthTexture() = default;
|
||||
|
||||
std::string DepthTexture::type_name() const {
|
||||
std::ostringstream out;
|
||||
out << "__depth_texture_" << dim();
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string DepthTexture::FriendlyName(const SymbolTable&) const {
|
||||
std::ostringstream out;
|
||||
out << "texture_depth_" << dim();
|
||||
|
|
|
@ -36,9 +36,6 @@ class DepthTexture : public Castable<DepthTexture, Texture> {
|
|||
DepthTexture(DepthTexture&&);
|
||||
~DepthTexture() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -34,11 +34,6 @@ TEST_F(AstDepthTextureTest, Dim) {
|
|||
EXPECT_EQ(d->dim(), TextureDimension::kCube);
|
||||
}
|
||||
|
||||
TEST_F(AstDepthTextureTest, TypeName) {
|
||||
auto* d = create<DepthTexture>(TextureDimension::kCube);
|
||||
EXPECT_EQ(d->type_name(), "__depth_texture_cube");
|
||||
}
|
||||
|
||||
TEST_F(AstDepthTextureTest, FriendlyName) {
|
||||
auto* d = create<DepthTexture>(TextureDimension::kCube);
|
||||
EXPECT_EQ(d->FriendlyName(Symbols()), "texture_depth_cube");
|
||||
|
|
|
@ -34,12 +34,5 @@ DiscardStatement* DiscardStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<DiscardStatement>(src);
|
||||
}
|
||||
|
||||
void DiscardStatement::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Discard{}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -37,14 +37,6 @@ class DiscardStatement : public Castable<DiscardStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
DiscardStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
DiscardStatement(const DiscardStatement&) = delete;
|
||||
};
|
||||
|
|
|
@ -44,12 +44,6 @@ TEST_F(DiscardStatementTest, IsDiscard) {
|
|||
EXPECT_TRUE(stmt->Is<DiscardStatement>());
|
||||
}
|
||||
|
||||
TEST_F(DiscardStatementTest, ToStr) {
|
||||
auto* stmt = create<DiscardStatement>();
|
||||
EXPECT_EQ(str(stmt), R"(Discard{}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -43,36 +43,5 @@ ElseStatement* ElseStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<ElseStatement>(src, cond, b);
|
||||
}
|
||||
|
||||
void ElseStatement::to_str(const sem::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(sem, out, indent + 4);
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << ")" << std::endl;
|
||||
}
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << "{" << std::endl;
|
||||
|
||||
if (body_ != nullptr) {
|
||||
for (auto* stmt : *body_) {
|
||||
stmt->to_str(sem, out, indent + 4);
|
||||
}
|
||||
}
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << "}" << std::endl;
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -55,14 +55,6 @@ class ElseStatement : public Castable<ElseStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
ElseStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
ElseStatement(const ElseStatement&) = delete;
|
||||
|
||||
|
|
|
@ -89,36 +89,6 @@ TEST_F(ElseStatementTest, Assert_DifferentProgramID_Body) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(ElseStatementTest, ToStr) {
|
||||
auto* cond = Expr(true);
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* e = create<ElseStatement>(cond, body);
|
||||
EXPECT_EQ(str(e), R"(Else{
|
||||
(
|
||||
ScalarConstructor[not set]{true}
|
||||
)
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ElseStatementTest, ToStr_NoCondition) {
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
});
|
||||
auto* e = create<ElseStatement>(nullptr, body);
|
||||
EXPECT_EQ(str(e), R"(Else{
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -29,10 +29,6 @@ ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
|||
|
||||
ExternalTexture::~ExternalTexture() = default;
|
||||
|
||||
std::string ExternalTexture::type_name() const {
|
||||
return "__external_texture";
|
||||
}
|
||||
|
||||
std::string ExternalTexture::FriendlyName(const SymbolTable&) const {
|
||||
return "texture_external";
|
||||
}
|
||||
|
|
|
@ -34,9 +34,6 @@ class ExternalTexture : public Castable<ExternalTexture, Texture> {
|
|||
ExternalTexture(ExternalTexture&&);
|
||||
~ExternalTexture() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -36,11 +36,6 @@ TEST_F(AstExternalTextureTest, Dim) {
|
|||
EXPECT_EQ(ty->dim(), ast::TextureDimension::k2d);
|
||||
}
|
||||
|
||||
TEST_F(AstExternalTextureTest, TypeName) {
|
||||
auto* ty = create<ExternalTexture>();
|
||||
EXPECT_EQ(ty->type_name(), "__external_texture");
|
||||
}
|
||||
|
||||
TEST_F(AstExternalTextureTest, FriendlyName) {
|
||||
auto* ty = create<ExternalTexture>();
|
||||
EXPECT_EQ(ty->FriendlyName(Symbols()), "texture_external");
|
||||
|
|
|
@ -28,10 +28,6 @@ F32::F32(F32&&) = default;
|
|||
|
||||
F32::~F32() = default;
|
||||
|
||||
std::string F32::type_name() const {
|
||||
return "__f32";
|
||||
}
|
||||
|
||||
std::string F32::FriendlyName(const SymbolTable&) const {
|
||||
return "f32";
|
||||
}
|
||||
|
|
|
@ -33,9 +33,6 @@ class F32 : public Castable<F32, Type> {
|
|||
F32(F32&&);
|
||||
~F32() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -22,11 +22,6 @@ namespace {
|
|||
|
||||
using AstF32Test = TestHelper;
|
||||
|
||||
TEST_F(AstF32Test, TypeName) {
|
||||
auto* f = create<F32>();
|
||||
EXPECT_EQ(f->type_name(), "__f32");
|
||||
}
|
||||
|
||||
TEST_F(AstF32Test, FriendlyName) {
|
||||
auto* f = create<F32>();
|
||||
EXPECT_EQ(f->FriendlyName(Symbols()), "f32");
|
||||
|
|
|
@ -35,12 +35,5 @@ FallthroughStatement* FallthroughStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<FallthroughStatement>(src);
|
||||
}
|
||||
|
||||
void FallthroughStatement::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Fallthrough{}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -37,14 +37,6 @@ class FallthroughStatement : public Castable<FallthroughStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
FallthroughStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
FallthroughStatement(const FallthroughStatement&) = delete;
|
||||
};
|
||||
|
|
|
@ -42,12 +42,6 @@ TEST_F(FallthroughStatementTest, IsFallthrough) {
|
|||
EXPECT_TRUE(stmt->Is<FallthroughStatement>());
|
||||
}
|
||||
|
||||
TEST_F(FallthroughStatementTest, ToStr) {
|
||||
auto* stmt = create<FallthroughStatement>();
|
||||
EXPECT_EQ(str(stmt), R"(Fallthrough{}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -30,10 +30,6 @@ FloatLiteral::FloatLiteral(ProgramID program_id,
|
|||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
||||
std::string FloatLiteral::to_str(const sem::Info&) const {
|
||||
return std::to_string(value_);
|
||||
}
|
||||
|
||||
std::string FloatLiteral::name() const {
|
||||
std::ostringstream out;
|
||||
out.flags(out.flags() | std::ios_base::showpoint);
|
||||
|
|
|
@ -38,10 +38,6 @@ class FloatLiteral : public Castable<FloatLiteral, Literal> {
|
|||
/// @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 sem::Info& sem) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
|
@ -26,11 +26,6 @@ TEST_F(FloatLiteralTest, Value) {
|
|||
EXPECT_EQ(f->value(), 47.2f);
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToStr) {
|
||||
auto* f = create<FloatLiteral>(42.1f);
|
||||
EXPECT_EQ(str(f), "42.099998");
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToName) {
|
||||
auto* f = create<FloatLiteral>(42.1f);
|
||||
EXPECT_EQ(f->name(), "__float42.0999985");
|
||||
|
|
|
@ -55,38 +55,5 @@ ForLoopStatement* ForLoopStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<ForLoopStatement>(src, init, cond, cont, b);
|
||||
}
|
||||
|
||||
void ForLoopStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "ForLoop {" << std::endl;
|
||||
|
||||
if (initializer_) {
|
||||
make_indent(out, indent + 2);
|
||||
out << "initializer:" << std::endl;
|
||||
initializer_->to_str(sem, out, indent + 4);
|
||||
}
|
||||
|
||||
if (condition_) {
|
||||
make_indent(out, indent + 2);
|
||||
out << "condition:" << std::endl;
|
||||
condition_->to_str(sem, out, indent + 4);
|
||||
}
|
||||
|
||||
if (continuing_) {
|
||||
make_indent(out, indent + 2);
|
||||
out << "continuing:" << std::endl;
|
||||
continuing_->to_str(sem, out, indent + 4);
|
||||
}
|
||||
|
||||
make_indent(out, indent + 2);
|
||||
out << "body:" << std::endl;
|
||||
for (auto* stmt : *body_) {
|
||||
stmt->to_str(sem, out, indent + 4);
|
||||
}
|
||||
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -68,14 +68,6 @@ class ForLoopStatement : public Castable<ForLoopStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
ForLoopStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
ForLoopStatement(const ForLoopStatement&) = delete;
|
||||
|
||||
|
|
|
@ -99,77 +99,6 @@ TEST_F(ForLoopStatementTest, Assert_DifferentProgramID_Body) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(ForLoopStatementTest, ToStr) {
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(nullptr, nullptr, nullptr, body);
|
||||
|
||||
EXPECT_EQ(str(l), R"(ForLoop {
|
||||
body:
|
||||
Return{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ForLoopStatementTest, ToStr_With_Init) {
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(Block(), nullptr, nullptr, body);
|
||||
|
||||
EXPECT_EQ(str(l), R"(ForLoop {
|
||||
initializer:
|
||||
Block{
|
||||
}
|
||||
body:
|
||||
Return{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ForLoopStatementTest, ToStr_With_Cond) {
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(nullptr, Expr(true), nullptr, body);
|
||||
|
||||
EXPECT_EQ(str(l), R"(ForLoop {
|
||||
condition:
|
||||
ScalarConstructor[not set]{true}
|
||||
body:
|
||||
Return{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ForLoopStatementTest, ToStr_With_Cont) {
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(nullptr, nullptr, Block(), body);
|
||||
|
||||
EXPECT_EQ(str(l), R"(ForLoop {
|
||||
continuing:
|
||||
Block{
|
||||
}
|
||||
body:
|
||||
Return{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(ForLoopStatementTest, ToStr_With_All) {
|
||||
auto* body = Block(Return());
|
||||
auto* l = For(Block(), Expr(true), Block(), body);
|
||||
|
||||
EXPECT_EQ(str(l), R"(ForLoop {
|
||||
initializer:
|
||||
Block{
|
||||
}
|
||||
condition:
|
||||
ScalarConstructor[not set]{true}
|
||||
continuing:
|
||||
Block{
|
||||
}
|
||||
body:
|
||||
Return{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -81,56 +81,6 @@ Function* Function::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<Function>(src, sym, p, ret, b, decos, ret_decos);
|
||||
}
|
||||
|
||||
void Function::to_str(const sem::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(sem, out, indent);
|
||||
}
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "(";
|
||||
|
||||
if (params_.size() > 0) {
|
||||
out << std::endl;
|
||||
|
||||
for (auto* param : params_)
|
||||
param->to_str(sem, out, indent + 2);
|
||||
|
||||
make_indent(out, indent);
|
||||
}
|
||||
out << ")" << std::endl;
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "{" << std::endl;
|
||||
|
||||
if (body_ != nullptr) {
|
||||
for (auto* stmt : *body_) {
|
||||
stmt->to_str(sem, out, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
}
|
||||
|
||||
std::string Function::type_name() const {
|
||||
std::ostringstream out;
|
||||
|
||||
out << "__func" + return_type_->type_name();
|
||||
for (auto* param : params_) {
|
||||
// No need for the sem::Variable here, functions params must have a
|
||||
// type
|
||||
out << param->type()->type_name();
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
Function* FunctionList::Find(Symbol sym) const {
|
||||
for (auto* func : *this) {
|
||||
if (func->symbol() == sym) {
|
||||
|
|
|
@ -94,17 +94,6 @@ class Function : public Castable<Function, Node> {
|
|||
/// @return the newly cloned node
|
||||
Function* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// @returns the type name for this function
|
||||
std::string type_name() const;
|
||||
|
||||
private:
|
||||
Function(const Function&) = delete;
|
||||
|
||||
|
|
|
@ -139,81 +139,6 @@ TEST_F(FunctionTest, Assert_NonConstParam) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
DecorationList{});
|
||||
|
||||
EXPECT_EQ(str(f), R"(Function func -> __void
|
||||
()
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr_WithDecoration) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
DecorationList{WorkgroupSize(2, 4, 6)});
|
||||
|
||||
EXPECT_EQ(str(f), R"(Function func -> __void
|
||||
WorkgroupDecoration{
|
||||
ScalarConstructor[not set]{2}
|
||||
ScalarConstructor[not set]{4}
|
||||
ScalarConstructor[not set]{6}
|
||||
}
|
||||
()
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Param("var", ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
DecorationList{});
|
||||
|
||||
EXPECT_EQ(str(f), R"(Function func -> __void
|
||||
(
|
||||
VariableConst{
|
||||
var
|
||||
none
|
||||
undefined
|
||||
__i32
|
||||
}
|
||||
)
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, TypeName) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
DecorationList{});
|
||||
EXPECT_EQ(f->type_name(), "__func__void");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, TypeName_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Param("var1", ty.i32()));
|
||||
params.push_back(Param("var2", ty.f32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{}, DecorationList{});
|
||||
EXPECT_EQ(f->type_name(), "__func__void__i32__f32");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, GetLastStatement) {
|
||||
VariableList params;
|
||||
auto* stmt = create<DiscardStatement>();
|
||||
|
|
|
@ -34,13 +34,6 @@ std::string GroupDecoration::name() const {
|
|||
return "group";
|
||||
}
|
||||
|
||||
void GroupDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "GroupDecoration{" << value_ << "}" << std::endl;
|
||||
}
|
||||
|
||||
GroupDecoration* GroupDecoration::Clone(CloneContext* ctx) const {
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
|
|
|
@ -38,14 +38,6 @@ class GroupDecoration : public Castable<GroupDecoration, Decoration> {
|
|||
/// @returns the WGSL name for the decoration
|
||||
std::string name() const 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
|
@ -26,13 +26,6 @@ TEST_F(GroupDecorationTest, Creation) {
|
|||
EXPECT_EQ(2u, d->value());
|
||||
}
|
||||
|
||||
|
||||
TEST_F(GroupDecorationTest, ToStr) {
|
||||
auto* d = create<GroupDecoration>(2);
|
||||
EXPECT_EQ(str(d), R"(GroupDecoration{2}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -28,10 +28,6 @@ I32::I32(I32&&) = default;
|
|||
|
||||
I32::~I32() = default;
|
||||
|
||||
std::string I32::type_name() const {
|
||||
return "__i32";
|
||||
}
|
||||
|
||||
std::string I32::FriendlyName(const SymbolTable&) const {
|
||||
return "i32";
|
||||
}
|
||||
|
|
|
@ -33,9 +33,6 @@ class I32 : public Castable<I32, Type> {
|
|||
I32(I32&&);
|
||||
~I32() override;
|
||||
|
||||
/// @returns the name for this type
|
||||
std::string type_name() const override;
|
||||
|
||||
/// @param symbols the program's symbol table
|
||||
/// @returns the name for this type that closely resembles how it would be
|
||||
/// declared in WGSL.
|
||||
|
|
|
@ -22,11 +22,6 @@ namespace {
|
|||
|
||||
using AstI32Test = TestHelper;
|
||||
|
||||
TEST_F(AstI32Test, TypeName) {
|
||||
auto* i = create<I32>();
|
||||
EXPECT_EQ(i->type_name(), "__i32");
|
||||
}
|
||||
|
||||
TEST_F(AstI32Test, FriendlyName) {
|
||||
auto* i = create<I32>();
|
||||
EXPECT_EQ(i->FriendlyName(Symbols()), "i32");
|
||||
|
|
|
@ -40,13 +40,5 @@ IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<IdentifierExpression>(src, sym);
|
||||
}
|
||||
|
||||
void IdentifierExpression::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "Identifier[" << result_type_str(sem) << "]{" << sym_.to_str() << "}"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -41,14 +41,6 @@ class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
|
|||
/// @return the newly cloned node
|
||||
IdentifierExpression* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
IdentifierExpression(const IdentifierExpression&) = delete;
|
||||
|
||||
|
|
|
@ -59,12 +59,6 @@ TEST_F(IdentifierExpressionTest, Assert_DifferentProgramID_Symbol) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(IdentifierExpressionTest, ToStr) {
|
||||
auto* i = Expr("ident");
|
||||
EXPECT_EQ(str(i), R"(Identifier[not set]{ident}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -53,44 +53,5 @@ IfStatement* IfStatement::Clone(CloneContext* ctx) const {
|
|||
return ctx->dst->create<IfStatement>(src, cond, b, el);
|
||||
}
|
||||
|
||||
void IfStatement::to_str(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "If{" << std::endl;
|
||||
|
||||
// Open if conditional
|
||||
make_indent(out, indent + 2);
|
||||
out << "(" << std::endl;
|
||||
|
||||
condition_->to_str(sem, out, indent + 4);
|
||||
|
||||
// Close if conditional
|
||||
make_indent(out, indent + 2);
|
||||
out << ")" << std::endl;
|
||||
|
||||
// Open if body
|
||||
make_indent(out, indent + 2);
|
||||
out << "{" << std::endl;
|
||||
|
||||
if (body_ != nullptr) {
|
||||
for (auto* stmt : *body_) {
|
||||
stmt->to_str(sem, out, indent + 4);
|
||||
}
|
||||
}
|
||||
|
||||
// Close the if body
|
||||
make_indent(out, indent + 2);
|
||||
out << "}" << std::endl;
|
||||
|
||||
// Close the If
|
||||
make_indent(out, indent);
|
||||
out << "}" << std::endl;
|
||||
|
||||
for (auto* e : else_statements_) {
|
||||
e->to_str(sem, out, indent);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -59,14 +59,6 @@ class IfStatement : public Castable<IfStatement, Statement> {
|
|||
/// @return the newly cloned node
|
||||
IfStatement* 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
private:
|
||||
IfStatement(const IfStatement&) = delete;
|
||||
|
||||
|
|
|
@ -101,60 +101,6 @@ TEST_F(IfStatementTest, Assert_DifferentProgramID_ElseStatement) {
|
|||
"internal compiler error");
|
||||
}
|
||||
|
||||
TEST_F(IfStatementTest, ToStr) {
|
||||
auto* cond = Expr("cond");
|
||||
auto* stmt = create<IfStatement>(cond, Block(create<DiscardStatement>()),
|
||||
ElseStatementList{});
|
||||
|
||||
EXPECT_EQ(str(stmt), R"(If{
|
||||
(
|
||||
Identifier[not set]{cond}
|
||||
)
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
TEST_F(IfStatementTest, ToStr_WithElseStatements) {
|
||||
auto* cond = Expr("cond");
|
||||
auto* body = Block(create<DiscardStatement>());
|
||||
auto* else_if_body = Block(create<DiscardStatement>());
|
||||
auto* else_body =
|
||||
Block(create<DiscardStatement>(), create<DiscardStatement>());
|
||||
auto* stmt = create<IfStatement>(
|
||||
cond, body,
|
||||
ElseStatementList{
|
||||
create<ElseStatement>(Expr("ident"), else_if_body),
|
||||
create<ElseStatement>(nullptr, else_body),
|
||||
});
|
||||
|
||||
EXPECT_EQ(str(stmt), R"(If{
|
||||
(
|
||||
Identifier[not set]{cond}
|
||||
)
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
Else{
|
||||
(
|
||||
Identifier[not set]{ident}
|
||||
)
|
||||
{
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
Else{
|
||||
{
|
||||
Discard{}
|
||||
Discard{}
|
||||
}
|
||||
}
|
||||
)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -28,12 +28,5 @@ std::string InternalDecoration::name() const {
|
|||
return "internal";
|
||||
}
|
||||
|
||||
void InternalDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "tint_internal(" << InternalName() << ")";
|
||||
}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -40,14 +40,6 @@ class InternalDecoration : public Castable<InternalDecoration, Decoration> {
|
|||
|
||||
/// @returns the WGSL name for the decoration
|
||||
std::string name() 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
};
|
||||
|
||||
} // namespace ast
|
||||
|
|
|
@ -35,14 +35,6 @@ std::string InterpolateDecoration::name() const {
|
|||
return "interpolate";
|
||||
}
|
||||
|
||||
void InterpolateDecoration::to_str(const sem::Info&,
|
||||
std::ostream& out,
|
||||
size_t indent) const {
|
||||
make_indent(out, indent);
|
||||
out << "InterpolateDecoration{" << type_ << " " << sampling_ << "}"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
InterpolateDecoration* InterpolateDecoration::Clone(CloneContext* ctx) const {
|
||||
// Clone arguments outside of create() call to have deterministic ordering
|
||||
auto src = ctx->Clone(source());
|
||||
|
|
|
@ -53,14 +53,6 @@ class InterpolateDecoration
|
|||
/// @returns the WGSL name for the decoration
|
||||
std::string name() const 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(const sem::Info& sem,
|
||||
std::ostream& out,
|
||||
size_t indent) const override;
|
||||
|
||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||
/// `ctx`.
|
||||
/// @param ctx the clone context
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue