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/BUILD.gn b/BUILD.gn
index 2adbf02..9570e28 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -248,8 +248,6 @@
"src/ast/if_statement.h",
"src/ast/import.cc",
"src/ast/import.h",
- "src/ast/int_literal.cc",
- "src/ast/int_literal.h",
"src/ast/kill_statement.cc",
"src/ast/kill_statement.h",
"src/ast/literal.cc",
@@ -274,6 +272,8 @@
"src/ast/scalar_constructor_expression.h",
"src/ast/set_decoration.cc",
"src/ast/set_decoration.h",
+ "src/ast/sint_literal.cc",
+ "src/ast/sint_literal.h",
"src/ast/statement.cc",
"src/ast/statement.h",
"src/ast/statement_condition.cc",
@@ -587,7 +587,6 @@
"src/ast/identifier_expression_test.cc",
"src/ast/if_statement_test.cc",
"src/ast/import_test.cc",
- "src/ast/int_literal_test.cc",
"src/ast/kill_statement_test.cc",
"src/ast/location_decoration_test.cc",
"src/ast/loop_statement_test.cc",
@@ -597,6 +596,7 @@
"src/ast/return_statement_test.cc",
"src/ast/scalar_constructor_expression_test.cc",
"src/ast/set_decoration_test.cc",
+ "src/ast/sint_literal_test.cc",
"src/ast/struct_member_offset_decoration_test.cc",
"src/ast/struct_member_test.cc",
"src/ast/struct_test.cc",
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e731adb..5875054 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,8 +85,6 @@
ast/if_statement.h
ast/import.cc
ast/import.h
- ast/int_literal.cc
- ast/int_literal.h
ast/kill_statement.cc
ast/kill_statement.h
ast/literal.h
@@ -111,6 +109,8 @@
ast/scalar_constructor_expression.h
ast/set_decoration.cc
ast/set_decoration.h
+ ast/sint_literal.cc
+ ast/sint_literal.h
ast/statement.cc
ast/statement.h
ast/statement_condition.cc
@@ -266,7 +266,6 @@
ast/identifier_expression_test.cc
ast/if_statement_test.cc
ast/import_test.cc
- ast/int_literal_test.cc
ast/kill_statement_test.cc
ast/location_decoration_test.cc
ast/loop_statement_test.cc
@@ -277,6 +276,7 @@
ast/return_statement_test.cc
ast/scalar_constructor_expression_test.cc
ast/set_decoration_test.cc
+ ast/sint_literal_test.cc
ast/struct_member_test.cc
ast/struct_member_offset_decoration_test.cc
ast/struct_test.cc
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());
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 29a952e..623ac51 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -39,8 +39,8 @@
#include "src/ast/builtin_decoration.h"
#include "src/ast/decorated_variable.h"
#include "src/ast/float_literal.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_decoration.h"
#include "src/ast/struct_member.h"
@@ -882,7 +882,7 @@
}
if (ast_type->IsI32()) {
return {ast_type, std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(
+ std::make_unique<ast::SintLiteral>(
ast_type, spirv_const->GetS32()))};
}
if (ast_type->IsF32()) {
@@ -954,7 +954,7 @@
}
if (type->IsI32()) {
return std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(type, 0));
+ std::make_unique<ast::SintLiteral>(type, 0));
}
if (type->IsF32()) {
return std::make_unique<ast::ScalarConstructorExpression>(
diff --git a/src/reader/wgsl/lexer_test.cc b/src/reader/wgsl/lexer_test.cc
index 12170dc..9bed255 100644
--- a/src/reader/wgsl/lexer_test.cc
+++ b/src/reader/wgsl/lexer_test.cc
@@ -201,7 +201,7 @@
Lexer l(std::string(params.input));
auto t = l.next();
- EXPECT_TRUE(t.IsIntLiteral());
+ EXPECT_TRUE(t.IsSintLiteral());
EXPECT_EQ(t.line(), 1u);
EXPECT_EQ(t.column(), 1u);
EXPECT_EQ(t.to_i32(), params.result);
@@ -308,7 +308,7 @@
Lexer l(params.input);
auto t = l.next();
- EXPECT_TRUE(t.IsIntLiteral());
+ EXPECT_TRUE(t.IsSintLiteral());
EXPECT_EQ(t.to_i32(), params.result);
EXPECT_EQ(1u, t.line());
EXPECT_EQ(1u, t.column());
@@ -328,7 +328,7 @@
Lexer l(GetParam());
auto t = l.next();
- EXPECT_FALSE(t.IsIntLiteral());
+ EXPECT_FALSE(t.IsSintLiteral());
EXPECT_FALSE(t.IsUintLiteral());
}
INSTANTIATE_TEST_SUITE_P(LexerTest,
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index 36d82e4..038e397 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -34,13 +34,13 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/kill_statement.h"
#include "src/ast/location_decoration.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/set_decoration.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/statement_condition.h"
#include "src/ast/struct_member_offset_decoration.h"
#include "src/ast/switch_statement.h"
@@ -497,7 +497,7 @@
next(); // consume the peek
t = next();
- if (!t.IsIntLiteral()) {
+ if (!t.IsSintLiteral()) {
set_error(t, "invalid value for location decoration");
return {};
}
@@ -525,7 +525,7 @@
next(); // consume the peek
t = next();
- if (!t.IsIntLiteral()) {
+ if (!t.IsSintLiteral()) {
set_error(t, "invalid value for binding decoration");
return {};
}
@@ -536,7 +536,7 @@
next(); // consume the peek
t = next();
- if (!t.IsIntLiteral()) {
+ if (!t.IsSintLiteral()) {
set_error(t, "invalid value for set decoration");
return {};
}
@@ -837,7 +837,7 @@
uint32_t size = 0;
if (t.IsComma()) {
t = next();
- if (!t.IsIntLiteral()) {
+ if (!t.IsSintLiteral()) {
set_error(t, "missing size of array declaration");
return nullptr;
}
@@ -1143,7 +1143,7 @@
next(); // Consume the peek
t = next();
- if (!t.IsIntLiteral()) {
+ if (!t.IsSintLiteral()) {
set_error(t, "invalid value for offset decoration");
return nullptr;
}
@@ -2741,13 +2741,13 @@
}
return std::make_unique<ast::BoolLiteral>(type, false);
}
- if (t.IsIntLiteral()) {
+ if (t.IsSintLiteral()) {
next(); // Consume the peek
auto* type = ctx_.type_mgr().Get(std::make_unique<ast::type::I32Type>());
if (!type) {
return nullptr;
}
- return std::make_unique<ast::IntLiteral>(type, t.to_i32());
+ return std::make_unique<ast::SintLiteral>(type, t.to_i32());
}
if (t.IsUintLiteral()) {
next(); // Consume the peek
diff --git a/src/reader/wgsl/parser_impl_argument_expression_list_test.cc b/src/reader/wgsl/parser_impl_argument_expression_list_test.cc
index efbd731..b91122f 100644
--- a/src/reader/wgsl/parser_impl_argument_expression_list_test.cc
+++ b/src/reader/wgsl/parser_impl_argument_expression_list_test.cc
@@ -15,8 +15,8 @@
#include "gtest/gtest.h"
#include "src/ast/array_accessor_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
diff --git a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc
index 9624223..fd7778f 100644
--- a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc
+++ b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc
@@ -16,10 +16,10 @@
#include "src/ast/array_accessor_expression.h"
#include "src/ast/assignment_statement.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/literal.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -47,8 +47,8 @@
auto* init = e->rhs()->AsConstructor()->AsScalarConstructor();
ASSERT_NE(init->literal(), nullptr);
- ASSERT_TRUE(init->literal()->IsInt());
- EXPECT_EQ(init->literal()->AsInt()->value(), 123);
+ ASSERT_TRUE(init->literal()->IsSint());
+ EXPECT_EQ(init->literal()->AsSint()->value(), 123);
}
TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) {
@@ -65,8 +65,8 @@
ASSERT_TRUE(e->rhs()->AsConstructor()->IsScalarConstructor());
auto* init = e->rhs()->AsConstructor()->AsScalarConstructor();
ASSERT_NE(init->literal(), nullptr);
- ASSERT_TRUE(init->literal()->IsInt());
- EXPECT_EQ(init->literal()->AsInt()->value(), 123);
+ ASSERT_TRUE(init->literal()->IsSint());
+ EXPECT_EQ(init->literal()->AsSint()->value(), 123);
ASSERT_TRUE(e->lhs()->IsMemberAccessor());
auto* mem = e->lhs()->AsMemberAccessor();
@@ -82,8 +82,8 @@
ASSERT_TRUE(ary->idx_expr()->AsConstructor()->IsScalarConstructor());
init = ary->idx_expr()->AsConstructor()->AsScalarConstructor();
ASSERT_NE(init->literal(), nullptr);
- ASSERT_TRUE(init->literal()->IsInt());
- EXPECT_EQ(init->literal()->AsInt()->value(), 2);
+ ASSERT_TRUE(init->literal()->IsSint());
+ EXPECT_EQ(init->literal()->AsSint()->value(), 2);
ASSERT_TRUE(ary->array()->IsMemberAccessor());
mem = ary->array()->AsMemberAccessor();
diff --git a/src/reader/wgsl/parser_impl_const_literal_test.cc b/src/reader/wgsl/parser_impl_const_literal_test.cc
index 74bc6e2..3a5420a 100644
--- a/src/reader/wgsl/parser_impl_const_literal_test.cc
+++ b/src/reader/wgsl/parser_impl_const_literal_test.cc
@@ -15,7 +15,7 @@
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h"
#include "src/ast/float_literal.h"
-#include "src/ast/int_literal.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/uint_literal.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -30,8 +30,8 @@
auto c = p->const_literal();
ASSERT_FALSE(p->has_error());
ASSERT_NE(c, nullptr);
- ASSERT_TRUE(c->IsInt());
- EXPECT_EQ(c->AsInt()->value(), -234);
+ ASSERT_TRUE(c->IsSint());
+ EXPECT_EQ(c->AsSint()->value(), -234);
}
TEST_F(ParserImplTest, ConstLiteral_Uint) {
diff --git a/src/reader/wgsl/parser_impl_postfix_expression_test.cc b/src/reader/wgsl/parser_impl_postfix_expression_test.cc
index 960bdf3..9baf8a6 100644
--- a/src/reader/wgsl/parser_impl_postfix_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_postfix_expression_test.cc
@@ -16,9 +16,9 @@
#include "src/ast/array_accessor_expression.h"
#include "src/ast/call_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -44,8 +44,8 @@
ASSERT_TRUE(ary->idx_expr()->IsConstructor());
ASSERT_TRUE(ary->idx_expr()->AsConstructor()->IsScalarConstructor());
auto* c = ary->idx_expr()->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(c->literal()->IsInt());
- EXPECT_EQ(c->literal()->AsInt()->value(), 1);
+ ASSERT_TRUE(c->literal()->IsSint());
+ EXPECT_EQ(c->literal()->AsSint()->value(), 1);
}
TEST_F(ParserImplTest, PostfixExpression_Array_ExpressionIndex) {
diff --git a/src/reader/wgsl/parser_impl_primary_expression_test.cc b/src/reader/wgsl/parser_impl_primary_expression_test.cc
index 1be32d7..a5fd1d9 100644
--- a/src/reader/wgsl/parser_impl_primary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/bool_literal.h"
#include "src/ast/cast_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type_constructor_expression.h"
@@ -76,26 +76,26 @@
ASSERT_TRUE(val[0]->IsConstructor());
ASSERT_TRUE(val[0]->AsConstructor()->IsScalarConstructor());
auto* ident = val[0]->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(ident->literal()->IsInt());
- EXPECT_EQ(ident->literal()->AsInt()->value(), 1);
+ ASSERT_TRUE(ident->literal()->IsSint());
+ EXPECT_EQ(ident->literal()->AsSint()->value(), 1);
ASSERT_TRUE(val[1]->IsConstructor());
ASSERT_TRUE(val[1]->AsConstructor()->IsScalarConstructor());
ident = val[1]->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(ident->literal()->IsInt());
- EXPECT_EQ(ident->literal()->AsInt()->value(), 2);
+ ASSERT_TRUE(ident->literal()->IsSint());
+ EXPECT_EQ(ident->literal()->AsSint()->value(), 2);
ASSERT_TRUE(val[2]->IsConstructor());
ASSERT_TRUE(val[2]->AsConstructor()->IsScalarConstructor());
ident = val[2]->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(ident->literal()->IsInt());
- EXPECT_EQ(ident->literal()->AsInt()->value(), 3);
+ ASSERT_TRUE(ident->literal()->IsSint());
+ EXPECT_EQ(ident->literal()->AsSint()->value(), 3);
ASSERT_TRUE(val[3]->IsConstructor());
ASSERT_TRUE(val[3]->AsConstructor()->IsScalarConstructor());
ident = val[3]->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(ident->literal()->IsInt());
- EXPECT_EQ(ident->literal()->AsInt()->value(), 4);
+ ASSERT_TRUE(ident->literal()->IsSint());
+ EXPECT_EQ(ident->literal()->AsSint()->value(), 4);
}
TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_InvalidTypeDecl) {
diff --git a/src/reader/wgsl/parser_impl_unary_expression_test.cc b/src/reader/wgsl/parser_impl_unary_expression_test.cc
index fad15fc..0484162d 100644
--- a/src/reader/wgsl/parser_impl_unary_expression_test.cc
+++ b/src/reader/wgsl/parser_impl_unary_expression_test.cc
@@ -15,8 +15,8 @@
#include "gtest/gtest.h"
#include "src/ast/array_accessor_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/unary_op_expression.h"
#include "src/reader/wgsl/parser_impl.h"
#include "src/reader/wgsl/parser_impl_test_helper.h"
@@ -41,8 +41,8 @@
ASSERT_TRUE(ary->idx_expr()->IsConstructor());
ASSERT_TRUE(ary->idx_expr()->AsConstructor()->IsScalarConstructor());
auto* init = ary->idx_expr()->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(init->literal()->IsInt());
- ASSERT_EQ(init->literal()->AsInt()->value(), 2);
+ ASSERT_TRUE(init->literal()->IsSint());
+ ASSERT_EQ(init->literal()->AsSint()->value(), 2);
}
TEST_F(ParserImplTest, UnaryExpression_Minus) {
@@ -59,8 +59,8 @@
ASSERT_TRUE(u->expr()->AsConstructor()->IsScalarConstructor());
auto* init = u->expr()->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(init->literal()->IsInt());
- EXPECT_EQ(init->literal()->AsInt()->value(), 1);
+ ASSERT_TRUE(init->literal()->IsSint());
+ EXPECT_EQ(init->literal()->AsSint()->value(), 1);
}
TEST_F(ParserImplTest, UnaryExpression_Minus_InvalidRHS) {
@@ -85,8 +85,8 @@
ASSERT_TRUE(u->expr()->AsConstructor()->IsScalarConstructor());
auto* init = u->expr()->AsConstructor()->AsScalarConstructor();
- ASSERT_TRUE(init->literal()->IsInt());
- EXPECT_EQ(init->literal()->AsInt()->value(), 1);
+ ASSERT_TRUE(init->literal()->IsSint());
+ EXPECT_EQ(init->literal()->AsSint()->value(), 1);
}
TEST_F(ParserImplTest, UnaryExpression_Bang_InvalidRHS) {
diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
index 3a8b29f..b3144ef 100644
--- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc
@@ -69,7 +69,7 @@
ASSERT_EQ(type, nullptr);
auto t = p->next();
- ASSERT_TRUE(t.IsIntLiteral());
+ ASSERT_TRUE(t.IsSintLiteral());
}
TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) {
diff --git a/src/reader/wgsl/token.cc b/src/reader/wgsl/token.cc
index 2976a95..a845d99 100644
--- a/src/reader/wgsl/token.cc
+++ b/src/reader/wgsl/token.cc
@@ -33,8 +33,8 @@
return "kStringLiteral";
case Token::Type::kFloatLiteral:
return "kFloatLiteral";
- case Token::Type::kIntLiteral:
- return "kIntLiteral";
+ case Token::Type::kSintLiteral:
+ return "kSintLiteral";
case Token::Type::kUintLiteral:
return "kUintLiteral";
case Token::Type::kUninitialized:
@@ -247,7 +247,7 @@
: type_(Type::kUintLiteral), source_(source), val_uint_(val) {}
Token::Token(const Source& source, int32_t val)
- : type_(Type::kIntLiteral), source_(source), val_int_(val) {}
+ : type_(Type::kSintLiteral), source_(source), val_int_(val) {}
Token::Token(const Source& source, float val)
: type_(Type::kFloatLiteral), source_(source), val_float_(val) {}
@@ -266,7 +266,7 @@
if (type_ == Type::kFloatLiteral) {
return std::to_string(val_float_);
}
- if (type_ == Type::kIntLiteral) {
+ if (type_ == Type::kSintLiteral) {
return std::to_string(val_int_);
}
if (type_ == Type::kUintLiteral) {
diff --git a/src/reader/wgsl/token.h b/src/reader/wgsl/token.h
index f5a2c5f..cca501b 100644
--- a/src/reader/wgsl/token.h
+++ b/src/reader/wgsl/token.h
@@ -46,9 +46,9 @@
kStringLiteral,
/// A float value
kFloatLiteral,
- /// An int value
- kIntLiteral,
- /// A uint value
+ /// An signed int value
+ kSintLiteral,
+ /// A unsigned int value
kUintLiteral,
/// A '&'
@@ -305,8 +305,8 @@
bool IsStringLiteral() const { return type_ == Type::kStringLiteral; }
/// @returns true if the token is a float
bool IsFloatLiteral() const { return type_ == Type::kFloatLiteral; }
- /// @returns true if the token is an int
- bool IsIntLiteral() const { return type_ == Type::kIntLiteral; }
+ /// @returns true if the token is an signed int
+ bool IsSintLiteral() const { return type_ == Type::kSintLiteral; }
/// @returns true if the token is a unsigned int
bool IsUintLiteral() const { return type_ == Type::kUintLiteral; }
diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc
index bd4a04f..0b746a9 100644
--- a/src/type_determiner_test.cc
+++ b/src/type_determiner_test.cc
@@ -33,11 +33,11 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/loop_statement.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/switch_statement.h"
@@ -112,7 +112,7 @@
ast::type::I32Type i32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -133,7 +133,7 @@
ast::type::I32Type i32;
auto cond = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* cond_ptr = cond.get();
ast::BreakStatement brk(ast::StatementCondition::kIf, std::move(cond));
@@ -154,7 +154,7 @@
ast::type::F32Type f32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -166,7 +166,7 @@
std::move(rhs)));
ast::CaseSelectorList lit;
- lit.push_back(std::make_unique<ast::IntLiteral>(&i32, 3));
+ lit.push_back(std::make_unique<ast::SintLiteral>(&i32, 3));
ast::CaseStatement cse(std::move(lit), std::move(body));
EXPECT_TRUE(td()->DetermineResultType(&cse));
@@ -180,7 +180,7 @@
ast::type::I32Type i32;
auto cond = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* cond_ptr = cond.get();
ast::ContinueStatement stmt(ast::StatementCondition::kIf, std::move(cond));
@@ -201,7 +201,7 @@
ast::type::F32Type f32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -213,7 +213,7 @@
std::move(rhs)));
ast::ElseStatement stmt(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3)),
+ std::make_unique<ast::SintLiteral>(&i32, 3)),
std::move(body));
EXPECT_TRUE(td()->DetermineResultType(&stmt));
@@ -230,7 +230,7 @@
ast::type::F32Type f32;
auto else_lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* else_lhs_ptr = else_lhs.get();
auto else_rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -243,14 +243,14 @@
auto else_stmt = std::make_unique<ast::ElseStatement>(
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3)),
+ std::make_unique<ast::SintLiteral>(&i32, 3)),
std::move(else_body));
ast::ElseStatementList else_stmts;
else_stmts.push_back(std::move(else_stmt));
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -262,7 +262,7 @@
std::move(rhs)));
ast::IfStatement stmt(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3)),
+ std::make_unique<ast::SintLiteral>(&i32, 3)),
std::move(body));
stmt.set_else_statements(std::move(else_stmts));
@@ -284,7 +284,7 @@
ast::type::F32Type f32;
auto body_lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* body_lhs_ptr = body_lhs.get();
auto body_rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -296,7 +296,7 @@
std::move(body_lhs), std::move(body_rhs)));
auto continuing_lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* continuing_lhs_ptr = continuing_lhs.get();
auto continuing_rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -324,7 +324,7 @@
ast::type::I32Type i32;
auto cond = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* cond_ptr = cond.get();
ast::ReturnStatement ret(std::move(cond));
@@ -345,7 +345,7 @@
ast::type::F32Type f32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -357,14 +357,14 @@
std::move(rhs)));
ast::CaseSelectorList lit;
- lit.push_back(std::make_unique<ast::IntLiteral>(&i32, 3));
+ lit.push_back(std::make_unique<ast::SintLiteral>(&i32, 3));
ast::CaseStatementList cases;
cases.push_back(
std::make_unique<ast::CaseStatement>(std::move(lit), std::move(body)));
ast::SwitchStatement stmt(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)),
+ std::make_unique<ast::SintLiteral>(&i32, 2)),
std::move(cases));
EXPECT_TRUE(td()->DetermineResultType(&stmt)) << td()->error();
@@ -382,7 +382,7 @@
ast::type::F32Type f32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto* lhs_ptr = lhs.get();
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
@@ -395,7 +395,7 @@
ast::UnlessStatement unless(
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3)),
+ std::make_unique<ast::SintLiteral>(&i32, 3)),
std::move(body));
EXPECT_TRUE(td()->DetermineResultType(&unless));
@@ -412,7 +412,7 @@
auto var =
std::make_unique<ast::Variable>("my_var", ast::StorageClass::kNone, &i32);
var->set_constructor(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
auto* init_ptr = var->constructor();
ast::VariableDeclStatement decl(std::move(var));
@@ -436,7 +436,7 @@
ast::type::ArrayType ary(&f32, 3);
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto var = std::make_unique<ast::Variable>(
"my_var", ast::StorageClass::kFunction, &ary);
mod()->AddGlobalVariable(std::move(var));
@@ -460,7 +460,7 @@
ast::type::ArrayType ary(&f32, 3);
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto var = std::make_unique<ast::Variable>(
"my_var", ast::StorageClass::kFunction, &ary);
var->set_is_const(true);
@@ -482,7 +482,7 @@
ast::type::MatrixType mat(&f32, 3, 2);
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto var =
std::make_unique<ast::Variable>("my_var", ast::StorageClass::kNone, &mat);
mod()->AddGlobalVariable(std::move(var));
@@ -507,9 +507,9 @@
ast::type::MatrixType mat(&f32, 3, 2);
auto idx1 = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto idx2 = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1));
+ std::make_unique<ast::SintLiteral>(&i32, 1));
auto var =
std::make_unique<ast::Variable>("my_var", ast::StorageClass::kNone, &mat);
mod()->AddGlobalVariable(std::move(var));
@@ -537,7 +537,7 @@
ast::type::VectorType vec(&f32, 3);
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2));
+ std::make_unique<ast::SintLiteral>(&i32, 2));
auto var =
std::make_unique<ast::Variable>("my_var", ast::StorageClass::kNone, &vec);
mod()->AddGlobalVariable(std::move(var));
@@ -953,7 +953,7 @@
auto mem_ident = std::make_unique<ast::IdentifierExpression>("mem");
auto foo_ident = std::make_unique<ast::IdentifierExpression>("foo");
auto idx = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 0));
+ std::make_unique<ast::SintLiteral>(&i32, 0));
auto swizzle = std::make_unique<ast::IdentifierExpression>("yx");
ast::MemberAccessorExpression mem(
@@ -1851,7 +1851,7 @@
ast::ExpressionList params;
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
@@ -1978,7 +1978,7 @@
ast::ExpressionList params;
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
@@ -2090,9 +2090,9 @@
ast::ExpressionList params;
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
@@ -2295,9 +2295,9 @@
ast::ExpressionList params;
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
@@ -2498,11 +2498,11 @@
ast::ExpressionList params;
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
params.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3)));
+ std::make_unique<ast::SintLiteral>(&i32, 3)));
ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error();
diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc
index 102d849..cc3b433 100644
--- a/src/writer/spirv/builder.cc
+++ b/src/writer/spirv/builder.cc
@@ -33,7 +33,6 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/location_decoration.h"
#include "src/ast/loop_statement.h"
#include "src/ast/member_accessor_expression.h"
@@ -41,6 +40,7 @@
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/set_decoration.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/struct_member_offset_decoration.h"
@@ -218,7 +218,7 @@
uint32_t Builder::GenerateU32Literal(uint32_t val) {
ast::type::U32Type u32;
- ast::IntLiteral lit(&u32, val);
+ ast::SintLiteral lit(&u32, val);
return GenerateLiteralIfNeeded(&lit);
}
@@ -995,9 +995,9 @@
} else {
push_type(spv::Op::OpConstantFalse, {Operand::Int(type_id), result});
}
- } else if (lit->IsInt()) {
+ } else if (lit->IsSint()) {
push_type(spv::Op::OpConstant, {Operand::Int(type_id), result,
- Operand::Int(lit->AsInt()->value())});
+ Operand::Int(lit->AsSint()->value())});
} else if (lit->IsUint()) {
push_type(spv::Op::OpConstant, {Operand::Int(type_id), result,
Operand::Int(lit->AsUint()->value())});
@@ -1366,12 +1366,12 @@
case_ids.push_back(block_id);
for (const auto& selector : item->selectors()) {
- if (!selector->IsInt()) {
+ if (!selector->IsSint()) {
error_ = "expected integer literal for switch case label";
return false;
}
- params.push_back(Operand::Int(selector->AsInt()->value()));
+ params.push_back(Operand::Int(selector->AsSint()->value()));
params.push_back(Operand::Int(block_id));
}
}
diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc
index d96554e..44b5038 100644
--- a/src/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/writer/spirv/builder_accessor_expression_test.cc
@@ -18,10 +18,10 @@
#include "src/ast/binary_expression.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/type/array_type.h"
@@ -54,7 +54,7 @@
auto ary = std::make_unique<ast::IdentifierExpression>("ary");
auto idx_expr = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1));
+ std::make_unique<ast::SintLiteral>(&i32, 1));
ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx_expr));
@@ -152,9 +152,9 @@
std::move(ary), std::make_unique<ast::BinaryExpression>(
ast::BinaryOp::kAdd,
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)),
+ std::make_unique<ast::SintLiteral>(&i32, 1)),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
Context ctx;
ast::Module mod;
@@ -201,9 +201,9 @@
std::make_unique<ast::ArrayAccessorExpression>(
std::make_unique<ast::IdentifierExpression>("ary"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))),
+ std::make_unique<ast::SintLiteral>(&i32, 3))),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
Context ctx;
ast::Module mod;
@@ -252,7 +252,7 @@
std::make_unique<ast::ArrayAccessorExpression>(
std::make_unique<ast::IdentifierExpression>("ary"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))),
+ std::make_unique<ast::SintLiteral>(&i32, 2))),
std::make_unique<ast::IdentifierExpression>("xy"));
Context ctx;
@@ -811,7 +811,7 @@
std::make_unique<ast::IdentifierExpression>("ident"),
std::make_unique<ast::IdentifierExpression>("yxz")),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
Context ctx;
ast::Module mod;
@@ -896,10 +896,10 @@
std::make_unique<ast::ArrayAccessorExpression>(
std::make_unique<ast::IdentifierExpression>("index"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 0))),
+ std::make_unique<ast::SintLiteral>(&i32, 0))),
std::make_unique<ast::IdentifierExpression>("foo")),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))),
+ std::make_unique<ast::SintLiteral>(&i32, 2))),
std::make_unique<ast::IdentifierExpression>("bar")),
std::make_unique<ast::IdentifierExpression>("baz")),
std::make_unique<ast::IdentifierExpression>("yx"));
diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc
index 3c54677..46875a7 100644
--- a/src/writer/spirv/builder_assign_test.cc
+++ b/src/writer/spirv/builder_assign_test.cc
@@ -19,9 +19,9 @@
#include "src/ast/assignment_statement.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
#include "src/ast/type/f32_type.h"
@@ -252,7 +252,7 @@
auto ident = std::make_unique<ast::ArrayAccessorExpression>(
std::make_unique<ast::IdentifierExpression>("var"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
auto val = std::make_unique<ast::ScalarConstructorExpression>(
std::make_unique<ast::FloatLiteral>(&f32, 1.0f));
diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc
index bf73129..83f7ebb 100644
--- a/src/writer/spirv/builder_binary_expression_test.cc
+++ b/src/writer/spirv/builder_binary_expression_test.cc
@@ -18,14 +18,15 @@
#include "src/ast/binary_expression.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/matrix_type.h"
#include "src/ast/type/u32_type.h"
#include "src/ast/type/vector_type.h"
#include "src/ast/type_constructor_expression.h"
+#include "src/ast/uint_literal.h"
#include "src/context.h"
#include "src/type_determiner.h"
#include "src/writer/spirv/builder.h"
@@ -54,9 +55,9 @@
ast::type::I32Type i32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3));
+ std::make_unique<ast::SintLiteral>(&i32, 3));
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 4));
+ std::make_unique<ast::SintLiteral>(&i32, 4));
ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs));
@@ -84,20 +85,20 @@
ast::ExpressionList vals;
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
auto lhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
auto rhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
@@ -144,9 +145,9 @@
ast::type::U32Type u32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 3));
+ std::make_unique<ast::UintLiteral>(&u32, 3));
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 4));
+ std::make_unique<ast::UintLiteral>(&u32, 4));
ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs));
@@ -174,20 +175,20 @@
ast::ExpressionList vals;
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
auto lhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
auto rhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
@@ -318,9 +319,9 @@
ast::type::U32Type u32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 3));
+ std::make_unique<ast::UintLiteral>(&u32, 3));
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 4));
+ std::make_unique<ast::UintLiteral>(&u32, 4));
ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs));
@@ -350,20 +351,20 @@
ast::ExpressionList vals;
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
auto lhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&u32, 1)));
+ std::make_unique<ast::UintLiteral>(&u32, 1)));
auto rhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
@@ -407,9 +408,9 @@
ast::type::I32Type i32;
auto lhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3));
+ std::make_unique<ast::SintLiteral>(&i32, 3));
auto rhs = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 4));
+ std::make_unique<ast::SintLiteral>(&i32, 4));
ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs));
@@ -439,20 +440,20 @@
ast::ExpressionList vals;
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
auto lhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
vals.push_back(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
auto rhs =
std::make_unique<ast::TypeConstructorExpression>(&vec3, std::move(vals));
diff --git a/src/writer/spirv/builder_cast_expression_test.cc b/src/writer/spirv/builder_cast_expression_test.cc
index ecb248c..c559ec9 100644
--- a/src/writer/spirv/builder_cast_expression_test.cc
+++ b/src/writer/spirv/builder_cast_expression_test.cc
@@ -16,9 +16,9 @@
#include "src/ast/cast_expression.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/module.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/u32_type.h"
@@ -93,7 +93,7 @@
ast::CastExpression cast(&f32,
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
Context ctx;
ast::Module mod;
@@ -211,7 +211,7 @@
ast::CastExpression cast(&u32,
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
Context ctx;
ast::Module mod;
@@ -262,7 +262,7 @@
ast::CastExpression cast(&i32,
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
Context ctx;
ast::Module mod;
diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc
index c481330..147af57 100644
--- a/src/writer/spirv/builder_ident_expression_test.cc
+++ b/src/writer/spirv/builder_ident_expression_test.cc
@@ -18,8 +18,8 @@
#include "src/ast/binary_expression.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/vector_type.h"
@@ -220,7 +220,7 @@
ast::Variable var("var", ast::StorageClass::kNone, &i32);
var.set_constructor(std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2)));
+ std::make_unique<ast::SintLiteral>(&i32, 2)));
var.set_is_const(true);
td.RegisterVariableForTesting(&var);
diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc
index e7109ab..7818e5d 100644
--- a/src/writer/spirv/builder_if_test.cc
+++ b/src/writer/spirv/builder_if_test.cc
@@ -22,10 +22,10 @@
#include "src/ast/else_statement.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/loop_statement.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/statement_condition.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/i32_type.h"
@@ -86,7 +86,7 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
auto cond = std::make_unique<ast::ScalarConstructorExpression>(
std::make_unique<ast::BoolLiteral>(&bool_type, true));
@@ -138,13 +138,13 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList else_body;
else_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
ast::ElseStatementList else_stmts;
else_stmts.push_back(
@@ -206,13 +206,13 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList else_body;
else_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
auto else_cond = std::make_unique<ast::ScalarConstructorExpression>(
std::make_unique<ast::BoolLiteral>(&bool_type, true));
@@ -286,22 +286,22 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList elseif_1_body;
elseif_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
ast::StatementList elseif_2_body;
elseif_2_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 4))));
+ std::make_unique<ast::SintLiteral>(&i32, 4))));
ast::StatementList else_body;
else_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 5))));
+ std::make_unique<ast::SintLiteral>(&i32, 5))));
auto elseif_1_cond = std::make_unique<ast::ScalarConstructorExpression>(
std::make_unique<ast::BoolLiteral>(&bool_type, true));
diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc
index a2307ff..1c96661 100644
--- a/src/writer/spirv/builder_literal_test.cc
+++ b/src/writer/spirv/builder_literal_test.cc
@@ -16,8 +16,8 @@
#include "spirv/unified1/spirv.h"
#include "src/ast/bool_literal.h"
#include "src/ast/float_literal.h"
-#include "src/ast/int_literal.h"
#include "src/ast/literal.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
@@ -84,7 +84,7 @@
TEST_F(BuilderTest, Literal_I32) {
ast::type::I32Type i32;
- ast::IntLiteral i(&i32, -23);
+ ast::SintLiteral i(&i32, -23);
ast::Module mod;
Builder b(&mod);
@@ -99,8 +99,8 @@
TEST_F(BuilderTest, Literal_I32_Dedup) {
ast::type::I32Type i32;
- ast::IntLiteral i1(&i32, -23);
- ast::IntLiteral i2(&i32, -23);
+ ast::SintLiteral i1(&i32, -23);
+ ast::SintLiteral i2(&i32, -23);
ast::Module mod;
Builder b(&mod);
diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc
index 0b59ac3..d5bfe5b 100644
--- a/src/writer/spirv/builder_loop_test.cc
+++ b/src/writer/spirv/builder_loop_test.cc
@@ -19,9 +19,9 @@
#include "src/ast/break_statement.h"
#include "src/ast/continue_statement.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/loop_statement.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/i32_type.h"
#include "src/context.h"
#include "src/type_determiner.h"
@@ -76,7 +76,7 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList continuing;
ast::LoopStatement expr(std::move(body), std::move(continuing));
@@ -128,13 +128,13 @@
body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList continuing;
continuing.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
ast::LoopStatement expr(std::move(body), std::move(continuing));
Context ctx;
diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc
index c9fec10..3637a92 100644
--- a/src/writer/spirv/builder_switch_test.cc
+++ b/src/writer/spirv/builder_switch_test.cc
@@ -22,8 +22,8 @@
#include "src/ast/fallthrough_statement.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/i32_type.h"
@@ -45,7 +45,7 @@
// switch (1) {
// }
auto cond = std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1));
+ std::make_unique<ast::SintLiteral>(&i32, 1));
ast::SwitchStatement expr(std::move(cond), ast::CaseStatementList{});
@@ -89,19 +89,19 @@
case_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
ast::StatementList case_2_body;
case_2_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::CaseSelectorList selector_1;
- selector_1.push_back(std::make_unique<ast::IntLiteral>(&i32, 1));
+ selector_1.push_back(std::make_unique<ast::SintLiteral>(&i32, 1));
ast::CaseSelectorList selector_2;
- selector_2.push_back(std::make_unique<ast::IntLiteral>(&i32, 2));
+ selector_2.push_back(std::make_unique<ast::SintLiteral>(&i32, 2));
ast::CaseStatementList cases;
cases.push_back(std::make_unique<ast::CaseStatement>(std::move(selector_1),
@@ -174,7 +174,7 @@
default_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
ast::CaseStatementList cases;
cases.push_back(
@@ -243,26 +243,26 @@
case_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
ast::StatementList case_2_body;
case_2_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList default_body;
default_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
ast::CaseSelectorList selector_1;
- selector_1.push_back(std::make_unique<ast::IntLiteral>(&i32, 1));
+ selector_1.push_back(std::make_unique<ast::SintLiteral>(&i32, 1));
ast::CaseSelectorList selector_2;
- selector_2.push_back(std::make_unique<ast::IntLiteral>(&i32, 2));
- selector_2.push_back(std::make_unique<ast::IntLiteral>(&i32, 3));
+ selector_2.push_back(std::make_unique<ast::SintLiteral>(&i32, 2));
+ selector_2.push_back(std::make_unique<ast::SintLiteral>(&i32, 3));
ast::CaseStatementList cases;
cases.push_back(std::make_unique<ast::CaseStatement>(std::move(selector_1),
@@ -344,26 +344,26 @@
case_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
case_1_body.push_back(std::make_unique<ast::FallthroughStatement>());
ast::StatementList case_2_body;
case_2_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 2))));
+ std::make_unique<ast::SintLiteral>(&i32, 2))));
ast::StatementList default_body;
default_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 3))));
+ std::make_unique<ast::SintLiteral>(&i32, 3))));
ast::CaseSelectorList selector_1;
- selector_1.push_back(std::make_unique<ast::IntLiteral>(&i32, 1));
+ selector_1.push_back(std::make_unique<ast::SintLiteral>(&i32, 1));
ast::CaseSelectorList selector_2;
- selector_2.push_back(std::make_unique<ast::IntLiteral>(&i32, 2));
+ selector_2.push_back(std::make_unique<ast::SintLiteral>(&i32, 2));
ast::CaseStatementList cases;
cases.push_back(std::make_unique<ast::CaseStatement>(std::move(selector_1),
@@ -441,11 +441,11 @@
case_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
case_1_body.push_back(std::make_unique<ast::FallthroughStatement>());
ast::CaseSelectorList selector_1;
- selector_1.push_back(std::make_unique<ast::IntLiteral>(&i32, 1));
+ selector_1.push_back(std::make_unique<ast::SintLiteral>(&i32, 1));
ast::CaseStatementList cases;
cases.push_back(std::make_unique<ast::CaseStatement>(std::move(selector_1),
@@ -511,10 +511,10 @@
case_1_body.push_back(std::make_unique<ast::AssignmentStatement>(
std::make_unique<ast::IdentifierExpression>("v"),
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1))));
+ std::make_unique<ast::SintLiteral>(&i32, 1))));
ast::CaseSelectorList selector_1;
- selector_1.push_back(std::make_unique<ast::IntLiteral>(&i32, 1));
+ selector_1.push_back(std::make_unique<ast::SintLiteral>(&i32, 1));
ast::CaseStatementList cases;
cases.push_back(std::make_unique<ast::CaseStatement>(std::move(selector_1),
diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc
index 1065115..2b4be37 100644
--- a/src/writer/spirv/builder_unary_op_expression_test.cc
+++ b/src/writer/spirv/builder_unary_op_expression_test.cc
@@ -17,8 +17,8 @@
#include "gtest/gtest.h"
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/f32_type.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/unary_op_expression.h"
@@ -40,7 +40,7 @@
ast::UnaryOpExpression expr(
ast::UnaryOp::kNegation,
std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
Context ctx;
ast::Module mod;
@@ -89,7 +89,7 @@
ast::UnaryOpExpression expr(
ast::UnaryOp::kNot, std::make_unique<ast::ScalarConstructorExpression>(
- std::make_unique<ast::IntLiteral>(&i32, 1)));
+ std::make_unique<ast::SintLiteral>(&i32, 1)));
Context ctx;
ast::Module mod;
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index 9638f48..f27f518 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -35,13 +35,13 @@
#include "src/ast/float_literal.h"
#include "src/ast/identifier_expression.h"
#include "src/ast/if_statement.h"
-#include "src/ast/int_literal.h"
#include "src/ast/location_decoration.h"
#include "src/ast/loop_statement.h"
#include "src/ast/member_accessor_expression.h"
#include "src/ast/return_statement.h"
#include "src/ast/scalar_constructor_expression.h"
#include "src/ast/set_decoration.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/statement.h"
#include "src/ast/struct.h"
#include "src/ast/struct_member.h"
@@ -299,8 +299,8 @@
out_.precision(precision);
out_.flags(flags);
- } else if (lit->IsInt()) {
- out_ << lit->AsInt()->value();
+ } else if (lit->IsSint()) {
+ out_ << lit->AsSint()->value();
} else if (lit->IsUint()) {
out_ << lit->AsUint()->value() << "u";
} else {
diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc
index 437fcba..8e98eb8 100644
--- a/src/writer/wgsl/generator_impl_array_accessor_test.cc
+++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc
@@ -17,8 +17,8 @@
#include "gtest/gtest.h"
#include "src/ast/array_accessor_expression.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
@@ -31,7 +31,7 @@
TEST_F(GeneratorImplTest, EmitExpression_ArrayAccessor) {
ast::type::I32Type i32;
- auto lit = std::make_unique<ast::IntLiteral>(&i32, 5);
+ auto lit = std::make_unique<ast::SintLiteral>(&i32, 5);
auto idx = std::make_unique<ast::ScalarConstructorExpression>(std::move(lit));
auto ary = std::make_unique<ast::IdentifierExpression>("ary");
diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc
index 5a1a906..99374a9 100644
--- a/src/writer/wgsl/generator_impl_case_test.cc
+++ b/src/writer/wgsl/generator_impl_case_test.cc
@@ -18,7 +18,7 @@
#include "src/ast/break_statement.h"
#include "src/ast/case_statement.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
@@ -36,7 +36,7 @@
body.push_back(std::make_unique<ast::BreakStatement>());
ast::CaseSelectorList lit;
- lit.push_back(std::make_unique<ast::IntLiteral>(&i32, 5));
+ lit.push_back(std::make_unique<ast::SintLiteral>(&i32, 5));
ast::CaseStatement c(std::move(lit), std::move(body));
GeneratorImpl g;
@@ -56,8 +56,8 @@
body.push_back(std::make_unique<ast::BreakStatement>());
ast::CaseSelectorList lit;
- lit.push_back(std::make_unique<ast::IntLiteral>(&i32, 5));
- lit.push_back(std::make_unique<ast::IntLiteral>(&i32, 6));
+ lit.push_back(std::make_unique<ast::SintLiteral>(&i32, 5));
+ lit.push_back(std::make_unique<ast::SintLiteral>(&i32, 6));
ast::CaseStatement c(std::move(lit), std::move(body));
GeneratorImpl g;
diff --git a/src/writer/wgsl/generator_impl_constructor_test.cc b/src/writer/wgsl/generator_impl_constructor_test.cc
index 8eba2b1..9565ae8 100644
--- a/src/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/writer/wgsl/generator_impl_constructor_test.cc
@@ -15,8 +15,8 @@
#include "gtest/gtest.h"
#include "src/ast/bool_literal.h"
#include "src/ast/float_literal.h"
-#include "src/ast/int_literal.h"
#include "src/ast/scalar_constructor_expression.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/type/array_type.h"
#include "src/ast/type/bool_type.h"
#include "src/ast/type/f32_type.h"
@@ -46,7 +46,7 @@
TEST_F(GeneratorImplTest, EmitConstructor_Int) {
ast::type::I32Type i32;
- auto lit = std::make_unique<ast::IntLiteral>(&i32, -12345);
+ auto lit = std::make_unique<ast::SintLiteral>(&i32, -12345);
ast::ScalarConstructorExpression expr(std::move(lit));
GeneratorImpl g;
@@ -107,7 +107,7 @@
TEST_F(GeneratorImplTest, EmitConstructor_Type_Int) {
ast::type::I32Type i32;
- auto lit = std::make_unique<ast::IntLiteral>(&i32, -12345);
+ auto lit = std::make_unique<ast::SintLiteral>(&i32, -12345);
ast::ExpressionList values;
values.push_back(
std::make_unique<ast::ScalarConstructorExpression>(std::move(lit)));
diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc
index b149541..b018da0 100644
--- a/src/writer/wgsl/generator_impl_switch_test.cc
+++ b/src/writer/wgsl/generator_impl_switch_test.cc
@@ -18,7 +18,7 @@
#include "src/ast/break_statement.h"
#include "src/ast/case_statement.h"
#include "src/ast/identifier_expression.h"
-#include "src/ast/int_literal.h"
+#include "src/ast/sint_literal.h"
#include "src/ast/switch_statement.h"
#include "src/ast/type/i32_type.h"
#include "src/writer/wgsl/generator_impl.h"
@@ -38,7 +38,7 @@
ast::type::I32Type i32;
ast::CaseSelectorList case_val;
- case_val.push_back(std::make_unique<ast::IntLiteral>(&i32, 5));
+ case_val.push_back(std::make_unique<ast::SintLiteral>(&i32, 5));
ast::StatementList case_body;
case_body.push_back(std::make_unique<ast::BreakStatement>());