// VoidExpression private void DefaultWalk(VoidExpression node) { if (Walk(node)) { WalkNode(node.Statement); } PostWalk(node); }
// VoidExpression private void Dump(VoidExpression node) { Out(".void {"); Indent(); WalkNode(node.Statement); Dedent(); Out("}"); }
protected internal override void PostWalk(VoidExpression node) { _voidExpressionsDepth--; }
// Normally, expressions do not affect control-flow significantly. Only statements do. // Only statements check whether they should keep executing more statements or if // they should return a value. However, VoidExpression is a way to mix up expressions // and statements. If a VoidExpression contains control flow, that causes a problem protected internal override bool Walk(VoidExpression node) { _voidExpressionsDepth++; return true; }
protected override void PostWalk(VoidExpression node) { node.Statement = Rewrite(node.Statement); }
static Statement Rewrite(VoidExpression ve) { var block = new List<Statement>(); var s = Rewrite(ve.Statement); if (s is BlockStatement) { block.AddRange(((BlockStatement)s).Statements); } else { block.Add(s); } block.Add(Ast.Return(Unspecified)); return Rewrite(Ast.Block(block)); }
// Normally, expressions do not affect control-flow significantly. Only statements do. // Only statements check whether they should keep executing more statements or if // they should return a value. However, VoidExpression is a way to mix up expressions // and statements. If a VoidExpression contains control flow, that causes a problem protected internal override bool Walk(VoidExpression node) { _voidExpressionsDepth++; return(true); }
// Void expression triggers rewrite protected internal override void PostWalk(VoidExpression node) { _rewrite = true; }
// VoidExpression private Expression Rewrite(VoidExpression node) { Statement statement = RewriteStatement(node.Statement); return(Ast.Void(statement)); }