private static Runtime CreateNewRuntime(IBridge bridge, bool allowCallbacks, bool enableLogging)
 {
     // Assume s_mutex is held
     var runtime = new Runtime(database, bridge, allowCallbacks, enableLogging);
     allRuntimes.Add(runtime);
     return runtime;
 }
 public static Runtime InitializeUniqueRuntime(IBridge bridge, bool allowCallbacks, bool enableLogging)
 {
     lock (mutex)
     {
         if (runtimeStack != null)
             throw new InvalidOperationException("already initialized for multiple runtimes");
         defaultRuntime = CreateNewRuntime(bridge, allowCallbacks, enableLogging);
         return defaultRuntime;
     }
 }
        public static void PushRuntime(Runtime runtime)
        {
            lock (mutex)
            {
                if (defaultRuntime != null && runtime != defaultRuntime)
                    throw new InvalidOperationException("initialized to expect only one runtime");
                if (defaultRuntime == null)
                {
                    if (runtimeStack == null)
                        runtimeStack = new Stack<Runtime>();

                    runtimeStack.Push(runtime);
                }
            }
        }
 public CapturedLogException(Runtime runtime)
 {
     Log = runtime.CurrentLog;
 }
Beispiel #5
0
 public NullableInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
     var elemType = TypeInfo.ExplodeNullableType(type);
     if (elemType == null)
         throw new InvalidOperationException("not a nullable type");
     elemInteropOps = outer.FindInteropOps(elemType);
 }
Beispiel #6
0
 public InteropOps(Runtime outer, Type type, TypeInfo typeInfo)
 {
     this.outer = outer;
     this.type = type;
     var n = typeInfo.RootTypeSteps;
     rootType = type;
     while (n-- > 0)
         rootType = rootType.BaseType;
     this.typeInfo = typeInfo;
 }
Beispiel #7
0
 public ProxiedInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
 }
Beispiel #8
0
 public NormalReferenceInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
 }
Beispiel #9
0
 public StringInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
 }
Beispiel #10
0
 public NumberInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
 }
Beispiel #11
0
 public DelegateInteropOps(Runtime outer, Type type, TypeInfo typeInfo)
     : base(outer, type, typeInfo)
 {
     var resType = default(Type);
     var argTypes = TypeInfo.ExplodeDelegateType(type, out resType);
     if (argTypes == null)
         throw new InvalidOperationException("not a delegate type");
     argInteropOps = new InteropOps[argTypes.Count];
     for (var i = 0; i < argTypes.Count; i++)
         argInteropOps[i] = outer.FindInteropOps(argTypes[i]);
     resInteropOps = resType == null ? null : outer.FindInteropOps(resType);
     captureThis = typeInfo.CaptureThis;
     inlineParamsArray = typeInfo.InlineParamsArray;
 }
Beispiel #12
0
 public InteropContext(Runtime runtime)
 {
     InteropContextManager.PushRuntime(runtime);
 }
Beispiel #13
0
 public void PrepareNewRuntime(Runtime runtime)
 {
     foreach (var sei in staticExports)
         runtime.BindExportedMethod(sei.MethodBase, null, sei.Script);
 }