Use std::variant to represent TSpirvTypeParameter
This PR is try to address the review comment: https://github.com/KhronosGroup/glslang/pull/3253#discussion_r1254932979.
This commit is contained in:
parent
afe6e781bd
commit
323836e46b
3 changed files with 35 additions and 29 deletions
|
|
@ -39,6 +39,7 @@
|
|||
// GL_EXT_spirv_intrinsics
|
||||
//
|
||||
#include "Common.h"
|
||||
#include <variant>
|
||||
|
||||
namespace glslang {
|
||||
|
||||
|
|
@ -96,23 +97,27 @@ struct TSpirvInstruction {
|
|||
struct TSpirvTypeParameter {
|
||||
POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
|
||||
|
||||
TSpirvTypeParameter(const TIntermConstantUnion* arg)
|
||||
{
|
||||
constant = arg;
|
||||
type = nullptr;
|
||||
}
|
||||
TSpirvTypeParameter(const TIntermConstantUnion* arg) { value = arg; }
|
||||
TSpirvTypeParameter(const TType* arg) { value = arg; }
|
||||
|
||||
TSpirvTypeParameter(const TType *arg)
|
||||
const TIntermConstantUnion* getAsConstant() const
|
||||
{
|
||||
constant = nullptr;
|
||||
type = arg;
|
||||
if (value.index() == 0)
|
||||
return std::get<const TIntermConstantUnion*>(value);
|
||||
return nullptr;
|
||||
}
|
||||
const TType* getAsType() const
|
||||
{
|
||||
if (value.index() == 1)
|
||||
return std::get<const TType*>(value);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool operator==(const TSpirvTypeParameter& rhs) const;
|
||||
bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
|
||||
|
||||
const TIntermConstantUnion* constant; // Constant expression
|
||||
const TType* type; // Type specifier
|
||||
// Parameter value: constant expression or type specifier
|
||||
std::variant<const TIntermConstantUnion*, const TType*> value;
|
||||
};
|
||||
|
||||
typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue