protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion) { OperandExtensions.SetLeakedState(this, false); CheckScope(g); if (_t == null) { _t = value.GetReturnType(g.TypeMapper); } if (_var == null) { _var = g.IL.DeclareLocal(_t); } Type nullableUnderlyingType = Helpers.GetNullableUnderlyingType(_t); if (ReferenceEquals(value, null)) { if (nullableUnderlyingType != null) { g.InitObj(this); return; } } else if (nullableUnderlyingType == value.GetReturnType(g.TypeMapper)) { EmitAddressOf(g); g.EmitGetHelper(value, nullableUnderlyingType, false); ConstructorInfo ctor = _t.GetConstructor(new [] { nullableUnderlyingType }); g.IL.Emit(OpCodes.Call, ctor); return; } g.EmitGetHelper(value, _t, allowExplicitConversion); EmitSetFromStack(g); }
protected internal override void EmitSet(CodeGen g, Operand value, bool allowExplicitConversion) { OperandExtensions.SetLeakedState(this, false); CheckScope(g); if (_t == null) _t = value.GetReturnType(g.TypeMapper); if (_var == null) _var = g.IL.DeclareLocal(_t); Type nullableUnderlyingType = Helpers.GetNullableUnderlyingType(_t); if (ReferenceEquals(value, null)) { if (nullableUnderlyingType != null) { g.InitObj(this); return; } } else if (nullableUnderlyingType == value.GetReturnType(g.TypeMapper)) { EmitAddressOf(g); g.EmitGetHelper(value, nullableUnderlyingType, false); ConstructorInfo ctor = _t.GetConstructor(new [] { nullableUnderlyingType}); g.IL.Emit(OpCodes.Call, ctor); return; } g.EmitGetHelper(value, _t, allowExplicitConversion); EmitSetFromStack(g); }