public Task ExecuteStatement(IStatement stat, LuaState state, CancellationToken token = default) { if (state.FunctionState.DidReturn || token.IsCancellationRequested) { return(Task.CompletedTask); } switch (stat) { case Assignment assignment: return(_statementInterpreter.ExecuteAssignment(assignment, state, token)); case LocalAssignment localAssignment: return(_statementInterpreter.ExecuteLocalAssignment(localAssignment, state, token)); case FunctionCall call: return(_statementInterpreter.ExecuteFunctionCall(call, state, token)); case Block block: return(_statementInterpreter.ExecuteBlock(block, state, token)); case IfStat ifStat: return(_statementInterpreter.ExecuteIfStat(ifStat, state, token)); case ReturnStat returnStat: return(_statementInterpreter.ExecuteReturnStat(returnStat, state, token)); case WhileStat whileStat: return(_statementInterpreter.ExecuteWhileStat(whileStat, state, token)); case RepeatStat repeatStat: return(_statementInterpreter.ExecuteRepeatStat(repeatStat, state, token)); case GenericFor genericFor: return(_statementInterpreter.ExecuteGenericFor(genericFor, state, token)); case NumericFor numericFor: return(_statementInterpreter.ExecuteNumericFor(numericFor, state, token)); default: throw new NotImplementedException(stat.GetType().Name); } }