/// <summary> /// Eval for multiple lines of code /// </summary> /// <param name="s"></param> /// <param name="parser"></param> /// <param name="section"></param> /// <param name="opType">Use null to check if rawCodes is not optimized</param> /// <param name="rawCodes"></param> /// <param name="check"></param> /// <param name="cmds"></param> /// <returns></returns> public static List <LogInfo> EvalOptLines(EngineState s, CodeParser parser, ScriptSection section, CodeType?opType, List <string> rawCodes, ErrorCheck check, out CodeCommand[] cmds) { // Parse CodeCommand List <LogInfo> errorLogs; (cmds, errorLogs) = parser.ParseStatements(rawCodes); if (errorLogs.Any(x => x.State == LogState.Error)) { Assert.AreEqual(ErrorCheck.ParserError, check); return(new List <LogInfo>()); } if (opType is CodeType type) { Assert.AreEqual(1, cmds.Length); Assert.AreEqual(type, cmds[0].Type); } else { Assert.IsTrue(1 < cmds.Length); } // Reset halt flags s.ResetFull(); // Run CodeCommands return(Engine.RunCommands(s, section, cmds, s.CurSectionInParams, s.CurSectionOutParams, false)); }
public static List <LogInfo> EvalLines(EngineState s, List <string> rawCodes, ErrorCheck check, out CodeCommand[] cmds) { // Create CodeCommand List <LogInfo> errorLogs; ScriptSection dummySection = DummySection(); CodeParser parser = new CodeParser(dummySection, Global.Setting, Project.Compat); (cmds, errorLogs) = parser.ParseStatements(rawCodes); if (errorLogs.Any(x => x.State == LogState.Error)) { Assert.AreEqual(ErrorCheck.ParserError, check); return(new List <LogInfo>()); } // Reset halt flags s.ResetFull(); // Run CodeCommands return(Engine.RunCommands(s, dummySection, cmds, s.CurSectionInParams, s.CurSectionOutParams, false)); }