MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / EvaluateCondition

Method EvaluateCondition

source/script.cpp:10596–10610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10594
10595
10596ResultType Line::EvaluateCondition()
10597// Returns CONDITION_TRUE or CONDITION_FALSE (FAIL is returned only in DEBUG mode).
10598{
10599#ifdef _DEBUG
10600 if (mActionType != ACT_IF)
10601 return LineError(_T("DEBUG: EvaluateCondition() was called with a line that isn't a condition."));
10602#endif
10603
10604 // The following is ordered for short-circuit performance.
10605 Var *var = mArg[0].type == ARG_TYPE_INPUT_VAR ? VAR(mArg[0]) : nullptr;
10606 bool if_condition = var ? VarToBOOL(*var) // Not verified recently: 30% faster than having ExpandArgs() resolve ARG1 even when it's a naked variable.
10607 : ResultToBOOL(ARG1); // CAN'T simply check *ARG1=='1' because the loadtime routine has various ways of setting if_expresion to false for things that are normally expressions.
10608
10609 return if_condition ? CONDITION_TRUE : CONDITION_FALSE;
10610}
10611
10612
10613

Callers 1

ExecUntilMethod · 0.80

Calls 2

VarToBOOLFunction · 0.85
ResultToBOOLFunction · 0.85

Tested by

no test coverage detected