コード例 #1
0
		public BlockStatement Process (DecompilationContext context, BlockStatement body)
		{
			this.cfg = context.ControlFlowGraph;
			this.annotations = AnnotationStore.CreateStore (cfg, optimization);
			this.body = context.Body;
			this.variables = context.Variables;

			this.expression_decompiler = new ExpressionDecompiler (context.Method, annotations);
			this.statements = new List<Statement> [cfg.Blocks.Length];
			this.processed = new HashSet<InstructionBlock> ();
			this.assignments = new Dictionary<VariableReference, Expression> ();

			Run ();

			PopulateBodyBlock (body);

			return body;
		}
コード例 #2
0
        static void Main(string [] args)
        {
            var method = GetProgramMethod("ForeachForeach");

            var cfg = ControlFlowGraph.Create(method);

            FormatControlFlowGraph(Console.Out, cfg);

            Console.WriteLine("--------------------");

            var store = AnnotationStore.CreateStore(cfg, BlockOptimization.Detailed);

            PrintAnnotations(method, store);

            var language = CSharp.GetLanguage(CSharpVersion.V1);

            //var body = method.Body.Decompile (language);

            var writer = language.GetWriter(new PlainTextFormatter(Console.Out));

            writer.Write(method);
        }
コード例 #3
0
 public void VerifyBehaviorOfChoosePreserveActionWhichPreservesTheMost(TypePreserve left, TypePreserve right, TypePreserve expected)
 {
     Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(left, right)));
     Assert.That(expected, Is.EqualTo(AnnotationStore.ChoosePreserveActionWhichPreservesTheMost(right, left)));
 }
コード例 #4
0
 /// <summary>
 ///     Create an instance of AnnotationDocumentPaginator for a given document and annotation store.
 /// </summary>
 /// <param name="originalPaginator">document to add annotations to</param>
 /// <param name="annotationStore">store to retrieve annotations from</param>
 public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, AnnotationStore annotationStore) : this(originalPaginator, annotationStore, FlowDirection.LeftToRight)
 {
 }
コード例 #5
0
        public void Setup()
        {
            var ctx = new LinkContext(null, new ConsoleLogger(), string.Empty);

            store = new AnnotationStore(ctx);
        }
コード例 #6
0
		public static void PrintAnnotations (MethodDefinition method, AnnotationStore store)
		{
			foreach (Instruction instruction in method.Body.Instructions) {
				Console.Write ("L_{0}: {1} {2}", instruction.Offset.ToString ("x4"), instruction.OpCode.Name, FormatOperand (instruction.Operand));

				Annotation annotation;
				if (store.TryGetAnnotation (instruction, out annotation)) {
					Console.Write (" - ");
					Console.Write (annotation);

					object data;
					if (store.TryGetData<object> (instruction, out data)) {
						Console.Write (" - ");
						if (data is ConditionData)
							PrintConditionData ((ConditionData) data);
						else if (data is LoopData)
							PrintLoopData ((LoopData) data);
						else
							Console.Write (data);
					}
				}

				Console.WriteLine ();
			}
		}
コード例 #7
0
        public void Setup()
        {
            var ctx = new LinkContext(null);

            store = new AnnotationStore(ctx);
        }