public XamlIlEmitContext(XamlIlTransformerConfiguration configuration,
                          XamlIlContext runtimeContext, IXamlIlLocal contextLocal,
                          IEnumerable <object> emitters)
 {
     _emitters      = emitters.ToList();
     Configuration  = configuration;
     RuntimeContext = runtimeContext;
     ContextLocal   = contextLocal;
 }
Esempio n. 2
0
 public void Dispose()
 {
     if (Local == null)
     {
         return;
     }
     _parent._localsPool.Add((_type, Local));
     Local = null;
 }
Esempio n. 3
0
 public XamlIlEmitContext(IXamlIlEmitter emitter, XamlIlTransformerConfiguration configuration,
                          XamlIlContext runtimeContext, IXamlIlLocal contextLocal,
                          Func <string, IXamlIlType, IXamlIlTypeBuilder> createSubType,
                          IFileSource file, IEnumerable <object> emitters)
 {
     File           = file;
     Emitter        = emitter;
     Emitters       = emitters.ToList();
     Configuration  = configuration;
     RuntimeContext = runtimeContext;
     ContextLocal   = contextLocal;
     CreateSubType  = createSubType;
 }
Esempio n. 4
0
        /// <summary>
        ///         /// T Build(IServiceProvider sp);
        /// </summary>


        XamlIlEmitContext InitCodeGen(Func <string, IXamlIlType, IXamlIlTypeBuilder> createSubType,
                                      IXamlIlEmitter codeGen, XamlIlContext context, bool needContextLocal)
        {
            IXamlIlLocal contextLocal = null;

            if (needContextLocal)
            {
                contextLocal = codeGen.DefineLocal(context.ContextType);
                codeGen
                .Emit(OpCodes.Ldarg_0)
                .Emit(OpCodes.Newobj, context.Constructor)
                .Emit(OpCodes.Stloc, contextLocal);
            }

            var emitContext = new XamlIlEmitContext(codeGen, _configuration, context, contextLocal, createSubType, Emitters);

            return(emitContext);
        }
Esempio n. 5
0
        XamlIlEmitContext InitCodeGen(
            IFileSource file,
            Func <string, IXamlIlType, IXamlIlTypeBuilder> createSubType,
            IXamlIlEmitter codeGen, XamlIlContext context, bool needContextLocal)
        {
            IXamlIlLocal contextLocal = null;

            if (needContextLocal)
            {
                contextLocal = codeGen.DefineLocal(context.ContextType);
                // Pass IService provider as the first argument to context factory
                codeGen
                .Emit(OpCodes.Ldarg_0);
                context.Factory(codeGen);
                codeGen.Emit(OpCodes.Stloc, contextLocal);
            }

            var emitContext = new XamlIlEmitContext(codeGen, _configuration, context, contextLocal, createSubType, file, Emitters);

            return(emitContext);
        }
Esempio n. 6
0
 public static IXamlIlEmitter Stloc(this IXamlIlEmitter emitter, IXamlIlLocal local)
 => emitter.Emit(OpCodes.Stloc, local);
Esempio n. 7
0
 public static IXamlIlEmitter Ldloca(this IXamlIlEmitter emitter, IXamlIlLocal local)
 => emitter.Emit(OpCodes.Ldloca, local);
Esempio n. 8
0
 public IXamlIlEmitter Emit(OpCode code, IXamlIlLocal local)
 {
     _ilg.Emit(code, ((SreLocal)local).Local);
     return(this);
 }
Esempio n. 9
0
 public IXamlIlEmitter Emit(OpCode code, IXamlIlLocal local)
 {
     Track(code, local);
     _inner.Emit(code, local);
     return(this);
 }
Esempio n. 10
0
 public static void EmitConvert(XamlIlEmitContext context, IXamlIlEmitter ilgen, IXamlIlLineInfo node, IXamlIlType what,
                                IXamlIlType to, IXamlIlLocal local)
 {
     EmitConvert(context, node, what, to, lda => ilgen.Emit(lda ? OpCodes.Ldloca : OpCodes.Ldloc, local));
 }
Esempio n. 11
0
 public PooledLocal(XamlIlLocalsPool parent, IXamlIlType type, IXamlIlLocal local)
 {
     Local   = local;
     _parent = parent;
     _type   = type;
 }
Esempio n. 12
0
 public IXamlIlEmitter Emit(SreOpCode code, IXamlIlLocal local)
 => Emit(Instruction.Create(Dic[code], ((CecilLocal)local).Variable));
Esempio n. 13
0
 public PooledLocal(XamlIlEmitContext parent, IXamlIlType type, IXamlIlLocal local)
 {
     Local   = local;
     _parent = parent;
     _type   = type;
 }