Exemple #1
0
 public override void RewriteChildren(ContractElement contractElement) {
   base.RewriteChildren(contractElement);
   var be = contractElement.Condition as IBlockExpression;
   if (be != null) {
     var lb = new LocalBinder(this.host);
     contractElement.Condition = lb.Rewrite(contractElement.Condition);
     if (lb.localDeclarations.Any()) {
       var be2 = new BlockExpression() {
         BlockStatement = new BlockStatement() {
           Statements = lb.localDeclarations,
         },
         Expression = contractElement.Condition,
       };
       contractElement.Condition = be2;
     }
   }
 }
Exemple #2
0
 /// <summary>
 /// If the local binder is used to just close a bunch of statements, then this method can
 /// be used. It will rewrite the list of statements <paramref name="clump"/> and return a
 /// new list of statements with the additional local declaration statements at the front
 /// of the list.
 /// </summary>
 public static List<IStatement> CloseClump(IMetadataHost host, List<IStatement> clump) {
   var cc = new LocalBinder(host);
   clump = cc.Rewrite(clump);
   cc.localDeclarations.AddRange(clump);
   return cc.localDeclarations;
 }