当前位置: 首页>>代码示例>>C#>>正文


C# EmitContext.MarkLabel方法代码示例

本文整理汇总了C#中Mono.CSharp.EmitContext.MarkLabel方法的典型用法代码示例。如果您正苦于以下问题:C# EmitContext.MarkLabel方法的具体用法?C# EmitContext.MarkLabel怎么用?C# EmitContext.MarkLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.CSharp.EmitContext的用法示例。


在下文中一共展示了EmitContext.MarkLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitFinallyBody

        protected override void EmitFinallyBody(EmitContext ec)
        {
            if (!TypeManager.IsStruct (expr_type)) {
                Label skip = ec.DefineLabel ();
                local_copy.Emit (ec);
                ec.Emit (OpCodes.Brfalse, skip);
                local_copy.Emit (ec);
                ec.Emit (OpCodes.Callvirt, TypeManager.void_dispose_void);
                ec.MarkLabel (skip);
                return;
            }

            MethodSpec ms = MemberCache.FindMember (expr_type,
                MemberFilter.Method ("Dispose", 0, ParametersCompiled.EmptyReadOnlyParameters, TypeManager.void_type),
                BindingRestriction.InstanceOnly) as MethodSpec;

            if (ms == null) {
                local_copy.Emit (ec);
                ec.Emit (OpCodes.Box, expr_type);
                ec.Emit (OpCodes.Callvirt, TypeManager.void_dispose_void);
                return;
            }

            local_copy.AddressOf (ec, AddressOp.Load);
            ec.Emit (OpCodes.Call, ms);
        }
开发者ID:speier,项目名称:shake,代码行数:26,代码来源:statement.cs

示例2: EmitMoveNext

        internal void EmitMoveNext(EmitContext ec, Block original_block)
        {
            move_next_ok = ec.DefineLabel ();
            move_next_error = ec.DefineLabel ();

            if (resume_points == null) {
                EmitMoveNext_NoResumePoints (ec, original_block);
                return;
            }

            current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type);
            ec.Emit (OpCodes.Ldarg_0);
            ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
            ec.Emit (OpCodes.Stloc, current_pc);

            // We're actually in state 'running', but this is as good a PC value as any if there's an abnormal exit
            ec.Emit (OpCodes.Ldarg_0);
            ec.EmitInt ((int) State.After);
            ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);

            Label [] labels = new Label [1 + resume_points.Count];
            labels [0] = ec.DefineLabel ();

            bool need_skip_finally = false;
            for (int i = 0; i < resume_points.Count; ++i) {
                ResumableStatement s = resume_points [i];
                need_skip_finally |= s is ExceptionStatement;
                labels [i+1] = s.PrepareForEmit (ec);
            }

            if (need_skip_finally) {
                skip_finally = ec.GetTemporaryLocal (TypeManager.bool_type);
                ec.Emit (OpCodes.Ldc_I4_0);
                ec.Emit (OpCodes.Stloc, skip_finally);
            }

            SymbolWriter.StartIteratorDispatcher (ec);
            ec.Emit (OpCodes.Ldloc, current_pc);
            ec.Emit (OpCodes.Switch, labels);

            ec.Emit (OpCodes.Br, move_next_error);
            SymbolWriter.EndIteratorDispatcher (ec);

            ec.MarkLabel (labels [0]);

            SymbolWriter.StartIteratorBody (ec);
            original_block.Emit (ec);
            SymbolWriter.EndIteratorBody (ec);

            SymbolWriter.StartIteratorDispatcher (ec);

            ec.Emit (OpCodes.Ldarg_0);
            ec.EmitInt ((int) State.After);
            ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);

            ec.MarkLabel (move_next_error);
            ec.EmitInt (0);
            ec.Emit (OpCodes.Ret);

            ec.MarkLabel (move_next_ok);
            ec.Emit (OpCodes.Ldc_I4_1);
            ec.Emit (OpCodes.Ret);

            SymbolWriter.EndIteratorDispatcher (ec);
        }
开发者ID:speier,项目名称:shake,代码行数:65,代码来源:iterators.cs

示例3: DoEmit

                protected override void DoEmit(EmitContext ec)
                {
                    Label label_init = ec.DefineLabel ();

                    ec.Emit (OpCodes.Ldarg_0);
                    ec.Emit (OpCodes.Ldflda, host.PC.Spec);
                    ec.EmitInt ((int) Iterator.State.Start);
                    ec.EmitInt ((int) Iterator.State.Uninitialized);
                    ec.Emit (OpCodes.Call, TypeManager.int_interlocked_compare_exchange);

                    ec.EmitInt ((int) Iterator.State.Uninitialized);
                    ec.Emit (OpCodes.Bne_Un_S, label_init);

                    ec.Emit (OpCodes.Ldarg_0);
                    ec.Emit (OpCodes.Ret);

                    ec.MarkLabel (label_init);

                    new_storey.Emit (ec);
                    ec.Emit (OpCodes.Ret);
                }
