コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public virtual BlockWithLabels <Label> RecordInformationForNewBlock(Label currentLabel, BlockWithLabels <Label> previousBlock)
        {
            BlockWithLabels <Label> block = CurrentSubroutine.GetBlock(currentLabel);

            if (previousBlock != null)
            {
                BlockWithLabels <Label> newBlock  = block;
                BlockWithLabels <Label> prevBlock = previousBlock;
                if (block is MethodCallBlock <Label> && previousBlock is MethodCallBlock <Label> )
                {
                    BlockWithLabels <Label> ab = CurrentSubroutine.NewBlock();
                    RecordInformationSameAsOtherBlock(ab, previousBlock);
                    newBlock  = ab;
                    prevBlock = ab;
                    CurrentSubroutine.AddSuccessor(previousBlock, EdgeTag.FallThrough, ab);
                    CurrentSubroutine.AddSuccessor(ab, EdgeTag.FallThrough, block);
                }
                else
                {
                    CurrentSubroutine.AddSuccessor(previousBlock, EdgeTag.FallThrough, block);
                }

                InsertPostConditionEdges(previousBlock, newBlock);
                InsertPreConditionEdges(prevBlock, block);
            }
            return(block);
        }