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

Side by Side Diff: pkg/compiler/lib/src/serialization/impact_serialization.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.serialization.impact; 5 library dart2js.serialization.impact;
6 6
7 import '../dart_types.dart'; 7 import '../dart_types.dart';
8 import '../common/resolution.dart'; 8 import '../common/resolution.dart';
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty); 55 useEncoder.setBool(Key.IS_EMPTY, use.isEmpty);
56 } 56 }
57 } 57 }
58 } 58 }
59 59
60 @override 60 @override
61 void visitDynamicUse(DynamicUse dynamicUse) { 61 void visitDynamicUse(DynamicUse dynamicUse) {
62 ObjectEncoder object = dynamicUses.createObject(); 62 ObjectEncoder object = dynamicUses.createObject();
63 object.setEnum(Key.KIND, dynamicUse.selector.kind); 63 object.setEnum(Key.KIND, dynamicUse.selector.kind);
64 64
65 object.setInt(Key.ARGUMENTS, 65 object.setInt(
66 dynamicUse.selector.callStructure.argumentCount); 66 Key.ARGUMENTS, dynamicUse.selector.callStructure.argumentCount);
67 object.setStrings(Key.NAMED_ARGUMENTS, 67 object.setStrings(
68 dynamicUse.selector.callStructure.namedArguments); 68 Key.NAMED_ARGUMENTS, dynamicUse.selector.callStructure.namedArguments);
69 69
70 object.setString(Key.NAME, 70 object.setString(Key.NAME, dynamicUse.selector.memberName.text);
71 dynamicUse.selector.memberName.text); 71 object.setBool(Key.IS_SETTER, dynamicUse.selector.memberName.isSetter);
72 object.setBool(Key.IS_SETTER,
73 dynamicUse.selector.memberName.isSetter);
74 if (dynamicUse.selector.memberName.library != null) { 72 if (dynamicUse.selector.memberName.library != null) {
75 object.setElement(Key.LIBRARY, 73 object.setElement(Key.LIBRARY, dynamicUse.selector.memberName.library);
76 dynamicUse.selector.memberName.library);
77 } 74 }
78 } 75 }
79 76
80 @override 77 @override
81 void visitStaticUse(StaticUse staticUse) { 78 void visitStaticUse(StaticUse staticUse) {
82 if (staticUse.element.isGenerativeConstructor && 79 if (staticUse.element.isGenerativeConstructor &&
83 staticUse.element.enclosingClass.isUnnamedMixinApplication) { 80 staticUse.element.enclosingClass.isUnnamedMixinApplication) {
84 // TODO(johnniwinther): Handle static use of forwarding constructors. 81 // TODO(johnniwinther): Handle static use of forwarding constructors.
85 return; 82 return;
86 } 83 }
(...skipping 15 matching lines...) Expand all
102 implements ResolutionImpact { 99 implements ResolutionImpact {
103 final Iterable<String> constSymbolNames; 100 final Iterable<String> constSymbolNames;
104 final Iterable<ConstantExpression> constantLiterals; 101 final Iterable<ConstantExpression> constantLiterals;
105 final Iterable<DynamicUse> dynamicUses; 102 final Iterable<DynamicUse> dynamicUses;
106 final EnumSet<Feature> _features; 103 final EnumSet<Feature> _features;
107 final Iterable<ListLiteralUse> listLiterals; 104 final Iterable<ListLiteralUse> listLiterals;
108 final Iterable<MapLiteralUse> mapLiterals; 105 final Iterable<MapLiteralUse> mapLiterals;
109 final Iterable<StaticUse> staticUses; 106 final Iterable<StaticUse> staticUses;
110 final Iterable<TypeUse> typeUses; 107 final Iterable<TypeUse> typeUses;
111 108
112 DeserializedResolutionImpact({ 109 DeserializedResolutionImpact(
113 this.constSymbolNames, 110 {this.constSymbolNames,
114 this.constantLiterals, 111 this.constantLiterals,
115 this.dynamicUses, 112 this.dynamicUses,
116 EnumSet<Feature> features, 113 EnumSet<Feature> features,
117 this.listLiterals, 114 this.listLiterals,
118 this.mapLiterals, 115 this.mapLiterals,
119 this.staticUses, 116 this.staticUses,
120 this.typeUses}) 117 this.typeUses})
121 : this._features = features; 118 : this._features = features;
122 119
123 Iterable<Feature> get features => _features.iterable(Feature.values); 120 Iterable<Feature> get features => _features.iterable(Feature.values);
124 } 121 }
125 122
126 class ImpactDeserializer { 123 class ImpactDeserializer {
127 /// Deserializes a [WorldImpact] from [objectDecoder]. 124 /// Deserializes a [WorldImpact] from [objectDecoder].
128 static ResolutionImpact deserializeImpact(ObjectDecoder objectDecoder) { 125 static ResolutionImpact deserializeImpact(ObjectDecoder objectDecoder) {
129 ListDecoder staticUseDecoder = objectDecoder.getList(Key.STATIC_USES); 126 ListDecoder staticUseDecoder = objectDecoder.getList(Key.STATIC_USES);
130 List<StaticUse> staticUses = <StaticUse>[]; 127 List<StaticUse> staticUses = <StaticUse>[];
131 for (int index = 0; index < staticUseDecoder.length; index++) { 128 for (int index = 0; index < staticUseDecoder.length; index++) {
132 ObjectDecoder object = staticUseDecoder.getObject(index); 129 ObjectDecoder object = staticUseDecoder.getObject(index);
133 StaticUseKind kind = object.getEnum(Key.KIND, StaticUseKind.values); 130 StaticUseKind kind = object.getEnum(Key.KIND, StaticUseKind.values);
134 Element element = object.getElement(Key.ELEMENT); 131 Element element = object.getElement(Key.ELEMENT);
135 staticUses.add(new StaticUse.internal(element, kind)); 132 staticUses.add(new StaticUse.internal(element, kind));
136 } 133 }
137 134
138 ListDecoder dynamicUseDecoder = objectDecoder.getList(Key.DYNAMIC_USES); 135 ListDecoder dynamicUseDecoder = objectDecoder.getList(Key.DYNAMIC_USES);
139 List<DynamicUse> dynamicUses = <DynamicUse>[]; 136 List<DynamicUse> dynamicUses = <DynamicUse>[];
140 for (int index = 0; index < dynamicUseDecoder.length; index++) { 137 for (int index = 0; index < dynamicUseDecoder.length; index++) {
141 ObjectDecoder object = dynamicUseDecoder.getObject(index); 138 ObjectDecoder object = dynamicUseDecoder.getObject(index);
142 SelectorKind kind = object.getEnum(Key.KIND, SelectorKind.values); 139 SelectorKind kind = object.getEnum(Key.KIND, SelectorKind.values);
143 int argumentCount = object.getInt(Key.ARGUMENTS); 140 int argumentCount = object.getInt(Key.ARGUMENTS);
144 List<String> namedArguments = 141 List<String> namedArguments =
145 object.getStrings(Key.NAMED_ARGUMENTS, isOptional: true); 142 object.getStrings(Key.NAMED_ARGUMENTS, isOptional: true);
146 String name = object.getString(Key.NAME); 143 String name = object.getString(Key.NAME);
147 bool isSetter = object.getBool(Key.IS_SETTER); 144 bool isSetter = object.getBool(Key.IS_SETTER);
148 LibraryElement library = object.getElement(Key.LIBRARY, isOptional: true); 145 LibraryElement library = object.getElement(Key.LIBRARY, isOptional: true);
149 dynamicUses.add( 146 dynamicUses.add(new DynamicUse(
150 new DynamicUse( 147 new Selector(kind, new Name(name, library, isSetter: isSetter),
151 new Selector( 148 new CallStructure(argumentCount, namedArguments)),
152 kind, 149 null));
153 new Name(name, library, isSetter: isSetter),
154 new CallStructure(argumentCount, namedArguments)),
155 null));
156 } 150 }
157 151
158 ListDecoder typeUseDecoder = objectDecoder.getList(Key.TYPE_USES); 152 ListDecoder typeUseDecoder = objectDecoder.getList(Key.TYPE_USES);
159 List<TypeUse> typeUses = <TypeUse>[]; 153 List<TypeUse> typeUses = <TypeUse>[];
160 for (int index = 0; index < typeUseDecoder.length; index++) { 154 for (int index = 0; index < typeUseDecoder.length; index++) {
161 ObjectDecoder object = typeUseDecoder.getObject(index); 155 ObjectDecoder object = typeUseDecoder.getObject(index);
162 TypeUseKind kind = object.getEnum(Key.KIND, TypeUseKind.values); 156 TypeUseKind kind = object.getEnum(Key.KIND, TypeUseKind.values);
163 DartType type = object.getType(Key.TYPE); 157 DartType type = object.getType(Key.TYPE);
164 typeUses.add(new TypeUse.internal(type, kind)); 158 typeUses.add(new TypeUse.internal(type, kind));
165 } 159 }
(...skipping 10 matching lines...) Expand all
176 ListDecoder listLiteralDecoder = 170 ListDecoder listLiteralDecoder =
177 objectDecoder.getList(Key.LISTS, isOptional: true); 171 objectDecoder.getList(Key.LISTS, isOptional: true);
178 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[]; 172 List<ListLiteralUse> listLiterals = const <ListLiteralUse>[];
179 if (listLiteralDecoder != null) { 173 if (listLiteralDecoder != null) {
180 listLiterals = <ListLiteralUse>[]; 174 listLiterals = <ListLiteralUse>[];
181 for (int i = 0; i < listLiteralDecoder.length; i++) { 175 for (int i = 0; i < listLiteralDecoder.length; i++) {
182 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i); 176 ObjectDecoder useDecoder = listLiteralDecoder.getObject(i);
183 DartType type = useDecoder.getType(Key.TYPE); 177 DartType type = useDecoder.getType(Key.TYPE);
184 bool isConstant = useDecoder.getBool(Key.IS_CONST); 178 bool isConstant = useDecoder.getBool(Key.IS_CONST);
185 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); 179 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY);
186 listLiterals.add(new ListLiteralUse( 180 listLiterals.add(
187 type, isConstant: isConstant, isEmpty: isEmpty)); 181 new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty));
188 } 182 }
189 } 183 }
190 184
191 ListDecoder mapLiteralDecoder = 185 ListDecoder mapLiteralDecoder =
192 objectDecoder.getList(Key.MAPS, isOptional: true); 186 objectDecoder.getList(Key.MAPS, isOptional: true);
193 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[]; 187 List<MapLiteralUse> mapLiterals = const <MapLiteralUse>[];
194 if (mapLiteralDecoder != null) { 188 if (mapLiteralDecoder != null) {
195 mapLiterals = <MapLiteralUse>[]; 189 mapLiterals = <MapLiteralUse>[];
196 for (int i = 0; i < mapLiteralDecoder.length; i++) { 190 for (int i = 0; i < mapLiteralDecoder.length; i++) {
197 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i); 191 ObjectDecoder useDecoder = mapLiteralDecoder.getObject(i);
198 DartType type = useDecoder.getType(Key.TYPE); 192 DartType type = useDecoder.getType(Key.TYPE);
199 bool isConstant = useDecoder.getBool(Key.IS_CONST); 193 bool isConstant = useDecoder.getBool(Key.IS_CONST);
200 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY); 194 bool isEmpty = useDecoder.getBool(Key.IS_EMPTY);
201 mapLiterals.add(new MapLiteralUse( 195 mapLiterals.add(
202 type, isConstant: isConstant, isEmpty: isEmpty)); 196 new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty));
203 } 197 }
204 } 198 }
205 199
206 return new DeserializedResolutionImpact( 200 return new DeserializedResolutionImpact(
207 constSymbolNames: constSymbolNames, 201 constSymbolNames: constSymbolNames,
208 constantLiterals: constantLiterals, 202 constantLiterals: constantLiterals,
209 dynamicUses: dynamicUses, 203 dynamicUses: dynamicUses,
210 features: features, 204 features: features,
211 listLiterals: listLiterals, 205 listLiterals: listLiterals,
212 mapLiterals: mapLiterals, 206 mapLiterals: mapLiterals,
213 staticUses: staticUses, 207 staticUses: staticUses,
214 typeUses: typeUses); 208 typeUses: typeUses);
215 } 209 }
216 } 210 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/equivalence.dart ('k') | pkg/compiler/lib/src/serialization/json_serializer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698