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


C# Expressions.MethodInvocationExpression类代码示例

本文整理汇总了C#中Telerik.JustDecompiler.Ast.Expressions.MethodInvocationExpression的典型用法代码示例。如果您正苦于以下问题:C# MethodInvocationExpression类的具体用法?C# MethodInvocationExpression怎么用?C# MethodInvocationExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MethodInvocationExpression类属于Telerik.JustDecompiler.Ast.Expressions命名空间,在下文中一共展示了MethodInvocationExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitMethodInvocationExpression

        public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            node.MethodExpression = (MethodReferenceExpression)Visit(node.MethodExpression);
            if (status != InliningResult.NotFound)
            {
                return node;
            }

            MethodReference methodRef = node.MethodExpression.Method;

            for (int i = 0; i < node.Arguments.Count; i++)
            {
                if (!methodRef.Parameters[i].ParameterType.IsByReference)
                {
                    node.Arguments[i] = (Expression)Visit(node.Arguments[i]);

                    if (status != InliningResult.NotFound)
                    {
                        return node;
                    }
                }
                else if (valueHasSideEffects)
                {
                    SideEffectsFinder sideEffectsFinder = new SideEffectsFinder();
                    if (sideEffectsFinder.HasSideEffectsRecursive(node.Arguments[i]))
                    {
                        status = InliningResult.Abort;
                        return node;
                    }
                }
            }

            return node;
        }
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:34,代码来源:RestrictedVariableInliner.cs

示例2: VisitMethodInvocationExpression

        public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            Expression methodTarget = node.GetTarget();
            if (methodTarget != null)
            {
                if (methodTarget.CodeNodeType == CodeNodeType.VariableReferenceExpression)
                {
                    VariableReference variable = (methodTarget as VariableReferenceExpression).Variable;
                    if (this.variableToReplacingExpressionMap.ContainsKey(variable))
                    {
                        this.variablesToNotInline.Add(variable);
                    }
                }
                else if (methodTarget.CodeNodeType == CodeNodeType.FieldReferenceExpression)
                {
                    FieldDefinition field = (methodTarget as FieldReferenceExpression).Field.Resolve();
                    if (this.fieldToReplacingExpressionMap.ContainsKey(field))
                    {
                        VariableReference variableToNotInline = (this.fieldToReplacingExpressionMap[field] as VariableReferenceExpression).Variable;
                        this.variablesToNotInline.Add(variableToNotInline);
                    }
                }
            }

            return base.VisitMethodInvocationExpression(node);
        }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:26,代码来源:VisualBasicRemoveDelegateCachingStep.cs

示例3: VisitMethodInvocationExpression

		public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
		{
			if (!(node.MethodExpression is MethodReferenceExpression))
			{
				return null;
			}

			MethodReferenceExpression methodReferenceExpression = node.MethodExpression;

			MethodReference methodReference = methodReferenceExpression.Method;

			if (methodReference.Name == null)
			{
				return null;
			}

			string eventMethodPrefix = GetEventMethodPrefix(methodReference.Name);
			if (string.IsNullOrEmpty(eventMethodPrefix))
			{
				return null;
			}

			if (methodReference.Parameters.Count != 1)
			{
				return null;
			}

            TypeReference typeReference = methodReference.DeclaringType;
			EventDefinition targetEvent = null;
			do
			{
				if (typeReference == null)
				{
					break;
				}

				TypeDefinition typeDefinition = typeReference.Resolve();

				if (typeDefinition == null)
				{
					break;
				}

				string eventName = methodReference.Name.Substring(eventMethodPrefix.Length);
				targetEvent = typeDefinition.Events.FirstOrDefault(e => e.Name == eventName);
				if (targetEvent == null)
				{
					typeReference = typeDefinition.BaseType;
				}
			} while (typeReference != null && targetEvent == null);

			if (targetEvent == null)
			{
				return null;
			}

			EventReferenceExpression target = new EventReferenceExpression(methodReferenceExpression.Target, targetEvent, null);
			return GetEventAssignExpression(target, node.Arguments[0], eventMethodPrefix, node.InvocationInstructions);
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:59,代码来源:RebuildEventsStep.cs

示例4: VisitMethodInvocationExpression

        public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            base.VisitMethodInvocationExpression(node);

            FixArguments(node.MethodExpression.Method, node.Arguments);

            return node;
        }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:8,代码来源:UsageBasedExpressionFixer.cs

