當前位置: 首頁>>代碼示例>>C#>>正文


C# BlockContext.HasSet方法代碼示例

本文整理匯總了C#中Mono.CSharp.BlockContext.HasSet方法的典型用法代碼示例。如果您正苦於以下問題:C# BlockContext.HasSet方法的具體用法?C# BlockContext.HasSet怎麽用?C# BlockContext.HasSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.CSharp.BlockContext的用法示例。


在下文中一共展示了BlockContext.HasSet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Resolve

		public bool Resolve (FlowBranching parent, BlockContext rc, IMethodData md)
		{
			if (resolved)
				return true;

			resolved = true;

			if (rc.HasSet (ResolveContext.Options.ExpressionTreeConversion))
				flags |= Flags.IsExpressionTree;

			try {
				ResolveMeta (rc);

				using (rc.With (ResolveContext.Options.DoFlowAnalysis, true)) {
					FlowBranchingToplevel top_level = rc.StartFlowBranching (this, parent);

					if (!Resolve (rc))
						return false;

					unreachable = top_level.End ();
				}
			} catch (Exception e) {
				if (e is CompletionResult || rc.Report.IsDisabled)
					throw;

				if (rc.CurrentBlock != null) {
					rc.Report.Error (584, rc.CurrentBlock.StartLocation, "Internal compiler error: {0}", e.Message);
				} else {
					rc.Report.Error (587, "Internal compiler error: {0}", e.Message);
				}

				if (Report.DebugFlags > 0)
					throw;
			}

			if (rc.ReturnType != TypeManager.void_type && !unreachable) {
				if (rc.CurrentAnonymousMethod == null) {
					// FIXME: Missing FlowAnalysis for generated iterator MoveNext method
					if (md is IteratorMethod) {
						unreachable = true;
					} else {
						rc.Report.Error (161, md.Location, "`{0}': not all code paths return a value", md.GetSignatureForError ());
						return false;
					}
				} else {
					rc.Report.Error (1643, rc.CurrentAnonymousMethod.Location, "Not all code paths return a value in anonymous method of type `{0}'",
							  rc.CurrentAnonymousMethod.GetSignatureForError ());
					return false;
				}
			}

			return true;
		}
開發者ID:alisci01,項目名稱:mono,代碼行數:53,代碼來源:statement.cs

示例2: DoResolve

		protected override bool DoResolve (BlockContext ec)
		{
			if (Expr == null) {
				if (ec.ReturnType == TypeManager.void_type)
					return true;
				
				ec.Report.Error (126, loc,
					"An object of a type convertible to `{0}' is required for the return statement",
					TypeManager.CSharpName (ec.ReturnType));
				return false;
			}

			if (ec.CurrentBlock.Toplevel.IsIterator) {
				ec.Report.Error (1622, loc, "Cannot return a value from iterators. Use the yield return " +
						  "statement to return a value, or yield break to end the iteration");
			}

			AnonymousExpression am = ec.CurrentAnonymousMethod;
			if (am == null && ec.ReturnType == TypeManager.void_type) {
				ec.Report.Error (127, loc, "`{0}': A return keyword must not be followed by any expression when method returns void",
					ec.GetSignatureForError ());
			}

			Expr = Expr.Resolve (ec);
			if (Expr == null)
				return false;

			if (ec.HasSet (ResolveContext.Options.InferReturnType)) {
				ec.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
				return true;
			}

			if (Expr.Type != ec.ReturnType) {
				Expr = Convert.ImplicitConversionRequired (ec, Expr, ec.ReturnType, loc);

				if (Expr == null) {
					if (am != null) {
						ec.Report.Error (1662, loc,
							"Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type",
							am.ContainerType, am.GetSignatureForError ());
					}
					return false;
				}
			}

			return true;			
		}
開發者ID:tgiphil,項目名稱:mono,代碼行數:47,代碼來源:statement.cs


注:本文中的Mono.CSharp.BlockContext.HasSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。