Chromium Code Reviews| 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 Constant implements Hashable { | 5 class Constant implements Hashable { |
| 6 const Constant(); | 6 const Constant(); |
| 7 | 7 |
| 8 bool isNull() => false; | 8 bool isNull() => false; |
| 9 bool isBool() => false; | 9 bool isBool() => false; |
| 10 bool isTrue() => false; | 10 bool isTrue() => false; |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 | 606 |
| 607 String getNameForConstant(Constant constant) { | 607 String getNameForConstant(Constant constant) { |
| 608 return compiledConstants[constant]; | 608 return compiledConstants[constant]; |
| 609 } | 609 } |
| 610 | 610 |
| 611 StringBuffer writeJsCode(StringBuffer buffer, Constant value) { | 611 StringBuffer writeJsCode(StringBuffer buffer, Constant value) { |
| 612 value.writeJsCode(buffer, this); | 612 value.writeJsCode(buffer, this); |
| 613 return buffer; | 613 return buffer; |
| 614 } | 614 } |
| 615 | 615 |
| 616 StringBuffer writeCanonicalizedJsCode(StringBuffer buffer, Constant value) { | |
|
ngeoffray
2012/03/30 08:28:32
How about using this as the only entry point for w
floitsch
2012/03/30 18:11:49
Done.
| |
| 617 value.writeCanonicalizedJsCode(buffer, this); | |
| 618 return buffer; | |
| 619 } | |
| 620 | |
| 616 StringBuffer writeJsCodeForVariable(StringBuffer buffer, | 621 StringBuffer writeJsCodeForVariable(StringBuffer buffer, |
| 617 VariableElement element) { | 622 VariableElement element) { |
| 618 if (!initialVariableValues.containsKey(element)) { | 623 if (!initialVariableValues.containsKey(element)) { |
| 619 compiler.internalError("No initial value for given element", | 624 compiler.internalError("No initial value for given element", |
| 620 element: element); | 625 element: element); |
| 621 } | 626 } |
| 622 Constant constant = initialVariableValues[element]; | 627 Constant constant = initialVariableValues[element]; |
| 623 if (constant.isObject()) { | 628 constant.writeCanonicalizedJsCode(buffer, this); |
| 624 String name = compiledConstants[constant]; | |
| 625 buffer.add("${compiler.namer.ISOLATE}.prototype.$name"); | |
| 626 } else { | |
| 627 writeJsCode(buffer, constant); | |
| 628 } | |
| 629 return buffer; | 629 return buffer; |
| 630 } | 630 } |
| 631 | 631 |
| 632 /** | 632 /** |
| 633 * Write the contents of the quoted string to a [StringBuffer] in | 633 * Write the contents of the quoted string to a [StringBuffer] in |
| 634 * a form that is valid as JavaScript string literal content. | 634 * a form that is valid as JavaScript string literal content. |
| 635 * The string is assumed quoted by single quote characters. | 635 * The string is assumed quoted by single quote characters. |
| 636 */ | 636 */ |
| 637 static void writeEscapedString(DartString string, | 637 static void writeEscapedString(DartString string, |
| 638 StringBuffer buffer, | 638 StringBuffer buffer, |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1124 Constant fieldValue = fieldValues[field]; | 1124 Constant fieldValue = fieldValues[field]; |
| 1125 if (fieldValue === null) { | 1125 if (fieldValue === null) { |
| 1126 // Use the default value. | 1126 // Use the default value. |
| 1127 fieldValue = compiler.compileVariable(field); | 1127 fieldValue = compiler.compileVariable(field); |
| 1128 } | 1128 } |
| 1129 jsNewArguments.add(fieldValue); | 1129 jsNewArguments.add(fieldValue); |
| 1130 }); | 1130 }); |
| 1131 return jsNewArguments; | 1131 return jsNewArguments; |
| 1132 } | 1132 } |
| 1133 } | 1133 } |
| OLD | NEW |