public abstract Emit ( |
||
g | ||
from | ||
to | ||
return | void |
public override void Emit(CodeGen g, Type from, Type to) { _fromConv?.Emit(g, from, Helpers.GetNullableUnderlyingType(to)); g.IL.Emit( OpCodes.Newobj, to.GetConstructor(new[] { from })); }
void EmitGetHelper_Conversion(Operand op, Type desiredType, Conversion conv, Type from = null) { if (conv.RequiresAddress) { if (ReferenceEquals(op, null)) { throw new ArgumentException("Conversion from nullref to " + desiredType.Name + " is impossible; for nullables variable it's required to load address."); } op.EmitAddressOf(this); } else if (ReferenceEquals(op, null)) { IL.Emit(OpCodes.Ldnull); } else { op.EmitGet(this); } if (from == null) { from = (object)op == null ? null : op.GetReturnType(TypeMapper); } conv.Emit(this, from, desiredType); }
protected override void BeginImpl() { lbDecision = g.il.DefineLabel(); lbDefault = lbEnd = g.il.DefineLabel(); expression.EmitGet(g); if (conv != null) { conv.Emit(g, expression.Type, govType); } exp = g.il.DeclareLocal(govType); g.il.Emit(OpCodes.Stloc, exp); g.il.Emit(OpCodes.Br, lbDecision); g.reachable = false; }
protected override void BeginImpl() { _lbDecision = G.IL.DefineLabel(); _lbDefault = _lbEnd = G.IL.DefineLabel(); _expression.EmitGet(G); if (_conv != null) { _conv.Emit(G, _expression.GetReturnType(G.TypeMapper), _govType); } _exp = G.IL.DeclareLocal(_govType); G.IL.Emit(OpCodes.Stloc, _exp); G.IL.Emit(OpCodes.Br, _lbDecision); G._reachable = false; }
public override void Emit(CodeGen g, Type from, Type to) { _before.Emit(g, from, _fromType); g.IL.Emit(OpCodes.Call, (MethodInfo)_method.Member); _after.Emit(g, _toType, to); }
internal void Convert(Operand op, Type to, bool allowExplicit) { Conversion conv = allowExplicit ? Conversion.GetExplicit(op, to, false) : Conversion.GetImplicit(op, to, false); conv.Emit(this, (object)op == null ? null : op.Type, to); }
void EmitGetHelper_Conversion(Operand op, Type desiredType, Conversion conv, Type from = null) { if (conv.RequiresAddress) { if (ReferenceEquals(op, null)) throw new ArgumentException("Conversion from nullref to " + desiredType.Name + " is impossible; for nullables variable it's required to load address."); op.EmitAddressOf(this); } else if (ReferenceEquals(op, null)) IL.Emit(OpCodes.Ldnull); else op.EmitGet(this); if (from == null) from = (object)op == null ? null : op.GetReturnType(TypeMapper); conv.Emit(this, from, desiredType); }