internal void RegisterAssignment(PropGraphNodeDescriptor lhsNode, AnalysisExpression rhs) { if (lhsNode != null && rhs != null && Utils.IsTypeForAnalysis(rhs.GetAnalysisType())) { this.StatementProcessor.RegisterAssignment(lhsNode, rhs.GetAnalysisNode()); } }
public bool IsDelegateCallNode(PropGraphNodeDescriptor n) { var index = vIndex[n]; var v = graph.GetNode(index); return(v.Value.CallNode != null && v.Value.CallNode is DelegateCallInfo); }
bool IsRetNode(PropGraphNodeDescriptor n) { var index = vIndex[n]; var v = graph.GetNode(index); return(v.Value.HasRetValue); }
internal async Task <bool> DiffPropAsync(IEnumerable <TypeDescriptor> src, PropGraphNodeDescriptor n) { var ts = GetTypesMS(n); int c = ts.Count; foreach (var t in src) { if (!ts.Contains(t)) { var isAsig = await IsAssignableAsync(t, n); if (isAsig) { ts.Add(t); } } } //ts.UnionWith(src.Where(t => !ts.Contains(t) && (await IsAssignableAsync(t, n)))); if (ts.Count > c) { this.UpdateCount += ts.Count - c; this.AddToWorkList(n); return(true); } return(false); }
internal bool IsAssignable(TypeDescriptor t1, PropGraphNodeDescriptor analysisNode) { // Contract.Assert(this.codeProvider!=null); if (codeProvider == null) { return(true); } var res = true; // Ugly TypeDescriptor type1 = t1; var type2 = analysisNode.Type; // if (!type1.IsSubtype(type2)) // Diego: This requires a Code Provider. Now it will simply fail. if (!this.codeProvider.IsSubtypeAsync(type1, type2).Result) { if (!type2.IsDelegate) { if (!IsCallNode(analysisNode) && !IsDelegateCallNode(analysisNode)) { return(false); } } } //foreach(var t2 in ts.AsSet()) //{ // AnalysisType type2 = (AnalysisType)t2; // if (!type1.IsSubtype(type2)) // if (!IsCallNode(n) && !IsDelegateCallNode(n)) // return false; //} return(res); }
internal async Task <bool> IsAssignableAsync(TypeDescriptor t1, PropGraphNodeDescriptor analysisNode) { // Contract.Assert(this.codeProvider!=null); if (codeProvider == null) { return(true); } var res = true; // Ugly var type1 = t1; var type2 = analysisNode.Type; var isSubType = await this.codeProvider.IsSubtypeAsync(type1, type2); if (!isSubType) { if (!type2.IsDelegate) { if (!IsCallNode(analysisNode) && !IsDelegateCallNode(analysisNode)) { return(false); } } } return(res); }
public StatementProcessor(MethodDescriptor m, PropGraphNodeDescriptor rv, PropGraphNodeDescriptor thisRef, IEnumerable <PropGraphNodeDescriptor> parameters) // , // ICodeProvider codeProvider) { // this.containerEntity = containerEntity; this.ReturnVariable = rv; this.Method = m; this.ParameterNodes = parameters; this.ThisRef = thisRef; this.PropagationGraph = new PropagationGraph(); this.InstantiatedTypes = new HashSet <TypeDescriptor>(); this.RemovedTypes = new HashSet <TypeDescriptor>(); if (rv != null) { PropagationGraph.AddRet(rv); } if (thisRef != null) { PropagationGraph.Add(thisRef); } foreach (var parameter in this.ParameterNodes) { if (parameter != null) { PropagationGraph.Add(parameter); } } //this.dispatcher = dispatcher; }
public StatementProcessor(MethodDescriptor m, PropGraphNodeDescriptor rv, PropGraphNodeDescriptor thisRef, IEnumerable<PropGraphNodeDescriptor> parameters, ProjectCodeProvider codeProvider) { // this.containerEntity = containerEntity; this.ReturnVariable = rv; this.Method = m; this.ParameterNodes = parameters; this.ThisRef = thisRef; this.PropagationGraph = new PropagationGraph(); this.InstantiatedTypes = new HashSet<TypeDescriptor>(); this.RemovedTypes = new HashSet<TypeDescriptor>(); if (rv != null) { PropagationGraph.AddRet(rv); } if (thisRef != null) { PropagationGraph.Add(thisRef); } foreach (var parameter in this.ParameterNodes) { if (parameter != null) { PropagationGraph.Add(parameter); } } //this.dispatcher = dispatcher; }
internal GraphNodeAnnotationData(PropGraphNodeDescriptor node) { this.Node = node; this.Elems = new Bag <TypeDescriptor>(); this.DeletedElems = new HashSet <TypeDescriptor>(); this.Delegates = new HashSet <MethodDescriptor>(); this.HasRetValue = false; }
public void RegisterRemoveAssignment(PropGraphNodeDescriptor lhs, PropGraphNodeDescriptor rhs) { if (lhs != null && rhs != null) { var typesToDelete = PropagationGraph.TypesInEdge(rhs, lhs); PropagationGraph.RemoveTypes(lhs, typesToDelete); PropagationGraph.AddToDeletionWorkList(lhs); } }
public void RegisterNewExpressionAssignment(PropGraphNodeDescriptor lhs, TypeDescriptor t) { if (lhs != null) { this.PropagationGraph.Add(lhs, t); this.PropagationGraph.AddToWorkList(lhs); } this.InstantiatedTypes.Add(t); }
public void RegisterRemoveTypes(PropGraphNodeDescriptor lhs, IEnumerable <TypeDescriptor> types) { if (lhs != null) { this.RemovedTypes.UnionWith(types); PropagationGraph.RemoveTypes(lhs, types); PropagationGraph.AddToDeletionWorkList(lhs); } }
internal ISet <TypeDescriptor> GetDeletedTypes(PropGraphNodeDescriptor node) { if (node != null) { return(this.methodEntity.PropGraph.GetDeletedTypes(node)); } else { return(new HashSet <TypeDescriptor>()); } }
//public bool DiffProp(IEnumerable<T> src, N n) //{ // var ts = GetTypes(n); // int c = ts.Count; // ts.UnionWith(src.Where(t => !ts.Contains(t))); // if (ts.Count > c) // { // this.workList.Add(n); // return true; // } // return false; //} internal bool DiffProp(IEnumerable <TypeDescriptor> src, PropGraphNodeDescriptor n, PropagationKind propKind) { if (propKind == PropagationKind.REMOVE_TYPES || propKind == PropagationKind.REMOVE_ASSIGNMENT) { return(DiffDelProp(src, n)); } else { return(DiffProp(src, n)); } }
private ISet <TypeDescriptor> GetTypes(PropGraphNodeDescriptor analysisNode) { if (analysisNode != null) { return(this.methodEntity.PropGraph.GetTypes(analysisNode)); } else { return(new HashSet <TypeDescriptor>()); } }
public void ReplaceNode(PropGraphNodeDescriptor nOld, PropGraphNodeDescriptor nNew) { long index; if (vIndex.TryGetValue(nOld, out index)) { var v = graph.GetNode(index); v.Value.Node = nNew; vIndex[nNew] = index; vIndex.Remove(nOld); } }
public void RegisterRemoveNewExpressionAssignment(PropGraphNodeDescriptor lhs) { if (lhs != null) { var types = PropagationGraph.GetTypes(lhs); this.RemovedTypes.UnionWith(types); PropagationGraph.RemoveTypes(lhs, types); PropagationGraph.AddToDeletionWorkList(lhs); } }
internal ISet <TypeDescriptor> GetDeletedTypes(PropGraphNodeDescriptor m) { var res = new HashSet <TypeDescriptor>(); long index; if (vIndex.TryGetValue(m, out index)) { var v = graph.GetNode(index); return(v != null ? v.Value.DeletedElems : res); } return(res); }
internal bool DiffProp(IEnumerable <TypeDescriptor> src, PropGraphNodeDescriptor n) { var ts = GetTypesMS(n); int c = ts.Count; ts.UnionWith(src.Where(t => !ts.Contains(t) && IsAssignable(t, n))); if (ts.Count > c) { this.AddToWorkList(n); return(true); } return(false); }
public bool DiffPropDelegates(IEnumerable <MethodDescriptor> src, PropGraphNodeDescriptor analysisNode) { var ts = GetDelegates(analysisNode); int c = ts.Count; ts.UnionWith(src.Where(t => !ts.Contains(t))); if (ts.Count > c) { this.AddToWorkList(analysisNode); return(true); } return(false); }
internal async Task <bool> DiffPropAsync(IEnumerable <TypeDescriptor> src, PropGraphNodeDescriptor n, PropagationKind propKind) { Logger.LogS("PropagationGraph", "DiffPropAsync", "Diff({0},{1})", src, n); if (propKind == PropagationKind.REMOVE_TYPES || propKind == PropagationKind.REMOVE_ASSIGNMENT) { return(DiffDelProp(src, n)); } else { return(await DiffPropAsync(src, n)); } }
public void RegisterAssignment(PropGraphNodeDescriptor lhs, PropGraphNodeDescriptor rhs) { if (lhs != null && rhs != null) { PropagationGraph.AddEdge(rhs, lhs); if (!rhs.Type.IsConcreteType) { PropagationGraph.Add(rhs, rhs.Type); PropagationGraph.AddToWorkList(rhs); } } }
public void RegisterRemoveType(PropGraphNodeDescriptor lhs, TypeDescriptor type) { if (lhs != null) { var types = new HashSet <TypeDescriptor>(); types.Add(type); this.RemovedTypes.Add(type); PropagationGraph.RemoveTypes(lhs, types); PropagationGraph.AddToDeletionWorkList(lhs); } }
public ISet <MethodDescriptor> GetDelegates(PropGraphNodeDescriptor analysisNode) { var result = new HashSet <MethodDescriptor>(); long index; if (vIndex.TryGetValue(analysisNode, out index)) { var v = graph.GetNode(index); return(v != null ? v.Value.Delegates : result); } return(result); }
internal ISet <TypeDescriptor> GetTypes(PropGraphNodeDescriptor analysisNode) { var result = new HashSet <TypeDescriptor>(); long index; if (vIndex.TryGetValue(analysisNode, out index)) { var v = graph.GetNode(index); return(v != null?v.Value.Elems.AsSet() : result); } return(result); }
private ISet <TypeDescriptor> GetTypes(PropGraphNodeDescriptor node, PropagationKind prop) { switch (prop) { case PropagationKind.ADD_TYPES: return(GetTypes(node)); case PropagationKind.REMOVE_TYPES: return(GetDeletedTypes(node)); default: return(GetTypes(node)); } }
public void AddEdge(PropGraphNodeDescriptor n1, PropGraphNodeDescriptor n2) { Add(n1); Add(n2); var sourceId = vIndex[n1]; var targetId = vIndex[n2]; if (!graph.Contains(sourceId, targetId)) { var data = new GraphEdgeAnnotationData(); graph.Add(sourceId, targetId, data); } }
public CallInfo GetInvocationInfo(PropGraphNodeDescriptor callNode) { Contract.Requires(IsCallNode(callNode) || IsDelegateCallNode(callNode)); long index; if (vIndex.TryGetValue(callNode, out index)) { var v = graph.GetNode(index); //return (AInvocationExp<M, T, N>)v["Call"]; return(v.Value.CallNode); } return(null); }
internal ISet <TypeDescriptor> TypesInEdge(PropGraphNodeDescriptor n1, PropGraphNodeDescriptor n2) { long iN1, iN2; if (vIndex.TryGetValue(n1, out iN1) && vIndex.TryGetValue(n2, out iN2)) { var e = graph.GetEdge(iN1, iN2); return(e.Value.Types); } else { return(new HashSet <TypeDescriptor>()); } }
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); } }
private GraphNode <GraphNodeAnnotationData> AddVertex(PropGraphNodeDescriptor analysisNode) { long index; GraphNode <GraphNodeAnnotationData> node = null; if (!vIndex.TryGetValue(analysisNode, out index)) { var data = new GraphNodeAnnotationData(analysisNode); index = (long)vIndex.Count; vIndex[analysisNode] = index; graph.Add(index, data); } node = graph.GetNode(index); return(node); }
public void RegisterRemoveTypes(PropGraphNodeDescriptor lhs, IEnumerable<TypeDescriptor> types) { if (lhs != null) { this.RemovedTypes.UnionWith(types); PropagationGraph.RemoveTypes(lhs, types); PropagationGraph.AddToDeletionWorkList(lhs); } }
public void RegisterRet(PropGraphNodeDescriptor rn) { PropagationGraph.AddEdge(rn, this.ReturnVariable); }
public void RegisterLocalVariable(PropGraphNodeDescriptor v) { PropagationGraph.Add(v); }
internal ISet<TypeDescriptor> GetDeletedTypes(PropGraphNodeDescriptor node) { if (node != null) { return this.MethodEntity.PropGraph.GetDeletedTypes(node); } else { return new HashSet<TypeDescriptor>(); } }
internal ISet<TypeDescriptor> GetTypes(PropGraphNodeDescriptor analysisNode) { if (analysisNode != null) { return this.MethodEntity.PropGraph.GetTypes(analysisNode); } else { return new HashSet<TypeDescriptor>(); } }
internal ISet<TypeDescriptor> GetTypes(PropGraphNodeDescriptor node, PropagationKind prop) { switch (prop) { case PropagationKind.ADD_TYPES: return GetTypes(node); case PropagationKind.REMOVE_TYPES: return GetDeletedTypes(node); default: return GetTypes(node); } }
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 CallInfo(this.Method, callNode, callee, receiver, arguments, lhs, false); RegisterInvocation(arguments, callNode, callExp); if (receiver != null) { PropagationGraph.AddEdge(receiver, callNode); } }
public void RegisterRemoveType(PropGraphNodeDescriptor lhs, TypeDescriptor type) { if (lhs != null) { var types = new HashSet<TypeDescriptor>(); types.Add(type); this.RemovedTypes.Add(type); PropagationGraph.RemoveTypes(lhs, types); PropagationGraph.AddToDeletionWorkList(lhs); } }
public async Task<ISet<MethodDescriptor>> CalleesAsync(PropGraphNodeDescriptor node) { ISet<MethodDescriptor> result; ValidateCache(); if (!calleesMappingCache.TryGetValue(node, out result)) { var calleesForNode = new HashSet<MethodDescriptor>(); var invExp = this.MethodEntity.PropGraph.GetInvocationInfo((AnalysisCallNode)node); Contract.Assert(invExp != null); calleesForNode.UnionWith(await invExp.ComputeCalleesForNodeAsync(this.MethodEntity.PropGraph, this.codeProvider)); calleesMappingCache[node] = calleesForNode; result = calleesForNode; } return result; }