public override void TraverseChildren(IBlockExpression blockExpression) {
   var saved = this.currentBlock;
   this.currentBlock = blockExpression.BlockStatement;
   base.TraverseChildren(blockExpression.BlockStatement);
   this.Traverse(blockExpression.Expression);
   this.currentBlock = saved;
 }
    private void PrintNewExpressionWithInitializers(IBlockExpression blockExpression) {

      var i = 0;
      foreach (var s in blockExpression.BlockStatement.Statements) {
        if (i++ == 0) {
          var lds = s as ILocalDeclarationStatement;
          this.Traverse(lds.InitialValue);
          this.sourceEmitterOutput.WriteLine("{");
          this.sourceEmitterOutput.IncreaseIndent();
          continue;
        }
        var expressionStatement = (IExpressionStatement)s;
        this.sourceEmitterOutput.Write("", true);
        var assign = expressionStatement.Expression as IAssignment;
        if (assign != null) {
          var def = assign.Target.Definition;
          PrintBoundExpressionDefinition(null, def, false);
          this.sourceEmitterOutput.Write(" = ");
          this.Traverse(assign.Source);
          this.sourceEmitterOutput.WriteLine(", ");
          continue;
        }

        var methodCall = expressionStatement.Expression as IMethodCall;
        if (methodCall != null) {
          this.PrintMethodReferenceName(methodCall.MethodToCall, NameFormattingOptions.OmitContainingNamespace | NameFormattingOptions.OmitContainingType);
          this.sourceEmitterOutput.Write(" = ");
          foreach (var a in methodCall.Arguments) {
            this.Traverse(a);
            break;
          }
          this.sourceEmitterOutput.WriteLine(", ");
          continue;
        }

        Contract.Assume(false);
      }
      this.sourceEmitterOutput.DecreaseIndent();
      this.sourceEmitterOutput.Write("}", true);
    }
예제 #3
0
 //^ ensures this.path.Count == old(this.path.Count);
 /// <summary>
 /// Traverses the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public virtual void Visit(IBlockExpression blockExpression)
 {
     if (this.stopTraversal) return;
       //^ int oldCount = this.path.Count;
       this.path.Push(blockExpression);
       this.Visit(blockExpression.BlockStatement);
       this.Visit(blockExpression.Expression);
       //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count.
       this.path.Pop();
 }
예제 #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="blockExpression"></param>
 public BlockExpression(IBlockExpression blockExpression)
     : base(blockExpression)
 {
     this.blockStatement = blockExpression.BlockStatement;
       this.expression = blockExpression.Expression;
 }
예제 #5
0
 /// <summary>
 /// Traverses the children of the block expression.
 /// </summary>
 public virtual void TraverseChildren(IBlockExpression blockExpression)
 {
     Contract.Requires(blockExpression != null);
       this.TraverseChildren((IExpression)blockExpression);
       if (this.StopTraversal) return;
       this.Traverse(blockExpression.BlockStatement);
       if (this.StopTraversal) return;
       this.Traverse(blockExpression.Expression);
 }
예제 #6
0
 /// <summary>
 /// Performs some computation with the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public virtual void Visit(IBlockExpression blockExpression)
 {
     this.Visit((IExpression)blockExpression);
 }
 /// <summary>
 /// Rewrites the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public virtual IExpression Rewrite(IBlockExpression blockExpression)
 {
     return blockExpression;
 }
예제 #8
0
 /// <summary>
 /// Performs some computation with the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public virtual void Visit(IBlockExpression blockExpression)
 {
 }
예제 #9
0
 /// <summary>
 /// Generates IL for the specified block expression.
 /// </summary>
 /// <param name="blockExpression">The block expression.</param>
 public override void TraverseChildren(IBlockExpression blockExpression) {
   uint numberOfIteratorLocals = 0;
   if (this.iteratorLocalCount != null)
     this.iteratorLocalCount.TryGetValue(blockExpression.BlockStatement, out numberOfIteratorLocals);
   this.generator.BeginScope(numberOfIteratorLocals);
   this.Traverse(blockExpression.BlockStatement.Statements);
   this.Traverse(blockExpression.Expression);
   this.generator.EndScope();
 }
