protected override Expr VisitCall (ExprCall e) { var call = (ExprCall)base.VisitCall (e); var method = e.Method; if (method.DeclaringType.FullName == "System.Diagnostics.Contracts.Contract") { switch (method.Name) { case "Requires": if (!method.HasGenericParameters) { switch (method.Parameters.Count) { case 1: return this.ProcessRequires1 (call); case 2: return this.ProcessRequires2 (call); default: throw new NotSupportedException ("Invalid number of parameters to Contract.Requires()"); } } else { goto default; } default: throw new NotSupportedException ("Cannot handle Contract." + e.Method.Name + "()"); } } return call; }
protected override Expr VisitCall (ExprCall e) { foreach (var param in e.Parameters) { this.Visit (param); } var instCall = this.il.Create (OpCodes.Call, e.Method); this.Emit (e, instCall); return e; }
protected virtual Expr VisitCall (ExprCall e) { return this.VisitCollection (e.Parameters, e, exprs => new ExprCall (e.MethodInfo, e.Method, exprs)); }
private Expr ProcessRequires1 (ExprCall e) { MethodDefinition mRequires = this.contractsRuntime.GetRequires (); Expr conditionExpr = e.Parameters.First (); Expr nullArgExpr = new ExprLoadConstant (this.methodInfo, null); string conditionText = this.GetConditionString (e); Expr conditionStringExpr = new ExprLoadConstant (this.methodInfo, conditionText); var call = new ExprCall (this.methodInfo, mRequires, new Expr [] { conditionExpr, nullArgExpr, conditionStringExpr }); this.contractRequiresInfo.Add (new ContractRequiresInfo (e, call)); return call; }