| 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_test; | 5 library dart2js.serialization_test; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'memory_compiler.dart'; | 8 import 'memory_compiler.dart'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:compiler/src/constants/constructors.dart'; | 10 import 'package:compiler/src/constants/constructors.dart'; |
| 11 import 'package:compiler/src/constants/expressions.dart'; | 11 import 'package:compiler/src/constants/expressions.dart'; |
| 12 import 'package:compiler/src/dart_types.dart'; | 12 import 'package:compiler/src/dart_types.dart'; |
| 13 import 'package:compiler/src/compiler.dart'; | 13 import 'package:compiler/src/compiler.dart'; |
| 14 import 'package:compiler/src/diagnostics/invariant.dart'; | 14 import 'package:compiler/src/diagnostics/invariant.dart'; |
| 15 import 'package:compiler/src/elements/elements.dart'; | 15 import 'package:compiler/src/elements/elements.dart'; |
| 16 import 'package:compiler/src/elements/visitor.dart'; | 16 import 'package:compiler/src/elements/visitor.dart'; |
| 17 import 'package:compiler/src/ordered_typeset.dart'; | 17 import 'package:compiler/src/ordered_typeset.dart'; |
| 18 import 'package:compiler/src/serialization/element_serialization.dart'; |
| 19 import 'package:compiler/src/serialization/json_serializer.dart'; |
| 18 import 'package:compiler/src/serialization/serialization.dart'; | 20 import 'package:compiler/src/serialization/serialization.dart'; |
| 19 import 'package:compiler/src/serialization/json_serializer.dart'; | |
| 20 import 'package:compiler/src/tree/tree.dart'; | |
| 21 | 21 |
| 22 main(List<String> arguments) { | 22 main(List<String> arguments) { |
| 23 // Ensure that we can print out constant expressions. | 23 // Ensure that we can print out constant expressions. |
| 24 DEBUG_MODE = true; | 24 DEBUG_MODE = true; |
| 25 | 25 |
| 26 Uri entryPoint; | 26 Uri entryPoint; |
| 27 String outPath; | 27 String outPath; |
| 28 bool prettyPrint = false; | 28 bool prettyPrint = false; |
| 29 for (String arg in arguments) { | 29 for (String arg in arguments) { |
| 30 if (arg.startsWith('--')) { | 30 if (arg.startsWith('--')) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } | 465 } |
| 466 | 466 |
| 467 @override | 467 @override |
| 468 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { | 468 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { |
| 469 checkElementIdentities(null, null, null, element1, element2); | 469 checkElementIdentities(null, null, null, element1, element2); |
| 470 check(element1, element2, 'name', element1.name, element2.name); | 470 check(element1, element2, 'name', element1.name, element2.name); |
| 471 check(element1, element2, 'libraryName', | 471 check(element1, element2, 'libraryName', |
| 472 element1.libraryName, element2.libraryName); | 472 element1.libraryName, element2.libraryName); |
| 473 visitMembers(element1, element2); | 473 visitMembers(element1, element2); |
| 474 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); | 474 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); |
| 475 |
| 475 checkElementLists( | 476 checkElementLists( |
| 476 element1, element2, 'compilationUnits', | 477 element1, element2, 'compilationUnits', |
| 477 element1.compilationUnits.toList(), | 478 LibrarySerializer.getCompilationUnits(element1), |
| 478 element2.compilationUnits.toList()); | 479 LibrarySerializer.getCompilationUnits(element2)); |
| 479 | 480 |
| 480 checkElementListIdentities( | 481 checkElementListIdentities( |
| 481 element1, element2, 'imports', element1.imports, element2.imports); | 482 element1, element2, 'imports', |
| 483 LibrarySerializer.getImports(element1), |
| 484 LibrarySerializer.getImports(element2)); |
| 482 checkElementListIdentities( | 485 checkElementListIdentities( |
| 483 element1, element2, 'exports', element1.exports, element2.exports); | 486 element1, element2, 'exports', element1.exports, element2.exports); |
| 484 | 487 |
| 485 List<Element> imports1 = <Element>[]; | |
| 486 List<Element> imports2 = <Element>[]; | |
| 487 element1.forEachImport((Element import) { | |
| 488 if (import.isAmbiguous) return; | |
| 489 imports1.add(import); | |
| 490 }); | |
| 491 element2.forEachImport((Element import) { | |
| 492 if (import.isAmbiguous) return; | |
| 493 imports2.add(import); | |
| 494 }); | |
| 495 checkElementListIdentities( | 488 checkElementListIdentities( |
| 496 element1, element2, 'importScope', imports1, imports2); | 489 element1, element2, 'importScope', |
| 490 LibrarySerializer.getImportedElements(element1), |
| 491 LibrarySerializer.getImportedElements(element2)); |
| 497 | 492 |
| 498 List<Element> exports1 = <Element>[]; | |
| 499 List<Element> exports2 = <Element>[]; | |
| 500 element1.forEachExport((Element export) { | |
| 501 if (export.isAmbiguous) return; | |
| 502 exports1.add(export); | |
| 503 }); | |
| 504 element2.forEachExport((Element export) { | |
| 505 if (export.isAmbiguous) return; | |
| 506 exports2.add(export); | |
| 507 }); | |
| 508 checkElementListIdentities( | 493 checkElementListIdentities( |
| 509 element1, element2, 'exportScope', exports1, exports2); | 494 element1, element2, 'exportScope', |
| 495 LibrarySerializer.getExportedElements(element1), |
| 496 LibrarySerializer.getExportedElements(element2)); |
| 510 } | 497 } |
| 511 | 498 |
| 512 @override | 499 @override |
| 513 void visitCompilationUnitElement(CompilationUnitElement element1, | 500 void visitCompilationUnitElement(CompilationUnitElement element1, |
| 514 CompilationUnitElement element2) { | 501 CompilationUnitElement element2) { |
| 515 check(element1, element2, | 502 check(element1, element2, |
| 516 'name', | 503 'name', |
| 517 element1.name, element2.name); | 504 element1.name, element2.name); |
| 518 checkElementIdentities( | 505 checkElementIdentities( |
| 519 element1, element2, 'library', | 506 element1, element2, 'library', |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 element1.library, element2.library); | 556 element1.library, element2.library); |
| 570 checkElementIdentities( | 557 checkElementIdentities( |
| 571 element1, element2, 'compilationUnit', | 558 element1, element2, 'compilationUnit', |
| 572 element1.compilationUnit, element2.compilationUnit); | 559 element1.compilationUnit, element2.compilationUnit); |
| 573 check(element1, element2, 'isObject', | 560 check(element1, element2, 'isObject', |
| 574 element1.isObject, element2.isObject); | 561 element1.isObject, element2.isObject); |
| 575 checkTypeLists(element1, element2, 'typeVariables', | 562 checkTypeLists(element1, element2, 'typeVariables', |
| 576 element1.typeVariables, element2.typeVariables); | 563 element1.typeVariables, element2.typeVariables); |
| 577 check(element1, element2, 'isAbstract', | 564 check(element1, element2, 'isAbstract', |
| 578 element1.isAbstract, element2.isAbstract); | 565 element1.isAbstract, element2.isAbstract); |
| 566 check(element1, element2, 'isUnnamedMixinApplication', |
| 567 element1.isUnnamedMixinApplication, element2.isUnnamedMixinApplication); |
| 568 check(element1, element2, 'isEnumClass', |
| 569 element1.isEnumClass, element2.isEnumClass); |
| 570 if (element1.isEnumClass) { |
| 571 EnumClassElement enum1 = element1; |
| 572 EnumClassElement enum2 = element2; |
| 573 checkElementLists(enum1, enum2, 'enumValues', |
| 574 enum1.enumValues, enum2.enumValues); |
| 575 } |
| 579 if (!element1.isObject) { | 576 if (!element1.isObject) { |
| 580 checkTypes(element1, element2, 'supertype', | 577 checkTypes(element1, element2, 'supertype', |
| 581 element1.supertype, element2.supertype); | 578 element1.supertype, element2.supertype); |
| 582 } | 579 } |
| 583 check(element1, element2, 'hierarchyDepth', | 580 check(element1, element2, 'hierarchyDepth', |
| 584 element1.hierarchyDepth, element2.hierarchyDepth); | 581 element1.hierarchyDepth, element2.hierarchyDepth); |
| 585 checkTypeLists( | 582 checkTypeLists( |
| 586 element1, element2, 'allSupertypes', | 583 element1, element2, 'allSupertypes', |
| 587 element1.allSupertypes.toList(), | 584 element1.allSupertypes.toList(), |
| 588 element2.allSupertypes.toList()); | 585 element2.allSupertypes.toList()); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 exp1, exp2, 'expression', | 1085 exp1, exp2, 'expression', |
| 1089 exp1.expression, exp2.expression); | 1086 exp1.expression, exp2.expression); |
| 1090 } | 1087 } |
| 1091 | 1088 |
| 1092 @override | 1089 @override |
| 1093 visitDeferred(DeferredConstantExpression exp1, | 1090 visitDeferred(DeferredConstantExpression exp1, |
| 1094 DeferredConstantExpression exp2) { | 1091 DeferredConstantExpression exp2) { |
| 1095 // TODO: implement visitDeferred | 1092 // TODO: implement visitDeferred |
| 1096 } | 1093 } |
| 1097 } | 1094 } |
| OLD | NEW |