public XamlIlEmitContext(XamlIlTransformerConfiguration configuration, XamlIlContext runtimeContext, IXamlIlLocal contextLocal, IEnumerable <object> emitters) { _emitters = emitters.ToList(); Configuration = configuration; RuntimeContext = runtimeContext; ContextLocal = contextLocal; }
public void Dispose() { if (Local == null) { return; } _parent._localsPool.Add((_type, Local)); Local = null; }
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; }
/// <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); }
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); }
public static IXamlIlEmitter Stloc(this IXamlIlEmitter emitter, IXamlIlLocal local) => emitter.Emit(OpCodes.Stloc, local);
public static IXamlIlEmitter Ldloca(this IXamlIlEmitter emitter, IXamlIlLocal local) => emitter.Emit(OpCodes.Ldloca, local);
public IXamlIlEmitter Emit(OpCode code, IXamlIlLocal local) { _ilg.Emit(code, ((SreLocal)local).Local); return(this); }
public IXamlIlEmitter Emit(OpCode code, IXamlIlLocal local) { Track(code, local); _inner.Emit(code, local); return(this); }
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)); }
public PooledLocal(XamlIlLocalsPool parent, IXamlIlType type, IXamlIlLocal local) { Local = local; _parent = parent; _type = type; }
public IXamlIlEmitter Emit(SreOpCode code, IXamlIlLocal local) => Emit(Instruction.Create(Dic[code], ((CecilLocal)local).Variable));
public PooledLocal(XamlIlEmitContext parent, IXamlIlType type, IXamlIlLocal local) { Local = local; _parent = parent; _type = type; }