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

Side by Side Diff: lib/compiler/implementation/compile_time_constants.dart

Issue 10880068: - Change "static final" to "static const" in the lib/ directory. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/colors.dart ('k') | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 List<Constant> getDependencies() => const <Constant>[]; 50 List<Constant> getDependencies() => const <Constant>[];
51 abstract DartString toDartString(); 51 abstract DartString toDartString();
52 52
53 void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) { 53 void _writeCanonicalizedJsCode(CodeBuffer buffer, ConstantHandler handler) {
54 _writeJsCode(buffer, handler); 54 _writeJsCode(buffer, handler);
55 } 55 }
56 } 56 }
57 57
58 class NullConstant extends PrimitiveConstant { 58 class NullConstant extends PrimitiveConstant {
59 /** The value a Dart null is compiled to in JavaScript. */ 59 /** The value a Dart null is compiled to in JavaScript. */
60 static final String JsNull = "null"; 60 static const String JsNull = "null";
61 61
62 factory NullConstant() => const NullConstant._internal(); 62 factory NullConstant() => const NullConstant._internal();
63 const NullConstant._internal(); 63 const NullConstant._internal();
64 bool isNull() => true; 64 bool isNull() => true;
65 get value => null; 65 get value => null;
66 66
67 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) { 67 void _writeJsCode(CodeBuffer buffer, ConstantHandler handler) {
68 buffer.add(JsNull); 68 buffer.add(JsNull);
69 } 69 }
70 70
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 List<Constant> getDependencies() => entries; 315 List<Constant> getDependencies() => entries;
316 316
317 int get length => entries.length; 317 int get length => entries.length;
318 } 318 }
319 319
320 class MapConstant extends ObjectConstant { 320 class MapConstant extends ObjectConstant {
321 /** 321 /**
322 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript 322 * The [PROTO_PROPERTY] must not be used as normal property in any JavaScript
323 * object. It would change the prototype chain. 323 * object. It would change the prototype chain.
324 */ 324 */
325 static final String PROTO_PROPERTY = "__proto__"; 325 static const String PROTO_PROPERTY = "__proto__";
326 326
327 /** The dart class implementing constant map literals. */ 327 /** The dart class implementing constant map literals. */
328 static final SourceString DART_CLASS = const SourceString("ConstantMap"); 328 static const SourceString DART_CLASS = const SourceString("ConstantMap");
329 static final SourceString DART_PROTO_CLASS = 329 static const SourceString DART_PROTO_CLASS =
330 const SourceString("ConstantProtoMap"); 330 const SourceString("ConstantProtoMap");
331 static final SourceString LENGTH_NAME = const SourceString("length"); 331 static const SourceString LENGTH_NAME = const SourceString("length");
332 static final SourceString JS_OBJECT_NAME = const SourceString("_jsObject"); 332 static const SourceString JS_OBJECT_NAME = const SourceString("_jsObject");
333 static final SourceString KEYS_NAME = const SourceString("_keys"); 333 static const SourceString KEYS_NAME = const SourceString("_keys");
334 static final SourceString PROTO_VALUE = const SourceString("_protoValue"); 334 static const SourceString PROTO_VALUE = const SourceString("_protoValue");
335 335
336 final ListConstant keys; 336 final ListConstant keys;
337 final List<Constant> values; 337 final List<Constant> values;
338 final Constant protoValue; 338 final Constant protoValue;
339 int _hashCode; 339 int _hashCode;
340 340
341 MapConstant(Type type, this.keys, this.values, this.protoValue) 341 MapConstant(Type type, this.keys, this.values, this.protoValue)
342 : super(type) { 342 : super(type) {
343 // TODO(floitsch): create a better hash. 343 // TODO(floitsch): create a better hash.
344 int hash = 0; 344 int hash = 0;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 */ 591 */
592 List<VariableElement> getStaticNonFinalFieldsForEmission() { 592 List<VariableElement> getStaticNonFinalFieldsForEmission() {
593 return initialVariableValues.getKeys().filter((element) { 593 return initialVariableValues.getKeys().filter((element) {
594 return element.kind == ElementKind.FIELD 594 return element.kind == ElementKind.FIELD
595 && !element.isInstanceMember() 595 && !element.isInstanceMember()
596 && !element.modifiers.isFinal(); 596 && !element.modifiers.isFinal();
597 }); 597 });
598 } 598 }
599 599
600 /** 600 /**
601 * Returns a [List] of static final fields that need to be initialized. The 601 * Returns a [List] of static const fields that need to be initialized. The
602 * list must be evaluated in order since the fields might depend on each 602 * list must be evaluated in order since the fields might depend on each
603 * other. 603 * other.
604 */ 604 */
605 List<VariableElement> getStaticFinalFieldsForEmission() { 605 List<VariableElement> getStaticFinalFieldsForEmission() {
hausner 2012/08/27 15:57:45 Put a TODO to rename the function?
606 return initialVariableValues.getKeys().filter((element) { 606 return initialVariableValues.getKeys().filter((element) {
607 return element.kind == ElementKind.FIELD 607 return element.kind == ElementKind.FIELD
608 && !element.isInstanceMember() 608 && !element.isInstanceMember()
609 && element.modifiers.isFinal(); 609 && element.modifiers.isFinal();
610 }); 610 });
611 } 611 }
612 612
613 List<Constant> getConstantsForEmission() { 613 List<Constant> getConstantsForEmission() {
614 // We must emit dependencies before their uses. 614 // We must emit dependencies before their uses.
615 Set<Constant> seenConstants = new Set<Constant>(); 615 Set<Constant> seenConstants = new Set<Constant>();
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 Constant fieldValue = fieldValues[field]; 1170 Constant fieldValue = fieldValues[field];
1171 if (fieldValue === null) { 1171 if (fieldValue === null) {
1172 // Use the default value. 1172 // Use the default value.
1173 fieldValue = compiler.compileVariable(field); 1173 fieldValue = compiler.compileVariable(field);
1174 } 1174 }
1175 jsNewArguments.add(fieldValue); 1175 jsNewArguments.add(fieldValue);
1176 }); 1176 });
1177 return jsNewArguments; 1177 return jsNewArguments;
1178 } 1178 }
1179 } 1179 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/colors.dart ('k') | lib/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698