Derive all ast::Node from Castable

The hand-rolled `AsBlah()`, `IsBlah()` methods will be migrated in future changes.

Change-Id: I078c100b561b50018771cc38c1cac4379c393424
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34301
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-11-30 23:30:58 +00:00
parent 11c9de63aa
commit e319d7f0e9
113 changed files with 198 additions and 185 deletions

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind AccessDecoration::Kind; constexpr const DecorationKind AccessDecoration::Kind;
AccessDecoration::AccessDecoration(AccessControl val, const Source& source) AccessDecoration::AccessDecoration(AccessControl val, const Source& source)
: TypeDecoration(source), value_(val) {} : Base(source), value_(val) {}
AccessDecoration::~AccessDecoration() = default; AccessDecoration::~AccessDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind AccessDecoration::GetKind() const {
} }
bool AccessDecoration::IsKind(DecorationKind kind) const { bool AccessDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || TypeDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool AccessDecoration::IsAccess() const { bool AccessDecoration::IsAccess() const {

View File

@ -24,7 +24,7 @@ namespace tint {
namespace ast { namespace ast {
/// An access decoration /// An access decoration
class AccessDecoration : public TypeDecoration { class AccessDecoration : public Castable<AccessDecoration, TypeDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kAccess; static constexpr const DecorationKind Kind = DecorationKind::kAccess;

View File

@ -17,16 +17,16 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
ArrayAccessorExpression::ArrayAccessorExpression() : Expression() {} ArrayAccessorExpression::ArrayAccessorExpression() : Base() {}
ArrayAccessorExpression::ArrayAccessorExpression(Expression* array, ArrayAccessorExpression::ArrayAccessorExpression(Expression* array,
Expression* idx_expr) Expression* idx_expr)
: Expression(), array_(array), idx_expr_(idx_expr) {} : Base(), array_(array), idx_expr_(idx_expr) {}
ArrayAccessorExpression::ArrayAccessorExpression(const Source& source, ArrayAccessorExpression::ArrayAccessorExpression(const Source& source,
Expression* array, Expression* array,
Expression* idx_expr) Expression* idx_expr)
: Expression(source), array_(array), idx_expr_(idx_expr) {} : Base(source), array_(array), idx_expr_(idx_expr) {}
ArrayAccessorExpression::ArrayAccessorExpression(ArrayAccessorExpression&&) = ArrayAccessorExpression::ArrayAccessorExpression(ArrayAccessorExpression&&) =
default; default;

View File

@ -25,7 +25,8 @@ namespace tint {
namespace ast { namespace ast {
/// An array accessor expression /// An array accessor expression
class ArrayAccessorExpression : public Expression { class ArrayAccessorExpression
: public Castable<ArrayAccessorExpression, Expression> {
public: public:
/// Constructor /// Constructor
ArrayAccessorExpression(); ArrayAccessorExpression();

View File

@ -23,7 +23,7 @@ namespace ast {
constexpr const DecorationKind ArrayDecoration::Kind; constexpr const DecorationKind ArrayDecoration::Kind;
ArrayDecoration::ArrayDecoration(const Source& source) : Decoration(source) {} ArrayDecoration::ArrayDecoration(const Source& source) : Base(source) {}
ArrayDecoration::~ArrayDecoration() = default; ArrayDecoration::~ArrayDecoration() = default;

View File

@ -27,7 +27,7 @@ namespace ast {
class StrideDecoration; class StrideDecoration;
/// A decoration attached to an array /// A decoration attached to an array
class ArrayDecoration : public Decoration { class ArrayDecoration : public Castable<ArrayDecoration, Decoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kArray; static constexpr const DecorationKind Kind = DecorationKind::kArray;

View File

@ -17,15 +17,15 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
AssignmentStatement::AssignmentStatement() : Statement() {} AssignmentStatement::AssignmentStatement() : Base() {}
AssignmentStatement::AssignmentStatement(Expression* lhs, Expression* rhs) AssignmentStatement::AssignmentStatement(Expression* lhs, Expression* rhs)
: Statement(), lhs_(lhs), rhs_(rhs) {} : Base(), lhs_(lhs), rhs_(rhs) {}
AssignmentStatement::AssignmentStatement(const Source& source, AssignmentStatement::AssignmentStatement(const Source& source,
Expression* lhs, Expression* lhs,
Expression* rhs) Expression* rhs)
: Statement(source), lhs_(lhs), rhs_(rhs) {} : Base(source), lhs_(lhs), rhs_(rhs) {}
AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default; AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default;

View File

@ -26,7 +26,7 @@ namespace tint {
namespace ast { namespace ast {
/// An assignment statement /// An assignment statement
class AssignmentStatement : public Statement { class AssignmentStatement : public Castable<AssignmentStatement, Statement> {
public: public:
/// Constructor /// Constructor
AssignmentStatement(); AssignmentStatement();

View File

@ -17,18 +17,18 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
BinaryExpression::BinaryExpression() : Expression() {} BinaryExpression::BinaryExpression() : Base() {}
BinaryExpression::BinaryExpression(BinaryOp op, BinaryExpression::BinaryExpression(BinaryOp op,
Expression* lhs, Expression* lhs,
Expression* rhs) Expression* rhs)
: Expression(), op_(op), lhs_(lhs), rhs_(rhs) {} : Base(), op_(op), lhs_(lhs), rhs_(rhs) {}
BinaryExpression::BinaryExpression(const Source& source, BinaryExpression::BinaryExpression(const Source& source,
BinaryOp op, BinaryOp op,
Expression* lhs, Expression* lhs,
Expression* rhs) Expression* rhs)
: Expression(source), op_(op), lhs_(lhs), rhs_(rhs) {} : Base(source), op_(op), lhs_(lhs), rhs_(rhs) {}
BinaryExpression::BinaryExpression(BinaryExpression&&) = default; BinaryExpression::BinaryExpression(BinaryExpression&&) = default;

View File

@ -48,7 +48,7 @@ enum class BinaryOp {
}; };
/// An binary expression /// An binary expression
class BinaryExpression : public Expression { class BinaryExpression : public Castable<BinaryExpression, Expression> {
public: public:
/// Constructor /// Constructor
BinaryExpression(); BinaryExpression();

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind BindingDecoration::Kind; constexpr const DecorationKind BindingDecoration::Kind;
BindingDecoration::BindingDecoration(uint32_t val, const Source& source) BindingDecoration::BindingDecoration(uint32_t val, const Source& source)
: VariableDecoration(source), value_(val) {} : Base(source), value_(val) {}
BindingDecoration::~BindingDecoration() = default; BindingDecoration::~BindingDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind BindingDecoration::GetKind() const {
} }
bool BindingDecoration::IsKind(DecorationKind kind) const { bool BindingDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || VariableDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool BindingDecoration::IsBinding() const { bool BindingDecoration::IsBinding() const {

View File

@ -23,7 +23,8 @@ namespace tint {
namespace ast { namespace ast {
/// A binding decoration /// A binding decoration
class BindingDecoration : public VariableDecoration { class BindingDecoration
: public Castable<BindingDecoration, VariableDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kBinding; static constexpr const DecorationKind Kind = DecorationKind::kBinding;

View File

@ -17,15 +17,15 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
BitcastExpression::BitcastExpression() : Expression() {} BitcastExpression::BitcastExpression() : Base() {}
BitcastExpression::BitcastExpression(type::Type* type, Expression* expr) BitcastExpression::BitcastExpression(type::Type* type, Expression* expr)
: Expression(), type_(type), expr_(expr) {} : Base(), type_(type), expr_(expr) {}
BitcastExpression::BitcastExpression(const Source& source, BitcastExpression::BitcastExpression(const Source& source,
type::Type* type, type::Type* type,
Expression* expr) Expression* expr)
: Expression(source), type_(type), expr_(expr) {} : Base(source), type_(type), expr_(expr) {}
BitcastExpression::BitcastExpression(BitcastExpression&&) = default; BitcastExpression::BitcastExpression(BitcastExpression&&) = default;
BitcastExpression::~BitcastExpression() = default; BitcastExpression::~BitcastExpression() = default;

View File

@ -26,7 +26,7 @@ namespace tint {
namespace ast { namespace ast {
/// A bitcast expression /// A bitcast expression
class BitcastExpression : public Expression { class BitcastExpression : public Castable<BitcastExpression, Expression> {
public: public:
/// Constructor /// Constructor
BitcastExpression(); BitcastExpression();

View File

@ -17,9 +17,9 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
BlockStatement::BlockStatement() : Statement() {} BlockStatement::BlockStatement() : Base() {}
BlockStatement::BlockStatement(const Source& source) : Statement(source) {} BlockStatement::BlockStatement(const Source& source) : Base(source) {}
BlockStatement::BlockStatement(BlockStatement&&) = default; BlockStatement::BlockStatement(BlockStatement&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A block statement /// A block statement
class BlockStatement : public Statement { class BlockStatement : public Castable<BlockStatement, Statement> {
public: public:
/// Constructor /// Constructor
BlockStatement(); BlockStatement();

View File

@ -18,7 +18,7 @@ namespace tint {
namespace ast { namespace ast {
BoolLiteral::BoolLiteral(ast::type::Type* type, bool value) BoolLiteral::BoolLiteral(ast::type::Type* type, bool value)
: Literal(type), value_(value) {} : Base(type), value_(value) {}
BoolLiteral::~BoolLiteral() = default; BoolLiteral::~BoolLiteral() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// A boolean literal /// A boolean literal
class BoolLiteral : public Literal { class BoolLiteral : public Castable<BoolLiteral, Literal> {
public: public:
/// Constructor /// Constructor
/// @param type the type of the literal /// @param type the type of the literal

View File

@ -17,9 +17,9 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
BreakStatement::BreakStatement() : Statement() {} BreakStatement::BreakStatement() : Base() {}
BreakStatement::BreakStatement(const Source& source) : Statement(source) {} BreakStatement::BreakStatement(const Source& source) : Base(source) {}
BreakStatement::BreakStatement(BreakStatement&&) = default; BreakStatement::BreakStatement(BreakStatement&&) = default;

View File

@ -21,7 +21,7 @@ namespace tint {
namespace ast { namespace ast {
/// An break statement /// An break statement
class BreakStatement : public Statement { class BreakStatement : public Castable<BreakStatement, Statement> {
public: public:
/// Constructor /// Constructor
BreakStatement(); BreakStatement();

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind BuiltinDecoration::Kind; constexpr const DecorationKind BuiltinDecoration::Kind;
BuiltinDecoration::BuiltinDecoration(Builtin builtin, const Source& source) BuiltinDecoration::BuiltinDecoration(Builtin builtin, const Source& source)
: VariableDecoration(source), builtin_(builtin) {} : Base(source), builtin_(builtin) {}
BuiltinDecoration::~BuiltinDecoration() = default; BuiltinDecoration::~BuiltinDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind BuiltinDecoration::GetKind() const {
} }
bool BuiltinDecoration::IsKind(DecorationKind kind) const { bool BuiltinDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || VariableDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool BuiltinDecoration::IsBuiltin() const { bool BuiltinDecoration::IsBuiltin() const {

View File

@ -22,7 +22,8 @@ namespace tint {
namespace ast { namespace ast {
/// A builtin decoration /// A builtin decoration
class BuiltinDecoration : public VariableDecoration { class BuiltinDecoration
: public Castable<BuiltinDecoration, VariableDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kBuiltin; static constexpr const DecorationKind Kind = DecorationKind::kBuiltin;

View File

@ -17,15 +17,15 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
CallExpression::CallExpression() : Expression() {} CallExpression::CallExpression() : Base() {}
CallExpression::CallExpression(Expression* func, ExpressionList params) CallExpression::CallExpression(Expression* func, ExpressionList params)
: Expression(), func_(func), params_(params) {} : Base(), func_(func), params_(params) {}
CallExpression::CallExpression(const Source& source, CallExpression::CallExpression(const Source& source,
Expression* func, Expression* func,
ExpressionList params) ExpressionList params)
: Expression(source), func_(func), params_(params) {} : Base(source), func_(func), params_(params) {}
CallExpression::CallExpression(CallExpression&&) = default; CallExpression::CallExpression(CallExpression&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A call expression /// A call expression
class CallExpression : public Expression { class CallExpression : public Castable<CallExpression, Expression> {
public: public:
/// Constructor /// Constructor
CallExpression(); CallExpression();

View File

@ -19,9 +19,9 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
CallStatement::CallStatement() : Statement() {} CallStatement::CallStatement() : Base() {}
CallStatement::CallStatement(CallExpression* call) : Statement(), call_(call) {} CallStatement::CallStatement(CallExpression* call) : Base(), call_(call) {}
CallStatement::CallStatement(CallStatement&&) = default; CallStatement::CallStatement(CallStatement&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A call expression /// A call expression
class CallStatement : public Statement { class CallStatement : public Castable<CallStatement, Statement> {
public: public:
/// Constructor /// Constructor
CallStatement(); CallStatement();

View File

@ -17,15 +17,15 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
CaseStatement::CaseStatement(BlockStatement* body) : Statement(), body_(body) {} CaseStatement::CaseStatement(BlockStatement* body) : Base(), body_(body) {}
CaseStatement::CaseStatement(CaseSelectorList selectors, BlockStatement* body) CaseStatement::CaseStatement(CaseSelectorList selectors, BlockStatement* body)
: Statement(), selectors_(selectors), body_(body) {} : Base(), selectors_(selectors), body_(body) {}
CaseStatement::CaseStatement(const Source& source, CaseStatement::CaseStatement(const Source& source,
CaseSelectorList selectors, CaseSelectorList selectors,
BlockStatement* body) BlockStatement* body)
: Statement(source), selectors_(selectors), body_(body) {} : Base(source), selectors_(selectors), body_(body) {}
CaseStatement::CaseStatement(CaseStatement&&) = default; CaseStatement::CaseStatement(CaseStatement&&) = default;

View File

@ -31,7 +31,7 @@ namespace ast {
using CaseSelectorList = std::vector<IntLiteral*>; using CaseSelectorList = std::vector<IntLiteral*>;
/// A case statement /// A case statement
class CaseStatement : public Statement { class CaseStatement : public Castable<CaseStatement, Statement> {
public: public:
/// Constructor /// Constructor
/// Creates a default case statement /// Creates a default case statement

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind ConstantIdDecoration::Kind; constexpr const DecorationKind ConstantIdDecoration::Kind;
ConstantIdDecoration::ConstantIdDecoration(uint32_t val, const Source& source) ConstantIdDecoration::ConstantIdDecoration(uint32_t val, const Source& source)
: VariableDecoration(source), value_(val) {} : Base(source), value_(val) {}
ConstantIdDecoration::~ConstantIdDecoration() = default; ConstantIdDecoration::~ConstantIdDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind ConstantIdDecoration::GetKind() const {
} }
bool ConstantIdDecoration::IsKind(DecorationKind kind) const { bool ConstantIdDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || VariableDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool ConstantIdDecoration::IsConstantId() const { bool ConstantIdDecoration::IsConstantId() const {

View File

@ -22,7 +22,8 @@ namespace tint {
namespace ast { namespace ast {
/// A constant id decoration /// A constant id decoration
class ConstantIdDecoration : public VariableDecoration { class ConstantIdDecoration
: public Castable<ConstantIdDecoration, VariableDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kConstantId; static constexpr const DecorationKind Kind = DecorationKind::kConstantId;

View File

@ -26,8 +26,10 @@ ConstructorExpression::ConstructorExpression() = default;
ConstructorExpression::~ConstructorExpression() = default; ConstructorExpression::~ConstructorExpression() = default;
ConstructorExpression::ConstructorExpression(ConstructorExpression&&) = default;
ConstructorExpression::ConstructorExpression(const Source& source) ConstructorExpression::ConstructorExpression(const Source& source)
: Expression(source) {} : Base(source) {}
bool ConstructorExpression::IsConstructor() const { bool ConstructorExpression::IsConstructor() const {
return true; return true;

View File

@ -24,7 +24,8 @@ class ScalarConstructorExpression;
class TypeConstructorExpression; class TypeConstructorExpression;
/// Base class for constructor style expressions /// Base class for constructor style expressions
class ConstructorExpression : public Expression { class ConstructorExpression
: public Castable<ConstructorExpression, Expression> {
public: public:
~ConstructorExpression() override; ~ConstructorExpression() override;
@ -48,7 +49,7 @@ class ConstructorExpression : public Expression {
/// @param source the constructor source /// @param source the constructor source
explicit ConstructorExpression(const Source& source); explicit ConstructorExpression(const Source& source);
/// Move constructor /// Move constructor
ConstructorExpression(ConstructorExpression&&) = default; ConstructorExpression(ConstructorExpression&&);
private: private:
ConstructorExpression(const ConstructorExpression&) = delete; ConstructorExpression(const ConstructorExpression&) = delete;

View File

@ -17,10 +17,9 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
ContinueStatement::ContinueStatement() : Statement() {} ContinueStatement::ContinueStatement() : Base() {}
ContinueStatement::ContinueStatement(const Source& source) ContinueStatement::ContinueStatement(const Source& source) : Base(source) {}
: Statement(source) {}
ContinueStatement::ContinueStatement(ContinueStatement&&) = default; ContinueStatement::ContinueStatement(ContinueStatement&&) = default;

View File

@ -24,7 +24,7 @@ namespace tint {
namespace ast { namespace ast {
/// An continue statement /// An continue statement
class ContinueStatement : public Statement { class ContinueStatement : public Castable<ContinueStatement, Statement> {
public: public:
/// Constructor /// Constructor
ContinueStatement(); ContinueStatement();

View File

@ -24,7 +24,7 @@ namespace ast {
DecoratedVariable::DecoratedVariable() = default; DecoratedVariable::DecoratedVariable() = default;
DecoratedVariable::DecoratedVariable(Variable* var) DecoratedVariable::DecoratedVariable(Variable* var)
: Variable(var->source(), var->name(), var->storage_class(), var->type()) {} : Base(var->source(), var->name(), var->storage_class(), var->type()) {}
DecoratedVariable::DecoratedVariable(DecoratedVariable&&) = default; DecoratedVariable::DecoratedVariable(DecoratedVariable&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A Decorated Variable statement. /// A Decorated Variable statement.
class DecoratedVariable : public Variable { class DecoratedVariable : public Castable<DecoratedVariable, Variable> {
public: public:
/// Create a new empty decorated variable statement /// Create a new empty decorated variable statement
DecoratedVariable(); DecoratedVariable();

View File

@ -47,7 +47,7 @@ enum class DecorationKind {
std::ostream& operator<<(std::ostream& out, DecorationKind data); std::ostream& operator<<(std::ostream& out, DecorationKind data);
/// The base class for all decorations /// The base class for all decorations
class Decoration : public Node { class Decoration : public Castable<Decoration, Node> {
public: public:
~Decoration() override; ~Decoration() override;
@ -59,19 +59,13 @@ class Decoration : public Node {
/// kind. /// kind.
virtual bool IsKind(DecorationKind kind) const = 0; virtual bool IsKind(DecorationKind kind) const = 0;
/// @return true if this decoration is of (or derives from) type |TO|
template <typename TO>
bool Is() const {
return IsKind(TO::Kind);
}
/// @returns true if the node is valid /// @returns true if the node is valid
bool IsValid() const override; bool IsValid() const override;
protected: protected:
/// Constructor /// Constructor
/// @param source the source of this decoration /// @param source the source of this decoration
explicit Decoration(const Source& source) : Node(source) {} explicit Decoration(const Source& source) : Base(source) {}
}; };
/// As dynamically casts |deco| to the target type |TO|. /// As dynamically casts |deco| to the target type |TO|.

View File

@ -57,7 +57,7 @@ TEST_F(DecorationTest, AsIncorrectType) {
} }
TEST_F(DecorationTest, Is) { TEST_F(DecorationTest, Is) {
auto* decoration = create<ConstantIdDecoration>(1, Source{}); Decoration* decoration = create<ConstantIdDecoration>(1, Source{});
EXPECT_TRUE(decoration->Is<VariableDecoration>()); EXPECT_TRUE(decoration->Is<VariableDecoration>());
EXPECT_FALSE(decoration->Is<ArrayDecoration>()); EXPECT_FALSE(decoration->Is<ArrayDecoration>());
} }

View File

@ -17,9 +17,11 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
DiscardStatement::DiscardStatement() : Statement() {} DiscardStatement::DiscardStatement() : Base() {}
DiscardStatement::DiscardStatement(const Source& source) : Statement(source) {} DiscardStatement::DiscardStatement(const Source& source) : Base(source) {}
DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
DiscardStatement::~DiscardStatement() = default; DiscardStatement::~DiscardStatement() = default;

View File

@ -21,7 +21,7 @@ namespace tint {
namespace ast { namespace ast {
/// A discard statement /// A discard statement
class DiscardStatement : public Statement { class DiscardStatement : public Castable<DiscardStatement, Statement> {
public: public:
/// Constructor /// Constructor
DiscardStatement(); DiscardStatement();
@ -29,7 +29,7 @@ class DiscardStatement : public Statement {
/// @param source the discard statement source /// @param source the discard statement source
explicit DiscardStatement(const Source& source); explicit DiscardStatement(const Source& source);
/// Move constructor /// Move constructor
DiscardStatement(DiscardStatement&&) = default; DiscardStatement(DiscardStatement&&);
~DiscardStatement() override; ~DiscardStatement() override;
/// @returns true if this is a discard statement /// @returns true if this is a discard statement

View File

@ -17,18 +17,18 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
ElseStatement::ElseStatement(BlockStatement* body) : Statement(), body_(body) {} ElseStatement::ElseStatement(BlockStatement* body) : Base(), body_(body) {}
ElseStatement::ElseStatement(Expression* condition, BlockStatement* body) ElseStatement::ElseStatement(Expression* condition, BlockStatement* body)
: Statement(), condition_(condition), body_(body) {} : Base(), condition_(condition), body_(body) {}
ElseStatement::ElseStatement(const Source& source, BlockStatement* body) ElseStatement::ElseStatement(const Source& source, BlockStatement* body)
: Statement(source), body_(body) {} : Base(source), body_(body) {}
ElseStatement::ElseStatement(const Source& source, ElseStatement::ElseStatement(const Source& source,
Expression* condition, Expression* condition,
BlockStatement* body) BlockStatement* body)
: Statement(source), condition_(condition), body_(body) {} : Base(source), condition_(condition), body_(body) {}
ElseStatement::ElseStatement(ElseStatement&&) = default; ElseStatement::ElseStatement(ElseStatement&&) = default;

View File

@ -27,7 +27,7 @@ namespace tint {
namespace ast { namespace ast {
/// An else statement /// An else statement
class ElseStatement : public Statement { class ElseStatement : public Castable<ElseStatement, Statement> {
public: public:
/// Constructor /// Constructor
/// @param body the else body /// @param body the else body

View File

@ -31,7 +31,9 @@ namespace ast {
Expression::Expression() = default; Expression::Expression() = default;
Expression::Expression(const Source& source) : Node(source) {} Expression::Expression(const Source& source) : Base(source) {}
Expression::Expression(Expression&&) = default;
Expression::~Expression() = default; Expression::~Expression() = default;

View File

@ -35,7 +35,7 @@ class MemberAccessorExpression;
class UnaryOpExpression; class UnaryOpExpression;
/// Base expression class /// Base expression class
class Expression : public Node { class Expression : public Castable<Expression, Node> {
public: public:
~Expression() override; ~Expression() override;
@ -109,7 +109,7 @@ class Expression : public Node {
/// @param source the source of the expression /// @param source the source of the expression
explicit Expression(const Source& source); explicit Expression(const Source& source);
/// Move constructor /// Move constructor
Expression(Expression&&) = default; Expression(Expression&&);
private: private:
Expression(const Expression&) = delete; Expression(const Expression&) = delete;

View File

@ -17,10 +17,12 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
FallthroughStatement::FallthroughStatement() : Statement() {} FallthroughStatement::FallthroughStatement() : Base() {}
FallthroughStatement::FallthroughStatement(const Source& source) FallthroughStatement::FallthroughStatement(const Source& source)
: Statement(source) {} : Base(source) {}
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
FallthroughStatement::~FallthroughStatement() = default; FallthroughStatement::~FallthroughStatement() = default;

View File

@ -21,7 +21,7 @@ namespace tint {
namespace ast { namespace ast {
/// An fallthrough statement /// An fallthrough statement
class FallthroughStatement : public Statement { class FallthroughStatement : public Castable<FallthroughStatement, Statement> {
public: public:
/// Constructor /// Constructor
FallthroughStatement(); FallthroughStatement();
@ -29,7 +29,7 @@ class FallthroughStatement : public Statement {
/// @param source the source information /// @param source the source information
explicit FallthroughStatement(const Source& source); explicit FallthroughStatement(const Source& source);
/// Move constructor /// Move constructor
FallthroughStatement(FallthroughStatement&&) = default; FallthroughStatement(FallthroughStatement&&);
~FallthroughStatement() override; ~FallthroughStatement() override;
/// @returns true if this is an fallthrough statement /// @returns true if this is an fallthrough statement

View File

@ -21,7 +21,7 @@ namespace tint {
namespace ast { namespace ast {
FloatLiteral::FloatLiteral(ast::type::Type* type, float value) FloatLiteral::FloatLiteral(ast::type::Type* type, float value)
: Literal(type), value_(value) {} : Base(type), value_(value) {}
FloatLiteral::~FloatLiteral() = default; FloatLiteral::~FloatLiteral() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// A float literal /// A float literal
class FloatLiteral : public Literal { class FloatLiteral : public Castable<FloatLiteral, Literal> {
public: public:
/// Constructor /// Constructor
/// @param type the type of the literal /// @param type the type of the literal

View File

@ -32,7 +32,7 @@ Function::Function(const std::string& name,
VariableList params, VariableList params,
type::Type* return_type, type::Type* return_type,
BlockStatement* body) BlockStatement* body)
: Node(), : Base(),
name_(name), name_(name),
params_(std::move(params)), params_(std::move(params)),
return_type_(return_type), return_type_(return_type),
@ -43,7 +43,7 @@ Function::Function(const Source& source,
VariableList params, VariableList params,
type::Type* return_type, type::Type* return_type,
BlockStatement* body) BlockStatement* body)
: Node(source), : Base(source),
name_(name), name_(name),
params_(std::move(params)), params_(std::move(params)),
return_type_(return_type), return_type_(return_type),

View File

@ -40,7 +40,7 @@ namespace tint {
namespace ast { namespace ast {
/// A Function statement. /// A Function statement.
class Function : public Node { class Function : public Castable<Function, Node> {
public: public:
/// Information about a binding /// Information about a binding
struct BindingInfo { struct BindingInfo {

View File

@ -24,8 +24,7 @@ namespace ast {
constexpr const DecorationKind FunctionDecoration::Kind; constexpr const DecorationKind FunctionDecoration::Kind;
FunctionDecoration::FunctionDecoration(const Source& source) FunctionDecoration::FunctionDecoration(const Source& source) : Base(source) {}
: Decoration(source) {}
FunctionDecoration::~FunctionDecoration() = default; FunctionDecoration::~FunctionDecoration() = default;

View File

@ -28,7 +28,7 @@ class StageDecoration;
class WorkgroupDecoration; class WorkgroupDecoration;
/// A decoration attached to a function /// A decoration attached to a function
class FunctionDecoration : public Decoration { class FunctionDecoration : public Castable<FunctionDecoration, Decoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kFunction; static constexpr const DecorationKind Kind = DecorationKind::kFunction;

View File

@ -18,11 +18,11 @@ namespace tint {
namespace ast { namespace ast {
IdentifierExpression::IdentifierExpression(const std::string& name) IdentifierExpression::IdentifierExpression(const std::string& name)
: Expression(), name_(name) {} : Base(), name_(name) {}
IdentifierExpression::IdentifierExpression(const Source& source, IdentifierExpression::IdentifierExpression(const Source& source,
const std::string& name) const std::string& name)
: Expression(source), name_(name) {} : Base(source), name_(name) {}
IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default; IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;

View File

@ -26,7 +26,7 @@ namespace tint {
namespace ast { namespace ast {
/// An identifier expression /// An identifier expression
class IdentifierExpression : public Expression { class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
public: public:
/// Constructor /// Constructor
/// @param name the name /// @param name the name

View File

@ -20,12 +20,12 @@ namespace tint {
namespace ast { namespace ast {
IfStatement::IfStatement(Expression* condition, BlockStatement* body) IfStatement::IfStatement(Expression* condition, BlockStatement* body)
: Statement(), condition_(condition), body_(body) {} : Base(), condition_(condition), body_(body) {}
IfStatement::IfStatement(const Source& source, IfStatement::IfStatement(const Source& source,
Expression* condition, Expression* condition,
BlockStatement* body) BlockStatement* body)
: Statement(source), condition_(condition), body_(body) {} : Base(source), condition_(condition), body_(body) {}
IfStatement::IfStatement(IfStatement&&) = default; IfStatement::IfStatement(IfStatement&&) = default;

View File

@ -27,7 +27,7 @@ namespace tint {
namespace ast { namespace ast {
/// An if statement /// An if statement
class IfStatement : public Statement { class IfStatement : public Castable<IfStatement, Statement> {
public: public:
/// Constructor /// Constructor
/// @param condition the if condition /// @param condition the if condition

View File

@ -17,7 +17,7 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
IntLiteral::IntLiteral(ast::type::Type* type) : Literal(type) {} IntLiteral::IntLiteral(ast::type::Type* type) : Base(type) {}
IntLiteral::~IntLiteral() = default; IntLiteral::~IntLiteral() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// An integer literal. This could be either signed or unsigned. /// An integer literal. This could be either signed or unsigned.
class IntLiteral : public Literal { class IntLiteral : public Castable<IntLiteral, Literal> {
public: public:
~IntLiteral() override; ~IntLiteral() override;

View File

@ -31,7 +31,7 @@ class IntLiteral;
class UintLiteral; class UintLiteral;
/// Base class for a literal value /// Base class for a literal value
class Literal : public Node { class Literal : public Castable<Literal, Node> {
public: public:
~Literal() override; ~Literal() override;

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind LocationDecoration::Kind; constexpr const DecorationKind LocationDecoration::Kind;
LocationDecoration::LocationDecoration(uint32_t val, const Source& source) LocationDecoration::LocationDecoration(uint32_t val, const Source& source)
: VariableDecoration(source), value_(val) {} : Base(source), value_(val) {}
LocationDecoration::~LocationDecoration() = default; LocationDecoration::~LocationDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind LocationDecoration::GetKind() const {
} }
bool LocationDecoration::IsKind(DecorationKind kind) const { bool LocationDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || VariableDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool LocationDecoration::IsLocation() const { bool LocationDecoration::IsLocation() const {

View File

@ -23,7 +23,8 @@ namespace tint {
namespace ast { namespace ast {
/// A location decoration /// A location decoration
class LocationDecoration : public VariableDecoration { class LocationDecoration
: public Castable<LocationDecoration, VariableDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kLocation; static constexpr const DecorationKind Kind = DecorationKind::kLocation;

View File

@ -18,12 +18,12 @@ namespace tint {
namespace ast { namespace ast {
LoopStatement::LoopStatement(BlockStatement* body, BlockStatement* continuing) LoopStatement::LoopStatement(BlockStatement* body, BlockStatement* continuing)
: Statement(), body_(body), continuing_(continuing) {} : Base(), body_(body), continuing_(continuing) {}
LoopStatement::LoopStatement(const Source& source, LoopStatement::LoopStatement(const Source& source,
BlockStatement* body, BlockStatement* body,
BlockStatement* continuing) BlockStatement* continuing)
: Statement(source), body_(body), continuing_(continuing) {} : Base(source), body_(body), continuing_(continuing) {}
LoopStatement::LoopStatement(LoopStatement&&) = default; LoopStatement::LoopStatement(LoopStatement&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A loop statement /// A loop statement
class LoopStatement : public Statement { class LoopStatement : public Castable<LoopStatement, Statement> {
public: public:
/// Constructor /// Constructor
/// @param body the body statements /// @param body the body statements

View File

@ -21,12 +21,12 @@ MemberAccessorExpression::MemberAccessorExpression() = default;
MemberAccessorExpression::MemberAccessorExpression(Expression* structure, MemberAccessorExpression::MemberAccessorExpression(Expression* structure,
IdentifierExpression* member) IdentifierExpression* member)
: Expression(), struct_(structure), member_(member) {} : Base(), struct_(structure), member_(member) {}
MemberAccessorExpression::MemberAccessorExpression(const Source& source, MemberAccessorExpression::MemberAccessorExpression(const Source& source,
Expression* structure, Expression* structure,
IdentifierExpression* member) IdentifierExpression* member)
: Expression(source), struct_(structure), member_(member) {} : Base(source), struct_(structure), member_(member) {}
MemberAccessorExpression::MemberAccessorExpression(MemberAccessorExpression&&) = MemberAccessorExpression::MemberAccessorExpression(MemberAccessorExpression&&) =
default; default;

View File

@ -27,7 +27,8 @@ namespace tint {
namespace ast { namespace ast {
/// A member accessor expression /// A member accessor expression
class MemberAccessorExpression : public Expression { class MemberAccessorExpression
: public Castable<MemberAccessorExpression, Expression> {
public: public:
/// Constructor /// Constructor
MemberAccessorExpression(); MemberAccessorExpression();

View File

@ -23,6 +23,8 @@ Node::Node() = default;
Node::Node(const Source& source) : source_(source) {} Node::Node(const Source& source) : source_(source) {}
Node::Node(Node&&) = default;
Node::~Node() = default; Node::~Node() = default;
void Node::make_indent(std::ostream& out, size_t indent) const { void Node::make_indent(std::ostream& out, size_t indent) const {

View File

@ -18,15 +18,16 @@
#include <ostream> #include <ostream>
#include <string> #include <string>
#include "src/castable.h"
#include "src/source.h" #include "src/source.h"
namespace tint { namespace tint {
namespace ast { namespace ast {
/// AST base class node /// AST base class node
class Node { class Node : public Castable<Node> {
public: public:
virtual ~Node(); ~Node() override;
/// @returns the node source data /// @returns the node source data
const Source& source() const { return source_; } const Source& source() const { return source_; }
@ -53,7 +54,7 @@ class Node {
/// @param source The input source for the node /// @param source The input source for the node
explicit Node(const Source& source); explicit Node(const Source& source);
/// Move constructor /// Move constructor
Node(Node&&) = default; Node(Node&&);
/// Writes indent into stream /// Writes indent into stream
/// @param out the stream to write to /// @param out the stream to write to

View File

@ -17,7 +17,7 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
NullLiteral::NullLiteral(ast::type::Type* type) : Literal(type) {} NullLiteral::NullLiteral(ast::type::Type* type) : Base(type) {}
NullLiteral::~NullLiteral() = default; NullLiteral::~NullLiteral() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// A null literal /// A null literal
class NullLiteral : public Literal { class NullLiteral : public Castable<NullLiteral, Literal> {
public: public:
/// Constructor /// Constructor
/// @param type the type /// @param type the type

View File

@ -17,15 +17,14 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
ReturnStatement::ReturnStatement() : Statement() {} ReturnStatement::ReturnStatement() : Base() {}
ReturnStatement::ReturnStatement(const Source& source) : Statement(source) {} ReturnStatement::ReturnStatement(const Source& source) : Base(source) {}
ReturnStatement::ReturnStatement(Expression* value) ReturnStatement::ReturnStatement(Expression* value) : Base(), value_(value) {}
: Statement(), value_(value) {}
ReturnStatement::ReturnStatement(const Source& source, Expression* value) ReturnStatement::ReturnStatement(const Source& source, Expression* value)
: Statement(source), value_(value) {} : Base(source), value_(value) {}
ReturnStatement::ReturnStatement(ReturnStatement&&) = default; ReturnStatement::ReturnStatement(ReturnStatement&&) = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A return statement /// A return statement
class ReturnStatement : public Statement { class ReturnStatement : public Castable<ReturnStatement, Statement> {
public: public:
/// Constructor /// Constructor
ReturnStatement(); ReturnStatement();

View File

@ -17,15 +17,14 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
ScalarConstructorExpression::ScalarConstructorExpression() ScalarConstructorExpression::ScalarConstructorExpression() : Base() {}
: ConstructorExpression() {}
ScalarConstructorExpression::ScalarConstructorExpression(Literal* literal) ScalarConstructorExpression::ScalarConstructorExpression(Literal* literal)
: literal_(literal) {} : literal_(literal) {}
ScalarConstructorExpression::ScalarConstructorExpression(const Source& source, ScalarConstructorExpression::ScalarConstructorExpression(const Source& source,
Literal* litearl) Literal* litearl)
: ConstructorExpression(source), literal_(litearl) {} : Base(source), literal_(litearl) {}
ScalarConstructorExpression::ScalarConstructorExpression( ScalarConstructorExpression::ScalarConstructorExpression(
ScalarConstructorExpression&&) = default; ScalarConstructorExpression&&) = default;

View File

@ -25,7 +25,8 @@ namespace tint {
namespace ast { namespace ast {
/// A scalar constructor /// A scalar constructor
class ScalarConstructorExpression : public ConstructorExpression { class ScalarConstructorExpression
: public Castable<ScalarConstructorExpression, ConstructorExpression> {
public: public:
/// Constructor /// Constructor
ScalarConstructorExpression(); ScalarConstructorExpression();

View File

@ -18,7 +18,7 @@ namespace tint {
namespace ast { namespace ast {
SetDecoration::SetDecoration(uint32_t val, const Source& source) SetDecoration::SetDecoration(uint32_t val, const Source& source)
: VariableDecoration(source), value_(val) {} : Base(source), value_(val) {}
SetDecoration::~SetDecoration() = default; SetDecoration::~SetDecoration() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// A set decoration /// A set decoration
class SetDecoration : public VariableDecoration { class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
public: public:
/// constructor /// constructor
/// @param value the set value /// @param value the set value

View File

@ -18,7 +18,7 @@ namespace tint {
namespace ast { namespace ast {
SintLiteral::SintLiteral(ast::type::Type* type, int32_t value) SintLiteral::SintLiteral(ast::type::Type* type, int32_t value)
: IntLiteral(type), value_(value) {} : Base(type), value_(value) {}
SintLiteral::~SintLiteral() = default; SintLiteral::~SintLiteral() = default;

View File

@ -23,7 +23,7 @@ namespace tint {
namespace ast { namespace ast {
/// A signed int literal /// A signed int literal
class SintLiteral : public IntLiteral { class SintLiteral : public Castable<SintLiteral, IntLiteral> {
public: public:
/// Constructor /// Constructor
/// @param type the type /// @param type the type

View File

@ -20,7 +20,7 @@ namespace ast {
constexpr const DecorationKind StageDecoration::Kind; constexpr const DecorationKind StageDecoration::Kind;
StageDecoration::StageDecoration(ast::PipelineStage stage, const Source& source) StageDecoration::StageDecoration(ast::PipelineStage stage, const Source& source)
: FunctionDecoration(source), stage_(stage) {} : Base(source), stage_(stage) {}
StageDecoration::~StageDecoration() = default; StageDecoration::~StageDecoration() = default;
@ -29,7 +29,7 @@ DecorationKind StageDecoration::GetKind() const {
} }
bool StageDecoration::IsKind(DecorationKind kind) const { bool StageDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || FunctionDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool StageDecoration::IsStage() const { bool StageDecoration::IsStage() const {

View File

@ -22,7 +22,7 @@ namespace tint {
namespace ast { namespace ast {
/// A workgroup decoration /// A workgroup decoration
class StageDecoration : public FunctionDecoration { class StageDecoration : public Castable<StageDecoration, FunctionDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kStage; static constexpr const DecorationKind Kind = DecorationKind::kStage;

View File

@ -36,7 +36,7 @@ namespace ast {
Statement::Statement() = default; Statement::Statement() = default;
Statement::Statement(const Source& source) : Node(source) {} Statement::Statement(const Source& source) : Base(source) {}
Statement::Statement(Statement&&) = default; Statement::Statement(Statement&&) = default;

View File

@ -39,7 +39,7 @@ class SwitchStatement;
class VariableDeclStatement; class VariableDeclStatement;
/// Base statement class /// Base statement class
class Statement : public Node { class Statement : public Castable<Statement, Node> {
public: public:
~Statement() override; ~Statement() override;

View File

@ -20,14 +20,14 @@ namespace ast {
constexpr const DecorationKind StrideDecoration::Kind; constexpr const DecorationKind StrideDecoration::Kind;
StrideDecoration::StrideDecoration(uint32_t stride, const Source& source) StrideDecoration::StrideDecoration(uint32_t stride, const Source& source)
: ArrayDecoration(source), stride_(stride) {} : Base(source), stride_(stride) {}
DecorationKind StrideDecoration::GetKind() const { DecorationKind StrideDecoration::GetKind() const {
return Kind; return Kind;
} }
bool StrideDecoration::IsKind(DecorationKind kind) const { bool StrideDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || ArrayDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool StrideDecoration::IsStride() const { bool StrideDecoration::IsStride() const {

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// A stride decoration /// A stride decoration
class StrideDecoration : public ArrayDecoration { class StrideDecoration : public Castable<StrideDecoration, ArrayDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kStride; static constexpr const DecorationKind Kind = DecorationKind::kStride;

View File

@ -17,23 +17,23 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
Struct::Struct() : Node() {} Struct::Struct() : Base() {}
Struct::Struct(StructMemberList members) Struct::Struct(StructMemberList members)
: Node(), members_(std::move(members)) {} : Base(), members_(std::move(members)) {}
Struct::Struct(StructDecorationList decorations, StructMemberList members) Struct::Struct(StructDecorationList decorations, StructMemberList members)
: Node(), : Base(),
decorations_(std::move(decorations)), decorations_(std::move(decorations)),
members_(std::move(members)) {} members_(std::move(members)) {}
Struct::Struct(const Source& source, StructMemberList members) Struct::Struct(const Source& source, StructMemberList members)
: Node(source), members_(std::move(members)) {} : Base(source), members_(std::move(members)) {}
Struct::Struct(const Source& source, Struct::Struct(const Source& source,
StructDecorationList decorations, StructDecorationList decorations,
StructMemberList members) StructMemberList members)
: Node(source), : Base(source),
decorations_(std::move(decorations)), decorations_(std::move(decorations)),
members_(std::move(members)) {} members_(std::move(members)) {}

View File

@ -27,7 +27,7 @@ namespace tint {
namespace ast { namespace ast {
/// A struct statement. /// A struct statement.
class Struct : public Node { class Struct : public Castable<Struct, Node> {
public: public:
/// Create a new empty struct statement /// Create a new empty struct statement
Struct(); Struct();

View File

@ -18,7 +18,7 @@ namespace tint {
namespace ast { namespace ast {
StructBlockDecoration::StructBlockDecoration(const Source& source) StructBlockDecoration::StructBlockDecoration(const Source& source)
: StructDecoration(source) {} : Base(source) {}
StructBlockDecoration::~StructBlockDecoration() = default; StructBlockDecoration::~StructBlockDecoration() = default;

View File

@ -25,7 +25,8 @@ namespace tint {
namespace ast { namespace ast {
/// The struct decorations /// The struct decorations
class StructBlockDecoration : public StructDecoration { class StructBlockDecoration
: public Castable<StructBlockDecoration, StructDecoration> {
public: public:
/// constructor /// constructor
/// @param source the source of this decoration /// @param source the source of this decoration

View File

@ -19,7 +19,7 @@ namespace ast {
constexpr const DecorationKind StructDecoration::Kind; constexpr const DecorationKind StructDecoration::Kind;
StructDecoration::StructDecoration(const Source& source) : Decoration(source) {} StructDecoration::StructDecoration(const Source& source) : Base(source) {}
StructDecoration::~StructDecoration() = default; StructDecoration::~StructDecoration() = default;

View File

@ -25,7 +25,7 @@ namespace tint {
namespace ast { namespace ast {
/// The struct decorations /// The struct decorations
class StructDecoration : public Decoration { class StructDecoration : public Castable<StructDecoration, Decoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kStruct; static constexpr const DecorationKind Kind = DecorationKind::kStruct;

View File

@ -24,13 +24,13 @@ StructMember::StructMember() = default;
StructMember::StructMember(const std::string& name, StructMember::StructMember(const std::string& name,
type::Type* type, type::Type* type,
StructMemberDecorationList decorations) StructMemberDecorationList decorations)
: Node(), name_(name), type_(type), decorations_(std::move(decorations)) {} : Base(), name_(name), type_(type), decorations_(std::move(decorations)) {}
StructMember::StructMember(const Source& source, StructMember::StructMember(const Source& source,
const std::string& name, const std::string& name,
type::Type* type, type::Type* type,
StructMemberDecorationList decorations) StructMemberDecorationList decorations)
: Node(source), : Base(source),
name_(name), name_(name),
type_(type), type_(type),
decorations_(std::move(decorations)) {} decorations_(std::move(decorations)) {}

View File

@ -29,7 +29,7 @@ namespace tint {
namespace ast { namespace ast {
/// A struct member statement. /// A struct member statement.
class StructMember : public Node { class StructMember : public Castable<StructMember, Node> {
public: public:
/// Create a new empty struct member statement /// Create a new empty struct member statement
StructMember(); StructMember();

View File

@ -24,7 +24,7 @@ namespace ast {
constexpr const DecorationKind StructMemberDecoration::Kind; constexpr const DecorationKind StructMemberDecoration::Kind;
StructMemberDecoration::StructMemberDecoration(const Source& source) StructMemberDecoration::StructMemberDecoration(const Source& source)
: Decoration(source) {} : Base(source) {}
StructMemberDecoration::~StructMemberDecoration() = default; StructMemberDecoration::~StructMemberDecoration() = default;

View File

@ -27,7 +27,8 @@ namespace ast {
class StructMemberOffsetDecoration; class StructMemberOffsetDecoration;
/// A decoration attached to a struct member /// A decoration attached to a struct member
class StructMemberDecoration : public Decoration { class StructMemberDecoration
: public Castable<StructMemberDecoration, Decoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = DecorationKind::kStructMember; static constexpr const DecorationKind Kind = DecorationKind::kStructMember;

View File

@ -21,14 +21,14 @@ constexpr const DecorationKind StructMemberOffsetDecoration::Kind;
StructMemberOffsetDecoration::StructMemberOffsetDecoration(uint32_t offset, StructMemberOffsetDecoration::StructMemberOffsetDecoration(uint32_t offset,
const Source& source) const Source& source)
: StructMemberDecoration(source), offset_(offset) {} : Base(source), offset_(offset) {}
DecorationKind StructMemberOffsetDecoration::GetKind() const { DecorationKind StructMemberOffsetDecoration::GetKind() const {
return Kind; return Kind;
} }
bool StructMemberOffsetDecoration::IsKind(DecorationKind kind) const { bool StructMemberOffsetDecoration::IsKind(DecorationKind kind) const {
return kind == Kind || StructMemberDecoration::IsKind(kind); return kind == Kind || Base::IsKind(kind);
} }
bool StructMemberOffsetDecoration::IsOffset() const { bool StructMemberOffsetDecoration::IsOffset() const {

View File

@ -25,7 +25,8 @@ namespace tint {
namespace ast { namespace ast {
/// A struct member offset decoration /// A struct member offset decoration
class StructMemberOffsetDecoration : public StructMemberDecoration { class StructMemberOffsetDecoration
: public Castable<StructMemberOffsetDecoration, StructMemberDecoration> {
public: public:
/// The kind of decoration that this type represents /// The kind of decoration that this type represents
static constexpr const DecorationKind Kind = static constexpr const DecorationKind Kind =

View File

@ -19,7 +19,7 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
SwitchStatement::SwitchStatement() : Statement() {} SwitchStatement::SwitchStatement() : Base() {}
SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body) SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body)
: condition_(condition), body_(body) {} : condition_(condition), body_(body) {}
@ -27,7 +27,7 @@ SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body)
SwitchStatement::SwitchStatement(const Source& source, SwitchStatement::SwitchStatement(const Source& source,
Expression* condition, Expression* condition,
CaseStatementList body) CaseStatementList body)
: Statement(source), condition_(condition), body_(body) {} : Base(source), condition_(condition), body_(body) {}
bool SwitchStatement::IsSwitch() const { bool SwitchStatement::IsSwitch() const {
return true; return true;

View File

@ -27,7 +27,7 @@ namespace tint {
namespace ast { namespace ast {
/// A switch statement /// A switch statement
class SwitchStatement : public Statement { class SwitchStatement : public Castable<SwitchStatement, Statement> {
public: public:
/// Constructor /// Constructor
SwitchStatement(); SwitchStatement();

View File

@ -17,17 +17,16 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
TypeConstructorExpression::TypeConstructorExpression() TypeConstructorExpression::TypeConstructorExpression() : Base() {}
: ConstructorExpression() {}
TypeConstructorExpression::TypeConstructorExpression(type::Type* type, TypeConstructorExpression::TypeConstructorExpression(type::Type* type,
ExpressionList values) ExpressionList values)
: ConstructorExpression(), type_(type), values_(std::move(values)) {} : Base(), type_(type), values_(std::move(values)) {}
TypeConstructorExpression::TypeConstructorExpression(const Source& source, TypeConstructorExpression::TypeConstructorExpression(const Source& source,
type::Type* type, type::Type* type,
ExpressionList values) ExpressionList values)
: ConstructorExpression(source), type_(type), values_(std::move(values)) {} : Base(source), type_(type), values_(std::move(values)) {}
TypeConstructorExpression::TypeConstructorExpression( TypeConstructorExpression::TypeConstructorExpression(
TypeConstructorExpression&&) = default; TypeConstructorExpression&&) = default;

View File

@ -25,7 +25,8 @@ namespace tint {
namespace ast { namespace ast {
/// A type specific constructor /// A type specific constructor
class TypeConstructorExpression : public ConstructorExpression { class TypeConstructorExpression
: public Castable<TypeConstructorExpression, ConstructorExpression> {
public: public:
TypeConstructorExpression(); TypeConstructorExpression();
/// Constructor /// Constructor

View File

@ -23,7 +23,7 @@ namespace ast {
constexpr const DecorationKind TypeDecoration::Kind; constexpr const DecorationKind TypeDecoration::Kind;
TypeDecoration::TypeDecoration(const Source& source) : Decoration(source) {} TypeDecoration::TypeDecoration(const Source& source) : Base(source) {}
TypeDecoration::~TypeDecoration() = default; TypeDecoration::~TypeDecoration() = default;

Some files were not shown because too many files have changed in this diff Show More