From acf764351830d4d1fe20a01090c40e86d440d5c6 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 30 Nov 2020 23:30:58 +0000 Subject: [PATCH] Replace Literal::(Is|As)* with Castable Change-Id: I842483890b369d63c23dba475b6738bffe5cfdbd Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34319 Reviewed-by: dan sinclair --- src/ast/bool_literal.cc | 4 - src/ast/bool_literal.h | 3 - src/ast/bool_literal_test.cc | 21 ++-- src/ast/float_literal.cc | 4 - src/ast/float_literal.h | 3 - src/ast/float_literal_test.cc | 19 ++-- src/ast/int_literal.cc | 4 - src/ast/int_literal.h | 3 - src/ast/int_literal_test.cc | 7 +- src/ast/literal.cc | 63 ----------- src/ast/literal.h | 33 ------ src/ast/null_literal.cc | 4 - src/ast/null_literal.h | 3 - src/ast/null_literal_test.cc | 17 +-- src/ast/sint_literal.cc | 4 - src/ast/sint_literal.h | 3 - src/ast/sint_literal_test.cc | 17 +-- src/ast/uint_literal.cc | 4 - src/ast/uint_literal.h | 3 - src/ast/uint_literal_test.cc | 17 +-- src/inspector/inspector.cc | 16 +-- src/reader/wgsl/parser_impl.cc | 4 +- .../parser_impl_additive_expression_test.cc | 8 +- .../wgsl/parser_impl_and_expression_test.cc | 4 +- .../wgsl/parser_impl_assignment_stmt_test.cc | 12 +-- .../wgsl/parser_impl_const_expr_test.cc | 12 +-- .../wgsl/parser_impl_const_literal_test.cc | 20 ++-- .../parser_impl_equality_expression_test.cc | 8 +- ...arser_impl_exclusive_or_expression_test.cc | 4 +- ...arser_impl_inclusive_or_expression_test.cc | 4 +- ...parser_impl_logical_and_expression_test.cc | 4 +- .../parser_impl_logical_or_expression_test.cc | 4 +- ...ser_impl_multiplicative_expression_test.cc | 12 +-- .../parser_impl_postfix_expression_test.cc | 4 +- .../parser_impl_primary_expression_test.cc | 20 ++-- .../parser_impl_relational_expression_test.cc | 16 +-- .../wgsl/parser_impl_shift_expression_test.cc | 8 +- .../wgsl/parser_impl_unary_expression_test.cc | 12 +-- .../bound_array_accessors_transform.cc | 12 +-- .../bound_array_accessors_transform_test.cc | 100 +++++++++--------- src/validator/validator_impl.cc | 11 +- src/writer/hlsl/generator_impl.cc | 16 +-- src/writer/msl/generator_impl.cc | 16 +-- src/writer/spirv/builder.cc | 30 +++--- src/writer/wgsl/generator_impl.cc | 16 +-- 45 files changed, 250 insertions(+), 359 deletions(-) diff --git a/src/ast/bool_literal.cc b/src/ast/bool_literal.cc index 3fba92d0d0..a40d99a533 100644 --- a/src/ast/bool_literal.cc +++ b/src/ast/bool_literal.cc @@ -22,10 +22,6 @@ BoolLiteral::BoolLiteral(ast::type::Type* type, bool value) BoolLiteral::~BoolLiteral() = default; -bool BoolLiteral::IsBool() const { - return true; -} - std::string BoolLiteral::to_str() const { return value_ ? "true" : "false"; } diff --git a/src/ast/bool_literal.h b/src/ast/bool_literal.h index 95914708d4..27005311b0 100644 --- a/src/ast/bool_literal.h +++ b/src/ast/bool_literal.h @@ -31,9 +31,6 @@ class BoolLiteral : public Castable { BoolLiteral(ast::type::Type* type, bool value); ~BoolLiteral() override; - /// @returns true if this is a bool literal - bool IsBool() const override; - /// @returns true if the bool literal is true bool IsTrue() const { return value_; } /// @returns true if the bool literal is false diff --git a/src/ast/bool_literal_test.cc b/src/ast/bool_literal_test.cc index 1a09808151..63fe6631cc 100644 --- a/src/ast/bool_literal_test.cc +++ b/src/ast/bool_literal_test.cc @@ -14,8 +14,12 @@ #include "src/ast/bool_literal.h" +#include "src/ast/float_literal.h" +#include "src/ast/null_literal.h" +#include "src/ast/sint_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/bool_type.h" +#include "src/ast/uint_literal.h" namespace tint { namespace ast { @@ -26,7 +30,7 @@ using BoolLiteralTest = TestHelper; TEST_F(BoolLiteralTest, True) { ast::type::BoolType bool_type; BoolLiteral b{&bool_type, true}; - ASSERT_TRUE(b.IsBool()); + ASSERT_TRUE(b.Is()); ASSERT_TRUE(b.IsTrue()); ASSERT_FALSE(b.IsFalse()); } @@ -34,7 +38,7 @@ TEST_F(BoolLiteralTest, True) { TEST_F(BoolLiteralTest, False) { ast::type::BoolType bool_type; BoolLiteral b{&bool_type, false}; - ASSERT_TRUE(b.IsBool()); + ASSERT_TRUE(b.Is()); ASSERT_FALSE(b.IsTrue()); ASSERT_TRUE(b.IsFalse()); } @@ -42,12 +46,13 @@ TEST_F(BoolLiteralTest, False) { TEST_F(BoolLiteralTest, Is) { ast::type::BoolType bool_type; BoolLiteral b{&bool_type, false}; - EXPECT_TRUE(b.IsBool()); - EXPECT_FALSE(b.IsSint()); - EXPECT_FALSE(b.IsFloat()); - EXPECT_FALSE(b.IsUint()); - EXPECT_FALSE(b.IsInt()); - EXPECT_FALSE(b.IsNull()); + Literal* l = &b; + EXPECT_TRUE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); } TEST_F(BoolLiteralTest, ToStr) { diff --git a/src/ast/float_literal.cc b/src/ast/float_literal.cc index d7b6a3152f..70ba92e1d1 100644 --- a/src/ast/float_literal.cc +++ b/src/ast/float_literal.cc @@ -25,10 +25,6 @@ FloatLiteral::FloatLiteral(ast::type::Type* type, float value) FloatLiteral::~FloatLiteral() = default; -bool FloatLiteral::IsFloat() const { - return true; -} - std::string FloatLiteral::to_str() const { return std::to_string(value_); } diff --git a/src/ast/float_literal.h b/src/ast/float_literal.h index d8b69e4946..411deaaa48 100644 --- a/src/ast/float_literal.h +++ b/src/ast/float_literal.h @@ -31,9 +31,6 @@ class FloatLiteral : public Castable { FloatLiteral(ast::type::Type* type, float value); ~FloatLiteral() override; - /// @returns true if this is a float literal - bool IsFloat() const override; - /// @returns the float literal value float value() const { return value_; } diff --git a/src/ast/float_literal_test.cc b/src/ast/float_literal_test.cc index cc5d55fd0f..568df88e77 100644 --- a/src/ast/float_literal_test.cc +++ b/src/ast/float_literal_test.cc @@ -14,8 +14,12 @@ #include "src/ast/float_literal.h" +#include "src/ast/bool_literal.h" +#include "src/ast/null_literal.h" +#include "src/ast/sint_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/f32_type.h" +#include "src/ast/uint_literal.h" namespace tint { namespace ast { @@ -26,19 +30,20 @@ using FloatLiteralTest = TestHelper; TEST_F(FloatLiteralTest, Value) { ast::type::F32Type f32; FloatLiteral f{&f32, 47.2f}; - ASSERT_TRUE(f.IsFloat()); + ASSERT_TRUE(f.Is()); EXPECT_EQ(f.value(), 47.2f); } TEST_F(FloatLiteralTest, Is) { ast::type::F32Type f32; FloatLiteral f{&f32, 42.f}; - EXPECT_FALSE(f.IsBool()); - EXPECT_FALSE(f.IsSint()); - EXPECT_FALSE(f.IsInt()); - EXPECT_TRUE(f.IsFloat()); - EXPECT_FALSE(f.IsUint()); - EXPECT_FALSE(f.IsNull()); + Literal* l = &f; + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_TRUE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); } TEST_F(FloatLiteralTest, ToStr) { diff --git a/src/ast/int_literal.cc b/src/ast/int_literal.cc index 20480d225d..bb86821409 100644 --- a/src/ast/int_literal.cc +++ b/src/ast/int_literal.cc @@ -21,9 +21,5 @@ IntLiteral::IntLiteral(ast::type::Type* type) : Base(type) {} IntLiteral::~IntLiteral() = default; -bool IntLiteral::IsInt() const { - return true; -} - } // namespace ast } // namespace tint diff --git a/src/ast/int_literal.h b/src/ast/int_literal.h index d23fceb271..e2f5c66dd5 100644 --- a/src/ast/int_literal.h +++ b/src/ast/int_literal.h @@ -27,9 +27,6 @@ class IntLiteral : public Castable { public: ~IntLiteral() override; - /// @returns true if this is a signed or unsigned integer. - bool IsInt() const override; - protected: /// Constructor /// @param type the type of the literal diff --git a/src/ast/int_literal_test.cc b/src/ast/int_literal_test.cc index 8b2190eba9..f002d491b3 100644 --- a/src/ast/int_literal_test.cc +++ b/src/ast/int_literal_test.cc @@ -14,6 +14,9 @@ #include "src/ast/int_literal.h" +#include "src/ast/bool_literal.h" +#include "src/ast/float_literal.h" +#include "src/ast/null_literal.h" #include "src/ast/sint_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/i32_type.h" @@ -29,13 +32,13 @@ using IntLiteralTest = TestHelper; TEST_F(IntLiteralTest, Sint_IsInt) { ast::type::I32Type i32; SintLiteral i{&i32, 47}; - ASSERT_TRUE(i.IsInt()); + ASSERT_TRUE(i.Is()); } TEST_F(IntLiteralTest, Uint_IsInt) { ast::type::I32Type i32; UintLiteral i{&i32, 42}; - EXPECT_TRUE(i.IsInt()); + EXPECT_TRUE(i.Is()); } } // namespace diff --git a/src/ast/literal.cc b/src/ast/literal.cc index 35733c7632..9b7b892a72 100644 --- a/src/ast/literal.cc +++ b/src/ast/literal.cc @@ -14,15 +14,6 @@ #include "src/ast/literal.h" -#include - -#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 { namespace ast { @@ -30,60 +21,6 @@ Literal::Literal(ast::type::Type* type) : type_(type) {} Literal::~Literal() = default; -bool Literal::IsBool() const { - return false; -} - -bool Literal::IsFloat() const { - return false; -} - -bool Literal::IsInt() const { - return false; -} - -bool Literal::IsSint() const { - return false; -} - -bool Literal::IsNull() const { - return false; -} - -bool Literal::IsUint() const { - return false; -} - -BoolLiteral* Literal::AsBool() { - assert(IsBool()); - return static_cast(this); -} - -FloatLiteral* Literal::AsFloat() { - assert(IsFloat()); - 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() { - assert(IsNull()); - return static_cast(this); -} - -UintLiteral* Literal::AsUint() { - assert(IsUint()); - return static_cast(this); -} - bool Literal::IsValid() const { return true; } diff --git a/src/ast/literal.h b/src/ast/literal.h index b8c1b7c280..4e3ff0f63f 100644 --- a/src/ast/literal.h +++ b/src/ast/literal.h @@ -23,44 +23,11 @@ namespace tint { namespace ast { -class BoolLiteral; -class FloatLiteral; -class NullLiteral; -class SintLiteral; -class IntLiteral; -class UintLiteral; - /// Base class for a literal value class Literal : public Castable { public: ~Literal() override; - /// @returns true if this is a bool literal - virtual bool IsBool() const; - /// @returns true if this is a float literal - virtual bool IsFloat() const; - /// @returns thre if this is an int literal (either sint or uint) - virtual bool IsInt() const; - /// @returns true if this is a signed int literal - 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 - virtual bool IsUint() const; - - /// @returns the literal as a boolean literal - BoolLiteral* AsBool(); - /// @returns the literal as a float literal - FloatLiteral* AsFloat(); - /// @returns the literal as an 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 - UintLiteral* AsUint(); - /// @returns the type of the literal ast::type::Type* type() const { return type_; } diff --git a/src/ast/null_literal.cc b/src/ast/null_literal.cc index 3c759ed500..54b9344a32 100644 --- a/src/ast/null_literal.cc +++ b/src/ast/null_literal.cc @@ -21,10 +21,6 @@ NullLiteral::NullLiteral(ast::type::Type* type) : Base(type) {} NullLiteral::~NullLiteral() = default; -bool NullLiteral::IsNull() const { - return true; -} - std::string NullLiteral::to_str() const { return "null " + type()->type_name(); } diff --git a/src/ast/null_literal.h b/src/ast/null_literal.h index 0c396c91b6..93b5f895b7 100644 --- a/src/ast/null_literal.h +++ b/src/ast/null_literal.h @@ -30,9 +30,6 @@ class NullLiteral : public Castable { explicit NullLiteral(ast::type::Type* type); ~NullLiteral() override; - /// @returns true if this is a null literal - bool IsNull() const override; - /// @returns the name for this literal. This name is unique to this value. std::string name() const override; diff --git a/src/ast/null_literal_test.cc b/src/ast/null_literal_test.cc index 2ede9c3713..d45b3e2bc8 100644 --- a/src/ast/null_literal_test.cc +++ b/src/ast/null_literal_test.cc @@ -14,8 +14,12 @@ #include "src/ast/null_literal.h" +#include "src/ast/bool_literal.h" +#include "src/ast/float_literal.h" +#include "src/ast/sint_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/i32_type.h" +#include "src/ast/uint_literal.h" namespace tint { namespace ast { @@ -26,12 +30,13 @@ using NullLiteralTest = TestHelper; TEST_F(NullLiteralTest, Is) { ast::type::I32Type i32; NullLiteral i{&i32}; - EXPECT_FALSE(i.IsBool()); - EXPECT_FALSE(i.IsSint()); - EXPECT_FALSE(i.IsFloat()); - EXPECT_FALSE(i.IsUint()); - EXPECT_FALSE(i.IsInt()); - EXPECT_TRUE(i.IsNull()); + Literal* l = &i; + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_TRUE(l->Is()); } TEST_F(NullLiteralTest, ToStr) { diff --git a/src/ast/sint_literal.cc b/src/ast/sint_literal.cc index 6a5da13ea3..ab44c210f1 100644 --- a/src/ast/sint_literal.cc +++ b/src/ast/sint_literal.cc @@ -22,10 +22,6 @@ SintLiteral::SintLiteral(ast::type::Type* type, int32_t value) SintLiteral::~SintLiteral() = default; -bool SintLiteral::IsSint() const { - return true; -} - std::string SintLiteral::to_str() const { return std::to_string(value_); } diff --git a/src/ast/sint_literal.h b/src/ast/sint_literal.h index 0e4db0435f..90e78c3c51 100644 --- a/src/ast/sint_literal.h +++ b/src/ast/sint_literal.h @@ -31,9 +31,6 @@ class SintLiteral : public Castable { SintLiteral(ast::type::Type* type, int32_t value); ~SintLiteral() override; - /// @returns true if this is a signed int literal - bool IsSint() const override; - /// Updates the literals value /// @param val the value to set void set_value(int32_t val) { value_ = val; } diff --git a/src/ast/sint_literal_test.cc b/src/ast/sint_literal_test.cc index 9e42a5cdb6..cc49ce6178 100644 --- a/src/ast/sint_literal_test.cc +++ b/src/ast/sint_literal_test.cc @@ -14,9 +14,13 @@ #include "src/ast/sint_literal.h" +#include "src/ast/bool_literal.h" +#include "src/ast/float_literal.h" +#include "src/ast/null_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/i32_type.h" #include "src/ast/type/u32_type.h" +#include "src/ast/uint_literal.h" namespace tint { namespace ast { @@ -27,18 +31,19 @@ using SintLiteralTest = TestHelper; TEST_F(SintLiteralTest, Value) { ast::type::I32Type i32; SintLiteral i{&i32, 47}; - ASSERT_TRUE(i.IsSint()); + ASSERT_TRUE(i.Is()); EXPECT_EQ(i.value(), 47); } TEST_F(SintLiteralTest, Is) { ast::type::I32Type i32; SintLiteral i{&i32, 42}; - EXPECT_FALSE(i.IsBool()); - EXPECT_TRUE(i.IsSint()); - EXPECT_FALSE(i.IsFloat()); - EXPECT_FALSE(i.IsUint()); - EXPECT_FALSE(i.IsNull()); + Literal* l = &i; + EXPECT_FALSE(l->Is()); + EXPECT_TRUE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); } TEST_F(SintLiteralTest, ToStr) { diff --git a/src/ast/uint_literal.cc b/src/ast/uint_literal.cc index 4548a4f368..201f17d91a 100644 --- a/src/ast/uint_literal.cc +++ b/src/ast/uint_literal.cc @@ -22,10 +22,6 @@ UintLiteral::UintLiteral(ast::type::Type* type, uint32_t value) UintLiteral::~UintLiteral() = default; -bool UintLiteral::IsUint() const { - return true; -} - std::string UintLiteral::to_str() const { return std::to_string(value_); } diff --git a/src/ast/uint_literal.h b/src/ast/uint_literal.h index f15642a31d..56936eec81 100644 --- a/src/ast/uint_literal.h +++ b/src/ast/uint_literal.h @@ -31,9 +31,6 @@ class UintLiteral : public Castable { UintLiteral(ast::type::Type* type, uint32_t value); ~UintLiteral() override; - /// @returns true if this is a uint literal - bool IsUint() const override; - /// Updates the literals value /// @param val the value to set void set_value(uint32_t val) { value_ = val; } diff --git a/src/ast/uint_literal_test.cc b/src/ast/uint_literal_test.cc index df60554a36..b066bcae41 100644 --- a/src/ast/uint_literal_test.cc +++ b/src/ast/uint_literal_test.cc @@ -14,6 +14,10 @@ #include "src/ast/uint_literal.h" +#include "src/ast/bool_literal.h" +#include "src/ast/float_literal.h" +#include "src/ast/null_literal.h" +#include "src/ast/sint_literal.h" #include "src/ast/test_helper.h" #include "src/ast/type/u32_type.h" @@ -26,18 +30,19 @@ using UintLiteralTest = TestHelper; TEST_F(UintLiteralTest, Value) { ast::type::U32Type u32; UintLiteral u{&u32, 47}; - ASSERT_TRUE(u.IsUint()); + ASSERT_TRUE(u.Is()); EXPECT_EQ(u.value(), 47u); } TEST_F(UintLiteralTest, Is) { ast::type::U32Type u32; UintLiteral u{&u32, 42}; - EXPECT_FALSE(u.IsBool()); - EXPECT_FALSE(u.IsSint()); - EXPECT_FALSE(u.IsFloat()); - EXPECT_TRUE(u.IsUint()); - EXPECT_FALSE(u.IsNull()); + Literal* l = &u; + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_FALSE(l->Is()); + EXPECT_TRUE(l->Is()); + EXPECT_FALSE(l->Is()); } TEST_F(UintLiteralTest, ToStr) { diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index 9012f73efa..596420e160 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -145,23 +145,23 @@ std::map Inspector::GetConstantIDs() { continue; } - if (literal->IsBool()) { - result[constant_id] = Scalar(literal->AsBool()->IsTrue()); + if (literal->Is()) { + result[constant_id] = Scalar(literal->As()->IsTrue()); continue; } - if (literal->IsUint()) { - result[constant_id] = Scalar(literal->AsUint()->value()); + if (literal->Is()) { + result[constant_id] = Scalar(literal->As()->value()); continue; } - if (literal->IsSint()) { - result[constant_id] = Scalar(literal->AsSint()->value()); + if (literal->Is()) { + result[constant_id] = Scalar(literal->As()->value()); continue; } - if (literal->IsFloat()) { - result[constant_id] = Scalar(literal->AsFloat()->value()); + if (literal->Is()) { + result[constant_id] = Scalar(literal->As()->value()); continue; } diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 86eeeb8f57..60eada7b5f 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1753,10 +1753,10 @@ Expect ParserImpl::expect_case_selectors() { return Failure::kErrored; if (!cond.matched) break; - if (!cond->IsInt()) + if (!cond->Is()) return add_error(t, "invalid case selector must be an integer value"); - selectors.push_back(cond.value->AsInt()); + selectors.push_back(cond.value->As()); } if (selectors.empty()) diff --git a/src/reader/wgsl/parser_impl_additive_expression_test.cc b/src/reader/wgsl/parser_impl_additive_expression_test.cc index 7cdfbda7bd..6776ad2847 100644 --- a/src/reader/wgsl/parser_impl_additive_expression_test.cc +++ b/src/reader/wgsl/parser_impl_additive_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) { @@ -67,8 +67,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, AdditiveExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_and_expression_test.cc b/src/reader/wgsl/parser_impl_and_expression_test.cc index 5cc8d98445..881d9ff513 100644 --- a/src/reader/wgsl/parser_impl_and_expression_test.cc +++ b/src/reader/wgsl/parser_impl_and_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, AndExpression_Parses) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, AndExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc index 541932d4c7..69387ba9f1 100644 --- a/src/reader/wgsl/parser_impl_assignment_stmt_test.cc +++ b/src/reader/wgsl/parser_impl_assignment_stmt_test.cc @@ -49,8 +49,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) { auto* init = e->rhs()->As(); ASSERT_NE(init->literal(), nullptr); - ASSERT_TRUE(init->literal()->IsSint()); - EXPECT_EQ(init->literal()->AsSint()->value(), 123); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_EQ(init->literal()->As()->value(), 123); } TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { @@ -69,8 +69,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { ASSERT_TRUE(e->rhs()->Is()); auto* init = e->rhs()->As(); ASSERT_NE(init->literal(), nullptr); - ASSERT_TRUE(init->literal()->IsSint()); - EXPECT_EQ(init->literal()->AsSint()->value(), 123); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_EQ(init->literal()->As()->value(), 123); ASSERT_TRUE(e->lhs()->Is()); auto* mem = e->lhs()->As(); @@ -86,8 +86,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { ASSERT_TRUE(ary->idx_expr()->Is()); init = ary->idx_expr()->As(); ASSERT_NE(init->literal(), nullptr); - ASSERT_TRUE(init->literal()->IsSint()); - EXPECT_EQ(init->literal()->AsSint()->value(), 2); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_EQ(init->literal()->As()->value(), 2); ASSERT_TRUE(ary->array()->Is()); mem = ary->array()->As(); diff --git a/src/reader/wgsl/parser_impl_const_expr_test.cc b/src/reader/wgsl/parser_impl_const_expr_test.cc index 4d13cf7414..cb0c7ee8c7 100644 --- a/src/reader/wgsl/parser_impl_const_expr_test.cc +++ b/src/reader/wgsl/parser_impl_const_expr_test.cc @@ -44,14 +44,14 @@ TEST_F(ParserImplTest, ConstExpr_TypeDecl) { ASSERT_TRUE(v[0]->Is()); ASSERT_TRUE(v[0]->Is()); auto* c = v[0]->As(); - ASSERT_TRUE(c->literal()->IsFloat()); - EXPECT_FLOAT_EQ(c->literal()->AsFloat()->value(), 1.); + ASSERT_TRUE(c->literal()->Is()); + EXPECT_FLOAT_EQ(c->literal()->As()->value(), 1.); ASSERT_TRUE(v[1]->Is()); ASSERT_TRUE(v[1]->Is()); c = v[1]->As(); - ASSERT_TRUE(c->literal()->IsFloat()); - EXPECT_FLOAT_EQ(c->literal()->AsFloat()->value(), 2.); + ASSERT_TRUE(c->literal()->Is()); + EXPECT_FLOAT_EQ(c->literal()->As()->value(), 2.); } TEST_F(ParserImplTest, ConstExpr_TypeDecl_MissingRightParen) { @@ -117,8 +117,8 @@ TEST_F(ParserImplTest, ConstExpr_ConstLiteral) { ASSERT_TRUE(e->Is()); ASSERT_TRUE(e->Is()); auto* c = e->As(); - ASSERT_TRUE(c->literal()->IsBool()); - EXPECT_TRUE(c->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(c->literal()->Is()); + EXPECT_TRUE(c->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, ConstExpr_ConstLiteral_Invalid) { diff --git a/src/reader/wgsl/parser_impl_const_literal_test.cc b/src/reader/wgsl/parser_impl_const_literal_test.cc index fb99a27283..51ee92a1a2 100644 --- a/src/reader/wgsl/parser_impl_const_literal_test.cc +++ b/src/reader/wgsl/parser_impl_const_literal_test.cc @@ -32,8 +32,8 @@ TEST_F(ParserImplTest, ConstLiteral_Int) { EXPECT_FALSE(c.errored); EXPECT_FALSE(p->has_error()); ASSERT_NE(c.value, nullptr); - ASSERT_TRUE(c->IsSint()); - EXPECT_EQ(c->AsSint()->value(), -234); + ASSERT_TRUE(c->Is()); + EXPECT_EQ(c->As()->value(), -234); } TEST_F(ParserImplTest, ConstLiteral_Uint) { @@ -43,8 +43,8 @@ TEST_F(ParserImplTest, ConstLiteral_Uint) { EXPECT_FALSE(c.errored); EXPECT_FALSE(p->has_error()); ASSERT_NE(c.value, nullptr); - ASSERT_TRUE(c->IsUint()); - EXPECT_EQ(c->AsUint()->value(), 234u); + ASSERT_TRUE(c->Is()); + EXPECT_EQ(c->As()->value(), 234u); } TEST_F(ParserImplTest, ConstLiteral_Float) { @@ -54,8 +54,8 @@ TEST_F(ParserImplTest, ConstLiteral_Float) { EXPECT_FALSE(c.errored); EXPECT_FALSE(p->has_error()); ASSERT_NE(c.value, nullptr); - ASSERT_TRUE(c->IsFloat()); - EXPECT_FLOAT_EQ(c->AsFloat()->value(), 234e12f); + ASSERT_TRUE(c->Is()); + EXPECT_FLOAT_EQ(c->As()->value(), 234e12f); } TEST_F(ParserImplTest, ConstLiteral_InvalidFloat) { @@ -73,8 +73,8 @@ TEST_F(ParserImplTest, ConstLiteral_True) { EXPECT_FALSE(c.errored); EXPECT_FALSE(p->has_error()); ASSERT_NE(c.value, nullptr); - ASSERT_TRUE(c->IsBool()); - EXPECT_TRUE(c->AsBool()->IsTrue()); + ASSERT_TRUE(c->Is()); + EXPECT_TRUE(c->As()->IsTrue()); } TEST_F(ParserImplTest, ConstLiteral_False) { @@ -84,8 +84,8 @@ TEST_F(ParserImplTest, ConstLiteral_False) { EXPECT_FALSE(c.errored); EXPECT_FALSE(p->has_error()); ASSERT_NE(c.value, nullptr); - ASSERT_TRUE(c->IsBool()); - EXPECT_TRUE(c->AsBool()->IsFalse()); + ASSERT_TRUE(c->Is()); + EXPECT_TRUE(c->As()->IsFalse()); } TEST_F(ParserImplTest, ConstLiteral_NoMatch) { diff --git a/src/reader/wgsl/parser_impl_equality_expression_test.cc b/src/reader/wgsl/parser_impl_equality_expression_test.cc index d73d1a5578..cb99ff9a38 100644 --- a/src/reader/wgsl/parser_impl_equality_expression_test.cc +++ b/src/reader/wgsl/parser_impl_equality_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_Equal) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) { @@ -67,8 +67,8 @@ TEST_F(ParserImplTest, EqualityExpression_Parses_NotEqual) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, EqualityExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_exclusive_or_expression_test.cc b/src/reader/wgsl/parser_impl_exclusive_or_expression_test.cc index 63f7dd52a0..8fbcbb03aa 100644 --- a/src/reader/wgsl/parser_impl_exclusive_or_expression_test.cc +++ b/src/reader/wgsl/parser_impl_exclusive_or_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, ExclusiveOrExpression_Parses) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, ExclusiveOrExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc b/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc index 207fcd97de..12b1ddb33d 100644 --- a/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc +++ b/src/reader/wgsl/parser_impl_inclusive_or_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, InclusiveOrExpression_Parses) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, InclusiveOrExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_logical_and_expression_test.cc b/src/reader/wgsl/parser_impl_logical_and_expression_test.cc index 7dd5ce3b0c..e961e9e826 100644 --- a/src/reader/wgsl/parser_impl_logical_and_expression_test.cc +++ b/src/reader/wgsl/parser_impl_logical_and_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, LogicalAndExpression_Parses) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, LogicalAndExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_logical_or_expression_test.cc b/src/reader/wgsl/parser_impl_logical_or_expression_test.cc index c5bfaeeaf2..d4ee1b649a 100644 --- a/src/reader/wgsl/parser_impl_logical_or_expression_test.cc +++ b/src/reader/wgsl/parser_impl_logical_or_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, LogicalOrExpression_Parses) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, LogicalOrExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_multiplicative_expression_test.cc b/src/reader/wgsl/parser_impl_multiplicative_expression_test.cc index 41a3e8c1fd..3f1595b127 100644 --- a/src/reader/wgsl/parser_impl_multiplicative_expression_test.cc +++ b/src/reader/wgsl/parser_impl_multiplicative_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) { @@ -67,8 +67,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) { @@ -90,8 +90,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, MultiplicativeExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_postfix_expression_test.cc b/src/reader/wgsl/parser_impl_postfix_expression_test.cc index 7eb7cebff3..e20955f9b5 100644 --- a/src/reader/wgsl/parser_impl_postfix_expression_test.cc +++ b/src/reader/wgsl/parser_impl_postfix_expression_test.cc @@ -47,8 +47,8 @@ TEST_F(ParserImplTest, PostfixExpression_Array_ConstantIndex) { ASSERT_TRUE(ary->idx_expr()->Is()); ASSERT_TRUE(ary->idx_expr()->Is()); auto* c = ary->idx_expr()->As(); - ASSERT_TRUE(c->literal()->IsSint()); - EXPECT_EQ(c->literal()->AsSint()->value(), 1); + ASSERT_TRUE(c->literal()->Is()); + EXPECT_EQ(c->literal()->As()->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 10ebcc9bdb..4753c63928 100644 --- a/src/reader/wgsl/parser_impl_primary_expression_test.cc +++ b/src/reader/wgsl/parser_impl_primary_expression_test.cc @@ -60,26 +60,26 @@ TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) { ASSERT_TRUE(val[0]->Is()); ASSERT_TRUE(val[0]->Is()); auto* ident = val[0]->As(); - ASSERT_TRUE(ident->literal()->IsSint()); - EXPECT_EQ(ident->literal()->AsSint()->value(), 1); + ASSERT_TRUE(ident->literal()->Is()); + EXPECT_EQ(ident->literal()->As()->value(), 1); ASSERT_TRUE(val[1]->Is()); ASSERT_TRUE(val[1]->Is()); ident = val[1]->As(); - ASSERT_TRUE(ident->literal()->IsSint()); - EXPECT_EQ(ident->literal()->AsSint()->value(), 2); + ASSERT_TRUE(ident->literal()->Is()); + EXPECT_EQ(ident->literal()->As()->value(), 2); ASSERT_TRUE(val[2]->Is()); ASSERT_TRUE(val[2]->Is()); ident = val[2]->As(); - ASSERT_TRUE(ident->literal()->IsSint()); - EXPECT_EQ(ident->literal()->AsSint()->value(), 3); + ASSERT_TRUE(ident->literal()->Is()); + EXPECT_EQ(ident->literal()->As()->value(), 3); ASSERT_TRUE(val[3]->Is()); ASSERT_TRUE(val[3]->Is()); ident = val[3]->As(); - ASSERT_TRUE(ident->literal()->IsSint()); - EXPECT_EQ(ident->literal()->AsSint()->value(), 4); + ASSERT_TRUE(ident->literal()->Is()); + EXPECT_EQ(ident->literal()->As()->value(), 4); } TEST_F(ParserImplTest, PrimaryExpression_TypeDecl_ZeroConstructor) { @@ -146,8 +146,8 @@ TEST_F(ParserImplTest, PrimaryExpression_ConstLiteral_True) { ASSERT_TRUE(e->Is()); ASSERT_TRUE(e->Is()); auto* init = e->As(); - ASSERT_TRUE(init->literal()->IsBool()); - EXPECT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, PrimaryExpression_ParenExpr) { diff --git a/src/reader/wgsl/parser_impl_relational_expression_test.cc b/src/reader/wgsl/parser_impl_relational_expression_test.cc index ffa68402ba..3fe6196205 100644 --- a/src/reader/wgsl/parser_impl_relational_expression_test.cc +++ b/src/reader/wgsl/parser_impl_relational_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThan) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) { @@ -67,8 +67,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThan) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) { @@ -90,8 +90,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_LessThanEqual) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) { @@ -113,8 +113,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_GreaterThanEqual) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, RelationalExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_shift_expression_test.cc b/src/reader/wgsl/parser_impl_shift_expression_test.cc index 17e7badecf..b3f231962a 100644 --- a/src/reader/wgsl/parser_impl_shift_expression_test.cc +++ b/src/reader/wgsl/parser_impl_shift_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftLeft) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) { @@ -67,8 +67,8 @@ TEST_F(ParserImplTest, ShiftExpression_Parses_ShiftRight) { ASSERT_TRUE(rel->rhs()->Is()); ASSERT_TRUE(rel->rhs()->Is()); auto* init = rel->rhs()->As(); - ASSERT_TRUE(init->literal()->IsBool()); - ASSERT_TRUE(init->literal()->AsBool()->IsTrue()); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_TRUE(init->literal()->As()->IsTrue()); } TEST_F(ParserImplTest, ShiftExpression_InvalidLHS) { diff --git a/src/reader/wgsl/parser_impl_unary_expression_test.cc b/src/reader/wgsl/parser_impl_unary_expression_test.cc index c846667359..e41e3ae9b4 100644 --- a/src/reader/wgsl/parser_impl_unary_expression_test.cc +++ b/src/reader/wgsl/parser_impl_unary_expression_test.cc @@ -43,8 +43,8 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) { ASSERT_TRUE(ary->idx_expr()->Is()); ASSERT_TRUE(ary->idx_expr()->Is()); auto* init = ary->idx_expr()->As(); - ASSERT_TRUE(init->literal()->IsSint()); - ASSERT_EQ(init->literal()->AsSint()->value(), 2); + ASSERT_TRUE(init->literal()->Is()); + ASSERT_EQ(init->literal()->As()->value(), 2); } TEST_F(ParserImplTest, UnaryExpression_Minus) { @@ -63,8 +63,8 @@ TEST_F(ParserImplTest, UnaryExpression_Minus) { ASSERT_TRUE(u->expr()->Is()); auto* init = u->expr()->As(); - ASSERT_TRUE(init->literal()->IsSint()); - EXPECT_EQ(init->literal()->AsSint()->value(), 1); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_EQ(init->literal()->As()->value(), 1); } TEST_F(ParserImplTest, UnaryExpression_Minus_InvalidRHS) { @@ -93,8 +93,8 @@ TEST_F(ParserImplTest, UnaryExpression_Bang) { ASSERT_TRUE(u->expr()->Is()); auto* init = u->expr()->As(); - ASSERT_TRUE(init->literal()->IsSint()); - EXPECT_EQ(init->literal()->AsSint()->value(), 1); + ASSERT_TRUE(init->literal()->Is()); + EXPECT_EQ(init->literal()->As()->value(), 1); } TEST_F(ParserImplTest, UnaryExpression_Bang_InvalidRHS) { diff --git a/src/transform/bound_array_accessors_transform.cc b/src/transform/bound_array_accessors_transform.cc index a1ea02de5e..ab5c20deda 100644 --- a/src/transform/bound_array_accessors_transform.cc +++ b/src/transform/bound_array_accessors_transform.cc @@ -215,20 +215,20 @@ bool BoundArrayAccessorsTransform::ProcessAccessExpression( // Scalar constructor we can re-write the value to be within bounds. if (auto* c = expr->idx_expr()->As()) { auto* lit = c->literal(); - if (lit->IsSint()) { - int32_t val = lit->AsSint()->value(); + if (lit->Is()) { + int32_t val = lit->As()->value(); if (val < 0) { val = 0; } else if (val >= int32_t(size)) { val = int32_t(size) - 1; } - lit->AsSint()->set_value(val); - } else if (lit->IsUint()) { - uint32_t val = lit->AsUint()->value(); + lit->As()->set_value(val); + } else if (lit->Is()) { + uint32_t val = lit->As()->value(); if (val >= size - 1) { val = size - 1; } - lit->AsUint()->set_value(val); + lit->As()->set_value(val); } else { error_ = "unknown scalar constructor type for accessor"; return false; diff --git a/src/transform/bound_array_accessors_transform_test.cc b/src/transform/bound_array_accessors_transform_test.cc index b0e6543a49..7805d8c132 100644 --- a/src/transform/bound_array_accessors_transform_test.cc +++ b/src/transform/bound_array_accessors_transform_test.cc @@ -148,8 +148,8 @@ TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); auto* scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -229,14 +229,14 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { ASSERT_TRUE(sub_idx->params()[1]->Is()); ASSERT_TRUE(sub_idx->params()[1]->Is()); auto* scalar = sub_idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 4u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 4u); ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -274,8 +274,8 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -336,8 +336,8 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); auto* scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -375,8 +375,8 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 0); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -414,8 +414,8 @@ TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -453,8 +453,8 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -514,8 +514,8 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); auto* scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -553,8 +553,8 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 0); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -592,8 +592,8 @@ TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { ASSERT_TRUE(ptr->idx_expr()->Is()); auto* scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -637,8 +637,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -647,8 +647,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -715,8 +715,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); auto* scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -725,8 +725,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -781,8 +781,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_TRUE(ptr->idx_expr()->Is()); auto* idx = ptr->idx_expr()->As(); @@ -801,8 +801,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { ASSERT_TRUE(idx->params()[1]->Is()); ASSERT_TRUE(idx->params()[1]->Is()); scalar = idx->params()[1]->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -848,8 +848,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 0); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -858,8 +858,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 1); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -902,8 +902,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 2); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -912,8 +912,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsSint()); - EXPECT_EQ(scalar->literal()->AsSint()->value(), 0); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 0); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -957,8 +957,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -967,8 +967,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); @@ -1012,8 +1012,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { ASSERT_TRUE(ary->idx_expr()->Is()); auto* scalar = ary->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 2u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 2u); ASSERT_NE(ary->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ary->idx_expr()->result_type()->Is()); @@ -1022,8 +1022,8 @@ TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { ASSERT_TRUE(ptr->idx_expr()->Is()); scalar = ptr->idx_expr()->As(); - ASSERT_TRUE(scalar->literal()->IsUint()); - EXPECT_EQ(scalar->literal()->AsUint()->value(), 1u); + ASSERT_TRUE(scalar->literal()->Is()); + EXPECT_EQ(scalar->literal()->As()->value(), 1u); ASSERT_NE(ptr->idx_expr()->result_type(), nullptr); ASSERT_TRUE(ptr->idx_expr()->result_type()->Is()); diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index c00c998c98..510bcd3e64 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -344,13 +344,14 @@ bool ValidatorImpl::ValidateSwitch(const ast::SwitchStatement* s) { return false; } - auto v = static_cast(selector->type()->Is() - ? selector->AsUint()->value() - : selector->AsSint()->value()); + auto v = + static_cast(selector->type()->Is() + ? selector->As()->value() + : selector->As()->value()); if (selector_set.count(v)) { auto v_str = selector->type()->Is() - ? selector->AsUint()->to_str() - : selector->AsSint()->to_str(); + ? selector->As()->to_str() + : selector->As()->to_str(); add_error(case_stmt->source(), "v-0027", "a literal value must not appear more than once in " "the case selectors for a switch statement: '" + diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index a84af8cfeb..3bbd20baae 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1538,14 +1538,14 @@ bool GeneratorImpl::EmitEntryPointFunction(std::ostream& out, } bool GeneratorImpl::EmitLiteral(std::ostream& out, ast::Literal* lit) { - if (lit->IsBool()) { - out << (lit->AsBool()->IsTrue() ? "true" : "false"); - } else if (lit->IsFloat()) { - out << FloatToString(lit->AsFloat()->value()) << "f"; - } else if (lit->IsSint()) { - out << lit->AsSint()->value(); - } else if (lit->IsUint()) { - out << lit->AsUint()->value() << "u"; + if (lit->Is()) { + out << (lit->As()->IsTrue() ? "true" : "false"); + } else if (lit->Is()) { + out << FloatToString(lit->As()->value()) << "f"; + } else if (lit->Is()) { + out << lit->As()->value(); + } else if (lit->Is()) { + out << lit->As()->value() << "u"; } else { error_ = "unknown literal type"; return false; diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index d4826e99bb..4bf91101dd 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -966,14 +966,14 @@ bool GeneratorImpl::EmitScalarConstructor( } bool GeneratorImpl::EmitLiteral(ast::Literal* lit) { - if (lit->IsBool()) { - out_ << (lit->AsBool()->IsTrue() ? "true" : "false"); - } else if (lit->IsFloat()) { - out_ << FloatToString(lit->AsFloat()->value()) << "f"; - } else if (lit->IsSint()) { - out_ << lit->AsSint()->value(); - } else if (lit->IsUint()) { - out_ << lit->AsUint()->value() << "u"; + if (lit->Is()) { + out_ << (lit->As()->IsTrue() ? "true" : "false"); + } else if (lit->Is()) { + out_ << FloatToString(lit->As()->value()) << "f"; + } else if (lit->Is()) { + out_ << lit->As()->value(); + } else if (lit->Is()) { + out_ << lit->As()->value() << "u"; } else { error_ = "unknown literal type"; return false; diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 042bea578f..08f9eab14f 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -1490,8 +1490,8 @@ uint32_t Builder::GenerateLiteralIfNeeded(ast::Variable* var, Operand::Int(var->As()->constant_id())}); } - if (lit->IsBool()) { - if (lit->AsBool()->IsTrue()) { + if (lit->Is()) { + if (lit->As()->IsTrue()) { push_type(is_spec_constant ? spv::Op::OpSpecConstantTrue : spv::Op::OpConstantTrue, {Operand::Int(type_id), result}); @@ -1500,19 +1500,19 @@ uint32_t Builder::GenerateLiteralIfNeeded(ast::Variable* var, : spv::Op::OpConstantFalse, {Operand::Int(type_id), result}); } - } else if (lit->IsSint()) { - push_type( - is_spec_constant ? spv::Op::OpSpecConstant : spv::Op::OpConstant, - {Operand::Int(type_id), result, Operand::Int(lit->AsSint()->value())}); - } else if (lit->IsUint()) { - push_type( - is_spec_constant ? spv::Op::OpSpecConstant : spv::Op::OpConstant, - {Operand::Int(type_id), result, Operand::Int(lit->AsUint()->value())}); - } else if (lit->IsFloat()) { + } else if (lit->Is()) { push_type(is_spec_constant ? spv::Op::OpSpecConstant : spv::Op::OpConstant, {Operand::Int(type_id), result, - Operand::Float(lit->AsFloat()->value())}); - } else if (lit->IsNull()) { + Operand::Int(lit->As()->value())}); + } else if (lit->Is()) { + push_type(is_spec_constant ? spv::Op::OpSpecConstant : spv::Op::OpConstant, + {Operand::Int(type_id), result, + Operand::Int(lit->As()->value())}); + } else if (lit->Is()) { + push_type(is_spec_constant ? spv::Op::OpSpecConstant : spv::Op::OpConstant, + {Operand::Int(type_id), result, + Operand::Float(lit->As()->value())}); + } else if (lit->Is()) { push_type(spv::Op::OpConstantNull, {Operand::Int(type_id), result}); } else { error_ = "unknown literal type"; @@ -2247,12 +2247,12 @@ bool Builder::GenerateSwitchStatement(ast::SwitchStatement* stmt) { case_ids.push_back(block_id); for (auto* selector : item->selectors()) { - if (!selector->IsSint()) { + if (!selector->Is()) { error_ = "expected integer literal for switch case label"; return false; } - params.push_back(Operand::Int(selector->AsSint()->value())); + params.push_back(Operand::Int(selector->As()->value())); params.push_back(Operand::Int(block_id)); } } diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 88dfb21b70..d038609466 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -321,14 +321,14 @@ bool GeneratorImpl::EmitScalarConstructor( } bool GeneratorImpl::EmitLiteral(ast::Literal* lit) { - if (lit->IsBool()) { - out_ << (lit->AsBool()->IsTrue() ? "true" : "false"); - } else if (lit->IsFloat()) { - out_ << FloatToString(lit->AsFloat()->value()); - } else if (lit->IsSint()) { - out_ << lit->AsSint()->value(); - } else if (lit->IsUint()) { - out_ << lit->AsUint()->value() << "u"; + if (lit->Is()) { + out_ << (lit->As()->IsTrue() ? "true" : "false"); + } else if (lit->Is()) { + out_ << FloatToString(lit->As()->value()); + } else if (lit->Is()) { + out_ << lit->As()->value(); + } else if (lit->Is()) { + out_ << lit->As()->value() << "u"; } else { error_ = "unknown literal type"; return false;