예제 #10
0
 public override void TraverseChildren(IBlockExpression blockExpression) {
   this.sourceEmitterOutput.WriteLine("(() => {");
   this.sourceEmitterOutput.IncreaseIndent();
   this.Traverse(blockExpression.BlockStatement);
   this.sourceEmitterOutput.Write("return ", true);
   this.Traverse(blockExpression.Expression);
   this.sourceEmitterOutput.Write("; })()");
   this.sourceEmitterOutput.DecreaseIndent();
 }
 public override void Visit(IBlockExpression blockExpression)
 {
     if(Process(blockExpression)){visitor.Visit(blockExpression);}
     base.Visit(blockExpression);
 }
            private void WriteBlockExpression(IBlockExpression expression, IFormatter formatter)
            {
                formatter.Write("[");

                if (expression.Expressions.Count > 16)
                {
                    formatter.WriteLine();
                    formatter.WriteIndent();
                }

                for (int i = 0; i < expression.Expressions.Count; i++)
                {
                    if (i != 0)
                    {
                        formatter.Write(", ");

                        if ((i % 16) == 0)
                        {
                            formatter.WriteLine();
                        }
                    }

                    this.WriteExpression(expression.Expressions[i], formatter);
                }

                if (expression.Expressions.Count > 16)
                {
                    formatter.WriteOutdent();
                    formatter.WriteLine();
                }

                formatter.Write("]");
            }
예제 #13
0
 /// <summary>
 /// Performs some computation with the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public virtual void Visit(IBlockExpression blockExpression)
 {
 }
예제 #14
0
 public virtual void VisitBlockExpression(IBlockExpression value)
 {
     this.VisitExpressionCollection(value.Expressions);
 }
예제 #15
0
 public override void TraverseChildren(IBlockExpression blockExpression) {
   base.TraverseChildren(blockExpression);
   ((BlockExpression)blockExpression).Type = blockExpression.Expression.Type;
 }
예제 #16
0
        public override void TraverseChildren(IBlockExpression blockExpression)
{ MethodEnter(blockExpression);
            base.TraverseChildren(blockExpression);
     MethodExit();   }
예제 #17
0
    /// <summary>
    /// Returns a deep copy of the given block expression.
    /// </summary>
    /// <param name="blockExpression"></param>
    public BlockExpression Copy(IBlockExpression blockExpression) {
      Contract.Requires(blockExpression != null);
      Contract.Ensures(Contract.Result<BlockExpression>() != null);

      var mutableCopy = this.shallowCopier.Copy(blockExpression);
      this.CopyChildren((Expression)mutableCopy);
      mutableCopy.BlockStatement = this.Copy((BlockStatement)mutableCopy.BlockStatement);
      mutableCopy.Expression = this.Copy(mutableCopy.Expression);
      return mutableCopy;
    }
예제 #18
0
 /// <summary>
 /// Traverses the block expression.
 /// </summary>
 public void Traverse(IBlockExpression blockExpression)
 {
     Contract.Requires(blockExpression != null);
       if (this.preorderVisitor != null) this.preorderVisitor.Visit(blockExpression);
       if (this.StopTraversal) return;
       this.TraverseChildren(blockExpression);
       if (this.StopTraversal) return;
       if (this.postorderVisitor != null) this.postorderVisitor.Visit(blockExpression);
 }
예제 #19
0
    /// <summary>
    /// Returns a shallow copy of the given block expression.
    /// </summary>
    /// <param name="blockExpression"></param>
    public BlockExpression Copy(IBlockExpression blockExpression) {
      Contract.Requires(blockExpression != null);
      Contract.Ensures(Contract.Result<BlockExpression>() != null);

      return new BlockExpression(blockExpression);
    }
예제 #20
0
 public void Visit(IBlockExpression blockExpression)
 {
     this.traverser.Traverse(blockExpression);
 }
