| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.kernel.world_builder; | 5 library dart2js.kernel.world_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/resolution.dart'; | 10 import '../common/resolution.dart'; |
| 11 import '../compile_time_constants.dart'; | 11 import '../compile_time_constants.dart'; |
| 12 import '../constants/constant_system.dart'; | 12 import '../constants/constant_system.dart'; |
| 13 import '../constants/constructors.dart'; | 13 import '../constants/constructors.dart'; |
| 14 import '../constants/evaluation.dart'; | 14 import '../constants/evaluation.dart'; |
| 15 import '../constants/expressions.dart'; | 15 import '../constants/expressions.dart'; |
| 16 import '../constants/values.dart'; | 16 import '../constants/values.dart'; |
| 17 import '../common_elements.dart'; | 17 import '../common_elements.dart'; |
| 18 import '../elements/elements.dart'; | 18 import '../elements/elements.dart'; |
| 19 import '../elements/entities.dart'; | 19 import '../elements/entities.dart'; |
| 20 import '../elements/types.dart'; | 20 import '../elements/types.dart'; |
| 21 import '../js_backend/constant_system_javascript.dart'; | 21 import '../js_backend/constant_system_javascript.dart'; |
| 22 import '../js_backend/native_data.dart' show NativeData; | 22 import '../js_backend/native_data.dart'; |
| 23 import '../js_backend/no_such_method_registry.dart'; | 23 import '../js_backend/no_such_method_registry.dart'; |
| 24 import '../native/native.dart' as native; | 24 import '../native/native.dart' as native; |
| 25 import '../native/resolver.dart'; | 25 import '../native/resolver.dart'; |
| 26 import '../ssa/kernel_impact.dart'; | 26 import '../ssa/kernel_impact.dart'; |
| 27 import '../universe/call_structure.dart'; | 27 import '../universe/call_structure.dart'; |
| 28 import 'element_adapter.dart'; | 28 import 'element_adapter.dart'; |
| 29 import 'elements.dart'; | 29 import 'elements.dart'; |
| 30 | 30 |
| 31 part 'native_basic_data.dart'; |
| 31 part 'native_class_resolver.dart'; | 32 part 'native_class_resolver.dart'; |
| 32 part 'no_such_method_resolver.dart'; | 33 part 'no_such_method_resolver.dart'; |
| 33 | 34 |
| 34 /// World builder used for creating elements and types corresponding to Kernel | 35 /// World builder used for creating elements and types corresponding to Kernel |
| 35 /// IR nodes. | 36 /// IR nodes. |
| 36 // TODO(johnniwinther): Implement [ResolutionWorldBuilder]. | 37 // TODO(johnniwinther): Implement [ResolutionWorldBuilder]. |
| 37 class KernelWorldBuilder extends KernelElementAdapterMixin { | 38 class KernelWorldBuilder extends KernelElementAdapterMixin { |
| 38 CommonElements _commonElements; | 39 CommonElements _commonElements; |
| 39 native.BehaviorBuilder _nativeBehaviorBuilder; | 40 native.BehaviorBuilder _nativeBehaviorBuilder; |
| 40 final DiagnosticReporter reporter; | 41 final DiagnosticReporter reporter; |
| 41 ElementEnvironment _elementEnvironment; | 42 ElementEnvironment _elementEnvironment; |
| 42 DartTypeConverter _typeConverter; | 43 DartTypeConverter _typeConverter; |
| 44 KernelConstantEnvironment _constantEnvironment; |
| 43 | 45 |
| 44 /// Library environment. Used for fast lookup. | 46 /// Library environment. Used for fast lookup. |
| 45 KEnv _env; | 47 KEnv _env; |
| 46 | 48 |
| 47 /// List of library environments by `KLibrary.libraryIndex`. This is used for | 49 /// List of library environments by `KLibrary.libraryIndex`. This is used for |
| 48 /// fast lookup into library classes and members. | 50 /// fast lookup into library classes and members. |
| 49 List<KLibraryEnv> _libraryEnvs = <KLibraryEnv>[]; | 51 List<KLibraryEnv> _libraryEnvs = <KLibraryEnv>[]; |
| 50 | 52 |
| 51 /// List of class environments by `KClass.classIndex`. This is used for | 53 /// List of class environments by `KClass.classIndex`. This is used for |
| 52 /// fast lookup into class members. | 54 /// fast lookup into class members. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 Map<KField, ConstantExpression> _fieldConstantMap = | 73 Map<KField, ConstantExpression> _fieldConstantMap = |
| 72 <KField, ConstantExpression>{}; | 74 <KField, ConstantExpression>{}; |
| 73 | 75 |
| 74 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = | 76 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = |
| 75 <ir.TreeNode, KLocalFunction>{}; | 77 <ir.TreeNode, KLocalFunction>{}; |
| 76 | 78 |
| 77 KernelWorldBuilder(this.reporter, ir.Program program) | 79 KernelWorldBuilder(this.reporter, ir.Program program) |
| 78 : _env = new KEnv(program) { | 80 : _env = new KEnv(program) { |
| 79 _elementEnvironment = new KernelElementEnvironment(this); | 81 _elementEnvironment = new KernelElementEnvironment(this); |
| 80 _commonElements = new CommonElements(_elementEnvironment); | 82 _commonElements = new CommonElements(_elementEnvironment); |
| 81 ConstantEnvironment constants = new KernelConstantEnvironment(this); | 83 _constantEnvironment = new KernelConstantEnvironment(this); |
| 82 _nativeBehaviorBuilder = | 84 _nativeBehaviorBuilder = |
| 83 new KernelBehaviorBuilder(_commonElements, constants); | 85 new KernelBehaviorBuilder(_commonElements, _constantEnvironment); |
| 84 _typeConverter = new DartTypeConverter(this); | 86 _typeConverter = new DartTypeConverter(this); |
| 85 } | 87 } |
| 86 | 88 |
| 87 KMethod get _mainFunction { | 89 KMethod get _mainFunction { |
| 88 return _env.program.mainMethod != null | 90 return _env.program.mainMethod != null |
| 89 ? _getMethod(_env.program.mainMethod) | 91 ? _getMethod(_env.program.mainMethod) |
| 90 : null; | 92 : null; |
| 91 } | 93 } |
| 92 | 94 |
| 93 KLibrary get _mainLibrary { | 95 KLibrary get _mainLibrary { |
| 94 return _env.program.mainMethod != null | 96 return _env.program.mainMethod != null |
| 95 ? _getLibrary(_env.program.mainMethod.enclosingLibrary) | 97 ? _getLibrary(_env.program.mainMethod.enclosingLibrary) |
| 96 : null; | 98 : null; |
| 97 } | 99 } |
| 98 | 100 |
| 101 Iterable<LibraryEntity> get _libraries { |
| 102 if (_env.length != _libraryMap.length) { |
| 103 // Create a [KLibrary] for each library. |
| 104 _env.forEachLibrary((KLibraryEnv env) { |
| 105 _getLibrary(env.library, env); |
| 106 }); |
| 107 } |
| 108 return _libraryMap.values; |
| 109 } |
| 110 |
| 99 @override | 111 @override |
| 100 CommonElements get commonElements => _commonElements; | 112 CommonElements get commonElements => _commonElements; |
| 101 | 113 |
| 102 @override | 114 @override |
| 103 ElementEnvironment get elementEnvironment => _elementEnvironment; | 115 ElementEnvironment get elementEnvironment => _elementEnvironment; |
| 104 | 116 |
| 117 ConstantEnvironment get constantEnvironment => _constantEnvironment; |
| 118 |
| 105 @override | 119 @override |
| 106 native.BehaviorBuilder get nativeBehaviorBuilder => _nativeBehaviorBuilder; | 120 native.BehaviorBuilder get nativeBehaviorBuilder => _nativeBehaviorBuilder; |
| 107 | 121 |
| 108 LibraryEntity lookupLibrary(Uri uri) { | 122 LibraryEntity lookupLibrary(Uri uri) { |
| 109 KLibraryEnv libraryEnv = _env.lookupLibrary(uri); | 123 KLibraryEnv libraryEnv = _env.lookupLibrary(uri); |
| 110 return _getLibrary(libraryEnv.library, libraryEnv); | 124 return _getLibrary(libraryEnv.library, libraryEnv); |
| 111 } | 125 } |
| 112 | 126 |
| 113 KLibrary _getLibrary(ir.Library node, [KLibraryEnv libraryEnv]) { | 127 KLibrary _getLibrary(ir.Library node, [KLibraryEnv libraryEnv]) { |
| 114 return _libraryMap.putIfAbsent(node, () { | 128 return _libraryMap.putIfAbsent(node, () { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 133 | 147 |
| 134 ClassEntity lookupClass(KLibrary library, String name) { | 148 ClassEntity lookupClass(KLibrary library, String name) { |
| 135 KLibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 149 KLibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
| 136 KClassEnv classEnv = libraryEnv.lookupClass(name); | 150 KClassEnv classEnv = libraryEnv.lookupClass(name); |
| 137 if (classEnv != null) { | 151 if (classEnv != null) { |
| 138 return _getClass(classEnv.cls, classEnv); | 152 return _getClass(classEnv.cls, classEnv); |
| 139 } | 153 } |
| 140 return null; | 154 return null; |
| 141 } | 155 } |
| 142 | 156 |
| 157 void _forEachClass(KLibrary library, void f(ClassEntity cls)) { |
| 158 KLibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
| 159 libraryEnv.forEachClass((KClassEnv classEnv) { |
| 160 f(_getClass(classEnv.cls, classEnv)); |
| 161 }); |
| 162 } |
| 163 |
| 143 MemberEntity lookupClassMember(KClass cls, String name, | 164 MemberEntity lookupClassMember(KClass cls, String name, |
| 144 {bool setter: false}) { | 165 {bool setter: false}) { |
| 145 KClassEnv classEnv = _classEnvs[cls.classIndex]; | 166 KClassEnv classEnv = _classEnvs[cls.classIndex]; |
| 146 ir.Member member = classEnv.lookupMember(name, setter: setter); | 167 ir.Member member = classEnv.lookupMember(name, setter: setter); |
| 147 return member != null ? getMember(member) : null; | 168 return member != null ? getMember(member) : null; |
| 148 } | 169 } |
| 149 | 170 |
| 150 ConstructorEntity lookupConstructor(KClass cls, String name) { | 171 ConstructorEntity lookupConstructor(KClass cls, String name) { |
| 151 KClassEnv classEnv = _classEnvs[cls.classIndex]; | 172 KClassEnv classEnv = _classEnvs[cls.classIndex]; |
| 152 ir.Member member = classEnv.lookupConstructor(name); | 173 ir.Member member = classEnv.lookupConstructor(name); |
| 153 return member != null ? getConstructor(member) : null; | 174 return member != null ? getConstructor(member) : null; |
| 154 } | 175 } |
| 155 | 176 |
| 156 KClass _getClass(ir.Class node, [KClassEnv classEnv]) { | 177 KClass _getClass(ir.Class node, [KClassEnv classEnv]) { |
| 157 return _classMap.putIfAbsent(node, () { | 178 return _classMap.putIfAbsent(node, () { |
| 158 KLibrary library = _getLibrary(node.enclosingLibrary); | 179 KLibrary library = _getLibrary(node.enclosingLibrary); |
| 159 if (classEnv == null) { | 180 if (classEnv == null) { |
| 160 classEnv = _libraryEnvs[library.libraryIndex].lookupClass(node.name); | 181 classEnv = _libraryEnvs[library.libraryIndex].lookupClass(node.name); |
| 161 } | 182 } |
| 162 _classEnvs.add(classEnv); | 183 _classEnvs.add(classEnv); |
| 163 return new KClass(library, _classMap.length, node.name, | 184 return new KClass(library, _classMap.length, node.name, |
| 164 isAbstract: node.isAbstract); | 185 isAbstract: node.isAbstract); |
| 165 }); | 186 }); |
| 166 } | 187 } |
| 167 | 188 |
| 189 Iterable<ConstantExpression> _getClassMetadata(KClass cls) { |
| 190 return _classEnvs[cls.classIndex].getMetadata(this); |
| 191 } |
| 192 |
| 168 KTypeVariable _getTypeVariable(ir.TypeParameter node) { | 193 KTypeVariable _getTypeVariable(ir.TypeParameter node) { |
| 169 return _typeVariableMap.putIfAbsent(node, () { | 194 return _typeVariableMap.putIfAbsent(node, () { |
| 170 if (node.parent is ir.Class) { | 195 if (node.parent is ir.Class) { |
| 171 ir.Class cls = node.parent; | 196 ir.Class cls = node.parent; |
| 172 int index = cls.typeParameters.indexOf(node); | 197 int index = cls.typeParameters.indexOf(node); |
| 173 return new KTypeVariable(_getClass(cls), node.name, index); | 198 return new KTypeVariable(_getClass(cls), node.name, index); |
| 174 } | 199 } |
| 175 if (node.parent is ir.FunctionNode) { | 200 if (node.parent is ir.FunctionNode) { |
| 176 ir.FunctionNode func = node.parent; | 201 ir.FunctionNode func = node.parent; |
| 177 int index = func.typeParameters.indexOf(node); | 202 int index = func.typeParameters.indexOf(node); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 } | 553 } |
| 529 | 554 |
| 530 /// Environment for fast lookup of program libraries. | 555 /// Environment for fast lookup of program libraries. |
| 531 class KEnv { | 556 class KEnv { |
| 532 final ir.Program program; | 557 final ir.Program program; |
| 533 | 558 |
| 534 Map<Uri, KLibraryEnv> _libraryMap; | 559 Map<Uri, KLibraryEnv> _libraryMap; |
| 535 | 560 |
| 536 KEnv(this.program); | 561 KEnv(this.program); |
| 537 | 562 |
| 538 /// Return the [KLibraryEnv] for the library with the canonical [uri]. | 563 void _ensureLibraryMap() { |
| 539 KLibraryEnv lookupLibrary(Uri uri) { | |
| 540 if (_libraryMap == null) { | 564 if (_libraryMap == null) { |
| 541 _libraryMap = <Uri, KLibraryEnv>{}; | 565 _libraryMap = <Uri, KLibraryEnv>{}; |
| 542 for (ir.Library library in program.libraries) { | 566 for (ir.Library library in program.libraries) { |
| 543 _libraryMap[library.importUri] = new KLibraryEnv(library); | 567 _libraryMap[library.importUri] = new KLibraryEnv(library); |
| 544 } | 568 } |
| 545 } | 569 } |
| 570 } |
| 571 |
| 572 /// Return the [KLibraryEnv] for the library with the canonical [uri]. |
| 573 KLibraryEnv lookupLibrary(Uri uri) { |
| 574 _ensureLibraryMap(); |
| 546 return _libraryMap[uri]; | 575 return _libraryMap[uri]; |
| 547 } | 576 } |
| 577 |
| 578 /// Calls [f] for each library in this environment. |
| 579 void forEachLibrary(void f(KLibraryEnv library)) { |
| 580 _ensureLibraryMap(); |
| 581 _libraryMap.values.forEach(f); |
| 582 } |
| 583 |
| 584 /// Returns the number of libraries in this environment. |
| 585 int get length { |
| 586 _ensureLibraryMap(); |
| 587 return _libraryMap.length; |
| 588 } |
| 548 } | 589 } |
| 549 | 590 |
| 550 /// Environment for fast lookup of library classes and members. | 591 /// Environment for fast lookup of library classes and members. |
| 551 // TODO(johnniwinther): Add member lookup. | 592 // TODO(johnniwinther): Add member lookup. |
| 552 class KLibraryEnv { | 593 class KLibraryEnv { |
| 553 final ir.Library library; | 594 final ir.Library library; |
| 554 | 595 |
| 555 Map<String, KClassEnv> _classMap; | 596 Map<String, KClassEnv> _classMap; |
| 556 Map<String, ir.Member> _memberMap; | 597 Map<String, ir.Member> _memberMap; |
| 557 | 598 |
| 558 KLibraryEnv(this.library); | 599 KLibraryEnv(this.library); |
| 559 | 600 |
| 560 /// Return the [KClassEnv] for the class [name] in [library]. | 601 void _ensureClassMap() { |
| 561 KClassEnv lookupClass(String name) { | |
| 562 if (_classMap == null) { | 602 if (_classMap == null) { |
| 563 _classMap = <String, KClassEnv>{}; | 603 _classMap = <String, KClassEnv>{}; |
| 564 for (ir.Class cls in library.classes) { | 604 for (ir.Class cls in library.classes) { |
| 565 _classMap[cls.name] = new KClassEnv(cls); | 605 _classMap[cls.name] = new KClassEnv(cls); |
| 566 } | 606 } |
| 567 } | 607 } |
| 608 } |
| 609 |
| 610 /// Return the [KClassEnv] for the class [name] in [library]. |
| 611 KClassEnv lookupClass(String name) { |
| 612 _ensureClassMap(); |
| 568 return _classMap[name]; | 613 return _classMap[name]; |
| 569 } | 614 } |
| 570 | 615 |
| 616 /// Calls [f] for each class in this library. |
| 617 void forEachClass(void f(KClassEnv cls)) { |
| 618 _ensureClassMap(); |
| 619 _classMap.values.forEach(f); |
| 620 } |
| 621 |
| 571 /// Return the [ir.Member] for the member [name] in [library]. | 622 /// Return the [ir.Member] for the member [name] in [library]. |
| 572 ir.Member lookupMember(String name, {bool setter: false}) { | 623 ir.Member lookupMember(String name, {bool setter: false}) { |
| 573 if (_memberMap == null) { | 624 if (_memberMap == null) { |
| 574 _memberMap = <String, ir.Member>{}; | 625 _memberMap = <String, ir.Member>{}; |
| 575 for (ir.Member member in library.members) { | 626 for (ir.Member member in library.members) { |
| 576 // TODO(johnniwinther): Support setter vs. getter. | 627 // TODO(johnniwinther): Support setter vs. getter. |
| 577 _memberMap[member.name.name] = member; | 628 _memberMap[member.name.name] = member; |
| 578 } | 629 } |
| 579 } | 630 } |
| 580 return _memberMap[name]; | 631 return _memberMap[name]; |
| 581 } | 632 } |
| 582 } | 633 } |
| 583 | 634 |
| 584 /// Environment for fast lookup of class members. | 635 /// Environment for fast lookup of class members. |
| 585 // TODO(johnniwinther): Add member lookup. | 636 // TODO(johnniwinther): Add member lookup. |
| 586 class KClassEnv { | 637 class KClassEnv { |
| 587 final ir.Class cls; | 638 final ir.Class cls; |
| 588 | 639 |
| 589 InterfaceType thisType; | 640 InterfaceType thisType; |
| 590 InterfaceType rawType; | 641 InterfaceType rawType; |
| 591 InterfaceType supertype; | 642 InterfaceType supertype; |
| 592 List<InterfaceType> supertypes; | 643 List<InterfaceType> supertypes; |
| 593 | 644 |
| 594 Map<String, ir.Member> _constructorMap; | 645 Map<String, ir.Member> _constructorMap; |
| 595 Map<String, ir.Member> _memberMap; | 646 Map<String, ir.Member> _memberMap; |
| 596 | 647 |
| 648 Iterable<ConstantExpression> _metadata; |
| 649 |
| 597 KClassEnv(this.cls); | 650 KClassEnv(this.cls); |
| 598 | 651 |
| 599 void _ensureMaps() { | 652 void _ensureMaps() { |
| 600 if (_memberMap == null) { | 653 if (_memberMap == null) { |
| 601 _memberMap = <String, ir.Member>{}; | 654 _memberMap = <String, ir.Member>{}; |
| 602 _constructorMap = <String, ir.Member>{}; | 655 _constructorMap = <String, ir.Member>{}; |
| 603 for (ir.Member member in cls.members) { | 656 for (ir.Member member in cls.members) { |
| 604 if (member is ir.Procedure && member.kind == ir.ProcedureKind.Factory) { | 657 if (member is ir.Procedure && member.kind == ir.ProcedureKind.Factory) { |
| 605 _constructorMap[member.name.name] = member; | 658 _constructorMap[member.name.name] = member; |
| 606 } else { | 659 } else { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 618 ir.Member lookupMember(String name, {bool setter: false}) { | 671 ir.Member lookupMember(String name, {bool setter: false}) { |
| 619 _ensureMaps(); | 672 _ensureMaps(); |
| 620 return _memberMap[name]; | 673 return _memberMap[name]; |
| 621 } | 674 } |
| 622 | 675 |
| 623 /// Return the [ir.Member] for the member [name] in [library]. | 676 /// Return the [ir.Member] for the member [name] in [library]. |
| 624 ir.Member lookupConstructor(String name, {bool setter: false}) { | 677 ir.Member lookupConstructor(String name, {bool setter: false}) { |
| 625 _ensureMaps(); | 678 _ensureMaps(); |
| 626 return _constructorMap[name]; | 679 return _constructorMap[name]; |
| 627 } | 680 } |
| 681 |
| 682 Iterable<ConstantExpression> getMetadata(KernelWorldBuilder worldBuilder) { |
| 683 if (_metadata == null) { |
| 684 _metadata = worldBuilder.getMetadata(cls.annotations); |
| 685 } |
| 686 return _metadata; |
| 687 } |
| 628 } | 688 } |
| 629 | 689 |
| 630 class KernelElementEnvironment implements ElementEnvironment { | 690 class KernelElementEnvironment implements ElementEnvironment { |
| 631 final KernelWorldBuilder worldBuilder; | 691 final KernelWorldBuilder worldBuilder; |
| 632 | 692 |
| 633 KernelElementEnvironment(this.worldBuilder); | 693 KernelElementEnvironment(this.worldBuilder); |
| 634 | 694 |
| 635 @override | 695 @override |
| 636 DartType get dynamicType => const DynamicType(); | 696 DartType get dynamicType => const DynamicType(); |
| 637 | 697 |
| 638 @override | 698 @override |
| 639 LibraryEntity get mainLibrary => worldBuilder._mainLibrary; | 699 LibraryEntity get mainLibrary => worldBuilder._mainLibrary; |
| 640 | 700 |
| 641 @override | 701 @override |
| 642 FunctionEntity get mainFunction => worldBuilder._mainFunction; | 702 FunctionEntity get mainFunction => worldBuilder._mainFunction; |
| 643 | 703 |
| 644 @override | 704 @override |
| 645 Iterable<LibraryEntity> get libraries => worldBuilder._libraryMap.values; | 705 Iterable<LibraryEntity> get libraries => worldBuilder._libraries; |
| 646 | 706 |
| 647 @override | 707 @override |
| 648 InterfaceType getThisType(ClassEntity cls) { | 708 InterfaceType getThisType(ClassEntity cls) { |
| 649 return worldBuilder._getThisType(cls); | 709 return worldBuilder._getThisType(cls); |
| 650 } | 710 } |
| 651 | 711 |
| 652 @override | 712 @override |
| 653 InterfaceType getRawType(ClassEntity cls) { | 713 InterfaceType getRawType(ClassEntity cls) { |
| 654 return worldBuilder._getRawType(cls); | 714 return worldBuilder._getRawType(cls); |
| 655 } | 715 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 {bool required: false}) { | 808 {bool required: false}) { |
| 749 ClassEntity cls = worldBuilder.lookupClass(library, name); | 809 ClassEntity cls = worldBuilder.lookupClass(library, name); |
| 750 if (cls == null && required) { | 810 if (cls == null && required) { |
| 751 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, | 811 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, |
| 752 "The class '$name' was not found in library '${library.name}'."); | 812 "The class '$name' was not found in library '${library.name}'."); |
| 753 } | 813 } |
| 754 return cls; | 814 return cls; |
| 755 } | 815 } |
| 756 | 816 |
| 757 @override | 817 @override |
| 818 void forEachClass(KLibrary library, void f(ClassEntity cls)) { |
| 819 worldBuilder._forEachClass(library, f); |
| 820 } |
| 821 |
| 822 @override |
| 758 LibraryEntity lookupLibrary(Uri uri, {bool required: false}) { | 823 LibraryEntity lookupLibrary(Uri uri, {bool required: false}) { |
| 759 LibraryEntity library = worldBuilder.lookupLibrary(uri); | 824 LibraryEntity library = worldBuilder.lookupLibrary(uri); |
| 760 if (library == null && required) { | 825 if (library == null && required) { |
| 761 throw new SpannableAssertionFailure( | 826 throw new SpannableAssertionFailure( |
| 762 CURRENT_ELEMENT_SPANNABLE, "The library '$uri' was not found."); | 827 CURRENT_ELEMENT_SPANNABLE, "The library '$uri' was not found."); |
| 763 } | 828 } |
| 764 return library; | 829 return library; |
| 765 } | 830 } |
| 766 | 831 |
| 767 @override | 832 @override |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1071 } |
| 1007 | 1072 |
| 1008 InterfaceType getMixinTypeForClass(KClass cls) { | 1073 InterfaceType getMixinTypeForClass(KClass cls) { |
| 1009 KClassEnv env = builder._classEnvs[cls.classIndex]; | 1074 KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1010 ir.Supertype mixedInType = env.cls.mixedInType; | 1075 ir.Supertype mixedInType = env.cls.mixedInType; |
| 1011 if (mixedInType == null) return null; | 1076 if (mixedInType == null) return null; |
| 1012 return builder.createInterfaceType( | 1077 return builder.createInterfaceType( |
| 1013 mixedInType.classNode, mixedInType.typeArguments); | 1078 mixedInType.classNode, mixedInType.typeArguments); |
| 1014 } | 1079 } |
| 1015 } | 1080 } |
| OLD | NEW |