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 VariableNode RegisterField(SyntaxNodeOrToken v, IFieldSymbol s) { VariableNode lhs; if (s.Type.TypeKind.Equals(TypeKind.Delegate)) { lhs = new DelegateVariableNode(v.ToString(), Utils.CreateTypeDescriptor(s.Type)); } else { lhs = new FieldNode(s.ContainingType.Name, v.ToString(), Utils.CreateTypeDescriptor(s.Type)); //lhs = ANode.Define(t, v); } if (lhs != null) { this.StatementProcessor.RegisterLocalVariable(lhs); } return(lhs); }
internal VariableNode RegisterVariable(SyntaxNodeOrToken v, ITypeSymbol type, ISymbol s) { VariableNode lhs; if (type.TypeKind.Equals(TypeKind.Delegate)) { lhs = new DelegateVariableNode(v.ToString(), Utils.CreateTypeDescriptor(type)); } else { lhs = new VariableNode(v.ToString(), Utils.CreateTypeDescriptor(type)); //lhs = ANode.Define(t, v); } if (lhs != null) { this.StatementProcessor.RegisterLocalVariable(lhs); } return(lhs); }
internal ISet <MethodDescriptor> GetPossibleMethodsForDelegate(DelegateVariableNode node) { return(this.methodEntity.PropGraph.GetDelegates(node)); }
private async Task <ISet <ResolvedCallee> > GetPossibleCalleesForDelegateCallAsync(DelegateVariableNode @delegate, IProjectCodeProvider codeProvider) { var possibleCallees = new HashSet <ResolvedCallee>(); var possibleDelegateMethods = this.GetPossibleMethodsForDelegate(@delegate); foreach (var method in possibleDelegateMethods) { if (method.IsStatic) { // Static method call var resolvedCallee = new ResolvedCallee(method); possibleCallees.Add(resolvedCallee); } else { // Instance method call var receiverPossibleTypes = this.GetTypes(@delegate); if (receiverPossibleTypes.Count > 0) { foreach (var receiverType in receiverPossibleTypes) { //var aMethod = delegateInstance.FindMethodImplementation(t); // Diego: Should I use : codeProvider.FindImplementation(delegateInstance, t); var callee = await codeProvider.FindMethodImplementationAsync(method, receiverType); var resolvedCallee = new ResolvedCallee(receiverType, callee); possibleCallees.Add(resolvedCallee); } } else { // We don't have any possibleType for the receiver, // so we just use the receiver's declared type to // identify the calle method implementation // if Count is 0, it is a delegate that do not came form an instance variable var receiverType = @delegate.Type; var resolvedCallee = new ResolvedCallee(receiverType, method); possibleCallees.Add(resolvedCallee); } } } return(possibleCallees); }
private async Task<IEnumerable<MethodDescriptor>> GetDelegateCalleesAsync(DelegateVariableNode delegateVariableNode) { var callees = new HashSet<MethodDescriptor>(); var types = GetTypes(delegateVariableNode); foreach (var delegateInstance in GetDelegates(delegateVariableNode)) { if (types.Count() > 0) { foreach (var t in types) { //var aMethod = delegateInstance.FindMethodImplementation(t); // Diego: SHould I use : codeProvider.FindImplementation(delegateInstance, t); var methodDescriptor = await codeProvider.FindMethodImplementationAsync(delegateInstance, t); callees.Add(methodDescriptor); } } else { // if Count is 0, it is a delegate that do not came form an instance variable callees.Add(delegateInstance); } } return callees; }
internal void RegisterDelegateAssignment(DelegateVariableNode lhs, MethodDescriptor m) { PropagationGraph.AddDelegate(lhs, m); PropagationGraph.AddToWorkList(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); }
/// <summary> /// Return the set of methods that a delegate node refers to /// It should include as precondition that the node is a delegateNode but /// we return and empty set in other cases /// </summary> /// <param name="node"></param> /// <returns></returns> internal ISet<MethodDescriptor> GetDelegates(DelegateVariableNode node) { return this.MethodEntity.PropGraph.GetDelegates(node); }