public JintProjectionStateHandler(string source, bool enableContentTypeValidation, TimeSpan compilationTimeout, TimeSpan executionTimeout)
        {
            _enableContentTypeValidation = enableContentTypeValidation;
            _definitionBuilder           = new SourceDefinitionBuilder();
            _definitionBuilder.NoWhen();
            _definitionBuilder.AllEvents();
            TimeConstraint timeConstraint = new(compilationTimeout, executionTimeout);

            _engine = new Engine(opts => opts.Constraint(timeConstraint));
            _engine.Global.RemoveOwnProperty("eval");
            _state              = JsValue.Undefined;
            _sharedState        = JsValue.Undefined;
            _interpreterRuntime = new InterpreterRuntime(_engine, _definitionBuilder);



            timeConstraint.Compiling();
            _engine.Execute(source);
            timeConstraint.Executing();
            _json = _interpreterRuntime.SwitchToExecutionMode();
            _engine.Global.FastAddProperty("emit", new ClrFunctionInstance(_engine, "emit", Emit, 4), true, false, true);
            _engine.Global.FastAddProperty("linkTo", new ClrFunctionInstance(_engine, "linkTo", LinkTo, 3), true, false, true);
            _engine.Global.FastAddProperty("linkStreamTo", new ClrFunctionInstance(_engine, "linkStreamTo", LinkStreamTo, 3), true, false, true);
            _engine.Global.FastAddProperty("copyTo", new ClrFunctionInstance(_engine, "copyTo", CopyTo, 3), true, false, true);
            _emitted = new List <EmittedEventEnvelope>();
        }
示例#2
0
 public static void GetFieldB(InterpreterRuntime runtime, int registerIndex)
 {
     if (!runtime.GetObject(registerIndex, out Test.UnitTests.Color result) || !runtime.Push(result.B, true))
     {
         Log.Error("Color::B Getter failed");
     }
 }
示例#3
0
 public static void SetFieldName(InterpreterRuntime runtime, int registerIndex)
 {
     if (!runtime.GetObject(registerIndex, out Test.UnitTests.Color result) || !runtime.Pop(out result.Name))
     {
         Log.Error("Color::Name Setter failed");
     }
 }
示例#4
0
 public static void NewColorEmpty(InterpreterRuntime runtime, int registerIndex)
 {
     if (!runtime.SetObject(new Test.UnitTests.Color(), registerIndex))
     {
         Log.Error("Color Constructor failed");
     }
 }
示例#5
0
 public static void SetRGB(InterpreterRuntime runtime, int registerIndex)
 {
     if (!runtime.GetObject(registerIndex, out Test.UnitTests.Color result) || !runtime.Pop(out System.Int32 a3) || !runtime.Pop(out System.Int32 a2) || !runtime.Pop(out System.Int32 a1))
     {
         Log.Error("Color::RGB Function failed");
     }