コード例 #1
0
ファイル: Program.cs プロジェクト: davidsykes/scriptcompiler
        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");
        }
コード例 #2
0
ファイル: SpeedTests.cs プロジェクト: lexx23/ScriptEngine
        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);
        }
コード例 #3
0
ファイル: SpeedTests.cs プロジェクト: lexx23/ScriptEngine
        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);
        }
コード例 #4
0
 public bool Run(ScriptRunningInstance player)
 {
     return(_interpreter.Run(player.ProgramCounter, player.VariablesManager));
 }