public override void TraverseChildren(IAddressableExpression addressableExpression) { base.TraverseChildren(addressableExpression); ITypeReference type = Dummy.TypeReference; ILocalDefinition/*?*/ local = addressableExpression.Definition as ILocalDefinition; if (local != null) type = local.Type; else { IParameterDefinition/*?*/ parameter = addressableExpression.Definition as IParameterDefinition; if (parameter != null) { type = parameter.Type; if (parameter.IsByReference) type = Immutable.ManagedPointerType.GetManagedPointerType(type, this.host.InternFactory); } else { IFieldReference/*?*/ field = addressableExpression.Definition as IFieldReference; if (field != null) type = field.Type; else { IExpression/*?*/ expression = addressableExpression.Definition as IExpression; if (expression != null) type = expression.Type; } } } ((AddressableExpression)addressableExpression).Type = type; }
/// <summary> /// /// </summary> /// <param name="addressableExpression"></param> /// <remarks>still a stub</remarks> public override void Visit(IAddressableExpression addressableExpression) { ILocalDefinition/*?*/ local = addressableExpression.Definition as ILocalDefinition; if (local != null) { TranslatedExpressions.Push(Bpl.Expr.Ident(this.sink.FindOrCreateLocalVariable(local))); return; } IParameterDefinition/*?*/ param = addressableExpression.Definition as IParameterDefinition; if (param != null) { TranslatedExpressions.Push(Bpl.Expr.Ident(this.sink.FindParameterVariable(param))); return; } IFieldReference/*?*/ field = addressableExpression.Definition as IFieldReference; if (field != null) { //TranslatedExpressions.Push(Bpl.Expr.Ident(this.StmtTraverser.MethodTraverser.ClassTraverser.FindOrCreateFieldVariable(field.ResolvedField))); throw new NotImplementedException(); } IArrayIndexer/*?*/ arrayIndexer = addressableExpression.Definition as IArrayIndexer; if (arrayIndexer != null) { this.Visit(arrayIndexer); return; } IAddressDereference/*?*/ addressDereference = addressableExpression.Definition as IAddressDereference; if (addressDereference != null) { this.Visit(addressDereference); return; } IMethodReference/*?*/ method = addressableExpression.Definition as IMethodReference; if (method != null) { Console.WriteLine(MemberHelper.GetMethodSignature(method, NameFormattingOptions.Signature)); //TODO throw new NotImplementedException(); } Debug.Assert(addressableExpression.Definition is IThisReference); }
public override void TraverseChildren(IAddressableExpression addressableExpression) { ILocalDefinition/*?*/ local = addressableExpression.Definition as ILocalDefinition; if (local != null) { this.PrintLocalName(local); return; } IParameterDefinition/*?*/ param = addressableExpression.Definition as IParameterDefinition; if (param != null) { this.PrintParameterDefinitionName(param); return; } IArrayIndexer/*?*/ arrayIndexer = addressableExpression.Definition as IArrayIndexer; if (arrayIndexer != null) { this.Traverse(arrayIndexer); return; } IAddressDereference/*?*/ addressDereference = addressableExpression.Definition as IAddressDereference; if (addressDereference != null) { this.Traverse(addressDereference); return; } if (addressableExpression.Instance != null) { var addrOf = addressableExpression.Instance as IAddressOf; if (addrOf != null && addrOf.Expression.Type.IsValueType) this.Traverse(addrOf.Expression); else this.Traverse(addressableExpression.Instance); this.sourceEmitterOutput.Write("."); } IFieldReference/*?*/ field = addressableExpression.Definition as IFieldReference; if (field != null) { if (addressableExpression.Instance == null) { this.PrintTypeReferenceName(field.ContainingType); this.sourceEmitterOutput.Write("."); } this.sourceEmitterOutput.Write(field.Name.Value); return; } IMethodReference/*?*/ method = addressableExpression.Definition as IMethodReference; if (method != null) { this.sourceEmitterOutput.Write(MemberHelper.GetMethodSignature(method, NameFormattingOptions.Signature)); return; } Contract.Assume(addressableExpression.Definition is IExpression); this.Traverse((IExpression)addressableExpression.Definition); }
/// <summary> /// Returns a deep copy of the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public AddressableExpression Copy(IAddressableExpression addressableExpression) { Contract.Requires(addressableExpression != null); Contract.Ensures(Contract.Result<AddressableExpression>() != null); var mutableCopy = this.shallowCopier.Copy(addressableExpression); this.CopyChildren((Expression)mutableCopy); if (mutableCopy.Instance != null) mutableCopy.Instance = this.Copy(mutableCopy.Instance); var local = mutableCopy.Definition as ILocalDefinition; if (local != null) mutableCopy.Definition = this.GetExistingCopyIfInsideCone(local); else { var parameter = mutableCopy.Definition as IParameterDefinition; if (parameter != null) mutableCopy.Definition = this.GetExistingCopyIfInsideCone(parameter); else { var fieldReference = mutableCopy.Definition as IFieldReference; if (fieldReference != null) mutableCopy.Definition = this.Copy(fieldReference); else { var arrayIndexer = mutableCopy.Definition as IArrayIndexer; if (arrayIndexer != null) mutableCopy.Definition = this.Copy(arrayIndexer); else { var methodReference = addressableExpression.Definition as IMethodReference; if (methodReference != null) mutableCopy.Definition = this.Copy(methodReference); else { var expression = (IExpression)mutableCopy.Definition; mutableCopy.Definition = this.Copy(expression); } } } } } return mutableCopy; }
/// <summary> /// /// </summary> /// <param name="addressOf"></param> public AddressOf(IAddressOf addressOf) : base(addressOf) { this.expression = addressOf.Expression; }
/// <summary> /// /// </summary> /// <param name="refArgument"></param> public RefArgument(IRefArgument refArgument) : base(refArgument) { this.expression = refArgument.Expression; }
public void Visit(IAddressableExpression addressableExpression) { throw new NotImplementedException(); }
/// <summary> /// /// </summary> /// <param name="addressableExpression"></param> public AddressableExpression(IAddressableExpression addressableExpression) : base(addressableExpression) { this.definition = addressableExpression.Definition; this.instance = addressableExpression.Instance; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public virtual void Visit(IAddressableExpression addressableExpression) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; object def = addressableExpression.Definition; var loc = def as ILocalDefinition; if (loc != null) this.VisitReference(loc); else { var par = def as IParameterDefinition; if (par != null) this.VisitReference(par); else { var fieldReference = def as IFieldReference; if (fieldReference != null) this.Visit(fieldReference); else { var indexer = def as IArrayIndexer; if (indexer != null) { this.Visit(indexer); return; //do not visit Instance again } else { var adr = def as IAddressDereference; if (adr != null) this.Visit(adr); else { var meth = def as IMethodReference; if (meth != null) this.Visit(meth); else { var thisRef = (IThisReference)def; this.Visit(thisRef); } } } } } } if (addressableExpression.Instance != null) this.Visit(addressableExpression.Instance); //^ assume this.path.Count == oldCount; //True because all of the virtual methods of this class promise not decrease this.path.Count. }
/// <summary> /// Performs some computation with the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public virtual void Visit(IAddressableExpression addressableExpression) { this.Visit((IExpression)addressableExpression); }
public override void TraverseChildren(IAddressableExpression addressableExpression) { if (addressableExpression.Definition == this.local) { //We are willing to replace the local with an expression because the CodeModel to IL converter will re-introduce the local. if (this.numberOfReferencesToLocal[local] == 1) this.localCanBeReplaced = true; else this.localCanBeReplaced = this.bindingsThatMakeALastUseOfALocalVersion.Contains(addressableExpression); this.StopTraversal = true; return; } base.TraverseChildren(addressableExpression); }
/// <summary> /// Traverses the addressable expression. /// </summary> public void Traverse(IAddressableExpression addressableExpression) { Contract.Requires(addressableExpression != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(addressableExpression); if (this.StopTraversal) return; this.TraverseChildren(addressableExpression); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(addressableExpression); }
/// <summary> /// Rewrites the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public virtual IAddressableExpression Rewrite(IAddressableExpression addressableExpression) { return addressableExpression; }
public override void Visit(IAddressableExpression addressableExpression) { NewLineAddIndent(); AppendElementType(addressableExpression); //output.Append(addressableExpression.Definition); base.Visit(addressableExpression); }
public override void TraverseChildren(IAddressableExpression addressableExpression) { base.TraverseChildren(addressableExpression); var local = addressableExpression.Definition as ILocalDefinition; if (local != null && this.firstReferenceToLocal[local] == null) this.firstReferenceToLocal[local] = addressableExpression; }
public override void Visit(IAddressableExpression addressableExpression) { allElements.Add(new InvokInfo(Traverser, "IAddressableExpression", addressableExpression)); }
//TODO: endow ForStatements with a block that contains its init statements. public override void TraverseChildren(IAddressableExpression addressableExpression) { base.TraverseChildren(addressableExpression); this.UpdateDeclaringBlock(addressableExpression.Definition as IFieldReference); }
/// <summary> /// Traverses the children of the addressable expression. /// </summary> public virtual void TraverseChildren(IAddressableExpression addressableExpression) { Contract.Requires(addressableExpression != null); this.TraverseChildren((IExpression)addressableExpression); if (this.StopTraversal) return; var local = addressableExpression.Definition as ILocalDefinition; if (local != null) this.Traverse(local); else { var parameter = addressableExpression.Definition as IParameterDefinition; if (parameter != null) this.Traverse(parameter); else { var fieldReference = addressableExpression.Definition as IFieldReference; if (fieldReference != null) this.Traverse(fieldReference); else { var arrayIndexer = addressableExpression.Definition as IArrayIndexer; if (arrayIndexer != null) { this.Traverse(arrayIndexer); return; //do not traverse Instance again } else { var methodReference = addressableExpression.Definition as IMethodReference; if (methodReference != null) this.Traverse(methodReference); else { var expression = (IExpression)addressableExpression.Definition; this.Traverse(expression); } } } } } if (this.StopTraversal) return; if (addressableExpression.Instance != null) { this.Traverse(addressableExpression.Instance); if (this.StopTraversal) return; } }
/// <summary> /// Returns a shallow copy of the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public AddressableExpression Copy(IAddressableExpression addressableExpression) { Contract.Requires(addressableExpression != null); Contract.Ensures(Contract.Result<AddressableExpression>() != null); return new AddressableExpression(addressableExpression); }
public void Visit(IAddressableExpression addressableExpression) { this.traverser.Traverse(addressableExpression); }
/// <summary> /// Visits the specified addressable expression. /// </summary> /// <param name="addressableExpression">The addressable expression.</param> public override void Visit(IAddressableExpression addressableExpression) { AddressableExpression mutableAddressableExpression = new AddressableExpression(addressableExpression); this.resultExpression = this.myCodeCopier.DeepCopy(mutableAddressableExpression); }
public void Visit(IAddressableExpression addressableExpression) { Contract.Requires(addressableExpression != null); throw new NotImplementedException(); }
/// <summary> /// Returns a deep copy of the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public AddressableExpression Copy(IAddressableExpression addressableExpression) { var mutableCopy = this.shallowCopier.Copy(addressableExpression); this.CopyChildren((Expression)mutableCopy); if (mutableCopy.Instance != null) mutableCopy.Instance = this.Copy(mutableCopy.Instance); var local = mutableCopy.Definition as ILocalDefinition; if (local != null) mutableCopy.Definition = this.GetExistingCopyIfInsideCone(local); else { var parameter = mutableCopy.Definition as IParameterDefinition; if (parameter != null) mutableCopy.Definition = this.GetExistingCopyIfInsideCone(parameter); else { var fieldReference = mutableCopy.Definition as IFieldReference; if (fieldReference != null) mutableCopy.Definition = this.Copy(fieldReference); else { var arrayIndexer = mutableCopy.Definition as IArrayIndexer; if (arrayIndexer != null) mutableCopy.Definition = this.Copy(arrayIndexer); else { var addressDereference = mutableCopy.Definition as IAddressDereference; if (addressDereference != null) mutableCopy.Definition = this.Copy(addressDereference); else { var methodReference = mutableCopy.Definition as IMethodReference; if (methodReference != null) mutableCopy.Definition = this.Copy(methodReference); else { var thisReference = (IThisReference)mutableCopy.Definition; mutableCopy.Definition = this.Copy(thisReference); } } } } } } return mutableCopy; }
/// <summary> /// Returns a shallow copy of the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public AddressableExpression Copy(IAddressableExpression addressableExpression) { return new AddressableExpression(addressableExpression); }
public void Visit(IAddressableExpression addressableExpression) { this.result = this.copier.Copy(addressableExpression); }
/// <summary> /// /// </summary> public AddressOf() { this.expression = CodeDummy.AddressableExpression; }
/// <summary> /// /// </summary> /// <param name="addressableExpression"></param> /// <remarks>still a stub</remarks> public override void TraverseChildren(IAddressableExpression addressableExpression) { Contract.Assume(false, "The expression containing this as a subexpression should never allow a call to this routine."); }
/// <summary> /// /// </summary> public RefArgument() : base() { this.expression = CodeDummy.AddressableExpression; }
public override void TraverseChildren(IAddressableExpression addressableExpression) { MethodEnter(addressableExpression); base.TraverseChildren(addressableExpression); MethodExit(); }
public override void TraverseChildren(IAddressableExpression addressableExpression) { this.LookForCapturedDefinition(addressableExpression.Definition); base.TraverseChildren(addressableExpression); }
/// <summary> /// Performs some computation with the given addressable expression. /// </summary> /// <param name="addressableExpression"></param> public virtual void Visit(IAddressableExpression addressableExpression) { }
public virtual void onASTElement(IAddressableExpression addressableExpression) { }