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


C# EmitContext.Set方法代码示例

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


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

示例1: DoResolve

		Expression DoResolve (EmitContext ec, bool lvalue_instance, bool out_access)
		{
			if (!FieldInfo.IsStatic){
				if (InstanceExpression == null){
					//
					// This can happen when referencing an instance field using
					// a fully qualified type expression: TypeName.InstanceField = xxx
					// 
					SimpleName.Error_ObjectRefRequired (ec, loc, GetSignatureForError ());
					return null;
				}

				// Resolve the field's instance expression while flow analysis is turned
				// off: when accessing a field "a.b", we must check whether the field
				// "a.b" is initialized, not whether the whole struct "a" is initialized.

				if (lvalue_instance) {
					using (ec.With (EmitContext.Flags.DoFlowAnalysis, false)) {
						Expression right_side =
							out_access ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess;
						InstanceExpression = InstanceExpression.ResolveLValue (ec, right_side, loc);
					}
				} else {
					ResolveFlags rf = ResolveFlags.VariableOrValue | ResolveFlags.DisableFlowAnalysis;
					InstanceExpression = InstanceExpression.Resolve (ec, rf);
				}

				if (InstanceExpression == null)
					return null;

				using (ec.Set (EmitContext.Flags.OmitStructFlowAnalysis)) {
					InstanceExpression.CheckMarshalByRefAccess (ec);
				}
			}

			// TODO: the code above uses some non-standard multi-resolve rules
			if (eclass != ExprClass.Invalid)
				return this;

			if (!ec.IsInObsoleteScope) {
				FieldBase f = TypeManager.GetField (FieldInfo);
				if (f != null) {
					f.CheckObsoleteness (loc);
				} else {
					ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (FieldInfo);
					if (oa != null)
						AttributeTester.Report_ObsoleteMessage (oa, TypeManager.GetFullNameSignature (FieldInfo), loc);
				}
			}

			IFixedBuffer fb = AttributeTester.GetFixedBuffer (FieldInfo);
			IVariableReference var = InstanceExpression as IVariableReference;
			
			if (fb != null) {
				IFixedExpression fe = InstanceExpression as IFixedExpression;
				if (!ec.InFixedInitializer && (fe == null || !fe.IsFixed)) {
					Report.Error (1666, loc, "You cannot use fixed size buffers contained in unfixed expressions. Try using the fixed statement");
				}

				if (InstanceExpression.eclass != ExprClass.Variable) {
					Report.SymbolRelatedToPreviousError (FieldInfo);
					Report.Error (1708, loc, "`{0}': Fixed size buffers can only be accessed through locals or fields",
						TypeManager.GetFullNameSignature (FieldInfo));
				} else if (var != null && var.IsHoisted) {
					AnonymousMethodExpression.Error_AddressOfCapturedVar (var, loc);
				}
				
				return new FixedBufferPtr (this, fb.ElementType, loc).Resolve (ec);
			}

			eclass = ExprClass.Variable;

			// If the instance expression is a local variable or parameter.
			if (var == null || var.VariableInfo == null)
				return this;

			VariableInfo vi = var.VariableInfo;
			if (!vi.IsFieldAssigned (ec, FieldInfo.Name, loc))
				return null;

			variable_info = vi.GetSubStruct (FieldInfo.Name);
			eclass = ExprClass.Variable;
			return this;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:84,代码来源:ecore.cs

示例2: Emit

		public override void Emit (EmitContext ec)
		{
			Block prev_block = ec.CurrentBlock;
			ec.CurrentBlock = this;

			if (scope_initializers != null) {
				SymbolWriter.OpenCompilerGeneratedBlock (ec.ig);

				using (ec.Set (EmitContext.Flags.OmitDebuggingInfo)) {
					foreach (Statement s in scope_initializers)
						s.Emit (ec);
				}

				SymbolWriter.CloseCompilerGeneratedBlock (ec.ig);
			}

			ec.Mark (StartLocation);
			DoEmit (ec);

			if (SymbolWriter.HasSymbolWriter)
				EmitSymbolInfo (ec);

			ec.CurrentBlock = prev_block;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:24,代码来源:statement.cs

示例3: Compatible

		public bool Compatible (EmitContext ec)
		{
			// TODO: Implement clone
			aec = new EmitContext (
				ec.ResolveContext, ec.TypeContainer, ec.DeclContainer,
				Location, null, ReturnType,
				(ec.InUnsafe ? Modifiers.UNSAFE : 0), /* No constructor */ false);

			aec.CurrentAnonymousMethod = this;
			aec.IsStatic = ec.IsStatic;

			IDisposable aec_dispose = null;
			EmitContext.Flags flags = 0;
			if (ec.InferReturnType)
				flags |= EmitContext.Flags.InferReturnType;

			if (ec.IsInProbingMode)
				flags |= EmitContext.Flags.ProbingMode;

			if (ec.IsInFieldInitializer)
				flags |= EmitContext.Flags.InFieldInitializer;

			if (ec.IsInUnsafeScope)
				flags |= EmitContext.Flags.InUnsafe;

			// HACK: Flag with 0 cannot be set 
			if (flags != 0)
				aec_dispose = aec.Set (flags);

			bool unreachable;
			bool res = aec.ResolveTopBlock (ec, Block, Block.Parameters, null, out unreachable);

			if (ec.InferReturnType)
				ReturnType = aec.ReturnType;

			if (aec_dispose != null) {
				aec_dispose.Dispose ();
			}

			return res;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:41,代码来源:anonymous.cs

示例4: ImplicitStandardConversionExists

		//
		// Returns true if the body of lambda expression can be implicitly
		// converted to the delegate of type `delegate_type'
		//
		public bool ImplicitStandardConversionExists (EmitContext ec, Type delegate_type)
		{
			using (ec.Set (EmitContext.Flags.ProbingMode)) {
				return Compatible (ec, delegate_type) != null;
			}
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:10,代码来源:anonymous.cs

示例5: InferReturnType

		public Type InferReturnType (EmitContext ec, TypeInferenceContext tic, Type delegate_type)
		{
			AnonymousMethodBody am;
			using (ec.Set (EmitContext.Flags.ProbingMode | EmitContext.Flags.InferReturnType)) {
				am = CompatibleMethod (ec, tic, GetType (), delegate_type);
			}
			
			if (am == null)
				return null;

			if (am.ReturnType == TypeManager.null_type)
				am.ReturnType = null;

			return am.ReturnType;
		}
开发者ID:lewurm,项目名称:benchmarker,代码行数:15,代码来源:anonymous.cs


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