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


C# MethodDeclaration.AcceptVisitor方法代码示例

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


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

示例1: VisitMethodDeclaration

        public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
        {
            var typeDeclaration = methodDeclaration.GetParent<TypeDeclaration>();
            var writer = this.m_TypeWriters[typeDeclaration];

            var modifiers = this.GetJavaModifiersAsList(methodDeclaration.Modifiers);
            var javaModifiers = this.ConvertModifierListToJavaModifiers(modifiers);
            writer.WriteLine(".method " + javaModifiers + " " +
                             JavaSignature.CreateMethodSignature(methodDeclaration, this.m_Resolver.TypeResolveContext, false));

            methodDeclaration.AcceptVisitor(new JavaMethodVisitor(this.m_Resolver, writer));

            writer.WriteLine(".end method");
        }
开发者ID:hach-que,项目名称:cscjvm,代码行数:14,代码来源:JavaTypeVisitor.cs

示例2: FactorOutAlgorithmFields

        public static void FactorOutAlgorithmFields(
            Type algorithmType, 
            MethodDeclaration method,
            MethodDeclaration initialize, 
            ref string declarations)
        {
            var mappings = new Dictionary<string, string>();
            foreach (var field in algorithmType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                if (field.GetCustomAttributes(typeof(FieldForGenerationAttribute), false).Length > 0)
                {
                    mappings.Add(field.Name, "field_" + LayerCompiler.GenerateRandomIdentifier());
                    declarations += field.FieldType.FullName + " " + mappings[field.Name] + ";\r\n";
                }
            }

            var factorOut = new FactorOutAlgorithmFieldsVisitor(mappings);
            method.AcceptVisitor(factorOut);
            if (initialize != null)
                initialize.AcceptVisitor(factorOut);
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:21,代码来源:AlgorithmRefactorer.cs

示例3: InlineInitialize

        /// <summary>
        /// Refactors the names of parameters and their references so the
        /// method body can be copied directly into the output.
        /// </summary>
        public static void InlineInitialize(IAlgorithm algorithm, MethodDeclaration method)
        {
            if (algorithm == null)
                throw new ArgumentNullException("algorithm");
            if (method == null)
                throw new ArgumentNullException("method");

            var parameterContext = method.Parameters.ElementAt(0);

            // Replace properties.
            method.AcceptVisitor(new FindPropertiesVisitor
            {
                Algorithm = algorithm,
                ParameterContextName = parameterContext.Name
            });

            // Replace identifiers.
            foreach (var i in method.Body.Descendants.Where(v => v is IdentifierExpression).Cast<IdentifierExpression>()
                )
            {
                if (i.Identifier == "context")
                    i.ReplaceWith(new ThisReferenceExpression());
            }
        }
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:28,代码来源:AlgorithmRefactorer.cs

示例4: InlineMethod

        /// <summary>
        /// Refactors the names of parameters and their references so the
        /// method body can be copied directly into the output.
        /// </summary>
        public static void InlineMethod(
            IAlgorithm algorithm, 
            MethodDeclaration method, 
            string outputName,
            string[] inputNames,
            Expression x, 
            Expression y, 
            Expression z,
            Expression i, 
            Expression j, 
            Expression k,
            Expression width, 
            Expression height, 
            Expression depth,
            Expression ox, 
            Expression oy, 
            Expression oz)
        {
            if (algorithm == null) throw new ArgumentNullException("algorithm");
            if (method == null) throw new ArgumentNullException("method");
            if (outputName == null) throw new ArgumentNullException("outputName");
            if (inputNames == null) throw new ArgumentNullException("inputNames");
            if (x == null) throw new ArgumentNullException("x");
            if (y == null) throw new ArgumentNullException("y");
            if (z == null) throw new ArgumentNullException("z");
            if (i == null) throw new ArgumentNullException("i");
            if (j == null) throw new ArgumentNullException("j");
            if (k == null) throw new ArgumentNullException("k");
            if (width == null) throw new ArgumentNullException("width");
            if (height == null) throw new ArgumentNullException("height");
            if (depth == null) throw new ArgumentNullException("depth");
            if (ox == null) throw new ArgumentNullException("ox");
            if (oy == null) throw new ArgumentNullException("oy");
            if (oz == null) throw new ArgumentNullException("oz");

            var parameterContext = method.Parameters.ElementAt(0);
            var parameterInputs = new ParameterDeclaration[method.Parameters.Count - 14];
            for (var idx = 1; idx < method.Parameters.Count - 13; idx++)
                parameterInputs[idx - 1] = method.Parameters.ElementAt(idx);
            var parameterOutput = method.Parameters.Reverse().ElementAt(12);
            var parameterX = method.Parameters.Reverse().ElementAt(11);
            var parameterY = method.Parameters.Reverse().ElementAt(10);
            var parameterZ = method.Parameters.Reverse().ElementAt(9);
            var parameterI = method.Parameters.Reverse().ElementAt(8);
            var parameterJ = method.Parameters.Reverse().ElementAt(7);
            var parameterK = method.Parameters.Reverse().ElementAt(6);
            var parameterWidth = method.Parameters.Reverse().ElementAt(5);
            var parameterHeight = method.Parameters.Reverse().ElementAt(4);
            var parameterDepth = method.Parameters.Reverse().ElementAt(3);
            var parameterOX = method.Parameters.Reverse().ElementAt(2);
            var parameterOY = method.Parameters.Reverse().ElementAt(1);
            var parameterOZ = method.Parameters.Reverse().ElementAt(0);

            // Replace properties.
            method.AcceptVisitor(new FindPropertiesVisitor
            {
                Algorithm = algorithm,
                ParameterContextName = parameterContext.Name
            });

            // Replace identifiers.
            var identifiers =
                method
                    .Body
                    .Descendants
                    .Where(v => v is IdentifierExpression)
                    .Cast<IdentifierExpression>()
                    .ToArray();
            foreach (var e in identifiers)
            {
                if (e.Identifier == parameterX.Name)
                    e.ReplaceWith(x.Clone());
                else if (e.Identifier == parameterY.Name)
                    e.ReplaceWith(y.Clone());
                else if (e.Identifier == parameterZ.Name)
                    e.ReplaceWith(z.Clone());
                else if (e.Identifier == parameterI.Name)
                    e.ReplaceWith(i.Clone());
                else if (e.Identifier == parameterJ.Name)
                    e.ReplaceWith(j.Clone());
                else if (e.Identifier == parameterK.Name)
                    e.ReplaceWith(k.Clone());
                else if (e.Identifier == parameterWidth.Name)
                    e.ReplaceWith(width.Clone());
                else if (e.Identifier == parameterHeight.Name)
                    e.ReplaceWith(height.Clone());
                else if (e.Identifier == parameterDepth.Name)
                    e.ReplaceWith(depth.Clone());
                else if (e.Identifier == parameterOX.Name)
                    e.ReplaceWith(ox.Clone());
                else if (e.Identifier == parameterOY.Name)
                    e.ReplaceWith(oy.Clone());
                else if (e.Identifier == parameterOZ.Name)
                    e.ReplaceWith(oz.Clone());
                else if (e.Identifier == parameterOutput.Name)
                    e.Identifier = outputName;
//.........这里部分代码省略.........
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:101,代码来源:AlgorithmRefactorer.cs

示例5: VisitMethodDeclaration

			public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration)
			{
				var eligibleParameters = methodDeclaration.Parameters
					.Where(p => p.ParameterModifier != ParameterModifier.Out && p.ParameterModifier != ParameterModifier.Ref)
					.ToList();
				if (eligibleParameters.Count == 0)
					return;
				var declarationResolveResult = ctx.Resolve(methodDeclaration) as MemberResolveResult;
				if (declarationResolveResult == null)
					return;
				var member = declarationResolveResult.Member;
				if (member.IsOverride || member.IsOverridable || member.ImplementedInterfaceMembers.Any())
					return;

				var collector = new TypeCriteriaCollector(ctx);
				methodDeclaration.AcceptVisitor(collector);
				
				foreach (var parameter in eligibleParameters) {
					ProcessParameter(parameter, methodDeclaration.Body, collector);
				}
			}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:21,代码来源:ParameterCanBeDemotedIssue.cs

示例6: VisitMethodDeclaration

				public override void VisitMethodDeclaration (MethodDeclaration methodDeclaration)
				{
					base.VisitMethodDeclaration (methodDeclaration);

					var i = new Inline ();
					while (i.KeepGoing) {
						i.KeepGoing = false;
						methodDeclaration.AcceptVisitor (i);
					}
				}
开发者ID:RReverser,项目名称:Netjs,代码行数:10,代码来源:CsToTs.cs


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