本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitBr_S方法的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator.EmitBr_S方法的具体用法?C# TracingILGenerator.EmitBr_S怎么用?C# TracingILGenerator.EmitBr_S使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitBr_S方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitDeserializeValue
public static void EmitDeserializeValue( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder value, NilImplication nilImplication, Action<TracingILGenerator, int> customUnpackerReading )
{
Contract.Requires( emitter != null );
Contract.Requires( il != null );
Contract.Requires( unpackerArgumentIndex >= 0 );
Contract.Requires( value != null );
if ( customUnpackerReading != null )
{
customUnpackerReading( il, unpackerArgumentIndex );
}
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:
*/
var then = il.DefineLabel( "THEN" );
var endIf = il.DefineLabel( "END_IF" );
var serializerGetter = emitter.RegisterSerializer( value.LocalType );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsArrayHeader );
il.EmitBrtrue_S( then );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsMapHeader );
il.EmitBrtrue_S( then );
// else
serializerGetter( il, 0 );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
il.EmitBr_S( endIf );
// then
var subtreeUnpacker = il.DeclareLocal( typeof( Unpacker ), "subtreeUnpacker" );
il.MarkLabel( then );
EmitUnpackerBeginReadSubtree( il, unpackerArgumentIndex, subtreeUnpacker );
serializerGetter( il, 0 );
il.EmitAnyLdloc( subtreeUnpacker );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
EmitUnpackerEndReadSubtree( il, subtreeUnpacker );
il.MarkLabel( endIf );
il.MarkLabel( endOfDeserialization );
}
示例2: EmitDeserializeValueCore
/// <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="value">The value local variable which stores unpacked value.</param>
/// <param name="targetType">The type of deserialzing type.</param>
/// <param name="member">The metadata for nil implication. Specify <c>null</c> if nil implication is not needed.</param>
/// <param name="memberName">The name of the member.</param>
/// <param name="endOfDeserialization">The end of deserialization label for nil implication.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
private static void EmitDeserializeValueCore( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder value, Type targetType, SerializingMember? member, string memberName, Label endOfDeserialization, LocalVariableHolder localHolder )
{
var directUnpacking = Metadata._Unpacker.GetDirectReadMethod( value.LocalType );
if ( directUnpacking != null && ( member == null || !UnpackHelpers.IsReadOnlyAppendableCollectionMember( member.Value.Member ) ) )
{
var isSuccess = localHolder.IsDeserializationSucceeded;
il.EmitLdc_I4_0();
il.EmitAnyStloc( isSuccess );
il.BeginExceptionBlock();
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitAnyLdloca( value );
il.EmitAnyCall( directUnpacking );
il.EmitAnyStloc( isSuccess );
il.BeginCatchBlock( typeof( MessageTypeException ) );
var ex = localHolder.GetCatchedException( typeof( MessageTypeException ) );
il.EmitAnyStloc( ex );
il.EmitTypeOf( targetType );
il.EmitLdstr( memberName );
il.EmitAnyLdloc( ex );
il.EmitAnyCall( SerializationExceptions.NewFailedToDeserializeMemberMethod );
il.EmitThrow();
il.EndExceptionBlock();
var endIf0 = il.DefineLabel( "END_IF" );
il.EmitAnyLdloc( isSuccess );
il.EmitBrtrue_S( endIf0 );
il.EmitAnyCall( SerializationExceptions.NewUnexpectedEndOfStreamMethod );
il.EmitThrow();
il.MarkLabel( endIf0 );
if ( member != null )
{
// If null, nil implication is NOT needed.
EmitNilImplicationForPrimitive( il, member.Value, value, endOfDeserialization );
}
}
else
{
EmitGeneralRead( il, unpackerArgumentIndex );
if ( member != null )
{
// If null, nil implication is NOT needed.
EmitNilImplication(
il,
unpackerArgumentIndex,
member.Value.Contract.Name,
member.Value.Contract.NilImplication,
endOfDeserialization,
localHolder
);
}
var thenIffCollection = il.DefineLabel( "THEN_IF_COLLECTION" );
var endIfCollection = il.DefineLabel( "END_IF_COLLECTION" );
/*
* if( !unpacker.IsArrayHeader && !unpacker.IsMapHeader )
* {
* value = GET_SERIALIZER().UnpackFrom( unpacker );
* }
* else
* {
* using( var subtreeUnpacker = unpacker.ReadSubtree() )
* {
* value = GET_SERIALIZER().UnpackFrom( subtreeUnpacker );
* }
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsArrayHeader );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsMapHeader );
il.EmitOr();
il.EmitBrtrue_S( thenIffCollection );
EmitUnpackFrom( emitter, il, value, unpackerArgumentIndex );
il.EmitBr_S( endIfCollection );
var subtreeUnpacker = localHolder.SubtreeUnpacker;
il.MarkLabel( thenIffCollection );
EmitUnpackerBeginReadSubtree( il, unpackerArgumentIndex, subtreeUnpacker );
EmitUnpackFrom( emitter, il, value, subtreeUnpacker );
EmitUnpackerEndReadSubtree( il, subtreeUnpacker );
il.MarkLabel( endIfCollection );
}
}
示例3: EmitDeserializeValue
//.........这里部分代码省略.........
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = il.DeclareLocal( typeof( MessagePackObject? ), "data" );
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = il.DeclareLocal( typeof( MessagePackObject ), "dataValue" );
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
il.EmitBrtrue( endOfDeserialization );
break;
}
case NilImplication.Prohibit:
{
/*
* if( unpacker.Data.Value.IsNil )
* {
* throw SerializationEceptions.NewProhibitNullException( "..." );
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = il.DeclareLocal( typeof( MessagePackObject? ), "data" );
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = il.DeclareLocal( typeof( MessagePackObject ), "dataValue" );
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
var endIf0 = il.DefineLabel( "END_IF0" );
il.EmitBrfalse_S( endIf0 );
il.EmitLdstr( memberName );
il.EmitAnyCall( SerializationExceptions.NewNullIsProhibitedMethod );
il.EmitThrow();
il.MarkLabel( endIf0 );
break;
}
}
}
/*
*
* 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:
*/
var then = il.DefineLabel( "THEN" );
var endIf = il.DefineLabel( "END_IF" );
var serializerGetter = emitter.RegisterSerializer( value.LocalType );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsArrayHeader );
il.EmitBrtrue_S( then );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.IsMapHeader );
il.EmitBrtrue_S( then );
// else
serializerGetter( il, 0 );
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
il.EmitBr_S( endIf );
// then
var subtreeUnpacker = il.DeclareLocal( typeof( Unpacker ), "subtreeUnpacker" );
il.MarkLabel( then );
EmitUnpackerBeginReadSubtree( il, unpackerArgumentIndex, subtreeUnpacker );
serializerGetter( il, 0 );
il.EmitAnyLdloc( subtreeUnpacker );
il.EmitAnyCall( typeof( MessagePackSerializer<> ).MakeGenericType( value.LocalType ).GetMethod( "UnpackFrom" ) );
il.EmitAnyStloc( value );
EmitUnpackerEndReadSubtree( il, subtreeUnpacker );
il.MarkLabel( endIf );
if ( isUnpacked != null )
{
il.EmitLdc_I4_1();
il.EmitAnyStloc( isUnpacked );
}
il.MarkLabel( endOfDeserialization );
}