Remove ast::NullLiteral
This isn't in the WGSL spec, nor is it generated by readers. This was only used inside the SPIR-V writer, but this remaining usage was removed in the parent change. Change-Id: I1bbfde67dc760b761af010a7a144dccb52369148 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45343 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
b225851eef
commit
91da97d6c3
|
@ -299,8 +299,6 @@ source_set("libtint_core_src") {
|
||||||
"ast/module.h",
|
"ast/module.h",
|
||||||
"ast/node.cc",
|
"ast/node.cc",
|
||||||
"ast/node.h",
|
"ast/node.h",
|
||||||
"ast/null_literal.cc",
|
|
||||||
"ast/null_literal.h",
|
|
||||||
"ast/pipeline_stage.cc",
|
"ast/pipeline_stage.cc",
|
||||||
"ast/pipeline_stage.h",
|
"ast/pipeline_stage.h",
|
||||||
"ast/return_statement.cc",
|
"ast/return_statement.cc",
|
||||||
|
|
|
@ -108,8 +108,6 @@ set(TINT_LIB_SRCS
|
||||||
ast/module.h
|
ast/module.h
|
||||||
ast/node.cc
|
ast/node.cc
|
||||||
ast/node.h
|
ast/node.h
|
||||||
ast/null_literal.cc
|
|
||||||
ast/null_literal.h
|
|
||||||
ast/pipeline_stage.cc
|
ast/pipeline_stage.cc
|
||||||
ast/pipeline_stage.h
|
ast/pipeline_stage.h
|
||||||
ast/return_statement.cc
|
ast/return_statement.cc
|
||||||
|
@ -439,7 +437,6 @@ if(${TINT_BUILD_TESTS})
|
||||||
ast/member_accessor_expression_test.cc
|
ast/member_accessor_expression_test.cc
|
||||||
ast/module_clone_test.cc
|
ast/module_clone_test.cc
|
||||||
ast/module_test.cc
|
ast/module_test.cc
|
||||||
ast/null_literal_test.cc
|
|
||||||
ast/return_statement_test.cc
|
ast/return_statement_test.cc
|
||||||
ast/scalar_constructor_expression_test.cc
|
ast/scalar_constructor_expression_test.cc
|
||||||
ast/sint_literal_test.cc
|
ast/sint_literal_test.cc
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/null_literal.h"
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -45,7 +44,6 @@ TEST_F(BoolLiteralTest, Is) {
|
||||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||||
EXPECT_FALSE(l->Is<UintLiteral>());
|
EXPECT_FALSE(l->Is<UintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<IntLiteral>());
|
EXPECT_FALSE(l->Is<IntLiteral>());
|
||||||
EXPECT_FALSE(l->Is<NullLiteral>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(BoolLiteralTest, ToStr) {
|
TEST_F(BoolLiteralTest, ToStr) {
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/null_literal.h"
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -34,7 +33,6 @@ TEST_F(FloatLiteralTest, Is) {
|
||||||
EXPECT_FALSE(l->Is<IntLiteral>());
|
EXPECT_FALSE(l->Is<IntLiteral>());
|
||||||
EXPECT_TRUE(l->Is<FloatLiteral>());
|
EXPECT_TRUE(l->Is<FloatLiteral>());
|
||||||
EXPECT_FALSE(l->Is<UintLiteral>());
|
EXPECT_FALSE(l->Is<UintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<NullLiteral>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FloatLiteralTest, ToStr) {
|
TEST_F(FloatLiteralTest, ToStr) {
|
||||||
|
|
|
@ -1,45 +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/null_literal.h"
|
|
||||||
|
|
||||||
#include "src/program_builder.h"
|
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::ast::NullLiteral);
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace ast {
|
|
||||||
|
|
||||||
NullLiteral::NullLiteral(const Source& source, type::Type* type)
|
|
||||||
: Base(source, type) {}
|
|
||||||
|
|
||||||
NullLiteral::~NullLiteral() = default;
|
|
||||||
|
|
||||||
std::string NullLiteral::to_str(const semantic::Info&) const {
|
|
||||||
return "null " + type()->type_name();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string NullLiteral::name() const {
|
|
||||||
return "__null" + type()->type_name();
|
|
||||||
}
|
|
||||||
|
|
||||||
NullLiteral* NullLiteral::Clone(CloneContext* ctx) const {
|
|
||||||
// Clone arguments outside of create() call to have deterministic ordering
|
|
||||||
auto src = ctx->Clone(source());
|
|
||||||
auto* ty = ctx->Clone(type());
|
|
||||||
return ctx->dst->create<NullLiteral>(src, ty);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
|
|
@ -1,51 +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.
|
|
||||||
|
|
||||||
#ifndef SRC_AST_NULL_LITERAL_H_
|
|
||||||
#define SRC_AST_NULL_LITERAL_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "src/ast/literal.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace ast {
|
|
||||||
|
|
||||||
/// A null literal
|
|
||||||
class NullLiteral : public Castable<NullLiteral, Literal> {
|
|
||||||
public:
|
|
||||||
/// Constructor
|
|
||||||
/// @param source the input source
|
|
||||||
/// @param type the type
|
|
||||||
NullLiteral(const Source& source, type::Type* type);
|
|
||||||
~NullLiteral() override;
|
|
||||||
|
|
||||||
/// @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 semantic::Info& sem) const override;
|
|
||||||
|
|
||||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
|
||||||
/// `ctx`.
|
|
||||||
/// @param ctx the clone context
|
|
||||||
/// @return the newly cloned node
|
|
||||||
NullLiteral* Clone(CloneContext* ctx) const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
|
||||||
|
|
||||||
#endif // SRC_AST_NULL_LITERAL_H_
|
|
|
@ -1,47 +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/null_literal.h"
|
|
||||||
|
|
||||||
#include "src/ast/test_helper.h"
|
|
||||||
|
|
||||||
namespace tint {
|
|
||||||
namespace ast {
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
using NullLiteralTest = TestHelper;
|
|
||||||
|
|
||||||
TEST_F(NullLiteralTest, Is) {
|
|
||||||
ast::Literal* l = create<NullLiteral>(ty.i32());
|
|
||||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
|
||||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
|
||||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
|
||||||
EXPECT_FALSE(l->Is<UintLiteral>());
|
|
||||||
EXPECT_FALSE(l->Is<IntLiteral>());
|
|
||||||
EXPECT_TRUE(l->Is<NullLiteral>());
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NullLiteralTest, ToStr) {
|
|
||||||
auto* i = create<NullLiteral>(ty.i32());
|
|
||||||
EXPECT_EQ(str(i), "null __i32");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(NullLiteralTest, Name_I32) {
|
|
||||||
auto* i = create<NullLiteral>(ty.i32());
|
|
||||||
EXPECT_EQ("__null__i32", i->name());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
} // namespace ast
|
|
||||||
} // namespace tint
|
|
|
@ -34,15 +34,6 @@ TEST_F(ScalarConstructorExpressionTest, Creation_WithSource) {
|
||||||
EXPECT_EQ(src.range.begin.column, 2u);
|
EXPECT_EQ(src.range.begin.column, 2u);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ScalarConstructorExpressionTest, Assert_NullLiteral) {
|
|
||||||
EXPECT_FATAL_FAILURE(
|
|
||||||
{
|
|
||||||
ProgramBuilder b;
|
|
||||||
b.create<ScalarConstructorExpression>(nullptr);
|
|
||||||
},
|
|
||||||
"internal compiler error");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(ScalarConstructorExpressionTest, ToStr) {
|
TEST_F(ScalarConstructorExpressionTest, ToStr) {
|
||||||
auto* c = Expr(true);
|
auto* c = Expr(true);
|
||||||
EXPECT_EQ(str(c), R"(ScalarConstructor[not set]{true}
|
EXPECT_EQ(str(c), R"(ScalarConstructor[not set]{true}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/null_literal.h"
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -33,7 +32,6 @@ TEST_F(SintLiteralTest, Is) {
|
||||||
EXPECT_TRUE(l->Is<SintLiteral>());
|
EXPECT_TRUE(l->Is<SintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||||
EXPECT_FALSE(l->Is<UintLiteral>());
|
EXPECT_FALSE(l->Is<UintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<NullLiteral>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SintLiteralTest, ToStr) {
|
TEST_F(SintLiteralTest, ToStr) {
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "src/ast/null_literal.h"
|
|
||||||
#include "src/ast/test_helper.h"
|
#include "src/ast/test_helper.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
@ -33,7 +32,6 @@ TEST_F(UintLiteralTest, Is) {
|
||||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||||
EXPECT_TRUE(l->Is<UintLiteral>());
|
EXPECT_TRUE(l->Is<UintLiteral>());
|
||||||
EXPECT_FALSE(l->Is<NullLiteral>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(UintLiteralTest, ToStr) {
|
TEST_F(UintLiteralTest, ToStr) {
|
||||||
|
|
|
@ -139,7 +139,6 @@ source_set("tint_unittests_core_src") {
|
||||||
"../src/ast/member_accessor_expression_test.cc",
|
"../src/ast/member_accessor_expression_test.cc",
|
||||||
"../src/ast/module_clone_test.cc",
|
"../src/ast/module_clone_test.cc",
|
||||||
"../src/ast/module_test.cc",
|
"../src/ast/module_test.cc",
|
||||||
"../src/ast/null_literal_test.cc",
|
|
||||||
"../src/ast/return_statement_test.cc",
|
"../src/ast/return_statement_test.cc",
|
||||||
"../src/ast/scalar_constructor_expression_test.cc",
|
"../src/ast/scalar_constructor_expression_test.cc",
|
||||||
"../src/ast/sint_literal_test.cc",
|
"../src/ast/sint_literal_test.cc",
|
||||||
|
|
Loading…
Reference in New Issue