static void Main(string[] args) { try { CheckArgumentsHaveBeenSupplied(args); var scriptPath = args[0]; var scriptToRun = args[1]; CheckScriptPathIsValid(scriptPath); var scriptCollection = ScriptLoader.LoadScripts(CreateBinaryReaderForScriptFile(scriptPath)); CheckScriptNameIsValid(scriptCollection, scriptToRun); var fnRoutinesCaller = new FnRoutinesCaller(); var variablesManager = new VariablesManager(); var stack = new ValueStack(); var scriptInterpreter = new ScriptInterpreter(scriptToRun, scriptCollection[scriptToRun], fnRoutinesCaller, variablesManager, stack); scriptInterpreter.Run(); } catch (Exception exception) { Console.WriteLine(exception.Message); } Console.WriteLine("Done"); }
public void SpeedTest_FunctionCall() { IList <ScriptModule> modules = new List <ScriptModule>() { new ScriptModule("function", "function", ModuleTypeEnum.STARTUP, false, _path + "speed_test_function_call.scr") }; ScriptCompiler compiler = new ScriptCompiler(); ScriptProgramm programm = compiler.CompileProgramm(modules); ScriptInterpreter interpreter = new ScriptInterpreter(programm); System.Diagnostics.Stopwatch sw = new Stopwatch(); sw.Start(); interpreter.Run(); sw.Stop(); Assert.AreEqual(3400, sw.ElapsedMilliseconds, 350); }
public void SpeedTest_Structure() { IList <ScriptModule> modules = new List <ScriptModule>() { new ScriptModule("struct", "struct", ModuleTypeEnum.STARTUP, false, _path + "structure.scr") }; ScriptCompiler compiler = new ScriptCompiler(); ScriptProgramm programm = compiler.CompileProgramm(modules); ScriptInterpreter interpreter = new ScriptInterpreter(programm); System.Diagnostics.Stopwatch sw = new Stopwatch(); sw.Start(); interpreter.Run(); sw.Stop(); Assert.AreEqual(2000, sw.ElapsedMilliseconds, 200); }
public bool Run(ScriptRunningInstance player) { return(_interpreter.Run(player.ProgramCounter, player.VariablesManager)); }