private async Task HandleCallEventAsync(CallMessageInfo callMessage) { if (MethodEntity.CanBeAnalized) { Contract.Assert(callMessage.ArgumentValues.Count() == this.MethodEntity.ParameterNodes.Count()); if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEventAsync", "Reached {0} via call {1}", this.MethodEntity.MethodDescriptor, callMessage); } // This is the node in the caller where info of ret-value should go var lhs = callMessage.LHS; // Save caller info var callContext = new CallContext(callMessage.Caller, callMessage.LHS, callMessage.CallNode); /// Loop detected due to recursion //if (MethodEntity.NodesProcessing.Contains(callMessage.CallNode)) //if (MethodEntity.NodesProcessing.Contains(callContext)) //{ // if (this.Verbose) // { // Logger.Instance.Log(string.Format("Recursion loop {0} ", this.Method.ToString())); // } // //lock (this.MethodEntity) // //{ // // MethodEntity.NodesProcessing.Remove(callContext); // // //MethodEntity.NodesProcessing.Remove(callMessage.CallNode); // //} // //EndOfPropagationEventAsync(callMessage.PropagationKind); // return new Task(() => { }); //} // Just a test to try to block the Entity to a single simultaneous caller //while (this.MethodEntity.CurrentContext != null) //{ // Logger.Instance.Log(string.Format("Waiting: {0} to finish", this.Method)); // Thread.Sleep(10); //} //lock (this.MethodEntity) { //this.MethodEntity.CurrentContext = callContext; // Here is when I register the caller this.MethodEntity.AddToCallers(callContext); if (this.MethodEntity.ThisRef != null) { await this.MethodEntity.PropGraph.DiffPropAsync(Demarshaler.Demarshal(callMessage.Receivers), this.MethodEntity.ThisRef, callMessage.PropagationKind); } var pairIterator = new PairIterator<PropGraphNodeDescriptor, ISet<TypeDescriptor>> (this.MethodEntity.ParameterNodes, callMessage.ArgumentValues); foreach (var pair in pairIterator) { var parameterNode = pair.Item1; //PropGraph.Add(pn, argumentValues[i]); if (parameterNode != null) { await this.MethodEntity.PropGraph.DiffPropAsync( Demarshaler.Demarshal(pair.Item2), parameterNode, callMessage.PropagationKind); } } } switch (callMessage.PropagationKind) { case PropagationKind.ADD_TYPES: await PropagateAsync(); break; case PropagationKind.REMOVE_TYPES: await PropagateDeleteAsync(); break; } } else { await EndOfPropagationEventAsync(callMessage.PropagationKind,false); } }
private void HandleCallEvent(CallMessageInfo callMessage) { if (MethodEntity.CanBeAnalized) { Contract.Assert(callMessage.ArgumentValues.Count() == this.MethodEntity.ParameterNodes.Count()); if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEvent", "Reached {0} via call", this.MethodEntity.MethodDescriptor); } // This tries to check that the invocation is repeated (didn't work: need to check) //if (MethodEntity.Callers.Where(cs => cs.Invocation.Equals(callMessage.CallNode)).Count()>0) // This check if the method is already in caller list if (MethodEntity.Callers.Where(cs => cs.Caller.Equals(callMessage.Caller)).Count() > 0) { if (this.Verbose) { Logger.Instance.Log("MethodEntityProcessor", "HandleCallEvent", "Recursion loop {0} ", this.MethodEntity.MethodDescriptor); } EndOfPropagationEvent(callMessage.PropagationKind, false); return; } // Save caller info var context = new CallContext(callMessage.Caller, callMessage.LHS, callMessage.CallNode); this.MethodEntity.AddToCallers(context); // Propagate type info in method //PropGraph.Add(thisRef, receivers); if (this.MethodEntity.ThisRef != null) { this.MethodEntity.PropGraph.DiffProp(Demarshaler.Demarshal(callMessage.Receivers), this.MethodEntity.ThisRef, callMessage.PropagationKind); } var pairEnumerable = new PairIterator<PropGraphNodeDescriptor, ISet<TypeDescriptor>>( this.MethodEntity.ParameterNodes, callMessage.ArgumentValues); foreach (var pair in pairEnumerable) { var parameterNode = pair.Item1; //PropGraph.Add(pn, argumentValues[i]); if (parameterNode != null) { this.MethodEntity.PropGraph.DiffProp( Demarshaler.Demarshal(pair.Item2), parameterNode, callMessage.PropagationKind); } } if (callMessage.PropagationKind == PropagationKind.ADD_TYPES) { Propagate(); } if (callMessage.PropagationKind == PropagationKind.REMOVE_TYPES) { PropagateDelete(); } } else { EndOfPropagationEvent(callMessage.PropagationKind, false); } }