• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Reflection.TracingILGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MsgPack.Serialization.Reflection.TracingILGenerator的典型用法代码示例。如果您正苦于以下问题:C# TracingILGenerator类的具体用法?C# TracingILGenerator怎么用?C# TracingILGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TracingILGenerator类属于MsgPack.Serialization.Reflection命名空间,在下文中一共展示了TracingILGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EmitFor

		/// <summary>
		///		Emits 'for' statement on current IL stream.
		/// </summary>
		/// <param name="il">IL generator to be emitted to.</param>
		/// <param name="count">'count' local variable which is <see cref="Int32"/> type and holds maximum loop count.</param>
		/// <param name="bodyEmitter">Delegate to emit for statement body.</param>
		public static void EmitFor( TracingILGenerator il, LocalBuilder count, Action<TracingILGenerator, LocalBuilder> bodyEmitter )
		{
			Contract.Requires( il != null );
			Contract.Requires( count != null );
			Contract.Requires( bodyEmitter != null );

			var i = il.DeclareLocal( typeof( int ), "i" );
			il.EmitLdc_I4_0();
			il.EmitAnyStloc( i );
			var forCond = il.DefineLabel( "FOR_COND" );
			il.EmitBr( forCond );
			var body = il.DefineLabel( "BODY" );
			il.MarkLabel( body );
			bodyEmitter( il, i );
			// increment
			il.EmitAnyLdloc( i );
			il.EmitLdc_I4_1();
			il.EmitAdd();
			il.EmitAnyStloc( i );
			// cond
			il.MarkLabel( forCond );
			il.EmitAnyLdloc( i );
			il.EmitAnyLdloc( count );
			il.EmitBlt( body );
		}
开发者ID:purplecow,项目名称:msgpack-cli,代码行数:31,代码来源:Emittion.cs


