| 2797 | |
| 2798 | |
| 2799 | ResultType Script::GetLineContExpr(TextStream *fp, LineBuffer &buf, LineBuffer &next_buf |
| 2800 | , LineNumberType &phys_line_number, bool &has_continuation_section) |
| 2801 | // Determine whether buf has an unclosed (/[/{, and if so, complete the expression by |
| 2802 | // appending subsequent lines until the number of opening and closing symbols balances out. |
| 2803 | // Continuation lines and sections are assumed to have already been handled (and appended to |
| 2804 | // buf) by a previous call to GetLineContinuation(), but **only up to the unbalanced line**; |
| 2805 | // any subsequent contination is handled by this function. |
| 2806 | { |
| 2807 | ActionTypeType action_type = ACT_INVALID; // Set default. |
| 2808 | ptrdiff_t action_end_pos = 0; |
| 2809 | |
| 2810 | size_t &buf_length = buf.length; |
| 2811 | size_t &next_buf_length = next_buf.length; |
| 2812 | |
| 2813 | TCHAR expect[MAX_BALANCEEXPR_DEPTH], open_quote = 0; |
| 2814 | int balance = BalanceExpr(buf, 0, expect); |
| 2815 | if (balance < 0 // Invalid. |
| 2816 | || !buf_length // Blank (shouldn't happen as buf must already qualify as expression-like). |
| 2817 | || next_buf_length == -1) // End of file. |
| 2818 | return balance == 0 ? OK : BalanceExprError(balance, expect, buf); |
| 2819 | |
| 2820 | // Perform rough checking for this line's action type. |
| 2821 | for (LPTSTR action_start = buf; ; ) |
| 2822 | { |
| 2823 | LPTSTR action_end = find_identifier_end(action_start); |
| 2824 | if (action_end > action_start) |
| 2825 | { |
| 2826 | TCHAR orig_char = *action_end; |
| 2827 | // This relies on names of control flow statements being invalid for use as var/func names: |
| 2828 | if (IS_SPACE_OR_TAB(orig_char) || orig_char == '(' || orig_char == '{') // '{' supports "else{". |
| 2829 | { |
| 2830 | *action_end = '\0'; |
| 2831 | action_type = ConvertActionType(action_start); |
| 2832 | *action_end = orig_char; |
| 2833 | |
| 2834 | if (action_type == ACT_ELSE || action_type == ACT_TRY || action_type == ACT_FINALLY) |
| 2835 | { |
| 2836 | action_start = omit_leading_whitespace(action_end); |
| 2837 | if (*action_start == '{') |
| 2838 | return OK; // This is unconditionally a block-begin, not an expression. |
| 2839 | continue; // Parse any same-line action instead. |
| 2840 | } |
| 2841 | |
| 2842 | if (mClassObjectCount && !g->CurrentFunc // In a class body. |
| 2843 | && (action_end - action_start == 6) && !_tcsnicmp(action_start, _T("Static"), 6)) // Ignore "Static" modifier. |
| 2844 | { |
| 2845 | action_start = omit_leading_whitespace(action_end); |
| 2846 | continue; |
| 2847 | } |
| 2848 | } |
| 2849 | } |
| 2850 | action_end_pos = action_end - buf; // Use position since action_end will be invalidated if buf is reallocated. |
| 2851 | break; |
| 2852 | } |
| 2853 | |
| 2854 | do |
| 2855 | { |
| 2856 | if (balance == 0 && buf[buf_length - 1] == ':') |
nothing calls this directly
no test coverage detected