OLD | NEW |
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_model_test; | 5 library dart2js.serialization_model_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'package:compiler/src/closure.dart'; | 10 import 'package:compiler/src/closure.dart'; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 }); | 153 }); |
154 } | 154 } |
155 | 155 |
156 void checkElements( | 156 void checkElements( |
157 Compiler compiler1, Compiler compiler2, Element element1, Element element2, | 157 Compiler compiler1, Compiler compiler2, Element element1, Element element2, |
158 {bool verbose: false}) { | 158 {bool verbose: false}) { |
159 if (element1.isAbstract) return; | 159 if (element1.isAbstract) return; |
160 if (element1.isFunction || | 160 if (element1.isFunction || |
161 element1.isConstructor || | 161 element1.isConstructor || |
162 (element1.isField && element1.isInstanceMember)) { | 162 (element1.isField && element1.isInstanceMember)) { |
163 ClosureClassMap closureData1 = | 163 ClosureRepresentationInfo closureData1 = |
164 compiler1.closureToClassMapper.getClosureToClassMapping(element1); | 164 compiler1.closureToClassMapper.getClosureRepresentationInfo(element1); |
165 ClosureClassMap closureData2 = | 165 ClosureRepresentationInfo closureData2 = |
166 compiler2.closureToClassMapper.getClosureToClassMapping(element2); | 166 compiler2.closureToClassMapper.getClosureRepresentationInfo(element2); |
167 | 167 |
168 checkElementIdentities( | 168 checkElementIdentities( |
169 closureData1, | 169 closureData1, |
170 closureData2, | 170 closureData2, |
171 '$element1.closureElement', | 171 '$element1.closureEntity', |
172 closureData1.closureElement, | 172 closureData1.closureEntity, |
173 closureData2.closureElement); | 173 closureData2.closureEntity); |
174 checkElementIdentities( | 174 checkElementIdentities( |
175 closureData1, | 175 closureData1, |
176 closureData2, | 176 closureData2, |
177 '$element1.closureClassElement', | 177 '$element1.closureClassEntity', |
178 closureData1.closureClassElement, | 178 closureData1.closureClassEntity, |
179 closureData2.closureClassElement); | 179 closureData2.closureClassEntity); |
180 checkElementIdentities(closureData1, closureData2, '$element1.callElement', | 180 checkElementIdentities(closureData1, closureData2, '$element1.callMethod', |
181 closureData1.callElement, closureData2.callElement); | 181 closureData1.callMethod, closureData2.callMethod); |
182 check(closureData1, closureData2, '$element1.thisLocal', | 182 check(closureData1, closureData2, '$element1.thisLocal', |
183 closureData1.thisLocal, closureData2.thisLocal, areLocalsEquivalent); | 183 closureData1.thisLocal, closureData2.thisLocal, areLocalsEquivalent); |
184 checkMaps( | 184 checkElementListIdentities( |
185 closureData1.freeVariableMap, | 185 closureData1, |
186 closureData2.freeVariableMap, | 186 closureData2, |
187 "$element1.freeVariableMap", | 187 "$element1.createdFieldEntities", |
188 areLocalsEquivalent, | 188 closureData1.createdFieldEntities, |
189 areCapturedVariablesEquivalent, | 189 closureData2.createdFieldEntities); |
190 verbose: verbose); | 190 check( |
191 checkMaps( | 191 closureData1, |
192 closureData1.capturingScopes, | 192 closureData2, |
193 closureData2.capturingScopes, | 193 '$element1.thisFieldEntity', |
194 "$element1.capturingScopes", | 194 closureData1.thisFieldEntity, |
195 areNodesEquivalent, | 195 closureData2.thisFieldEntity, |
196 areClosureScopesEquivalent, | 196 areLocalsEquivalent); |
197 verbose: verbose, | |
198 keyToString: nodeToString); | |
199 checkSets( | |
200 closureData1.variablesUsedInTryOrGenerator, | |
201 closureData2.variablesUsedInTryOrGenerator, | |
202 "$element1.variablesUsedInTryOrGenerator", | |
203 areLocalsEquivalent, | |
204 verbose: verbose); | |
205 if (element1 is MemberElement && element2 is MemberElement) { | 197 if (element1 is MemberElement && element2 is MemberElement) { |
206 MemberElement member1 = element1.implementation; | 198 MemberElement member1 = element1.implementation; |
207 MemberElement member2 = element2.implementation; | 199 MemberElement member2 = element2.implementation; |
208 checkSets(member1.nestedClosures, member2.nestedClosures, | 200 checkSets(member1.nestedClosures, member2.nestedClosures, |
209 "$member1.nestedClosures", areElementsEquivalent, verbose: verbose, | 201 "$member1.nestedClosures", areElementsEquivalent, verbose: verbose, |
210 onSameElement: (a, b) { | 202 onSameElement: (a, b) { |
211 LocalFunctionElement localFunction1 = a.expression; | 203 LocalFunctionElement localFunction1 = a.expression; |
212 LocalFunctionElement localFunction2 = b.expression; | 204 LocalFunctionElement localFunction2 = b.expression; |
213 checkElementIdentities(localFunction1, localFunction2, 'enclosingClass', | 205 checkElementIdentities(localFunction1, localFunction2, 'enclosingClass', |
214 localFunction1.enclosingClass, localFunction2.enclosingClass); | 206 localFunction1.enclosingClass, localFunction2.enclosingClass); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 check(outputUnit1, outputUnit2, 'OutputUnit.isMainOutput $message', | 286 check(outputUnit1, outputUnit2, 'OutputUnit.isMainOutput $message', |
295 outputUnit1.isMainOutput, outputUnit2.isMainOutput); | 287 outputUnit1.isMainOutput, outputUnit2.isMainOutput); |
296 checkSetEquivalence( | 288 checkSetEquivalence( |
297 outputUnit1, | 289 outputUnit1, |
298 outputUnit2, | 290 outputUnit2, |
299 'OutputUnit.imports $message', | 291 'OutputUnit.imports $message', |
300 outputUnit1.imports, | 292 outputUnit1.imports, |
301 outputUnit2.imports, | 293 outputUnit2.imports, |
302 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); | 294 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); |
303 } | 295 } |
OLD | NEW |