| 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'; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 @override | 422 @override |
| 423 void visitParameterElement(ParameterElement element1, | 423 void visitParameterElement(ParameterElement element1, |
| 424 ParameterElement element2) { | 424 ParameterElement element2) { |
| 425 check(element1, element2, | 425 check(element1, element2, |
| 426 'name', | 426 'name', |
| 427 element1.name, element2.name); | 427 element1.name, element2.name); |
| 428 visit(element1.functionDeclaration, element2.functionDeclaration); | 428 visit(element1.functionDeclaration, element2.functionDeclaration); |
| 429 } | 429 } |
| 430 |
| 431 @override |
| 432 void visitImportElement(ImportElement element1, ImportElement element2) { |
| 433 visit(element1.importedLibrary, element2.importedLibrary); |
| 434 visit(element1.library, element2.library); |
| 435 } |
| 436 |
| 437 @override |
| 438 void visitExportElement(ExportElement element1, ExportElement element2) { |
| 439 visit(element1.exportedLibrary, element2.exportedLibrary); |
| 440 visit(element1.library, element2.library); |
| 441 } |
| 442 |
| 443 @override |
| 444 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { |
| 445 check(element1, element2, |
| 446 'name', |
| 447 element1.name, element2.name); |
| 448 visit(element1.library, element2.library); |
| 449 } |
| 430 } | 450 } |
| 431 | 451 |
| 432 /// Visitor that checks for equivalence of [Element] properties. | 452 /// Visitor that checks for equivalence of [Element] properties. |
| 433 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> { | 453 class ElementPropertyEquivalence extends BaseElementVisitor<dynamic, Element> { |
| 434 const ElementPropertyEquivalence(); | 454 const ElementPropertyEquivalence(); |
| 435 | 455 |
| 436 void visit(Element element1, Element element2) { | 456 void visit(Element element1, Element element2) { |
| 437 if (element1 == element2) return; | 457 if (element1 == element2) return; |
| 438 check(element1, element2, 'kind', element1.kind, element2.kind); | 458 check(element1, element2, 'kind', element1.kind, element2.kind); |
| 439 element1.accept(this, element2); | 459 element1.accept(this, element2); |
| 440 } | 460 } |
| 441 | 461 |
| 442 @override | 462 @override |
| 443 void visitElement(Element e, Element arg) { | 463 void visitElement(Element e, Element arg) { |
| 444 throw new UnsupportedError("Unsupported element $e"); | 464 throw new UnsupportedError("Unsupported element $e"); |
| 445 } | 465 } |
| 446 | 466 |
| 447 @override | 467 @override |
| 448 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { | 468 void visitLibraryElement(LibraryElement element1, LibraryElement element2) { |
| 449 checkElementIdentities(null, null, null, element1, element2); | 469 checkElementIdentities(null, null, null, element1, element2); |
| 450 check(element1, element2, 'name', element1.name, element2.name); | 470 check(element1, element2, 'name', element1.name, element2.name); |
| 451 check(element1, element2, 'getLibraryName', | 471 check(element1, element2, 'getLibraryName', |
| 452 element1.getLibraryName(), element2.getLibraryName()); | 472 element1.libraryName, element2.libraryName); |
| 453 visitMembers(element1, element2); | 473 visitMembers(element1, element2); |
| 454 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); | 474 visit(element1.entryCompilationUnit, element2.entryCompilationUnit); |
| 455 checkElementLists( | 475 checkElementLists( |
| 456 element1, element2, 'compilationUnits', | 476 element1, element2, 'compilationUnits', |
| 457 element1.compilationUnits.toList(), | 477 element1.compilationUnits.toList(), |
| 458 element2.compilationUnits.toList()); | 478 element2.compilationUnits.toList()); |
| 459 | 479 |
| 460 bool filterTags(LibraryTag tag) => tag.asLibraryDependency() != null; | 480 checkElementListIdentities( |
| 461 | 481 element1, element2, 'imports', element1.imports, element2.imports); |
| 462 List<LibraryTag> tags1 = element1.tags.where(filterTags).toList(); | 482 checkElementListIdentities( |
| 463 List<LibraryTag> tags2 = element2.tags.where(filterTags).toList(); | 483 element1, element2, 'exports', element1.exports, element2.exports); |
| 464 checkListEquivalence(element1, element2, 'tags', tags1, tags2, | |
| 465 (Object object1, Object object2, String property, | |
| 466 LibraryDependency tag1, LibraryDependency tag2) { | |
| 467 checkElementIdentities( | |
| 468 tag1, tag2, 'getLibraryFromTag', | |
| 469 element1.getLibraryFromTag(tag1), | |
| 470 element2.getLibraryFromTag(tag2)); | |
| 471 }); | |
| 472 | 484 |
| 473 List<Element> imports1 = <Element>[]; | 485 List<Element> imports1 = <Element>[]; |
| 474 List<Element> imports2 = <Element>[]; | 486 List<Element> imports2 = <Element>[]; |
| 475 element1.forEachImport((Element import) { | 487 element1.forEachImport((Element import) { |
| 476 if (import.isAmbiguous) return; | 488 if (import.isAmbiguous) return; |
| 477 imports1.add(import); | 489 imports1.add(import); |
| 478 }); | 490 }); |
| 479 element2.forEachImport((Element import) { | 491 element2.forEachImport((Element import) { |
| 480 if (import.isAmbiguous) return; | 492 if (import.isAmbiguous) return; |
| 481 imports2.add(import); | 493 imports2.add(import); |
| 482 }); | 494 }); |
| 483 checkElementListIdentities( | 495 checkElementListIdentities( |
| 484 element1, element2, 'imports', imports1, imports2); | 496 element1, element2, 'importScope', imports1, imports2); |
| 485 | 497 |
| 486 List<Element> exports1 = <Element>[]; | 498 List<Element> exports1 = <Element>[]; |
| 487 List<Element> exports2 = <Element>[]; | 499 List<Element> exports2 = <Element>[]; |
| 488 element1.forEachExport((Element export) { | 500 element1.forEachExport((Element export) { |
| 489 if (export.isAmbiguous) return; | 501 if (export.isAmbiguous) return; |
| 490 exports1.add(export); | 502 exports1.add(export); |
| 491 }); | 503 }); |
| 492 element2.forEachExport((Element export) { | 504 element2.forEachExport((Element export) { |
| 493 if (export.isAmbiguous) return; | 505 if (export.isAmbiguous) return; |
| 494 exports2.add(export); | 506 exports2.add(export); |
| 495 }); | 507 }); |
| 496 checkElementListIdentities( | 508 checkElementListIdentities( |
| 497 element1, element2, 'exports', exports1, exports2); | 509 element1, element2, 'exportScope', exports1, exports2); |
| 498 } | 510 } |
| 499 | 511 |
| 500 @override | 512 @override |
| 501 void visitCompilationUnitElement(CompilationUnitElement element1, | 513 void visitCompilationUnitElement(CompilationUnitElement element1, |
| 502 CompilationUnitElement element2) { | 514 CompilationUnitElement element2) { |
| 503 check(element1, element2, | 515 check(element1, element2, |
| 504 'name', | 516 'name', |
| 505 element1.name, element2.name); | 517 element1.name, element2.name); |
| 506 checkElementIdentities( | 518 checkElementIdentities( |
| 507 element1, element2, 'library', | 519 element1, element2, 'library', |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 } | 784 } |
| 773 | 785 |
| 774 @override | 786 @override |
| 775 void visitFieldParameterElement(InitializingFormalElement element1, | 787 void visitFieldParameterElement(InitializingFormalElement element1, |
| 776 InitializingFormalElement element2) { | 788 InitializingFormalElement element2) { |
| 777 visitParameterElement(element1, element2); | 789 visitParameterElement(element1, element2); |
| 778 checkElementIdentities( | 790 checkElementIdentities( |
| 779 element1, element2, 'fieldElement', | 791 element1, element2, 'fieldElement', |
| 780 element1.fieldElement, element2.fieldElement); | 792 element1.fieldElement, element2.fieldElement); |
| 781 } | 793 } |
| 794 |
| 795 @override |
| 796 void visitImportElement(ImportElement element1, ImportElement element2) { |
| 797 check(element1, element2, 'uri', element1.uri, element2.uri); |
| 798 check( |
| 799 element1, element2, 'isDeferred', |
| 800 element1.isDeferred, element2.isDeferred); |
| 801 checkElementProperties( |
| 802 element1, element2, 'prefix', |
| 803 element1.prefix, element2.prefix); |
| 804 checkElementIdentities( |
| 805 element1, element2, 'importedLibrary', |
| 806 element1.importedLibrary, element2.importedLibrary); |
| 807 } |
| 808 |
| 809 @override |
| 810 void visitExportElement(ExportElement element1, ExportElement element2) { |
| 811 check(element1, element2, 'uri', element1.uri, element2.uri); |
| 812 checkElementIdentities( |
| 813 element1, element2, 'importedLibrary', |
| 814 element1.exportedLibrary, element2.exportedLibrary); |
| 815 } |
| 816 |
| 817 @override |
| 818 void visitPrefixElement(PrefixElement element1, PrefixElement element2) { |
| 819 check( |
| 820 element1, element2, 'isDeferred', |
| 821 element1.isDeferred, element2.isDeferred); |
| 822 checkElementIdentities( |
| 823 element1, element2, 'importedLibrary', |
| 824 element1.deferredImport, element2.deferredImport); |
| 825 // TODO(johnniwinther): Check members. |
| 826 } |
| 782 } | 827 } |
| 783 | 828 |
| 784 /// Visitor that checks for equivalence of [DartType]s. | 829 /// Visitor that checks for equivalence of [DartType]s. |
| 785 class TypeEquivalence implements DartTypeVisitor<dynamic, DartType> { | 830 class TypeEquivalence implements DartTypeVisitor<dynamic, DartType> { |
| 786 const TypeEquivalence(); | 831 const TypeEquivalence(); |
| 787 | 832 |
| 788 void visit(DartType type1, DartType type2) { | 833 void visit(DartType type1, DartType type2) { |
| 789 check(type1, type2, 'kind', type1.kind, type2.kind); | 834 check(type1, type2, 'kind', type1.kind, type2.kind); |
| 790 type1.accept(this, type2); | 835 type1.accept(this, type2); |
| 791 } | 836 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 exp1, exp2, 'expression', | 1088 exp1, exp2, 'expression', |
| 1044 exp1.expression, exp2.expression); | 1089 exp1.expression, exp2.expression); |
| 1045 } | 1090 } |
| 1046 | 1091 |
| 1047 @override | 1092 @override |
| 1048 visitDeferred(DeferredConstantExpression exp1, | 1093 visitDeferred(DeferredConstantExpression exp1, |
| 1049 DeferredConstantExpression exp2) { | 1094 DeferredConstantExpression exp2) { |
| 1050 // TODO: implement visitDeferred | 1095 // TODO: implement visitDeferred |
| 1051 } | 1096 } |
| 1052 } | 1097 } |
| OLD | NEW |