| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // TODO(floitsch): create a better hash. | 278 // TODO(floitsch): create a better hash. |
| 279 int hash = 0; | 279 int hash = 0; |
| 280 for (Constant input in entries) hash ^= input.hashCode(); | 280 for (Constant input in entries) hash ^= input.hashCode(); |
| 281 _hashCode = hash; | 281 _hashCode = hash; |
| 282 } | 282 } |
| 283 bool isList() => true; | 283 bool isList() => true; |
| 284 | 284 |
| 285 void _writeJsCode(StringBuffer buffer, ConstantHandler handler) { | 285 void _writeJsCode(StringBuffer buffer, ConstantHandler handler) { |
| 286 // TODO(floitsch): we should not need to go through the compiler to make | 286 // TODO(floitsch): we should not need to go through the compiler to make |
| 287 // the list constant. | 287 // the list constant. |
| 288 String isolatePrototype = "${handler.compiler.namer.ISOLATE}.prototype"; | 288 buffer.add("${handler.compiler.namer.ISOLATE}.makeConstantList"); |
| 289 buffer.add("$isolatePrototype.makeConstantList"); | |
| 290 buffer.add("(["); | 289 buffer.add("(["); |
| 291 for (int i = 0; i < entries.length; i++) { | 290 for (int i = 0; i < entries.length; i++) { |
| 292 if (i != 0) buffer.add(", "); | 291 if (i != 0) buffer.add(", "); |
| 293 Constant entry = entries[i]; | 292 Constant entry = entries[i]; |
| 294 handler.writeConstant(buffer, entry); | 293 handler.writeConstant(buffer, entry); |
| 295 } | 294 } |
| 296 buffer.add("])"); | 295 buffer.add("])"); |
| 297 } | 296 } |
| 298 | 297 |
| 299 bool operator ==(var other) { | 298 bool operator ==(var other) { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 buffer.add(code.toRadixString(16)); | 685 buffer.add(code.toRadixString(16)); |
| 687 } | 686 } |
| 688 } else { | 687 } else { |
| 689 buffer.add(new String.fromCharCodes(<int>[code])); | 688 buffer.add(new String.fromCharCodes(<int>[code])); |
| 690 } | 689 } |
| 691 } | 690 } |
| 692 } | 691 } |
| 693 } | 692 } |
| 694 | 693 |
| 695 String getJsConstructor(ClassElement element) { | 694 String getJsConstructor(ClassElement element) { |
| 696 return compiler.namer.isolatePropertyAccess(element); | 695 return compiler.namer.initialStaticsAccess(element); |
| 697 } | 696 } |
| 698 } | 697 } |
| 699 | 698 |
| 700 class CompileTimeConstantEvaluator extends AbstractVisitor { | 699 class CompileTimeConstantEvaluator extends AbstractVisitor { |
| 701 final TreeElements elements; | 700 final TreeElements elements; |
| 702 final Compiler compiler; | 701 final Compiler compiler; |
| 703 | 702 |
| 704 CompileTimeConstantEvaluator(this.elements, this.compiler); | 703 CompileTimeConstantEvaluator(this.elements, this.compiler); |
| 705 | 704 |
| 706 Constant evaluate(Node node) { | 705 Constant evaluate(Node node) { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 Constant fieldValue = fieldValues[field]; | 1146 Constant fieldValue = fieldValues[field]; |
| 1148 if (fieldValue === null) { | 1147 if (fieldValue === null) { |
| 1149 // Use the default value. | 1148 // Use the default value. |
| 1150 fieldValue = compiler.compileVariable(field); | 1149 fieldValue = compiler.compileVariable(field); |
| 1151 } | 1150 } |
| 1152 jsNewArguments.add(fieldValue); | 1151 jsNewArguments.add(fieldValue); |
| 1153 }); | 1152 }); |
| 1154 return jsNewArguments; | 1153 return jsNewArguments; |
| 1155 } | 1154 } |
| 1156 } | 1155 } |
| OLD | NEW |