本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator.EmitBrfalse_S方法的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator.EmitBrfalse_S方法的具体用法?C# TracingILGenerator.EmitBrfalse_S怎么用?C# TracingILGenerator.EmitBrfalse_S使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MsgPack.Serialization.Reflection.TracingILGenerator
的用法示例。
在下文中一共展示了TracingILGenerator.EmitBrfalse_S方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitUnpackerEndReadSubtree
public static void EmitUnpackerEndReadSubtree( TracingILGenerator il, LocalBuilder subtreeUnpacker )
{
Contract.Requires( il != null );
Contract.Requires( subtreeUnpacker != null );
/*
* finally
* {
* if( subtreeUnpacker != null )
* {
* subtreeUnpacker.Dispose();
* }
* }
*/
il.BeginFinallyBlock();
il.EmitAnyLdloc( subtreeUnpacker );
var endIf = il.DefineLabel( "END_IF" );
il.EmitBrfalse_S( endIf );
il.EmitAnyLdloc( subtreeUnpacker );
il.EmitAnyCall( Metadata._IDisposable.Dispose );
il.MarkLabel( endIf );
il.EndExceptionBlock();
}
示例2: EmitDeserializeCollectionValue
/// <summary>
/// Emits the deserialize collection 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="target">The target collection variable.</param>
/// <param name="member">The deserializing member metadata which holds the collection.</param>
/// <param name="memberType">Type of the deserializing member.</param>
/// <param name="nilImplication">The nil implication.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
public static void EmitDeserializeCollectionValue( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder target, MemberInfo member, Type memberType, NilImplication nilImplication, LocalVariableHolder localHolder )
{
Contract.Requires( emitter != null );
Contract.Requires( il != null );
Contract.Requires( unpackerArgumentIndex >= 0 );
Contract.Requires( target != null );
Contract.Requires( member != null );
Contract.Requires( memberType != null );
Contract.Requires( localHolder != null );
var endOfDeserialization = il.DefineLabel( "END_OF_DESERIALIZATION" );
EmitGeneralRead( il, unpackerArgumentIndex );
switch ( nilImplication )
{
case NilImplication.MemberDefault:
{
/*
* if( unpacker.Data.Value.IsNil )
* {
* // Skip current.
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = localHolder.UnpackedDataValue;
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
il.EmitBrtrue( endOfDeserialization );
break;
}
case NilImplication.Null:
case NilImplication.Prohibit:
{
/*
* // for Prohibit
* if( unpacker.Data.Value.IsNil )
* {
* throw SerializationEceptions.NewProhibitNullException( "..." );
* }
*
* // for Null, and
* if( unpacker.Data.Value.IsNil )
* {
* throw SerializationEceptions.NewReadOnlyMemberItemsMustNotBeNullMethod( "..." );
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = localHolder.UnpackedDataValue;
il.EmitAnyStloc( dataValue );
il.EmitAnyLdloca( dataValue );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
var endIf0 = il.DefineLabel( "END_IF0" );
il.EmitBrfalse_S( endIf0 );
il.EmitLdstr( member.Name );
if ( nilImplication == NilImplication.Prohibit )
{
il.EmitAnyCall( SerializationExceptions.NewNullIsProhibitedMethod );
}
else
{
// Because result member is readonly collection, so the member will not be null if packed value was nil.
il.EmitAnyCall( SerializationExceptions.NewReadOnlyMemberItemsMustNotBeNullMethod );
}
il.EmitThrow();
il.MarkLabel( endIf0 );
break;
}
}
/*
* if( !unpacker.IsArrayHeader && !unpacker.IsMapHeader )
* {
* throw new SerializatonException( "Cannot deserialize..." );
* }
//.........这里部分代码省略.........
示例3: 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 );
}
}
示例4: EmitNilImplication
/// <summary>
/// Emits the nil implication.
/// </summary>
/// <param name="il">The il generator.</param>
/// <param name="unpackerArgumentIndex">Index of the unpacker argument.</param>
/// <param name="memberName">Name of the deserializing member.</param>
/// <param name="nilImplication">The nil implication.</param>
/// <param name="endOfDeserialization">The label to the end of deserialization.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
public static void EmitNilImplication(
TracingILGenerator il,
int unpackerArgumentIndex,
string memberName,
NilImplication nilImplication,
Label endOfDeserialization,
LocalVariableHolder localHolder
)
{
switch ( nilImplication )
{
case NilImplication.MemberDefault:
{
// TODO: This should be empty for extra items.
/*
* if( unpacker.Data.Value.IsNil )
* {
* // Skip current.
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.Data );
var data = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = localHolder.UnpackedDataValue;
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 = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._Nullable<MessagePackObject>.Value );
var dataValue = localHolder.UnpackedDataValue;
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;
}
}
}
示例5: EmitNilImplication
/// <summary>
/// Emits the nil implication.
/// </summary>
/// <param name="il">The il generator.</param>
/// <param name="unpackerArgumentIndex">Index of the unpacker argument.</param>
/// <param name="member">Metadata of the serializing member.</param>
/// <param name="endOfDeserialization">The label to the end of deserialization.</param>
/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
public static void EmitNilImplication(
TracingILGenerator il,
int unpackerArgumentIndex,
SerializingMember member,
Label endOfDeserialization,
LocalVariableHolder localHolder
)
{
switch ( member.Contract.NilImplication )
{
case NilImplication.MemberDefault:
{
// TODO: This should be empty for extra items.
/*
* if( unpacker.Data.Value.IsNil )
* {
* // Skip current.
* goto END_OF_DESERIALIZATION;
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.LastReadData );
var data = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
il.EmitBrtrue( endOfDeserialization );
break;
}
case NilImplication.Null:
{
if ( member.Member.GetMemberValueType().GetIsValueType() && Nullable.GetUnderlyingType( member.Member.GetMemberValueType() ) == null )
{
throw SerializationExceptions.NewValueTypeCannotBeNull(
member.Contract.Name, member.Member.GetMemberValueType(), member.Member.DeclaringType
);
}
if ( !member.Member.CanSetValue() )
{
throw SerializationExceptions.NewReadOnlyMemberItemsMustNotBeNull(
member.Contract.Name
);
}
break;
}
case NilImplication.Prohibit:
{
if ( !member.Member.CanSetValue() )
{
throw SerializationExceptions.NewReadOnlyMemberItemsMustNotBeNull(
member.Contract.Name
);
}
/*
* if( unpacker.Data.Value.IsNil )
* {
* throw SerializationEceptions.NewProhibitNullException( "..." );
* }
*/
il.EmitAnyLdarg( unpackerArgumentIndex );
il.EmitGetProperty( Metadata._Unpacker.LastReadData );
var data = localHolder.UnpackedData;
il.EmitAnyStloc( data );
il.EmitAnyLdloca( data );
il.EmitGetProperty( Metadata._MessagePackObject.IsNil );
var endIf0 = il.DefineLabel( "END_IF0" );
il.EmitBrfalse_S( endIf0 );
il.EmitLdstr( member.Contract.Name );
il.EmitAnyCall( SerializationExceptions.NewNullIsProhibitedMethod );
il.EmitThrow();
il.MarkLabel( endIf0 );
break;
}
}
}
示例6: EmitDeserializeValue
public static void EmitDeserializeValue( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder value, LocalBuilder isUnpacked, string memberName, 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 ( memberName != null )
{
switch ( nilImplication )
{
case NilImplication.MemberDefault:
{
/*
* if( unpacker.Data.Value.IsNil )
* {
* // Skip current.
* 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 );
//.........这里部分代码省略.........