| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 } | 548 } |
| 524 | 549 |
| 525 /// Environment for fast lookup of program libraries. | 550 /// Environment for fast lookup of program libraries. |
| 526 class KEnv { | 551 class KEnv { |
| 527 final ir.Program program; | 552 final ir.Program program; |
| 528 | 553 |
| 529 Map<Uri, KLibraryEnv> _libraryMap; | 554 Map<Uri, KLibraryEnv> _libraryMap; |
| 530 | 555 |
| 531 KEnv(this.program); | 556 KEnv(this.program); |
| 532 | 557 |
| 533 /// Return the [KLibraryEnv] for the library with the canonical [uri]. | 558 void _ensureLibraryMap() { |
| 534 KLibraryEnv lookupLibrary(Uri uri) { | |
| 535 if (_libraryMap == null) { | 559 if (_libraryMap == null) { |
| 536 _libraryMap = <Uri, KLibraryEnv>{}; | 560 _libraryMap = <Uri, KLibraryEnv>{}; |
| 537 for (ir.Library library in program.libraries) { | 561 for (ir.Library library in program.libraries) { |
| 538 _libraryMap[library.importUri] = new KLibraryEnv(library); | 562 _libraryMap[library.importUri] = new KLibraryEnv(library); |
| 539 } | 563 } |
| 540 } | 564 } |
| 565 } |
| 566 |
| 567 /// Return the [KLibraryEnv] for the library with the canonical [uri]. |
| 568 KLibraryEnv lookupLibrary(Uri uri) { |
| 569 _ensureLibraryMap(); |
| 541 return _libraryMap[uri]; | 570 return _libraryMap[uri]; |
| 542 } | 571 } |
| 572 |
| 573 /// Calls [f] for each library in this environment. |
| 574 void forEachLibrary(void f(KLibraryEnv library)) { |
| 575 _ensureLibraryMap(); |
| 576 _libraryMap.values.forEach(f); |
| 577 } |
| 578 |
| 579 /// Returns the number of libraries in this environment. |
| 580 int get length { |
| 581 _ensureLibraryMap(); |
| 582 return _libraryMap.length; |
| 583 } |
| 543 } | 584 } |
| 544 | 585 |
| 545 /// Environment for fast lookup of library classes and members. | 586 /// Environment for fast lookup of library classes and members. |
| 546 // TODO(johnniwinther): Add member lookup. | 587 // TODO(johnniwinther): Add member lookup. |
| 547 class KLibraryEnv { | 588 class KLibraryEnv { |
| 548 final ir.Library library; | 589 final ir.Library library; |
| 549 | 590 |
| 550 Map<String, KClassEnv> _classMap; | 591 Map<String, KClassEnv> _classMap; |
| 551 Map<String, ir.Member> _memberMap; | 592 Map<String, ir.Member> _memberMap; |
| 552 | 593 |
| 553 KLibraryEnv(this.library); | 594 KLibraryEnv(this.library); |
| 554 | 595 |
| 555 /// Return the [KClassEnv] for the class [name] in [library]. | 596 void _ensureClassMap() { |
| 556 KClassEnv lookupClass(String name) { | |
| 557 if (_classMap == null) { | 597 if (_classMap == null) { |
| 558 _classMap = <String, KClassEnv>{}; | 598 _classMap = <String, KClassEnv>{}; |
| 559 for (ir.Class cls in library.classes) { | 599 for (ir.Class cls in library.classes) { |
| 560 _classMap[cls.name] = new KClassEnv(cls); | 600 _classMap[cls.name] = new KClassEnv(cls); |
| 561 } | 601 } |
| 562 } | 602 } |
| 603 } |
| 604 |
| 605 /// Return the [KClassEnv] for the class [name] in [library]. |
| 606 KClassEnv lookupClass(String name) { |
| 607 _ensureClassMap(); |
| 563 return _classMap[name]; | 608 return _classMap[name]; |
| 564 } | 609 } |
| 565 | 610 |
| 611 /// Calls [f] for each class in this library. |
| 612 void forEachClass(void f(KClassEnv cls)) { |
| 613 _ensureClassMap(); |
| 614 _classMap.values.forEach(f); |
| 615 } |
| 616 |
| 566 /// Return the [ir.Member] for the member [name] in [library]. | 617 /// Return the [ir.Member] for the member [name] in [library]. |
| 567 ir.Member lookupMember(String name, {bool setter: false}) { | 618 ir.Member lookupMember(String name, {bool setter: false}) { |
| 568 if (_memberMap == null) { | 619 if (_memberMap == null) { |
| 569 _memberMap = <String, ir.Member>{}; | 620 _memberMap = <String, ir.Member>{}; |
| 570 for (ir.Member member in library.members) { | 621 for (ir.Member member in library.members) { |
| 571 // TODO(johnniwinther): Support setter vs. getter. | 622 // TODO(johnniwinther): Support setter vs. getter. |
| 572 _memberMap[member.name.name] = member; | 623 _memberMap[member.name.name] = member; |
| 573 } | 624 } |
| 574 } | 625 } |
| 575 return _memberMap[name]; | 626 return _memberMap[name]; |
| 576 } | 627 } |
| 577 } | 628 } |
| 578 | 629 |
| 579 /// Environment for fast lookup of class members. | 630 /// Environment for fast lookup of class members. |
| 580 // TODO(johnniwinther): Add member lookup. | 631 // TODO(johnniwinther): Add member lookup. |
| 581 class KClassEnv { | 632 class KClassEnv { |
| 582 final ir.Class cls; | 633 final ir.Class cls; |
| 583 | 634 |
| 584 InterfaceType thisType; | 635 InterfaceType thisType; |
| 585 InterfaceType rawType; | 636 InterfaceType rawType; |
| 586 InterfaceType supertype; | 637 InterfaceType supertype; |
| 587 List<InterfaceType> supertypes; | 638 List<InterfaceType> supertypes; |
| 588 | 639 |
| 589 Map<String, ir.Member> _constructorMap; | 640 Map<String, ir.Member> _constructorMap; |
| 590 Map<String, ir.Member> _memberMap; | 641 Map<String, ir.Member> _memberMap; |
| 591 | 642 |
| 643 Iterable<ConstantExpression> _metadata; |
| 644 |
| 592 KClassEnv(this.cls); | 645 KClassEnv(this.cls); |
| 593 | 646 |
| 594 void _ensureMaps() { | 647 void _ensureMaps() { |
| 595 if (_memberMap == null) { | 648 if (_memberMap == null) { |
| 596 _memberMap = <String, ir.Member>{}; | 649 _memberMap = <String, ir.Member>{}; |
| 597 _constructorMap = <String, ir.Member>{}; | 650 _constructorMap = <String, ir.Member>{}; |
| 598 for (ir.Member member in cls.members) { | 651 for (ir.Member member in cls.members) { |
| 599 if (member is ir.Procedure && member.kind == ir.ProcedureKind.Factory) { | 652 if (member is ir.Procedure && member.kind == ir.ProcedureKind.Factory) { |
| 600 _constructorMap[member.name.name] = member; | 653 _constructorMap[member.name.name] = member; |
| 601 } else { | 654 } else { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 613 ir.Member lookupMember(String name, {bool setter: false}) { | 666 ir.Member lookupMember(String name, {bool setter: false}) { |
| 614 _ensureMaps(); | 667 _ensureMaps(); |
| 615 return _memberMap[name]; | 668 return _memberMap[name]; |
| 616 } | 669 } |
| 617 | 670 |
| 618 /// Return the [ir.Member] for the member [name] in [library]. | 671 /// Return the [ir.Member] for the member [name] in [library]. |
| 619 ir.Member lookupConstructor(String name, {bool setter: false}) { | 672 ir.Member lookupConstructor(String name, {bool setter: false}) { |
| 620 _ensureMaps(); | 673 _ensureMaps(); |
| 621 return _constructorMap[name]; | 674 return _constructorMap[name]; |
| 622 } | 675 } |
| 676 |
| 677 Iterable<ConstantExpression> getMetadata(KernelWorldBuilder worldBuilder) { |
| 678 if (_metadata == null) { |
| 679 _metadata = worldBuilder.getMetadata(cls.annotations); |
| 680 } |
| 681 return _metadata; |
| 682 } |
| 623 } | 683 } |
| 624 | 684 |
| 625 class KernelElementEnvironment implements ElementEnvironment { | 685 class KernelElementEnvironment implements ElementEnvironment { |
| 626 final KernelWorldBuilder worldBuilder; | 686 final KernelWorldBuilder worldBuilder; |
| 627 | 687 |
| 628 KernelElementEnvironment(this.worldBuilder); | 688 KernelElementEnvironment(this.worldBuilder); |
| 629 | 689 |
| 630 @override | 690 @override |
| 631 DartType get dynamicType => const DynamicType(); | 691 DartType get dynamicType => const DynamicType(); |
| 632 | 692 |
| 633 @override | 693 @override |
| 634 LibraryEntity get mainLibrary => worldBuilder._mainLibrary; | 694 LibraryEntity get mainLibrary => worldBuilder._mainLibrary; |
| 635 | 695 |
| 636 @override | 696 @override |
| 637 FunctionEntity get mainFunction => worldBuilder._mainFunction; | 697 FunctionEntity get mainFunction => worldBuilder._mainFunction; |
| 638 | 698 |
| 639 @override | 699 @override |
| 640 Iterable<LibraryEntity> get libraries => worldBuilder._libraryMap.values; | 700 Iterable<LibraryEntity> get libraries => worldBuilder._libraries; |
| 641 | 701 |
| 642 @override | 702 @override |
| 643 InterfaceType getThisType(ClassEntity cls) { | 703 InterfaceType getThisType(ClassEntity cls) { |
| 644 return worldBuilder._getThisType(cls); | 704 return worldBuilder._getThisType(cls); |
| 645 } | 705 } |
| 646 | 706 |
| 647 @override | 707 @override |
| 648 InterfaceType getRawType(ClassEntity cls) { | 708 InterfaceType getRawType(ClassEntity cls) { |
| 649 return worldBuilder._getRawType(cls); | 709 return worldBuilder._getRawType(cls); |
| 650 } | 710 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 {bool required: false}) { | 803 {bool required: false}) { |
| 744 ClassEntity cls = worldBuilder.lookupClass(library, name); | 804 ClassEntity cls = worldBuilder.lookupClass(library, name); |
| 745 if (cls == null && required) { | 805 if (cls == null && required) { |
| 746 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, | 806 throw new SpannableAssertionFailure(CURRENT_ELEMENT_SPANNABLE, |
| 747 "The class '$name' was not found in library '${library.name}'."); | 807 "The class '$name' was not found in library '${library.name}'."); |
| 748 } | 808 } |
| 749 return cls; | 809 return cls; |
| 750 } | 810 } |
| 751 | 811 |
| 752 @override | 812 @override |
| 813 void forEachClass(KLibrary library, void f(ClassEntity cls)) { |
| 814 worldBuilder._forEachClass(library, f); |
| 815 } |
| 816 |
| 817 @override |
| 753 LibraryEntity lookupLibrary(Uri uri, {bool required: false}) { | 818 LibraryEntity lookupLibrary(Uri uri, {bool required: false}) { |
| 754 LibraryEntity library = worldBuilder.lookupLibrary(uri); | 819 LibraryEntity library = worldBuilder.lookupLibrary(uri); |
| 755 if (library == null && required) { | 820 if (library == null && required) { |
| 756 throw new SpannableAssertionFailure( | 821 throw new SpannableAssertionFailure( |
| 757 CURRENT_ELEMENT_SPANNABLE, "The library '$uri' was not found."); | 822 CURRENT_ELEMENT_SPANNABLE, "The library '$uri' was not found."); |
| 758 } | 823 } |
| 759 return library; | 824 return library; |
| 760 } | 825 } |
| 761 | 826 |
| 762 @override | 827 @override |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 } | 1066 } |
| 1002 | 1067 |
| 1003 InterfaceType getMixinTypeForClass(KClass cls) { | 1068 InterfaceType getMixinTypeForClass(KClass cls) { |
| 1004 KClassEnv env = builder._classEnvs[cls.classIndex]; | 1069 KClassEnv env = builder._classEnvs[cls.classIndex]; |
| 1005 ir.Supertype mixedInType = env.cls.mixedInType; | 1070 ir.Supertype mixedInType = env.cls.mixedInType; |
| 1006 if (mixedInType == null) return null; | 1071 if (mixedInType == null) return null; |
| 1007 return builder.createInterfaceType( | 1072 return builder.createInterfaceType( |
| 1008 mixedInType.classNode, mixedInType.typeArguments); | 1073 mixedInType.classNode, mixedInType.typeArguments); |
| 1009 } | 1074 } |
| 1010 } | 1075 } |
| OLD | NEW |