MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / StringRepeat

Function StringRepeat

engine/Evaluator/express.cpp:788–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

786static thread_local GameValue tls_exitWithValue;
787
788static 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
840static GameValue StringElse(const GameState* state, GameValuePar oper1, GameValuePar oper2)
841{

Callers

nothing calls this directly

Calls 9

BeginContextMethod · 0.80
EvaluateMultipleMethod · 0.80
TypeErrorMethod · 0.80
EndContextMethod · 0.80
GetLastErrorMethod · 0.80
SetErrorMethod · 0.45
GetContextMethod · 0.45
GetTypeMethod · 0.45
ExecuteMethod · 0.45

Tested by

no test coverage detected