Rename the IntLiteral to SintLiteral.
This Cl clarifies that IntLiteral is a signed value, which matches with
the usage of UintLiteral.
Change-Id: Ic8f0e2382cb66eb6b09daed096886dcc55e6b0f0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/22540
Reviewed-by: David Neto <dneto@google.com>
diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc
index b8dc640..3c37042 100644
--- a/src/ast/bool_literal_test.cc
+++ b/src/ast/bool_literal_test.cc
@@ -43,7 +43,7 @@
ast::type::BoolType bool_type;
BoolLiteral b{&bool_type, false};
EXPECT_TRUE(b.IsBool());
- EXPECT_FALSE(b.IsInt());
+ EXPECT_FALSE(b.IsSint());
EXPECT_FALSE(b.IsFloat());
EXPECT_FALSE(b.IsUint());
EXPECT_FALSE(b.IsNull());
diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc
index bc53f57..cdc5982 100644
--- a/src/ast/case_statement_test.cc
+++ b/src/ast/case_statement_test.cc
@@ -17,8 +17,8 @@
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/kill_statement.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/i32_type.h"
@@ -136,8 +136,8 @@
ast::type::I32Type i32;
CaseSelectorList b;
- b.push_back(std::make_unique<IntLiteral>(&i32, 1));
- b.push_back(std::make_unique<IntLiteral>(&i32, 2));
+ b.push_back(std::make_unique<SintLiteral>(&i32, 1));
+ b.push_back(std::make_unique<SintLiteral>(&i32, 2));
StatementList stmts;
stmts.push_back(std::make_unique<KillStatement>());
CaseStatement c(std::move(b), std::move(stmts));
diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc
index 960a7dd..028b623 100644
--- a/src/ast/float_literal_test.cc
+++ b/src/ast/float_literal_test.cc
@@ -34,7 +34,7 @@
ast::type::F32Type f32;
FloatLiteral f{&f32, 42.f};
EXPECT_FALSE(f.IsBool());
- EXPECT_FALSE(f.IsInt());
+ EXPECT_FALSE(f.IsSint());
EXPECT_TRUE(f.IsFloat());
EXPECT_FALSE(f.IsUint());
EXPECT_FALSE(f.IsNull());
diff --git a/src/ast/literal.cc b/src/ast/literal.cc
index 489a32c..6dcf084 100644
--- a/src/ast/literal.cc
+++ b/src/ast/literal.cc
@@ -18,8 +18,8 @@
#include "src/ast/bool_literal.h"
#include "src/ast/float_literal.h"
-#include "src/ast/int_literal.h"
#include "src/ast/null_literal.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/uint_literal.h"
namespace tint {
@@ -37,7 +37,7 @@
return false;
}
-bool Literal::IsInt() const {
+bool Literal::IsSint() const {
return false;
}
@@ -59,9 +59,9 @@
return static_cast<FloatLiteral*>(this);
}
-IntLiteral* Literal::AsInt() {
- assert(IsInt());
- return static_cast<IntLiteral*>(this);
+SintLiteral* Literal::AsSint() {
+ assert(IsSint());
+ return static_cast<SintLiteral*>(this);
}
NullLiteral* Literal::AsNull() {
diff --git a/src/ast/literal.h b/src/ast/literal.h
index 54079cd..16957a9 100644
--- a/src/ast/literal.h
+++ b/src/ast/literal.h
@@ -24,8 +24,8 @@
class BoolLiteral;
class FloatLiteral;
-class IntLiteral;
class NullLiteral;
+class SintLiteral;
class UintLiteral;
/// Base class for a literal value
@@ -38,7 +38,7 @@
/// @returns true if this is a float literal
virtual bool IsFloat() const;
/// @returns true if this is a signed int literal
- virtual bool IsInt() const;
+ virtual bool IsSint() const;
/// @returns true if this is a null literal
virtual bool IsNull() const;
/// @returns true if this is a unsigned int literal
@@ -48,8 +48,8 @@
BoolLiteral* AsBool();
/// @returns the literal as a float literal
FloatLiteral* AsFloat();
- /// @returns the literal as a int literal
- IntLiteral* AsInt();
+ /// @returns the literal as a signed int literal
+ SintLiteral* AsSint();
/// @returns the literal as a null literal
NullLiteral* AsNull();
/// @returns the literal as a unsigned int literal
diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc
index 67354f6..62bd62e 100644
--- a/src/ast/null_literal_test.cc
+++ b/src/ast/null_literal_test.cc
@@ -27,7 +27,7 @@
ast::type::I32Type i32;
NullLiteral i{&i32};
EXPECT_FALSE(i.IsBool());
- EXPECT_FALSE(i.IsInt());
+ EXPECT_FALSE(i.IsSint());
EXPECT_FALSE(i.IsFloat());
EXPECT_FALSE(i.IsUint());
EXPECT_TRUE(i.IsNull());
@@ -48,4 +48,4 @@
} // namespace
} // namespace ast
-} // namespace tint
\ No newline at end of file
+} // namespace tint
diff --git a/src/ast/int_literal.cc b/src/ast/sint_literal.cc
similarity index 70%
rename from src/ast/int_literal.cc
rename to src/ast/sint_literal.cc
index 30a4676..4f9f79c 100644
--- a/src/ast/int_literal.cc
+++ b/src/ast/sint_literal.cc
@@ -12,26 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/int_literal.h"
+#include "src/ast/sint_literal.h"
namespace tint {
namespace ast {
-IntLiteral::IntLiteral(ast::type::Type* type, int32_t value)
+SintLiteral::SintLiteral(ast::type::Type* type, int32_t value)
: Literal(type), value_(value) {}
-IntLiteral::~IntLiteral() = default;
+SintLiteral::~SintLiteral() = default;
-bool IntLiteral::IsInt() const {
+bool SintLiteral::IsSint() const {
return true;
}
-std::string IntLiteral::to_str() const {
+std::string SintLiteral::to_str() const {
return std::to_string(value_);
}
-std::string IntLiteral::name() const {
- return "__int" + type()->type_name() + "_" + std::to_string(value_);
+std::string SintLiteral::name() const {
+ return "__sint" + type()->type_name() + "_" + std::to_string(value_);
}
} // namespace ast
diff --git a/src/ast/int_literal.h b/src/ast/sint_literal.h
similarity index 74%
rename from src/ast/int_literal.h
rename to src/ast/sint_literal.h
index 1a72749..6c62aad 100644
--- a/src/ast/int_literal.h
+++ b/src/ast/sint_literal.h
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#ifndef SRC_AST_INT_LITERAL_H_
-#define SRC_AST_INT_LITERAL_H_
+#ifndef SRC_AST_SINT_LITERAL_H_
+#define SRC_AST_SINT_LITERAL_H_
#include <string>
@@ -22,17 +22,17 @@
namespace tint {
namespace ast {
-/// A int literal
-class IntLiteral : public Literal {
+/// A signed int literal
+class SintLiteral : public Literal {
public:
/// Constructor
/// @param type the type
- /// @param value the int literals value
- IntLiteral(ast::type::Type* type, int32_t value);
- ~IntLiteral() override;
+ /// @param value the signed int literals value
+ SintLiteral(ast::type::Type* type, int32_t value);
+ ~SintLiteral() override;
- /// @returns true if this is a int literal
- bool IsInt() const override;
+ /// @returns true if this is a signed int literal
+ bool IsSint() const override;
/// @returns the int literal value
int32_t value() const { return value_; }
@@ -50,4 +50,4 @@
} // namespace ast
} // namespace tint
-#endif // SRC_AST_INT_LITERAL_H_
+#endif // SRC_AST_SINT_LITERAL_H_
diff --git a/src/ast/int_literal_test.cc b/src/ast/sint_literal_test.cc
similarity index 68%
rename from src/ast/int_literal_test.cc
rename to src/ast/sint_literal_test.cc
index 9bb2307..ad4ccb9 100644
--- a/src/ast/int_literal_test.cc
+++ b/src/ast/sint_literal_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "src/ast/int_literal.h"
+#include "src/ast/sint_literal.h"
#include "gtest/gtest.h"
#include "src/ast/type/i32_type.h"
@@ -22,42 +22,42 @@
namespace ast {
namespace {
-using IntLiteralTest = testing::Test;
+using SintLiteralTest = testing::Test;
-TEST_F(IntLiteralTest, Value) {
+TEST_F(SintLiteralTest, Value) {
ast::type::I32Type i32;
- IntLiteral i{&i32, 47};
- ASSERT_TRUE(i.IsInt());
+ SintLiteral i{&i32, 47};
+ ASSERT_TRUE(i.IsSint());
EXPECT_EQ(i.value(), 47);
}
-TEST_F(IntLiteralTest, Is) {
+TEST_F(SintLiteralTest, Is) {
ast::type::I32Type i32;
- IntLiteral i{&i32, 42};
+ SintLiteral i{&i32, 42};
EXPECT_FALSE(i.IsBool());
- EXPECT_TRUE(i.IsInt());
+ EXPECT_TRUE(i.IsSint());
EXPECT_FALSE(i.IsFloat());
EXPECT_FALSE(i.IsUint());
EXPECT_FALSE(i.IsNull());
}
-TEST_F(IntLiteralTest, ToStr) {
+TEST_F(SintLiteralTest, ToStr) {
ast::type::I32Type i32;
- IntLiteral i{&i32, -42};
+ SintLiteral i{&i32, -42};
EXPECT_EQ(i.to_str(), "-42");
}
-TEST_F(IntLiteralTest, Name_I32) {
+TEST_F(SintLiteralTest, Name_I32) {
ast::type::I32Type i32;
- IntLiteral i{&i32, 2};
- EXPECT_EQ("__int__i32_2", i.name());
+ SintLiteral i{&i32, 2};
+ EXPECT_EQ("__sint__i32_2", i.name());
}
-TEST_F(IntLiteralTest, Name_U32) {
+TEST_F(SintLiteralTest, Name_U32) {
ast::type::U32Type u32;
- IntLiteral i{&u32, 2};
- EXPECT_EQ("__int__u32_2", i.name());
+ SintLiteral i{&u32, 2};
+ EXPECT_EQ("__sint__u32_2", i.name());
}
} // namespace
} // namespace ast
diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc
index 841ad22..5fab748 100644
--- a/src/ast/uint_literal_test.cc
+++ b/src/ast/uint_literal_test.cc
@@ -34,7 +34,7 @@
ast::type::U32Type u32;
UintLiteral u{&u32, 42};
EXPECT_FALSE(u.IsBool());
- EXPECT_FALSE(u.IsInt());
+ EXPECT_FALSE(u.IsSint());
EXPECT_FALSE(u.IsFloat());
EXPECT_TRUE(u.IsUint());
EXPECT_FALSE(u.IsNull());