开发者ID:speier,项目名称:shake,代码行数:21,代码来源:iterators.cs

示例4: Emit

		public override void Emit (EmitContext ec)
		{
			Label l_initialized = ec.DefineLabel ();

			if (mg_cache != null) {
				ec.Emit (OpCodes.Ldsfld, mg_cache.Spec);
				ec.Emit (OpCodes.Brtrue_S, l_initialized);
			}

			base.Emit (ec);

			if (mg_cache != null) {
				ec.Emit (OpCodes.Stsfld, mg_cache.Spec);
				ec.MarkLabel (l_initialized);
				ec.Emit (OpCodes.Ldsfld, mg_cache.Spec);
			}
		}
开发者ID:psni,项目名称:mono,代码行数:17,代码来源:delegate.cs

示例5: EmitDispose

        public void EmitDispose(EmitContext ec)
        {
            Label end = ec.DefineLabel ();

            Label [] labels = null;
            int n_resume_points = resume_points == null ? 0 : resume_points.Count;
            for (int i = 0; i < n_resume_points; ++i) {
                ResumableStatement s = (ResumableStatement) resume_points [i];
                Label ret = s.PrepareForDispose (ec, end);
                if (ret.Equals (end) && labels == null)
                    continue;
                if (labels == null) {
                    labels = new Label [resume_points.Count + 1];
                    for (int j = 0; j <= i; ++j)
                        labels [j] = end;
                }
                labels [i+1] = ret;
            }

            if (labels != null) {
                current_pc = ec.GetTemporaryLocal (TypeManager.uint32_type);
                ec.Emit (OpCodes.Ldarg_0);
                ec.Emit (OpCodes.Ldfld, IteratorHost.PC.Spec);
                ec.Emit (OpCodes.Stloc, current_pc);
            }

            ec.Emit (OpCodes.Ldarg_0);
            ec.EmitInt ((int) State.After);
            ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);

            if (labels != null) {
                //SymbolWriter.StartIteratorDispatcher (ec.ig);
                ec.Emit (OpCodes.Ldloc, current_pc);
                ec.Emit (OpCodes.Switch, labels);
                //SymbolWriter.EndIteratorDispatcher (ec.ig);

                foreach (ResumableStatement s in resume_points)
                    s.EmitForDispose (ec, this, end, true);
            }

            ec.MarkLabel (end);
        }
开发者ID:speier,项目名称:shake,代码行数:42,代码来源:iterators.cs

示例6: DoEmit

			protected override void DoEmit (EmitContext ec)
			{
				copy.EmitAssign (ec, for_each.expr);

				int rank = length_exprs.Length;
				Label[] test = new Label [rank];
				Label[] loop = new Label [rank];

				for (int i = 0; i < rank; i++) {
					test [i] = ec.DefineLabel ();
					loop [i] = ec.DefineLabel ();

					if (lengths != null)
						lengths [i].EmitAssign (ec, length_exprs [i]);
				}

				IntConstant zero = new IntConstant (0, loc);
				for (int i = 0; i < rank; i++) {
					variables [i].EmitAssign (ec, zero);

					ec.Emit (OpCodes.Br, test [i]);
					ec.MarkLabel (loop [i]);
				}

				variable.local_info.CreateBuilder (ec);
				variable.EmitAssign (ec, conv, false, false);

				statement.Emit (ec);

				ec.MarkLabel (ec.LoopBegin);

				for (int i = rank - 1; i >= 0; i--){
					counter [i].Emit (ec);

					ec.MarkLabel (test [i]);
					variables [i].Emit (ec);

					if (lengths != null)
						lengths [i].Emit (ec);
					else
						length_exprs [i].Emit (ec);

					ec.Emit (OpCodes.Blt, loop [i]);
				}

				ec.MarkLabel (ec.LoopEnd);
			}
开发者ID:alisci01,项目名称:mono,代码行数:47,代码来源:statement.cs

示例7: EmitFinallyBody

				protected override void EmitFinallyBody (EmitContext ec)
				{
					Label call_dispose = ec.DefineLabel ();
					if (dispose != null) {
						local_copy.Emit (ec, false);
						ec.Emit (OpCodes.Isinst, dispose.Type);
						dispose.Store (ec);
					}

					base.EmitFinallyBody (ec);

					if (dispose != null) {
						ec.MarkLabel (call_dispose);
						dispose.Release (ec);
					}
				}
开发者ID:tgiphil,项目名称:mono,代码行数:16,代码来源:statement.cs

示例8: DoEmit

		protected override void DoEmit (EmitContext ec)
		{
			LabelTarget (ec);
			ec.MarkLabel (label);
		}
