Пример #1
0
        public ReplWindow(string autostartFilename)
        {
            _autostartFilename = autostartFilename;
            _windowId          = GetHashCode();

            _sb.AppendLine("Welcome to C# REPL (read-evaluate-print loop)! Enter \"help\" to get a list of common methods.");

            _evaluator = new ScriptEvaluator(new StringWriter(_sb))
            {
                InteractiveBaseClass = typeof(REPL)
            };

            IEnumerator DelayedAutostart()
            {
                yield return(null);

                var envSetup = "using System;" +
                               "using UnityEngine;" +
                               "using System.Linq;" +
                               "using System.Collections;" +
                               "using System.Collections.Generic;";

                Evaluate(envSetup);
                RunAutostart(autostartFilename);
            }

            RuntimeUnityEditorCore.PluginObject.StartCoroutine(DelayedAutostart());
        }
Пример #2
0
        public ReplWindow(string autostartFilename)
        {
            _windowId = GetHashCode();

            _sb.AppendLine("Welcome to C# REPL (read-evaluate-print loop)! Enter \"help\" to get a list of common methods.");

            _evaluator = new ScriptEvaluator(new StringWriter(_sb))
            {
                InteractiveBaseClass = typeof(REPL)
            };

            var envSetup = new[]
            {
                "using System;",
                "using UnityEngine;",
                "using System.Linq;",
                "using System.Collections;",
                "using System.Collections.Generic;",
            };

            foreach (var define in envSetup)
            {
                Evaluate(define);
            }

            _autostartFilename = autostartFilename;
        }
        public void ResetConsole(bool log = true)
        {
            if (Evaluator != null)
            {
                Evaluator.Dispose();
            }

            m_evalLogBuilder = new StringBuilder();

            Evaluator = new ScriptEvaluator(new StringWriter(m_evalLogBuilder))
            {
                InteractiveBaseClass = typeof(ScriptInteraction)
            };

            UsingDirectives = new List <string>();

            foreach (string use in DefaultUsing)
            {
                AddUsing(use);
            }

            if (log)
            {
                ExplorerCore.Log($"C# Console reset. Using directives:\r\n{Evaluator.GetUsing()}");
            }
        }
 public ScriptEvaluatorTest()
 {
     this.scriptEvaluator = new ScriptEvaluator(
         new DefaultAssemblies(
             new DotNetAssemblyLocator(
                 new RealFileIO()
                 )
             )
         );
 }
Пример #5
0
        void Start()
        {
            // Create our domain
            domain = ScriptDomain.CreateDomain("EvalDomain", true);

            // Create our evaluator
            evaluator = new ScriptEvaluator(domain);

            // Add a using statement for UnityEngine. This will allow us ti access all types under the UnityEngine namespace
            evaluator.AddUsing("UnityEngine");
        }
Пример #6
0
 public ScriptEvaluatorTest()
 {
     this.scriptEvaluator = new ScriptEvaluator(
         new DefaultAssemblies(
             new DotNetAssemblyLocator(
                 () => new Process(),
                 FileIO.RealIO
                 )
             )
         );
 }
Пример #7
0
        public ReplWindow(string autostartFilename)
        {
            _autostartFilename = autostartFilename;
            _windowId          = GetHashCode();

            _sb.AppendLine("Welcome to C# REPL (read-evaluate-print loop)! Enter \"help\" to get a list of common methods.");

            _evaluator = new ScriptEvaluator(new StringWriter(_sb))
            {
                InteractiveBaseClass = typeof(REPL)
            };
        }
Пример #8
0
 public REPLWindow(int id)
     : base(id, "Unity REPL")
 {
     sb.AppendLine("Welcome to C# REPL! Enter \"help\" to get a list of common methods.");
     evaluator = new ScriptEvaluator(new StringWriter(sb)) {InteractiveBaseClass = typeof(REPL)};
     suggestionsWindow = new SuggestionsWindow(1010);
     suggestionsWindow.SuggestionAccept += AcceptSuggestion;
     MinSize = new Vector2(MIN_WIDTH, MIN_HEIGHT);
     windowRect.x = SUGGESTIONS_WIDTH;
     windowRect.width = MIN_WIDTH;
     windowRect.height = MIN_HEIGHT;
 }
Пример #9
0
        public void ResetConsole()
        {
            if (m_evaluator != null)
            {
                m_evaluator.Dispose();
            }

            m_evaluator = new ScriptEvaluator(new StringWriter(new StringBuilder()))
            {
                InteractiveBaseClass = typeof(ScriptInteraction)
            };

            UsingDirectives = new List <string>();
        }
        private void btnMoveDown_Click(object sender, System.EventArgs e)
        {
            if (lstScriptsOrder.SelectedIndex < lstScriptsOrder.Items.Count - 1)
            {
                FollowingScripts SelectedItem = (FollowingScripts)lstFollowingScripts.SelectedItem;
                int SelectedIndex             = lstScriptsOrder.SelectedIndex;

                ScriptEvaluator SelectedScript = SelectedItem.ListScript[SelectedIndex];

                SelectedItem.ListScript[SelectedIndex]     = SelectedItem.ListScript[SelectedIndex + 1];
                SelectedItem.ListScript[SelectedIndex + 1] = SelectedScript;

                lstScriptsOrder.Items[SelectedIndex]     = lstScriptsOrder.Items[SelectedIndex + 1];
                lstScriptsOrder.Items[SelectedIndex + 1] = SelectedScript;

                lstScriptsOrder.SelectedIndex = SelectedIndex + 1;
            }
        }
