private CompiledScript CompileScript(PreludeScript prelude, string script, string fileName)
 {
     IntPtr query = Js1.CompileQuery(
         prelude.GetHandle(), script, fileName, _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate);
     CompiledScript.CheckResult(query, disposeScriptOnException: true);
     return new CompiledScript(query, fileName);
 }
예제 #2
0
        private CompiledScript CompileScript(PreludeScript prelude, string script, string fileName)
        {
            IntPtr query = Js1.CompileQuery(
                prelude.GetHandle(), script, fileName, _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate);

            CompiledScript.CheckResult(query, disposeScriptOnException: true);
            return(new CompiledScript(query, fileName));
        }
예제 #3
0
 private CompiledScript CompileScript(PreludeScript prelude, string script, string fileName)
 {
     prelude.ScheduleTerminateExecution();
     IntPtr query = Js1.CompileQuery(
         prelude.GetHandle(), script, fileName, _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate);
     var terminated = prelude.CancelTerminateExecution();
     CompiledScript.CheckResult(query, terminated, disposeScriptOnException: true);
     return new CompiledScript(query);
 }
예제 #4
0
        private CompiledScript CompileScript(PreludeScript prelude, string script, string fileName)
        {
            prelude.ScheduleTerminateExecution();
            IntPtr query = Js1.CompileQuery(
                prelude.GetHandle(), script, fileName, _commandHandlerRegisteredCallback, _reverseCommandHandlerDelegate);
            var terminated = prelude.CancelTerminateExecution();

            CompiledScript.CheckResult(query, terminated, disposeScriptOnException: true);
            return(new CompiledScript(query, fileName));
        }
예제 #5
0
        public void long_execution_of_non_v8_code_does_not_crash()
        {
            _cancelCallbackFactory = (timeout, action) => ThreadPool.QueueUserWorkItem(state =>
                {
                    Console.WriteLine("Calling a callback in " + timeout + "ms");
                    Thread.Sleep(timeout);
                    action();
                });
            Action<string> logger = Console.WriteLine;


            Func<string, Tuple<string, string>> getModuleSource = name =>
                {
                    var fullScriptFileName = Path.GetFullPath(Path.Combine(_jsPath, name + ".js"));
                    var scriptSource = File.ReadAllText(fullScriptFileName, Helper.UTF8NoBom);
                    return Tuple.Create(scriptSource, fullScriptFileName);
                };


            var preludeSource = getModuleSource("1Prelude");
            var prelude = new PreludeScript(preludeSource.Item1, preludeSource.Item2, getModuleSource, _cancelCallbackFactory, logger);
            try
            {
                //var cancelToken = 123;
                prelude.ScheduleTerminateExecution();
                Thread.Sleep(500);
                _commandHandlerRegisteredCallback = (name, handle) => { };
                _reverseCommandHandlerDelegate = (name, body) => { };
                Js1.CompileQuery(
                    prelude.GetHandle(), "log(1);", "fn", _commandHandlerRegisteredCallback,
                    _reverseCommandHandlerDelegate);

                prelude.CancelTerminateExecution();
            }
            catch
            {
                prelude.Dispose(); // clean up unmanaged resources if failed to create
                throw;
            }

        }