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


C# ResolveContext.HasAny方法代码示例

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


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

示例1: DoResolve

		protected override Expression DoResolve (ResolveContext rc)
		{
			if (rc.HasSet (ResolveContext.Options.ConstantScope)) {
				rc.Report.Error (1706, loc, "Anonymous methods and lambda expressions cannot be used in the current context");
				return null;
			}

			//
			// Update top-level block generated duting parsing with actual top-level block
			//
			if (rc.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer) && rc.CurrentMemberDefinition.Parent.PartialContainer.PrimaryConstructorParameters != null) {
				var tb = rc.ConstructorBlock.ParametersBlock.TopBlock;
				if (Block.TopBlock != tb) {
					Block b = Block;
					while (b.Parent != Block.TopBlock && b != Block.TopBlock)
						b = b.Parent;

					b.Parent = tb;
					tb.IncludeBlock (Block, Block.TopBlock);
					b.ParametersBlock.TopBlock = tb;
				}
			}

			eclass = ExprClass.Value;

			//
			// This hack means `The type is not accessible
			// anywhere', we depend on special conversion
			// rules.
			// 
			type = InternalType.AnonymousMethod;

			if (!DoResolveParameters (rc))
				return null;

			return this;
		}
开发者ID:FrancisVarga,项目名称:mono,代码行数:37,代码来源:anonymous.cs

示例2: DoSimpleNameResolve


//.........这里部分代码省略.........
            }

            if (e == null) {
            /*
                if (almost_matched == null && almost_matched_members.Count > 0) {
                    almost_matched_type = ec.CurrentType;
                    almost_matched = new List<MemberSpec> (almost_matched_members);
                }
            */
                e = ResolveAsTypeStep (ec, true);
            }

            if (e == null) {
                if (current_block != null) {
                    IKnownVariable ikv = current_block.Explicit.GetKnownVariable (Name);
                    if (ikv != null) {
                        LocalInfo li = ikv as LocalInfo;
                        // Supress CS0219 warning
                        if (li != null)
                            li.Used = true;

                        Error_VariableIsUsedBeforeItIsDeclared (ec.Report, Name);
                        return null;
                    }
                }

                if (RootContext.EvalMode){
                    FieldInfo fi = Evaluator.LookupField (Name);
                    if (fi != null)
                        return new FieldExpr (Import.CreateField (fi, null), loc).Resolve (ec);
                }
            /*
                if (almost_matched != null)
                    almost_matched_members = almost_matched;
                if (almost_matched_type == null)
                    almost_matched_type = ec.CurrentType;
            */
                string type_name = ec.MemberContext.CurrentType == null ? null : ec.MemberContext.CurrentType.Name;
                return Error_MemberLookupFailed (ec, ec.CurrentType, null, ec.CurrentType, Name, arity,
                    type_name, MemberKind.All, BindingRestriction.AccessibleOnly);
            }

            if (e is MemberExpr) {
                MemberExpr me = (MemberExpr) e;

                Expression left;
                if (me.IsInstance) {
                    if (ec.IsStatic || ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer | ResolveContext.Options.ConstantScope)) {
                        //
                        // Note that an MemberExpr can be both IsInstance and IsStatic.
                        // An unresolved MethodGroupExpr can contain both kinds of methods
                        // and each predicate is true if the MethodGroupExpr contains
                        // at least one of that kind of method.
                        //
            /*
                        if (!me.IsStatic &&
                            (!intermediate || !IdenticalNameAndTypeName (ec, me, loc))) {
                            Error_ObjectRefRequired (ec, loc, me.GetSignatureForError ());
                            return null;
                        }
            */
                        //
                        // Pass the buck to MemberAccess and Invocation.
                        //
                        left = EmptyExpression.Null;
                    } else {
                        left = ec.GetThis (loc);
                    }
                } else {
                    left = new TypeExpression (ec.CurrentType, loc);
                }

                me = me.ResolveMemberAccess (ec, left, loc, null);
                if (me == null)
                    return null;

                if (HasTypeArguments) {
                    if (!targs.Resolve (ec))
                        return null;

                    me.SetTypeArguments (ec, targs);
                }

                if (!me.IsStatic && (me.InstanceExpression != null && me.InstanceExpression != EmptyExpression.Null) &&
                    TypeManager.IsNestedFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
                    me.InstanceExpression.Type != me.DeclaringType &&
                    !TypeManager.IsFamilyAccessible (me.InstanceExpression.Type, me.DeclaringType) &&
                    (!intermediate || !IdenticalNameAndTypeName (ec, e, loc))) {
                    ec.Report.Error (38, loc, "Cannot access a nonstatic member of outer type `{0}' via nested type `{1}'",
                        TypeManager.CSharpName (me.DeclaringType), TypeManager.CSharpName (me.InstanceExpression.Type));
                    return null;
                }

                return (right_side != null)
                    ? me.DoResolveLValue (ec, right_side)
                    : me.Resolve (ec);
            }

            return e;
        }
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs

