VariableEffect GenerateVariableEffect(JsonData jsonData) { VariableEffect newEffect = new VariableEffect(); newEffect.effectVariable = jsonData["effectVariable"].ToString(); newEffect.variableChangeAmount = Convert.ToInt32(jsonData["variableChangeAmount"].ToString()); return(newEffect); }
private bool HasInvariantField(VariableEffect p) { if (p.FieldChain.Count > 0) { Field f = p.FieldChain[p.FieldChain.Count - 1]; if (f.IsRep || (!(f is PTExtraField) && f.Type.IsValueType)) { return(true); } } return(false); }
public Set <VariableEffect> ComputePathsFromVariableToHeapLocation(Set <IPTAnalysisNode> ns, Label lb) { Set <VariableEffect> variableEffects = new Set <VariableEffect>(); //if (WriteEffects.HasWriteEffects) // Console.Out.WriteLine("Modifies:"); // Traverse every write effect foreach (IPTAnalysisNode n in ns) { // Get the fields that are backward reachable from the modified field Set <List <Edge> > paths = PointsToGraph.DFSPathFrom(n, false, true, true); foreach (List <Edge> currentPath in paths) { currentPath.Reverse(); IPTAnalysisNode rootNode; if (currentPath.Count > 0) { rootNode = currentPath[0].Src; } else { rootNode = n; } Variable v = null; if (rootNode.IsVariableReference) { IVarRefNode vrNode = rootNode as IVarRefNode; v = vrNode.ReferencedVariable; if (!IsLocal(v)) { continue; } //if (!(v is Parameter) && !v.Equals(PTGraph.GlobalScope)) // continue; } if (rootNode.Equals(GNode.nGBL)) { v = PTGraph.GlobalScope; } /* * if (rootNode.IsParameterNode && ((PNode)rootNode).IsByValue) * { * bool fieldUpdate = !n.Field.Equals(PTGraph.asterisk); * foreach (Edge e in currentPath) * fieldUpdate = fieldUpdate || !e.Field.Equals(PTGraph.asterisk); * if (!fieldUpdate) * continue; * } */ string nodeName = rootNode.Name; if (v != null) { VariableEffect vEffect = new VariableEffect(v, lb); foreach (Edge e in currentPath) { if (!e.Field.Equals(PTGraph.asterisk)) { vEffect.AddField(e.Field); // lastField = e.Field; } } variableEffects.Add(vEffect); } } } return(variableEffects); }
protected string GetBuffID(BaseItem item, VariableEffect stat) { return(item.Name + " " + stat.Variable + " " + stat.Multiply + " " + stat.Modifier); }
private Pair<Statement, string> PreparePurityWarning(VariableEffect vEffect) { Pair<Statement, string> res = null; // Add the path (decorated with text) to the set of warnings to inform to the developer string path = vEffect.ToString(); Label lb = vEffect.Label; Variable v = vEffect.Variable; Statement stat = lb.Statement; if (stat != null) { if (vEffect.Variable is Parameter) { Parameter p = (Parameter)vEffect.Variable; if (p.IsOut) { return res; } } string msg; if (method.Equals(Method)) msg = string.Format("Cannot prove this statement does not modify {0} in declared pure method {1}", path, Method.Name); else msg = string.Format("Cannot prove this statement does not (indirectly) modify {0} in declared pure method {1}", path, Method.Name); // Constructor are allowed to modify the "this" parameter if (!isConstructor(Method) || !v.Equals(Method.ThisParameter)) { res = new Pair<Statement, string>(stat, msg); } string statementString = stat.SourceContext.SourceText; if (stat.SourceContext.SourceText == null) { statementString = CodePrinter.StatementToString(stat); } //Console.Out.WriteLine("({0},{1}) {2} {3}. Statement:{4}", // stat.SourceContext.StartLine, // stat.SourceContext.StartColumn, // method.Equals(Method) ? "modifies" : "is modified in this call", // path, // statementString); } return res; }
/// <summary> /// Compute one Effects using one path from a variable an effect in /// an abstract heap location /// </summary> /// <param name="af"></param> /// <param name="currentPath"></param> /// <param name="v"></param> /// <returns></returns> private static VariableEffect ComputeOneEffectPath(AField af, List<Edge> currentPath, Variable v) { if (WeakPurityAndWriteEffectsAnalysis.debug) { if (v == null) System.Diagnostics.Debugger.Break(); } VariableEffect vEffect = new VariableEffect(v, af.Label); foreach (Edge e in currentPath) { if (!e.Field.Equals(PTGraph.asterisk)) { vEffect.AddField(e.Field); // lastField = e.Field; // DIEGO-CHECK: If I have an effect on a omega node i can reach all nodes if (e.Src.IsOmega && (e.Field.Equals(PTGraph.allFields) || e.Field.Equals(PTGraph.allFieldsNotOwned))) break; } } if (!af.Field.Equals(PTGraph.asterisk) || vEffect.FieldChain.Count == 0) vEffect.AddField(af.Field,af.WasNull); return vEffect; }
VariableEffect GenerateVariableEffect(JsonData jsonData) { VariableEffect newEffect = new VariableEffect(); newEffect.effectVariable = jsonData["effectVariable"].ToString(); newEffect.variableChangeAmount = Convert.ToInt32(jsonData["variableChangeAmount"].ToString()); return newEffect; }