| 786 | static thread_local GameValue tls_exitWithValue; |
| 787 | |
| 788 | static GameValue StringRepeat(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 789 | { |
| 790 | int maxIters = 10000; |
| 791 | for (int i = 0;; i++) |
| 792 | { |
| 793 | if (i >= maxIters) |
| 794 | { |
| 795 | RptF("Max iteration count exceeded in while loop"); |
| 796 | state->SetError(EvalGen); |
| 797 | break; |
| 798 | } |
| 799 | // test condition |
| 800 | { |
| 801 | GameVarSpace local(state->GetContext()); |
| 802 | state->BeginContext(&local); |
| 803 | RString expression = oper1; |
| 804 | |
| 805 | GameValue value = state->EvaluateMultiple(expression); |
| 806 | bool test = false; |
| 807 | if (value.GetType() & GameBool) |
| 808 | { |
| 809 | test = bool(value); |
| 810 | } |
| 811 | else |
| 812 | { |
| 813 | state->TypeError(GameBool, value.GetType()); |
| 814 | } |
| 815 | |
| 816 | state->EndContext(); |
| 817 | if (!test) |
| 818 | { |
| 819 | break; |
| 820 | } |
| 821 | } |
| 822 | // perform loop body |
| 823 | { |
| 824 | GameVarSpace local(state->GetContext()); |
| 825 | state->BeginContext(&local); |
| 826 | RString expression = oper2; |
| 827 | const_cast<GameState*>(state)->Execute(expression); |
| 828 | state->EndContext(); |
| 829 | } |
| 830 | if (state->GetLastError() == EvalBreak) |
| 831 | { |
| 832 | GameValue exitVal = tls_exitWithValue; |
| 833 | const_cast<GameState*>(state)->SetError(EvalOK); |
| 834 | return exitVal; |
| 835 | } |
| 836 | } |
| 837 | return NOTHING; |
| 838 | } |
| 839 | |
| 840 | static GameValue StringElse(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 841 | { |
nothing calls this directly
no test coverage detected