mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-08 04:59:08 +00:00
sem: Have sem::Type derive from sem::Node
Having a common base class will tighten up some of the dynamic casting that we do. Bug: tint:724 Change-Id: I45c6f200e1ec242ddb08ce75bd1c4c037a21a38d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49882 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
a0174e613f
commit
58750eab19
@ -304,7 +304,10 @@ class ProgramBuilder {
|
|||||||
/// @param args the arguments to pass to the type constructor
|
/// @param args the arguments to pass to the type constructor
|
||||||
/// @returns the node pointer
|
/// @returns the node pointer
|
||||||
template <typename T, typename... ARGS>
|
template <typename T, typename... ARGS>
|
||||||
traits::EnableIfIsType<T, sem::Node>* create(ARGS&&... args) {
|
traits::EnableIf<traits::IsTypeOrDerived<T, sem::Node>::value &&
|
||||||
|
!traits::IsTypeOrDerived<T, sem::Type>::value,
|
||||||
|
T>*
|
||||||
|
create(ARGS&&... args) {
|
||||||
AssertNotMoved();
|
AssertNotMoved();
|
||||||
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
return sem_nodes_.Create<T>(std::forward<ARGS>(args)...);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::Node);
|
|||||||
namespace tint {
|
namespace tint {
|
||||||
namespace sem {
|
namespace sem {
|
||||||
|
|
||||||
|
Node::Node() = default;
|
||||||
|
|
||||||
|
Node::Node(const Node&) = default;
|
||||||
|
|
||||||
Node::~Node() = default;
|
Node::~Node() = default;
|
||||||
|
|
||||||
} // namespace sem
|
} // namespace sem
|
||||||
|
@ -23,6 +23,12 @@ namespace sem {
|
|||||||
/// Node is the base class for all semantic nodes
|
/// Node is the base class for all semantic nodes
|
||||||
class Node : public Castable<Node> {
|
class Node : public Castable<Node> {
|
||||||
public:
|
public:
|
||||||
|
/// Constructor
|
||||||
|
Node();
|
||||||
|
|
||||||
|
/// Copy constructor
|
||||||
|
Node(const Node&);
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~Node() override;
|
~Node() override;
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "src/castable.h"
|
#include "src/sem/node.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ namespace sem {
|
|||||||
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
|
enum class MemoryLayout { kUniformBuffer, kStorageBuffer };
|
||||||
|
|
||||||
/// Base class for a type in the system
|
/// Base class for a type in the system
|
||||||
class Type : public Castable<Type> {
|
class Type : public Castable<Type, Node> {
|
||||||
public:
|
public:
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Type(Type&&);
|
Type(Type&&);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user