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); }
//^ 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(); }
/// <summary> /// /// </summary> /// <param name="blockExpression"></param> public BlockExpression(IBlockExpression blockExpression) : base(blockExpression) { this.blockStatement = blockExpression.BlockStatement; this.expression = blockExpression.Expression; }
/// <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); }
/// <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; }
/// <summary> /// Performs some computation with the given block expression. /// </summary> /// <param name="blockExpression"></param> public virtual void Visit(IBlockExpression blockExpression) { }
/// <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(); }
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("]"); }
public virtual void VisitBlockExpression(IBlockExpression value) { this.VisitExpressionCollection(value.Expressions); }
public override void TraverseChildren(IBlockExpression blockExpression) { base.TraverseChildren(blockExpression); ((BlockExpression)blockExpression).Type = blockExpression.Expression.Type; }
public override void TraverseChildren(IBlockExpression blockExpression) { MethodEnter(blockExpression); base.TraverseChildren(blockExpression); MethodExit(); }
/// <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; }
/// <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); }
/// <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); }
public void Visit(IBlockExpression blockExpression) { this.traverser.Traverse(blockExpression); }
/// <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); }
public void Visit(IBlockExpression blockExpression) { Contract.Requires(blockExpression != null); throw new NotImplementedException(); }
/// <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; }
public void Visit(IBlockExpression blockExpression) { throw new NotImplementedException(); }
/// <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; }
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); }
public virtual void onASTElement(IBlockExpression blockExpression) { }
public void Visit(IBlockExpression blockExpression) { this.result = this.rewriter.Rewrite(blockExpression); }