From c6f2947cebb41c3864e300a4f08d4a7c7a819099 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 2 Jun 2020 20:11:44 +0000 Subject: [PATCH] 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 --- BUILD.gn | 6 +- src/CMakeLists.txt | 6 +- src/ast/bool_literal_test.cc | 2 +- src/ast/case_statement_test.cc | 6 +- src/ast/float_literal_test.cc | 2 +- src/ast/literal.cc | 10 +-- src/ast/literal.h | 8 +- src/ast/null_literal_test.cc | 4 +- src/ast/{int_literal.cc => sint_literal.cc} | 14 ++-- src/ast/{int_literal.h => sint_literal.h} | 20 ++--- ...t_literal_test.cc => sint_literal_test.cc} | 32 ++++---- src/ast/uint_literal_test.cc | 2 +- src/reader/spirv/parser_impl.cc | 6 +- src/reader/wgsl/lexer_test.cc | 6 +- src/reader/wgsl/parser_impl.cc | 16 ++-- ...rser_impl_argument_expression_list_test.cc | 2 +- .../wgsl/parser_impl_assignment_stmt_test.cc | 14 ++-- .../wgsl/parser_impl_const_literal_test.cc | 6 +- .../parser_impl_postfix_expression_test.cc | 6 +- .../parser_impl_primary_expression_test.cc | 18 ++--- .../wgsl/parser_impl_unary_expression_test.cc | 14 ++-- .../parser_impl_variable_ident_decl_test.cc | 2 +- src/reader/wgsl/token.cc | 8 +- src/reader/wgsl/token.h | 10 +-- src/type_determiner_test.cc | 74 +++++++++---------- src/writer/spirv/builder.cc | 12 +-- .../spirv/builder_accessor_expression_test.cc | 20 ++--- src/writer/spirv/builder_assign_test.cc | 4 +- .../spirv/builder_binary_expression_test.cc | 67 ++++++++--------- .../spirv/builder_cast_expression_test.cc | 8 +- .../spirv/builder_ident_expression_test.cc | 4 +- src/writer/spirv/builder_if_test.cc | 20 ++--- src/writer/spirv/builder_literal_test.cc | 8 +- src/writer/spirv/builder_loop_test.cc | 8 +- src/writer/spirv/builder_switch_test.cc | 44 +++++------ .../spirv/builder_unary_op_expression_test.cc | 6 +- src/writer/wgsl/generator_impl.cc | 6 +- .../generator_impl_array_accessor_test.cc | 4 +- src/writer/wgsl/generator_impl_case_test.cc | 8 +- .../wgsl/generator_impl_constructor_test.cc | 6 +- src/writer/wgsl/generator_impl_switch_test.cc | 4 +- 41 files changed, 262 insertions(+), 261 deletions(-) rename src/ast/{int_literal.cc => sint_literal.cc} (70%) rename src/ast/{int_literal.h => sint_literal.h} (74%) rename src/ast/{int_literal_test.cc => sint_literal_test.cc} (68%) diff --git a/BUILD.gn b/BUILD.gn index 2adbf02b6e..9570e28ac1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -248,8 +248,6 @@ source_set("libtint_core_src") { "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 @@ source_set("libtint_core_src") { "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 @@ source_set("tint_unittests_core_src") { "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 @@ source_set("tint_unittests_core_src") { "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 e731adb36d..5875054d6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,8 +85,6 @@ set(TINT_LIB_SRCS 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 @@ set(TINT_LIB_SRCS 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 @@ set(TINT_TEST_SRCS 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 @@ set(TINT_TEST_SRCS 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 b8dc640056..3c37042b7b 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -43,7 +43,7 @@ TEST_F(BoolLiteralTest, Is) { 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 bc53f579a2..cdc59826f1 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 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { ast::type::I32Type i32; CaseSelectorList b; - b.push_back(std::make_unique(&i32, 1)); - b.push_back(std::make_unique(&i32, 2)); + b.push_back(std::make_unique(&i32, 1)); + b.push_back(std::make_unique(&i32, 2)); StatementList stmts; stmts.push_back(std::make_unique()); 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 960a7dd42a..028b623898 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -34,7 +34,7 @@ TEST_F(FloatLiteralTest, Is) { 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 489a32c671..6dcf084515 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 @@ bool Literal::IsFloat() const { return false; } -bool Literal::IsInt() const { +bool Literal::IsSint() const { return false; } @@ -59,9 +59,9 @@ FloatLiteral* Literal::AsFloat() { return static_cast(this); } -IntLiteral* Literal::AsInt() { - assert(IsInt()); - return static_cast(this); +SintLiteral* Literal::AsSint() { + assert(IsSint()); + return static_cast(this); } NullLiteral* Literal::AsNull() { diff --git a/src/ast/literal.h b/src/ast/literal.h index 54079cd29f..16957a9d3a 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -24,8 +24,8 @@ namespace ast { class BoolLiteral; class FloatLiteral; -class IntLiteral; class NullLiteral; +class SintLiteral; class UintLiteral; /// Base class for a literal value @@ -38,7 +38,7 @@ class Literal { /// @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 @@ class Literal { 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 67354f697d..62bd62efda 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -27,7 +27,7 @@ TEST_F(NullLiteralTest, Is) { 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 @@ TEST_F(NullLiteralTest, Name_I32) { } // 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 30a4676c38..4f9f79c71d 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 1a72749517..6c62aad5f0 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 @@ -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 @@ class IntLiteral : public Literal { } // 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 9bb2307e65..ad4ccb9dbd 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 tint { 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 841ad2253d..5fab7489a6 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -34,7 +34,7 @@ TEST_F(UintLiteralTest, Is) { 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 29a952ee58..623ac51d72 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 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) { } if (ast_type->IsI32()) { return {ast_type, std::make_unique( - std::make_unique( + std::make_unique( ast_type, spirv_const->GetS32()))}; } if (ast_type->IsF32()) { @@ -954,7 +954,7 @@ std::unique_ptr ParserImpl::MakeNullValue( } if (type->IsI32()) { return std::make_unique( - std::make_unique(type, 0)); + std::make_unique(type, 0)); } if (type->IsF32()) { return std::make_unique( diff --git a/src/reader/wgsl/lexer_test.cc b/src/reader/wgsl/lexer_test.cc index 12170dce7b..9bed255526 100644 --- a/src/reader/wgsl/lexer_test.cc +++ b/src/reader/wgsl/lexer_test.cc @@ -201,7 +201,7 @@ TEST_P(IntegerTest_HexSigned, Matches) { 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 @@ TEST_P(IntegerTest_Signed, Matches) { 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 @@ TEST_P(IntegerTest_Invalid, Parses) { 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 36d82e438d..038e397f54 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 @@ std::unique_ptr ParserImpl::variable_decoration() { 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 @@ std::unique_ptr ParserImpl::variable_decoration() { 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 @@ std::unique_ptr ParserImpl::variable_decoration() { 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 @@ ast::type::Type* ParserImpl::type_decl_array(Token t) { 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 @@ ParserImpl::struct_member_decoration() { 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 @@ std::unique_ptr ParserImpl::const_literal() { } return std::make_unique(type, false); } - if (t.IsIntLiteral()) { + if (t.IsSintLiteral()) { next(); // Consume the peek auto* type = ctx_.type_mgr().Get(std::make_unique()); if (!type) { return nullptr; } - return std::make_unique(type, t.to_i32()); + return std::make_unique(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 efbd7313b0..b91122f9e0 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 9624223877..fd7778f863 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 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) { 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 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { 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 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { 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 74bc6e23fd..3a5420a909 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 @@ TEST_F(ParserImplTest, ConstLiteral_Int) { 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 960bdf33f4..9baf8a62b3 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 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) { 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 1be32d7f45..a5fd1d98f8 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 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) { 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 fad15fc34c..0484162d5f 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 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) { 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 @@ TEST_F(ParserImplTest, UnaryExpression_Minus) { 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 @@ TEST_F(ParserImplTest, UnaryExpression_Bang) { 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 3a8b29fb7c..b3144ef386 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 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidIdent) { 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 2976a95fe8..a845d99065 100644 --- a/src/reader/wgsl/token.cc +++ b/src/reader/wgsl/token.cc @@ -33,8 +33,8 @@ std::string Token::TypeToName(Type type) { 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 @@ Token::Token(const Source& source, uint32_t val) : 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 @@ std::string Token::to_str() const { 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 f5a2c5f3ce..cca501b291 100644 --- a/src/reader/wgsl/token.h +++ b/src/reader/wgsl/token.h @@ -46,9 +46,9 @@ class Token { 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 @@ class Token { 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 bd4a04fc9b..0b746a9cd9 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 @@ TEST_F(TypeDeterminerTest, Stmt_Assign) { ast::type::I32Type i32; auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -133,7 +133,7 @@ TEST_F(TypeDeterminerTest, Stmt_Break) { ast::type::I32Type i32; auto cond = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* cond_ptr = cond.get(); ast::BreakStatement brk(ast::StatementCondition::kIf, std::move(cond)); @@ -154,7 +154,7 @@ TEST_F(TypeDeterminerTest, Stmt_Case) { ast::type::F32Type f32; auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -166,7 +166,7 @@ TEST_F(TypeDeterminerTest, Stmt_Case) { std::move(rhs))); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 3)); + lit.push_back(std::make_unique(&i32, 3)); ast::CaseStatement cse(std::move(lit), std::move(body)); EXPECT_TRUE(td()->DetermineResultType(&cse)); @@ -180,7 +180,7 @@ TEST_F(TypeDeterminerTest, Stmt_Continue) { ast::type::I32Type i32; auto cond = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* cond_ptr = cond.get(); ast::ContinueStatement stmt(ast::StatementCondition::kIf, std::move(cond)); @@ -201,7 +201,7 @@ TEST_F(TypeDeterminerTest, Stmt_Else) { ast::type::F32Type f32; auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -213,7 +213,7 @@ TEST_F(TypeDeterminerTest, Stmt_Else) { std::move(rhs))); ast::ElseStatement stmt(std::make_unique( - std::make_unique(&i32, 3)), + std::make_unique(&i32, 3)), std::move(body)); EXPECT_TRUE(td()->DetermineResultType(&stmt)); @@ -230,7 +230,7 @@ TEST_F(TypeDeterminerTest, Stmt_If) { ast::type::F32Type f32; auto else_lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* else_lhs_ptr = else_lhs.get(); auto else_rhs = std::make_unique( @@ -243,14 +243,14 @@ TEST_F(TypeDeterminerTest, Stmt_If) { auto else_stmt = std::make_unique( std::make_unique( - std::make_unique(&i32, 3)), + std::make_unique(&i32, 3)), std::move(else_body)); ast::ElseStatementList else_stmts; else_stmts.push_back(std::move(else_stmt)); auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -262,7 +262,7 @@ TEST_F(TypeDeterminerTest, Stmt_If) { std::move(rhs))); ast::IfStatement stmt(std::make_unique( - std::make_unique(&i32, 3)), + std::make_unique(&i32, 3)), std::move(body)); stmt.set_else_statements(std::move(else_stmts)); @@ -284,7 +284,7 @@ TEST_F(TypeDeterminerTest, Stmt_Loop) { ast::type::F32Type f32; auto body_lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* body_lhs_ptr = body_lhs.get(); auto body_rhs = std::make_unique( @@ -296,7 +296,7 @@ TEST_F(TypeDeterminerTest, Stmt_Loop) { std::move(body_lhs), std::move(body_rhs))); auto continuing_lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* continuing_lhs_ptr = continuing_lhs.get(); auto continuing_rhs = std::make_unique( @@ -324,7 +324,7 @@ TEST_F(TypeDeterminerTest, Stmt_Return) { ast::type::I32Type i32; auto cond = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* cond_ptr = cond.get(); ast::ReturnStatement ret(std::move(cond)); @@ -345,7 +345,7 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) { ast::type::F32Type f32; auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -357,14 +357,14 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) { std::move(rhs))); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 3)); + lit.push_back(std::make_unique(&i32, 3)); ast::CaseStatementList cases; cases.push_back( std::make_unique(std::move(lit), std::move(body))); ast::SwitchStatement stmt(std::make_unique( - std::make_unique(&i32, 2)), + std::make_unique(&i32, 2)), std::move(cases)); EXPECT_TRUE(td()->DetermineResultType(&stmt)) << td()->error(); @@ -382,7 +382,7 @@ TEST_F(TypeDeterminerTest, Stmt_Unless) { ast::type::F32Type f32; auto lhs = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto* lhs_ptr = lhs.get(); auto rhs = std::make_unique( @@ -395,7 +395,7 @@ TEST_F(TypeDeterminerTest, Stmt_Unless) { ast::UnlessStatement unless( std::make_unique( - std::make_unique(&i32, 3)), + std::make_unique(&i32, 3)), std::move(body)); EXPECT_TRUE(td()->DetermineResultType(&unless)); @@ -412,7 +412,7 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { auto var = std::make_unique("my_var", ast::StorageClass::kNone, &i32); var->set_constructor(std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); auto* init_ptr = var->constructor(); ast::VariableDeclStatement decl(std::move(var)); @@ -436,7 +436,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { ast::type::ArrayType ary(&f32, 3); auto idx = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto var = std::make_unique( "my_var", ast::StorageClass::kFunction, &ary); mod()->AddGlobalVariable(std::move(var)); @@ -460,7 +460,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { ast::type::ArrayType ary(&f32, 3); auto idx = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto var = std::make_unique( "my_var", ast::StorageClass::kFunction, &ary); var->set_is_const(true); @@ -482,7 +482,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { ast::type::MatrixType mat(&f32, 3, 2); auto idx = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto var = std::make_unique("my_var", ast::StorageClass::kNone, &mat); mod()->AddGlobalVariable(std::move(var)); @@ -507,9 +507,9 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { ast::type::MatrixType mat(&f32, 3, 2); auto idx1 = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto idx2 = std::make_unique( - std::make_unique(&i32, 1)); + std::make_unique(&i32, 1)); auto var = std::make_unique("my_var", ast::StorageClass::kNone, &mat); mod()->AddGlobalVariable(std::move(var)); @@ -537,7 +537,7 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { ast::type::VectorType vec(&f32, 3); auto idx = std::make_unique( - std::make_unique(&i32, 2)); + std::make_unique(&i32, 2)); auto var = std::make_unique("my_var", ast::StorageClass::kNone, &vec); mod()->AddGlobalVariable(std::move(var)); @@ -953,7 +953,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { auto mem_ident = std::make_unique("mem"); auto foo_ident = std::make_unique("foo"); auto idx = std::make_unique( - std::make_unique(&i32, 0)); + std::make_unique(&i32, 0)); auto swizzle = std::make_unique("yx"); ast::MemberAccessorExpression mem( @@ -1851,7 +1851,7 @@ TEST_P(ImportData_SingleParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); @@ -1978,7 +1978,7 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) { ast::ExpressionList params; params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); @@ -2090,9 +2090,9 @@ TEST_P(ImportData_TwoParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); @@ -2295,9 +2295,9 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) { ast::ExpressionList params; params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); @@ -2498,11 +2498,11 @@ TEST_P(ImportData_ThreeParamTest, Error_Integer) { ast::ExpressionList params; params.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); params.push_back(std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); params.push_back(std::make_unique( - std::make_unique(&i32, 3))); + std::make_unique(&i32, 3))); ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 102d849ddc..cc3b433fd8 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 @@ void Builder::iterate(std::function cb) const { 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 @@ uint32_t Builder::GenerateLiteralIfNeeded(ast::Literal* lit) { } 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 @@ bool Builder::GenerateSwitchStatement(ast::SwitchStatement* stmt) { 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 d96554e75f..44b5038909 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 @@ TEST_F(BuilderTest, ArrayAccessor) { auto ary = std::make_unique("ary"); auto idx_expr = std::make_unique( - std::make_unique(&i32, 1)); + std::make_unique(&i32, 1)); ast::ArrayAccessorExpression expr(std::move(ary), std::move(idx_expr)); @@ -152,9 +152,9 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { std::move(ary), std::make_unique( ast::BinaryOp::kAdd, std::make_unique( - std::make_unique(&i32, 1)), + std::make_unique(&i32, 1)), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); Context ctx; ast::Module mod; @@ -201,9 +201,9 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { std::make_unique( std::make_unique("ary"), std::make_unique( - std::make_unique(&i32, 3))), + std::make_unique(&i32, 3))), std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); Context ctx; ast::Module mod; @@ -252,7 +252,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { std::make_unique( std::make_unique("ary"), std::make_unique( - std::make_unique(&i32, 2))), + std::make_unique(&i32, 2))), std::make_unique("xy")); Context ctx; @@ -811,7 +811,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { std::make_unique("ident"), std::make_unique("yxz")), std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); Context ctx; ast::Module mod; @@ -896,10 +896,10 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { std::make_unique( std::make_unique("index"), std::make_unique( - std::make_unique(&i32, 0))), + std::make_unique(&i32, 0))), std::make_unique("foo")), std::make_unique( - std::make_unique(&i32, 2))), + std::make_unique(&i32, 2))), std::make_unique("bar")), std::make_unique("baz")), std::make_unique("yx")); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index 3c5467780d..46875a763d 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 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { auto ident = std::make_unique( std::make_unique("var"), std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); auto val = std::make_unique( std::make_unique(&f32, 1.0f)); diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index bf7312941c..83f7ebbfa8 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 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar) { ast::type::I32Type i32; auto lhs = std::make_unique( - std::make_unique(&i32, 3)); + std::make_unique(&i32, 3)); auto rhs = std::make_unique( - std::make_unique(&i32, 4)); + std::make_unique(&i32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -84,20 +85,20 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) { ast::ExpressionList vals; vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); auto lhs = std::make_unique(&vec3, std::move(vals)); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); auto rhs = std::make_unique(&vec3, std::move(vals)); @@ -144,9 +145,9 @@ TEST_P(BinaryArithUnsignedIntegerTest, Scalar) { ast::type::U32Type u32; auto lhs = std::make_unique( - std::make_unique(&u32, 3)); + std::make_unique(&u32, 3)); auto rhs = std::make_unique( - std::make_unique(&u32, 4)); + std::make_unique(&u32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -174,20 +175,20 @@ TEST_P(BinaryArithUnsignedIntegerTest, Vector) { ast::ExpressionList vals; vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); auto lhs = std::make_unique(&vec3, std::move(vals)); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); auto rhs = std::make_unique(&vec3, std::move(vals)); @@ -318,9 +319,9 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Scalar) { ast::type::U32Type u32; auto lhs = std::make_unique( - std::make_unique(&u32, 3)); + std::make_unique(&u32, 3)); auto rhs = std::make_unique( - std::make_unique(&u32, 4)); + std::make_unique(&u32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -350,20 +351,20 @@ TEST_P(BinaryCompareUnsignedIntegerTest, Vector) { ast::ExpressionList vals; vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); auto lhs = std::make_unique(&vec3, std::move(vals)); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); vals.push_back(std::make_unique( - std::make_unique(&u32, 1))); + std::make_unique(&u32, 1))); auto rhs = std::make_unique(&vec3, std::move(vals)); @@ -407,9 +408,9 @@ TEST_P(BinaryCompareSignedIntegerTest, Scalar) { ast::type::I32Type i32; auto lhs = std::make_unique( - std::make_unique(&i32, 3)); + std::make_unique(&i32, 3)); auto rhs = std::make_unique( - std::make_unique(&i32, 4)); + std::make_unique(&i32, 4)); ast::BinaryExpression expr(param.op, std::move(lhs), std::move(rhs)); @@ -439,20 +440,20 @@ TEST_P(BinaryCompareSignedIntegerTest, Vector) { ast::ExpressionList vals; vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); auto lhs = std::make_unique(&vec3, std::move(vals)); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); vals.push_back(std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); auto rhs = std::make_unique(&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 ecb248cc4a..c559ec9b4c 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 @@ TEST_F(BuilderTest, Cast_I32ToFloat) { ast::CastExpression cast(&f32, std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); Context ctx; ast::Module mod; @@ -211,7 +211,7 @@ TEST_F(BuilderTest, Cast_I32ToU32) { ast::CastExpression cast(&u32, std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&i32, 2))); Context ctx; ast::Module mod; @@ -262,7 +262,7 @@ TEST_F(BuilderTest, Cast_I32ToI32) { ast::CastExpression cast(&i32, std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&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 c48133092a..147af57955 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 @@ TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { ast::Variable var("var", ast::StorageClass::kNone, &i32); var.set_constructor(std::make_unique( - std::make_unique(&i32, 2))); + std::make_unique(&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 e7109ab07d..7818e5db95 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 @@ TEST_F(BuilderTest, If_WithStatements) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); auto cond = std::make_unique( std::make_unique(&bool_type, true)); @@ -138,13 +138,13 @@ TEST_F(BuilderTest, If_WithElse) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList else_body; else_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&i32, 3)))); ast::ElseStatementList else_stmts; else_stmts.push_back( @@ -206,13 +206,13 @@ TEST_F(BuilderTest, If_WithElseIf) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList else_body; else_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&i32, 3)))); auto else_cond = std::make_unique( std::make_unique(&bool_type, true)); @@ -286,22 +286,22 @@ TEST_F(BuilderTest, If_WithMultiple) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList elseif_1_body; elseif_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&i32, 3)))); ast::StatementList elseif_2_body; elseif_2_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 4)))); + std::make_unique(&i32, 4)))); ast::StatementList else_body; else_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 5)))); + std::make_unique(&i32, 5)))); auto elseif_1_cond = std::make_unique( std::make_unique(&bool_type, true)); diff --git a/src/writer/spirv/builder_literal_test.cc b/src/writer/spirv/builder_literal_test.cc index a2307ffc8f..1c96661b73 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_Bool_Dedup) { 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) { 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 0b59ac3da3..d5bfe5b156 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 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList continuing; ast::LoopStatement expr(std::move(body), std::move(continuing)); @@ -128,13 +128,13 @@ TEST_F(BuilderTest, Loop_WithContinuing) { body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList continuing; continuing.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&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 c9fec10f03..3637a923f4 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 @@ TEST_F(BuilderTest, Switch_Empty) { // switch (1) { // } auto cond = std::make_unique( - std::make_unique(&i32, 1)); + std::make_unique(&i32, 1)); ast::SwitchStatement expr(std::move(cond), ast::CaseStatementList{}); @@ -89,19 +89,19 @@ TEST_F(BuilderTest, Switch_WithCase) { case_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); ast::StatementList case_2_body; case_2_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(std::make_unique(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); + selector_2.push_back(std::make_unique(&i32, 2)); ast::CaseStatementList cases; cases.push_back(std::make_unique(std::move(selector_1), @@ -174,7 +174,7 @@ TEST_F(BuilderTest, Switch_WithDefault) { default_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); ast::CaseStatementList cases; cases.push_back( @@ -243,26 +243,26 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { case_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); ast::StatementList case_2_body; case_2_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList default_body; default_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(std::make_unique(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); - selector_2.push_back(std::make_unique(&i32, 3)); + selector_2.push_back(std::make_unique(&i32, 2)); + selector_2.push_back(std::make_unique(&i32, 3)); ast::CaseStatementList cases; cases.push_back(std::make_unique(std::move(selector_1), @@ -344,26 +344,26 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { case_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); case_1_body.push_back(std::make_unique()); ast::StatementList case_2_body; case_2_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 2)))); + std::make_unique(&i32, 2)))); ast::StatementList default_body; default_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 3)))); + std::make_unique(&i32, 3)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(std::make_unique(&i32, 1)); ast::CaseSelectorList selector_2; - selector_2.push_back(std::make_unique(&i32, 2)); + selector_2.push_back(std::make_unique(&i32, 2)); ast::CaseStatementList cases; cases.push_back(std::make_unique(std::move(selector_1), @@ -441,11 +441,11 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { case_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); case_1_body.push_back(std::make_unique()); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(std::make_unique(&i32, 1)); ast::CaseStatementList cases; cases.push_back(std::make_unique(std::move(selector_1), @@ -511,10 +511,10 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { case_1_body.push_back(std::make_unique( std::make_unique("v"), std::make_unique( - std::make_unique(&i32, 1)))); + std::make_unique(&i32, 1)))); ast::CaseSelectorList selector_1; - selector_1.push_back(std::make_unique(&i32, 1)); + selector_1.push_back(std::make_unique(&i32, 1)); ast::CaseStatementList cases; cases.push_back(std::make_unique(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 1065115e41..2b4be370b4 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 @@ TEST_F(BuilderTest, UnaryOp_Negation_Integer) { ast::UnaryOpExpression expr( ast::UnaryOp::kNegation, std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); Context ctx; ast::Module mod; @@ -89,7 +89,7 @@ TEST_F(BuilderTest, UnaryOp_Not) { ast::UnaryOpExpression expr( ast::UnaryOp::kNot, std::make_unique( - std::make_unique(&i32, 1))); + std::make_unique(&i32, 1))); Context ctx; ast::Module mod; diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 9638f48bc4..f27f518135 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 @@ bool GeneratorImpl::EmitLiteral(ast::Literal* lit) { 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 437fcba9b2..8e98eb81c3 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 @@ using GeneratorImplTest = testing::Test; TEST_F(GeneratorImplTest, EmitExpression_ArrayAccessor) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, 5); + auto lit = std::make_unique(&i32, 5); auto idx = std::make_unique(std::move(lit)); auto ary = std::make_unique("ary"); diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc index 5a1a906036..99374a9dbb 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 @@ TEST_F(GeneratorImplTest, Emit_Case) { body.push_back(std::make_unique()); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); + lit.push_back(std::make_unique(&i32, 5)); ast::CaseStatement c(std::move(lit), std::move(body)); GeneratorImpl g; @@ -56,8 +56,8 @@ TEST_F(GeneratorImplTest, Emit_Case_MultipleSelectors) { body.push_back(std::make_unique()); ast::CaseSelectorList lit; - lit.push_back(std::make_unique(&i32, 5)); - lit.push_back(std::make_unique(&i32, 6)); + lit.push_back(std::make_unique(&i32, 5)); + lit.push_back(std::make_unique(&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 8eba2b17ed..9565ae8705 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_Bool) { TEST_F(GeneratorImplTest, EmitConstructor_Int) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, -12345); + auto lit = std::make_unique(&i32, -12345); ast::ScalarConstructorExpression expr(std::move(lit)); GeneratorImpl g; @@ -107,7 +107,7 @@ TEST_F(GeneratorImplTest, EmitConstructor_Type_Bool) { TEST_F(GeneratorImplTest, EmitConstructor_Type_Int) { ast::type::I32Type i32; - auto lit = std::make_unique(&i32, -12345); + auto lit = std::make_unique(&i32, -12345); ast::ExpressionList values; values.push_back( std::make_unique(std::move(lit))); diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc index b149541206..b018da077f 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 @@ TEST_F(GeneratorImplTest, Emit_Switch) { ast::type::I32Type i32; ast::CaseSelectorList case_val; - case_val.push_back(std::make_unique(&i32, 5)); + case_val.push_back(std::make_unique(&i32, 5)); ast::StatementList case_body; case_body.push_back(std::make_unique());