コード例 #1
0
 Sequence <Pair <EdgeTag, Subroutine> > IEdgeSubroutineAdaptor.GetOrdinaryEdgeSubroutinesInternal(
     CFGBlock @from, CFGBlock to,
     Sequence <Edge <CFGBlock, EdgeTag> > context)
 {
     return(DecoratorHelper.Inner <IEdgeSubroutineAdaptor> (this)
            .GetOrdinaryEdgeSubroutinesInternal(from, to, context).Where(
                (pair) => !pair.Value.IsContract && !pair.Value.IsOldValue));
 }
コード例 #2
0
 IEnumerable <APC> ICFG.Predecessors(APC pc)
 {
     DecoratorHelper.Push(this);
     try {
         return(UnderlyingCFG.Predecessors(pc));
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #3
0
 bool ICFG.HasSinglePredecessor(APC pc, out APC predecessor)
 {
     DecoratorHelper.Push(this);
     try {
         return(UnderlyingCFG.HasSinglePredecessor(pc, out predecessor));
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #4
0
 public bool HasSinglePredecessor(APC pc, out APC ifFound)
 {
     DecoratorHelper.Push <IEdgeSubroutineAdaptor> (this);
     try {
         return(this.underlying.HasSinglePredecessor(pc, out ifFound));
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #5
0
 public IEnumerable <APC> Successors(APC pc)
 {
     DecoratorHelper.Push <IEdgeSubroutineAdaptor> (this);
     try {
         return(this.underlying.Successors(pc));
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #6
0
 void ICFG.Print(TextWriter tw, ILPrinter <APC> printer, Func <CFGBlock, IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                 LispList <Edge <CFGBlock, EdgeTag> > context)
 {
     DecoratorHelper.Push(this);
     try {
         UnderlyingCFG.Print(tw, printer, contextLookup, context);
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #7
0
 public void Print(TextWriter tw, ILPrinter <APC> printer,
                   Func <CFGBlock, IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                   LispList <Edge <CFGBlock, EdgeTag> > context)
 {
     DecoratorHelper.Push <IEdgeSubroutineAdaptor> (this);
     try {
         this.underlying.Print(tw, printer, contextLookup, context);
     } finally {
         DecoratorHelper.Pop();
     }
 }
コード例 #8
0
        internal static void Init(Entity entity)
        {
            DEntity = entity;

            DecoratorHelper.UnlockDecorators();

            DecoratorHelper.SAFE_DECOR_REGISTER(prefix + loadedOnce, DecoratorHelper.DecoratorType.Bool);

            DecoratorHelper.LockDecorators();

            ScriptHasLoadedOnce = true;
        }
コード例 #9
0
ファイル: SubroutineBase.cs プロジェクト: raj581/Marvin
        public override LispList <Pair <EdgeTag, Subroutine> > GetOrdinaryEdgeSubroutines(CFGBlock from, CFGBlock to, LispList <Edge <CFGBlock, EdgeTag> > context)
        {
            IMetaDataProvider metadataDecoder = this.SubroutineFacade.MetaDataProvider;
            var apc = new APC(to, 0, context);

            DecoratorHelper.Push(this);
            try {
                LispList <Pair <EdgeTag, Subroutine> > list = DecoratorHelper.Dispatch <IEdgeSubroutineAdaptor> (this).GetOrdinaryEdgeSubroutinesInternal(from, to, context);
                if (apc.InsideContract)
                {
                    if (context != null && !list.IsEmpty())
                    {
                        Method calledMethod;
                        bool   isNewObj;
                        bool   isVirtual;
                        if (@from.IsMethodCallBlock(out calledMethod, out isNewObj, out isVirtual) && isVirtual && ((IStackInfo)this).IsCallOnThis(new APC(@from, 0, null)))
                        {
                            TypeNode type = metadataDecoder.DeclaringType(calledMethod);
                            do
                            {
                                if (context.Head.Tag.Is(EdgeTag.InheritedMask) || context.Head.Tag.Is(EdgeTag.ExtraMask) || context.Head.Tag.Is(EdgeTag.OldMask))
                                {
                                    context = context.Tail;
                                }
                                else
                                {
                                    Method calledMethod2;
                                    bool   isNewObj2;
                                    bool   isVirtual2;
                                    if (context.Head.Tag.Is(EdgeTag.AfterMask) && context.Head.From.IsMethodCallBlock(out calledMethod2, out isNewObj2, out isVirtual2))
                                    {
                                        TypeNode sub = metadataDecoder.DeclaringType(calledMethod2);
                                        if (metadataDecoder.DerivesFrom(sub, type))
                                        {
                                            type = sub;
                                        }
                                        if (!DecoratorHelper.Dispatch <IStackInfo> (this).IsCallOnThis(new APC(context.Head.From, 0, null)))
                                        {
                                            break;
                                        }
                                    }
                                    else if (context.Head.Tag.Is(EdgeTag.BeforeMask) && context.Head.To.IsMethodCallBlock(out calledMethod2, out isNewObj2, out isVirtual2))
                                    {
                                        TypeNode sub = metadataDecoder.DeclaringType(calledMethod2);
                                        if (metadataDecoder.DerivesFrom(sub, type))
                                        {
                                            type = sub;
                                        }
                                        if (!DecoratorHelper.Dispatch <IStackInfo> (this).IsCallOnThis(new APC(context.Head.To, 0, null)))
                                        {
                                            break;
                                        }
                                    }
                                    else if (context.Head.Tag == EdgeTag.Exit)
                                    {
                                        var methodInfo = context.Head.From.Subroutine as IMethodInfo;
                                        if (methodInfo != null)
                                        {
                                            TypeNode sub = metadataDecoder.DeclaringType(methodInfo.Method);
                                            if (metadataDecoder.DerivesFrom(sub, type))
                                            {
                                                type = sub;
                                            }
                                        }
                                        break;
                                    }
                                    else
                                    {
                                        if (context.Head.Tag != EdgeTag.Entry)
                                        {
                                            return(list);
                                        }
                                        var methodInfo = context.Head.From.Subroutine as IMethodInfo;
                                        if (methodInfo != null)
                                        {
                                            TypeNode sub = metadataDecoder.DeclaringType(methodInfo.Method);
                                            if (metadataDecoder.DerivesFrom(sub, type))
                                            {
                                                type = sub;
                                            }
                                        }
                                        break;
                                    }
                                    context = context.Tail;
                                }
                            } while (!context.IsEmpty());
                            Method implementingMethod;
                            if (!metadataDecoder.Equal(type, metadataDecoder.DeclaringType(calledMethod)) &&
                                metadataDecoder.TryGetImplementingMethod(type, calledMethod, out implementingMethod))
                            {
                                list = SpecializedEnsures(list, this.SubroutineFacade.GetEnsures(calledMethod), this.SubroutineFacade.GetEnsures(implementingMethod));
                            }
                        }
                    }
                }
                else
                {
                    Method calledMethod;
                    bool   isNewObj;
                    bool   isVirtual;
                    if (@from.IsMethodCallBlock(out calledMethod, out isNewObj, out isVirtual))
                    {
                        if (DecoratorHelper.Dispatch <IStackInfo> (this).IsCallOnThis(new APC(@from, 0, null)))
                        {
                            var methodInfo = @from.Subroutine as IMethodInfo;
                            if (methodInfo != null)
                            {
                                TypeNode bestType = metadataDecoder.DeclaringType(methodInfo.Method);
                                Method   implementingMethod;
                                if (isVirtual && metadataDecoder.TryGetImplementingMethod(bestType, calledMethod, out implementingMethod))
                                {
                                    list = SpecializedEnsures(list, this.SubroutineFacade.GetEnsures(calledMethod), this.SubroutineFacade.GetEnsures(implementingMethod));
                                }
                                list = InsertInvariant(@from, list, calledMethod, ref bestType, context);
                            }
                        }
                    }
                }
                return(list);
            } finally {
                DecoratorHelper.Pop();
            }
        }