public override void TraverseChildren(IAssertStatement assertStatement) { Bpl.Expr conditionExpr = ExpressionFor(assertStatement.Condition); Bpl.Type conditionType = this.sink.CciTypeToBoogie(assertStatement.Condition.Type); if (conditionType == this.sink.Heap.RefType) { conditionExpr = Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, conditionExpr, Bpl.Expr.Ident(this.sink.Heap.NullRef)); } else if (conditionType == Bpl.Type.Int) { conditionExpr = Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, conditionExpr, Bpl.Expr.Literal(0)); } else { System.Diagnostics.Debug.Assert(conditionType == Bpl.Type.Bool); } if (this.sink.Options.getMeHere) { StmtBuilder.Add(new Bpl.AssumeCmd(assertStatement.Token(), conditionExpr)); } else { StmtBuilder.Add(new Bpl.AssertCmd(assertStatement.Token(), conditionExpr)); } }
/// <summary> /// Allocates a copy of a statement that asserts that a condition must always be true when execution reaches it. For example the assert statement of Spec#. /// </summary> /// <param name="assertStatement"></param> public AssertStatement(IAssertStatement assertStatement) : base(assertStatement) { this.condition = assertStatement.Condition; this.description = assertStatement.Description; this.conditionAsText = assertStatement.OriginalSource; this.hasBeenVerified = assertStatement.HasBeenVerified; }
public override void Visit(IAssertStatement assertStatement) { if (Process(assertStatement)) { visitor.Visit(assertStatement); } base.Visit(assertStatement); }
public override void TraverseChildren(IAssertStatement assertStatement) { this.PrintToken(CSharpToken.Indent); sourceEmitterOutput.Write("CodeContract.Assert("); this.Traverse(assertStatement.Condition); if (assertStatement.Description != null) { sourceEmitterOutput.Write(","); this.Traverse(assertStatement.Description); } sourceEmitterOutput.WriteLine(");"); }
public override void TraverseChildren(IAssertStatement assertStatement) { this.PrintToken(VBToken.Indent); sourceEmitterOutput.Write("CodeContract.Assert("); this.Traverse(assertStatement.Condition); if (assertStatement.Description != null) { sourceEmitterOutput.Write(","); this.Traverse(assertStatement.Description); } sourceEmitterOutput.WriteLine(");"); }
/// <summary> /// Converts the assert statement into a call to Contract.Assert /// </summary> public override IStatement Rewrite(IAssertStatement assertStatement) { var methodCall = new MethodCall { Arguments = new List <IExpression> { Rewrite(assertStatement.Condition), assertStatement.Description ?? new CompileTimeConstant { Type = host.PlatformType.SystemString, Value = "Assert" } }, IsStaticCall = true, MethodToCall = AssertReference, Type = systemVoid, Locations = new List <ILocation>(assertStatement.Locations) }; var es = new ExpressionStatement { Expression = methodCall }; return(es); }
public void Visit(IAssertStatement assertStatement) { Contract.Requires(assertStatement != null); throw new NotImplementedException(); }
/// <summary> /// Performs some computation with the given assert statement. /// </summary> /// <param name="assertStatement"></param> public virtual void Visit(IAssertStatement assertStatement) { this.Visit((IStatement)assertStatement); }
/// <summary> /// Traverses the children of the assert statement. /// </summary> public virtual void TraverseChildren(IAssertStatement assertStatement) { Contract.Requires(assertStatement != null); this.TraverseChildren((IStatement)assertStatement); if (this.StopTraversal) return; this.Traverse(assertStatement.Condition); if (this.StopTraversal) return; if (assertStatement.Description != null) this.Traverse(assertStatement.Description); }
/// <summary> /// Performs some computation with the given assert statement. /// </summary> /// <param name="assertStatement"></param> public virtual void Visit(IAssertStatement assertStatement) { }
public virtual void onASTElement(IAssertStatement assertStatement) { }
/// <summary> /// Returns a deep copy of the given assert statement. /// </summary> /// <param name="assertStatement"></param> public AssertStatement Copy(IAssertStatement assertStatement) { Contract.Requires(assertStatement != null); Contract.Ensures(Contract.Result<AssertStatement>() != null); var mutableCopy = this.shallowCopier.Copy(assertStatement); mutableCopy.Condition = this.Copy(mutableCopy.Condition); if (mutableCopy.Description != null) mutableCopy.Description = this.Copy(mutableCopy.Description); return mutableCopy; }
public void Visit(IAssertStatement assertStatement) { this.result = this.rewriter.Rewrite(assertStatement); }
/// <summary> /// Rewrites the given assert statement. /// </summary> /// <param name="assertStatement"></param> public virtual IStatement Rewrite(IAssertStatement assertStatement) { return assertStatement; }
public override void Visit(IAssertStatement assertStatement) { allElements.Add(new InvokInfo(Traverser, "IAssertStatement", assertStatement)); }
/// <summary> /// Throws an exception when executed: IAssertStatement nodes /// must be replaced before converting the Code Model to IL. /// </summary> public override void TraverseChildren(IAssertStatement assertStatement) { Contract.Assume(false, "IAssertStatement nodes must be replaced before trying to convert the Code Model to IL."); }
public override void Visit(IAssertStatement assertStatement) { if(Process(assertStatement)){visitor.Visit(assertStatement);} base.Visit(assertStatement); }
/// <summary> /// Returns a shallow copy of the given assert statement. /// </summary> /// <param name="assertStatement"></param> public AssertStatement Copy(IAssertStatement assertStatement) { return new AssertStatement(assertStatement); }
public void Visit(IAssertStatement assertStatement) { this.result = this.copier.Copy(assertStatement); }
/// <summary> /// Returns a shallow copy of the given assert statement. /// </summary> /// <param name="assertStatement"></param> public AssertStatement Copy(IAssertStatement assertStatement) { Contract.Requires(assertStatement != null); Contract.Ensures(Contract.Result<AssertStatement>() != null); return new AssertStatement(assertStatement); }
public override void TraverseChildren(IAssertStatement assertStatement) { MethodEnter(assertStatement); base.TraverseChildren(assertStatement); MethodExit(); }
/// <summary> /// Traverses the assert statement. /// </summary> public void Traverse(IAssertStatement assertStatement) { Contract.Requires(assertStatement != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(assertStatement); if (this.StopTraversal) return; this.TraverseChildren(assertStatement); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(assertStatement); }
/// <summary> /// Rewrites the given assert statement. /// </summary> /// <param name="assertStatement"></param> public virtual IStatement Rewrite(IAssertStatement assertStatement) { var mutableAssertStatement = assertStatement as AssertStatement; if (mutableAssertStatement == null) return assertStatement; this.RewriteChildren(mutableAssertStatement); return mutableAssertStatement; }
public void Visit(IAssertStatement assertStatement) { this.traverser.Traverse(assertStatement); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given assert statement. /// </summary> /// <param name="assertStatement"></param> public virtual void Visit(IAssertStatement assertStatement) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(assertStatement); this.Visit(assertStatement.Condition); if (assertStatement.Description != null) this.Visit(assertStatement.Description); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not to decrease this.path.Count. this.path.Pop(); }
/// <summary> /// Visits the specified assert statement. /// </summary> /// <param name="assertStatement">The assert statement.</param> public override void Visit(IAssertStatement assertStatement) { AssertStatement mutableAssertStatement = assertStatement as AssertStatement; if (alwaysMakeACopy || mutableAssertStatement == null) mutableAssertStatement = new AssertStatement(assertStatement); this.resultStatement = this.myCodeMutator.Visit(mutableAssertStatement); }
public void Visit(IAssertStatement assertStatement) { throw new NotImplementedException(); }
/// <summary> /// Returns a deep copy of the given assert statement. /// </summary> /// <param name="assertStatement"></param> public AssertStatement Copy(IAssertStatement assertStatement) { var mutableCopy = this.shallowCopier.Copy(assertStatement); mutableCopy.Condition = this.Copy(mutableCopy.Condition); if (mutableCopy.Description != null) mutableCopy.Description = this.Copy(mutableCopy.Description); return mutableCopy; }
/// <summary> /// Visits the specified assert statement. /// </summary> /// <param name="assertStatement">The assert statement.</param> public override void Visit(IAssertStatement assertStatement) { AssertStatement mutableAssertStatement = new AssertStatement(assertStatement); this.resultStatement = this.myCodeCopier.DeepCopy(mutableAssertStatement); }
/// <summary> /// Converts the assert statement into a call to Contract.Assert /// </summary> public override IStatement Rewrite(IAssertStatement assertStatement) { var methodCall = new MethodCall() { Arguments = new List<IExpression> { assertStatement.Condition, }, IsStaticCall = true, MethodToCall = this.contractProvider.ContractMethods.Assert, Type = systemVoid, Locations = new List<ILocation>(assertStatement.Locations), }; ExpressionStatement es = new ExpressionStatement() { Expression = methodCall }; return es; }
/// <summary> /// Visits the specified assert statement. /// </summary> /// <param name="assertStatement">The assert statement.</param> public override void Visit(IAssertStatement assertStatement) { AssertStatement mutableAssertStatement = assertStatement as AssertStatement; if (mutableAssertStatement == null) { this.resultStatement = assertStatement; return; } this.resultStatement = this.myCodeMutator.Visit(mutableAssertStatement); }