tint: Optimize sem node lookup
Add a 'NodeID' to each ast::Node which is the sequentially allocated index of the node. Use this in sem::Info to map the AST node to the semantic node, instead of using a std::unordered_map. Optimised very hot code by entirely eliminating map lookups, and dramatically reducing cache misses (lookups are usually sequentually ordered). Timings running 'webgpu:shader,execution,expression,call,builtin,atan2:f32:inputSource="const";vectorize="_undef_"' with dawn/node, using SwiftShader: Without change: 3.22647107s With change: 3.10578879s Bug: tint:1613 Change-Id: I22ec48d933b2e5f9da04494bff4e979e6f7b1982 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/96140 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
8d73198aca
commit
4a92a3c904
|
@ -287,6 +287,7 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"ast/module.h",
|
"ast/module.h",
|
||||||
"ast/multisampled_texture.cc",
|
"ast/multisampled_texture.cc",
|
||||||
"ast/multisampled_texture.h",
|
"ast/multisampled_texture.h",
|
||||||
|
"ast/node_id.h",
|
||||||
"ast/node.cc",
|
"ast/node.cc",
|
||||||
"ast/node.h",
|
"ast/node.h",
|
||||||
"ast/override.cc",
|
"ast/override.cc",
|
||||||
|
|
|
@ -157,6 +157,7 @@ set(TINT_LIB_SRCS
|
||||||
ast/module.h
|
ast/module.h
|
||||||
ast/multisampled_texture.cc
|
ast/multisampled_texture.cc
|
||||||
ast/multisampled_texture.h
|
ast/multisampled_texture.h
|
||||||
|
ast/node_id.h
|
||||||
ast/node.cc
|
ast/node.cc
|
||||||
ast/node.h
|
ast/node.h
|
||||||
ast/override.cc
|
ast/override.cc
|
||||||
|
|
|
@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Alias);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Alias::Alias(ProgramID pid, const Source& src, const Symbol& n, const Type* subtype)
|
Alias::Alias(ProgramID pid, NodeID nid, const Source& src, const Symbol& n, const Type* subtype)
|
||||||
: Base(pid, src, n), type(subtype) {
|
: Base(pid, nid, src, n), type(subtype) {
|
||||||
TINT_ASSERT(AST, type);
|
TINT_ASSERT(AST, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,11 @@ class Alias final : public Castable<Alias, TypeDecl> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param name the symbol for the alias
|
/// @param name the symbol for the alias
|
||||||
/// @param subtype the alias'd type
|
/// @param subtype the alias'd type
|
||||||
Alias(ProgramID pid, const Source& src, const Symbol& name, const Type* subtype);
|
Alias(ProgramID pid, NodeID nid, const Source& src, const Symbol& name, const Type* subtype);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Alias(Alias&&);
|
Alias(Alias&&);
|
||||||
/// Destructor
|
/// Destructor
|
||||||
|
|
|
@ -38,11 +38,12 @@ std::string SizeExprToString(const Expression* size, const SymbolTable& symbols)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Array::Array(ProgramID pid,
|
Array::Array(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Type* subtype,
|
const Type* subtype,
|
||||||
const Expression* cnt,
|
const Expression* cnt,
|
||||||
AttributeList attrs)
|
AttributeList attrs)
|
||||||
: Base(pid, src), type(subtype), count(cnt), attributes(attrs) {}
|
: Base(pid, nid, src), type(subtype), count(cnt), attributes(attrs) {}
|
||||||
|
|
||||||
Array::Array(Array&&) = default;
|
Array::Array(Array&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,14 @@ class Array final : public Castable<Array, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param subtype the type of the array elements
|
/// @param subtype the type of the array elements
|
||||||
/// @param count the number of elements in the array. nullptr represents a
|
/// @param count the number of elements in the array. nullptr represents a
|
||||||
/// runtime-sized array.
|
/// runtime-sized array.
|
||||||
/// @param attributes the array attributes
|
/// @param attributes the array attributes
|
||||||
Array(ProgramID pid,
|
Array(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Type* subtype,
|
const Type* subtype,
|
||||||
const Expression* count,
|
const Expression* count,
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::AssignmentStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
AssignmentStatement::AssignmentStatement(ProgramID pid,
|
AssignmentStatement::AssignmentStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* l,
|
const Expression* l,
|
||||||
const Expression* r)
|
const Expression* r)
|
||||||
: Base(pid, src), lhs(l), rhs(r) {
|
: Base(pid, nid, src), lhs(l), rhs(r) {
|
||||||
TINT_ASSERT(AST, lhs);
|
TINT_ASSERT(AST, lhs);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
||||||
TINT_ASSERT(AST, rhs);
|
TINT_ASSERT(AST, rhs);
|
||||||
|
|
|
@ -24,11 +24,13 @@ namespace tint::ast {
|
||||||
class AssignmentStatement final : public Castable<AssignmentStatement, Statement> {
|
class AssignmentStatement final : public Castable<AssignmentStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the assignment statement source
|
/// @param source the assignment statement source
|
||||||
/// @param lhs the left side of the expression
|
/// @param lhs the left side of the expression
|
||||||
/// @param rhs the right side of the expression
|
/// @param rhs the right side of the expression
|
||||||
AssignmentStatement(ProgramID program_id,
|
AssignmentStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Expression* lhs,
|
const Expression* lhs,
|
||||||
const Expression* rhs);
|
const Expression* rhs);
|
||||||
|
|
|
@ -30,7 +30,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Type);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Type::Type(ProgramID pid, const Source& src) : Base(pid, src) {}
|
Type::Type(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
Type::Type(Type&&) = default;
|
Type::Type(Type&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Atomic);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Atomic::Atomic(ProgramID pid, const Source& src, const Type* const subtype)
|
Atomic::Atomic(ProgramID pid, NodeID nid, const Source& src, const Type* const subtype)
|
||||||
: Base(pid, src), type(subtype) {}
|
: Base(pid, nid, src), type(subtype) {}
|
||||||
|
|
||||||
std::string Atomic::FriendlyName(const SymbolTable& symbols) const {
|
std::string Atomic::FriendlyName(const SymbolTable& symbols) const {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
|
|
@ -26,9 +26,10 @@ class Atomic final : public Castable<Atomic, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param subtype the pointee type
|
/// @param subtype the pointee type
|
||||||
Atomic(ProgramID pid, const Source& src, const Type* const subtype);
|
Atomic(ProgramID pid, NodeID nid, const Source& src, const Type* const subtype);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Atomic(Atomic&&);
|
Atomic(Atomic&&);
|
||||||
~Atomic() override;
|
~Atomic() override;
|
||||||
|
|
|
@ -33,8 +33,9 @@ class Attribute : public Castable<Attribute, Node> {
|
||||||
protected:
|
protected:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
Attribute(ProgramID pid, const Source& src) : Base(pid, src) {}
|
Attribute(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A list of attributes
|
/// A list of attributes
|
||||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BinaryExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BinaryExpression::BinaryExpression(ProgramID pid,
|
BinaryExpression::BinaryExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
BinaryOp o,
|
BinaryOp o,
|
||||||
const Expression* l,
|
const Expression* l,
|
||||||
const Expression* r)
|
const Expression* r)
|
||||||
: Base(pid, src), op(o), lhs(l), rhs(r) {
|
: Base(pid, nid, src), op(o), lhs(l), rhs(r) {
|
||||||
TINT_ASSERT(AST, lhs);
|
TINT_ASSERT(AST, lhs);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
||||||
TINT_ASSERT(AST, rhs);
|
TINT_ASSERT(AST, rhs);
|
||||||
|
|
|
@ -46,12 +46,14 @@ enum class BinaryOp {
|
||||||
class BinaryExpression final : public Castable<BinaryExpression, Expression> {
|
class BinaryExpression final : public Castable<BinaryExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the binary expression source
|
/// @param source the binary expression source
|
||||||
/// @param op the operation type
|
/// @param op the operation type
|
||||||
/// @param lhs the left side of the expression
|
/// @param lhs the left side of the expression
|
||||||
/// @param rhs the right side of the expression
|
/// @param rhs the right side of the expression
|
||||||
BinaryExpression(ProgramID program_id,
|
BinaryExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
BinaryOp op,
|
BinaryOp op,
|
||||||
const Expression* lhs,
|
const Expression* lhs,
|
||||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BindingAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BindingAttribute::BindingAttribute(ProgramID pid, const Source& src, uint32_t val)
|
BindingAttribute::BindingAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
|
||||||
: Base(pid, src), value(val) {}
|
: Base(pid, nid, src), value(val) {}
|
||||||
|
|
||||||
BindingAttribute::~BindingAttribute() = default;
|
BindingAttribute::~BindingAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class BindingAttribute final : public Castable<BindingAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param value the binding value
|
/// @param value the binding value
|
||||||
BindingAttribute(ProgramID pid, const Source& src, uint32_t value);
|
BindingAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
|
||||||
~BindingAttribute() override;
|
~BindingAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BitcastExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BitcastExpression::BitcastExpression(ProgramID pid,
|
BitcastExpression::BitcastExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Type* t,
|
const Type* t,
|
||||||
const Expression* e)
|
const Expression* e)
|
||||||
: Base(pid, src), type(t), expr(e) {
|
: Base(pid, nid, src), type(t), expr(e) {
|
||||||
TINT_ASSERT(AST, type);
|
TINT_ASSERT(AST, type);
|
||||||
TINT_ASSERT(AST, expr);
|
TINT_ASSERT(AST, expr);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);
|
||||||
|
|
|
@ -28,11 +28,13 @@ namespace tint::ast {
|
||||||
class BitcastExpression final : public Castable<BitcastExpression, Expression> {
|
class BitcastExpression final : public Castable<BitcastExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the bitcast expression source
|
/// @param source the bitcast expression source
|
||||||
/// @param type the type
|
/// @param type the type
|
||||||
/// @param expr the expr
|
/// @param expr the expr
|
||||||
BitcastExpression(ProgramID program_id,
|
BitcastExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Type* type,
|
const Type* type,
|
||||||
const Expression* expr);
|
const Expression* expr);
|
||||||
|
|
|
@ -20,8 +20,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BlockStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BlockStatement::BlockStatement(ProgramID pid, const Source& src, const StatementList& stmts)
|
BlockStatement::BlockStatement(ProgramID pid,
|
||||||
: Base(pid, src), statements(std::move(stmts)) {
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const StatementList& stmts)
|
||||||
|
: Base(pid, nid, src), statements(std::move(stmts)) {
|
||||||
for (auto* stmt : statements) {
|
for (auto* stmt : statements) {
|
||||||
TINT_ASSERT(AST, stmt);
|
TINT_ASSERT(AST, stmt);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, stmt, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, stmt, program_id);
|
||||||
|
|
|
@ -25,10 +25,14 @@ namespace tint::ast {
|
||||||
class BlockStatement final : public Castable<BlockStatement, Statement> {
|
class BlockStatement final : public Castable<BlockStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the block statement source
|
/// @param source the block statement source
|
||||||
/// @param statements the statements
|
/// @param statements the statements
|
||||||
BlockStatement(ProgramID program_id, const Source& source, const StatementList& statements);
|
BlockStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
|
const Source& source,
|
||||||
|
const StatementList& statements);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
BlockStatement(BlockStatement&&);
|
BlockStatement(BlockStatement&&);
|
||||||
~BlockStatement() override;
|
~BlockStatement() override;
|
||||||
|
|
|
@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Bool);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Bool::Bool(ProgramID pid, const Source& src) : Base(pid, src) {}
|
Bool::Bool(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
Bool::Bool(Bool&&) = default;
|
Bool::Bool(Bool&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,9 @@ class Bool final : public Castable<Bool, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
Bool(ProgramID pid, const Source& src);
|
Bool(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Bool(Bool&&);
|
Bool(Bool&&);
|
||||||
~Bool() override;
|
~Bool() override;
|
||||||
|
|
|
@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BoolLiteralExpression);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BoolLiteralExpression::BoolLiteralExpression(ProgramID pid, const Source& src, bool val)
|
BoolLiteralExpression::BoolLiteralExpression(ProgramID pid, NodeID nid, const Source& src, bool val)
|
||||||
: Base(pid, src), value(val) {}
|
: Base(pid, nid, src), value(val) {}
|
||||||
|
|
||||||
BoolLiteralExpression::~BoolLiteralExpression() = default;
|
BoolLiteralExpression::~BoolLiteralExpression() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class BoolLiteralExpression final : public Castable<BoolLiteralExpression, Liter
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param value the bool literals value
|
/// @param value the bool literals value
|
||||||
BoolLiteralExpression(ProgramID pid, const Source& src, bool value);
|
BoolLiteralExpression(ProgramID pid, NodeID nid, const Source& src, bool value);
|
||||||
~BoolLiteralExpression() override;
|
~BoolLiteralExpression() override;
|
||||||
|
|
||||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||||
|
|
|
@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BreakStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BreakStatement::BreakStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
|
BreakStatement::BreakStatement(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
BreakStatement::BreakStatement(BreakStatement&&) = default;
|
BreakStatement::BreakStatement(BreakStatement&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class BreakStatement final : public Castable<BreakStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
BreakStatement(ProgramID pid, const Source& src);
|
BreakStatement(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
BreakStatement(BreakStatement&&);
|
BreakStatement(BreakStatement&&);
|
||||||
~BreakStatement() override;
|
~BreakStatement() override;
|
||||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::BuiltinAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
BuiltinAttribute::BuiltinAttribute(ProgramID pid, const Source& src, Builtin b)
|
BuiltinAttribute::BuiltinAttribute(ProgramID pid, NodeID nid, const Source& src, Builtin b)
|
||||||
: Base(pid, src), builtin(b) {}
|
: Base(pid, nid, src), builtin(b) {}
|
||||||
|
|
||||||
BuiltinAttribute::~BuiltinAttribute() = default;
|
BuiltinAttribute::~BuiltinAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,10 @@ class BuiltinAttribute final : public Castable<BuiltinAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param builtin the builtin value
|
/// @param builtin the builtin value
|
||||||
BuiltinAttribute(ProgramID pid, const Source& src, Builtin builtin);
|
BuiltinAttribute(ProgramID pid, NodeID nid, const Source& src, Builtin builtin);
|
||||||
~BuiltinAttribute() override;
|
~BuiltinAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -34,10 +34,11 @@ CallExpression::Target ToTarget(const Type* type) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CallExpression::CallExpression(ProgramID pid,
|
CallExpression::CallExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const IdentifierExpression* name,
|
const IdentifierExpression* name,
|
||||||
ExpressionList a)
|
ExpressionList a)
|
||||||
: Base(pid, src), target(ToTarget(name)), args(a) {
|
: Base(pid, nid, src), target(ToTarget(name)), args(a) {
|
||||||
TINT_ASSERT(AST, name);
|
TINT_ASSERT(AST, name);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, name, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, name, program_id);
|
||||||
for (auto* arg : args) {
|
for (auto* arg : args) {
|
||||||
|
@ -46,8 +47,12 @@ CallExpression::CallExpression(ProgramID pid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CallExpression::CallExpression(ProgramID pid, const Source& src, const Type* type, ExpressionList a)
|
CallExpression::CallExpression(ProgramID pid,
|
||||||
: Base(pid, src), target(ToTarget(type)), args(a) {
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const Type* type,
|
||||||
|
ExpressionList a)
|
||||||
|
: Base(pid, nid, src), target(ToTarget(type)), args(a) {
|
||||||
TINT_ASSERT(AST, type);
|
TINT_ASSERT(AST, type);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, type, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, type, program_id);
|
||||||
for (auto* arg : args) {
|
for (auto* arg : args) {
|
||||||
|
|
|
@ -33,21 +33,25 @@ namespace tint::ast {
|
||||||
class CallExpression final : public Castable<CallExpression, Expression> {
|
class CallExpression final : public Castable<CallExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the call expression source
|
/// @param source the call expression source
|
||||||
/// @param name the function or type name
|
/// @param name the function or type name
|
||||||
/// @param args the arguments
|
/// @param args the arguments
|
||||||
CallExpression(ProgramID program_id,
|
CallExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const IdentifierExpression* name,
|
const IdentifierExpression* name,
|
||||||
ExpressionList args);
|
ExpressionList args);
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the call expression source
|
/// @param source the call expression source
|
||||||
/// @param type the type
|
/// @param type the type
|
||||||
/// @param args the arguments
|
/// @param args the arguments
|
||||||
CallExpression(ProgramID program_id,
|
CallExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Type* type,
|
const Type* type,
|
||||||
ExpressionList args);
|
ExpressionList args);
|
||||||
|
|
|
@ -20,8 +20,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CallStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
CallStatement::CallStatement(ProgramID pid, const Source& src, const CallExpression* call)
|
CallStatement::CallStatement(ProgramID pid,
|
||||||
: Base(pid, src), expr(call) {
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const CallExpression* call)
|
||||||
|
: Base(pid, nid, src), expr(call) {
|
||||||
TINT_ASSERT(AST, expr);
|
TINT_ASSERT(AST, expr);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, expr, program_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,10 @@ class CallStatement final : public Castable<CallStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node for the statement
|
/// @param src the source of this node for the statement
|
||||||
/// @param call the function
|
/// @param call the function
|
||||||
CallStatement(ProgramID pid, const Source& src, const CallExpression* call);
|
CallStatement(ProgramID pid, NodeID nid, const Source& src, const CallExpression* call);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
CallStatement(CallStatement&&);
|
CallStatement(CallStatement&&);
|
||||||
~CallStatement() override;
|
~CallStatement() override;
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CaseStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
CaseStatement::CaseStatement(ProgramID pid,
|
CaseStatement::CaseStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
CaseSelectorList s,
|
CaseSelectorList s,
|
||||||
const BlockStatement* b)
|
const BlockStatement* b)
|
||||||
: Base(pid, src), selectors(s), body(b) {
|
: Base(pid, nid, src), selectors(s), body(b) {
|
||||||
TINT_ASSERT(AST, body);
|
TINT_ASSERT(AST, body);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
|
||||||
for (auto* selector : selectors) {
|
for (auto* selector : selectors) {
|
||||||
|
|
|
@ -30,10 +30,12 @@ class CaseStatement final : public Castable<CaseStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param selectors the case selectors
|
/// @param selectors the case selectors
|
||||||
/// @param body the case body
|
/// @param body the case body
|
||||||
CaseStatement(ProgramID pid,
|
CaseStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
CaseSelectorList selectors,
|
CaseSelectorList selectors,
|
||||||
const BlockStatement* body);
|
const BlockStatement* body);
|
||||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CompoundAssignmentStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
CompoundAssignmentStatement::CompoundAssignmentStatement(ProgramID pid,
|
CompoundAssignmentStatement::CompoundAssignmentStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* l,
|
const Expression* l,
|
||||||
const Expression* r,
|
const Expression* r,
|
||||||
BinaryOp o)
|
BinaryOp o)
|
||||||
: Base(pid, src), lhs(l), rhs(r), op(o) {
|
: Base(pid, nid, src), lhs(l), rhs(r), op(o) {
|
||||||
TINT_ASSERT(AST, lhs);
|
TINT_ASSERT(AST, lhs);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
||||||
TINT_ASSERT(AST, rhs);
|
TINT_ASSERT(AST, rhs);
|
||||||
|
|
|
@ -25,12 +25,14 @@ namespace tint::ast {
|
||||||
class CompoundAssignmentStatement final : public Castable<CompoundAssignmentStatement, Statement> {
|
class CompoundAssignmentStatement final : public Castable<CompoundAssignmentStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the compound assignment statement source
|
/// @param source the compound assignment statement source
|
||||||
/// @param lhs the left side of the expression
|
/// @param lhs the left side of the expression
|
||||||
/// @param rhs the right side of the expression
|
/// @param rhs the right side of the expression
|
||||||
/// @param op the binary operator
|
/// @param op the binary operator
|
||||||
CompoundAssignmentStatement(ProgramID program_id,
|
CompoundAssignmentStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Expression* lhs,
|
const Expression* lhs,
|
||||||
const Expression* rhs,
|
const Expression* rhs,
|
||||||
|
|
|
@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Const);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Const::Const(ProgramID pid,
|
Const::Const(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Symbol& sym,
|
const Symbol& sym,
|
||||||
const ast::Type* ty,
|
const ast::Type* ty,
|
||||||
const Expression* ctor,
|
const Expression* ctor,
|
||||||
AttributeList attrs)
|
AttributeList attrs)
|
||||||
: Base(pid, src, sym, ty, ctor, attrs) {
|
: Base(pid, nid, src, sym, ty, ctor, attrs) {
|
||||||
TINT_ASSERT(AST, ctor != nullptr);
|
TINT_ASSERT(AST, ctor != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,13 +33,15 @@ namespace tint::ast {
|
||||||
class Const final : public Castable<Const, Variable> {
|
class Const final : public Castable<Const, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'const' creation-time value variable.
|
/// Create a 'const' creation-time value variable.
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the variable source
|
/// @param source the variable source
|
||||||
/// @param sym the variable symbol
|
/// @param sym the variable symbol
|
||||||
/// @param type the declared variable type
|
/// @param type the declared variable type
|
||||||
/// @param constructor the constructor expression. Must not be nullptr.
|
/// @param constructor the constructor expression. Must not be nullptr.
|
||||||
/// @param attributes the variable attributes
|
/// @param attributes the variable attributes
|
||||||
Const(ProgramID program_id,
|
Const(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Symbol& sym,
|
const Symbol& sym,
|
||||||
const ast::Type* type,
|
const ast::Type* type,
|
||||||
|
|
|
@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ContinueStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
ContinueStatement::ContinueStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
|
ContinueStatement::ContinueStatement(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
ContinueStatement::ContinueStatement(ContinueStatement&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class ContinueStatement final : public Castable<ContinueStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
ContinueStatement(ProgramID pid, const Source& src);
|
ContinueStatement(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
ContinueStatement(ContinueStatement&&);
|
ContinueStatement(ContinueStatement&&);
|
||||||
~ContinueStatement() override;
|
~ContinueStatement() override;
|
||||||
|
|
|
@ -28,9 +28,10 @@ bool IsValidDepthDimension(TextureDimension dim) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DepthMultisampledTexture::DepthMultisampledTexture(ProgramID pid,
|
DepthMultisampledTexture::DepthMultisampledTexture(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
TextureDimension d)
|
TextureDimension d)
|
||||||
: Base(pid, src, d) {
|
: Base(pid, nid, src, d) {
|
||||||
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class DepthMultisampledTexture final : public Castable<DepthMultisampledTexture,
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
DepthMultisampledTexture(ProgramID pid, const Source& src, TextureDimension dim);
|
DepthMultisampledTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
DepthMultisampledTexture(DepthMultisampledTexture&&);
|
DepthMultisampledTexture(DepthMultisampledTexture&&);
|
||||||
~DepthMultisampledTexture() override;
|
~DepthMultisampledTexture() override;
|
||||||
|
|
|
@ -28,8 +28,8 @@ bool IsValidDepthDimension(TextureDimension dim) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DepthTexture::DepthTexture(ProgramID pid, const Source& src, TextureDimension d)
|
DepthTexture::DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension d)
|
||||||
: Base(pid, src, d) {
|
: Base(pid, nid, src, d) {
|
||||||
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
TINT_ASSERT(AST, IsValidDepthDimension(dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class DepthTexture final : public Castable<DepthTexture, Texture> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param dim the dimensionality of the texture
|
/// @param dim the dimensionality of the texture
|
||||||
DepthTexture(ProgramID pid, const Source& src, TextureDimension dim);
|
DepthTexture(ProgramID pid, NodeID nid, const Source& src, TextureDimension dim);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
DepthTexture(DepthTexture&&);
|
DepthTexture(DepthTexture&&);
|
||||||
~DepthTexture() override;
|
~DepthTexture() override;
|
||||||
|
|
|
@ -20,8 +20,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DisableValidationAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
DisableValidationAttribute::DisableValidationAttribute(ProgramID pid, DisabledValidation val)
|
DisableValidationAttribute::DisableValidationAttribute(ProgramID pid,
|
||||||
: Base(pid), validation(val) {}
|
NodeID nid,
|
||||||
|
DisabledValidation val)
|
||||||
|
: Base(pid, nid), validation(val) {}
|
||||||
|
|
||||||
DisableValidationAttribute::~DisableValidationAttribute() = default;
|
DisableValidationAttribute::~DisableValidationAttribute() = default;
|
||||||
|
|
||||||
|
@ -46,7 +48,8 @@ std::string DisableValidationAttribute::InternalName() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisableValidationAttribute* DisableValidationAttribute::Clone(CloneContext* ctx) const {
|
const DisableValidationAttribute* DisableValidationAttribute::Clone(CloneContext* ctx) const {
|
||||||
return ctx->dst->ASTNodes().Create<DisableValidationAttribute>(ctx->dst->ID(), validation);
|
return ctx->dst->ASTNodes().Create<DisableValidationAttribute>(
|
||||||
|
ctx->dst->ID(), ctx->dst->AllocateNodeID(), validation);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
|
|
|
@ -51,9 +51,10 @@ class DisableValidationAttribute final
|
||||||
: public Castable<DisableValidationAttribute, InternalAttribute> {
|
: public Castable<DisableValidationAttribute, InternalAttribute> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param validation the validation to disable
|
/// @param validation the validation to disable
|
||||||
explicit DisableValidationAttribute(ProgramID program_id, DisabledValidation validation);
|
explicit DisableValidationAttribute(ProgramID pid, NodeID nid, DisabledValidation validation);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~DisableValidationAttribute() override;
|
~DisableValidationAttribute() override;
|
||||||
|
|
|
@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::DiscardStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
DiscardStatement::DiscardStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
|
DiscardStatement::DiscardStatement(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
|
DiscardStatement::DiscardStatement(DiscardStatement&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class DiscardStatement final : public Castable<DiscardStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
DiscardStatement(ProgramID pid, const Source& src);
|
DiscardStatement(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
DiscardStatement(DiscardStatement&&);
|
DiscardStatement(DiscardStatement&&);
|
||||||
~DiscardStatement() override;
|
~DiscardStatement() override;
|
||||||
|
|
|
@ -21,7 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Enable);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Enable::Enable(ProgramID pid, const Source& src, Extension ext) : Base(pid, src), extension(ext) {}
|
Enable::Enable(ProgramID pid, NodeID nid, const Source& src, Extension ext)
|
||||||
|
: Base(pid, nid, src), extension(ext) {}
|
||||||
|
|
||||||
Enable::Enable(Enable&&) = default;
|
Enable::Enable(Enable&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,10 @@ class Enable final : public Castable<Enable, Node> {
|
||||||
public:
|
public:
|
||||||
/// Create a extension
|
/// Create a extension
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param ext the extension
|
/// @param ext the extension
|
||||||
Enable(ProgramID pid, const Source& src, Extension ext);
|
Enable(ProgramID pid, NodeID nid, const Source& src, Extension ext);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Enable(Enable&&);
|
Enable(Enable&&);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Expression);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Expression::Expression(ProgramID pid, const Source& src) : Base(pid, src) {}
|
Expression::Expression(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
Expression::Expression(Expression&&) = default;
|
Expression::Expression(Expression&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ class Expression : public Castable<Expression, Node> {
|
||||||
protected:
|
protected:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
Expression(ProgramID pid, const Source& src);
|
Expression(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Expression(Expression&&);
|
Expression(Expression&&);
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,8 +21,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ExternalTexture);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
// ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
|
// ExternalTexture::ExternalTexture() : Base(ast::TextureDimension::k2d) {}
|
||||||
ExternalTexture::ExternalTexture(ProgramID pid, const Source& src)
|
ExternalTexture::ExternalTexture(ProgramID pid, NodeID nid, const Source& src)
|
||||||
: Base(pid, src, ast::TextureDimension::k2d) {}
|
: Base(pid, nid, src, ast::TextureDimension::k2d) {}
|
||||||
|
|
||||||
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
ExternalTexture::ExternalTexture(ExternalTexture&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ class ExternalTexture final : public Castable<ExternalTexture, Texture> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
ExternalTexture(ProgramID pid, const Source& src);
|
ExternalTexture(ProgramID pid, NodeID nid, const Source& src);
|
||||||
|
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
ExternalTexture(ExternalTexture&&);
|
ExternalTexture(ExternalTexture&&);
|
||||||
|
|
|
@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::F16);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
F16::F16(ProgramID pid, const Source& src) : Base(pid, src) {}
|
F16::F16(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
F16::F16(F16&&) = default;
|
F16::F16(F16&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ class F16 : public Castable<F16, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
F16(ProgramID pid, const Source& src);
|
F16(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
F16(F16&&);
|
F16(F16&&);
|
||||||
~F16() override;
|
~F16() override;
|
||||||
|
|
|
@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::F32);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
F32::F32(ProgramID pid, const Source& src) : Base(pid, src) {}
|
F32::F32(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
F32::F32(F32&&) = default;
|
F32::F32(F32&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ class F32 final : public Castable<F32, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
F32(ProgramID pid, const Source& src);
|
F32(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
F32(F32&&);
|
F32(F32&&);
|
||||||
~F32() override;
|
~F32() override;
|
||||||
|
|
|
@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FallthroughStatement);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
FallthroughStatement::FallthroughStatement(ProgramID pid, const Source& src) : Base(pid, src) {}
|
FallthroughStatement::FallthroughStatement(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
|
FallthroughStatement::FallthroughStatement(FallthroughStatement&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,9 @@ class FallthroughStatement final : public Castable<FallthroughStatement, Stateme
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
FallthroughStatement(ProgramID pid, const Source& src);
|
FallthroughStatement(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
FallthroughStatement(FallthroughStatement&&);
|
FallthroughStatement(FallthroughStatement&&);
|
||||||
~FallthroughStatement() override;
|
~FallthroughStatement() override;
|
||||||
|
|
|
@ -23,10 +23,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::FloatLiteralExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
FloatLiteralExpression::FloatLiteralExpression(ProgramID pid,
|
FloatLiteralExpression::FloatLiteralExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
double val,
|
double val,
|
||||||
Suffix suf)
|
Suffix suf)
|
||||||
: Base(pid, src), value(val), suffix(suf) {}
|
: Base(pid, nid, src), value(val), suffix(suf) {}
|
||||||
|
|
||||||
FloatLiteralExpression::~FloatLiteralExpression() = default;
|
FloatLiteralExpression::~FloatLiteralExpression() = default;
|
||||||
|
|
||||||
|
|
|
@ -36,10 +36,11 @@ class FloatLiteralExpression final : public Castable<FloatLiteralExpression, Lit
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param val the literal value
|
/// @param val the literal value
|
||||||
/// @param suf the literal suffix
|
/// @param suf the literal suffix
|
||||||
FloatLiteralExpression(ProgramID pid, const Source& src, double val, Suffix suf);
|
FloatLiteralExpression(ProgramID pid, NodeID nid, const Source& src, double val, Suffix suf);
|
||||||
~FloatLiteralExpression() override;
|
~FloatLiteralExpression() override;
|
||||||
|
|
||||||
/// Clones this node and all transitive child nodes using the `CloneContext`
|
/// Clones this node and all transitive child nodes using the `CloneContext`
|
||||||
|
|
|
@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::ForLoopStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
ForLoopStatement::ForLoopStatement(ProgramID pid,
|
ForLoopStatement::ForLoopStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Statement* init,
|
const Statement* init,
|
||||||
const Expression* cond,
|
const Expression* cond,
|
||||||
const Statement* cont,
|
const Statement* cont,
|
||||||
const BlockStatement* b)
|
const BlockStatement* b)
|
||||||
: Base(pid, src), initializer(init), condition(cond), continuing(cont), body(b) {
|
: Base(pid, nid, src), initializer(init), condition(cond), continuing(cont), body(b) {
|
||||||
TINT_ASSERT(AST, body);
|
TINT_ASSERT(AST, body);
|
||||||
|
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, initializer, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, initializer, program_id);
|
||||||
|
|
|
@ -25,14 +25,16 @@ class Expression;
|
||||||
class ForLoopStatement final : public Castable<ForLoopStatement, Statement> {
|
class ForLoopStatement final : public Castable<ForLoopStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the for loop statement source
|
/// @param source the for loop statement source
|
||||||
/// @param initializer the optional loop initializer statement
|
/// @param initializer the optional loop initializer statement
|
||||||
/// @param condition the optional loop condition expression
|
/// @param condition the optional loop condition expression
|
||||||
/// @param continuing the optional continuing statement
|
/// @param continuing the optional continuing statement
|
||||||
/// @param body the loop body
|
/// @param body the loop body
|
||||||
ForLoopStatement(ProgramID program_id,
|
ForLoopStatement(ProgramID pid,
|
||||||
Source const& source,
|
NodeID nid,
|
||||||
|
const Source& source,
|
||||||
const Statement* initializer,
|
const Statement* initializer,
|
||||||
const Expression* condition,
|
const Expression* condition,
|
||||||
const Statement* continuing,
|
const Statement* continuing,
|
||||||
|
|
|
@ -23,6 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Function);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Function::Function(ProgramID pid,
|
Function::Function(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
Symbol sym,
|
Symbol sym,
|
||||||
ParameterList parameters,
|
ParameterList parameters,
|
||||||
|
@ -30,7 +31,7 @@ Function::Function(ProgramID pid,
|
||||||
const BlockStatement* b,
|
const BlockStatement* b,
|
||||||
AttributeList attrs,
|
AttributeList attrs,
|
||||||
AttributeList return_type_attrs)
|
AttributeList return_type_attrs)
|
||||||
: Base(pid, src),
|
: Base(pid, nid, src),
|
||||||
symbol(sym),
|
symbol(sym),
|
||||||
params(std::move(parameters)),
|
params(std::move(parameters)),
|
||||||
return_type(return_ty),
|
return_type(return_ty),
|
||||||
|
|
|
@ -35,7 +35,8 @@ namespace tint::ast {
|
||||||
class Function final : public Castable<Function, Node> {
|
class Function final : public Castable<Function, Node> {
|
||||||
public:
|
public:
|
||||||
/// Create a function
|
/// Create a function
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the variable source
|
/// @param source the variable source
|
||||||
/// @param symbol the function symbol
|
/// @param symbol the function symbol
|
||||||
/// @param params the function parameters
|
/// @param params the function parameters
|
||||||
|
@ -43,7 +44,8 @@ class Function final : public Castable<Function, Node> {
|
||||||
/// @param body the function body
|
/// @param body the function body
|
||||||
/// @param attributes the function attributes
|
/// @param attributes the function attributes
|
||||||
/// @param return_type_attributes the return type attributes
|
/// @param return_type_attributes the return type attributes
|
||||||
Function(ProgramID program_id,
|
Function(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
Symbol symbol,
|
Symbol symbol,
|
||||||
ParameterList params,
|
ParameterList params,
|
||||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::GroupAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
GroupAttribute::GroupAttribute(ProgramID pid, const Source& src, uint32_t val)
|
GroupAttribute::GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
|
||||||
: Base(pid, src), value(val) {}
|
: Base(pid, nid, src), value(val) {}
|
||||||
|
|
||||||
GroupAttribute::~GroupAttribute() = default;
|
GroupAttribute::~GroupAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param value the group value
|
/// @param value the group value
|
||||||
GroupAttribute(ProgramID pid, const Source& src, uint32_t value);
|
GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
|
||||||
~GroupAttribute() override;
|
~GroupAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -20,7 +20,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::I32);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
I32::I32(ProgramID pid, const Source& src) : Base(pid, src) {}
|
I32::I32(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, src) {}
|
||||||
|
|
||||||
I32::I32(I32&&) = default;
|
I32::I32(I32&&) = default;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ class I32 final : public Castable<I32, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
I32(ProgramID pid, const Source& src);
|
I32(ProgramID pid, NodeID nid, const Source& src);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
I32(I32&&);
|
I32(I32&&);
|
||||||
~I32() override;
|
~I32() override;
|
||||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IdAttribute::IdAttribute(ProgramID pid, const Source& src, uint32_t val)
|
IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
|
||||||
: Base(pid, src), value(val) {}
|
: Base(pid, nid, src), value(val) {}
|
||||||
|
|
||||||
IdAttribute::~IdAttribute() = default;
|
IdAttribute::~IdAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class IdAttribute final : public Castable<IdAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// Create an id attribute.
|
/// Create an id attribute.
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param val the numeric id value
|
/// @param val the numeric id value
|
||||||
IdAttribute(ProgramID pid, const Source& src, uint32_t val);
|
IdAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val);
|
||||||
~IdAttribute() override;
|
~IdAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -20,8 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdentifierExpression);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IdentifierExpression::IdentifierExpression(ProgramID pid, const Source& src, Symbol sym)
|
IdentifierExpression::IdentifierExpression(ProgramID pid, NodeID nid, const Source& src, Symbol sym)
|
||||||
: Base(pid, src), symbol(sym) {
|
: Base(pid, nid, src), symbol(sym) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, symbol, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, symbol, program_id);
|
||||||
TINT_ASSERT(AST, symbol.IsValid());
|
TINT_ASSERT(AST, symbol.IsValid());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,10 @@ class IdentifierExpression final : public Castable<IdentifierExpression, Express
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param sym the symbol for the identifier
|
/// @param sym the symbol for the identifier
|
||||||
IdentifierExpression(ProgramID pid, const Source& src, Symbol sym);
|
IdentifierExpression(ProgramID pid, NodeID nid, const Source& src, Symbol sym);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
IdentifierExpression(IdentifierExpression&&);
|
IdentifierExpression(IdentifierExpression&&);
|
||||||
~IdentifierExpression() override;
|
~IdentifierExpression() override;
|
||||||
|
|
|
@ -21,11 +21,12 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IfStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IfStatement::IfStatement(ProgramID pid,
|
IfStatement::IfStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* cond,
|
const Expression* cond,
|
||||||
const BlockStatement* b,
|
const BlockStatement* b,
|
||||||
const Statement* else_stmt)
|
const Statement* else_stmt)
|
||||||
: Base(pid, src), condition(cond), body(b), else_statement(else_stmt) {
|
: Base(pid, nid, src), condition(cond), body(b), else_statement(else_stmt) {
|
||||||
TINT_ASSERT(AST, condition);
|
TINT_ASSERT(AST, condition);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, condition, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, condition, program_id);
|
||||||
TINT_ASSERT(AST, body);
|
TINT_ASSERT(AST, body);
|
||||||
|
|
|
@ -27,11 +27,13 @@ class IfStatement final : public Castable<IfStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param condition the if condition
|
/// @param condition the if condition
|
||||||
/// @param body the if body
|
/// @param body the if body
|
||||||
/// @param else_stmt the else statement, or nullptr
|
/// @param else_stmt the else statement, or nullptr
|
||||||
IfStatement(ProgramID pid,
|
IfStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* condition,
|
const Expression* condition,
|
||||||
const BlockStatement* body,
|
const BlockStatement* body,
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IncrementDecrementStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IncrementDecrementStatement::IncrementDecrementStatement(ProgramID pid,
|
IncrementDecrementStatement::IncrementDecrementStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* l,
|
const Expression* l,
|
||||||
bool inc)
|
bool inc)
|
||||||
: Base(pid, src), lhs(l), increment(inc) {
|
: Base(pid, nid, src), lhs(l), increment(inc) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, lhs, program_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,15 @@ class IncrementDecrementStatement final : public Castable<IncrementDecrementStat
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param lhs the LHS expression
|
/// @param lhs the LHS expression
|
||||||
/// @param inc `true` for increment, `false` for decrement
|
/// @param inc `true` for increment, `false` for decrement
|
||||||
IncrementDecrementStatement(ProgramID pid, const Source& src, const Expression* lhs, bool inc);
|
IncrementDecrementStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const Expression* lhs,
|
||||||
|
bool inc);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
IncrementDecrementStatement(IncrementDecrementStatement&&);
|
IncrementDecrementStatement(IncrementDecrementStatement&&);
|
||||||
~IncrementDecrementStatement() override;
|
~IncrementDecrementStatement() override;
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IndexAccessorExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IndexAccessorExpression::IndexAccessorExpression(ProgramID pid,
|
IndexAccessorExpression::IndexAccessorExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* obj,
|
const Expression* obj,
|
||||||
const Expression* idx)
|
const Expression* idx)
|
||||||
: Base(pid, src), object(obj), index(idx) {
|
: Base(pid, nid, src), object(obj), index(idx) {
|
||||||
TINT_ASSERT(AST, object);
|
TINT_ASSERT(AST, object);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, object, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, object, program_id);
|
||||||
TINT_ASSERT(AST, idx);
|
TINT_ASSERT(AST, idx);
|
||||||
|
|
|
@ -23,11 +23,13 @@ namespace tint::ast {
|
||||||
class IndexAccessorExpression final : public Castable<IndexAccessorExpression, Expression> {
|
class IndexAccessorExpression final : public Castable<IndexAccessorExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the index accessor source
|
/// @param source the index accessor source
|
||||||
/// @param obj the object
|
/// @param obj the object
|
||||||
/// @param idx the index expression
|
/// @param idx the index expression
|
||||||
IndexAccessorExpression(ProgramID program_id,
|
IndexAccessorExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Expression* obj,
|
const Expression* obj,
|
||||||
const Expression* idx);
|
const Expression* idx);
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IntLiteralExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
IntLiteralExpression::IntLiteralExpression(ProgramID pid,
|
IntLiteralExpression::IntLiteralExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
int64_t val,
|
int64_t val,
|
||||||
Suffix suf)
|
Suffix suf)
|
||||||
: Base(pid, src), value(val), suffix(suf) {}
|
: Base(pid, nid, src), value(val), suffix(suf) {}
|
||||||
|
|
||||||
IntLiteralExpression::~IntLiteralExpression() = default;
|
IntLiteralExpression::~IntLiteralExpression() = default;
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,11 @@ class IntLiteralExpression : public Castable<IntLiteralExpression, LiteralExpres
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param val the literal value
|
/// @param val the literal value
|
||||||
/// @param suf the literal suffix
|
/// @param suf the literal suffix
|
||||||
IntLiteralExpression(ProgramID pid, const Source& src, int64_t val, Suffix suf);
|
IntLiteralExpression(ProgramID pid, NodeID nid, const Source& src, int64_t val, Suffix suf);
|
||||||
|
|
||||||
~IntLiteralExpression() override;
|
~IntLiteralExpression() override;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InternalAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
InternalAttribute::InternalAttribute(ProgramID pid) : Base(pid, Source{}) {}
|
InternalAttribute::InternalAttribute(ProgramID pid, NodeID nid) : Base(pid, nid, Source{}) {}
|
||||||
|
|
||||||
InternalAttribute::~InternalAttribute() = default;
|
InternalAttribute::~InternalAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ class InternalAttribute : public Castable<InternalAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param program_id the identifier of the program that owns this node
|
||||||
explicit InternalAttribute(ProgramID program_id);
|
/// @param nid the unique node identifier
|
||||||
|
explicit InternalAttribute(ProgramID program_id, NodeID nid);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~InternalAttribute() override;
|
~InternalAttribute() override;
|
||||||
|
|
|
@ -23,10 +23,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InterpolateAttribute);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
InterpolateAttribute::InterpolateAttribute(ProgramID pid,
|
InterpolateAttribute::InterpolateAttribute(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
InterpolationType ty,
|
InterpolationType ty,
|
||||||
InterpolationSampling smpl)
|
InterpolationSampling smpl)
|
||||||
: Base(pid, src), type(ty), sampling(smpl) {}
|
: Base(pid, nid, src), type(ty), sampling(smpl) {}
|
||||||
|
|
||||||
InterpolateAttribute::~InterpolateAttribute() = default;
|
InterpolateAttribute::~InterpolateAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,12 @@ class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribu
|
||||||
public:
|
public:
|
||||||
/// Create an interpolate attribute.
|
/// Create an interpolate attribute.
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param type the interpolation type
|
/// @param type the interpolation type
|
||||||
/// @param sampling the interpolation sampling
|
/// @param sampling the interpolation sampling
|
||||||
InterpolateAttribute(ProgramID pid,
|
InterpolateAttribute(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
InterpolationType type,
|
InterpolationType type,
|
||||||
InterpolationSampling sampling);
|
InterpolationSampling sampling);
|
||||||
|
|
|
@ -20,7 +20,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::InvariantAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
InvariantAttribute::InvariantAttribute(ProgramID pid, const Source& src) : Base(pid, src) {}
|
InvariantAttribute::InvariantAttribute(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
InvariantAttribute::~InvariantAttribute() = default;
|
InvariantAttribute::~InvariantAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,9 @@ class InvariantAttribute final : public Castable<InvariantAttribute, Attribute>
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
InvariantAttribute(ProgramID pid, const Source& src);
|
InvariantAttribute(ProgramID pid, NodeID nid, const Source& src);
|
||||||
~InvariantAttribute() override;
|
~InvariantAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -21,12 +21,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Let);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Let::Let(ProgramID pid,
|
Let::Let(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Symbol& sym,
|
const Symbol& sym,
|
||||||
const ast::Type* ty,
|
const ast::Type* ty,
|
||||||
const Expression* ctor,
|
const Expression* ctor,
|
||||||
AttributeList attrs)
|
AttributeList attrs)
|
||||||
: Base(pid, src, sym, ty, ctor, attrs) {
|
: Base(pid, nid, src, sym, ty, ctor, attrs) {
|
||||||
TINT_ASSERT(AST, ctor != nullptr);
|
TINT_ASSERT(AST, ctor != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,15 @@ namespace tint::ast {
|
||||||
class Let final : public Castable<Let, Variable> {
|
class Let final : public Castable<Let, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'let' variable
|
/// Create a 'let' variable
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the variable source
|
/// @param source the variable source
|
||||||
/// @param sym the variable symbol
|
/// @param sym the variable symbol
|
||||||
/// @param type the declared variable type
|
/// @param type the declared variable type
|
||||||
/// @param constructor the constructor expression
|
/// @param constructor the constructor expression
|
||||||
/// @param attributes the variable attributes
|
/// @param attributes the variable attributes
|
||||||
Let(ProgramID program_id,
|
Let(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Symbol& sym,
|
const Symbol& sym,
|
||||||
const ast::Type* type,
|
const ast::Type* type,
|
||||||
|
|
|
@ -18,7 +18,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LiteralExpression);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
LiteralExpression::LiteralExpression(ProgramID pid, const Source& src) : Base(pid, src) {}
|
LiteralExpression::LiteralExpression(ProgramID pid, NodeID nid, const Source& src)
|
||||||
|
: Base(pid, nid, src) {}
|
||||||
|
|
||||||
LiteralExpression::~LiteralExpression() = default;
|
LiteralExpression::~LiteralExpression() = default;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,9 @@ class LiteralExpression : public Castable<LiteralExpression, Expression> {
|
||||||
protected:
|
protected:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the input source
|
/// @param src the input source
|
||||||
LiteralExpression(ProgramID pid, const Source& src);
|
LiteralExpression(ProgramID pid, NodeID nid, const Source& src);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace tint::ast
|
} // namespace tint::ast
|
||||||
|
|
|
@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LocationAttribute);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
LocationAttribute::LocationAttribute(ProgramID pid, const Source& src, uint32_t val)
|
LocationAttribute::LocationAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val)
|
||||||
: Base(pid, src), value(val) {}
|
: Base(pid, nid, src), value(val) {}
|
||||||
|
|
||||||
LocationAttribute::~LocationAttribute() = default;
|
LocationAttribute::~LocationAttribute() = default;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,10 @@ class LocationAttribute final : public Castable<LocationAttribute, Attribute> {
|
||||||
public:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param value the location value
|
/// @param value the location value
|
||||||
LocationAttribute(ProgramID pid, const Source& src, uint32_t value);
|
LocationAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value);
|
||||||
~LocationAttribute() override;
|
~LocationAttribute() override;
|
||||||
|
|
||||||
/// @returns the WGSL name for the attribute
|
/// @returns the WGSL name for the attribute
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::LoopStatement);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
LoopStatement::LoopStatement(ProgramID pid,
|
LoopStatement::LoopStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const BlockStatement* b,
|
const BlockStatement* b,
|
||||||
const BlockStatement* cont)
|
const BlockStatement* cont)
|
||||||
: Base(pid, src), body(b), continuing(cont) {
|
: Base(pid, nid, src), body(b), continuing(cont) {
|
||||||
TINT_ASSERT(AST, body);
|
TINT_ASSERT(AST, body);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, continuing, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, continuing, program_id);
|
||||||
|
|
|
@ -23,11 +23,13 @@ namespace tint::ast {
|
||||||
class LoopStatement final : public Castable<LoopStatement, Statement> {
|
class LoopStatement final : public Castable<LoopStatement, Statement> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the loop statement source
|
/// @param source the loop statement source
|
||||||
/// @param body the body statements
|
/// @param body the body statements
|
||||||
/// @param continuing the continuing statements
|
/// @param continuing the continuing statements
|
||||||
LoopStatement(ProgramID program_id,
|
LoopStatement(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const BlockStatement* body,
|
const BlockStatement* body,
|
||||||
const BlockStatement* continuing);
|
const BlockStatement* continuing);
|
||||||
|
|
|
@ -20,8 +20,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::Matrix);
|
||||||
|
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
Matrix::Matrix(ProgramID pid, const Source& src, const Type* subtype, uint32_t r, uint32_t c)
|
Matrix::Matrix(ProgramID pid,
|
||||||
: Base(pid, src), type(subtype), rows(r), columns(c) {
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const Type* subtype,
|
||||||
|
uint32_t r,
|
||||||
|
uint32_t c)
|
||||||
|
: Base(pid, nid, src), type(subtype), rows(r), columns(c) {
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, subtype, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, subtype, program_id);
|
||||||
TINT_ASSERT(AST, rows > 1);
|
TINT_ASSERT(AST, rows > 1);
|
||||||
TINT_ASSERT(AST, rows < 5);
|
TINT_ASSERT(AST, rows < 5);
|
||||||
|
|
|
@ -26,13 +26,19 @@ class Matrix final : public Castable<Matrix, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param src the source of this node
|
/// @param src the source of this node
|
||||||
/// @param subtype the declared type of the matrix components. May be null for
|
/// @param subtype the declared type of the matrix components. May be null for
|
||||||
/// matrix constructors, where the element type will be inferred from
|
/// matrix constructors, where the element type will be inferred from
|
||||||
/// the constructor arguments
|
/// the constructor arguments
|
||||||
/// @param rows the number of rows in the matrix
|
/// @param rows the number of rows in the matrix
|
||||||
/// @param columns the number of columns in the matrix
|
/// @param columns the number of columns in the matrix
|
||||||
Matrix(ProgramID pid, const Source& src, const Type* subtype, uint32_t rows, uint32_t columns);
|
Matrix(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
|
const Source& src,
|
||||||
|
const Type* subtype,
|
||||||
|
uint32_t rows,
|
||||||
|
uint32_t columns);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Matrix(Matrix&&);
|
Matrix(Matrix&&);
|
||||||
~Matrix() override;
|
~Matrix() override;
|
||||||
|
|
|
@ -21,10 +21,11 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::MemberAccessorExpression);
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
MemberAccessorExpression::MemberAccessorExpression(ProgramID pid,
|
MemberAccessorExpression::MemberAccessorExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& src,
|
const Source& src,
|
||||||
const Expression* str,
|
const Expression* str,
|
||||||
const IdentifierExpression* mem)
|
const IdentifierExpression* mem)
|
||||||
: Base(pid, src), structure(str), member(mem) {
|
: Base(pid, nid, src), structure(str), member(mem) {
|
||||||
TINT_ASSERT(AST, structure);
|
TINT_ASSERT(AST, structure);
|
||||||
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, structure, program_id);
|
TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, structure, program_id);
|
||||||
TINT_ASSERT(AST, member);
|
TINT_ASSERT(AST, member);
|
||||||
|
|
|
@ -23,11 +23,13 @@ namespace tint::ast {
|
||||||
class MemberAccessorExpression final : public Castable<MemberAccessorExpression, Expression> {
|
class MemberAccessorExpression final : public Castable<MemberAccessorExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param program_id the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
/// @param nid the unique node identifier
|
||||||
/// @param source the member accessor expression source
|
/// @param source the member accessor expression source
|
||||||
/// @param structure the structure
|
/// @param structure the structure
|
||||||
/// @param member the member
|
/// @param member the member
|
||||||
MemberAccessorExpression(ProgramID program_id,
|
MemberAccessorExpression(ProgramID pid,
|
||||||
|
NodeID nid,
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const Expression* structure,
|
const Expression* structure,
|
||||||
const IdentifierExpression* member);
|
const IdentifierExpression* member);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue