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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/constant_ordering.dart

Issue 2864363002: Remove DartString from constants. (Closed)
Patch Set: Remove toDartString Created 3 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/mirrors_used.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 library dart2js.js_emitter.constant_ordering; 5 library dart2js.js_emitter.constant_ordering;
6 6
7 import '../constants/values.dart'; 7 import '../constants/values.dart';
8 import '../elements/elements.dart' show Elements; 8 import '../elements/elements.dart' show Elements;
9 import '../elements/entities.dart' show Entity, FieldEntity; 9 import '../elements/entities.dart' show Entity, FieldEntity;
10 import '../elements/resolution_types.dart'; 10 import '../elements/resolution_types.dart';
11 import '../js_backend/js_backend.dart' show SyntheticConstantKind; 11 import '../js_backend/js_backend.dart' show SyntheticConstantKind;
12 import '../tree/dartstring.dart' show DartString;
13 12
14 /// A canonical but arbitrary ordering of constants. The ordering is 'stable' 13 /// A canonical but arbitrary ordering of constants. The ordering is 'stable'
15 /// under perturbation of the source. 14 /// under perturbation of the source.
16 int deepCompareConstants(ConstantValue a, ConstantValue b) { 15 int deepCompareConstants(ConstantValue a, ConstantValue b) {
17 return _CompareVisitor.compareValues(a, b); 16 return _CompareVisitor.compareValues(a, b);
18 } 17 }
19 18
20 class _CompareVisitor implements ConstantValueVisitor<int, ConstantValue> { 19 class _CompareVisitor implements ConstantValueVisitor<int, ConstantValue> {
21 const _CompareVisitor(); 20 const _CompareVisitor();
22 21
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return a.primitiveValue.compareTo(b.primitiveValue); 87 return a.primitiveValue.compareTo(b.primitiveValue);
89 } 88 }
90 89
91 int visitBool(BoolConstantValue a, BoolConstantValue b) { 90 int visitBool(BoolConstantValue a, BoolConstantValue b) {
92 int aInt = a.primitiveValue ? 1 : 0; 91 int aInt = a.primitiveValue ? 1 : 0;
93 int bInt = b.primitiveValue ? 1 : 0; 92 int bInt = b.primitiveValue ? 1 : 0;
94 return aInt.compareTo(bInt); 93 return aInt.compareTo(bInt);
95 } 94 }
96 95
97 int visitString(StringConstantValue a, StringConstantValue b) { 96 int visitString(StringConstantValue a, StringConstantValue b) {
98 DartString aString = a.primitiveValue; 97 String aString = a.primitiveValue;
99 DartString bString = b.primitiveValue; 98 String bString = b.primitiveValue;
100 int r = aString.length.compareTo(bString.length); 99 return aString.compareTo(bString);
101 if (r != 0) return r;
102 return aString.slowToString().compareTo(bString.slowToString());
103 } 100 }
104 101
105 int visitList(ListConstantValue a, ListConstantValue b) { 102 int visitList(ListConstantValue a, ListConstantValue b) {
106 int r = compareLists(compareValues, a.entries, b.entries); 103 int r = compareLists(compareValues, a.entries, b.entries);
107 if (r != 0) return r; 104 if (r != 0) return r;
108 ResolutionInterfaceType type1 = a.type; 105 ResolutionInterfaceType type1 = a.type;
109 ResolutionInterfaceType type2 = b.type; 106 ResolutionInterfaceType type2 = b.type;
110 return compareDartTypes(type1, type2); 107 return compareDartTypes(type1, type2);
111 } 108 }
112 109
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 int visitBool(BoolConstantValue a, _) => BOOL; 211 int visitBool(BoolConstantValue a, _) => BOOL;
215 int visitString(StringConstantValue a, _) => STRING; 212 int visitString(StringConstantValue a, _) => STRING;
216 int visitList(ListConstantValue a, _) => LIST; 213 int visitList(ListConstantValue a, _) => LIST;
217 int visitMap(MapConstantValue a, _) => MAP; 214 int visitMap(MapConstantValue a, _) => MAP;
218 int visitConstructed(ConstructedConstantValue a, _) => CONSTRUCTED; 215 int visitConstructed(ConstructedConstantValue a, _) => CONSTRUCTED;
219 int visitType(TypeConstantValue a, _) => TYPE; 216 int visitType(TypeConstantValue a, _) => TYPE;
220 int visitInterceptor(InterceptorConstantValue a, _) => INTERCEPTOR; 217 int visitInterceptor(InterceptorConstantValue a, _) => INTERCEPTOR;
221 int visitSynthetic(SyntheticConstantValue a, _) => SYNTHETIC; 218 int visitSynthetic(SyntheticConstantValue a, _) => SYNTHETIC;
222 int visitDeferred(DeferredConstantValue a, _) => DEFERRED; 219 int visitDeferred(DeferredConstantValue a, _) => DEFERRED;
223 } 220 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/mirrors_used.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698