开发者ID:tgiphil,项目名称:mono,代码行数:5,代码来源:statement.cs

示例9: EmitFinallyBody

		protected override void EmitFinallyBody (EmitContext ec)
		{
			//
			// if (lock_taken) Monitor.Exit (expr_copy)
			//
			Label skip = ec.DefineLabel ();

			if (lock_taken != null) {
				lock_taken.Emit (ec);
				ec.Emit (OpCodes.Brfalse_S, skip);
			}

			expr_copy.Emit (ec);
			ec.Emit (OpCodes.Call, TypeManager.void_monitor_exit_object);
			ec.MarkLabel (skip);
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:16,代码来源:statement.cs

示例10: DoEmit

				protected override void DoEmit (EmitContext ec)
				{
					Label label_init = ec.DefineLabel ();

					ec.Emit (OpCodes.Ldarg_0);
					ec.Emit (OpCodes.Ldflda, host.PC.Spec);
					ec.EmitInt ((int) Iterator.State.Start);
					ec.EmitInt ((int) Iterator.State.Uninitialized);

					var m = ec.Module.PredefinedMembers.InterlockedCompareExchange.Resolve (loc);
					if (m != null)
						ec.Emit (OpCodes.Call, m);

					ec.EmitInt ((int) Iterator.State.Uninitialized);
					ec.Emit (OpCodes.Bne_Un_S, label_init);

					ec.Emit (OpCodes.Ldarg_0);
					ec.Emit (OpCodes.Ret);

					ec.MarkLabel (label_init);

					new_storey.Emit (ec);
					ec.Emit (OpCodes.Ret);
				}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:24,代码来源:iterators.cs

示例11: EmitResultLift

		public void EmitResultLift (EmitContext ec, TypeSpec type, bool statement)
		{
			if (!NullShortCircuit)
				throw new InternalErrorException ();

			bool value_rt = TypeSpec.IsValueType (type);
			TypeSpec lifted;
			if (value_rt) {
				if (type.IsNullableType)
					lifted = type;
				else {
					lifted = Nullable.NullableInfo.MakeType (ec.Module, type);
					ec.Emit (OpCodes.Newobj, Nullable.NullableInfo.GetConstructor (lifted));
				}
			} else {
				lifted = null;
			}

			var end = ec.DefineLabel ();
			if (value_on_stack || !statement) {
				ec.Emit (OpCodes.Br_S, end);
			}

			ec.MarkLabel (NullOperatorLabel);

			if (value_on_stack)
				ec.Emit (OpCodes.Pop);

			if (!statement) {
				if (value_rt)
					Nullable.LiftedNull.Create (lifted, Location.Null).Emit (ec);
				else
					ec.EmitNull ();
			}

			ec.MarkLabel (end);
		}
开发者ID:frje,项目名称:SharpLang,代码行数:37,代码来源:codegen.cs

示例12: MarkYield

		//
		// Called back from Yield
		//
		public void MarkYield (EmitContext ec, Expression expr, int resume_pc, bool unwind_protect, Label resume_point)
		{
			// Store the new current
			ec.Emit (OpCodes.Ldarg_0);
			expr.Emit (ec);
			ec.Emit (OpCodes.Stfld, IteratorHost.CurrentField.Spec);

			//
			// Guard against being disposed meantime
			//
			Label disposed = ec.DefineLabel ();
			ec.Emit (OpCodes.Ldarg_0);
			ec.Emit (OpCodes.Ldfld, IteratorHost.DisposingField.Spec);
			ec.Emit (OpCodes.Brtrue_S, disposed);

			//
			// store resume program-counter
			//
			ec.Emit (OpCodes.Ldarg_0);
			ec.EmitInt (resume_pc);
			ec.Emit (OpCodes.Stfld, IteratorHost.PC.Spec);
			ec.MarkLabel (disposed);

			// mark finally blocks as disabled
			if (unwind_protect && skip_finally != null) {
				ec.EmitInt (1);
				ec.Emit (OpCodes.Stloc, skip_finally);
			}

			// Return ok
			ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, move_next_ok);

			ec.MarkLabel (resume_point);
		}
开发者ID:ngraziano,项目名称:mono,代码行数:37,代码来源:iterators.cs