Пример #11
0
        /// <summary>
        /// Modeled on Bitcoin-SV interpreter.cpp 0.1.1 lines 1866-1945
        /// </summary>
        /// <param name="scriptSig"></param>
        /// <param name="scriptPub"></param>
        /// <param name="flags"></param>
        /// <param name="checker"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static bool VerifyScript(Script scriptSig, Script scriptPub, ScriptFlags flags, SignatureCheckerBase checker, out ScriptError error)
        {
            SetError(out error, ScriptError.UNKNOWN_ERROR);

            if ((flags & ScriptFlags.ENABLE_SIGHASH_FORKID) != 0)
            {
                flags |= ScriptFlags.VERIFY_STRICTENC;
            }

            if ((flags & ScriptFlags.VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly())
            {
                return(SetError(out error, ScriptError.SIG_PUSHONLY));
            }

            var evaluator = new ScriptEvaluator();

            return(evaluator switch
            {
                _ when !evaluator.EvalScript(scriptSig, flags, checker, out error) => false,
                _ when !evaluator.EvalScript(scriptPub, flags, checker, out error) => false,
                _ when evaluator.Count == 0 => SetError(out error, ScriptError.EVAL_FALSE),
                _ when !evaluator.Peek() => SetError(out error, ScriptError.EVAL_FALSE),
                _ => SetSuccess(out error)
            });
Пример #12
0
        public ReplWindow()
        {
            _windowId = GetHashCode();

            _sb.AppendLine("Welcome to C# REPL (read-evaluate-print loop)! Enter \"help\" to get a list of common methods.");

            _evaluator = new ScriptEvaluator(new StringWriter(_sb))
            {
                InteractiveBaseClass = typeof(REPL)
            };

            var envSetup = new string[]
            {
                "using System;",
                "using UnityEngine;",
                "using System.Linq;",
                "using System.Collections;",
                "using System.Collections.Generic;",
            };

            foreach (var define in envSetup)
            {
                Evaluate(define);
            }

            _namespaces = new HashSet <string>(
                AppDomain.CurrentDomain.GetAssemblies()
                .SelectMany(x =>
            {
                try { return(x.GetTypes()); }
                catch { return(Enumerable.Empty <Type>()); }
            })
                .Where(x => x.IsPublic && !string.IsNullOrEmpty(x.Namespace))
                .Select(x => x.Namespace));
            BepInEx.Logger.Log(LogLevel.Debug, $"[REPL] Found {_namespaces.Count} public namespaces");
        }
        public override void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers)
        {
            base.Init (fuzzLocationRoot, connector, predefinedFuzzers);

            IDictionary<string, string> config = DictionaryHelper.ReadDictionaryXml (fuzzLocationRoot, "FuzzerArg");

            _scriptEvaluator = new ScriptEvaluator<UnixSocketEnvironment> (config, this);

            _socket = new UnixSocketConnection (config);

            //Attach to the UnixSocketConnection hooks and call the associated user script
            _socket.Hook_BeforeSocketCreation += delegate(UnixSocketConnection conn) {
                _scriptEvaluator.Environment.HookType = UnixSocketHookType.BeforeSocketCreation;
                _scriptEvaluator.Run ();
            };

            _socket.Hook_AfterSocketCreation += delegate(UnixSocketConnection conn) {
                _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketCreation;
                _scriptEvaluator.Run ();
            };

            _socket.Hook_AfterSocketConnect += delegate(UnixSocketConnection conn) {
                _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketConnect;
                _scriptEvaluator.Run ();
            };

            _socket.Hook_BeforeSocketClose += delegate(UnixSocketConnection conn) {
                _scriptEvaluator.Environment.HookType = UnixSocketHookType.BeforeSocketClose;
                _scriptEvaluator.Run ();
            };

            _socket.Hook_AfterSocketClose += delegate(UnixSocketConnection conn) {
                _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketClose;
                _scriptEvaluator.Run ();
            };
        }
 public void Setup(IDictionary<string, string> config)
 {
     _scriptEvaluator = new ScriptEvaluator<ScriptedDataGeneratorEnvironment> (
         config, new Action<byte[]> (SetDataCallback), config);
 }
Пример #15
0
 public AssemblyReferenceCommandHandler(ScriptEvaluator scriptEvaluator, WorkspaceManager workspaceManager, IFileIO io)
 {
     this.scriptEvaluator  = scriptEvaluator;
     this.workspaceManager = workspaceManager;
     this.io = io;
 }
Пример #16
0
 public NugetReferenceCommandHandler(ScriptEvaluator scriptEvaluator, WorkspaceManager workspaceManager, NugetPackageInstaller nugetInstaller)
 {
     this.scriptEvaluator  = scriptEvaluator;
     this.workspaceManager = workspaceManager;
     this.nugetInstaller   = nugetInstaller;
 }
Пример #17
0
 public ViewModel(IEnumerable<City> cities, ScriptEvaluator scriptEngine)
 {
     this.Cities = cities;
     this.scriptEngine = scriptEngine;
 }
Пример #18
0
 public EvaluationCommandHandler(ScriptEvaluator scriptEvaluator, WorkspaceManager workspaceManager, PrettyPrinter prettyPrinter)
 {
     this.scriptEvaluator  = scriptEvaluator;
     this.workspaceManager = workspaceManager;
     this.prettyPrinter    = prettyPrinter;
 }