示例2: LoadValue

		public override void LoadValue( TracingILGenerator il, bool shouldBeAddress )
		{
			this.Evaluate( il );
			il.TraceWriteLine( "// Load->: {0}", this );
			if ( this.ContextType.ResolveRuntimeType().GetIsValueType() && shouldBeAddress )
			{
				if ( this._isLocal )
				{
					il.EmitAnyLdloca( this._index );
				}
				else
				{
					il.EmitAnyLdarga( this._index );
				}
			}
			else
			{
				if ( this._isLocal )
				{
					il.EmitAnyLdloc( this._index );
				}
				else
				{
					il.EmitAnyLdarg( this._index );
				}
			}
			il.TraceWriteLine( "// ->Load: {0}", this );
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:28,代码来源:VariableILConstruct.cs


示例3: DoConditionalInstruction

		private void DoConditionalInstruction(
			TracingILGenerator il, Action onThen, Action onElse
			)
		{
			if ( this._elseExpression != null )
			{
				var @else = il.DefineLabel( "ELSE" );
				var endIf = il.DefineLabel( "END_IF" );
				this._condition.Branch( il, @else );
				onThen();
				if ( !this._thenExpression.IsTerminating )
				{
					il.EmitBr( endIf );
				}

				il.MarkLabel( @else );
				onElse();
				il.MarkLabel( endIf );
			}
			else
			{
				var endIf = il.DefineLabel( "END_IF" );
				this._condition.Branch( il, endIf );
				onThen();
				il.MarkLabel( endIf );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:27,代码来源:ConditionalILConstruct.cs


示例4: Evaluate

		public override void Evaluate( TracingILGenerator il )
		{
			if ( this._value != null )
			{
				this._value.LoadValue( il, false );
			}

			this._variable.StoreValue( il );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:9,代码来源:StoreVariableILConstruct.cs


示例5: StoreValue

		public override void StoreValue( TracingILGenerator il )
		{
			il.TraceWriteLine( "// Stor->: {0}", this );
			this.DoConditionalInstruction(
				il,
				() => this._thenExpression.StoreValue( il ),
				() => this._elseExpression.StoreValue( il )
				);
			il.TraceWriteLine( "// ->Stor: {0}", this );
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:10,代码来源:ConditionalILConstruct.cs


示例6: LoadValue

		public override void LoadValue( TracingILGenerator il, bool shouldBeAddress )
		{
			il.TraceWriteLine( "// Load->: {0}", this );
			this.DoConditionalInstruction(
				il,
				() => this._thenExpression.LoadValue( il, shouldBeAddress ),
				() => this._elseExpression.LoadValue( il, shouldBeAddress )
				);
			il.TraceWriteLine( "// ->Load: {0}", this );
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:10,代码来源:ConditionalILConstruct.cs


示例7: Evaluate

		public override void Evaluate( TracingILGenerator il )
		{
			il.TraceWriteLine( "// Eval->: {0}", this );
			this.DoConditionalInstruction(
				il,
				() => this._thenExpression.Evaluate( il ),
				() => this._elseExpression.Evaluate( il )
				);
			il.TraceWriteLine( "// ->Eval: {0}", this );
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:10,代码来源:ConditionalILConstruct.cs


示例8: Evaluate

		private void Evaluate( TracingILGenerator il, bool shouldBeAddress )
		{
			if ( !this._isBound )
			{
				this._binding.Evaluate( il );
				this._isBound = true;
			}

			this._expression.LoadValue( il, shouldBeAddress );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:10,代码来源:StatementExpressionILConstruct.cs


示例9: Evaluate

		public override void Evaluate( TracingILGenerator il )
		{
			if ( this._isLocal && this._index < 0 )
			{
				il.TraceWriteLine( "// Eval->: {0}", this );

				this._index = il.DeclareLocal( this.ContextType.ResolveRuntimeType(), this._name ).LocalIndex;

				il.TraceWriteLine( "// ->Eval: {0}", this );
			}
		}
开发者ID:msgpack,项目名称:msgpack-cli,代码行数:11,代码来源:VariableILConstruct.cs


示例10: Branch

		public override void Branch( TracingILGenerator il, Label @else )
		{
			il.TraceWriteLine( "// Brnc->: {0}", this );
			foreach ( var expression in this._expressions )
			{
				expression.LoadValue( il, false );
				il.EmitBrfalse( @else );
			}

			il.TraceWriteLine( "// ->Brnc: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:11,代码来源:AndConditionILConstruct.cs


示例11: Evaluate

		public override void Evaluate( TracingILGenerator il )
		{
			il.TraceWriteLine( "// Eval->: {0}", this );

			foreach ( var statement in this._statements )
			{
				statement.Evaluate( il );
			}

			il.TraceWriteLine( "// ->Eval: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:11,代码来源:SequenceILConstruct.cs


示例12: EvaluateCore

		private void EvaluateCore( TracingILGenerator il )
		{
			for ( int i = 0; i < this._expressions.Count; i++ )
			{
				this._expressions[ i ].LoadValue( il, false );

				if ( i > 0 )
				{
					il.EmitAnd();
				}
			}
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:12,代码来源:AndConditionILConstruct.cs


示例13: Branch

		public sealed override void Branch( TracingILGenerator il, Label @else )
		{
			il.TraceWriteLine( "// Brnc->: {0}", this );
			if ( this.ContextType != typeof( bool ) )
			{
				throw new InvalidOperationException(
					String.Format( CultureInfo.CurrentCulture, "Cannot branch with non boolean type '{0}'.", this.ContextType )
					);
			}

			this.BranchCore( il, @else );
			il.TraceWriteLine( "// ->Brnc: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:13,代码来源:ContextfulILConstruct.cs


示例14: StoreValue

		public override void StoreValue( TracingILGenerator il )
		{
			il.TraceWriteLine( "// Stor->: {0}", this );
			if ( this._instance != null )
			{
				this._instance.LoadValue( il, this._instance.ContextType.GetIsValueType() );
			}

			this._value.LoadValue( il, false );

			il.EmitStfld( this._field );
			il.TraceWriteLine( "// ->Stor: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:13,代码来源:StoreFieldILConstruct.cs


示例15: LoadValue

		public override void LoadValue( TracingILGenerator il, bool shouldBeAddress )
		{
			il.TraceWriteLine( "// Load->: {0}", this );
			if ( this._instance != null )
			{
				this._instance.LoadValue( il, this._instance.ContextType.GetIsValueType() );
			}

			if ( shouldBeAddress )
			{
				il.EmitLdflda( this._field );
			}
			else
			{
				il.EmitLdfld( this._field );
			}
			il.TraceWriteLine( "// ->Load: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:18,代码来源:LoadFieldILConstruct.cs


示例16: LoadValue

		public override void LoadValue( TracingILGenerator il, bool shouldBeAddress )
		{
			if ( this._statements.Length == 0 )
			{
				base.LoadValue( il, shouldBeAddress );
				return;
			}

			il.TraceWriteLine( "// Eval(Load)->: {0}", this );

			for ( var i = 0; i < this._statements.Length - 1; i++ )
			{
				this._statements[ i ].Evaluate( il );
			}

			this._statements.Last().LoadValue( il, shouldBeAddress );

			il.TraceWriteLine( "// ->Eval(Load): {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:19,代码来源:SequenceILConstruct.cs


示例17: EmitDeserializeValueWithoutNilImplication

		/// <summary>
		///		Emits deserializing value instructions.
		/// </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="memberName">The name of the member.</param>
		/// <param name="localHolder">The <see cref="LocalVariableHolder"/> which holds shared local variable information.</param>
		public static void EmitDeserializeValueWithoutNilImplication( SerializerEmitter emitter, TracingILGenerator il, int unpackerArgumentIndex, LocalBuilder value, Type targetType, string memberName, LocalVariableHolder localHolder )
		{
			Contract.Requires( emitter != null );
			Contract.Requires( il != null );
			Contract.Requires( unpackerArgumentIndex >= 0 );
			Contract.Requires( value != 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:
			 */

			// Nil implication is not needed.
			EmitDeserializeValueCore( emitter, il, unpackerArgumentIndex, value, targetType, null, memberName, endOfDeserialization, localHolder );

			il.MarkLabel( endOfDeserialization );
		}
开发者ID:purplecow,项目名称:msgpack-cli,代码行数:42,代码来源:Emittion.cs


示例18: LoadValue

		public override void LoadValue( TracingILGenerator il, bool shouldBeAddress )
		{
			il.TraceWriteLine( "// Load->: {0}", this );
			this.Evaluate( il, shouldBeAddress );
			il.TraceWriteLine( "// ->Load: {0}", this );
		}
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:6,代码来源:StatementExpressionILConstruct.cs


示例19: EmitConstruction

		public static void EmitConstruction( TracingILGenerator il, LocalBuilder target, Action<TracingILGenerator> initialCountLoadingEmitter )
		{
			Contract.Requires( il != null );
			Contract.Requires( target != null );
			Contract.Requires( initialCountLoadingEmitter != null );

			// TODO: For collection, supports .ctor(IEnumerable<> other)

			if ( target.LocalType.IsArray )
			{
				initialCountLoadingEmitter( il );
				il.EmitNewarr( target.LocalType.GetElementType() );
				il.EmitAnyStloc( target );
				return;
			}

			ConstructorInfo ctor = target.LocalType.GetConstructor( _ctor_Int32_ParameterTypes );
			if ( ctor != null && initialCountLoadingEmitter != null && typeof( IEnumerable ).IsAssignableFrom( target.LocalType ) )
			{
				if ( target.LocalType.IsValueType )
				{
					// Same as general method call
					var capacity = il.DeclareLocal( typeof( int ), "capacity" );
					initialCountLoadingEmitter( il );
					il.EmitAnyStloc( capacity );
					il.EmitAnyLdloca( target );
					il.EmitAnyLdloc( capacity );
					il.EmitCallConstructor( ctor );
				}
				else
				{
					initialCountLoadingEmitter( il );
					il.EmitNewobj( ctor );
					il.EmitAnyStloc( target );
				}
				return;
			}

			if ( target.LocalType.IsValueType )
			{
				// ValueType instance has been initialized by the runtime.
				return;
			}

			ctor = target.LocalType.GetConstructor( Type.EmptyTypes );
			if ( ctor == null )
			{
				throw SerializationExceptions.NewTargetDoesNotHavePublicDefaultConstructorNorInitialCapacity( target.LocalType );
			}

			il.EmitNewobj( ctor );
			il.EmitAnyStloc( target );
		}
开发者ID:purplecow,项目名称:msgpack-cli,代码行数:53,代码来源:Emittion.cs


示例20: 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();
		}
开发者ID:purplecow,项目名称:msgpack-cli,代码行数:24,代码来源:Emittion.cs



注:本文中的MsgPack.Serialization.Reflection.TracingILGenerator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JsRt.JavaScriptValue类代码示例发布时间:2022-05-26
下一篇:
C# MsgPack.SplittingStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap