MCPcopy Create free account
hub / github.com/alecazam/kram / GetBinaryOpResultType

Function GetBinaryOpResultType

hlslparser/src/HLSLParser.cpp:1803–1834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801}
1802
1803static bool GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& type1, const HLSLType& type2, HLSLType& result)
1804{
1805 // only allow numeric types for binary operators
1806 if (!IsNumericType(type1.baseType) || type1.array ||
1807 !IsNumericType(type2.baseType) || type2.array) {
1808 return false;
1809 }
1810
1811 if (IsBitOp(binaryOp)) {
1812 if (!IsIntegerType(type1.baseType)) {
1813 return false;
1814 }
1815 }
1816
1817 if (IsLogicOp(binaryOp) || IsCompareOp(binaryOp)) {
1818 int numComponents = std::max(baseTypeDescriptions[type1.baseType].numComponents, baseTypeDescriptions[type2.baseType].numComponents);
1819 result.baseType = HLSLBaseType(HLSLBaseType_Bool + numComponents - 1);
1820 }
1821 else {
1822 // TODO: allso mulAssign, ...
1823 assert(!IsAssignOp(binaryOp));
1824
1825 result.baseType = ArithmeticOpResultType(binaryOp, type1.baseType, type2.baseType);
1826 }
1827
1828 result.typeName = NULL;
1829 result.array = false;
1830 result.arraySize = NULL;
1831 result.flags = (type1.flags & type2.flags) & HLSLTypeFlag_Const; // Propagate constness.
1832
1833 return result.baseType != HLSLBaseType_Unknown;
1834}
1835
1836HLSLParser::HLSLParser(Allocator* allocator, const char* fileName, const char* buffer, size_t length) : m_tokenizer(fileName, buffer, length),
1837 m_userTypes(allocator),

Callers 1

ParseBinaryExpressionMethod · 0.85

Calls 9

IsNumericTypeFunction · 0.85
IsBitOpFunction · 0.85
IsIntegerTypeFunction · 0.85
IsLogicOpFunction · 0.85
IsCompareOpFunction · 0.85
HLSLBaseTypeEnum · 0.85
IsAssignOpFunction · 0.85
ArithmeticOpResultTypeFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected