| 4867 | } |
| 4868 | |
| 4869 | BfAstNode* BfReducer::CreateStatement(BfAstNode* node, CreateStmtFlags createStmtFlags) |
| 4870 | { |
| 4871 | AssertCurrentNode(node); |
| 4872 | |
| 4873 | if ((createStmtFlags & CreateStmtFlags_CheckStack) != 0) |
| 4874 | { |
| 4875 | BP_ZONE("CreateStatement.CheckStack"); |
| 4876 | |
| 4877 | StackHelper stackHelper; |
| 4878 | if (!stackHelper.CanStackExpand(64 * 1024)) |
| 4879 | { |
| 4880 | BfAstNode* result = NULL; |
| 4881 | if (!stackHelper.Execute([&]() |
| 4882 | { |
| 4883 | result = CreateStatement(node, createStmtFlags); |
| 4884 | })) |
| 4885 | { |
| 4886 | Fail("Statement too complex to parse", node); |
| 4887 | } |
| 4888 | return result; |
| 4889 | } |
| 4890 | } |
| 4891 | |
| 4892 | if ((createStmtFlags & CreateStmtFlags_AllowUnterminatedExpression) != 0) |
| 4893 | { |
| 4894 | if (IsTerminatingExpression(node)) |
| 4895 | { |
| 4896 | mPrevStmtHadError = false; |
| 4897 | |
| 4898 | // Must be an expression. Always set CreateExprFlags_NoCaseExpr, to keep ending statements in a switch case to look like case expressions |
| 4899 | auto expr = CreateExpression(node, (CreateExprFlags)((createStmtFlags & CreateStmtFlags_To_CreateExprFlags_Mask) | CreateExprFlags_NoCaseExpr)); |
| 4900 | if (expr != NULL) |
| 4901 | { |
| 4902 | auto nextNode = mVisitorPos.GetNext(); |
| 4903 | if (nextNode != NULL) |
| 4904 | FailAfter("Semicolon expected", expr); |
| 4905 | } |
| 4906 | return expr; |
| 4907 | } |
| 4908 | } |
| 4909 | |
| 4910 | mStmtHasError = false; |
| 4911 | auto stmtNode = DoCreateStatement(node, createStmtFlags); |
| 4912 | mPrevStmtHadError = mStmtHasError; |
| 4913 | if (stmtNode == NULL) |
| 4914 | return NULL; |
| 4915 | |
| 4916 | auto origStmtNode = stmtNode; |
| 4917 | if (stmtNode->IsA<BfBlock>()) |
| 4918 | return stmtNode; |
| 4919 | |
| 4920 | auto nextNode = mVisitorPos.GetNext(); |
| 4921 | if (auto expr = BfNodeDynCast<BfExpression>(stmtNode)) |
| 4922 | { |
| 4923 | if (((createStmtFlags & CreateStmtFlags_AllowUnterminatedExpression) != 0) && (nextNode == NULL)) |
| 4924 | return expr; |
| 4925 | |
| 4926 | auto stmt = mAlloc->Alloc<BfExpressionStatement>(); |
nothing calls this directly
no test coverage detected