Add ProgramID feed it into all ast::Nodes
This will be used to detect accidental leaks of program objects between programs. Bug: tint:709 Change-Id: I20f784a2c673d19a04a880b3ec91dfe2eb743bdb Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47622 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
f01ed13a25
commit
e6995de232
|
@ -362,6 +362,8 @@ source_set("libtint_core_src") {
|
|||
"inspector/scalar.h",
|
||||
"intrinsic_table.cc",
|
||||
"intrinsic_table.h",
|
||||
"program_id.cc",
|
||||
"program_id.h",
|
||||
"program.cc",
|
||||
"program.h",
|
||||
"program_builder.cc",
|
||||
|
|
|
@ -179,6 +179,8 @@ set(TINT_LIB_SRCS
|
|||
inspector/scalar.h
|
||||
program_builder.cc
|
||||
program_builder.h
|
||||
program_id.cc
|
||||
program_id.h
|
||||
program.cc
|
||||
program.h
|
||||
reader/reader.cc
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::AccessDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
AccessDecoration::AccessDecoration(const Source& source, AccessControl val)
|
||||
: Base(source), value_(val) {}
|
||||
AccessDecoration::AccessDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
AccessControl val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
AccessDecoration::~AccessDecoration() = default;
|
||||
|
||||
|
|
|
@ -25,9 +25,12 @@ namespace ast {
|
|||
class AccessDecoration : public Castable<AccessDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param value the access value
|
||||
explicit AccessDecoration(const Source& source, AccessControl value);
|
||||
AccessDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
AccessControl value);
|
||||
~AccessDecoration() override;
|
||||
|
||||
/// @returns the access control value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ArrayAccessorExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(const Source& source,
|
||||
ArrayAccessorExpression::ArrayAccessorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* array,
|
||||
Expression* idx_expr)
|
||||
: Base(source), array_(array), idx_expr_(idx_expr) {
|
||||
: Base(program_id, source), array_(array), idx_expr_(idx_expr) {
|
||||
TINT_ASSERT(array_);
|
||||
TINT_ASSERT(idx_expr_);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,12 @@ class ArrayAccessorExpression
|
|||
: public Castable<ArrayAccessorExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the array accessor source
|
||||
/// @param array the array
|
||||
/// @param idx_expr the index expression
|
||||
ArrayAccessorExpression(const Source& source,
|
||||
ArrayAccessorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* array,
|
||||
Expression* idx_expr);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::AssignmentStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
AssignmentStatement::AssignmentStatement(const Source& source,
|
||||
AssignmentStatement::AssignmentStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* lhs,
|
||||
Expression* rhs)
|
||||
: Base(source), lhs_(lhs), rhs_(rhs) {
|
||||
: Base(program_id, source), lhs_(lhs), rhs_(rhs) {
|
||||
TINT_ASSERT(lhs_);
|
||||
TINT_ASSERT(rhs_);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,14 @@ namespace ast {
|
|||
class AssignmentStatement : public Castable<AssignmentStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the assignment statement source
|
||||
/// @param lhs the left side of the expression
|
||||
/// @param rhs the right side of the expression
|
||||
AssignmentStatement(const Source& source, Expression* lhs, Expression* rhs);
|
||||
AssignmentStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* lhs,
|
||||
Expression* rhs);
|
||||
/// Move constructor
|
||||
AssignmentStatement(AssignmentStatement&&);
|
||||
~AssignmentStatement() override;
|
||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BinaryExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BinaryExpression::BinaryExpression(const Source& source,
|
||||
BinaryExpression::BinaryExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
BinaryOp op,
|
||||
Expression* lhs,
|
||||
Expression* rhs)
|
||||
: Base(source), op_(op), lhs_(lhs), rhs_(rhs) {
|
||||
: Base(program_id, source), op_(op), lhs_(lhs), rhs_(rhs) {
|
||||
TINT_ASSERT(lhs_);
|
||||
TINT_ASSERT(rhs_);
|
||||
TINT_ASSERT(op_ != BinaryOp::kNone);
|
||||
|
|
|
@ -47,11 +47,13 @@ enum class BinaryOp {
|
|||
class BinaryExpression : public Castable<BinaryExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the binary expression source
|
||||
/// @param op the operation type
|
||||
/// @param lhs the left side of the expression
|
||||
/// @param rhs the right side of the expression
|
||||
BinaryExpression(const Source& source,
|
||||
BinaryExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
BinaryOp op,
|
||||
Expression* lhs,
|
||||
Expression* rhs);
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BindingDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BindingDecoration::BindingDecoration(const Source& source, uint32_t val)
|
||||
: Base(source), value_(val) {}
|
||||
BindingDecoration::BindingDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
BindingDecoration::~BindingDecoration() = default;
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ namespace ast {
|
|||
class BindingDecoration : public Castable<BindingDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param value the binding value
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
BindingDecoration(const Source& source, uint32_t value);
|
||||
/// @param value the binding value
|
||||
BindingDecoration(ProgramID program_id, const Source& source, uint32_t value);
|
||||
~BindingDecoration() override;
|
||||
|
||||
/// @returns the binding value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BitcastExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BitcastExpression::BitcastExpression(const Source& source,
|
||||
BitcastExpression::BitcastExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
Expression* expr)
|
||||
: Base(source), type_(type), expr_(expr) {
|
||||
: Base(program_id, source), type_(type), expr_(expr) {
|
||||
TINT_ASSERT(type_);
|
||||
TINT_ASSERT(expr_);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,14 @@ namespace ast {
|
|||
class BitcastExpression : public Castable<BitcastExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the bitcast expression source
|
||||
/// @param type the type
|
||||
/// @param expr the expr
|
||||
BitcastExpression(const Source& source, type::Type* type, Expression* expr);
|
||||
BitcastExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
Expression* expr);
|
||||
/// Move constructor
|
||||
BitcastExpression(BitcastExpression&&);
|
||||
~BitcastExpression() override;
|
||||
|
|
|
@ -21,9 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BlockStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BlockStatement::BlockStatement(const Source& source,
|
||||
BlockStatement::BlockStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
const StatementList& statements)
|
||||
: Base(source), statements_(std::move(statements)) {
|
||||
: Base(program_id, source), statements_(std::move(statements)) {
|
||||
for (auto* stmt : *this) {
|
||||
TINT_ASSERT(stmt);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,12 @@ namespace ast {
|
|||
class BlockStatement : public Castable<BlockStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the block statement source
|
||||
/// @param statements the statements
|
||||
BlockStatement(const Source& source, const StatementList& statements);
|
||||
BlockStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
const StatementList& statements);
|
||||
/// Move constructor
|
||||
BlockStatement(BlockStatement&&);
|
||||
~BlockStatement() override;
|
||||
|
|
|
@ -21,8 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BoolLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BoolLiteral::BoolLiteral(const Source& source, type::Type* type, bool value)
|
||||
: Base(source, type), value_(value) {}
|
||||
BoolLiteral::BoolLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
bool value)
|
||||
: Base(program_id, source, type), value_(value) {}
|
||||
|
||||
BoolLiteral::~BoolLiteral() = default;
|
||||
|
||||
|
|
|
@ -26,10 +26,14 @@ namespace ast {
|
|||
class BoolLiteral : public Castable<BoolLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the bool literals value
|
||||
BoolLiteral(const Source& source, type::Type* type, bool value);
|
||||
BoolLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
bool value);
|
||||
~BoolLiteral() override;
|
||||
|
||||
/// @returns true if the bool literal is true
|
||||
|
|
|
@ -21,7 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BreakStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BreakStatement::BreakStatement(const Source& source) : Base(source) {}
|
||||
BreakStatement::BreakStatement(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
BreakStatement::BreakStatement(BreakStatement&&) = default;
|
||||
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace ast {
|
|||
class BreakStatement : public Castable<BreakStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the break statement source
|
||||
explicit BreakStatement(const Source& source);
|
||||
BreakStatement(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
BreakStatement(BreakStatement&&);
|
||||
~BreakStatement() override;
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BuiltinDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
BuiltinDecoration::BuiltinDecoration(const Source& source, Builtin builtin)
|
||||
: Base(source), builtin_(builtin) {}
|
||||
BuiltinDecoration::BuiltinDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
Builtin builtin)
|
||||
: Base(program_id, source), builtin_(builtin) {}
|
||||
|
||||
BuiltinDecoration::~BuiltinDecoration() = default;
|
||||
|
||||
|
|
|
@ -25,9 +25,12 @@ namespace ast {
|
|||
class BuiltinDecoration : public Castable<BuiltinDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param builtin the builtin value
|
||||
BuiltinDecoration(const Source& source, Builtin builtin);
|
||||
BuiltinDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
Builtin builtin);
|
||||
~BuiltinDecoration() override;
|
||||
|
||||
/// @returns the builtin value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CallExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CallExpression::CallExpression(const Source& source,
|
||||
CallExpression::CallExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* func,
|
||||
ExpressionList params)
|
||||
: Base(source), func_(func), params_(params) {
|
||||
: Base(program_id, source), func_(func), params_(params) {
|
||||
TINT_ASSERT(func_);
|
||||
for (auto* param : params_) {
|
||||
TINT_ASSERT(param);
|
||||
|
|
|
@ -24,10 +24,14 @@ namespace ast {
|
|||
class CallExpression : public Castable<CallExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the call expression source
|
||||
/// @param func the function
|
||||
/// @param params the parameters
|
||||
CallExpression(const Source& source, Expression* func, ExpressionList params);
|
||||
CallExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* func,
|
||||
ExpressionList params);
|
||||
/// Move constructor
|
||||
CallExpression(CallExpression&&);
|
||||
~CallExpression() override;
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CallStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CallStatement::CallStatement(const Source& source, CallExpression* call)
|
||||
: Base(source), call_(call) {
|
||||
CallStatement::CallStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
CallExpression* call)
|
||||
: Base(program_id, source), call_(call) {
|
||||
TINT_ASSERT(call_);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,12 @@ namespace ast {
|
|||
class CallStatement : public Castable<CallStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source for the statement
|
||||
/// @param call the function
|
||||
CallStatement(const Source& source, CallExpression* call);
|
||||
CallStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
CallExpression* call);
|
||||
/// Move constructor
|
||||
CallStatement(CallStatement&&);
|
||||
~CallStatement() override;
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CaseStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
CaseStatement::CaseStatement(const Source& source,
|
||||
CaseStatement::CaseStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
CaseSelectorList selectors,
|
||||
BlockStatement* body)
|
||||
: Base(source), selectors_(selectors), body_(body) {
|
||||
: Base(program_id, source), selectors_(selectors), body_(body) {
|
||||
TINT_ASSERT(body_);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,12 @@ using CaseSelectorList = std::vector<IntLiteral*>;
|
|||
class CaseStatement : public Castable<CaseStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
/// @param selectors the case selectors
|
||||
/// @param body the case body
|
||||
CaseStatement(const Source& source,
|
||||
CaseStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
CaseSelectorList selectors,
|
||||
BlockStatement* body);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ConstantIdDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ConstantIdDecoration::ConstantIdDecoration(const Source& source, uint32_t val)
|
||||
: Base(source), value_(val) {}
|
||||
ConstantIdDecoration::ConstantIdDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
ConstantIdDecoration::~ConstantIdDecoration() = default;
|
||||
|
||||
|
|
|
@ -24,9 +24,12 @@ namespace ast {
|
|||
class ConstantIdDecoration : public Castable<ConstantIdDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param val the constant_id value
|
||||
ConstantIdDecoration(const Source& source, uint32_t val);
|
||||
ConstantIdDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val);
|
||||
~ConstantIdDecoration() override;
|
||||
|
||||
/// @returns the constant id value
|
||||
|
|
|
@ -23,8 +23,9 @@ ConstructorExpression::~ConstructorExpression() = default;
|
|||
|
||||
ConstructorExpression::ConstructorExpression(ConstructorExpression&&) = default;
|
||||
|
||||
ConstructorExpression::ConstructorExpression(const Source& source)
|
||||
: Base(source) {}
|
||||
ConstructorExpression::ConstructorExpression(ProgramID program_id,
|
||||
const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
} // namespace ast
|
||||
} // namespace tint
|
||||
|
|
|
@ -28,8 +28,9 @@ class ConstructorExpression
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the constructor source
|
||||
explicit ConstructorExpression(const Source& source);
|
||||
ConstructorExpression(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
ConstructorExpression(ConstructorExpression&&);
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ContinueStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ContinueStatement::ContinueStatement(const Source& source) : Base(source) {}
|
||||
ContinueStatement::ContinueStatement(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
||||
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace ast {
|
|||
class ContinueStatement : public Castable<ContinueStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the continue statement source
|
||||
explicit ContinueStatement(const Source& source);
|
||||
ContinueStatement(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
ContinueStatement(ContinueStatement&&);
|
||||
~ContinueStatement() override;
|
||||
|
|
|
@ -29,8 +29,10 @@ class Decoration : public Castable<Decoration, Node> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
explicit Decoration(const Source& source) : Base(source) {}
|
||||
Decoration(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
};
|
||||
|
||||
/// A list of decorations
|
||||
|
|
|
@ -21,7 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DiscardStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
DiscardStatement::DiscardStatement(const Source& source) : Base(source) {}
|
||||
DiscardStatement::DiscardStatement(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
|
||||
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace ast {
|
|||
class DiscardStatement : public Castable<DiscardStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the discard statement source
|
||||
explicit DiscardStatement(const Source& source);
|
||||
DiscardStatement(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
DiscardStatement(DiscardStatement&&);
|
||||
~DiscardStatement() override;
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ElseStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ElseStatement::ElseStatement(const Source& source,
|
||||
ElseStatement::ElseStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body)
|
||||
: Base(source), condition_(condition), body_(body) {
|
||||
: Base(program_id, source), condition_(condition), body_(body) {
|
||||
TINT_ASSERT(body_);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,12 @@ namespace ast {
|
|||
class ElseStatement : public Castable<ElseStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
/// @param condition the else condition
|
||||
/// @param body the else body
|
||||
ElseStatement(const Source& source,
|
||||
ElseStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body);
|
||||
/// Move constructor
|
||||
|
|
|
@ -22,7 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Expression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Expression::Expression(const Source& source) : Base(source) {}
|
||||
Expression::Expression(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
Expression::Expression(Expression&&) = default;
|
||||
|
||||
|
|
|
@ -31,8 +31,9 @@ class Expression : public Castable<Expression, Node> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of the expression
|
||||
explicit Expression(const Source& source);
|
||||
Expression(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
Expression(Expression&&);
|
||||
|
||||
|
|
|
@ -21,8 +21,9 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FallthroughStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
FallthroughStatement::FallthroughStatement(const Source& source)
|
||||
: Base(source) {}
|
||||
FallthroughStatement::FallthroughStatement(ProgramID program_id,
|
||||
const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
|
||||
|
||||
|
|
|
@ -24,8 +24,9 @@ namespace ast {
|
|||
class FallthroughStatement : public Castable<FallthroughStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
explicit FallthroughStatement(const Source& source);
|
||||
FallthroughStatement(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
FallthroughStatement(FallthroughStatement&&);
|
||||
~FallthroughStatement() override;
|
||||
|
|
|
@ -23,8 +23,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FloatLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
FloatLiteral::FloatLiteral(const Source& source, type::Type* type, float value)
|
||||
: Base(source, type), value_(value) {}
|
||||
FloatLiteral::FloatLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
float value)
|
||||
: Base(program_id, source, type), value_(value) {}
|
||||
|
||||
FloatLiteral::~FloatLiteral() = default;
|
||||
|
||||
|
|
|
@ -26,10 +26,14 @@ namespace ast {
|
|||
class FloatLiteral : public Castable<FloatLiteral, Literal> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the float literals value
|
||||
FloatLiteral(const Source& source, type::Type* type, float value);
|
||||
FloatLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
float value);
|
||||
~FloatLiteral() override;
|
||||
|
||||
/// @returns the float literal value
|
||||
|
|
|
@ -23,14 +23,15 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Function);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Function::Function(const Source& source,
|
||||
Function::Function(ProgramID program_id,
|
||||
const Source& source,
|
||||
Symbol symbol,
|
||||
VariableList params,
|
||||
type::Type* return_type,
|
||||
BlockStatement* body,
|
||||
DecorationList decorations,
|
||||
DecorationList return_type_decorations)
|
||||
: Base(source),
|
||||
: Base(program_id, source),
|
||||
symbol_(symbol),
|
||||
params_(std::move(params)),
|
||||
return_type_(return_type),
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace ast {
|
|||
class Function : public Castable<Function, Node> {
|
||||
public:
|
||||
/// Create a function
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the variable source
|
||||
/// @param symbol the function symbol
|
||||
/// @param params the function parameters
|
||||
|
@ -43,7 +44,8 @@ class Function : public Castable<Function, Node> {
|
|||
/// @param body the function body
|
||||
/// @param decorations the function decorations
|
||||
/// @param return_type_decorations the return type decorations
|
||||
Function(const Source& source,
|
||||
Function(ProgramID program_id,
|
||||
const Source& source,
|
||||
Symbol symbol,
|
||||
VariableList params,
|
||||
type::Type* return_type,
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::GroupDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
GroupDecoration::GroupDecoration(const Source& source, uint32_t val)
|
||||
: Base(source), value_(val) {}
|
||||
GroupDecoration::GroupDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
GroupDecoration::~GroupDecoration() = default;
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ namespace ast {
|
|||
class GroupDecoration : public Castable<GroupDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param value the group value
|
||||
/// @param source the source of this decoration
|
||||
GroupDecoration(const Source& source, uint32_t value);
|
||||
GroupDecoration(ProgramID program_id, const Source& source, uint32_t value);
|
||||
~GroupDecoration() override;
|
||||
|
||||
/// @returns the group value
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdentifierExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IdentifierExpression::IdentifierExpression(const Source& source, Symbol sym)
|
||||
: Base(source), sym_(sym) {
|
||||
IdentifierExpression::IdentifierExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Symbol sym)
|
||||
: Base(program_id, source), sym_(sym) {
|
||||
TINT_ASSERT(sym_.IsValid());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,9 +25,10 @@ namespace ast {
|
|||
class IdentifierExpression : public Castable<IdentifierExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source
|
||||
/// @param sym the symbol for the identifier
|
||||
IdentifierExpression(const Source& source, Symbol sym);
|
||||
IdentifierExpression(ProgramID program_id, const Source& source, Symbol sym);
|
||||
/// Move constructor
|
||||
IdentifierExpression(IdentifierExpression&&);
|
||||
~IdentifierExpression() override;
|
||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IfStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IfStatement::IfStatement(const Source& source,
|
||||
IfStatement::IfStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body,
|
||||
ElseStatementList else_stmts)
|
||||
: Base(source),
|
||||
: Base(program_id, source),
|
||||
condition_(condition),
|
||||
body_(body),
|
||||
else_statements_(std::move(else_stmts)) {
|
||||
|
|
|
@ -26,11 +26,13 @@ namespace ast {
|
|||
class IfStatement : public Castable<IfStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
/// @param condition the if condition
|
||||
/// @param body the if body
|
||||
/// @param else_stmts the else statements
|
||||
IfStatement(const Source& source,
|
||||
IfStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
BlockStatement* body,
|
||||
ElseStatementList else_stmts);
|
||||
|
|
|
@ -19,8 +19,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IntLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
IntLiteral::IntLiteral(const Source& source, type::Type* type, uint32_t value)
|
||||
: Base(source, type), value_(value) {}
|
||||
IntLiteral::IntLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
uint32_t value)
|
||||
: Base(program_id, source, type), value_(value) {}
|
||||
|
||||
IntLiteral::~IntLiteral() = default;
|
||||
|
||||
|
|
|
@ -30,10 +30,14 @@ class IntLiteral : public Castable<IntLiteral, Literal> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value value of the literal
|
||||
IntLiteral(const Source& source, type::Type* type, uint32_t value);
|
||||
IntLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
uint32_t value);
|
||||
|
||||
private:
|
||||
uint32_t const value_;
|
||||
|
|
|
@ -19,7 +19,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InternalDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
InternalDecoration::InternalDecoration() : Base(Source{}) {}
|
||||
InternalDecoration::InternalDecoration(ProgramID program_id)
|
||||
: Base(program_id, Source{}) {}
|
||||
|
||||
InternalDecoration::~InternalDecoration() = default;
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace ast {
|
|||
class InternalDecoration : public Castable<InternalDecoration, Decoration> {
|
||||
public:
|
||||
/// Constructor
|
||||
InternalDecoration();
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
explicit InternalDecoration(ProgramID program_id);
|
||||
|
||||
/// Destructor
|
||||
~InternalDecoration() override;
|
||||
|
|
|
@ -19,8 +19,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Literal);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Literal::Literal(const Source& source, type::Type* type)
|
||||
: Base(source), type_(type) {}
|
||||
Literal::Literal(ProgramID program_id, const Source& source, type::Type* type)
|
||||
: Base(program_id, source), type_(type) {}
|
||||
|
||||
Literal::~Literal() = default;
|
||||
|
||||
|
|
|
@ -47,9 +47,12 @@ class Literal : public Castable<Literal, Node> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
explicit Literal(const Source& source, type::Type* type);
|
||||
explicit Literal(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type);
|
||||
|
||||
private:
|
||||
type::Type* const type_;
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LocationDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
LocationDecoration::LocationDecoration(const Source& source, uint32_t val)
|
||||
: Base(source), value_(val) {}
|
||||
LocationDecoration::LocationDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t val)
|
||||
: Base(program_id, source), value_(val) {}
|
||||
|
||||
LocationDecoration::~LocationDecoration() = default;
|
||||
|
||||
|
|
|
@ -24,9 +24,12 @@ namespace ast {
|
|||
class LocationDecoration : public Castable<LocationDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param value the location value
|
||||
LocationDecoration(const Source& source, uint32_t value);
|
||||
LocationDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t value);
|
||||
~LocationDecoration() override;
|
||||
|
||||
/// @returns the location value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LoopStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
LoopStatement::LoopStatement(const Source& source,
|
||||
LoopStatement::LoopStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
BlockStatement* body,
|
||||
BlockStatement* continuing)
|
||||
: Base(source), body_(body), continuing_(continuing) {
|
||||
: Base(program_id, source), body_(body), continuing_(continuing) {
|
||||
TINT_ASSERT(body_);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,12 @@ namespace ast {
|
|||
class LoopStatement : public Castable<LoopStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the loop statement source
|
||||
/// @param body the body statements
|
||||
/// @param continuing the continuing statements
|
||||
LoopStatement(const Source& source,
|
||||
LoopStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
BlockStatement* body,
|
||||
BlockStatement* continuing);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::MemberAccessorExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
MemberAccessorExpression::MemberAccessorExpression(const Source& source,
|
||||
MemberAccessorExpression::MemberAccessorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* structure,
|
||||
IdentifierExpression* member)
|
||||
: Base(source), struct_(structure), member_(member) {
|
||||
: Base(program_id, source), struct_(structure), member_(member) {
|
||||
TINT_ASSERT(structure);
|
||||
TINT_ASSERT(member);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,12 @@ class MemberAccessorExpression
|
|||
: public Castable<MemberAccessorExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the member accessor expression source
|
||||
/// @param structure the structure
|
||||
/// @param member the member
|
||||
MemberAccessorExpression(const Source& source,
|
||||
MemberAccessorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* structure,
|
||||
IdentifierExpression* member);
|
||||
/// Move constructor
|
||||
|
|
|
@ -23,10 +23,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Module);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Module::Module(const Source& source) : Base(source) {}
|
||||
Module::Module(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
Module::Module(const Source& source, std::vector<Cloneable*> global_decls)
|
||||
: Base(source), global_declarations_(std::move(global_decls)) {
|
||||
Module::Module(ProgramID program_id,
|
||||
const Source& source,
|
||||
std::vector<Cloneable*> global_decls)
|
||||
: Base(program_id, source), global_declarations_(std::move(global_decls)) {
|
||||
for (auto* decl : global_declarations_) {
|
||||
if (decl == nullptr) {
|
||||
continue;
|
||||
|
|
|
@ -28,14 +28,18 @@ namespace ast {
|
|||
class Module : public Castable<Module, Node> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of the module
|
||||
explicit Module(const Source& source);
|
||||
Module(ProgramID program_id, const Source& source);
|
||||
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of the module
|
||||
/// @param global_decls the list of global types, functions, and variables, in
|
||||
/// the order they were declared in the source program
|
||||
Module(const Source& source, std::vector<Cloneable*> global_decls);
|
||||
Module(ProgramID program_id,
|
||||
const Source& source,
|
||||
std::vector<Cloneable*> global_decls);
|
||||
|
||||
/// Destructor
|
||||
~Module() override;
|
||||
|
|
|
@ -19,7 +19,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Node);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Node::Node(const Source& source) : source_(source) {}
|
||||
Node::Node(ProgramID program_id, const Source& source)
|
||||
: program_id_(program_id), source_(source) {}
|
||||
|
||||
Node::Node(Node&&) = default;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/clone_context.h"
|
||||
#include "src/program_id.h"
|
||||
|
||||
namespace tint {
|
||||
|
||||
|
@ -37,6 +38,9 @@ class Node : public Castable<Node, Cloneable> {
|
|||
public:
|
||||
~Node() override;
|
||||
|
||||
/// @returns the identifier of the program that owns this node
|
||||
ProgramID program_id() const { return program_id_; }
|
||||
|
||||
/// @returns the node source data
|
||||
const Source& source() const { return source_; }
|
||||
|
||||
|
@ -55,8 +59,9 @@ class Node : public Castable<Node, Cloneable> {
|
|||
|
||||
protected:
|
||||
/// Create a new node
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source for the node
|
||||
explicit Node(const Source& source);
|
||||
Node(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
Node(Node&&);
|
||||
|
||||
|
@ -68,6 +73,7 @@ class Node : public Castable<Node, Cloneable> {
|
|||
private:
|
||||
Node(const Node&) = delete;
|
||||
|
||||
ProgramID const program_id_;
|
||||
Source const source_;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,11 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ReturnStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ReturnStatement::ReturnStatement(const Source& source)
|
||||
: Base(source), value_(nullptr) {}
|
||||
ReturnStatement::ReturnStatement(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source), value_(nullptr) {}
|
||||
|
||||
ReturnStatement::ReturnStatement(const Source& source, Expression* value)
|
||||
: Base(source), value_(value) {}
|
||||
ReturnStatement::ReturnStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* value)
|
||||
: Base(program_id, source), value_(value) {}
|
||||
|
||||
ReturnStatement::ReturnStatement(ReturnStatement&&) = default;
|
||||
|
||||
|
|
|
@ -25,12 +25,17 @@ namespace ast {
|
|||
class ReturnStatement : public Castable<ReturnStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
explicit ReturnStatement(const Source& source);
|
||||
ReturnStatement(ProgramID program_id, const Source& source);
|
||||
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the return statement source
|
||||
/// @param value the return value
|
||||
ReturnStatement(const Source& source, Expression* value);
|
||||
ReturnStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* value);
|
||||
/// Move constructor
|
||||
ReturnStatement(ReturnStatement&&);
|
||||
~ReturnStatement() override;
|
||||
|
|
|
@ -21,9 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ScalarConstructorExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(const Source& source,
|
||||
ScalarConstructorExpression::ScalarConstructorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Literal* literal)
|
||||
: Base(source), literal_(literal) {
|
||||
: Base(program_id, source), literal_(literal) {
|
||||
TINT_ASSERT(literal);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,12 @@ class ScalarConstructorExpression
|
|||
: public Castable<ScalarConstructorExpression, ConstructorExpression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the constructor source
|
||||
/// @param literal the const literal
|
||||
ScalarConstructorExpression(const Source& source, Literal* literal);
|
||||
ScalarConstructorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
Literal* literal);
|
||||
/// Move constructor
|
||||
ScalarConstructorExpression(ScalarConstructorExpression&&);
|
||||
~ScalarConstructorExpression() override;
|
||||
|
|
|
@ -21,8 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::SintLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SintLiteral::SintLiteral(const Source& source, type::Type* type, int32_t value)
|
||||
: Base(source, type, static_cast<uint32_t>(value)) {}
|
||||
SintLiteral::SintLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
int32_t value)
|
||||
: Base(program_id, source, type, static_cast<uint32_t>(value)) {}
|
||||
|
||||
SintLiteral::~SintLiteral() = default;
|
||||
|
||||
|
|
|
@ -26,10 +26,14 @@ namespace ast {
|
|||
class SintLiteral : public Castable<SintLiteral, IntLiteral> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type
|
||||
/// @param value the signed int literals value
|
||||
SintLiteral(const Source& source, type::Type* type, int32_t value);
|
||||
SintLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
int32_t value);
|
||||
~SintLiteral() override;
|
||||
|
||||
/// @returns the int literal value
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StageDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StageDecoration::StageDecoration(const Source& source, PipelineStage stage)
|
||||
: Base(source), stage_(stage) {}
|
||||
StageDecoration::StageDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
PipelineStage stage)
|
||||
: Base(program_id, source), stage_(stage) {}
|
||||
|
||||
StageDecoration::~StageDecoration() = default;
|
||||
|
||||
|
|
|
@ -25,9 +25,12 @@ namespace ast {
|
|||
class StageDecoration : public Castable<StageDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param stage the pipeline stage
|
||||
/// @param source the source of this decoration
|
||||
StageDecoration(const Source& source, PipelineStage stage);
|
||||
StageDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
PipelineStage stage);
|
||||
~StageDecoration() override;
|
||||
|
||||
/// @returns the stage
|
||||
|
|
|
@ -31,7 +31,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Statement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Statement::Statement(const Source& source) : Base(source) {}
|
||||
Statement::Statement(ProgramID program_id, const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
Statement::Statement(Statement&&) = default;
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ class Statement : public Castable<Statement, Node> {
|
|||
|
||||
protected:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of the expression
|
||||
explicit Statement(const Source& source);
|
||||
Statement(ProgramID program_id, const Source& source);
|
||||
/// Move constructor
|
||||
Statement(Statement&&);
|
||||
|
||||
|
|
|
@ -21,8 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StrideDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StrideDecoration::StrideDecoration(const Source& source, uint32_t stride)
|
||||
: Base(source), stride_(stride) {}
|
||||
StrideDecoration::StrideDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t stride)
|
||||
: Base(program_id, source), stride_(stride) {}
|
||||
|
||||
StrideDecoration::~StrideDecoration() = default;
|
||||
|
||||
|
|
|
@ -24,9 +24,10 @@ namespace ast {
|
|||
class StrideDecoration : public Castable<StrideDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param stride the stride value
|
||||
/// @param source the source of this decoration
|
||||
StrideDecoration(const Source& source, uint32_t stride);
|
||||
StrideDecoration(ProgramID program_id, const Source& source, uint32_t stride);
|
||||
~StrideDecoration() override;
|
||||
|
||||
/// @returns the stride value
|
||||
|
|
|
@ -22,10 +22,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Struct);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
Struct::Struct(const Source& source,
|
||||
Struct::Struct(ProgramID program_id,
|
||||
const Source& source,
|
||||
StructMemberList members,
|
||||
DecorationList decorations)
|
||||
: Base(source),
|
||||
: Base(program_id, source),
|
||||
members_(std::move(members)),
|
||||
decorations_(std::move(decorations)) {
|
||||
for (auto* mem : members_) {
|
||||
|
|
|
@ -27,10 +27,12 @@ namespace ast {
|
|||
class Struct : public Castable<Struct, Node> {
|
||||
public:
|
||||
/// Create a new struct statement
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source The input source for the import statement
|
||||
/// @param members The struct members
|
||||
/// @param decorations The struct decorations
|
||||
Struct(const Source& source,
|
||||
Struct(ProgramID program_id,
|
||||
const Source& source,
|
||||
StructMemberList members,
|
||||
DecorationList decorations);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,8 +21,9 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StructBlockDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructBlockDecoration::StructBlockDecoration(const Source& source)
|
||||
: Base(source) {}
|
||||
StructBlockDecoration::StructBlockDecoration(ProgramID program_id,
|
||||
const Source& source)
|
||||
: Base(program_id, source) {}
|
||||
|
||||
StructBlockDecoration::~StructBlockDecoration() = default;
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ class StructBlockDecoration
|
|||
: public Castable<StructBlockDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
explicit StructBlockDecoration(const Source& source);
|
||||
StructBlockDecoration(ProgramID program_id, const Source& source);
|
||||
~StructBlockDecoration() override;
|
||||
|
||||
/// Outputs the decoration to the given stream
|
||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StructMember);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructMember::StructMember(const Source& source,
|
||||
StructMember::StructMember(ProgramID program_id,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
type::Type* type,
|
||||
DecorationList decorations)
|
||||
: Base(source),
|
||||
: Base(program_id, source),
|
||||
symbol_(sym),
|
||||
type_(type),
|
||||
decorations_(std::move(decorations)) {
|
||||
|
|
|
@ -27,11 +27,13 @@ namespace ast {
|
|||
class StructMember : public Castable<StructMember, Node> {
|
||||
public:
|
||||
/// Create a new struct member statement
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source The input source for the struct member statement
|
||||
/// @param sym The struct member symbol
|
||||
/// @param type The struct member type
|
||||
/// @param decorations The struct member decorations
|
||||
StructMember(const Source& source,
|
||||
StructMember(ProgramID program_id,
|
||||
const Source& source,
|
||||
const Symbol& sym,
|
||||
type::Type* type,
|
||||
DecorationList decorations);
|
||||
|
|
|
@ -22,9 +22,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StructMemberAlignDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructMemberAlignDecoration::StructMemberAlignDecoration(const Source& source,
|
||||
StructMemberAlignDecoration::StructMemberAlignDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t align)
|
||||
: Base(source), align_(align) {}
|
||||
: Base(program_id, source), align_(align) {}
|
||||
|
||||
StructMemberAlignDecoration::~StructMemberAlignDecoration() = default;
|
||||
|
||||
|
|
|
@ -27,9 +27,12 @@ class StructMemberAlignDecoration
|
|||
: public Castable<StructMemberAlignDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param align the align value
|
||||
StructMemberAlignDecoration(const Source& source, uint32_t align);
|
||||
StructMemberAlignDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t align);
|
||||
~StructMemberAlignDecoration() override;
|
||||
|
||||
/// @returns the align value
|
||||
|
|
|
@ -21,9 +21,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StructMemberOffsetDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructMemberOffsetDecoration::StructMemberOffsetDecoration(const Source& source,
|
||||
StructMemberOffsetDecoration::StructMemberOffsetDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t offset)
|
||||
: Base(source), offset_(offset) {}
|
||||
: Base(program_id, source), offset_(offset) {}
|
||||
|
||||
StructMemberOffsetDecoration::~StructMemberOffsetDecoration() = default;
|
||||
|
||||
|
|
|
@ -34,9 +34,12 @@ class StructMemberOffsetDecoration
|
|||
: public Castable<StructMemberOffsetDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param offset the offset value
|
||||
StructMemberOffsetDecoration(const Source& source, uint32_t offset);
|
||||
StructMemberOffsetDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t offset);
|
||||
~StructMemberOffsetDecoration() override;
|
||||
|
||||
/// @returns the offset value
|
||||
|
|
|
@ -22,9 +22,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::StructMemberSizeDecoration);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
StructMemberSizeDecoration::StructMemberSizeDecoration(const Source& source,
|
||||
StructMemberSizeDecoration::StructMemberSizeDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t size)
|
||||
: Base(source), size_(size) {}
|
||||
: Base(program_id, source), size_(size) {}
|
||||
|
||||
StructMemberSizeDecoration::~StructMemberSizeDecoration() = default;
|
||||
|
||||
|
|
|
@ -27,9 +27,12 @@ class StructMemberSizeDecoration
|
|||
: public Castable<StructMemberSizeDecoration, Decoration> {
|
||||
public:
|
||||
/// constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source of this decoration
|
||||
/// @param size the size value
|
||||
StructMemberSizeDecoration(const Source& source, uint32_t size);
|
||||
StructMemberSizeDecoration(ProgramID program_id,
|
||||
const Source& source,
|
||||
uint32_t size);
|
||||
~StructMemberSizeDecoration() override;
|
||||
|
||||
/// @returns the size value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::SwitchStatement);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
SwitchStatement::SwitchStatement(const Source& source,
|
||||
SwitchStatement::SwitchStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
CaseStatementList body)
|
||||
: Base(source), condition_(condition), body_(body) {
|
||||
: Base(program_id, source), condition_(condition), body_(body) {
|
||||
TINT_ASSERT(condition_);
|
||||
for (auto* stmt : body_) {
|
||||
TINT_ASSERT(stmt);
|
||||
|
|
|
@ -25,10 +25,12 @@ namespace ast {
|
|||
class SwitchStatement : public Castable<SwitchStatement, Statement> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the source information
|
||||
/// @param condition the switch condition
|
||||
/// @param body the switch body
|
||||
SwitchStatement(const Source& source,
|
||||
SwitchStatement(ProgramID program_id,
|
||||
const Source& source,
|
||||
Expression* condition,
|
||||
CaseStatementList body);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::TypeConstructorExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
TypeConstructorExpression::TypeConstructorExpression(const Source& source,
|
||||
TypeConstructorExpression::TypeConstructorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
ExpressionList values)
|
||||
: Base(source), type_(type), values_(std::move(values)) {
|
||||
: Base(program_id, source), type_(type), values_(std::move(values)) {
|
||||
TINT_ASSERT(type);
|
||||
for (auto* val : values_) {
|
||||
TINT_ASSERT(val);
|
||||
|
|
|
@ -27,10 +27,12 @@ class TypeConstructorExpression
|
|||
: public Castable<TypeConstructorExpression, ConstructorExpression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the constructor source
|
||||
/// @param type the type
|
||||
/// @param values the constructor values
|
||||
TypeConstructorExpression(const Source& source,
|
||||
TypeConstructorExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
ExpressionList values);
|
||||
/// Move constructor
|
||||
|
|
|
@ -21,8 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::UintLiteral);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
UintLiteral::UintLiteral(const Source& source, type::Type* type, uint32_t value)
|
||||
: Base(source, type, value) {}
|
||||
UintLiteral::UintLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
uint32_t value)
|
||||
: Base(program_id, source, type, value) {}
|
||||
|
||||
UintLiteral::~UintLiteral() = default;
|
||||
|
||||
|
|
|
@ -26,10 +26,14 @@ namespace ast {
|
|||
class UintLiteral : public Castable<UintLiteral, IntLiteral> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param program_id the identifier of the program that owns this node
|
||||
/// @param source the input source
|
||||
/// @param type the type of the literal
|
||||
/// @param value the uint literals value
|
||||
UintLiteral(const Source& source, type::Type* type, uint32_t value);
|
||||
UintLiteral(ProgramID program_id,
|
||||
const Source& source,
|
||||
type::Type* type,
|
||||
uint32_t value);
|
||||
~UintLiteral() override;
|
||||
|
||||
/// @returns the uint literal value
|
||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::UnaryOpExpression);
|
|||
namespace tint {
|
||||
namespace ast {
|
||||
|
||||
UnaryOpExpression::UnaryOpExpression(const Source& source,
|
||||
UnaryOpExpression::UnaryOpExpression(ProgramID program_id,
|
||||
const Source& source,
|
||||
UnaryOp op,
|
||||
Expression* expr)
|
||||
: Base(source), op_(op), expr_(expr) {
|
||||
: Base(program_id, source), op_(op), expr_(expr) {
|
||||
TINT_ASSERT(expr_);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue