本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitLdnull方法的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator.EmitLdnull方法的具体用法?C# TracingILGenerator.EmitLdnull怎么用?C# TracingILGenerator.EmitLdnull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitLdnull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitCompareNull
private static void EmitCompareNull( TracingILGenerator il, LocalBuilder value, Label targetIfNotNull )
{
if ( value.LocalType == typeof( MessagePackObject ) )
{
il.EmitAnyLdloca( value );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
il.EmitBrfalse_S( targetIfNotNull );
}
else if ( value.LocalType.GetIsValueType() )
{
Contract.Assert( Nullable.GetUnderlyingType( value.LocalType ) != null, value.LocalType.FullName );
il.EmitAnyLdloca( value );
il.EmitGetProperty( value.LocalType.GetProperty( "HasValue" ) );
il.EmitBrtrue_S( targetIfNotNull );
}
else // ref type
{
il.EmitAnyLdloc( value );
il.EmitLdnull();
il.EmitBne_Un_S( targetIfNotNull );
}
}
示例2: EmitDeserializeValue
/// <summary>
/// Emits the deserialize value.
/// </summary>
/// <param name="emitter">The emitter.</param>
/// <param name="il">The il generator.</param>
/// <param name="unpackerArgumentIndex">Index of the unpacker argument.</param>
/// <param name="result">The result local variable which represents the result of deserialization.</param>
/// <param name="member">The metadata for nil implication. Specify <c>null</c> if nil implication is not needed.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
public static void EmitDeserializeValue( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder result, SerializingMember member, LocalVariableHolder localHolder )
{
Contract.Requires( emitter != null );
Contract.Requires( il != null );
Contract.Requires( unpackerArgumentIndex >= 0 );
Contract.Requires( result != null );
var endOfDeserialization = il.DefineLabel( "END_OF_DESERIALIZATION" );
/*
*
* if( !unpacker.IsArrayHeader && !unpacker.IsMapHeader )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* else
* {
* using( var subtreeUnpacker = unpacker.ReadSubtree )
* {
* valueN = GET_SERIALIZER.UnpackFrom( unpacker );
* }
* }
*
* isValueNUnpacked = true;
* END_OF_DESERIALIZATION:
*/
LocalBuilder value;
bool useDummyNullableValue = false;
if ( member.Member.GetMemberValueType().GetIsValueType() &&
Nullable.GetUnderlyingType( member.Member.GetMemberValueType() ) == null )
{
// Use temporary nullable value for nil implication.
value = localHolder.GetDeserializedValue(
typeof( Nullable<> ).MakeGenericType( member.Member.GetMemberValueType() ) );
useDummyNullableValue = true;
}
else
{
value = localHolder.GetDeserializedValue( member.Member.GetMemberValueType() );
}
if ( value.LocalType.GetIsValueType() )
{
il.EmitAnyLdloca( value );
il.EmitInitobj( value.LocalType );
}
else
{
il.EmitLdnull();
il.EmitAnyStloc( value );
}
EmitDeserializeValueCore( emitter, il, unpackerArgumentIndex, value, result.LocalType, member, member.Contract.Name, endOfDeserialization, localHolder );
if ( result.LocalType.IsValueType )
{
il.EmitAnyLdloca( result );
}
else
{
il.EmitAnyLdloc( result );
}
if ( useDummyNullableValue )
{
il.EmitAnyLdloca( value );
il.EmitGetProperty( typeof( Nullable<> ).MakeGenericType( member.Member.GetMemberValueType() ).GetProperty( "Value" ) );
}
else
{
il.EmitAnyLdloc( value );
}
EmitStoreValue( il, member.Member );
il.MarkLabel( endOfDeserialization );
}