public void Emit(XamlIlEmitContext context, IXamlIlEmitter codeGen, bool swallowResult) { int firstCast = -1; for (var c = ParametersWithThis.Count - 1; c >= 0; c--) { if (!_method.ParametersWithThis[c].Equals(ParametersWithThis[c])) { firstCast = c; } } if (firstCast != -1) { var locals = new Stack <XamlIlEmitContext.PooledLocal>(); for (var c = ParametersWithThis.Count - 1; c >= firstCast; c--) { codeGen.Castclass(ParametersWithThis[c]); if (c > firstCast) { var l = context.GetLocal(ParametersWithThis[c]); codeGen.Stloc(l.Local); locals.Push(l); } } while (locals.Count != 0) { using (var l = locals.Pop()) codeGen.Ldloc(l.Local); } } _method.Emit(context, codeGen, swallowResult); }
public XamlIlNodeEmitResult Emit(XamlIlEmitContext context, IXamlIlEmitter codeGen) { context.Emit(Value, codeGen, context.Configuration.WellKnownTypes.Object); var t = Type.GetClrType(); if (t.IsValueType) { codeGen.Unbox_Any(t); } else { codeGen.Castclass(t); } return(XamlIlNodeEmitResult.Type(0, t)); }
public void EmitCall(IXamlIlEmitter codeGen) { int firstCast = -1; for (var c = Parameters.Count - 1; c >= 0; c--) { if (!_baseParametersWithThis[c].Equals(Parameters[c])) { firstCast = c; } } if (firstCast != -1) { var locals = new Stack <XamlIlLocalsPool.PooledLocal>(); for (var c = Parameters.Count - 1; c >= firstCast; c--) { codeGen.Castclass(_baseParametersWithThis[c]); if (c > firstCast) { var l = codeGen.LocalsPool.GetLocal(_baseParametersWithThis[c]); codeGen.Stloc(l.Local); locals.Push(l); } } while (locals.Count != 0) { using (var l = locals.Pop()) { codeGen.Ldloc(l.Local); l.Dispose(); } } } codeGen.EmitCall(_method); }