Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart

Issue 813753002: Change the S-expression representation of constant values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_data.dart ('k') | tests/compiler/dart2js/backend_dart/opt_constprop_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0d802f2047cfc917786ca68fb860465b7da6579f..7887a74ca2107129385bf27766c9b663cdf23f05 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
@@ -4,6 +4,7 @@
library dart2js.ir_nodes_sexpr;
+import '../constants/values.dart';
import '../util/util.dart';
import 'cps_ir_nodes.dart';
@@ -159,7 +160,9 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
}
String visitConstant(Constant node) {
- return '(Constant ${node.expression.value.toStructuredString()})';
+ String value =
+ node.expression.value.accept(new ConstantStringifier(), null);
+ return '(Constant $value)';
}
String visitThis(This node) {
@@ -234,6 +237,70 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
}
}
+class ConstantStringifier extends ConstantValueVisitor<String, Null> {
+ // Some of these methods are unimplemented because we haven't had a need
+ // to print such constants. When printing is implemented, the corresponding
+ // parsing support should be added to SExpressionUnstringifier.parseConstant
+ // in the dart2js tests (currently in the file
+ // tests/compiler/dart2js/backend_dart/sexpr_unstringifier.dart).
+
+ String _failWith(ConstantValue constant) {
+ throw 'Stringification not supported for ${constant.toStructuredString()}';
+ }
+
+ String visitFunction(FunctionConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitNull(NullConstantValue constant, _) {
+ return '(Null)';
+ }
+
+ String visitInt(IntConstantValue constant, _) {
+ return '(Int ${constant.unparse()})';
+ }
+
+ String visitDouble(DoubleConstantValue constant, _) {
+ return '(Double ${constant.unparse()})';
+ }
+
+ String visitBool(BoolConstantValue constant, _) {
+ return '(Bool ${constant.unparse()})';
+ }
+
+ String visitString(StringConstantValue constant, _) {
+ return '(String ${constant.unparse()})';
+ }
+
+ String visitList(ListConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitMap(MapConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitConstructed(ConstructedConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitType(TypeConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitInterceptor(InterceptorConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitDummy(DummyConstantValue constant, _) {
+ return _failWith(constant);
+ }
+
+ String visitDeferred(DeferredConstantValue constant, _) {
+ return _failWith(constant);
+ }
+}
+
class _Namer {
final Map<Node, String> _names = <Node, String>{};
int _valueCounter = 0;
« no previous file with comments | « pkg/analyzer2dart/test/sexpr_data.dart ('k') | tests/compiler/dart2js/backend_dart/opt_constprop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698