| 1583 | } |
| 1584 | |
| 1585 | BfExpression* BfReducer::CreateExpression(BfAstNode* node, CreateExprFlags createExprFlags) |
| 1586 | { |
| 1587 | if (node == NULL) |
| 1588 | return NULL; |
| 1589 | |
| 1590 | BP_ZONE("CreateExpression"); |
| 1591 | |
| 1592 | // |
| 1593 | { |
| 1594 | BP_ZONE("CreateExpression.CheckStack"); |
| 1595 | |
| 1596 | StackHelper stackHelper; |
| 1597 | if (!stackHelper.CanStackExpand(64 * 1024)) |
| 1598 | { |
| 1599 | BfExpression* result = NULL; |
| 1600 | if (!stackHelper.Execute([&]() |
| 1601 | { |
| 1602 | result = CreateExpression(node, createExprFlags); |
| 1603 | })) |
| 1604 | { |
| 1605 | Fail("Expression too complex to parse", node); |
| 1606 | } |
| 1607 | return result; |
| 1608 | } |
| 1609 | } |
| 1610 | |
| 1611 | AssertCurrentNode(node); |
| 1612 | |
| 1613 | auto rhsCreateExprFlags = (CreateExprFlags)(createExprFlags & CreateExprFlags_BreakOnRChevron); |
| 1614 | |
| 1615 | auto exprLeft = BfNodeDynCast<BfExpression>(node); |
| 1616 | |
| 1617 | AssertCurrentNode(node); |
| 1618 | |
| 1619 | if (auto interpolateExpr = BfNodeDynCastExact<BfStringInterpolationExpression>(node)) |
| 1620 | { |
| 1621 | for (auto block : interpolateExpr->mExpressions) |
| 1622 | { |
| 1623 | HandleBlock(block, true); |
| 1624 | } |
| 1625 | return interpolateExpr; |
| 1626 | } |
| 1627 | |
| 1628 | if ((createExprFlags & (CreateExprFlags_AllowVariableDecl | CreateExprFlags_PermissiveVariableDecl)) != 0) |
| 1629 | { |
| 1630 | bool isLocalVariable = false; |
| 1631 | auto nextNode = mVisitorPos.GetNext(); |
| 1632 | BfVariableDeclaration* continuingVariable = NULL; |
| 1633 | |
| 1634 | int outEndNode = -1; |
| 1635 | bool couldBeExpr = false; |
| 1636 | bool isTuple = false; |
| 1637 | if (IsTypeReference(node, BfToken_None, -1, &outEndNode, &couldBeExpr, NULL, &isTuple)) |
| 1638 | { |
| 1639 | if ((createExprFlags & CreateExprFlags_PermissiveVariableDecl) != 0) |
| 1640 | isLocalVariable = true; |
| 1641 | else if (auto identifierNode = BfNodeDynCast<BfIdentifierNode>(mVisitorPos.Get(outEndNode))) |
| 1642 | { |
no test coverage detected