public Expr Go(bool failQuietly = true) { Instruction unknownInst = null; var insts = this.method.Body.Instructions; foreach (Instruction inst in insts) { if (failQuietly) { if (unknownInst == null) { try { Expr expr = this.ProcessInst(inst); this.Instructions.Add(expr, inst); this.exprs.Push(expr); } catch (NotSupportedException) { unknownInst = inst; } } else { // Met unknown instruction, so check that there are no more contracts if (inst.OpCode.OperandType == OperandType.InlineMethod) { MethodReference method = (MethodReference)inst.Operand; if (method.DeclaringType.FullName == "System.Diagnostics.Contracts.Contract") { throw new NotSupportedException("Unknown instruction in contract: " + unknownInst); } } } } else { Expr expr = this.ProcessInst(inst); this.Instructions.Add(expr, inst); this.exprs.Push(expr); } } Expr decompiled = new ExprBlock(this.methodInfo, this.exprs.Reverse().ToArray()); return(decompiled); }
protected virtual Expr VisitBlock (ExprBlock e) { return this.VisitCollection (e.Exprs, e, exprs => new ExprBlock (e.MethodInfo, exprs)); }