protected void InsertPreConditionEdges(BlockWithLabels <Label> previousBlock, BlockWithLabels <Label> newBlock) { var methodCallBlock = newBlock as MethodCallBlock <Label>; if (methodCallBlock == null || CurrentSubroutine.IsContract || CurrentSubroutine.IsOldValue) { return; } if (CurrentSubroutine.IsMethod) { var methodInfo = CurrentSubroutine as IMethodInfo; Property property; if (methodInfo != null && MetaDataProvider.IsConstructor(methodInfo.Method) && MetaDataProvider.IsPropertySetter(methodCallBlock.CalledMethod, out property) && MetaDataProvider.IsAutoPropertyMember(methodCallBlock.CalledMethod)) { return; } } EdgeTag callTag = methodCallBlock.IsNewObj ? EdgeTag.BeforeNewObj : EdgeTag.BeforeCall; Subroutine requires = this.SubroutineFacade.GetRequires(methodCallBlock.CalledMethod); CurrentSubroutine.AddEdgeSubroutine(previousBlock, newBlock, requires, callTag); }
protected void InsertPostConditionEdges(BlockWithLabels <Label> previousBlock, BlockWithLabels <Label> newBlock) { var methodCallBlock = previousBlock as MethodCallBlock <Label>; if (methodCallBlock == null) { return; } if (CurrentSubroutine.IsMethod) { var methodInfo = CurrentSubroutine as IMethodInfo; Property property; if (methodInfo != null && MetaDataProvider.IsConstructor(methodInfo.Method) && MetaDataProvider.IsPropertyGetter(methodCallBlock.CalledMethod, out property) && MetaDataProvider.IsAutoPropertyMember(methodCallBlock.CalledMethod)) { return; } } EdgeTag callTag = methodCallBlock.IsNewObj ? EdgeTag.AfterNewObj : EdgeTag.AfterCall; Subroutine ensures = this.SubroutineFacade.GetEnsures(methodCallBlock.CalledMethod); CurrentSubroutine.AddEdgeSubroutine(previousBlock, newBlock, ensures, callTag); }
public AssertionObligation(APC pc, EdgeTag tag, TVariable cond, bool isAssume) { this.Apc = pc; this.Tag = tag; this.Condition = cond; this.IsAssume = isAssume; }
public override bool Assume(APC pc, EdgeTag tag, TVariable condition, bool data) { if (!pc.InsideRequiresAtCallInsideContract && tag == EdgeTag.Assume) { this.Obligations.Add(new AssertionObligation(pc, tag, condition, true)); } return(data); }
public Result Assume(APC pc, EdgeTag tag, Dummy condition, Data data) { if (tag == EdgeTag.Requires && pc.InsideRequiresAtCall || tag == EdgeTag.Invariant && pc.InsideInvariantOnExit) { return(this.visitor.Assert(pc, tag, condition, data)); } return(this.visitor.Assume(pc, tag, condition, data)); }
public Result Assert(APC pc, EdgeTag tag, Dummy condition, Data data) { if (pc.InsideEnsuresAtCall) { return(this.visitor.Assume(pc, tag, condition, data)); } return(this.visitor.Assert(pc, tag, condition, data)); }
public override bool Assert(APC pc, EdgeTag tag, TVariable condition, bool data) { if (pc.InsideRequiresAtCallInsideContract) { return(data); } this.Obligations.Add(new AssertionObligation(pc, tag, condition)); return(data); }
public override ExprDomain <TSymValue> Assert(APC pc, EdgeTag tag, TSymValue condition, ExprDomain <TSymValue> data) { FlatDomain <Expr <TSymValue> > expression = data [condition]; if (expression.IsNormal()) { data = expression.Value.Decode <ExprDomain <TSymValue>, ExprDomain <TSymValue>, AssumeDecoder <TSymValue> > (pc, condition, new AssumeDecoder <TSymValue> (true), data); } return(data); }
public void Initialize(Graph g, int id, Node begin, Node end, EdgeTag t) { graph = g; Id = id; Begin = begin; End = end; eTag = t; Marks = new MarkList(); Colour = Color.black; UpdateLine(); UpdateCollider(); UpdateTagPosition(); }
public override ExprDomain <TSymValue> Assume(APC pc, EdgeTag tag, TSymValue condition, ExprDomain <TSymValue> data) { FlatDomain <Expr <TSymValue> > aExpression = data [condition]; if (aExpression.IsNormal()) { bool truth = tag != EdgeTag.False; data = aExpression.Value.Decode <ExprDomain <TSymValue>, ExprDomain <TSymValue>, AssumeDecoder <TSymValue> > (pc, condition, new AssumeDecoder <TSymValue> (truth), data); } return(data); }
public override void AddEdge(Node <T> from, Node <T> to) { EdgeTag <T, T2> newEdge = new EdgeTag <T, T2>(from, to); EdgeTag <T, T2> backEdge = new EdgeTag <T, T2>(to, from); if (!edges.Contains(newEdge)) { edges.Add(newEdge); } if (!edges.Contains(backEdge)) { edges.Add(backEdge); } }
public void AddEdge(int beginId, int endId) { Edge newEdge = Instantiate(prefabEdge, Vector3.zero, Quaternion.identity, transform); Node begin = nodes.Find(node => node.Id == beginId); Node end = nodes.Find(node => node.Id == endId); EdgeTag tag = Instantiate(prefabEdgeTag, Vector3.zero, Quaternion.identity, canvas); tag.Initialize(newEdge); newEdge.Initialize(this, edgeIdCount, begin, end, tag); newEdge.BeginPosition = new Vector3(begin.transform.position.x, begin.transform.position.y, 1); newEdge.EndPosition = new Vector3(end.transform.position.x, end.transform.position.y, 1); edges.Add(newEdge); edgeIdCount++; }
public void AddEdge(Node <T> from, Node <T> to, T2 tag) { EdgeTag <T, T2> newEdge = new EdgeTag <T, T2>(from, to); EdgeTag <T, T2> backEdge = new EdgeTag <T, T2>(to, from); newEdge.Tag = tag; backEdge.Tag = tag; if (!edges.Contains(newEdge)) { edges.Add(newEdge); } if (!edges.Contains(backEdge)) { edges.Add(backEdge); } }
private bool HandleConditionalBranch(Label pc, Label target, bool isTrueBranch, BlockWithLabels <Label> currentBlock) { currentBlock.AddLabel(pc); EdgeTag trueTag = isTrueBranch ? EdgeTag.True : EdgeTag.False; EdgeTag falseTag = isTrueBranch ? EdgeTag.False : EdgeTag.True; AssumeBlock <Label> trueBlock = CurrentSubroutine.NewAssumeBlock(pc, trueTag); this.builder.RecordInformationSameAsOtherBlock(trueBlock, this.current_block); CurrentSubroutine.AddSuccessor(currentBlock, trueTag, trueBlock); CurrentSubroutine.AddSuccessor(trueBlock, EdgeTag.FallThrough, CurrentSubroutine.GetTargetBlock(target)); AssumeBlock <Label> falseBlock = CurrentSubroutine.NewAssumeBlock(pc, falseTag); this.builder.RecordInformationSameAsOtherBlock(falseBlock, this.current_block); CurrentSubroutine.AddSuccessor(currentBlock, falseTag, falseBlock); this.current_block = falseBlock; return(false); }
public override TDomain Assume(APC pc, EdgeTag tag, TVar condition, TDomain data) { var boxed = ToBoxedExpression(pc, condition); if (tag != EdgeTag.False) { bool value; if (boxed.IsTrivialCondition(out value)) { return(!value ? data.Bottom : data); } } List <int> thresholds; if (ThresholdDB.TryGetAThreshold(boxed, expression_decoder, out thresholds)) { ThresholdDB.Add(thresholds); } TDomain result; switch (tag) { case EdgeTag.True: case EdgeTag.Requires: case EdgeTag.Assume: case EdgeTag.Invariant: result = data.AssumeTrue(boxed); break; case EdgeTag.False: result = data.AssumeFalse(boxed); break; default: result = data; break; } if (tag != EdgeTag.False) { var abstractType = ContextProvider.ValueContext.GetType( ContextProvider.MethodContext.CFG.Post(pc), condition); if (abstractType.IsNormal() && MetaDataProvider.Equal(abstractType.Value, MetaDataProvider.System_Boolean)) { var guard = BoxedExpression.Binary(BinaryOperator.Ceq, boxed, BoxedExpression.Const(1, MetaDataProvider . System_Int32)); result = result.AssumeTrue(guard); } } return(result); }
public static bool Is (this EdgeTag current, EdgeTag mask) { return (current & mask) != EdgeTag.None; }
public static bool Is(this EdgeTag current, EdgeTag mask) { return((current & mask) != EdgeTag.None); }
public override sealed void AddEdgeSubroutine(CFGBlock from, CFGBlock to, Subroutine subroutine, EdgeTag tag) { if (subroutine == null) { return; } var key = Pair.From(from, to); Sequence <Pair <EdgeTag, Subroutine> > list; this.edge_subroutines.TryGetValue(key, out list); this.edge_subroutines[key] = list.Cons(Pair.From(tag, subroutine)); }
public AssertionObligation(APC pc, EdgeTag tag, TVariable cond) : this(pc, tag, cond, false) { }
public abstract void AddEdgeSubroutine(CFGBlock from, CFGBlock to, Subroutine subroutine, EdgeTag tag);