blob: d91252fccc6147e4bd5948228e7ffa0a0fdcf235 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#include "slang-ir-util.h"
namespace Slang
{
bool isPointerOfType(IRInst* type, IROp opCode)
{
if (auto ptrType = as<IRPtrTypeBase>(type))
{
return ptrType->getValueType() && ptrType->getValueType()->getOp() == opCode;
}
return false;
}
Dictionary<IRInst*, IRInst*> buildInterfaceRequirementDict(IRInterfaceType* interfaceType)
{
Dictionary<IRInst*, IRInst*> result;
for (UInt i = 0; i < interfaceType->getOperandCount(); i++)
{
auto entry = as<IRInterfaceRequirementEntry>(interfaceType->getOperand(i));
if (!entry) continue;
result[entry->getRequirementKey()] = entry->getRequirementVal();
}
return result;
}
bool isPointerOfType(IRInst* type, IRInst* elementType)
{
if (auto ptrType = as<IRPtrTypeBase>(type))
{
return ptrType->getValueType() && isTypeEqual(ptrType->getValueType(), (IRType*)elementType);
}
return false;
}
bool isPtrToClassType(IRInst* type)
{
return isPointerOfType(type, kIROp_ClassType);
}
bool isPtrToArrayType(IRInst* type)
{
return isPointerOfType(type, kIROp_ArrayType) || isPointerOfType(type, kIROp_UnsizedArrayType);
}
}
|