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

Function NeedsParenthesis

hlslparser/src/MSLGenerator.cpp:1122–1139  ·  view source on GitHub ↗

@@ We could be a lot smarter removing parenthesis based on the operator precedence of the parent expression.

Source from the content-addressed store, hash-verified

1120
1121// @@ We could be a lot smarter removing parenthesis based on the operator precedence of the parent expression.
1122static bool NeedsParenthesis(HLSLExpression* expression, HLSLExpression* parentExpression)
1123{
1124 // For now we just omit the parenthesis if there's no parent expression.
1125 if (parentExpression == NULL) {
1126 return false;
1127 }
1128
1129 // One more special case that's pretty common.
1130 if (parentExpression->nodeType == HLSLNodeType_MemberAccess) {
1131 if (expression->nodeType == HLSLNodeType_IdentifierExpression ||
1132 expression->nodeType == HLSLNodeType_ArrayAccess ||
1133 expression->nodeType == HLSLNodeType_MemberAccess) {
1134 return false;
1135 }
1136 }
1137
1138 return true;
1139}
1140
1141bool MSLGenerator::NeedsCast(const HLSLType& target, const HLSLType& source)
1142{

Callers 1

OutputExpressionMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected