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


C# Arguments.AddRange方法代码示例

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


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

示例1: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			right = right.Resolve (ec);
			if (right == null)
				return null;

			MemberAccess ma = target as MemberAccess;
			using (ec.Set (ResolveContext.Options.CompoundAssignmentScope)) {
				target = target.Resolve (ec);
			}
			
			if (target == null)
				return null;

			if (target is MethodGroupExpr){
				ec.Report.Error (1656, loc,
					"Cannot assign to `{0}' because it is a `{1}'",
					((MethodGroupExpr)target).Name, target.ExprClassName);
				return null;
			}

			var event_expr = target as EventExpr;
			if (event_expr != null) {
				source = Convert.ImplicitConversionRequired (ec, right, target.Type, loc);
				if (source == null)
					return null;

				Expression rside;
				if (op == Binary.Operator.Addition)
					rside = EmptyExpression.EventAddition;
				else if (op == Binary.Operator.Subtraction)
					rside = EmptyExpression.EventSubtraction;
				else
					rside = null;

				target = target.ResolveLValue (ec, rside);
				if (target == null)
					return null;

				eclass = ExprClass.Value;
				type = event_expr.Operator.ReturnType;
				return this;
			}

			//
			// Only now we can decouple the original source/target
			// into a tree, to guarantee that we do not have side
			// effects.
			//
			if (left == null)
				left = new TargetExpression (target);

			source = new Binary (op, left, right, true);

			if (target is DynamicMemberAssignable) {
				Arguments targs = ((DynamicMemberAssignable) target).Arguments;
				source = source.Resolve (ec);

				Arguments args = new Arguments (targs.Count + 1);
				args.AddRange (targs);
				args.Add (new Argument (source));

				var binder_flags = CSharpBinderFlags.ValueFromCompoundAssignment;

				//
				// Compound assignment does target conversion using additional method
				// call, set checked context as the binary operation can overflow
				//
				if (ec.HasSet (ResolveContext.Options.CheckedScope))
					binder_flags |= CSharpBinderFlags.CheckedContext;

				if (target is DynamicMemberBinder) {
					source = new DynamicMemberBinder (ma.Name, binder_flags, args, loc).Resolve (ec);

					// Handles possible event addition/subtraction
					if (op == Binary.Operator.Addition || op == Binary.Operator.Subtraction) {
						args = new Arguments (targs.Count + 1);
						args.AddRange (targs);
						args.Add (new Argument (right));
						string method_prefix = op == Binary.Operator.Addition ?
							Event.AEventAccessor.AddPrefix : Event.AEventAccessor.RemovePrefix;

						var invoke = DynamicInvocation.CreateSpecialNameInvoke (
							new MemberAccess (right, method_prefix + ma.Name, loc), args, loc).Resolve (ec);

						args = new Arguments (targs.Count);
						args.AddRange (targs);
						source = new DynamicEventCompoundAssign (ma.Name, args,
							(ExpressionStatement) source, (ExpressionStatement) invoke, loc).Resolve (ec);
					}
				} else {
					source = new DynamicIndexBinder (binder_flags, args, loc).Resolve (ec);
				}

				return source;
			}

			return base.DoResolve (ec);
		}
开发者ID:dyxu,项目名称:vimrc,代码行数:99,代码来源:assign.cs

