Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart |
| index d25af39fcfef36600f263d3db575224f16940da6..f4e82fd0d917096dbec803810b8d4644462f9811 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart |
| @@ -7,12 +7,19 @@ library dart2js.ir_nodes_sexpr; |
| import '../util/util.dart'; |
| import 'cps_ir_nodes.dart'; |
| +/// A [Decorator] is a function used by [SExpressionStringifier] to augment the |
| +/// output produced for a node. It can be provided to the constructor. |
| +typedef String Decorator(Node node, String s); |
| + |
| /// Generate a Lisp-like S-expression representation of an IR node as a string. |
| class SExpressionStringifier extends Visitor<String> with Indentation { |
| final _Namer namer = new _Namer(); |
| String newValueName(Node node) => namer.defineValueName(node); |
| String newContinuationName(Node node) => namer.defineContinuationName(node); |
| + final Decorator decorator; |
| + |
| + SExpressionStringifier([this.decorator]); |
| String access(Reference<Definition> r) => namer.getName(r.definition); |
| @@ -20,6 +27,13 @@ class SExpressionStringifier extends Visitor<String> with Indentation { |
| return namer.useElementName(node); |
| } |
| + /// Main entry point for creating a [String] from a [Node]. All recursive |
| + /// calls must go through this method. |
| + String visit(Node node) { |
| + String s = super.visit(node); |
| + return (decorator != null) ? decorator(node, s) : s; |
|
sigurdm
2014/11/27 12:53:37
One fewer negations:
return decorator == null ? s
karlklose
2014/11/27 13:25:14
Done.
|
| + } |
| + |
| String visitFunctionDefinition(FunctionDefinition node) { |
| String name = node.element.name; |
| namer.useReturnName(node.returnContinuation); |