Move castable into utils.
The Castable class is used by utils/. This Cl moves the implementation into the utils/ folder. The `Is` and `As` methods are added into the `tint` namespace to make usage shorter. Change-Id: I0decedb92ebed01b6aa12d2e3efa7190742e9a33 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127402 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
a965f520f9
commit
12fa303899
|
@ -14,7 +14,7 @@
|
||||||
* Do not use C++ exceptions
|
* Do not use C++ exceptions
|
||||||
|
|
||||||
* Do not use C++ RTTI.
|
* Do not use C++ RTTI.
|
||||||
Instead, use `tint::Castable::As<T>()` from
|
Instead, use `tint::utils::Castable::As<T>()` from
|
||||||
[src/castable.h](../src/castable.h)
|
[src/castable.h](../src/castable.h)
|
||||||
|
|
||||||
* Generally, avoid `assert`. Instead, issue a [diagnostic](../src/diagnostic.h)
|
* Generally, avoid `assert`. Instead, issue a [diagnostic](../src/diagnostic.h)
|
||||||
|
|
|
@ -195,8 +195,6 @@ template("libtint_source_set") {
|
||||||
|
|
||||||
libtint_source_set("libtint_base_src") {
|
libtint_source_set("libtint_base_src") {
|
||||||
sources = [
|
sources = [
|
||||||
"castable.cc",
|
|
||||||
"castable.h",
|
|
||||||
"debug.cc",
|
"debug.cc",
|
||||||
"debug.h",
|
"debug.h",
|
||||||
"diagnostic/diagnostic.cc",
|
"diagnostic/diagnostic.cc",
|
||||||
|
@ -222,6 +220,8 @@ libtint_source_set("libtint_base_src") {
|
||||||
"utils/bitset.h",
|
"utils/bitset.h",
|
||||||
"utils/block_allocator.h",
|
"utils/block_allocator.h",
|
||||||
"utils/bump_allocator.h",
|
"utils/bump_allocator.h",
|
||||||
|
"utils/castable.cc",
|
||||||
|
"utils/castable.h",
|
||||||
"utils/compiler_macros.h",
|
"utils/compiler_macros.h",
|
||||||
"utils/concat.h",
|
"utils/concat.h",
|
||||||
"utils/crc32.h",
|
"utils/crc32.h",
|
||||||
|
@ -1590,6 +1590,7 @@ if (tint_build_unittests) {
|
||||||
"utils/bitset_test.cc",
|
"utils/bitset_test.cc",
|
||||||
"utils/block_allocator_test.cc",
|
"utils/block_allocator_test.cc",
|
||||||
"utils/bump_allocator_test.cc",
|
"utils/bump_allocator_test.cc",
|
||||||
|
"utils/castable_test.cc",
|
||||||
"utils/crc32_test.cc",
|
"utils/crc32_test.cc",
|
||||||
"utils/defer_test.cc",
|
"utils/defer_test.cc",
|
||||||
"utils/enum_set_test.cc",
|
"utils/enum_set_test.cc",
|
||||||
|
@ -1982,7 +1983,6 @@ if (tint_build_unittests) {
|
||||||
|
|
||||||
tint_unittests_source_set("tint_unittests_base_src") {
|
tint_unittests_source_set("tint_unittests_base_src") {
|
||||||
sources = [
|
sources = [
|
||||||
"castable_test.cc",
|
|
||||||
"debug_test.cc",
|
"debug_test.cc",
|
||||||
"number_test.cc",
|
"number_test.cc",
|
||||||
"reflection_test.cc",
|
"reflection_test.cc",
|
||||||
|
|
|
@ -230,8 +230,6 @@ list(APPEND TINT_LIB_SRCS
|
||||||
ast/while_statement.h
|
ast/while_statement.h
|
||||||
ast/workgroup_attribute.cc
|
ast/workgroup_attribute.cc
|
||||||
ast/workgroup_attribute.h
|
ast/workgroup_attribute.h
|
||||||
castable.cc
|
|
||||||
castable.h
|
|
||||||
clone_context.cc
|
clone_context.cc
|
||||||
clone_context.h
|
clone_context.h
|
||||||
constant/clone_context.h
|
constant/clone_context.h
|
||||||
|
@ -517,6 +515,8 @@ list(APPEND TINT_LIB_SRCS
|
||||||
utils/bitset.h
|
utils/bitset.h
|
||||||
utils/block_allocator.h
|
utils/block_allocator.h
|
||||||
utils/bump_allocator.h
|
utils/bump_allocator.h
|
||||||
|
utils/castable.cc
|
||||||
|
utils/castable.h
|
||||||
utils/compiler_macros.h
|
utils/compiler_macros.h
|
||||||
utils/concat.h
|
utils/concat.h
|
||||||
utils/crc32.h
|
utils/crc32.h
|
||||||
|
@ -882,7 +882,6 @@ if(TINT_BUILD_TESTS)
|
||||||
ast/variable_test.cc
|
ast/variable_test.cc
|
||||||
ast/while_statement_test.cc
|
ast/while_statement_test.cc
|
||||||
ast/workgroup_attribute_test.cc
|
ast/workgroup_attribute_test.cc
|
||||||
castable_test.cc
|
|
||||||
clone_context_test.cc
|
clone_context_test.cc
|
||||||
constant/composite_test.cc
|
constant/composite_test.cc
|
||||||
constant/scalar_test.cc
|
constant/scalar_test.cc
|
||||||
|
@ -996,6 +995,7 @@ if(TINT_BUILD_TESTS)
|
||||||
utils/bitset_test.cc
|
utils/bitset_test.cc
|
||||||
utils/block_allocator_test.cc
|
utils/block_allocator_test.cc
|
||||||
utils/bump_allocator_test.cc
|
utils/bump_allocator_test.cc
|
||||||
|
utils/castable_test.cc
|
||||||
utils/crc32_test.cc
|
utils/crc32_test.cc
|
||||||
utils/defer_test.cc
|
utils/defer_test.cc
|
||||||
utils/enum_set_test.cc
|
utils/enum_set_test.cc
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// Base class for IndexAccessorExpression and MemberAccessorExpression
|
/// Base class for IndexAccessorExpression and MemberAccessorExpression
|
||||||
class AccessorExpression : public Castable<AccessorExpression, Expression> {
|
class AccessorExpression : public utils::Castable<AccessorExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A type alias type. Holds a name and pointer to another type.
|
/// A type alias type. Holds a name and pointer to another type.
|
||||||
class Alias final : public Castable<Alias, TypeDecl> {
|
class Alias final : public utils::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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An assignment statement
|
/// An assignment statement
|
||||||
class AssignmentStatement final : public Castable<AssignmentStatement, Statement> {
|
class AssignmentStatement final : public utils::Castable<AssignmentStatement, 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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// The base class for all attributes
|
/// The base class for all attributes
|
||||||
class Attribute : public Castable<Attribute, Node> {
|
class Attribute : public utils::Castable<Attribute, Node> {
|
||||||
public:
|
public:
|
||||||
~Attribute() override;
|
~Attribute() override;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ enum class BinaryOp {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An binary expression
|
/// An binary expression
|
||||||
class BinaryExpression final : public Castable<BinaryExpression, Expression> {
|
class BinaryExpression final : public utils::Castable<BinaryExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A binding attribute
|
/// A binding attribute
|
||||||
class BindingAttribute final : public Castable<BindingAttribute, Attribute> {
|
class BindingAttribute final : public utils::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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A bitcast expression
|
/// A bitcast expression
|
||||||
class BitcastExpression final : public Castable<BitcastExpression, Expression> {
|
class BitcastExpression final : public utils::Castable<BitcastExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Attribute;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A block statement
|
/// A block statement
|
||||||
class BlockStatement final : public Castable<BlockStatement, Statement> {
|
class BlockStatement final : public utils::Castable<BlockStatement, 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
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A boolean literal
|
/// A boolean literal
|
||||||
class BoolLiteralExpression final : public Castable<BoolLiteralExpression, LiteralExpression> {
|
class BoolLiteralExpression final
|
||||||
|
: public utils::Castable<BoolLiteralExpression, LiteralExpression> {
|
||||||
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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A break-if statement
|
/// A break-if statement
|
||||||
class BreakIfStatement final : public Castable<BreakIfStatement, Statement> {
|
class BreakIfStatement final : public utils::Castable<BreakIfStatement, 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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An break statement
|
/// An break statement
|
||||||
class BreakStatement final : public Castable<BreakStatement, Statement> {
|
class BreakStatement final : public utils::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
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Expression;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A builtin attribute
|
/// A builtin attribute
|
||||||
class BuiltinAttribute final : public Castable<BuiltinAttribute, Attribute> {
|
class BuiltinAttribute final : public utils::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
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace tint::ast {
|
||||||
/// * sem::Builtin
|
/// * sem::Builtin
|
||||||
/// * sem::ValueConstructor
|
/// * sem::ValueConstructor
|
||||||
/// * sem::ValueConversion
|
/// * sem::ValueConversion
|
||||||
class CallExpression final : public Castable<CallExpression, Expression> {
|
class CallExpression final : public utils::Castable<CallExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A call expression
|
/// A call expression
|
||||||
class CallStatement final : public Castable<CallStatement, Statement> {
|
class CallStatement final : public utils::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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A case selector
|
/// A case selector
|
||||||
class CaseSelector final : public Castable<CaseSelector, Node> {
|
class CaseSelector final : public utils::Castable<CaseSelector, Node> {
|
||||||
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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A case statement
|
/// A case statement
|
||||||
class CaseStatement final : public Castable<CaseStatement, Statement> {
|
class CaseStatement final : public utils::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
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A compound assignment statement
|
/// A compound assignment statement
|
||||||
class CompoundAssignmentStatement final : public Castable<CompoundAssignmentStatement, Statement> {
|
class CompoundAssignmentStatement final
|
||||||
|
: public utils::Castable<CompoundAssignmentStatement, 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
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace tint::ast {
|
||||||
/// const max_f32 : f32 = 0x1.fffffep+127; // f32 typed constant
|
/// const max_f32 : f32 = 0x1.fffffep+127; // f32 typed constant
|
||||||
/// ```
|
/// ```
|
||||||
/// @see https://www.w3.org/TR/WGSL/#creation-time-consts
|
/// @see https://www.w3.org/TR/WGSL/#creation-time-consts
|
||||||
class Const final : public Castable<Const, Variable> {
|
class Const final : public utils::Castable<Const, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'const' creation-time value variable.
|
/// Create a 'const' creation-time value variable.
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A `const_assert` statement
|
/// A `const_assert` statement
|
||||||
class ConstAssert final : public Castable<ConstAssert, Statement> {
|
class ConstAssert final : public utils::Castable<ConstAssert, 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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An continue statement
|
/// An continue statement
|
||||||
class ContinueStatement final : public Castable<ContinueStatement, Statement> {
|
class ContinueStatement final : public utils::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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A diagnostic attribute
|
/// A diagnostic attribute
|
||||||
class DiagnosticAttribute final : public Castable<DiagnosticAttribute, Attribute> {
|
class DiagnosticAttribute final : public utils::Castable<DiagnosticAttribute, 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
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace tint::ast {
|
||||||
/// // Turn off diagnostics for derivative uniformity violations.
|
/// // Turn off diagnostics for derivative uniformity violations.
|
||||||
/// diagnostic(off, derivative_uniformity);
|
/// diagnostic(off, derivative_uniformity);
|
||||||
/// ```
|
/// ```
|
||||||
class DiagnosticDirective final : public Castable<DiagnosticDirective, Node> {
|
class DiagnosticDirective final : public utils::Castable<DiagnosticDirective, 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
|
||||||
|
|
|
@ -53,7 +53,7 @@ enum class DisabledValidation {
|
||||||
/// violations. Typically generated by transforms that need to produce ASTs that
|
/// violations. Typically generated by transforms that need to produce ASTs that
|
||||||
/// would otherwise cause validation errors.
|
/// would otherwise cause validation errors.
|
||||||
class DisableValidationAttribute final
|
class DisableValidationAttribute final
|
||||||
: public Castable<DisableValidationAttribute, InternalAttribute> {
|
: public utils::Castable<DisableValidationAttribute, InternalAttribute> {
|
||||||
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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A discard statement
|
/// A discard statement
|
||||||
class DiscardStatement final : public Castable<DiscardStatement, Statement> {
|
class DiscardStatement final : public utils::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
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace tint::ast {
|
||||||
/// // Enable an extension named "f16"
|
/// // Enable an extension named "f16"
|
||||||
/// enable f16;
|
/// enable f16;
|
||||||
/// ```
|
/// ```
|
||||||
class Enable final : public Castable<Enable, Node> {
|
class Enable final : public utils::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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// Base expression class
|
/// Base expression class
|
||||||
class Expression : public Castable<Expression, Node> {
|
class Expression : public utils::Castable<Expression, Node> {
|
||||||
public:
|
public:
|
||||||
~Expression() override;
|
~Expression() override;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace tint::ast {
|
||||||
/// ```
|
/// ```
|
||||||
/// enable f16;
|
/// enable f16;
|
||||||
/// ```
|
/// ```
|
||||||
class Extension final : public Castable<Extension, Node> {
|
class Extension final : public utils::Castable<Extension, 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
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A float literal
|
/// A float literal
|
||||||
class FloatLiteralExpression final : public Castable<FloatLiteralExpression, LiteralExpression> {
|
class FloatLiteralExpression final
|
||||||
|
: public utils::Castable<FloatLiteralExpression, LiteralExpression> {
|
||||||
public:
|
public:
|
||||||
/// Literal suffix
|
/// Literal suffix
|
||||||
enum class Suffix {
|
enum class Suffix {
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace tint::ast {
|
||||||
class Expression;
|
class Expression;
|
||||||
|
|
||||||
/// A for loop statement
|
/// A for loop statement
|
||||||
class ForLoopStatement final : public Castable<ForLoopStatement, Statement> {
|
class ForLoopStatement final : public utils::Castable<ForLoopStatement, 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
|
||||||
|
|
|
@ -38,7 +38,7 @@ class IdentifierExpression;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A Function statement.
|
/// A Function statement.
|
||||||
class Function final : public Castable<Function, Node> {
|
class Function final : public utils::Castable<Function, Node> {
|
||||||
public:
|
public:
|
||||||
/// Create a function
|
/// Create a function
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A group attribute
|
/// A group attribute
|
||||||
class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
|
class GroupAttribute final : public utils::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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An id attribute for pipeline-overridable constants
|
/// An id attribute for pipeline-overridable constants
|
||||||
class IdAttribute final : public Castable<IdAttribute, Attribute> {
|
class IdAttribute final : public utils::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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An identifier
|
/// An identifier
|
||||||
class Identifier : public Castable<Identifier, Node> {
|
class Identifier : public utils::Castable<Identifier, Node> {
|
||||||
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
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Identifier;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An identifier expression
|
/// An identifier expression
|
||||||
class IdentifierExpression final : public Castable<IdentifierExpression, Expression> {
|
class IdentifierExpression final : public utils::Castable<IdentifierExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An if statement
|
/// An if statement
|
||||||
class IfStatement final : public Castable<IfStatement, Statement> {
|
class IfStatement final : public utils::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
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An increment or decrement statement
|
/// An increment or decrement statement
|
||||||
class IncrementDecrementStatement final : public Castable<IncrementDecrementStatement, Statement> {
|
class IncrementDecrementStatement final
|
||||||
|
: public utils::Castable<IncrementDecrementStatement, 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
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An index accessor expression
|
/// An index accessor expression
|
||||||
class IndexAccessorExpression final : public Castable<IndexAccessorExpression, AccessorExpression> {
|
class IndexAccessorExpression final
|
||||||
|
: public utils::Castable<IndexAccessorExpression, AccessorExpression> {
|
||||||
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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An integer literal. The literal may have an 'i', 'u' or no suffix.
|
/// An integer literal. The literal may have an 'i', 'u' or no suffix.
|
||||||
class IntLiteralExpression final : public Castable<IntLiteralExpression, LiteralExpression> {
|
class IntLiteralExpression final : public utils::Castable<IntLiteralExpression, LiteralExpression> {
|
||||||
public:
|
public:
|
||||||
/// Literal suffix
|
/// Literal suffix
|
||||||
enum class Suffix {
|
enum class Suffix {
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace tint::ast {
|
||||||
/// An attribute used to indicate that a function is tint-internal.
|
/// An attribute used to indicate that a function is tint-internal.
|
||||||
/// These attributes are not produced by generators, but instead are usually
|
/// These attributes are not produced by generators, but instead are usually
|
||||||
/// created by transforms for consumption by a particular backend.
|
/// created by transforms for consumption by a particular backend.
|
||||||
class InternalAttribute : public Castable<InternalAttribute, Attribute> {
|
class InternalAttribute : public utils::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
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Expression;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// An interpolate attribute
|
/// An interpolate attribute
|
||||||
class InterpolateAttribute final : public Castable<InterpolateAttribute, Attribute> {
|
class InterpolateAttribute final : public utils::Castable<InterpolateAttribute, Attribute> {
|
||||||
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
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// The invariant attribute
|
/// The invariant attribute
|
||||||
class InvariantAttribute final : public Castable<InvariantAttribute, Attribute> {
|
class InvariantAttribute final : public utils::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
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace tint::ast {
|
||||||
/// let twice_depth : i32 = width + width; // Must have initializer
|
/// let twice_depth : i32 = width + width; // Must have initializer
|
||||||
/// ```
|
/// ```
|
||||||
/// @see https://www.w3.org/TR/WGSL/#let-decls
|
/// @see https://www.w3.org/TR/WGSL/#let-decls
|
||||||
class Let final : public Castable<Let, Variable> {
|
class Let final : public utils::Castable<Let, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'let' variable
|
/// Create a 'let' variable
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// Base class for a literal value expressions
|
/// Base class for a literal value expressions
|
||||||
class LiteralExpression : public Castable<LiteralExpression, Expression> {
|
class LiteralExpression : public utils::Castable<LiteralExpression, Expression> {
|
||||||
public:
|
public:
|
||||||
~LiteralExpression() override;
|
~LiteralExpression() override;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A location attribute
|
/// A location attribute
|
||||||
class LocationAttribute final : public Castable<LocationAttribute, Attribute> {
|
class LocationAttribute final : public utils::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
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A loop statement
|
/// A loop statement
|
||||||
class LoopStatement final : public Castable<LoopStatement, Statement> {
|
class LoopStatement final : public utils::Castable<LoopStatement, 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
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace tint::ast {
|
||||||
|
|
||||||
/// A member accessor expression
|
/// A member accessor expression
|
||||||
class MemberAccessorExpression final
|
class MemberAccessorExpression final
|
||||||
: public Castable<MemberAccessorExpression, AccessorExpression> {
|
: public utils::Castable<MemberAccessorExpression, AccessorExpression> {
|
||||||
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
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TypeDecl;
|
||||||
|
|
||||||
/// Module holds the top-level AST types, functions and global variables used by
|
/// Module holds the top-level AST types, functions and global variables used by
|
||||||
/// a Program.
|
/// a Program.
|
||||||
class Module final : public Castable<Module, Node> {
|
class Module final : public utils::Castable<Module, Node> {
|
||||||
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
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// The must_use attribute
|
/// The must_use attribute
|
||||||
class MustUseAttribute final : public Castable<MustUseAttribute, Attribute> {
|
class MustUseAttribute final : public utils::Castable<MustUseAttribute, 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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// AST base class node
|
/// AST base class node
|
||||||
class Node : public Castable<Node, Cloneable> {
|
class Node : public utils::Castable<Node, Cloneable> {
|
||||||
public:
|
public:
|
||||||
~Node() override;
|
~Node() override;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace tint::ast {
|
||||||
/// override scale : f32; // No default - must be overridden.
|
/// override scale : f32; // No default - must be overridden.
|
||||||
/// ```
|
/// ```
|
||||||
/// @see https://www.w3.org/TR/WGSL/#override-decls
|
/// @see https://www.w3.org/TR/WGSL/#override-decls
|
||||||
class Override final : public Castable<Override, Variable> {
|
class Override final : public utils::Castable<Override, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create an 'override' pipeline-overridable constant.
|
/// Create an 'override' pipeline-overridable constant.
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace tint::ast {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// @see https://www.w3.org/TR/WGSL/#creation-time-consts
|
/// @see https://www.w3.org/TR/WGSL/#creation-time-consts
|
||||||
class Parameter final : public Castable<Parameter, Variable> {
|
class Parameter final : public utils::Castable<Parameter, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'parameter' creation-time value variable.
|
/// Create a 'parameter' creation-time value variable.
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace tint::ast {
|
||||||
|
|
||||||
/// Represents the `_` of a phony assignment `_ = <expr>`
|
/// Represents the `_` of a phony assignment `_ = <expr>`
|
||||||
/// @see https://www.w3.org/TR/WGSL/#phony-assignment-section
|
/// @see https://www.w3.org/TR/WGSL/#phony-assignment-section
|
||||||
class PhonyExpression final : public Castable<PhonyExpression, Expression> {
|
class PhonyExpression final : public utils::Castable<PhonyExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A return statement
|
/// A return statement
|
||||||
class ReturnStatement final : public Castable<ReturnStatement, Statement> {
|
class ReturnStatement final : public utils::Castable<ReturnStatement, 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
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A workgroup attribute
|
/// A workgroup attribute
|
||||||
class StageAttribute final : public Castable<StageAttribute, Attribute> {
|
class StageAttribute final : public utils::Castable<StageAttribute, 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
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// Base statement class
|
/// Base statement class
|
||||||
class Statement : public Castable<Statement, Node> {
|
class Statement : public utils::Castable<Statement, Node> {
|
||||||
public:
|
public:
|
||||||
~Statement() override;
|
~Statement() override;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace tint::ast {
|
||||||
|
|
||||||
/// A stride attribute used by the SPIR-V reader for strided arrays and
|
/// A stride attribute used by the SPIR-V reader for strided arrays and
|
||||||
/// matrices.
|
/// matrices.
|
||||||
class StrideAttribute final : public Castable<StrideAttribute, Attribute> {
|
class StrideAttribute final : public utils::Castable<StrideAttribute, 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
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A struct statement.
|
/// A struct statement.
|
||||||
class Struct final : public Castable<Struct, TypeDecl> {
|
class Struct final : public utils::Castable<Struct, TypeDecl> {
|
||||||
public:
|
public:
|
||||||
/// Create a new struct statement
|
/// Create a new struct statement
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Identifier;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A struct member statement.
|
/// A struct member statement.
|
||||||
class StructMember final : public Castable<StructMember, Node> {
|
class StructMember final : public utils::Castable<StructMember, Node> {
|
||||||
public:
|
public:
|
||||||
/// Create a new struct member statement
|
/// Create a new struct member statement
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A struct member align attribute
|
/// A struct member align attribute
|
||||||
class StructMemberAlignAttribute final : public Castable<StructMemberAlignAttribute, Attribute> {
|
class StructMemberAlignAttribute final
|
||||||
|
: public utils::Castable<StructMemberAlignAttribute, 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
|
||||||
|
|
|
@ -32,7 +32,8 @@ namespace tint::ast {
|
||||||
/// trivial for the Resolver to handle `@offset(n)` or `@size(n)` /
|
/// trivial for the Resolver to handle `@offset(n)` or `@size(n)` /
|
||||||
/// `@align(n)` attributes, so this is what we do, keeping all the layout
|
/// `@align(n)` attributes, so this is what we do, keeping all the layout
|
||||||
/// logic in one place.
|
/// logic in one place.
|
||||||
class StructMemberOffsetAttribute final : public Castable<StructMemberOffsetAttribute, Attribute> {
|
class StructMemberOffsetAttribute final
|
||||||
|
: public utils::Castable<StructMemberOffsetAttribute, 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
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A struct member size attribute
|
/// A struct member size attribute
|
||||||
class StructMemberSizeAttribute final : public Castable<StructMemberSizeAttribute, Attribute> {
|
class StructMemberSizeAttribute final
|
||||||
|
: public utils::Castable<StructMemberSizeAttribute, 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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A switch statement
|
/// A switch statement
|
||||||
class SwitchStatement final : public Castable<SwitchStatement, Statement> {
|
class SwitchStatement final : public utils::Castable<SwitchStatement, 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
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Expression;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A templated identifier expression
|
/// A templated identifier expression
|
||||||
class TemplatedIdentifier final : public Castable<TemplatedIdentifier, Identifier> {
|
class TemplatedIdentifier final : public utils::Castable<TemplatedIdentifier, Identifier> {
|
||||||
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
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Identifier;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// The base class for type declarations.
|
/// The base class for type declarations.
|
||||||
class TypeDecl : public Castable<TypeDecl, Node> {
|
class TypeDecl : public utils::Castable<TypeDecl, Node> {
|
||||||
public:
|
public:
|
||||||
/// Create a new struct statement
|
/// Create a new struct statement
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A unary op expression
|
/// A unary op expression
|
||||||
class UnaryOpExpression final : public Castable<UnaryOpExpression, Expression> {
|
class UnaryOpExpression final : public utils::Castable<UnaryOpExpression, Expression> {
|
||||||
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
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace tint::ast {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// @see https://www.w3.org/TR/WGSL/#var-decls
|
/// @see https://www.w3.org/TR/WGSL/#var-decls
|
||||||
class Var final : public Castable<Var, Variable> {
|
class Var final : public utils::Castable<Var, Variable> {
|
||||||
public:
|
public:
|
||||||
/// Create a 'var' variable
|
/// Create a 'var' variable
|
||||||
/// @param pid the identifier of the program that owns this node
|
/// @param pid the identifier of the program that owns this node
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace tint::ast {
|
||||||
/// declaration, "override" declaration, "const" declaration, or formal parameter to a function.
|
/// declaration, "override" declaration, "const" declaration, or formal parameter to a function.
|
||||||
///
|
///
|
||||||
/// @see https://www.w3.org/TR/WGSL/#value-decls
|
/// @see https://www.w3.org/TR/WGSL/#value-decls
|
||||||
class Variable : public Castable<Variable, Node> {
|
class Variable : public utils::Castable<Variable, Node> {
|
||||||
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
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A variable declaration statement
|
/// A variable declaration statement
|
||||||
class VariableDeclStatement final : public Castable<VariableDeclStatement, Statement> {
|
class VariableDeclStatement final : public utils::Castable<VariableDeclStatement, 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
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace tint::ast {
|
||||||
class Expression;
|
class Expression;
|
||||||
|
|
||||||
/// A while loop statement
|
/// A while loop statement
|
||||||
class WhileStatement final : public Castable<WhileStatement, Statement> {
|
class WhileStatement final : public utils::Castable<WhileStatement, 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
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Expression;
|
||||||
namespace tint::ast {
|
namespace tint::ast {
|
||||||
|
|
||||||
/// A workgroup attribute
|
/// A workgroup attribute
|
||||||
class WorkgroupAttribute final : public Castable<WorkgroupAttribute, Attribute> {
|
class WorkgroupAttribute final : public utils::Castable<WorkgroupAttribute, 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
|
||||||
|
|
|
@ -97,7 +97,7 @@ const tint::Cloneable* CloneContext::CloneCloneable(const Cloneable* object) {
|
||||||
return object->Clone(this);
|
return object->Clone(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloneContext::CheckedCastFailure(const Cloneable* got, const TypeInfo& expected) {
|
void CloneContext::CheckedCastFailure(const Cloneable* got, const utils::TypeInfo& expected) {
|
||||||
TINT_ICE(Clone, Diagnostics()) << "Cloned object was not of the expected type\n"
|
TINT_ICE(Clone, Diagnostics()) << "Cloned object was not of the expected type\n"
|
||||||
<< "got: " << got->TypeInfo().name << "\n"
|
<< "got: " << got->TypeInfo().name << "\n"
|
||||||
<< "expected: " << expected.name;
|
<< "expected: " << expected.name;
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/debug.h"
|
#include "src/tint/debug.h"
|
||||||
#include "src/tint/program_id.h"
|
#include "src/tint/program_id.h"
|
||||||
#include "src/tint/symbol.h"
|
#include "src/tint/symbol.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/compiler_macros.h"
|
#include "src/tint/utils/compiler_macros.h"
|
||||||
#include "src/tint/utils/hashmap.h"
|
#include "src/tint/utils/hashmap.h"
|
||||||
#include "src/tint/utils/hashset.h"
|
#include "src/tint/utils/hashset.h"
|
||||||
|
@ -49,7 +49,7 @@ ProgramID ProgramIDOf(const Program*);
|
||||||
ProgramID ProgramIDOf(const ProgramBuilder*);
|
ProgramID ProgramIDOf(const ProgramBuilder*);
|
||||||
|
|
||||||
/// Cloneable is the base class for all objects that can be cloned
|
/// Cloneable is the base class for all objects that can be cloned
|
||||||
class Cloneable : public Castable<Cloneable> {
|
class Cloneable : public utils::Castable<Cloneable> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Cloneable();
|
Cloneable();
|
||||||
|
@ -308,18 +308,18 @@ class CloneContext {
|
||||||
using TPtr = utils::traits::ParameterType<F, 0>;
|
using TPtr = utils::traits::ParameterType<F, 0>;
|
||||||
using T = typename std::remove_pointer<TPtr>::type;
|
using T = typename std::remove_pointer<TPtr>::type;
|
||||||
for (auto& transform : transforms_) {
|
for (auto& transform : transforms_) {
|
||||||
bool already_registered = transform.typeinfo->Is(&TypeInfo::Of<T>()) ||
|
bool already_registered = transform.typeinfo->Is(&utils::TypeInfo::Of<T>()) ||
|
||||||
TypeInfo::Of<T>().Is(transform.typeinfo);
|
utils::TypeInfo::Of<T>().Is(transform.typeinfo);
|
||||||
if (TINT_UNLIKELY(already_registered)) {
|
if (TINT_UNLIKELY(already_registered)) {
|
||||||
TINT_ICE(Clone, Diagnostics())
|
TINT_ICE(Clone, Diagnostics()) << "ReplaceAll() called with a handler for type "
|
||||||
<< "ReplaceAll() called with a handler for type " << TypeInfo::Of<T>().name
|
<< utils::TypeInfo::Of<T>().name
|
||||||
<< " that is already handled by a handler for type "
|
<< " that is already handled by a handler for type "
|
||||||
<< transform.typeinfo->name;
|
<< transform.typeinfo->name;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloneableTransform transform;
|
CloneableTransform transform;
|
||||||
transform.typeinfo = &TypeInfo::Of<T>();
|
transform.typeinfo = &utils::TypeInfo::Of<T>();
|
||||||
transform.function = [=](const Cloneable* in) { return replacer(in->As<T>()); };
|
transform.function = [=](const Cloneable* in) { return replacer(in->As<T>()); };
|
||||||
transforms_.Push(std::move(transform));
|
transforms_.Push(std::move(transform));
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -554,8 +554,8 @@ class CloneContext {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~CloneableTransform();
|
~CloneableTransform();
|
||||||
|
|
||||||
// TypeInfo of the Cloneable that the transform operates on
|
// utils::TypeInfo of the Cloneable that the transform operates on
|
||||||
const TypeInfo* typeinfo;
|
const utils::TypeInfo* typeinfo;
|
||||||
std::function<const Cloneable*(const Cloneable*)> function;
|
std::function<const Cloneable*(const Cloneable*)> function;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ class CloneContext {
|
||||||
if (TINT_LIKELY(cast)) {
|
if (TINT_LIKELY(cast)) {
|
||||||
return cast;
|
return cast;
|
||||||
}
|
}
|
||||||
CheckedCastFailure(obj, TypeInfo::Of<TO>());
|
CheckedCastFailure(obj, utils::TypeInfo::Of<TO>());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ class CloneContext {
|
||||||
|
|
||||||
/// Adds an error diagnostic to Diagnostics() that the cloned object was not
|
/// Adds an error diagnostic to Diagnostics() that the cloned object was not
|
||||||
/// of the expected type.
|
/// of the expected type.
|
||||||
void CheckedCastFailure(const Cloneable* got, const TypeInfo& expected);
|
void CheckedCastFailure(const Cloneable* got, const utils::TypeInfo& expected);
|
||||||
|
|
||||||
/// @returns the diagnostic list of #dst
|
/// @returns the diagnostic list of #dst
|
||||||
diag::List& Diagnostics() const;
|
diag::List& Diagnostics() const;
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct Allocator {
|
||||||
utils::BlockAllocator<Cloneable> alloc;
|
utils::BlockAllocator<Cloneable> alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Node : public Castable<Node, Cloneable> {
|
struct Node : public utils::Castable<Node, Cloneable> {
|
||||||
Node(Allocator* alloc,
|
Node(Allocator* alloc,
|
||||||
Symbol n,
|
Symbol n,
|
||||||
const Node* node_a = nullptr,
|
const Node* node_a = nullptr,
|
||||||
|
@ -55,7 +55,7 @@ struct Node : public Castable<Node, Cloneable> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Replaceable : public Castable<Replaceable, Node> {
|
struct Replaceable : public utils::Castable<Replaceable, Node> {
|
||||||
Replaceable(Allocator* alloc,
|
Replaceable(Allocator* alloc,
|
||||||
Symbol n,
|
Symbol n,
|
||||||
const Node* node_a = nullptr,
|
const Node* node_a = nullptr,
|
||||||
|
@ -64,18 +64,18 @@ struct Replaceable : public Castable<Replaceable, Node> {
|
||||||
: Base(alloc, n, node_a, node_b, node_c) {}
|
: Base(alloc, n, node_a, node_b, node_c) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Replacement : public Castable<Replacement, Replaceable> {
|
struct Replacement : public utils::Castable<Replacement, Replaceable> {
|
||||||
Replacement(Allocator* alloc, Symbol n) : Base(alloc, n) {}
|
Replacement(Allocator* alloc, Symbol n) : Base(alloc, n) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NotANode : public Castable<NotANode, Cloneable> {
|
struct NotANode : public utils::Castable<NotANode, Cloneable> {
|
||||||
explicit NotANode(Allocator* alloc) : allocator(alloc) {}
|
explicit NotANode(Allocator* alloc) : allocator(alloc) {}
|
||||||
|
|
||||||
Allocator* const allocator;
|
Allocator* const allocator;
|
||||||
NotANode* Clone(CloneContext*) const override { return allocator->Create<NotANode>(); }
|
NotANode* Clone(CloneContext*) const override { return allocator->Create<NotANode>(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ProgramNode : public Castable<ProgramNode, Cloneable> {
|
struct ProgramNode : public utils::Castable<ProgramNode, Cloneable> {
|
||||||
ProgramNode(Allocator* alloc, ProgramID id, ProgramID cloned_id)
|
ProgramNode(Allocator* alloc, ProgramID id, ProgramID cloned_id)
|
||||||
: allocator(alloc), program_id(id), cloned_program_id(cloned_id) {}
|
: allocator(alloc), program_id(id), cloned_program_id(cloned_id) {}
|
||||||
|
|
||||||
|
@ -1051,7 +1051,7 @@ TEST_F(CloneContextNodeTest, CloneIntoSameBuilder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_SameTypeTwice) {
|
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_SameTypeTwice) {
|
||||||
std::string node_name = TypeInfo::Of<Node>().name;
|
std::string node_name = utils::TypeInfo::Of<Node>().name;
|
||||||
|
|
||||||
EXPECT_FATAL_FAILURE(
|
EXPECT_FATAL_FAILURE(
|
||||||
{
|
{
|
||||||
|
@ -1066,8 +1066,8 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_SameTypeTwice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_BaseThenDerived) {
|
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_BaseThenDerived) {
|
||||||
std::string node_name = TypeInfo::Of<Node>().name;
|
std::string node_name = utils::TypeInfo::Of<Node>().name;
|
||||||
std::string replaceable_name = TypeInfo::Of<Replaceable>().name;
|
std::string replaceable_name = utils::TypeInfo::Of<Replaceable>().name;
|
||||||
|
|
||||||
EXPECT_FATAL_FAILURE(
|
EXPECT_FATAL_FAILURE(
|
||||||
{
|
{
|
||||||
|
@ -1082,8 +1082,8 @@ TEST_F(CloneContextNodeTest, CloneWithReplaceAll_BaseThenDerived) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_DerivedThenBase) {
|
TEST_F(CloneContextNodeTest, CloneWithReplaceAll_DerivedThenBase) {
|
||||||
std::string node_name = TypeInfo::Of<Node>().name;
|
std::string node_name = utils::TypeInfo::Of<Node>().name;
|
||||||
std::string replaceable_name = TypeInfo::Of<Replaceable>().name;
|
std::string replaceable_name = utils::TypeInfo::Of<Replaceable>().name;
|
||||||
|
|
||||||
EXPECT_FATAL_FAILURE(
|
EXPECT_FATAL_FAILURE(
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
#ifndef SRC_TINT_CONSTANT_COMPOSITE_H_
|
#ifndef SRC_TINT_CONSTANT_COMPOSITE_H_
|
||||||
#define SRC_TINT_CONSTANT_COMPOSITE_H_
|
#define SRC_TINT_CONSTANT_COMPOSITE_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/constant/value.h"
|
#include "src/tint/constant/value.h"
|
||||||
#include "src/tint/number.h"
|
#include "src/tint/number.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/hash.h"
|
#include "src/tint/utils/hash.h"
|
||||||
#include "src/tint/utils/vector.h"
|
#include "src/tint/utils/vector.h"
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace tint::constant {
|
||||||
/// Composite may be of a vector, matrix, array or structure type.
|
/// Composite may be of a vector, matrix, array or structure type.
|
||||||
/// If each element is the same type and value, then a Splat would be a more efficient constant
|
/// If each element is the same type and value, then a Splat would be a more efficient constant
|
||||||
/// implementation. Use CreateComposite() to create the appropriate type.
|
/// implementation. Use CreateComposite() to create the appropriate type.
|
||||||
class Composite : public Castable<Composite, Value> {
|
class Composite : public utils::Castable<Composite, Value> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param t the compsite type
|
/// @param t the compsite type
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
#ifndef SRC_TINT_CONSTANT_NODE_H_
|
#ifndef SRC_TINT_CONSTANT_NODE_H_
|
||||||
#define SRC_TINT_CONSTANT_NODE_H_
|
#define SRC_TINT_CONSTANT_NODE_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
#include "src/tint/utils/castable.h"
|
||||||
|
|
||||||
namespace tint::constant {
|
namespace tint::constant {
|
||||||
|
|
||||||
/// Node is the base class for all constant nodes
|
/// Node is the base class for all constant nodes
|
||||||
class Node : public Castable<Node> {
|
class Node : public utils::Castable<Node> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Node();
|
Node();
|
||||||
|
|
|
@ -15,17 +15,17 @@
|
||||||
#ifndef SRC_TINT_CONSTANT_SCALAR_H_
|
#ifndef SRC_TINT_CONSTANT_SCALAR_H_
|
||||||
#define SRC_TINT_CONSTANT_SCALAR_H_
|
#define SRC_TINT_CONSTANT_SCALAR_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/constant/value.h"
|
#include "src/tint/constant/value.h"
|
||||||
#include "src/tint/number.h"
|
#include "src/tint/number.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/hash.h"
|
#include "src/tint/utils/hash.h"
|
||||||
|
|
||||||
namespace tint::constant {
|
namespace tint::constant {
|
||||||
|
|
||||||
/// Scalar holds a single scalar or abstract-numeric value.
|
/// Scalar holds a single scalar or abstract-numeric value.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class Scalar : public Castable<Scalar<T>, Value> {
|
class Scalar : public utils::Castable<Scalar<T>, Value> {
|
||||||
public:
|
public:
|
||||||
static_assert(!std::is_same_v<UnwrapNumber<T>, T> || std::is_same_v<T, bool>,
|
static_assert(!std::is_same_v<UnwrapNumber<T>, T> || std::is_same_v<T, bool>,
|
||||||
"T must be a Number or bool");
|
"T must be a Number or bool");
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
#ifndef SRC_TINT_CONSTANT_SPLAT_H_
|
#ifndef SRC_TINT_CONSTANT_SPLAT_H_
|
||||||
#define SRC_TINT_CONSTANT_SPLAT_H_
|
#define SRC_TINT_CONSTANT_SPLAT_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/constant/composite.h"
|
#include "src/tint/constant/composite.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/vector.h"
|
#include "src/tint/utils/vector.h"
|
||||||
|
|
||||||
namespace tint::constant {
|
namespace tint::constant {
|
||||||
|
@ -26,7 +26,7 @@ namespace tint::constant {
|
||||||
///
|
///
|
||||||
/// Splat is used for zero-initializers, 'splat' initializers, or initializers where each element is
|
/// Splat is used for zero-initializers, 'splat' initializers, or initializers where each element is
|
||||||
/// identical. Splat may be of a vector, matrix, array or structure type.
|
/// identical. Splat may be of a vector, matrix, array or structure type.
|
||||||
class Splat : public Castable<Splat, Value> {
|
class Splat : public utils::Castable<Splat, Value> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param t the splat type
|
/// @param t the splat type
|
||||||
|
|
|
@ -17,16 +17,16 @@
|
||||||
|
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/constant/clone_context.h"
|
#include "src/tint/constant/clone_context.h"
|
||||||
#include "src/tint/constant/node.h"
|
#include "src/tint/constant/node.h"
|
||||||
#include "src/tint/number.h"
|
#include "src/tint/number.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
|
|
||||||
namespace tint::constant {
|
namespace tint::constant {
|
||||||
|
|
||||||
/// Value is the interface to a compile-time evaluated expression value.
|
/// Value is the interface to a compile-time evaluated expression value.
|
||||||
class Value : public Castable<Value, Node> {
|
class Value : public utils::Castable<Value, Node> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Value();
|
Value();
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
#include "src/tint/ast/module.h"
|
#include "src/tint/ast/module.h"
|
||||||
#include "src/tint/ast/variable_decl_statement.h"
|
#include "src/tint/ast/variable_decl_statement.h"
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/program.h"
|
#include "src/tint/program.h"
|
||||||
#include "src/tint/sem/block_statement.h"
|
#include "src/tint/sem/block_statement.h"
|
||||||
#include "src/tint/sem/function.h"
|
#include "src/tint/sem/function.h"
|
||||||
#include "src/tint/sem/statement.h"
|
#include "src/tint/sem/statement.h"
|
||||||
#include "src/tint/sem/variable.h"
|
#include "src/tint/sem/variable.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
|
|
||||||
namespace tint::fuzzers::ast_fuzzer::util {
|
namespace tint::fuzzers::ast_fuzzer::util {
|
||||||
/// @file
|
/// @file
|
||||||
|
|
|
@ -456,7 +456,7 @@ std::vector<ResourceBinding> Inspector::GetWriteOnlyStorageTextureResourceBindin
|
||||||
|
|
||||||
std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
|
std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
|
||||||
const std::string& entry_point,
|
const std::string& entry_point,
|
||||||
const tint::TypeInfo* texture_type,
|
const tint::utils::TypeInfo* texture_type,
|
||||||
ResourceBinding::ResourceType resource_type) {
|
ResourceBinding::ResourceType resource_type) {
|
||||||
auto* func = FindEntryPointByName(entry_point);
|
auto* func = FindEntryPointByName(entry_point);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
|
@ -485,19 +485,20 @@ std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
|
||||||
|
|
||||||
std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||||
const std::string& entry_point) {
|
const std::string& entry_point) {
|
||||||
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::DepthTexture>(),
|
return GetTextureResourceBindings(entry_point, &utils::TypeInfo::Of<type::DepthTexture>(),
|
||||||
ResourceBinding::ResourceType::kDepthTexture);
|
ResourceBinding::ResourceType::kDepthTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ResourceBinding> Inspector::GetDepthMultisampledTextureResourceBindings(
|
std::vector<ResourceBinding> Inspector::GetDepthMultisampledTextureResourceBindings(
|
||||||
const std::string& entry_point) {
|
const std::string& entry_point) {
|
||||||
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::DepthMultisampledTexture>(),
|
return GetTextureResourceBindings(entry_point,
|
||||||
|
&utils::TypeInfo::Of<type::DepthMultisampledTexture>(),
|
||||||
ResourceBinding::ResourceType::kDepthMultisampledTexture);
|
ResourceBinding::ResourceType::kDepthMultisampledTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
|
std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
|
||||||
const std::string& entry_point) {
|
const std::string& entry_point) {
|
||||||
return GetTextureResourceBindings(entry_point, &TypeInfo::Of<type::ExternalTexture>(),
|
return GetTextureResourceBindings(entry_point, &utils::TypeInfo::Of<type::ExternalTexture>(),
|
||||||
ResourceBinding::ResourceType::kExternalTexture);
|
ResourceBinding::ResourceType::kExternalTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ class Inspector {
|
||||||
/// @returns vector of all of the bindings for depth textures.
|
/// @returns vector of all of the bindings for depth textures.
|
||||||
std::vector<ResourceBinding> GetTextureResourceBindings(
|
std::vector<ResourceBinding> GetTextureResourceBindings(
|
||||||
const std::string& entry_point,
|
const std::string& entry_point,
|
||||||
const tint::TypeInfo* texture_type,
|
const tint::utils::TypeInfo* texture_type,
|
||||||
ResourceBinding::ResourceType resource_type);
|
ResourceBinding::ResourceType resource_type);
|
||||||
|
|
||||||
/// @param entry_point name of the entry point to get information about.
|
/// @param entry_point name of the entry point to get information about.
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#ifndef SRC_TINT_IR_BINARY_H_
|
#ifndef SRC_TINT_IR_BINARY_H_
|
||||||
#define SRC_TINT_IR_BINARY_H_
|
#define SRC_TINT_IR_BINARY_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/instruction.h"
|
#include "src/tint/ir/instruction.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// An instruction in the IR.
|
/// An instruction in the IR.
|
||||||
class Binary : public Castable<Binary, Instruction> {
|
class Binary : public utils::Castable<Binary, Instruction> {
|
||||||
public:
|
public:
|
||||||
/// The kind of instruction.
|
/// The kind of instruction.
|
||||||
enum class Kind {
|
enum class Kind {
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#ifndef SRC_TINT_IR_BITCAST_H_
|
#ifndef SRC_TINT_IR_BITCAST_H_
|
||||||
#define SRC_TINT_IR_BITCAST_H_
|
#define SRC_TINT_IR_BITCAST_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/instruction.h"
|
#include "src/tint/ir/instruction.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A bitcast instruction in the IR.
|
/// A bitcast instruction in the IR.
|
||||||
class Bitcast : public Castable<Bitcast, Instruction> {
|
class Bitcast : public utils::Castable<Bitcast, Instruction> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param result the result value
|
/// @param result the result value
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace tint::ir {
|
||||||
/// A flow node comprising a block of statements. The instructions in the block are a linear list of
|
/// A flow node comprising a block of statements. The instructions in the block are a linear list of
|
||||||
/// instructions to execute. The block will branch at the end. The only blocks which do not branch
|
/// instructions to execute. The block will branch at the end. The only blocks which do not branch
|
||||||
/// are the end blocks of functions.
|
/// are the end blocks of functions.
|
||||||
class Block : public Castable<Block, FlowNode> {
|
class Block : public utils::Castable<Block, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Block();
|
Block();
|
||||||
|
|
|
@ -16,16 +16,16 @@
|
||||||
#define SRC_TINT_IR_BUILTIN_H_
|
#define SRC_TINT_IR_BUILTIN_H_
|
||||||
|
|
||||||
#include "src/tint/builtin/function.h"
|
#include "src/tint/builtin/function.h"
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/call.h"
|
#include "src/tint/ir/call.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A value conversion instruction in the IR.
|
/// A value conversion instruction in the IR.
|
||||||
class Builtin : public Castable<Builtin, Call> {
|
class Builtin : public utils::Castable<Builtin, Call> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param result the result value
|
/// @param result the result value
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#ifndef SRC_TINT_IR_CALL_H_
|
#ifndef SRC_TINT_IR_CALL_H_
|
||||||
#define SRC_TINT_IR_CALL_H_
|
#define SRC_TINT_IR_CALL_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/instruction.h"
|
#include "src/tint/ir/instruction.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A Call instruction in the IR.
|
/// A Call instruction in the IR.
|
||||||
class Call : public Castable<Call, Instruction> {
|
class Call : public utils::Castable<Call, Instruction> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param result the result value
|
/// @param result the result value
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Constant in the IR.
|
/// Constant in the IR.
|
||||||
class Constant : public Castable<Constant, Value> {
|
class Constant : public utils::Castable<Constant, Value> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param val the value stored in the constant
|
/// @param val the value stored in the constant
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#ifndef SRC_TINT_IR_CONSTRUCT_H_
|
#ifndef SRC_TINT_IR_CONSTRUCT_H_
|
||||||
#define SRC_TINT_IR_CONSTRUCT_H_
|
#define SRC_TINT_IR_CONSTRUCT_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/call.h"
|
#include "src/tint/ir/call.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A constructor instruction in the IR.
|
/// A constructor instruction in the IR.
|
||||||
class Construct : public Castable<Construct, Call> {
|
class Construct : public utils::Castable<Construct, Call> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param result the result value
|
/// @param result the result value
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#ifndef SRC_TINT_IR_CONVERT_H_
|
#ifndef SRC_TINT_IR_CONVERT_H_
|
||||||
#define SRC_TINT_IR_CONVERT_H_
|
#define SRC_TINT_IR_CONVERT_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/call.h"
|
#include "src/tint/ir/call.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
#include "src/tint/type/type.h"
|
#include "src/tint/type/type.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A value conversion instruction in the IR.
|
/// A value conversion instruction in the IR.
|
||||||
class Convert : public Castable<Convert, Call> {
|
class Convert : public utils::Castable<Convert, Call> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param result the result value
|
/// @param result the result value
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
#ifndef SRC_TINT_IR_FLOW_NODE_H_
|
#ifndef SRC_TINT_IR_FLOW_NODE_H_
|
||||||
#define SRC_TINT_IR_FLOW_NODE_H_
|
#define SRC_TINT_IR_FLOW_NODE_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/vector.h"
|
#include "src/tint/utils/vector.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Base class for flow nodes
|
/// Base class for flow nodes
|
||||||
class FlowNode : public Castable<FlowNode> {
|
class FlowNode : public utils::Castable<FlowNode> {
|
||||||
public:
|
public:
|
||||||
~FlowNode() override;
|
~FlowNode() override;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Terminator;
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// An IR representation of a function
|
/// An IR representation of a function
|
||||||
class Function : public Castable<Function, FlowNode> {
|
class Function : public utils::Castable<Function, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Function();
|
Function();
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Block;
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// A flow node representing an if statement.
|
/// A flow node representing an if statement.
|
||||||
class If : public Castable<If, FlowNode> {
|
class If : public utils::Castable<If, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
If();
|
If();
|
||||||
|
|
|
@ -15,15 +15,15 @@
|
||||||
#ifndef SRC_TINT_IR_INSTRUCTION_H_
|
#ifndef SRC_TINT_IR_INSTRUCTION_H_
|
||||||
#define SRC_TINT_IR_INSTRUCTION_H_
|
#define SRC_TINT_IR_INSTRUCTION_H_
|
||||||
|
|
||||||
#include "src/tint/castable.h"
|
|
||||||
#include "src/tint/ir/value.h"
|
#include "src/tint/ir/value.h"
|
||||||
#include "src/tint/symbol_table.h"
|
#include "src/tint/symbol_table.h"
|
||||||
|
#include "src/tint/utils/castable.h"
|
||||||
#include "src/tint/utils/string_stream.h"
|
#include "src/tint/utils/string_stream.h"
|
||||||
|
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// An instruction in the IR.
|
/// An instruction in the IR.
|
||||||
class Instruction : public Castable<Instruction> {
|
class Instruction : public utils::Castable<Instruction> {
|
||||||
public:
|
public:
|
||||||
Instruction(const Instruction& instr) = delete;
|
Instruction(const Instruction& instr) = delete;
|
||||||
Instruction(Instruction&& instr) = delete;
|
Instruction(Instruction&& instr) = delete;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Flow node describing a loop.
|
/// Flow node describing a loop.
|
||||||
class Loop : public Castable<Loop, FlowNode> {
|
class Loop : public utils::Castable<Loop, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Loop();
|
Loop();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Flow node representing a switch statement
|
/// Flow node representing a switch statement
|
||||||
class Switch : public Castable<Switch, FlowNode> {
|
class Switch : public utils::Castable<Switch, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// A case selector
|
/// A case selector
|
||||||
struct CaseSelector {
|
struct CaseSelector {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace tint::ir {
|
namespace tint::ir {
|
||||||
|
|
||||||
/// Temporary value in the IR.
|
/// Temporary value in the IR.
|
||||||
class Temp : public Castable<Temp, Value> {
|
class Temp : public utils::Castable<Temp, Value> {
|
||||||
public:
|
public:
|
||||||
/// A value id.
|
/// A value id.
|
||||||
using Id = uint32_t;
|
using Id = uint32_t;
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace tint::ir {
|
||||||
|
|
||||||
/// Flow node used as the end of a function. Must only be used as the `end_target` in a function
|
/// Flow node used as the end of a function. Must only be used as the `end_target` in a function
|
||||||
/// flow node. There are no instructions and no branches from this node.
|
/// flow node. There are no instructions and no branches from this node.
|
||||||
class Terminator : public Castable<Terminator, FlowNode> {
|
class Terminator : public utils::Castable<Terminator, FlowNode> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
Terminator();
|
Terminator();
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue