コード例 #1
0
        public static ForwardAnalysisSolver <AState, Type, EdgeData> Make <Local, Parameter, Method, Field, Source, Dest, Context>(
            IDecodeMSIL <APC, Local, Parameter, Method, Field, Type, Source, Dest, Context, EdgeData> decoder,
            IAnalysis <APC, AState, IVisitMSIL <APC, Local, Parameter, Method, Field, Type, Source, Dest, AState, AState>, EdgeData> driver,
            ILPrinter <APC> printer
            )
            where Context : IMethodContext <Field, Method>
        {
            Contract.Requires(decoder != null);
            Contract.Requires(driver != null);

            IVisitMSIL <APC, Local, Parameter, Method, Field, Type, Source, Dest, AState, AState> visitor = driver.Visitor();
            var result = new ForwardAnalysisSolver <AState, Type, EdgeData>(
                decoder.Context.MethodContext.CFG,
                delegate(APC pc, AState state) { return(decoder.ForwardDecode <AState, AState, IVisitMSIL <APC, Local, Parameter, Method, Field, Type, Source, Dest, AState, AState> >(pc, visitor, state)); },
                driver.EdgeConversion,
                driver.Join,
                driver.ImmutableVersion,
                driver.MutableVersion,
                driver.Dump,
                delegate(APC pc, AState state) { return(decoder.IsUnreachable(pc) || driver.IsBottom(pc, state)); },
                delegate(APC pc, AState state) { return(driver.IsTop(pc, state)); },
                printer,
                decoder.Display,
                decoder.EdgeData
                );

            result.CachePolicy = driver.CacheStates(result);
            return(result);
        }
コード例 #2
0
 public CodeLayer(IDecodeMSIL <APC, Local, Parameter, Method, Field, Type, Expression, Variable, ContextData, EdgeData> ildecoder, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder, IDecodeContracts <Local, Parameter, Method, Field, Type> ctDecoder,
                  Converter <Expression, string> expression2String, Converter <Variable, string> variable2String,
                  ILPrinter <APC> printer, Func <Variable, Variable, bool> newerThan)
     : this(ildecoder, mdDecoder, ctDecoder, expression2String, variable2String, newerThan)
 {
     this.printer = printer;
 }
コード例 #3
0
        public void Print(TextWriter tw, ILPrinter <APC> printer,
                          Func <CFGBlock, IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                          LispList <Edge <CFGBlock, EdgeTag> > context)
        {
            var set = new HashSet <Pair <Subroutine, LispList <Edge <CFGBlock, EdgeTag> > > > ();

            this.method_subroutine.Print(tw, printer, contextLookup, context, set);
        }
コード例 #4
0
ファイル: CodeLayer.cs プロジェクト: pmq20/mono_forked
 public CodeLayer(IILDecoder <APC, Expression, Variable, ContextData, EdgeData> ilDecoder,
                  IMetaDataProvider metadataDecoder,
                  IContractProvider contractDecoder,
                  Func <Expression, string> expressionToString,
                  Func <Variable, string> variableToString, ILPrinter <APC> printer)
     : this(ilDecoder, metadataDecoder, contractDecoder, expressionToString, variableToString)
 {
     this.printer = new Lazy <ILPrinter <APC> > (() => printer);
 }
コード例 #5
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();
     }
 }
コード例 #6
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();
     }
 }
コード例 #7
0
 public void Print(System.IO.TextWriter tw, ILPrinter <APC> ilPrinter, BlockInfoPrinter <APC> edgePrinter, Func <CFGBlock, IEnumerable <DataStructures.FList <DataStructures.STuple <CFGBlock, CFGBlock, string> > > > contextLookup, DataStructures.FList <DataStructures.STuple <CFGBlock, CFGBlock, string> > context)
 {
     CallAdaption.Push <IEdgeSubroutineAdaptor>(this);
     try
     {
         underlying.Print(tw, ilPrinter, edgePrinter, contextLookup, context);
     }
     finally
     {
         CallAdaption.Pop(this);
     }
 }
コード例 #8
0
 Create <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, ContextData, EdgeData>(
     IDecodeMSIL <APC, Local, Parameter, Method, Field, Type, Expression, Variable, ContextData, EdgeData> ildecoder,
     IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder,
     IDecodeContracts <Local, Parameter, Method, Field, Type> ctDecoder,
     Converter <Expression, string> expression2String,
     Converter <Variable, string> variable2String,
     ILPrinter <APC> printer,
     Func <Variable, Variable, bool> newerThan
     )
     where Type : IEquatable <Type>
     where ContextData : IMethodContext <Field, Method>
 {
     return(new CodeLayer <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly, Expression, Variable, ContextData, EdgeData>(
                ildecoder, mdDecoder, ctDecoder,
                expression2String, variable2String,
                printer, newerThan
                ));
 }
コード例 #9
0
        public ForwardAnalysisSolver(
            ICFG cfg,
            Transformer <APC, AState, AState> transfer,
            EdgeConverter <APC, AState, EdgeData> edgeConverter,
            Joiner <APC, AState> joiner,
            Converter <AState, AState> immutableVersion,
            Converter <AState, AState> mutableVersion,
            Action <Pair <AState, TextWriter> > dumper,
            Func <APC, AState, bool> isBottom,
            Func <APC, AState, bool> isTop,
            ILPrinter <APC> printer,
            Printer <EdgeData> edgeDataPrinter,
            Func <APC, APC, EdgeData> edgeDataGetter
            )
            : base(cfg)
        {
            Contract.Requires(transfer != null);
            Contract.Requires(immutableVersion != null);
            Contract.Requires(isBottom != null);
            Contract.Requires(isTop != null);
            Contract.Requires(joiner != null);
            Contract.Requires(mutableVersion != null);
            Contract.Requires(edgeConverter != null);
            Contract.Requires(edgeDataGetter != null);

            this.transfer         = transfer;
            this.edgeConverter    = edgeConverter;
            this.joiner           = joiner;
            this.immutableVersion = immutableVersion;
            this.mutableVersion   = mutableVersion;
            this.dumper           = dumper;
            this.isBottom         = isBottom;
            this.isTop            = isTop;
            this.printer          = printer;
            this.edgeDataPrinter  = edgeDataPrinter;
            this.edgeDataGetter   = edgeDataGetter;
        }
コード例 #10
0
ファイル: SubroutineBase.cs プロジェクト: raj581/Marvin
 protected virtual void PrintReferencedSubroutines(TextWriter tw, HashSet <Subroutine> subs, ILPrinter <APC> printer,
                                                   Func <CFGBlock, IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                                                   LispList <Edge <CFGBlock, EdgeTag> > context,
                                                   HashSet <Pair <Subroutine, LispList <Edge <CFGBlock, EdgeTag> > > > printed)
 {
     foreach (Subroutine subroutine in subs)
     {
         if (contextLookup == null)
         {
             subroutine.Print(tw, printer, contextLookup, context, printed);
         }
         else
         {
             foreach (var ctx in contextLookup(subroutine.Entry))
             {
                 subroutine.Print(tw, printer, contextLookup, ctx, printed);
             }
         }
     }
 }
コード例 #11
0
ファイル: SubroutineBase.cs プロジェクト: raj581/Marvin
        public override void Print(TextWriter tw, ILPrinter <APC> printer, Func <CFGBlock,
                                                                                 IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                                   LispList <Edge <CFGBlock, EdgeTag> > context,
                                   HashSet <Pair <Subroutine, LispList <Edge <CFGBlock, EdgeTag> > > > printed)
        {
            var element = new Pair <Subroutine, LispList <Edge <CFGBlock, EdgeTag> > > (this, context);

            if (printed.Contains(element))
            {
                return;
            }
            printed.Add(element);
            var    subs       = new HashSet <Subroutine> ();
            var    methodInfo = this as IMethodInfo;
            string method     = (methodInfo != null) ? String.Format("({0})", this.SubroutineFacade.MetaDataProvider.FullName(methodInfo.Method)) : null;

            tw.WriteLine("Subroutine SR{0} {1} {2}", Id, Kind, method);
            tw.WriteLine("-------------");
            foreach (BlockWithLabels <Label> block in this.blocks)
            {
                tw.Write("Block {0} ({1})", block.Index, block.ReversePostOrderIndex);
                if (this.edge_info.DepthFirstInfo(block).TargetOfBackEdge)
                {
                    tw.WriteLine(" (target of backedge)");
                }
                else if (IsJoinPoint(block))
                {
                    tw.WriteLine(" (join point)");
                }
                else
                {
                    tw.WriteLine();
                }

                tw.Write("  Predecessors: ");
                foreach (var edge in block.Subroutine.PredecessorEdges[block])
                {
                    tw.Write("({0}, {1}) ", edge.Key, edge.Value.Index);
                }
                tw.WriteLine();
                PrintHandlers(tw, block);

                tw.WriteLine("  Code:");
                foreach (APC apc in block.APCs())
                {
                    printer(apc, "    ", tw);
                }

                tw.Write("  Successors: ");
                foreach (var edge in block.Subroutine.SuccessorEdges[block])
                {
                    tw.Write("({0}, {1}", edge.Key, edge.Value.Index);
                    if (this.edge_info.IsBackEdge(block, Dummy.Value, edge.Value))
                    {
                        tw.Write(" BE");
                    }

                    for (LispList <Pair <EdgeTag, Subroutine> > list = GetOrdinaryEdgeSubroutines(block, edge.Value, context); list != null; list = list.Tail)
                    {
                        subs.Add(list.Head.Value);
                        tw.Write(" SR{0}({1})", list.Head.Value.Id, list.Head.Key);
                    }
                    tw.Write(") ");
                }
                tw.WriteLine();
            }
            PrintReferencedSubroutines(tw, subs, printer, contextLookup, context, printed);
        }
コード例 #12
0
 public void Print(TextWriter tw, ILPrinter <APC> ilPrinter, BlockInfoPrinter <APC> edgePrinter, Func <CFGBlock, IEnumerable <SubroutineContext> > contextLookup, SubroutineContext context)
 {
     throw new NotImplementedException();
 }
コード例 #13
0
ファイル: Program.cs プロジェクト: tamirdresher/reaqtor
 private static void PrintIL(LambdaExpression e)
 {
     PrintTitle("IL", ConsoleColor.Green);
     Console.WriteLine(ILPrinter.GetIL(e));
     Console.WriteLine();
 }
コード例 #14
0
ファイル: ContractFilteredCFG.cs プロジェクト: carrie901/mono
		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 ();
			}
		}
コード例 #15
0
ファイル: CodeLayerFactory.cs プロジェクト: pmq20/mono_forked
 Create <Expression, Variable, ContextData, EdgeConversionData> (
     IILDecoder <APC, Expression, Variable, ContextData, EdgeConversionData> ilDecoder,
     IMetaDataProvider metadataDecoder,
     IContractProvider contractDecoder, Func <Expression, string> expressionToString, Func <Variable, string> variableToString, ILPrinter <APC> printer)
     where ContextData : IMethodContextProvider
 {
     return(new CodeLayer <Expression, Variable, ContextData, EdgeConversionData>
                (ilDecoder, metadataDecoder, contractDecoder, expressionToString, variableToString, printer));
 }
コード例 #16
0
ファイル: ControlFlowGraph.cs プロジェクト: REALTOBIZ/mono
 public void Print (TextWriter tw, ILPrinter<APC> printer,
                    Func<CFGBlock, IEnumerable<Sequence<Edge<CFGBlock, EdgeTag>>>> contextLookup,
                    Sequence<Edge<CFGBlock, EdgeTag>> context)
 {
         var set = new HashSet<Pair<Subroutine, Sequence<Edge<CFGBlock, EdgeTag>>>> ();
         this.method_subroutine.Print (tw, printer, contextLookup, context, set);
 }
コード例 #17
0
        protected override void PrintReferencedSubroutines(TextWriter tw, HashSet <Subroutine> subs, ILPrinter <APC> printer,
                                                           Func <CFGBlock, IEnumerable <LispList <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                                                           LispList <Edge <CFGBlock, EdgeTag> > context,
                                                           HashSet <Pair <Subroutine, LispList <Edge <CFGBlock, EdgeTag> > > > printed)
        {
            foreach (Subroutine sub in this.FaultFinallySubroutines.Values)
            {
                if (contextLookup == null)
                {
                    sub.Print(tw, printer, contextLookup, context, printed);
                }
                else
                {
                    foreach (var ctx in contextLookup(sub.Entry))
                    {
                        sub.Print(tw, printer, contextLookup, ctx, printed);
                    }
                }
            }

            base.PrintReferencedSubroutines(tw, subs, printer, contextLookup, context, printed);
        }
コード例 #18
0
ファイル: Subroutine.cs プロジェクト: pmq20/mono_forked
 public abstract void Print(TextWriter tw, ILPrinter <APC> printer,
                            Func <CFGBlock, IEnumerable <Sequence <Edge <CFGBlock, EdgeTag> > > > contextLookup,
                            Sequence <Edge <CFGBlock, EdgeTag> > context,
                            HashSet <Pair <Subroutine, Sequence <Edge <CFGBlock, EdgeTag> > > > set);