本文整理汇总了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;
}
示例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);
}
示例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);
}
示例4: VisitMethodInvocationExpression
public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
{
base.VisitMethodInvocationExpression(node);
FixArguments(node.MethodExpression.Method, node.Arguments);
return node;
}
示例5: VisitMethodInvocationExpression
public override void VisitMethodInvocationExpression(MethodInvocationExpression node)
{
base.VisitMethodInvocationExpression(node);
if (node.MethodExpression.CodeNodeType == CodeNodeType.MethodReferenceExpression)
{
FixArguments(node.MethodExpression.Method, node.Arguments);
}
}
示例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;
}
示例7: VisitMethodInvocationExpression
public override ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
{
LinqQueryExpression result;
if (TryMatchLinqQuery(node, out result))
{
return RemoveTransparentIdentifiers(result);
}
return base.VisitMethodInvocationExpression(node);
}
示例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;
}
示例9: VisitMethodInvocationExpression
public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
{
TypeReference typeReference;
if (!node.IsTypeOfExpression(out typeReference))
{
return null;
}
return new TypeOfExpression (typeReference, node.UnderlyingSameMethodInstructions);
}
示例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);
}
示例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;
}
示例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--;
}
}
示例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;
}
示例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;
}
示例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;
}