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

Method ParseExpression

hlslparser/src/HLSLParser.cpp:2651–2682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2649}
2650
2651bool HLSLParser::ParseExpression(HLSLExpression*& expression)
2652{
2653 if (!ParseBinaryExpression(0, expression)) {
2654 return false;
2655 }
2656
2657 HLSLBinaryOp assignOp;
2658 if (AcceptAssign(assignOp)) {
2659 HLSLExpression* expression2 = NULL;
2660 if (!ParseExpression(expression2)) {
2661 return false;
2662 }
2663 HLSLBinaryExpression* binaryExpression = m_tree->AddNode<HLSLBinaryExpression>(expression->fileName, expression->line);
2664 binaryExpression->binaryOp = assignOp;
2665 binaryExpression->expression1 = expression;
2666 binaryExpression->expression2 = expression2;
2667 // This type is not strictly correct, since the type should be a reference.
2668 // However, for our usage of the types it should be sufficient.
2669 binaryExpression->expressionType = expression->expressionType;
2670
2671 if (!CheckTypeCast(expression2->expressionType, expression->expressionType)) {
2672 const char* srcTypeName = GetTypeNameHLSL(expression2->expressionType);
2673 const char* dstTypeName = GetTypeNameHLSL(expression->expressionType);
2674 m_tokenizer.Error("Cannot implicitly convert from '%s' to '%s'", srcTypeName, dstTypeName);
2675 return false;
2676 }
2677
2678 expression = binaryExpression;
2679 }
2680
2681 return true;
2682}
2683
2684bool HLSLParser::AcceptBinaryOperator(int priority, HLSLBinaryOp& binaryOp)
2685{

Callers

nothing calls this directly

Calls 2

GetTypeNameHLSLFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected