| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 class ConstantEmitter { | 7 class ConstantEmitter { |
| 8 ConstantReferenceEmitter _referenceEmitter; | 8 ConstantReferenceEmitter _referenceEmitter; |
| 9 ConstantInitializerEmitter _initializerEmitter; | 9 ConstantInitializerEmitter _initializerEmitter; |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } else if (value == -double.INFINITY) { | 91 } else if (value == -double.INFINITY) { |
| 92 return new jsAst.LiteralNumber("(-1/0)"); | 92 return new jsAst.LiteralNumber("(-1/0)"); |
| 93 } else { | 93 } else { |
| 94 return new jsAst.LiteralNumber("$value"); | 94 return new jsAst.LiteralNumber("$value"); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 jsAst.Expression visitTrue(TrueConstant constant) { | 98 jsAst.Expression visitTrue(TrueConstant constant) { |
| 99 if (compiler.enableMinification) { | 99 if (compiler.enableMinification) { |
| 100 // Use !0 for true. | 100 // Use !0 for true. |
| 101 return new jsAst.Prefix("!", new jsAst.LiteralNumber("0")); | 101 return js["!0"]; |
| 102 } else { | 102 } else { |
| 103 return new jsAst.LiteralBool(true); | 103 return new jsAst.LiteralBool(true); |
| 104 } | 104 } |
| 105 | |
| 106 } | 105 } |
| 107 | 106 |
| 108 jsAst.Expression visitFalse(FalseConstant constant) { | 107 jsAst.Expression visitFalse(FalseConstant constant) { |
| 109 if (compiler.enableMinification) { | 108 if (compiler.enableMinification) { |
| 110 // Use !1 for false. | 109 // Use !1 for false. |
| 111 return new jsAst.Prefix("!", new jsAst.LiteralNumber("1")); | 110 return js["!1"]; |
| 112 } else { | 111 } else { |
| 113 return new jsAst.LiteralBool(false); | 112 return new jsAst.LiteralBool(false); |
| 114 } | 113 } |
| 115 } | 114 } |
| 116 | 115 |
| 117 /** | 116 /** |
| 118 * Write the contents of the quoted string to a [CodeBuffer] in | 117 * Write the contents of the quoted string to a [CodeBuffer] in |
| 119 * a form that is valid as JavaScript string literal content. | 118 * a form that is valid as JavaScript string literal content. |
| 120 * The string is assumed quoted by double quote characters. | 119 * The string is assumed quoted by double quote characters. |
| 121 */ | 120 */ |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 314 } |
| 316 | 315 |
| 317 List<jsAst.Expression> _array(List<Constant> values) { | 316 List<jsAst.Expression> _array(List<Constant> values) { |
| 318 List<jsAst.Expression> valueList = <jsAst.Expression>[]; | 317 List<jsAst.Expression> valueList = <jsAst.Expression>[]; |
| 319 for (int i = 0; i < values.length; i++) { | 318 for (int i = 0; i < values.length; i++) { |
| 320 valueList.add(_reference(values[i])); | 319 valueList.add(_reference(values[i])); |
| 321 } | 320 } |
| 322 return valueList; | 321 return valueList; |
| 323 } | 322 } |
| 324 } | 323 } |
| OLD | NEW |