当前位置: 首页>>代码示例>>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;未经允许,请勿转载。