OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 class ConstantEmitter implements ConstantVisitor { | 5 class ConstantEmitter implements ConstantVisitor { |
6 final Compiler compiler; | 6 final Compiler compiler; |
7 final Namer namer; | 7 final Namer namer; |
8 | 8 |
9 CodeBuffer buffer; | 9 CodeBuffer buffer; |
10 bool shouldEmitCanonicalVersion; | 10 bool shouldEmitCanonicalVersion; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void visitNull(NullConstant constant) { | 56 void visitNull(NullConstant constant) { |
57 buffer.add("null"); | 57 buffer.add("null"); |
58 } | 58 } |
59 | 59 |
60 void visitInt(IntConstant constant) { | 60 void visitInt(IntConstant constant) { |
61 buffer.add(constant.value.toString()); | 61 buffer.add(constant.value.toString()); |
62 } | 62 } |
63 | 63 |
64 void visitDouble(DoubleConstant constant) { | 64 void visitDouble(DoubleConstant constant) { |
65 double value = constant.value; | 65 double value = constant.value; |
66 if (value.isNaN()) { | 66 if (value.isNaN) { |
67 buffer.add("(0/0)"); | 67 buffer.add("(0/0)"); |
68 } else if (value == double.INFINITY) { | 68 } else if (value == double.INFINITY) { |
69 buffer.add("(1/0)"); | 69 buffer.add("(1/0)"); |
70 } else if (value == -double.INFINITY) { | 70 } else if (value == -double.INFINITY) { |
71 buffer.add("(-1/0)"); | 71 buffer.add("(-1/0)"); |
72 } else { | 72 } else { |
73 buffer.add("$value"); | 73 buffer.add("$value"); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 buffer.add(getJsConstructor(constant.type.element)); | 243 buffer.add(getJsConstructor(constant.type.element)); |
244 buffer.add("("); | 244 buffer.add("("); |
245 for (int i = 0; i < constant.fields.length; i++) { | 245 for (int i = 0; i < constant.fields.length; i++) { |
246 if (i != 0) buffer.add(", "); | 246 if (i != 0) buffer.add(", "); |
247 _visit(constant.fields[i]); | 247 _visit(constant.fields[i]); |
248 } | 248 } |
249 buffer.add(")"); | 249 buffer.add(")"); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
OLD | NEW |