示例5: VisitMethodInvocationExpression

		public override void VisitMethodInvocationExpression(MethodInvocationExpression node)
		{
			base.VisitMethodInvocationExpression(node);
			if (node.MethodExpression.CodeNodeType == CodeNodeType.MethodReferenceExpression)
			{
				FixArguments(node.MethodExpression.Method, node.Arguments);
			}
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:8,代码来源:FixMethodOverloadsStep.cs

示例6: MethodSpecificContext

 public MethodSpecificContext(MethodBody body,
     Dictionary<VariableDefinition, string> variableDefinitionToNameMap, Dictionary<ParameterDefinition, string> parameterDefinitionTonameMap,
     MethodInvocationExpression ctorInvokeExpression)
     : this(body)
 {
     this.VariableDefinitionToNameMap = variableDefinitionToNameMap;
     this.ParameterDefinitionToNameMap = parameterDefinitionTonameMap;
     this.CtorInvokeExpression = ctorInvokeExpression;
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:9,代码来源:MethodSpecificContext.cs

示例7: VisitMethodInvocationExpression

 public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
 {
     LinqQueryExpression result;
     if (TryMatchLinqQuery(node, out result))
     {
         return RemoveTransparentIdentifiers(result);
     }
     return base.VisitMethodInvocationExpression(node);
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:9,代码来源:RebuildLinqQueriesStep.cs

示例8: VisitMethodInvocationExpression

        public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            MethodReferenceExpression methodReference = node.MethodExpression;
            if ((methodReference == null) ||
                (methodReference.Method.CallingConvention == MethodCallingConvention.StdCall))
            {
                return null;
            }

			MethodReference method = methodReference.Method;

			BinaryOperator binaryOperator;
            if (binaryOperators.TryGetValue (method.Name, out binaryOperator))
            {
                return BuildBinaryExpression(binaryOperator, node.Arguments[0], node.Arguments[1], method.FixedReturnType, node.InvocationInstructions);
            }

			UnaryOperator unaryOperator;
            if (unaryOperators.TryGetValue (method.Name, out unaryOperator))
            {
                return BuildUnaryExpression(unaryOperator, node.Arguments[0], node.InvocationInstructions);
            }
			
            if(method.Name == "op_True")
            {
                return (Expression)codeTransformer.Visit(node.Arguments[0]);
            }
            else if(method.Name == "op_False")
            {
                //TODO: Must consider better representation
                return new ConditionExpression((Expression)codeTransformer.Visit(node.Arguments[0]),
                        new LiteralExpression(false, typeSystem, null), new LiteralExpression(true, typeSystem, null), node.InvocationInstructions);
            }

            if (method.Name == "op_Explicit")
            {
                return new CastExpression((Expression)codeTransformer.Visit(node.Arguments[0]), node.ExpressionType, node.InvocationInstructions);
            }

            if (method.Name == "op_Implicit")
            { 
                return codeTransformer.Visit(node.Arguments[0]);
            }

            if (method.Name == "get_Chars" && node.MethodExpression.Target.ExpressionType.FullName == "System.String")
            {
                ArrayIndexerExpression stringIndexing = new ArrayIndexerExpression(node.MethodExpression.Target, node.InvocationInstructions);
                foreach (Expression arg in node.Arguments)
                {
                    stringIndexing.Indices.Add(arg);
                }
                return stringIndexing;
            }

			return null;
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:56,代码来源:OperatorStep.cs

示例9: VisitMethodInvocationExpression

        public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            TypeReference typeReference;
            if (!node.IsTypeOfExpression(out typeReference))
            {
                return null;
            }

			return new TypeOfExpression (typeReference, node.UnderlyingSameMethodInstructions);
		}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:10,代码来源:TypeOfStep.cs

示例10: VisitMethodInvocationExpression

        public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
			ICodeNode newNode = typeOfStep.VisitMethodInvocationExpression(node);
			if (newNode != null)
			{
				return newNode;
			}
			replaceThisWithBaseStep.VisitMethodInvocationExpression(node);

			newNode = operatorStep.VisitMethodInvocationExpression(node);

			if (newNode != null)
			{
				return base.Visit(newNode);
			}

			newNode = replaceDelegateInvokeStep.VisitMethodInvocationExpression(node);

			if (newNode != null)
			{
				return base.VisitDelegateInvokeExpression(newNode as DelegateInvokeExpression);
			}
			newNode = propertyRecognizer.VisitMethodInvocationExpression(node);

            if (newNode != null)
            {
                PropertyReferenceExpression propertyReference = newNode as PropertyReferenceExpression;

                if (propertyReference != null) // if it was a getter
                {
                    newNode = this.VisitPropertyReferenceExpression(propertyReference);
                }
				if (newNode is BinaryExpression) // if it was a setter
				{
					newNode = this.VisitBinaryExpression(newNode as BinaryExpression);
				}
                return newNode;
            }

			newNode = rebuildEventsStep.VisitMethodInvocationExpression(node);

			if (newNode != null)
			{
				if (newNode is BinaryExpression)
				{
					return VisitBinaryExpression(newNode as BinaryExpression);
				}
				return newNode;
			}
			return base.VisitMethodInvocationExpression(node);
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:51,代码来源:CombinedTransformerStep.cs

示例11: VisitMethodInvocationExpression

        public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
			if (node.MethodExpression.CodeNodeType == CodeNodeType.MethodReferenceExpression)
			{
                MethodReferenceExpression methodReferenceExpression = node.MethodExpression;
				MethodReference methodReference = methodReferenceExpression.Method;
				if (IsDelegateInvokeMethod(methodReference))
				{
                    ExpressionCollection visitedArguments = (ExpressionCollection)codeTransformer.Visit(node.Arguments);
					return new DelegateInvokeExpression(methodReferenceExpression.Target, visitedArguments, methodReference, node.InvocationInstructions);
				}
			}
			return null;
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:14,代码来源:ReplaceDelegateInvokeStep.cs

示例12: VisitMethodInvocationExpression

			public override void VisitMethodInvocationExpression(MethodInvocationExpression node)
			{
				Visit(node.MethodExpression);

				if (node.MethodExpression is MethodReferenceExpression)
				{
					this.methodInvocationsStackCount++;
				}

				Visit(node.Arguments);

				if (node.MethodExpression is MethodReferenceExpression)
				{
					this.methodInvocationsStackCount--;
				}
			}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:16,代码来源:DetermineNotSupportedVBCodeStep.cs

示例13: VisitMethodInvocationExpression

        public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            MethodReferenceExpression methodRef = node.MethodExpression;

            if (methodRef == null)
            {
                return null;
            }

            MethodDefinition method = methodRef.Method as MethodDefinition;

            //// must be resolved.
            if (method == null)
            {
                MethodReference methodReference = methodRef.Method;
                if (methodReference != null
                    && !string.IsNullOrEmpty(methodReference.Name)
                    && (methodReference.Name.StartsWith("set_") || methodReference.Name.StartsWith("get_") || methodReference.Name.StartsWith("put_") /*Setter prefix in winrt*/))
                {
                    method = methodReference.Resolve();
                }
            }

            if (method != null)
            {
                if (method.IsGetter || method.IsSetter)
                {
                    PropertyReferenceExpression propExpr = new PropertyReferenceExpression(node, null);
                    if (propExpr.Property == null)
                    {
                        // sanity check - if the method is resolved and is determined to be getter/setter, then a
                        // property record should be available.
                        return node;
                    }
                    Expression result = propExpr;
                    if (method.IsSetter)
                    {
                        int last = node.Arguments.Count - 1;
                        result = new BinaryExpression(BinaryOperator.Assign, propExpr, node.Arguments[last], typeSystem, null);
                    }
                    return result;
                }
            }
            return null;
        }
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:45,代码来源:PropertyRecognizer.cs

示例14: VisitMethodInvocationExpression

 public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
 {
     Expression visitedExpression = (Expression)base.VisitMethodInvocationExpression(node);
     MethodInvocationExpression methodInvocation = visitedExpression as MethodInvocationExpression;
     if (methodInvocation != null && methodInvocation.MethodExpression.Target != null && methodInvocation.MethodExpression.Method.Name == "Invoke")
     {
         if (methodInvocation.MethodExpression.Target.CodeNodeType == CodeNodeType.FieldReferenceExpression &&
             (methodInvocation.MethodExpression.Target as FieldReferenceExpression).Field.Name == "Target" &&
             (methodInvocation.MethodExpression.Target as FieldReferenceExpression).Target != null &&
             (methodInvocation.MethodExpression.Target as FieldReferenceExpression).Target.CodeNodeType == CodeNodeType.FieldReferenceExpression)
         {
             FieldDefinition fieldDef = ((methodInvocation.MethodExpression.Target as FieldReferenceExpression).Target as FieldReferenceExpression).Field.Resolve();
             CallSiteInfo callSiteInfo;
             if (fieldDef != null && fieldToCallSiteInfoMap.TryGetValue(fieldDef, out callSiteInfo))
             {
                 if (callSiteInfo.BinderType != CallSiteBinderType.IsEvent)
                 {
                     return GenerateExpression(callSiteInfo, methodInvocation.Arguments, methodInvocation.InvocationInstructions);
                 }
                 else
                 {
                     isEventIfStatements.Add(closestIf, methodInvocation);
                 }
             }
         }
         else if (methodInvocation.MethodExpression.Target.CodeNodeType == CodeNodeType.VariableReferenceExpression)
         {
             VariableReference varRef = (methodInvocation.MethodExpression.Target as VariableReferenceExpression).Variable;
             CallSiteInfo callSiteInfo;
             if (variableToCallSiteInfoMap.TryGetValue(varRef, out callSiteInfo))
             {
                 if (callSiteInfo.BinderType != CallSiteBinderType.IsEvent)
                 {
                     return GenerateExpression(callSiteInfo, methodInvocation.Arguments, methodInvocation.InvocationInstructions);
                 }
                 else
                 {
                     isEventIfStatements.Add(closestIf, methodInvocation);
                 }
             }
         }
     }
     return visitedExpression;
 }
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:44,代码来源:CallSiteInvocationReplacer.cs

示例15: VisitMethodInvocationExpression

        public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
        {
            node = (MethodInvocationExpression)base.VisitMethodInvocationExpression(node);

            VisitInvocationArguments(node.Arguments, node.MethodExpression.Method);

            if (node.IsConstrained)
            {
                if (node.MethodExpression.Target.CodeNodeType == CodeNodeType.LiteralExpression)
                {
                    TypeDefinition constraintTypeDef = node.ConstraintType.Resolve();
                    if (constraintTypeDef.IsEnum)
                    {
                        node.MethodExpression.Target = EnumHelper.GetEnumExpression(constraintTypeDef, node.MethodExpression.Target as LiteralExpression, typeSystem);
                    }
                }
            }

            return node;
        }
开发者ID:besturn,项目名称:JustDecompileEngine,代码行数:20,代码来源:RenameEnumValues.cs


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