Пример #1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                Console.WriteLine();
                Console.WriteLine("Goodbye! ¡Adiós! Ciao! Adieu! Adeus! Tschüss! Пока! 再见 さようなら הֱיה שלום وداعا");
            };

            ClearLine();

            // Subscribe to the printing events from the interpreter.
            // A printing event will be triggered after each successful statement
            // execution. On error an exception will be thrown.
            Interpreter.Instance.OnOutput += Print;

            string scriptFilename = "scripts/test.cscs";

            scriptFilename = "";
            string script = Utils.GetFileContents(scriptFilename);

            Environment.SetEnvironmentVariable("MONO_REGISTRY_PATH",
                                               "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/registry/");

            DebuggerServer.BaseDirectory = "";
            if (string.IsNullOrWhiteSpace(script) && (args.Length < 1 || args[1] == "debugger"))
            {
                DebuggerServer.StartServer(13337, true);
            }

            if (args.Length >= 3)
            {
                Translation.TranslateScript(args);
                return;
            }
            if (args.Length > 0)
            {
                if (args[0].EndsWith(EXT))
                {
                    scriptFilename = args[0];
                    Console.WriteLine("Reading script from " + scriptFilename);
                    script = Utils.GetFileContents(scriptFilename);
                }
                else
                {
                    script = args[0];
                }
            }

            if (!string.IsNullOrWhiteSpace(script))
            {
                ProcessScript(script, scriptFilename);
                return;
            }

            RunLoop();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                Console.WriteLine();
                Console.WriteLine("Goodbye! ¡Adiós! Ciao! Adieu! Adeus! Tschüss! Пока! 再见 さようなら הֱיה שלום وداعا");
            };

            ClearLine();

            // Subscribe to the printing events from the interpreter.
            // A printing event will be triggered after each successful statement
            // execution. On error an exception will be thrown.
            Interpreter.Instance.GetOutput += Print;

            //ProcessScript("include(\"scripts/functions.cscs\");");
            string scriptFilename = "scripts/temp.cscs";
            string script         = "";

            script = Utils.GetFileContents(scriptFilename);

            if (string.IsNullOrWhiteSpace(script) && (args.Length < 1 || args[1] == "debugger"))
            {
                DebuggerServer.StartServer(13337, true);
                //return;
            }

            if (args.Length >= 3)
            {
                Translation.TranslateScript(args);
                return;
            }
            if (args.Length > 0)
            {
                if (args[0].EndsWith(EXT))
                {
                    scriptFilename = args[0];
                    Console.WriteLine("Reading script from " + scriptFilename);
                    script = Utils.GetFileContents(scriptFilename);
                }
                else
                {
                    script = args[0];
                }
            }

            if (!string.IsNullOrWhiteSpace(script))
            {
                ProcessScript(script, scriptFilename);
                return;
            }

            RunLoop();
        }
Пример #3
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();
            int             port = Utils.GetSafeInt(args, 0, 13337);

            DebuggerServer.StartServer(port);

            DebuggerServer.OnRequest += ProcessRequest;
            return(Variable.EmptyInstance);
        }
Пример #4
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string          res  = "OK";
            List <Variable> args = script.GetFunctionArgs();

            if (m_start)
            {
                int port = Utils.GetSafeInt(args, 0, 13337);
                res = DebuggerServer.StartServer(port);
            }
            else
            {
                DebuggerServer.StopServer();
            }

            return(new Variable(res));
        }
Пример #5
0
        public static async Task<Variable> Execute(ParsingScript script)
        {
            char[] toArray = Constants.END_PARSE_ARRAY;
            Variable result = null;
            Exception exception = null;
#if UNITY_EDITOR || UNITY_STANDALONE || MAIN_THREAD_CHECK
            // Do nothing: already on the main thread
#elif __ANDROID__
            scripting.Droid.MainActivity.TheView.RunOnUiThread(() =>
            {
#elif __IOS__
            scripting.iOS.AppDelegate.GetCurrentController().InvokeOnMainThread(() =>
            {
#else
#endif
                try
                {
#if __IOS__  || __ANDROID__
                    result = script.Execute(toArray);
#else
                    result = await script.ExecuteAsync(toArray);
#endif
                }
                catch (ParsingException exc)
                {
                    exception = exc;
                }

#if UNITY_EDITOR || UNITY_STANDALONE || MAIN_THREAD_CHECK
            // Do nothing: already on the main thread or main thread is not required
#elif __ANDROID__ || __IOS__
            });
#endif
            if (exception != null)
            {
                throw exception;
            }
            if (result.Type == Variable.VarType.QUIT)
            {
                DebuggerServer.StopServer();
            }
            return result;
        }
    }
Пример #6
0
        protected override Variable Evaluate(ParsingScript script)
        {
            string res = "OK";
            List<Variable> args = script.GetFunctionArgs();
            if (m_start)
            {
                int port = Utils.GetSafeInt(args, 0, 13337);
                bool allowRemote = Utils.GetSafeInt(args, 1, 0) == 1;
                DebuggerServer.AllowedClients = Utils.GetSafeString(args, 2);

                res = DebuggerServer.StartServer(port, allowRemote);
            }
            else
            {
                DebuggerServer.StopServer();
            }

            return new Variable(res);
        }