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


C# SimpleName.Resolve方法代碼示例

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


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

示例1: DoResolve

		public Expression DoResolve (EmitContext ec, Expression right_side, ResolveFlags flags)
		{
			if (type != null)
				throw new Exception ();
			//
			// Resolve the expression with flow analysis turned off, we'll do the definite
			// assignment checks later.  This is because we don't know yet what the expression
			// will resolve to - it may resolve to a FieldExpr and in this case we must do the
			// definite assignment check on the actual field and not on the whole struct.
			//

			Expression original = expr;
			expr = expr.Resolve (ec, flags | ResolveFlags.DisableFlowAnalysis);

			if (expr == null)
				return null;

			if (expr is SimpleName){
				SimpleName child_expr = (SimpleName) expr;
				
				Expression new_expr = new SimpleName (child_expr.Name, Identifier, loc);

				return new_expr.Resolve (ec, flags);
			}
					
			//
			// TODO: I mailed Ravi about this, and apparently we can get rid
			// of this and put it in the right place.
			// 
			// Handle enums here when they are in transit.
			// Note that we cannot afford to hit MemberLookup in this case because
			// it will fail to find any members at all
			//

			int errors = Report.Errors;
			
			Type expr_type = expr.Type;
			if ((expr is TypeExpr) &&
			    (expr_type == TypeManager.enum_type ||
			     expr_type.IsSubclassOf (TypeManager.enum_type))){
				
				Enum en = TypeManager.LookupEnum (expr_type);
				
				if (en != null) {
					object value = en.LookupEnumValue (ec, Identifier, loc);

					if (value != null){
						Constant c = Constantify (value, en.UnderlyingType);
						return new EnumConstant (c, expr_type);
					}
				}
			}

			if (expr_type.IsPointer){
				Error (23, "The `.' operator can not be applied to pointer operands (" +
				       TypeManager.CSharpName (expr_type) + ")");
				return null;
			}

			member_lookup = MemberLookupFinal (ec, expr_type, expr_type, Identifier, loc);
			if (member_lookup == null)
				return null;

			if (member_lookup is TypeExpr){
				member_lookup.Resolve (ec, ResolveFlags.Type);
				return member_lookup;
			} else if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type)
				return null;
			
			member_lookup = ResolveMemberAccess (ec, member_lookup, expr, loc, original);
			if (member_lookup == null)
				return null;

			// The following DoResolve/DoResolveLValue will do the definite assignment
			// check.

			if (right_side != null)
				member_lookup = member_lookup.DoResolveLValue (ec, right_side);
			else
				member_lookup = member_lookup.DoResolve (ec);

			return member_lookup;
		}
開發者ID:emtees,項目名稱:old-code,代碼行數:83,代碼來源:expression.cs


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