/// <summary> /// Converts the old value into a call to Contract.OldValue /// </summary> public override IExpression Rewrite(IOldValue oldValue) { var mref = contractProvider.ContractMethods.Old; var methodToCall = new GenericMethodInstanceReference { CallingConvention = CallingConvention.Generic, ContainingType = mref.ContainingType, GenericArguments = new List <ITypeReference> { oldValue.Type }, GenericMethod = mref, InternFactory = host.InternFactory, Name = mref.Name, Parameters = new List <IParameterTypeInformation> { new ParameterTypeInformation { Type = oldValue.Type } }, Type = oldValue.Type }; var methodCall = new MethodCall { Arguments = new List <IExpression> { oldValue.Expression }, IsStaticCall = true, MethodToCall = methodToCall, Type = oldValue.Type, Locations = new List <ILocation>(oldValue.Locations) }; return(methodCall); }
public override void Visit(IOldValue oldValue) { if (Process(oldValue)) { visitor.Visit(oldValue); } base.Visit(oldValue); }
public void Visit(IOldValue oldValue) { this.result = this.rewriter.Rewrite(oldValue); }
public override void TraverseChildren(IOldValue oldValue) { base.sourceEmitterOutput.Write("old("); base.Traverse(oldValue.Expression); base.sourceEmitterOutput.Write(")"); }
/// <summary> /// Traverses the old value expression. /// </summary> public void Traverse(IOldValue oldValue) { Contract.Requires(oldValue != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(oldValue); if (this.StopTraversal) return; this.TraverseChildren(oldValue); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(oldValue); }
public void Visit(IOldValue oldValue) { this.traverser.Traverse(oldValue); }
public virtual void onASTElement(IOldValue oldValue) { }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given old value expression. /// </summary> /// <param name="oldValue"></param> public virtual void Visit(IOldValue oldValue) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(oldValue); this.Visit(oldValue.Expression); //^ 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> /// Rewrites the given old value expression. /// </summary> /// <param name="oldValue"></param> public virtual IExpression Rewrite(IOldValue oldValue) { return oldValue; }
public void Visit(IOldValue oldValue) { this.result = this.copier.Copy(oldValue); }
public override void TraverseChildren(IOldValue oldValue) { base.TraverseChildren(oldValue); ((OldValue)oldValue).Type = oldValue.Expression.Type; }
public override void Visit(IOldValue oldValue) { allElements.Add(new InvokInfo(Traverser, "IOldValue", oldValue)); }
/// <summary> /// Throws an exception when executed: IOldValue nodes /// must be replaced before converting the Code Model to IL. /// </summary> public override void TraverseChildren(IOldValue oldValue) { Contract.Assume(false, "IOldValue nodes must be replaced before trying to convert the Code Model to IL."); }
public override void Visit(IOldValue oldValue) { if(Process(oldValue)){visitor.Visit(oldValue);} base.Visit(oldValue); }
/// <summary> /// Converts the old value into a call to Contract.OldValue /// </summary> public override IExpression Rewrite(IOldValue oldValue) { var mref = this.contractProvider.ContractMethods.Old; var methodToCall = new Microsoft.Cci.MutableCodeModel.GenericMethodInstanceReference() { CallingConvention = CallingConvention.Generic, ContainingType = mref.ContainingType, GenericArguments = new List<ITypeReference> { oldValue.Type }, GenericMethod = mref, InternFactory = this.host.InternFactory, Name = mref.Name, Parameters = new List<IParameterTypeInformation>{ new ParameterTypeInformation { Type = oldValue.Type, } }, Type = oldValue.Type, }; var methodCall = new MethodCall() { Arguments = new List<IExpression> { oldValue.Expression, }, IsStaticCall = true, MethodToCall = methodToCall, Type = oldValue.Type, Locations = new List<ILocation>(oldValue.Locations), }; return methodCall; }
/// <summary> /// Visits the specified old value. /// </summary> /// <param name="oldValue">The old value.</param> public override void Visit(IOldValue oldValue) { OldValue mutableOldValue = oldValue as OldValue; if (alwaysMakeACopy || mutableOldValue == null) mutableOldValue = new OldValue(oldValue); this.resultExpression = this.myCodeMutator.Visit(mutableOldValue); }
/// <summary> /// Returns a shallow copy of the given old value expression. /// </summary> /// <param name="oldValue"></param> public OldValue Copy(IOldValue oldValue) { Contract.Requires(oldValue != null); Contract.Ensures(Contract.Result<OldValue>() != null); return new OldValue(oldValue); }
public override void TraverseChildren(IOldValue oldValue) { base.TraverseChildren(oldValue); TranslatedExpressions.Push(new Bpl.OldExpr(oldValue.Token(), TranslatedExpressions.Pop())); }
/// <summary> /// Returns a deep copy of the given old value expression. /// </summary> /// <param name="oldValue"></param> public OldValue Copy(IOldValue oldValue) { Contract.Requires(oldValue != null); Contract.Ensures(Contract.Result<OldValue>() != null); var mutableCopy = this.shallowCopier.Copy(oldValue); this.CopyChildren((Expression)mutableCopy); mutableCopy.Expression = this.Copy(mutableCopy.Expression); return mutableCopy; }
public override void TraverseChildren(IOldValue oldValue) { MethodEnter(oldValue); base.TraverseChildren(oldValue); MethodExit(); }
/// <summary> /// Performs some computation with the given old value expression. /// </summary> /// <param name="oldValue"></param> public virtual void Visit(IOldValue oldValue) { }
public void Visit(IOldValue oldValue) { Contract.Requires(oldValue != null); throw new NotImplementedException(); }
/// <summary> /// Traverses the children of the old value expression. /// </summary> public virtual void TraverseChildren(IOldValue oldValue) { Contract.Requires(oldValue != null); this.TraverseChildren((IExpression)oldValue); if (this.StopTraversal) return; this.Traverse(oldValue.Expression); }
public override void Visit(IOldValue oldValue) { base.Visit(oldValue); TranslatedExpressions.Push(new Bpl.OldExpr(oldValue.Token(), TranslatedExpressions.Pop())); }
/// <summary> /// Performs some computation with the given old value expression. /// </summary> /// <param name="oldValue"></param> public virtual void Visit(IOldValue oldValue) { this.Visit((IExpression)oldValue); }
/// <summary> /// Rewrites the given old value expression. /// </summary> /// <param name="oldValue"></param> public virtual IExpression Rewrite(IOldValue oldValue) { var mutableOldValue = oldValue as OldValue; if (mutableOldValue == null) return oldValue; this.RewriteChildren(mutableOldValue); return mutableOldValue; }
public void Visit(IOldValue oldValue) { throw new NotImplementedException(); }
/// <summary> /// Visits the specified old value. /// </summary> /// <param name="oldValue">The old value.</param> public override void Visit(IOldValue oldValue) { OldValue mutableOldValue = new OldValue(oldValue); this.resultExpression = this.myCodeCopier.DeepCopy(mutableOldValue); }
/// <summary> /// /// </summary> /// <param name="oldValue"></param> public OldValue(IOldValue oldValue) : base(oldValue) { this.expression = oldValue.Expression; }
/// <summary> /// Returns a deep copy of the given old value expression. /// </summary> /// <param name="oldValue"></param> public OldValue Copy(IOldValue oldValue) { var mutableCopy = this.shallowCopier.Copy(oldValue); this.CopyChildren((Expression)mutableCopy); mutableCopy.Expression = this.Copy(mutableCopy.Expression); return mutableCopy; }
/// <summary> /// Returns a shallow copy of the given old value expression. /// </summary> /// <param name="oldValue"></param> public OldValue Copy(IOldValue oldValue) { return new OldValue(oldValue); }
/// <summary> /// Visits the specified old value. /// </summary> /// <param name="oldValue">The old value.</param> public override void Visit(IOldValue oldValue) { OldValue mutableOldValue = oldValue as OldValue; if (mutableOldValue == null) { this.resultExpression = oldValue; return; } this.resultExpression = this.myCodeMutator.Visit(mutableOldValue); }