示例2: DoResolveLValue

        public override Expression DoResolveLValue(ResolveContext rc, Expression right_side)
        {
            if (right_side == EmptyExpression.OutAccess.Instance) {
                right_side.DoResolveLValue (rc, this);
                return null;
            }

            if (DoResolveCore (rc)) {
                setter_args = new Arguments (Arguments.Count + 1);
                setter_args.AddRange (Arguments);
                setter_args.Add (new Argument (right_side));
                setter = CreateCallSiteBinder (rc, setter_args, true);
            }

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

示例3: CreateSetterArguments

		protected virtual Arguments CreateSetterArguments (ResolveContext rc, Expression rhs)
		{
			var setter_args = new Arguments (Arguments.Count + 1);
			setter_args.AddRange (Arguments);
			setter_args.Add (new Argument (rhs));
			return setter_args;
		}
开发者ID:caomw,项目名称:mono,代码行数:7,代码来源:dynamic.cs

示例4: DoResolve

		protected override Expression DoResolve (ResolveContext ec)
		{
			right = right.Resolve (ec);
			if (right == null)
				return null;

			MemberAccess ma = target as MemberAccess;
			using (ec.Set (ResolveContext.Options.CompoundAssignmentScope)) {
				target = target.Resolve (ec);
			}
			
			if (target == null)
				return null;

			if (target is MethodGroupExpr){
				ec.Report.Error (1656, loc,
					"Cannot assign to `{0}' because it is a `{1}'",
					((MethodGroupExpr)target).Name, target.ExprClassName);
				return null;
			}

			if (target is EventExpr)
				return new EventAddOrRemove (target, op, right, loc).Resolve (ec);

			//
			// Only now we can decouple the original source/target
			// into a tree, to guarantee that we do not have side
			// effects.
			//
			if (left == null)
				left = new TargetExpression (target);

			source = new Binary (op, left, right, true, loc);

			if (target is DynamicMemberBinder) {
				Arguments targs = ((DynamicMemberBinder) target).Arguments;
				source = source.Resolve (ec);

				Arguments args = new Arguments (2);
				args.AddRange (targs);
				args.Add (new Argument (source));
				source = new DynamicMemberBinder (ma.Name, args, loc).ResolveLValue (ec, right);

				// Handles possible event addition/subtraction
				if (op == Binary.Operator.Addition || op == Binary.Operator.Subtraction) {
					args = new Arguments (2);
					args.AddRange (targs);
					args.Add (new Argument (right));
					string method_prefix = op == Binary.Operator.Addition ?
						Event.AEventAccessor.AddPrefix : Event.AEventAccessor.RemovePrefix;

					var invoke = DynamicInvocation.CreateSpecialNameInvoke (
						new MemberAccess (right, method_prefix + ma.Name, loc), args, loc).Resolve (ec);

					args = new Arguments (1);
					args.AddRange (targs);
					source = new DynamicEventCompoundAssign (ma.Name, args,
						(ExpressionStatement) source, (ExpressionStatement) invoke, loc).Resolve (ec);
				}

				return source;
			}

			return base.DoResolve (ec);
		}
开发者ID:ikvm,项目名称:mono,代码行数:65,代码来源:assign.cs

示例5: IsApplicable

        ///
        /// Determines if the candidate method is applicable (section 14.4.2.1)
        /// to the given set of arguments
        /// A return value rates candidate method compatibility,
        /// 0 = the best, int.MaxValue = the worst
        ///
        public int IsApplicable(ResolveContext ec,
            ref Arguments arguments, int arg_count, ref MethodSpec method, ref bool params_expanded_form)
        {
            var candidate = method;

            AParametersCollection pd = candidate.Parameters;
            int param_count = GetApplicableParametersCount (candidate, pd);
            int optional_count = 0;

            if (arg_count != param_count) {
                for (int i = 0; i < pd.Count; ++i) {
                    if (pd.FixedParameters [i].HasDefaultValue) {
                        optional_count = pd.Count - i;
                        break;
                    }
                }

                int args_gap = System.Math.Abs (arg_count - param_count);
                if (optional_count != 0) {
                    if (args_gap > optional_count)
                        return int.MaxValue - 10000 + args_gap - optional_count;

                    // Readjust expected number when params used
                    if (pd.HasParams) {
                        optional_count--;
                        if (arg_count < param_count)
                            param_count--;
                    } else if (arg_count > param_count) {
                        return int.MaxValue - 10000 + args_gap;
                    }
                } else if (arg_count != param_count) {
                    if (!pd.HasParams)
                        return int.MaxValue - 10000 + args_gap;
                    if (arg_count < param_count - 1)
                        return int.MaxValue - 10000 + args_gap;
                }

                // Initialize expanded form of a method with 1 params parameter
                params_expanded_form = param_count == 1 && pd.HasParams;

                // Resize to fit optional arguments
                if (optional_count != 0) {
                    Arguments resized;
                    if (arguments == null) {
                        resized = new Arguments (optional_count);
                    } else {
                        resized = new Arguments (param_count);
                        resized.AddRange (arguments);
                    }

                    for (int i = arg_count; i < param_count; ++i)
                        resized.Add (null);
                    arguments = resized;
                }
            }

            if (arg_count > 0) {
                //
                // Shuffle named arguments to the right positions if there are any
                //
                if (arguments [arg_count - 1] is NamedArgument) {
                    arg_count = arguments.Count;

                    for (int i = 0; i < arg_count; ++i) {
                        bool arg_moved = false;
                        while (true) {
                            NamedArgument na = arguments[i] as NamedArgument;
                            if (na == null)
                                break;

                            int index = pd.GetParameterIndexByName (na.Name);

                            // Named parameter not found or already reordered
                            if (index <= i)
                                break;

                            // When using parameters which should not be available to the user
                            if (index >= param_count)
                                break;

                            if (!arg_moved) {
                                arguments.MarkReorderedArgument (na);
                                arg_moved = true;
                            }

                            Argument temp = arguments[index];
                            arguments[index] = arguments[i];
                            arguments[i] = temp;

                            if (temp == null)
                                break;
                        }
                    }
                } else {
//.........这里部分代码省略.........
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs

示例6: ResolveAccessor

		Expression ResolveAccessor (ResolveContext ec, Expression right_side)
		{
			CommonResolve (ec);

			bool dynamic;
			arguments.Resolve (ec, out dynamic);
			if (dynamic || TypeManager.IsDynamicType (indexer_type)) {
				int additional = right_side == null ? 1 : 2;
				Arguments args = new Arguments (arguments.Count + additional);
				if (is_base_indexer) {
					ec.Report.Error (1972, loc, "The indexer base access cannot be dynamically dispatched. Consider casting the dynamic arguments or eliminating the base access");
				} else {
					args.Add (new Argument (instance_expr));
				}
				args.AddRange (arguments);
				if (right_side != null)
					args.Add (new Argument (right_side));

				return new DynamicIndexBinder (right_side != null, args, loc).Resolve (ec);
			}

			Indexers ilist = Indexers.GetIndexersForType (current_type, indexer_type);
			if (ilist.Methods == null) {
				ec.Report.Error (21, loc, "Cannot apply indexing with [] to an expression of type `{0}'",
						  TypeManager.CSharpName (indexer_type));
				return null;
			}

			MethodGroupExpr mg = new IndexerMethodGroupExpr (ilist, loc);
			mg = mg.OverloadResolve (ec, ref arguments, false, loc);
			if (mg == null)
				return null;

			MethodInfo mi = (MethodInfo) mg;
			PropertyInfo pi = null;
			for (int i = 0; i < ilist.Methods.Count; ++i) {
				if (ilist.Methods [i] == mi) {
					pi = (PropertyInfo) ilist.Properties [i];
					break;
				}
			}

			type = TypeManager.TypeToCoreType (pi.PropertyType);
			if (type.IsPointer && !ec.IsUnsafe)
				UnsafeError (ec, loc);

			MethodInfo accessor;
			if (right_side == null) {
				accessor = get = pi.GetGetMethod (true);
			} else {
				accessor = set = pi.GetSetMethod (true);
				if (accessor == null && pi.GetGetMethod (true) != null) {
					ec.Report.SymbolRelatedToPreviousError (pi);
					ec.Report.Error (200, loc, "The read only property or indexer `{0}' cannot be assigned to",
						TypeManager.GetFullNameSignature (pi));
					return null;
				}

				set_expr = Convert.ImplicitConversion (ec, right_side, type, loc);
			}

			if (accessor == null) {
				ec.Report.SymbolRelatedToPreviousError (pi);
				ec.Report.Error (154, loc, "The property or indexer `{0}' cannot be used in this context because it lacks a `{1}' accessor",
					TypeManager.GetFullNameSignature (pi), GetAccessorName (right_side != null));
				return null;
			}

			//
			// Only base will allow this invocation to happen.
			//
			if (accessor.IsAbstract && this is BaseIndexerAccess) {
				Error_CannotCallAbstractBase (ec, TypeManager.GetFullNameSignature (pi));
			}

			bool must_do_cs1540_check;
			if (!IsAccessorAccessible (ec.CurrentType, accessor, out must_do_cs1540_check)) {
				if (set == null)
					set = pi.GetSetMethod (true);
				else
					get = pi.GetGetMethod (true);

				if (set != null && get != null &&
					(set.Attributes & MethodAttributes.MemberAccessMask) != (get.Attributes & MethodAttributes.MemberAccessMask)) {
					ec.Report.SymbolRelatedToPreviousError (accessor);
					ec.Report.Error (271, loc, "The property or indexer `{0}' cannot be used in this context because a `{1}' accessor is inaccessible",
						TypeManager.GetFullNameSignature (pi), GetAccessorName (right_side != null));
				} else {
					ec.Report.SymbolRelatedToPreviousError (pi);
					ErrorIsInaccesible (loc, TypeManager.GetFullNameSignature (pi), ec.Report);
				}
			}

			instance_expr.CheckMarshalByRefAccess (ec);
			eclass = ExprClass.IndexerAccess;
			return this;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:97,代码来源:expression.cs


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