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:
parent
11c9de63aa
commit
e319d7f0e9
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind AccessDecoration::Kind;
|
||||
|
||||
AccessDecoration::AccessDecoration(AccessControl val, const Source& source)
|
||||
: TypeDecoration(source), value_(val) {}
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
AccessDecoration::~AccessDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind AccessDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool AccessDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || TypeDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool AccessDecoration::IsAccess() const {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An access decoration
|
||||
class AccessDecoration : public TypeDecoration {
|
||||
class AccessDecoration : public Castable<AccessDecoration, TypeDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kAccess;
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression() : Expression() {}
|
||||
ArrayAccessorExpression::ArrayAccessorExpression() : Base() {}
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(Expression* array,
|
||||
Expression* idx_expr)
|
||||
: Expression(), array_(array), idx_expr_(idx_expr) {}
|
||||
: Base(), array_(array), idx_expr_(idx_expr) {}
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(const Source& source,
|
||||
Expression* array,
|
||||
Expression* idx_expr)
|
||||
: Expression(source), array_(array), idx_expr_(idx_expr) {}
|
||||
: Base(source), array_(array), idx_expr_(idx_expr) {}
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(ArrayAccessorExpression&&) =
|
||||
default;
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An array accessor expression
|
||||
class ArrayAccessorExpression : public Expression {
|
||||
class ArrayAccessorExpression
|
||||
: public Castable<ArrayAccessorExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
ArrayAccessorExpression();
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace ast {
|
|||
|
||||
constexpr const DecorationKind ArrayDecoration::Kind;
|
||||
|
||||
ArrayDecoration::ArrayDecoration(const Source& source) : Decoration(source) {}
|
||||
ArrayDecoration::ArrayDecoration(const Source& source) : Base(source) {}
|
||||
|
||||
ArrayDecoration::~ArrayDecoration() = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace ast {
|
|||
class StrideDecoration;
|
||||
|
||||
/// A decoration attached to an array
|
||||
class ArrayDecoration : public Decoration {
|
||||
class ArrayDecoration : public Castable<ArrayDecoration, Decoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kArray;
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
AssignmentStatement::AssignmentStatement() : Statement() {}
|
||||
AssignmentStatement::AssignmentStatement() : Base() {}
|
||||
|
||||
AssignmentStatement::AssignmentStatement(Expression* lhs, Expression* rhs)
|
||||
: Statement(), lhs_(lhs), rhs_(rhs) {}
|
||||
: Base(), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
AssignmentStatement::AssignmentStatement(const Source& source,
|
||||
Expression* lhs,
|
||||
Expression* rhs)
|
||||
: Statement(source), lhs_(lhs), rhs_(rhs) {}
|
||||
: Base(source), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
AssignmentStatement::AssignmentStatement(AssignmentStatement&&) = default;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An assignment statement
|
||||
class AssignmentStatement : public Statement {
|
||||
class AssignmentStatement : public Castable<AssignmentStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
AssignmentStatement();
|
||||
|
|
|
@ -17,18 +17,18 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BinaryExpression::BinaryExpression() : Expression() {}
|
||||
BinaryExpression::BinaryExpression() : Base() {}
|
||||
|
||||
BinaryExpression::BinaryExpression(BinaryOp op,
|
||||
Expression* lhs,
|
||||
Expression* rhs)
|
||||
: Expression(), op_(op), lhs_(lhs), rhs_(rhs) {}
|
||||
: Base(), op_(op), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
BinaryExpression::BinaryExpression(const Source& source,
|
||||
BinaryOp op,
|
||||
Expression* lhs,
|
||||
Expression* rhs)
|
||||
: Expression(source), op_(op), lhs_(lhs), rhs_(rhs) {}
|
||||
: Base(source), op_(op), lhs_(lhs), rhs_(rhs) {}
|
||||
|
||||
BinaryExpression::BinaryExpression(BinaryExpression&&) = default;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ enum class BinaryOp {
|
|||
};
|
||||
|
||||
/// An binary expression
|
||||
class BinaryExpression : public Expression {
|
||||
class BinaryExpression : public Castable<BinaryExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
BinaryExpression();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind BindingDecoration::Kind;
|
||||
|
||||
BindingDecoration::BindingDecoration(uint32_t val, const Source& source)
|
||||
: VariableDecoration(source), value_(val) {}
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
BindingDecoration::~BindingDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind BindingDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool BindingDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || VariableDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool BindingDecoration::IsBinding() const {
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A binding decoration
|
||||
class BindingDecoration : public VariableDecoration {
|
||||
class BindingDecoration
|
||||
: public Castable<BindingDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kBinding;
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BitcastExpression::BitcastExpression() : Expression() {}
|
||||
BitcastExpression::BitcastExpression() : Base() {}
|
||||
|
||||
BitcastExpression::BitcastExpression(type::Type* type, Expression* expr)
|
||||
: Expression(), type_(type), expr_(expr) {}
|
||||
: Base(), type_(type), expr_(expr) {}
|
||||
|
||||
BitcastExpression::BitcastExpression(const Source& source,
|
||||
type::Type* type,
|
||||
Expression* expr)
|
||||
: Expression(source), type_(type), expr_(expr) {}
|
||||
: Base(source), type_(type), expr_(expr) {}
|
||||
|
||||
BitcastExpression::BitcastExpression(BitcastExpression&&) = default;
|
||||
BitcastExpression::~BitcastExpression() = default;
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A bitcast expression
|
||||
class BitcastExpression : public Expression {
|
||||
class BitcastExpression : public Castable<BitcastExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
BitcastExpression();
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
namespace tint {
|
||||
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;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A block statement
|
||||
class BlockStatement : public Statement {
|
||||
class BlockStatement : public Castable<BlockStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
BlockStatement();
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
BoolLiteral::BoolLiteral(ast::type::Type* type, bool value)
|
||||
: Literal(type), value_(value) {}
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A boolean literal
|
||||
class BoolLiteral : public Literal {
|
||||
class BoolLiteral : public Castable<BoolLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
namespace tint {
|
||||
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;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An break statement
|
||||
class BreakStatement : public Statement {
|
||||
class BreakStatement : public Castable<BreakStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
BreakStatement();
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind BuiltinDecoration::Kind;
|
||||
|
||||
BuiltinDecoration::BuiltinDecoration(Builtin builtin, const Source& source)
|
||||
: VariableDecoration(source), builtin_(builtin) {}
|
||||
: Base(source), builtin_(builtin) {}
|
||||
|
||||
BuiltinDecoration::~BuiltinDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind BuiltinDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool BuiltinDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || VariableDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool BuiltinDecoration::IsBuiltin() const {
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A builtin decoration
|
||||
class BuiltinDecoration : public VariableDecoration {
|
||||
class BuiltinDecoration
|
||||
: public Castable<BuiltinDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kBuiltin;
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CallExpression::CallExpression() : Expression() {}
|
||||
CallExpression::CallExpression() : Base() {}
|
||||
|
||||
CallExpression::CallExpression(Expression* func, ExpressionList params)
|
||||
: Expression(), func_(func), params_(params) {}
|
||||
: Base(), func_(func), params_(params) {}
|
||||
|
||||
CallExpression::CallExpression(const Source& source,
|
||||
Expression* func,
|
||||
ExpressionList params)
|
||||
: Expression(source), func_(func), params_(params) {}
|
||||
: Base(source), func_(func), params_(params) {}
|
||||
|
||||
CallExpression::CallExpression(CallExpression&&) = default;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A call expression
|
||||
class CallExpression : public Expression {
|
||||
class CallExpression : public Castable<CallExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
CallExpression();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
namespace tint {
|
||||
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;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A call expression
|
||||
class CallStatement : public Statement {
|
||||
class CallStatement : public Castable<CallStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
CallStatement();
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CaseStatement::CaseStatement(BlockStatement* body) : Statement(), body_(body) {}
|
||||
CaseStatement::CaseStatement(BlockStatement* body) : Base(), body_(body) {}
|
||||
|
||||
CaseStatement::CaseStatement(CaseSelectorList selectors, BlockStatement* body)
|
||||
: Statement(), selectors_(selectors), body_(body) {}
|
||||
: Base(), selectors_(selectors), body_(body) {}
|
||||
|
||||
CaseStatement::CaseStatement(const Source& source,
|
||||
CaseSelectorList selectors,
|
||||
BlockStatement* body)
|
||||
: Statement(source), selectors_(selectors), body_(body) {}
|
||||
: Base(source), selectors_(selectors), body_(body) {}
|
||||
|
||||
CaseStatement::CaseStatement(CaseStatement&&) = default;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace ast {
|
|||
using CaseSelectorList = std::vector<IntLiteral*>;
|
||||
|
||||
/// A case statement
|
||||
class CaseStatement : public Statement {
|
||||
class CaseStatement : public Castable<CaseStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// Creates a default case statement
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind ConstantIdDecoration::Kind;
|
||||
|
||||
ConstantIdDecoration::ConstantIdDecoration(uint32_t val, const Source& source)
|
||||
: VariableDecoration(source), value_(val) {}
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
ConstantIdDecoration::~ConstantIdDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind ConstantIdDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool ConstantIdDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || VariableDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool ConstantIdDecoration::IsConstantId() const {
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A constant id decoration
|
||||
class ConstantIdDecoration : public VariableDecoration {
|
||||
class ConstantIdDecoration
|
||||
: public Castable<ConstantIdDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kConstantId;
|
||||
|
|
|
@ -26,8 +26,10 @@ ConstructorExpression::ConstructorExpression() = default;
|
|||
|
||||
ConstructorExpression::~ConstructorExpression() = default;
|
||||
|
||||
ConstructorExpression::ConstructorExpression(ConstructorExpression&&) = default;
|
||||
|
||||
ConstructorExpression::ConstructorExpression(const Source& source)
|
||||
: Expression(source) {}
|
||||
: Base(source) {}
|
||||
|
||||
bool ConstructorExpression::IsConstructor() const {
|
||||
return true;
|
||||
|
|
|
@ -24,7 +24,8 @@ class ScalarConstructorExpression;
|
|||
class TypeConstructorExpression;
|
||||
|
||||
/// Base class for constructor style expressions
|
||||
class ConstructorExpression : public Expression {
|
||||
class ConstructorExpression
|
||||
: public Castable<ConstructorExpression, Expression> {
|
||||
public:
|
||||
~ConstructorExpression() override;
|
||||
|
||||
|
@ -48,7 +49,7 @@ class ConstructorExpression : public Expression {
|
|||
/// @param source the constructor source
|
||||
explicit ConstructorExpression(const Source& source);
|
||||
/// Move constructor
|
||||
ConstructorExpression(ConstructorExpression&&) = default;
|
||||
ConstructorExpression(ConstructorExpression&&);
|
||||
|
||||
private:
|
||||
ConstructorExpression(const ConstructorExpression&) = delete;
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ContinueStatement::ContinueStatement() : Statement() {}
|
||||
ContinueStatement::ContinueStatement() : Base() {}
|
||||
|
||||
ContinueStatement::ContinueStatement(const Source& source)
|
||||
: Statement(source) {}
|
||||
ContinueStatement::ContinueStatement(const Source& source) : Base(source) {}
|
||||
|
||||
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An continue statement
|
||||
class ContinueStatement : public Statement {
|
||||
class ContinueStatement : public Castable<ContinueStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
ContinueStatement();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace ast {
|
|||
DecoratedVariable::DecoratedVariable() = default;
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A Decorated Variable statement.
|
||||
class DecoratedVariable : public Variable {
|
||||
class DecoratedVariable : public Castable<DecoratedVariable, Variable> {
|
||||
public:
|
||||
/// Create a new empty decorated variable statement
|
||||
DecoratedVariable();
|
||||
|
|
|
@ -47,7 +47,7 @@ enum class DecorationKind {
|
|||
std::ostream& operator<<(std::ostream& out, DecorationKind data);
|
||||
|
||||
/// The base class for all decorations
|
||||
class Decoration : public Node {
|
||||
class Decoration : public Castable<Decoration, Node> {
|
||||
public:
|
||||
~Decoration() override;
|
||||
|
||||
|
@ -59,19 +59,13 @@ class Decoration : public Node {
|
|||
/// kind.
|
||||
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
|
||||
bool IsValid() const override;
|
||||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @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|.
|
||||
|
|
|
@ -57,7 +57,7 @@ TEST_F(DecorationTest, AsIncorrectType) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationTest, Is) {
|
||||
auto* decoration = create<ConstantIdDecoration>(1, Source{});
|
||||
Decoration* decoration = create<ConstantIdDecoration>(1, Source{});
|
||||
EXPECT_TRUE(decoration->Is<VariableDecoration>());
|
||||
EXPECT_FALSE(decoration->Is<ArrayDecoration>());
|
||||
}
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
namespace tint {
|
||||
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;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A discard statement
|
||||
class DiscardStatement : public Statement {
|
||||
class DiscardStatement : public Castable<DiscardStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
DiscardStatement();
|
||||
|
@ -29,7 +29,7 @@ class DiscardStatement : public Statement {
|
|||
/// @param source the discard statement source
|
||||
explicit DiscardStatement(const Source& source);
|
||||
/// Move constructor
|
||||
DiscardStatement(DiscardStatement&&) = default;
|
||||
DiscardStatement(DiscardStatement&&);
|
||||
~DiscardStatement() override;
|
||||
|
||||
/// @returns true if this is a discard statement
|
||||
|
|
|
@ -17,18 +17,18 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ElseStatement::ElseStatement(BlockStatement* body) : Statement(), body_(body) {}
|
||||
ElseStatement::ElseStatement(BlockStatement* body) : Base(), body_(body) {}
|
||||
|
||||
ElseStatement::ElseStatement(Expression* condition, BlockStatement* body)
|
||||
: Statement(), condition_(condition), body_(body) {}
|
||||
: Base(), condition_(condition), body_(body) {}
|
||||
|
||||
ElseStatement::ElseStatement(const Source& source, BlockStatement* body)
|
||||
: Statement(source), body_(body) {}
|
||||
: Base(source), body_(body) {}
|
||||
|
||||
ElseStatement::ElseStatement(const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body)
|
||||
: Statement(source), condition_(condition), body_(body) {}
|
||||
: Base(source), condition_(condition), body_(body) {}
|
||||
|
||||
ElseStatement::ElseStatement(ElseStatement&&) = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An else statement
|
||||
class ElseStatement : public Statement {
|
||||
class ElseStatement : public Castable<ElseStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param body the else body
|
||||
|
|
|
@ -31,7 +31,9 @@ namespace ast {
|
|||
|
||||
Expression::Expression() = default;
|
||||
|
||||
Expression::Expression(const Source& source) : Node(source) {}
|
||||
Expression::Expression(const Source& source) : Base(source) {}
|
||||
|
||||
Expression::Expression(Expression&&) = default;
|
||||
|
||||
Expression::~Expression() = default;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class MemberAccessorExpression;
|
|||
class UnaryOpExpression;
|
||||
|
||||
/// Base expression class
|
||||
class Expression : public Node {
|
||||
class Expression : public Castable<Expression, Node> {
|
||||
public:
|
||||
~Expression() override;
|
||||
|
||||
|
@ -109,7 +109,7 @@ class Expression : public Node {
|
|||
/// @param source the source of the expression
|
||||
explicit Expression(const Source& source);
|
||||
/// Move constructor
|
||||
Expression(Expression&&) = default;
|
||||
Expression(Expression&&);
|
||||
|
||||
private:
|
||||
Expression(const Expression&) = delete;
|
||||
|
|
|
@ -17,10 +17,12 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
FallthroughStatement::FallthroughStatement() : Statement() {}
|
||||
FallthroughStatement::FallthroughStatement() : Base() {}
|
||||
|
||||
FallthroughStatement::FallthroughStatement(const Source& source)
|
||||
: Statement(source) {}
|
||||
: Base(source) {}
|
||||
|
||||
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
|
||||
|
||||
FallthroughStatement::~FallthroughStatement() = default;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An fallthrough statement
|
||||
class FallthroughStatement : public Statement {
|
||||
class FallthroughStatement : public Castable<FallthroughStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
FallthroughStatement();
|
||||
|
@ -29,7 +29,7 @@ class FallthroughStatement : public Statement {
|
|||
/// @param source the source information
|
||||
explicit FallthroughStatement(const Source& source);
|
||||
/// Move constructor
|
||||
FallthroughStatement(FallthroughStatement&&) = default;
|
||||
FallthroughStatement(FallthroughStatement&&);
|
||||
~FallthroughStatement() override;
|
||||
|
||||
/// @returns true if this is an fallthrough statement
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
FloatLiteral::FloatLiteral(ast::type::Type* type, float value)
|
||||
: Literal(type), value_(value) {}
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A float literal
|
||||
class FloatLiteral : public Literal {
|
||||
class FloatLiteral : public Castable<FloatLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param type the type of the literal
|
||||
|
|
|
@ -32,7 +32,7 @@ Function::Function(const std::string& name,
|
|||
VariableList params,
|
||||
type::Type* return_type,
|
||||
BlockStatement* body)
|
||||
: Node(),
|
||||
: Base(),
|
||||
name_(name),
|
||||
params_(std::move(params)),
|
||||
return_type_(return_type),
|
||||
|
@ -43,7 +43,7 @@ Function::Function(const Source& source,
|
|||
VariableList params,
|
||||
type::Type* return_type,
|
||||
BlockStatement* body)
|
||||
: Node(source),
|
||||
: Base(source),
|
||||
name_(name),
|
||||
params_(std::move(params)),
|
||||
return_type_(return_type),
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A Function statement.
|
||||
class Function : public Node {
|
||||
class Function : public Castable<Function, Node> {
|
||||
public:
|
||||
/// Information about a binding
|
||||
struct BindingInfo {
|
||||
|
|
|
@ -24,8 +24,7 @@ namespace ast {
|
|||
|
||||
constexpr const DecorationKind FunctionDecoration::Kind;
|
||||
|
||||
FunctionDecoration::FunctionDecoration(const Source& source)
|
||||
: Decoration(source) {}
|
||||
FunctionDecoration::FunctionDecoration(const Source& source) : Base(source) {}
|
||||
|
||||
FunctionDecoration::~FunctionDecoration() = default;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class StageDecoration;
|
|||
class WorkgroupDecoration;
|
||||
|
||||
/// A decoration attached to a function
|
||||
class FunctionDecoration : public Decoration {
|
||||
class FunctionDecoration : public Castable<FunctionDecoration, Decoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kFunction;
|
||||
|
|
|
@ -18,11 +18,11 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
IdentifierExpression::IdentifierExpression(const std::string& name)
|
||||
: Expression(), name_(name) {}
|
||||
: Base(), name_(name) {}
|
||||
|
||||
IdentifierExpression::IdentifierExpression(const Source& source,
|
||||
const std::string& name)
|
||||
: Expression(source), name_(name) {}
|
||||
: Base(source), name_(name) {}
|
||||
|
||||
IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An identifier expression
|
||||
class IdentifierExpression : public Expression {
|
||||
class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param name the name
|
||||
|
|
|
@ -20,12 +20,12 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
IfStatement::IfStatement(Expression* condition, BlockStatement* body)
|
||||
: Statement(), condition_(condition), body_(body) {}
|
||||
: Base(), condition_(condition), body_(body) {}
|
||||
|
||||
IfStatement::IfStatement(const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body)
|
||||
: Statement(source), condition_(condition), body_(body) {}
|
||||
: Base(source), condition_(condition), body_(body) {}
|
||||
|
||||
IfStatement::IfStatement(IfStatement&&) = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An if statement
|
||||
class IfStatement : public Statement {
|
||||
class IfStatement : public Castable<IfStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param condition the if condition
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IntLiteral::IntLiteral(ast::type::Type* type) : Literal(type) {}
|
||||
IntLiteral::IntLiteral(ast::type::Type* type) : Base(type) {}
|
||||
|
||||
IntLiteral::~IntLiteral() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// An integer literal. This could be either signed or unsigned.
|
||||
class IntLiteral : public Literal {
|
||||
class IntLiteral : public Castable<IntLiteral, Literal> {
|
||||
public:
|
||||
~IntLiteral() override;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class IntLiteral;
|
|||
class UintLiteral;
|
||||
|
||||
/// Base class for a literal value
|
||||
class Literal : public Node {
|
||||
class Literal : public Castable<Literal, Node> {
|
||||
public:
|
||||
~Literal() override;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind LocationDecoration::Kind;
|
||||
|
||||
LocationDecoration::LocationDecoration(uint32_t val, const Source& source)
|
||||
: VariableDecoration(source), value_(val) {}
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
LocationDecoration::~LocationDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind LocationDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool LocationDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || VariableDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool LocationDecoration::IsLocation() const {
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A location decoration
|
||||
class LocationDecoration : public VariableDecoration {
|
||||
class LocationDecoration
|
||||
: public Castable<LocationDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kLocation;
|
||||
|
|
|
@ -18,12 +18,12 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
LoopStatement::LoopStatement(BlockStatement* body, BlockStatement* continuing)
|
||||
: Statement(), body_(body), continuing_(continuing) {}
|
||||
: Base(), body_(body), continuing_(continuing) {}
|
||||
|
||||
LoopStatement::LoopStatement(const Source& source,
|
||||
BlockStatement* body,
|
||||
BlockStatement* continuing)
|
||||
: Statement(source), body_(body), continuing_(continuing) {}
|
||||
: Base(source), body_(body), continuing_(continuing) {}
|
||||
|
||||
LoopStatement::LoopStatement(LoopStatement&&) = default;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A loop statement
|
||||
class LoopStatement : public Statement {
|
||||
class LoopStatement : public Castable<LoopStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param body the body statements
|
||||
|
|
|
@ -21,12 +21,12 @@ MemberAccessorExpression::MemberAccessorExpression() = default;
|
|||
|
||||
MemberAccessorExpression::MemberAccessorExpression(Expression* structure,
|
||||
IdentifierExpression* member)
|
||||
: Expression(), struct_(structure), member_(member) {}
|
||||
: Base(), struct_(structure), member_(member) {}
|
||||
|
||||
MemberAccessorExpression::MemberAccessorExpression(const Source& source,
|
||||
Expression* structure,
|
||||
IdentifierExpression* member)
|
||||
: Expression(source), struct_(structure), member_(member) {}
|
||||
: Base(source), struct_(structure), member_(member) {}
|
||||
|
||||
MemberAccessorExpression::MemberAccessorExpression(MemberAccessorExpression&&) =
|
||||
default;
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A member accessor expression
|
||||
class MemberAccessorExpression : public Expression {
|
||||
class MemberAccessorExpression
|
||||
: public Castable<MemberAccessorExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
MemberAccessorExpression();
|
||||
|
|
|
@ -23,6 +23,8 @@ Node::Node() = default;
|
|||
|
||||
Node::Node(const Source& source) : source_(source) {}
|
||||
|
||||
Node::Node(Node&&) = default;
|
||||
|
||||
Node::~Node() = default;
|
||||
|
||||
void Node::make_indent(std::ostream& out, size_t indent) const {
|
||||
|
|
|
@ -18,15 +18,16 @@
|
|||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "src/castable.h"
|
||||
#include "src/source.h"
|
||||
|
||||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
/// AST base class node
|
||||
class Node {
|
||||
class Node : public Castable<Node> {
|
||||
public:
|
||||
virtual ~Node();
|
||||
~Node() override;
|
||||
|
||||
/// @returns the node source data
|
||||
const Source& source() const { return source_; }
|
||||
|
@ -53,7 +54,7 @@ class Node {
|
|||
/// @param source The input source for the node
|
||||
explicit Node(const Source& source);
|
||||
/// Move constructor
|
||||
Node(Node&&) = default;
|
||||
Node(Node&&);
|
||||
|
||||
/// Writes indent into stream
|
||||
/// @param out the stream to write to
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
NullLiteral::NullLiteral(ast::type::Type* type) : Literal(type) {}
|
||||
NullLiteral::NullLiteral(ast::type::Type* type) : Base(type) {}
|
||||
|
||||
NullLiteral::~NullLiteral() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A null literal
|
||||
class NullLiteral : public Literal {
|
||||
class NullLiteral : public Castable<NullLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param type the type
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
namespace tint {
|
||||
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)
|
||||
: Statement(), value_(value) {}
|
||||
ReturnStatement::ReturnStatement(Expression* value) : Base(), value_(value) {}
|
||||
|
||||
ReturnStatement::ReturnStatement(const Source& source, Expression* value)
|
||||
: Statement(source), value_(value) {}
|
||||
: Base(source), value_(value) {}
|
||||
|
||||
ReturnStatement::ReturnStatement(ReturnStatement&&) = default;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A return statement
|
||||
class ReturnStatement : public Statement {
|
||||
class ReturnStatement : public Castable<ReturnStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
ReturnStatement();
|
||||
|
|
|
@ -17,15 +17,14 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression()
|
||||
: ConstructorExpression() {}
|
||||
ScalarConstructorExpression::ScalarConstructorExpression() : Base() {}
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(Literal* literal)
|
||||
: literal_(literal) {}
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(const Source& source,
|
||||
Literal* litearl)
|
||||
: ConstructorExpression(source), literal_(litearl) {}
|
||||
: Base(source), literal_(litearl) {}
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(
|
||||
ScalarConstructorExpression&&) = default;
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A scalar constructor
|
||||
class ScalarConstructorExpression : public ConstructorExpression {
|
||||
class ScalarConstructorExpression
|
||||
: public Castable<ScalarConstructorExpression, ConstructorExpression> {
|
||||
public:
|
||||
/// Constructor
|
||||
ScalarConstructorExpression();
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
SetDecoration::SetDecoration(uint32_t val, const Source& source)
|
||||
: VariableDecoration(source), value_(val) {}
|
||||
: Base(source), value_(val) {}
|
||||
|
||||
SetDecoration::~SetDecoration() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A set decoration
|
||||
class SetDecoration : public VariableDecoration {
|
||||
class SetDecoration : public Castable<SetDecoration, VariableDecoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param value the set value
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
SintLiteral::SintLiteral(ast::type::Type* type, int32_t value)
|
||||
: IntLiteral(type), value_(value) {}
|
||||
: Base(type), value_(value) {}
|
||||
|
||||
SintLiteral::~SintLiteral() = default;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A signed int literal
|
||||
class SintLiteral : public IntLiteral {
|
||||
class SintLiteral : public Castable<SintLiteral, IntLiteral> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param type the type
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace ast {
|
|||
constexpr const DecorationKind StageDecoration::Kind;
|
||||
|
||||
StageDecoration::StageDecoration(ast::PipelineStage stage, const Source& source)
|
||||
: FunctionDecoration(source), stage_(stage) {}
|
||||
: Base(source), stage_(stage) {}
|
||||
|
||||
StageDecoration::~StageDecoration() = default;
|
||||
|
||||
|
@ -29,7 +29,7 @@ DecorationKind StageDecoration::GetKind() const {
|
|||
}
|
||||
|
||||
bool StageDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || FunctionDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool StageDecoration::IsStage() const {
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A workgroup decoration
|
||||
class StageDecoration : public FunctionDecoration {
|
||||
class StageDecoration : public Castable<StageDecoration, FunctionDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kStage;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace ast {
|
|||
|
||||
Statement::Statement() = default;
|
||||
|
||||
Statement::Statement(const Source& source) : Node(source) {}
|
||||
Statement::Statement(const Source& source) : Base(source) {}
|
||||
|
||||
Statement::Statement(Statement&&) = default;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class SwitchStatement;
|
|||
class VariableDeclStatement;
|
||||
|
||||
/// Base statement class
|
||||
class Statement : public Node {
|
||||
class Statement : public Castable<Statement, Node> {
|
||||
public:
|
||||
~Statement() override;
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ namespace ast {
|
|||
constexpr const DecorationKind StrideDecoration::Kind;
|
||||
|
||||
StrideDecoration::StrideDecoration(uint32_t stride, const Source& source)
|
||||
: ArrayDecoration(source), stride_(stride) {}
|
||||
: Base(source), stride_(stride) {}
|
||||
|
||||
DecorationKind StrideDecoration::GetKind() const {
|
||||
return Kind;
|
||||
}
|
||||
|
||||
bool StrideDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || ArrayDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool StrideDecoration::IsStride() const {
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A stride decoration
|
||||
class StrideDecoration : public ArrayDecoration {
|
||||
class StrideDecoration : public Castable<StrideDecoration, ArrayDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kStride;
|
||||
|
|
|
@ -17,23 +17,23 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Struct::Struct() : Node() {}
|
||||
Struct::Struct() : Base() {}
|
||||
|
||||
Struct::Struct(StructMemberList members)
|
||||
: Node(), members_(std::move(members)) {}
|
||||
: Base(), members_(std::move(members)) {}
|
||||
|
||||
Struct::Struct(StructDecorationList decorations, StructMemberList members)
|
||||
: Node(),
|
||||
: Base(),
|
||||
decorations_(std::move(decorations)),
|
||||
members_(std::move(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,
|
||||
StructDecorationList decorations,
|
||||
StructMemberList members)
|
||||
: Node(source),
|
||||
: Base(source),
|
||||
decorations_(std::move(decorations)),
|
||||
members_(std::move(members)) {}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A struct statement.
|
||||
class Struct : public Node {
|
||||
class Struct : public Castable<Struct, Node> {
|
||||
public:
|
||||
/// Create a new empty struct statement
|
||||
Struct();
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
StructBlockDecoration::StructBlockDecoration(const Source& source)
|
||||
: StructDecoration(source) {}
|
||||
: Base(source) {}
|
||||
|
||||
StructBlockDecoration::~StructBlockDecoration() = default;
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// The struct decorations
|
||||
class StructBlockDecoration : public StructDecoration {
|
||||
class StructBlockDecoration
|
||||
: public Castable<StructBlockDecoration, StructDecoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param source the source of this decoration
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace ast {
|
|||
|
||||
constexpr const DecorationKind StructDecoration::Kind;
|
||||
|
||||
StructDecoration::StructDecoration(const Source& source) : Decoration(source) {}
|
||||
StructDecoration::StructDecoration(const Source& source) : Base(source) {}
|
||||
|
||||
StructDecoration::~StructDecoration() = default;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// The struct decorations
|
||||
class StructDecoration : public Decoration {
|
||||
class StructDecoration : public Castable<StructDecoration, Decoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kStruct;
|
||||
|
|
|
@ -24,13 +24,13 @@ StructMember::StructMember() = default;
|
|||
StructMember::StructMember(const std::string& name,
|
||||
type::Type* type,
|
||||
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,
|
||||
const std::string& name,
|
||||
type::Type* type,
|
||||
StructMemberDecorationList decorations)
|
||||
: Node(source),
|
||||
: Base(source),
|
||||
name_(name),
|
||||
type_(type),
|
||||
decorations_(std::move(decorations)) {}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A struct member statement.
|
||||
class StructMember : public Node {
|
||||
class StructMember : public Castable<StructMember, Node> {
|
||||
public:
|
||||
/// Create a new empty struct member statement
|
||||
StructMember();
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace ast {
|
|||
constexpr const DecorationKind StructMemberDecoration::Kind;
|
||||
|
||||
StructMemberDecoration::StructMemberDecoration(const Source& source)
|
||||
: Decoration(source) {}
|
||||
: Base(source) {}
|
||||
|
||||
StructMemberDecoration::~StructMemberDecoration() = default;
|
||||
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace ast {
|
|||
class StructMemberOffsetDecoration;
|
||||
|
||||
/// A decoration attached to a struct member
|
||||
class StructMemberDecoration : public Decoration {
|
||||
class StructMemberDecoration
|
||||
: public Castable<StructMemberDecoration, Decoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind = DecorationKind::kStructMember;
|
||||
|
|
|
@ -21,14 +21,14 @@ constexpr const DecorationKind StructMemberOffsetDecoration::Kind;
|
|||
|
||||
StructMemberOffsetDecoration::StructMemberOffsetDecoration(uint32_t offset,
|
||||
const Source& source)
|
||||
: StructMemberDecoration(source), offset_(offset) {}
|
||||
: Base(source), offset_(offset) {}
|
||||
|
||||
DecorationKind StructMemberOffsetDecoration::GetKind() const {
|
||||
return Kind;
|
||||
}
|
||||
|
||||
bool StructMemberOffsetDecoration::IsKind(DecorationKind kind) const {
|
||||
return kind == Kind || StructMemberDecoration::IsKind(kind);
|
||||
return kind == Kind || Base::IsKind(kind);
|
||||
}
|
||||
|
||||
bool StructMemberOffsetDecoration::IsOffset() const {
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A struct member offset decoration
|
||||
class StructMemberOffsetDecoration : public StructMemberDecoration {
|
||||
class StructMemberOffsetDecoration
|
||||
: public Castable<StructMemberOffsetDecoration, StructMemberDecoration> {
|
||||
public:
|
||||
/// The kind of decoration that this type represents
|
||||
static constexpr const DecorationKind Kind =
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SwitchStatement::SwitchStatement() : Statement() {}
|
||||
SwitchStatement::SwitchStatement() : Base() {}
|
||||
|
||||
SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body)
|
||||
: condition_(condition), body_(body) {}
|
||||
|
@ -27,7 +27,7 @@ SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body)
|
|||
SwitchStatement::SwitchStatement(const Source& source,
|
||||
Expression* condition,
|
||||
CaseStatementList body)
|
||||
: Statement(source), condition_(condition), body_(body) {}
|
||||
: Base(source), condition_(condition), body_(body) {}
|
||||
|
||||
bool SwitchStatement::IsSwitch() const {
|
||||
return true;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A switch statement
|
||||
class SwitchStatement : public Statement {
|
||||
class SwitchStatement : public Castable<SwitchStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
SwitchStatement();
|
||||
|
|
|
@ -17,17 +17,16 @@
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
TypeConstructorExpression::TypeConstructorExpression()
|
||||
: ConstructorExpression() {}
|
||||
TypeConstructorExpression::TypeConstructorExpression() : Base() {}
|
||||
|
||||
TypeConstructorExpression::TypeConstructorExpression(type::Type* type,
|
||||
ExpressionList values)
|
||||
: ConstructorExpression(), type_(type), values_(std::move(values)) {}
|
||||
: Base(), type_(type), values_(std::move(values)) {}
|
||||
|
||||
TypeConstructorExpression::TypeConstructorExpression(const Source& source,
|
||||
type::Type* type,
|
||||
ExpressionList values)
|
||||
: ConstructorExpression(source), type_(type), values_(std::move(values)) {}
|
||||
: Base(source), type_(type), values_(std::move(values)) {}
|
||||
|
||||
TypeConstructorExpression::TypeConstructorExpression(
|
||||
TypeConstructorExpression&&) = default;
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
/// A type specific constructor
|
||||
class TypeConstructorExpression : public ConstructorExpression {
|
||||
class TypeConstructorExpression
|
||||
: public Castable<TypeConstructorExpression, ConstructorExpression> {
|
||||
public:
|
||||
TypeConstructorExpression();
|
||||
/// Constructor
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace ast {
|
|||
|
||||
constexpr const DecorationKind TypeDecoration::Kind;
|
||||
|
||||
TypeDecoration::TypeDecoration(const Source& source) : Decoration(source) {}
|
||||
TypeDecoration::TypeDecoration(const Source& source) : Base(source) {}
|
||||
|
||||
TypeDecoration::~TypeDecoration() = default;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue