| 3607 | } |
| 3608 | |
| 3609 | GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_previous_operand, bool p_can_assign) { |
| 3610 | LambdaNode *lambda = alloc_node<LambdaNode>(); |
| 3611 | lambda->parent_function = current_function; |
| 3612 | lambda->parent_lambda = current_lambda; |
| 3613 | |
| 3614 | FunctionNode *function = alloc_node<FunctionNode>(); |
| 3615 | function->source_lambda = lambda; |
| 3616 | |
| 3617 | function->is_static = current_function != nullptr ? current_function->is_static : false; |
| 3618 | |
| 3619 | if (match(GDScriptTokenizer::Token::IDENTIFIER)) { |
| 3620 | function->identifier = parse_identifier(); |
| 3621 | } |
| 3622 | |
| 3623 | bool multiline_context = multiline_stack.back()->get(); |
| 3624 | |
| 3625 | push_completion_call(nullptr); |
| 3626 | |
| 3627 | // Reset the multiline stack since we don't want the multiline mode one in the lambda body. |
| 3628 | push_multiline(false); |
| 3629 | if (multiline_context) { |
| 3630 | tokenizer->push_expression_indented_block(); |
| 3631 | } |
| 3632 | |
| 3633 | push_multiline(true); // For the parameters. |
| 3634 | if (function->identifier) { |
| 3635 | consume(GDScriptTokenizer::Token::PARENTHESIS_OPEN, R"(Expected opening "(" after lambda name.)"); |
| 3636 | } else { |
| 3637 | consume(GDScriptTokenizer::Token::PARENTHESIS_OPEN, R"(Expected opening "(" after "func".)"); |
| 3638 | } |
| 3639 | |
| 3640 | FunctionNode *previous_function = current_function; |
| 3641 | current_function = function; |
| 3642 | |
| 3643 | LambdaNode *previous_lambda = current_lambda; |
| 3644 | current_lambda = lambda; |
| 3645 | |
| 3646 | SuiteNode *body = alloc_node<SuiteNode>(); |
| 3647 | body->parent_function = current_function; |
| 3648 | body->parent_block = current_suite; |
| 3649 | |
| 3650 | SuiteNode *previous_suite = current_suite; |
| 3651 | current_suite = body; |
| 3652 | |
| 3653 | parse_function_signature(function, body, "lambda", -1); |
| 3654 | |
| 3655 | current_suite = previous_suite; |
| 3656 | |
| 3657 | bool previous_in_lambda = in_lambda; |
| 3658 | in_lambda = true; |
| 3659 | |
| 3660 | // Save break/continue state. |
| 3661 | bool could_break = can_break; |
| 3662 | bool could_continue = can_continue; |
| 3663 | |
| 3664 | // Disallow break/continue. |
| 3665 | can_break = false; |
| 3666 | can_continue = false; |
nothing calls this directly
no test coverage detected