public void AddCall(CallInfo call, AnalysisCallNode callNode) { var v = AddVertex(callNode, call); callNodes.Add(callNode); AddToWorkList(callNode); }
private async Task <ISet <MethodDescriptor> > GetCalleesAsync(AnalysisCallNode node) { var result = new HashSet <MethodDescriptor>(); var invExp = methodEntity.PropGraph.GetInvocationInfo(node); var calleeResult = await methodEntity.PropGraph.ComputeCalleesForNodeAsync(invExp, codeProvider); result.UnionWith(calleeResult); return(result); }
public void RegisterStaticCall(MethodDescriptor callee, IList <PropGraphNodeDescriptor> arguments, VariableNode lhs, AnalysisCallNode callNode) { Contract.Requires(callee != null); Contract.Requires(callNode != null); Contract.Requires(arguments != null); var callExp = new MethodCallInfo(this.Method, callNode, callee, arguments, lhs, false); RegisterInvocation(arguments, callNode, callExp); }
private GraphNode <GraphNodeAnnotationData> AddVertex(AnalysisCallNode m, CallInfo callNode) { Contract.Assert(callNode != null); var v = AddVertex(m); if (callNode != null) { v.Value.CallNode = callNode; } return(v); }
public static SymbolReference GetMethodReferenceInfo(AnalysisCallNode callNode, SyntaxNode declarationNode) { var span = CodeGraphHelper.GetSpan(declarationNode); var declarationNodeRange = CodeGraphHelper.GetRange(span); var range = callNode.LocationDescriptor.Range; var result = new SymbolReference() { refType = "ref", preview = callNode.LocationDescriptor.FilePath, trange = CodeGraphHelper.GetAbsoluteRange(range, declarationNodeRange) }; return(result); }
public void RegisterPropertyCall(MethodDescriptor callee, PropGraphNodeDescriptor receiver, IList <PropGraphNodeDescriptor> arguments, VariableNode lhs, AnalysisCallNode callNode) { Contract.Requires(callNode != null); Contract.Requires(callee != null); var callExp = new MethodCallInfo(this.Method, callNode, callee, receiver, arguments, lhs, false); RegisterInvocation(arguments, callNode, callExp); if (receiver != null) { PropagationGraph.AddEdge(receiver, callNode); } }
//public void RegisterVirtualDelegateCall(MethodDescriptor callee, VariableNode receiver, // IList<AnalysisNode> arguments, // VariableNode lhs, DelegateVariableNode delegateVariableNode) //{ // Contract.Requires(receiver != null); // Contract.Requires(arguments != null); // Contract.Requires(lhs != null); // Contract.Requires(callee != null); // Contract.Requires(delegateVariableNode != null); // var callExp = new DelegateCallInfo(this.Method, delegateVariableNode, receiver, arguments, lhs); // this.PropagationGraph.AddEdge(receiver, delegateVariableNode); // RegisterInvocation(arguments, delegateVariableNode, callExp); //} private void RegisterInvocation(IList <PropGraphNodeDescriptor> arguments, AnalysisCallNode invocationNode, CallInfo callExp) { Contract.Requires(callExp != null); Contract.Requires(arguments != null); Contract.Requires(invocationNode != null); this.PropagationGraph.AddCall(callExp, invocationNode); this.PropagationGraph.AddToWorkList(invocationNode); foreach (var a in arguments) { if (a != null) { PropagationGraph.AddEdge(a, invocationNode); } } }
public void RegisterConstructorCall(MethodDescriptor callee, IList <PropGraphNodeDescriptor> arguments, VariableNode lhs, AnalysisCallNode callNode) { Contract.Requires(callee != null); Contract.Requires(callNode != null); Contract.Requires(arguments != null); //var argumentValues = arguments.Select(a => a!=null?worker.GetTypes(a):new HashSet<Type>()); var callExp = new MethodCallInfo(this.Method, callNode, callee, lhs, arguments, lhs, true); PropagationGraph.AddCall(callExp, callNode); PropagationGraph.AddToWorkList(callNode); foreach (var argument in arguments) { if (argument != null) { PropagationGraph.AddEdge(argument, callNode); } } }
public void RegisterCallLHS(AnalysisCallNode callNode, VariableNode lhs) { var callExp = PropagationGraph.GetInvocationInfo(callNode); callExp.LHS = lhs; }
public void RegisterStaticDelegateCall(MethodDescriptor callee, IList<PropGraphNodeDescriptor> arguments, VariableNode lhs, DelegateVariableNode delegateNode, AnalysisCallNode callNode) { Contract.Requires(delegateNode != null); Contract.Requires(arguments != null); Contract.Requires(callee != null); var callExp = new DelegateCallInfo(this.Method, callNode, delegateNode, arguments, lhs); // RegisterInvocation(arguments, delegateNode, callExp); RegisterInvocation(arguments, callNode, callExp); }
internal CallContext(MethodDescriptor caller, VariableNode lhs, AnalysisCallNode inv) { this.Caller = caller; this.CallLHS = lhs; this.Invocation = inv; }
public static ReferenceAnnotation GetMethodInvocationInfo(MethodDescriptor callerDescriptor, AnalysisCallNode callNode) { var result = new ReferenceAnnotation() { declarationId = CodeGraphHelper.GetSymbolId(callNode.AdditionalInfo.StaticMethodDescriptor), symbolId = CodeGraphHelper.GetSymbolId(callerDescriptor, callNode.InMethodPosition), declFile = callNode.AdditionalInfo.StaticMethodDeclarationPath, symbolType = SymbolType.Method, label = callNode.Name, hover = callNode.AdditionalInfo.DisplayString, refType = "ref", range = callNode.LocationDescriptor.Range }; return(result); }
/// <summary> /// Compute all the calless of this method entities /// </summary> /// <returns></returns> //internal static async Task<ISet<MethodDescriptor>> GetCalleesAsync(MethodEntity methodEntity, IProjectCodeProvider codeProvider) //{ // var result = new HashSet<MethodDescriptor>(); // foreach (var callNode in methodEntity.PropGraph.CallNodes) // { // result.UnionWith(await GetCalleesAsync(methodEntity, callNode, codeProvider)); // } // return result; //} /// <summary> /// Computes all the potential callees for a particular method invocation /// </summary> /// <param name="node"></param> /// <returns></returns> internal static async Task <ISet <MethodDescriptor> > GetCalleesAsync(MethodEntity methodEntity, AnalysisCallNode node, IProjectCodeProvider codeProvider) { var stopWatch = Stopwatch.StartNew(); ISet <MethodDescriptor> result; var calleesForNode = new HashSet <MethodDescriptor>(); var invExp = methodEntity.PropGraph.GetInvocationInfo((AnalysisCallNode)node); Meausure("ME.PG.GetInvocationInfo", stopWatch); Contract.Assert(invExp != null); Contract.Assert(codeProvider != null); var calleeResult = await methodEntity.PropGraph.ComputeCalleesForNodeAsync(invExp, codeProvider); Meausure("ME.PG.ComputeCalleesForNode", stopWatch); calleesForNode.UnionWith(calleeResult); //calleesForNode.UnionWith(invExp.ComputeCalleesForNode(this.MethodEntity.PropGraph,this.codeProvider)); result = calleesForNode; return(result); }
//public void RegisterVirtualDelegateCall(MethodDescriptor callee, VariableNode receiver, // IList<AnalysisNode> arguments, // VariableNode lhs, DelegateVariableNode delegateVariableNode) //{ // Contract.Requires(receiver != null); // Contract.Requires(arguments != null); // Contract.Requires(lhs != null); // Contract.Requires(callee != null); // Contract.Requires(delegateVariableNode != null); // var callExp = new DelegateCallInfo(this.Method, delegateVariableNode, receiver, arguments, lhs); // this.PropagationGraph.AddEdge(receiver, delegateVariableNode); // RegisterInvocation(arguments, delegateVariableNode, callExp); //} private void RegisterInvocation(IList<PropGraphNodeDescriptor> arguments, AnalysisCallNode invocationNode, AnalysisInvocationExpession callExp) { Contract.Requires(callExp != null); Contract.Requires(arguments != null); Contract.Requires(invocationNode != null); this.PropagationGraph.AddCall(callExp, invocationNode); this.PropagationGraph.AddToWorkList(invocationNode); foreach (var a in arguments) { if (a != null) { PropagationGraph.AddEdge(a, invocationNode); } } }
public void RegisterVirtualCall(MethodDescriptor callee, VariableNode receiver, IList<PropGraphNodeDescriptor> arguments, VariableNode lhs, AnalysisCallNode callNode) { Contract.Requires(receiver != null); Contract.Requires(callee != null); Contract.Requires(callNode != null); Contract.Requires(arguments != null); var callExp = new CallInfo(this.Method, callNode, callee, receiver, arguments, lhs, false); RegisterInvocation(arguments, callNode, callExp); if (receiver != null) { PropagationGraph.AddEdge(receiver, callNode); } }
public void RegisterConstructorCall(MethodDescriptor callee, IList<PropGraphNodeDescriptor> arguments, VariableNode lhs, AnalysisCallNode callNode) { Contract.Requires(callee != null); Contract.Requires(callNode != null); Contract.Requires(arguments != null); //var argumentValues = arguments.Select(a => a!=null?worker.GetTypes(a):new HashSet<Type>()); var callExp = new CallInfo(this.Method, callNode, callee, arguments, lhs, true); PropagationGraph.AddCall(callExp, callNode); PropagationGraph.AddToWorkList(callNode); foreach (var argument in arguments) { if (argument != null) { PropagationGraph.AddEdge(argument, callNode); } } }