예제 #21
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <summary>
 /// Visits the specified block expression.
 /// </summary>
 /// <param name="blockExpression">The block expression.</param>
 public override void Visit(IBlockExpression blockExpression)
 {
     BlockExpression mutableBlockExpression = new BlockExpression(blockExpression);
     this.resultExpression = this.myCodeCopier.DeepCopy(mutableBlockExpression);
 }
예제 #22
0
 public void Visit(IBlockExpression blockExpression)
 {
     Contract.Requires(blockExpression != null);
       throw new NotImplementedException();
 }
예제 #23
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <summary>
 /// Returns a deep copy of the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public BlockExpression Copy(IBlockExpression blockExpression)
 {
     var mutableCopy = this.shallowCopier.Copy(blockExpression);
       this.CopyChildren((Expression)mutableCopy);
       mutableCopy.BlockStatement = this.Copy((BlockStatement)mutableCopy.BlockStatement);
       mutableCopy.Expression = this.Copy(mutableCopy.Expression);
       return mutableCopy;
 }
예제 #24
0
 public void Visit(IBlockExpression blockExpression)
 {
     throw new NotImplementedException();
 }
예제 #25
0
파일: Copier.cs 프로젝트: riverar/devtools
 /// <summary>
 /// Returns a shallow copy of the given block expression.
 /// </summary>
 /// <param name="blockExpression"></param>
 public BlockExpression Copy(IBlockExpression blockExpression)
 {
     return new BlockExpression(blockExpression);
 }
 public override IExpression Rewrite(IBlockExpression blockExpression) {
   var e = base.Rewrite(blockExpression);
   var be = e as IBlockExpression;
   if (be == null) return e;
   if (IteratorHelper.EnumerableIsEmpty(be.BlockStatement.Statements))
     return be.Expression;
   return be;
 }
예제 #27
0
파일: Copier.cs 프로젝트: riverar/devtools
 public void Visit(IBlockExpression blockExpression)
 {
     this.result = this.copier.Copy(blockExpression);
 }
 /// <summary>
 /// Special case for the source expression "new C(){ f1 = e1, f2 = e2, ... }" (where the f's can be fields
 /// or properties). See comment in the decompiler.
 /// </summary>
 public override void TraverseChildren(IBlockExpression blockExpression) {
   var boundExpression = blockExpression.Expression as IBoundExpression;
   if (boundExpression != null) {
     var localDefinition = boundExpression.Definition as ILocalDefinition;
     if (localDefinition != null) {
       var specialCase = true;
       var i = 0;
       foreach (var s in blockExpression.BlockStatement.Statements) {
         if (i == 0) {
           if (!(s is ILocalDeclarationStatement)) {
             specialCase = false;
             break;
           }
         } else {
           var expressionStatement = s as IExpressionStatement;
           var expr = expressionStatement.Expression;
           if (!((expr is IAssignment || expr is IMethodCall))) {
             specialCase = false;
             break;
           }
         }
         i++;
       }
       if (specialCase) {
         PrintNewExpressionWithInitializers(blockExpression);
         return;
       }
     }
   }
   this.sourceEmitterOutput.WriteLine("(() => {");
   this.sourceEmitterOutput.IncreaseIndent();
   this.Traverse(blockExpression.BlockStatement);
   this.sourceEmitterOutput.Write("return ", true);
   this.Traverse(blockExpression.Expression);
   this.sourceEmitterOutput.Write("; })()");
   this.sourceEmitterOutput.DecreaseIndent();
 }
 public override void TraverseChildren(IBlockExpression blockExpression) {
   this.StmtTraverser.Traverse(blockExpression.BlockStatement);
   this.Traverse(blockExpression.Expression);
 }
예제 #30
0
 public virtual void onASTElement(IBlockExpression blockExpression) { }
예제 #31
0
파일: Mutator.cs 프로젝트: riverar/devtools
 public void Visit(IBlockExpression blockExpression)
 {
     this.result = this.rewriter.Rewrite(blockExpression);
 }