示例3: DoResolve

		public override Expression DoResolve (ResolveContext ec)
		{
			count = count.Resolve (ec);
			if (count == null)
				return null;
			
			if (count.Type != TypeManager.uint32_type){
				count = Convert.ImplicitConversionRequired (ec, count, TypeManager.int32_type, loc);
				if (count == null)
					return null;
			}

			Constant c = count as Constant;
			if (c != null && c.IsNegative) {
				ec.Report.Error (247, loc, "Cannot use a negative size with stackalloc");
				return null;
			}

			if (ec.HasAny (ResolveContext.Options.CatchScope | ResolveContext.Options.FinallyScope)) {
				ec.Report.Error (255, loc, "Cannot use stackalloc in finally or catch");
			}

			TypeExpr texpr = t.ResolveAsTypeTerminal (ec, false);
			if (texpr == null)
				return null;

			otype = texpr.Type;

			if (!TypeManager.VerifyUnManaged (otype, loc))
				return null;

			type = TypeManager.GetPointerType (otype);
			eclass = ExprClass.Value;

			return this;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:36,代码来源:expression.cs

示例4: DoResolveLValue

        public override Expression DoResolveLValue(ResolveContext ec, Expression right_side)
        {
            IVariableReference var = InstanceExpression as IVariableReference;
            if (var != null && var.VariableInfo != null)
                var.VariableInfo.SetFieldAssigned (ec, Name);

            bool lvalue_instance = !spec.IsStatic && TypeManager.IsValueType (spec.DeclaringType);
            bool out_access = right_side == EmptyExpression.OutAccess.Instance || right_side == EmptyExpression.LValueMemberOutAccess;

            Expression e = DoResolve (ec, lvalue_instance, out_access);

            if (e == null)
                return null;

            spec.MemberDefinition.SetIsAssigned ();

            if ((right_side == EmptyExpression.UnaryAddress || right_side == EmptyExpression.OutAccess.Instance) &&
                    (spec.Modifiers & Modifiers.VOLATILE) != 0) {
                ec.Report.Warning (420, 1, loc,
                    "`{0}': A volatile field references will not be treated as volatile",
                    spec.GetSignatureForError ());
            }

            if (spec.IsReadOnly) {
                // InitOnly fields can only be assigned in constructors or initializers
                if (!ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.ConstructorScope))
                    return Report_AssignToReadonly (ec, right_side);

                if (ec.HasSet (ResolveContext.Options.ConstructorScope)) {

                    // InitOnly fields cannot be assigned-to in a different constructor from their declaring type
                    if (!TypeManager.IsEqual (ec.CurrentMemberDefinition.Parent.Definition, DeclaringType.GetDefinition ()))
                        return Report_AssignToReadonly (ec, right_side);
                    // static InitOnly fields cannot be assigned-to in an instance constructor
                    if (IsStatic && !ec.IsStatic)
                        return Report_AssignToReadonly (ec, right_side);
                    // instance constructors can't modify InitOnly fields of other instances of the same type
                    if (!IsStatic && !(InstanceExpression is This))
                        return Report_AssignToReadonly (ec, right_side);
                }
            }

            if (right_side == EmptyExpression.OutAccess.Instance &&
                !IsStatic && !(InstanceExpression is This) && TypeManager.mbr_type != null && TypeManager.IsSubclassOf (DeclaringType, TypeManager.mbr_type)) {
                ec.Report.SymbolRelatedToPreviousError (DeclaringType);
                ec.Report.Warning (197, 1, loc,
                        "Passing `{0}' as ref or out or taking its address may cause a runtime exception because it is a field of a marshal-by-reference class",
                        GetSignatureForError ());
            }

            eclass = ExprClass.Variable;
            return this;
        }
开发者ID:speier,项目名称:shake,代码行数:53,代码来源:ecore.cs

示例5: IsThisAvailable

		public static bool IsThisAvailable (ResolveContext ec)
		{
			if (ec.IsStatic || ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer | ResolveContext.Options.ConstantScope))
				return false;

			if (ec.CurrentAnonymousMethod == null)
				return true;

			if (ec.CurrentType.IsValueType && ec.CurrentIterator == null)
				return false;

			return true;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:13,代码来源:expression.cs


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