示例13: EmitForDispose

		public override void EmitForDispose (EmitContext ec, Iterator iterator, Label end, bool have_dispatcher)
		{
			if (emitted_dispose)
				return;

			emitted_dispose = true;

			Label end_of_try = ec.DefineLabel ();

			// Ensure that the only way we can get into this code is through a dispatcher
			if (have_dispatcher)
				ec.Emit (OpCodes.Br, end);

			ec.BeginExceptionBlock ();

			ec.MarkLabel (dispose_try_block);

			Label [] labels = null;
			for (int i = 0; i < resume_points.Count; ++i) {
				ResumableStatement s = (ResumableStatement) resume_points [i];
				Label ret = s.PrepareForDispose (ec, end_of_try);
				if (ret.Equals (end_of_try) && labels == null)
					continue;
				if (labels == null) {
					labels = new Label [resume_points.Count];
					for (int j = 0; j < i; ++j)
						labels [j] = end_of_try;
				}
				labels [i] = ret;
			}

			if (labels != null) {
				int j;
				for (j = 1; j < labels.Length; ++j)
					if (!labels [0].Equals (labels [j]))
						break;
				bool emit_dispatcher = j < labels.Length;

				if (emit_dispatcher) {
					//SymbolWriter.StartIteratorDispatcher (ec.ig);
					ec.Emit (OpCodes.Ldloc, iterator.CurrentPC);
					ec.EmitInt (first_resume_pc);
					ec.Emit (OpCodes.Sub);
					ec.Emit (OpCodes.Switch, labels);
					//SymbolWriter.EndIteratorDispatcher (ec.ig);
				}

				foreach (ResumableStatement s in resume_points)
					s.EmitForDispose (ec, iterator, end_of_try, emit_dispatcher);
			}

			ec.MarkLabel (end_of_try);

			ec.BeginFinallyBlock ();

			EmitFinallyBody (ec);

			ec.EndExceptionBlock ();
		}
开发者ID:alisci01,项目名称:mono,代码行数:59,代码来源:statement.cs

示例14: Emit

		public override void Emit (EmitContext ec)
		{
			if (Report.Errors > 0)
				return;

#if PRODUCTION
			try {
#endif
			if (ec.HasReturnLabel)
				ec.ReturnLabel = ec.DefineLabel ();

			base.Emit (ec);

			ec.Mark (EndLocation);

			if (ec.HasReturnLabel)
				ec.MarkLabel (ec.ReturnLabel);

			if (ec.return_value != null) {
				ec.Emit (OpCodes.Ldloc, ec.return_value);
				ec.Emit (OpCodes.Ret);
			} else {
				//
				// If `HasReturnLabel' is set, then we already emitted a
				// jump to the end of the method, so we must emit a `ret'
				// there.
				//
				// Unfortunately, System.Reflection.Emit automatically emits
				// a leave to the end of a finally block.  This is a problem
				// if no code is following the try/finally block since we may
				// jump to a point after the end of the method.
				// As a workaround, we're always creating a return label in
				// this case.
				//

				if (ec.HasReturnLabel || !unreachable) {
					if (ec.ReturnType != TypeManager.void_type)
						ec.Emit (OpCodes.Ldloc, ec.TemporaryReturn ());
					ec.Emit (OpCodes.Ret);
				}
			}

#if PRODUCTION
			} catch (Exception e){
				Console.WriteLine ("Exception caught by the compiler while emitting:");
				Console.WriteLine ("   Block that caused the problem begin at: " + block.loc);
					
				Console.WriteLine (e.GetType ().FullName + ": " + e.Message);
				throw;
			}
#endif
		}
开发者ID:alisci01,项目名称:mono,代码行数:52,代码来源:statement.cs

示例15: EmitConditionalAccess

		protected void EmitConditionalAccess (EmitContext ec)
		{
			var a_expr = arguments [0].Expr;

			var des = a_expr as DynamicExpressionStatement;
			if (des != null) {
				des.EmitConditionalAccess (ec);
			}

			if (HasConditionalAccess ()) {
				var NullOperatorLabel = ec.DefineLabel ();

				if (ExpressionAnalyzer.IsInexpensiveLoad (a_expr)) {
					a_expr.Emit (ec);
				} else {
					var lt = new LocalTemporary (a_expr.Type);
					lt.EmitAssign (ec, a_expr, true, false);

					Arguments [0].Expr = lt;
				}

				ec.Emit (OpCodes.Brtrue_S, NullOperatorLabel);

				if (!ec.ConditionalAccess.Statement) {
					if (ec.ConditionalAccess.Type.IsNullableType)
						Nullable.LiftedNull.Create (ec.ConditionalAccess.Type, Location.Null).Emit (ec);
					else
						ec.EmitNull ();
				}

				ec.Emit (OpCodes.Br, ec.ConditionalAccess.EndLabel);
				ec.MarkLabel (NullOperatorLabel);

				return;
			}

			if (a_expr.HasConditionalAccess ()) {
				var lt = new LocalTemporary (a_expr.Type);
				lt.EmitAssign (ec, a_expr, false, false);

				Arguments [0].Expr = lt;
			}
		}
开发者ID:caomw,项目名称:mono,代码行数:43,代码来源:dynamic.cs


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