private LispList <Pair <EdgeTag, Subroutine> > InsertInvariant(CFGBlock from, LispList <Pair <EdgeTag, Subroutine> > list, Method calledMethod, ref TypeNode type, LispList <Edge <CFGBlock, EdgeTag> > context) { IMetaDataProvider metadataDecoder = this.SubroutineFacade.MetaDataProvider; Property property; if (metadataDecoder.IsPropertySetter(calledMethod, out property) && (metadataDecoder.IsAutoPropertyMember(calledMethod) || WithinConstructor(from, context))) { return(list); } if (metadataDecoder.IsConstructor(calledMethod)) { type = metadataDecoder.DeclaringType(calledMethod); } Subroutine invariant = this.SubroutineFacade.GetInvariant(type); if (invariant != null) { var methodCallBlock = from as MethodCallBlock <Label>; if (methodCallBlock != null) { EdgeTag first = methodCallBlock.IsNewObj ? EdgeTag.AfterNewObj : EdgeTag.AfterCall; return(list.Cons(new Pair <EdgeTag, Subroutine> (first, invariant))); } } return(list); }
public MethodSubroutine(SubroutineFacade SubroutineFacade, Method method, Label startLabel, SubroutineWithHandlersBuilder <Label, Handler> builder) : base(SubroutineFacade, startLabel, builder) { this.method = method; IMetaDataProvider metaDataProvider = this.SubroutineFacade.MetaDataProvider; builder.BuildBlocks(startLabel, this); BlockWithLabels <Label> targetBlock = GetTargetBlock(startLabel); Commit(); TypeNode type = metaDataProvider.DeclaringType(method); Subroutine invariant = this.SubroutineFacade.GetInvariant(type); if (invariant != null && !metaDataProvider.IsConstructor(method) && !metaDataProvider.IsStatic(method)) { AddEdgeSubroutine(Entry, targetBlock, invariant, EdgeTag.Entry); Subroutine requires = this.SubroutineFacade.GetRequires(method); if (requires != null) { AddEdgeSubroutine(Entry, targetBlock, requires, EdgeTag.Entry); } } else { AddEdgeSubroutine(Entry, targetBlock, this.SubroutineFacade.GetRequires(method), EdgeTag.Entry); } if (this.blocks_ending_in_return_point == null) { return; } Subroutine ensures = this.SubroutineFacade.GetEnsures(method); bool putInvariantAfterExit = !metaDataProvider.IsStatic(method) && !metaDataProvider.IsFinalizer(method) && !metaDataProvider.IsDispose(method); foreach (var block in this.blocks_ending_in_return_point) { if (putInvariantAfterExit) { AddEdgeSubroutine(block, Exit, invariant, EdgeTag.Exit); } AddEdgeSubroutine(block, Exit, ensures, EdgeTag.Exit); } if (ensures != null) { throw new NotImplementedException(); } this.blocks_ending_in_return_point = null; }