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

Function StringExitWith

engine/Evaluator/express.cpp:883–898  ·  view source on GitHub ↗

if (cond) exitWith { code } — evaluates code when cond is true, stores the value in tls_exitWithValue, and signals EvalBreak to stop further statement execution in the current scope. Loop handlers (ForDoOp, StringRepeat) catch EvalBreak, clear it, and use tls_exitWithValue as the loop's return value. At top level (no enclosing loop), EvaluateMultiple captures the value when it sees EvalBreak so t

Source from the content-addressed store, hash-verified

881// At top level (no enclosing loop), EvaluateMultiple captures the value when
882// it sees EvalBreak so the tri runner still receives "FAIL:..." strings.
883static GameValue StringExitWith(const GameState* state, GameValuePar oper1, GameValuePar oper2)
884{
885 bool test = oper1;
886 if (test)
887 {
888 GameVarSpace local(state->GetContext());
889 state->BeginContext(&local);
890 RString expression = oper2;
891 GameValue ret = state->EvaluateMultiple(expression);
892 state->EndContext();
893 tls_exitWithValue = ret;
894 const_cast<GameState*>(state)->SetError(EvalBreak);
895 return ret;
896 }
897 return NOTHING;
898}
899
900// --- for / from / to / step / do (for-loop variant) -------------------------
901

Callers

nothing calls this directly

Calls 5

BeginContextMethod · 0.80
EvaluateMultipleMethod · 0.80
EndContextMethod · 0.80
GetContextMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected