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.element_map; | 5 library dart2js.kernel.element_map; |
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/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 final DiagnosticReporter reporter; | 65 final DiagnosticReporter reporter; |
66 CommonElements _commonElements; | 66 CommonElements _commonElements; |
67 ElementEnvironment _elementEnvironment; | 67 ElementEnvironment _elementEnvironment; |
68 DartTypeConverter _typeConverter; | 68 DartTypeConverter _typeConverter; |
69 KernelConstantEnvironment _constantEnvironment; | 69 KernelConstantEnvironment _constantEnvironment; |
70 _KernelDartTypes _types; | 70 _KernelDartTypes _types; |
71 | 71 |
72 /// Library environment. Used for fast lookup. | 72 /// Library environment. Used for fast lookup. |
73 ProgramEnv _env = new ProgramEnv(); | 73 ProgramEnv _env = new ProgramEnv(); |
74 | 74 |
| 75 List<LibraryEntity> _libraryList = <LibraryEntity>[]; |
| 76 List<ClassEntity> _classList = <ClassEntity>[]; |
| 77 List<MemberEntity> _memberList = <MemberEntity>[]; |
| 78 |
75 /// List of library environments by `IndexedLibrary.libraryIndex`. This is | 79 /// List of library environments by `IndexedLibrary.libraryIndex`. This is |
76 /// used for fast lookup into library classes and members. | 80 /// used for fast lookup into library classes and members. |
77 List<LibraryEnv> _libraryEnvs = <LibraryEnv>[]; | 81 List<LibraryEnv> _libraryEnvs = <LibraryEnv>[]; |
78 | 82 |
79 /// List of class environments by `IndexedClass.classIndex`. This is used for | 83 /// List of class environments by `IndexedClass.classIndex`. This is used for |
80 /// fast lookup into class members. | 84 /// fast lookup into class members. |
81 List<ClassEnv> _classEnvs = <ClassEnv>[]; | 85 List<ClassEnv> _classEnvs = <ClassEnv>[]; |
82 | 86 |
83 /// List of member data by `IndexedMember.classIndex`. This is used for | 87 /// List of member data by `IndexedMember.memberIndex`. This is used for |
84 /// fast lookup into member properties. | 88 /// fast lookup into member properties. |
85 List<MemberData> _memberList = <MemberData>[]; | 89 List<MemberData> _memberData = <MemberData>[]; |
86 | 90 |
87 KernelToElementMapBase(this.reporter, Environment environment) { | 91 KernelToElementMapBase(this.reporter, Environment environment) { |
88 _elementEnvironment = new KernelElementEnvironment(this); | 92 _elementEnvironment = new KernelElementEnvironment(this); |
89 _commonElements = new CommonElements(_elementEnvironment); | 93 _commonElements = new CommonElements(_elementEnvironment); |
90 _constantEnvironment = new KernelConstantEnvironment(this, environment); | 94 _constantEnvironment = new KernelConstantEnvironment(this, environment); |
91 _typeConverter = new DartTypeConverter(this); | 95 _typeConverter = new DartTypeConverter(this); |
92 _types = new _KernelDartTypes(this); | 96 _types = new _KernelDartTypes(this); |
93 } | 97 } |
94 | 98 |
95 DartTypes get types => _types; | 99 DartTypes get types => _types; |
(...skipping 15 matching lines...) Expand all Loading... |
111 } | 115 } |
112 | 116 |
113 Iterable<LibraryEntity> get _libraries; | 117 Iterable<LibraryEntity> get _libraries; |
114 | 118 |
115 LibraryEntity lookupLibrary(Uri uri) { | 119 LibraryEntity lookupLibrary(Uri uri) { |
116 LibraryEnv libraryEnv = _env.lookupLibrary(uri); | 120 LibraryEnv libraryEnv = _env.lookupLibrary(uri); |
117 if (libraryEnv == null) return null; | 121 if (libraryEnv == null) return null; |
118 return _getLibrary(libraryEnv.library, libraryEnv); | 122 return _getLibrary(libraryEnv.library, libraryEnv); |
119 } | 123 } |
120 | 124 |
121 String _getLibraryName(KLibrary library) { | 125 String _getLibraryName(IndexedLibrary library) { |
122 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 126 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
123 return libraryEnv.library.name ?? ''; | 127 return libraryEnv.library.name ?? ''; |
124 } | 128 } |
125 | 129 |
126 MemberEntity lookupLibraryMember(KLibrary library, String name, | 130 MemberEntity lookupLibraryMember(IndexedLibrary library, String name, |
127 {bool setter: false}) { | 131 {bool setter: false}) { |
128 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 132 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
129 ir.Member member = libraryEnv.lookupMember(name, setter: setter); | 133 ir.Member member = libraryEnv.lookupMember(name, setter: setter); |
130 return member != null ? getMember(member) : null; | 134 return member != null ? getMember(member) : null; |
131 } | 135 } |
132 | 136 |
133 void _forEachLibraryMember(KLibrary library, void f(MemberEntity member)) { | 137 void _forEachLibraryMember( |
| 138 IndexedLibrary library, void f(MemberEntity member)) { |
134 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 139 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
135 libraryEnv.forEachMember((ir.Member node) { | 140 libraryEnv.forEachMember((ir.Member node) { |
136 f(getMember(node)); | 141 f(getMember(node)); |
137 }); | 142 }); |
138 } | 143 } |
139 | 144 |
140 ClassEntity lookupClass(KLibrary library, String name) { | 145 ClassEntity lookupClass(IndexedLibrary library, String name) { |
141 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 146 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
142 ClassEnv classEnv = libraryEnv.lookupClass(name); | 147 ClassEnv classEnv = libraryEnv.lookupClass(name); |
143 if (classEnv != null) { | 148 if (classEnv != null) { |
144 return _getClass(classEnv.cls, classEnv); | 149 return _getClass(classEnv.cls, classEnv); |
145 } | 150 } |
146 return null; | 151 return null; |
147 } | 152 } |
148 | 153 |
149 void _forEachClass(KLibrary library, void f(ClassEntity cls)) { | 154 void _forEachClass(IndexedLibrary library, void f(ClassEntity cls)) { |
150 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; | 155 LibraryEnv libraryEnv = _libraryEnvs[library.libraryIndex]; |
151 libraryEnv.forEachClass((ClassEnv classEnv) { | 156 libraryEnv.forEachClass((ClassEnv classEnv) { |
152 if (!classEnv.isUnnamedMixinApplication) { | 157 if (!classEnv.isUnnamedMixinApplication) { |
153 f(_getClass(classEnv.cls, classEnv)); | 158 f(_getClass(classEnv.cls, classEnv)); |
154 } | 159 } |
155 }); | 160 }); |
156 } | 161 } |
157 | 162 |
158 MemberEntity lookupClassMember(IndexedClass cls, String name, | 163 MemberEntity lookupClassMember(IndexedClass cls, String name, |
159 {bool setter: false}) { | 164 {bool setter: false}) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 _ensureThisAndRawType(cls, env); | 396 _ensureThisAndRawType(cls, env); |
392 return env.thisType; | 397 return env.thisType; |
393 } | 398 } |
394 | 399 |
395 InterfaceType _getRawType(IndexedClass cls) { | 400 InterfaceType _getRawType(IndexedClass cls) { |
396 ClassEnv env = _classEnvs[cls.classIndex]; | 401 ClassEnv env = _classEnvs[cls.classIndex]; |
397 _ensureThisAndRawType(cls, env); | 402 _ensureThisAndRawType(cls, env); |
398 return env.rawType; | 403 return env.rawType; |
399 } | 404 } |
400 | 405 |
401 FunctionType _getFunctionType(IndexedMember function) { | 406 FunctionType _getFunctionType(IndexedFunction function) { |
402 FunctionData data = _memberList[function.memberIndex]; | 407 FunctionData data = _memberData[function.memberIndex]; |
403 return data.getFunctionType(this); | 408 return data.getFunctionType(this); |
404 } | 409 } |
405 | 410 |
406 ClassEntity _getAppliedMixin(IndexedClass cls) { | 411 ClassEntity _getAppliedMixin(IndexedClass cls) { |
407 ClassEnv env = _classEnvs[cls.classIndex]; | 412 ClassEnv env = _classEnvs[cls.classIndex]; |
408 _ensureSupertypes(cls, env); | 413 _ensureSupertypes(cls, env); |
409 return env.mixedInType?.element; | 414 return env.mixedInType?.element; |
410 } | 415 } |
411 | 416 |
412 bool _isMixinApplication(IndexedClass cls) { | 417 bool _isMixinApplication(IndexedClass cls) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 env.forEachMember((ir.Member member) { | 456 env.forEachMember((ir.Member member) { |
452 f(cls, getMember(member)); | 457 f(cls, getMember(member)); |
453 }); | 458 }); |
454 _ensureSupertypes(cls, env); | 459 _ensureSupertypes(cls, env); |
455 if (env.supertype != null) { | 460 if (env.supertype != null) { |
456 _forEachClassMember(env.supertype.element, f); | 461 _forEachClassMember(env.supertype.element, f); |
457 } | 462 } |
458 } | 463 } |
459 | 464 |
460 ConstantConstructor _getConstructorConstant(IndexedConstructor constructor) { | 465 ConstantConstructor _getConstructorConstant(IndexedConstructor constructor) { |
461 ConstructorData data = _memberList[constructor.memberIndex]; | 466 ConstructorData data = _memberData[constructor.memberIndex]; |
462 return data.getConstructorConstant(this, constructor); | 467 return data.getConstructorConstant(this, constructor); |
463 } | 468 } |
464 | 469 |
465 ConstantExpression _getFieldConstant(IndexedField field) { | 470 ConstantExpression _getFieldConstant(IndexedField field) { |
466 FieldData data = _memberList[field.memberIndex]; | 471 FieldData data = _memberData[field.memberIndex]; |
467 return data.getFieldConstant(this, field); | 472 return data.getFieldConstant(this, field); |
468 } | 473 } |
469 | 474 |
470 InterfaceType _asInstanceOf(InterfaceType type, ClassEntity cls) { | 475 InterfaceType _asInstanceOf(InterfaceType type, ClassEntity cls) { |
471 OrderedTypeSet orderedTypeSet = _getOrderedTypeSet(type.element); | 476 OrderedTypeSet orderedTypeSet = _getOrderedTypeSet(type.element); |
472 InterfaceType supertype = | 477 InterfaceType supertype = |
473 orderedTypeSet.asInstanceOf(cls, _getHierarchyDepth(cls)); | 478 orderedTypeSet.asInstanceOf(cls, _getHierarchyDepth(cls)); |
474 if (supertype != null) { | 479 if (supertype != null) { |
475 supertype = _substByContext(supertype, type); | 480 supertype = _substByContext(supertype, type); |
476 } | 481 } |
(...skipping 16 matching lines...) Expand all Loading... |
493 ClassEnv env = _classEnvs[cls.classIndex]; | 498 ClassEnv env = _classEnvs[cls.classIndex]; |
494 _ensureSupertypes(cls, env); | 499 _ensureSupertypes(cls, env); |
495 return env.interfaces; | 500 return env.interfaces; |
496 } | 501 } |
497 | 502 |
498 Spannable _getSpannable(MemberEntity member, ir.Node node) { | 503 Spannable _getSpannable(MemberEntity member, ir.Node node) { |
499 return member; | 504 return member; |
500 } | 505 } |
501 | 506 |
502 ir.Member _getMemberNode(covariant IndexedMember member) { | 507 ir.Member _getMemberNode(covariant IndexedMember member) { |
503 return _memberList[member.memberIndex].node; | 508 return _memberData[member.memberIndex].node; |
504 } | 509 } |
505 | 510 |
506 ir.Class _getClassNode(covariant IndexedClass cls) { | 511 ir.Class _getClassNode(covariant IndexedClass cls) { |
507 return _classEnvs[cls.classIndex].cls; | 512 return _classEnvs[cls.classIndex].cls; |
508 } | 513 } |
509 } | 514 } |
510 | 515 |
511 /// Mixin that implements the abstract methods in [KernelToElementMapBase] by | 516 /// Mixin that implements the abstract methods in [KernelToElementMapBase] by |
512 /// creating K-model elements. | 517 /// creating K-model elements. |
513 abstract class KElementCreatorMixin { | 518 abstract class KElementCreatorMixin { |
514 ProgramEnv get _env; | 519 ProgramEnv get _env; |
| 520 List<LibraryEntity> get _libraryList; |
515 List<LibraryEnv> get _libraryEnvs; | 521 List<LibraryEnv> get _libraryEnvs; |
| 522 List<ClassEntity> get _classList; |
516 List<ClassEnv> get _classEnvs; | 523 List<ClassEnv> get _classEnvs; |
517 List<MemberData> get _memberList; | 524 List<MemberEntity> get _memberList; |
| 525 List<MemberData> get _memberData; |
518 | 526 |
519 Map<ir.Library, KLibrary> _libraryMap = <ir.Library, KLibrary>{}; | 527 Map<ir.Library, KLibrary> _libraryMap = <ir.Library, KLibrary>{}; |
520 Map<ir.Class, KClass> _classMap = <ir.Class, KClass>{}; | 528 Map<ir.Class, KClass> _classMap = <ir.Class, KClass>{}; |
521 Map<ir.TypeParameter, KTypeVariable> _typeVariableMap = | 529 Map<ir.TypeParameter, KTypeVariable> _typeVariableMap = |
522 <ir.TypeParameter, KTypeVariable>{}; | 530 <ir.TypeParameter, KTypeVariable>{}; |
523 Map<ir.Member, KConstructor> _constructorMap = <ir.Member, KConstructor>{}; | 531 Map<ir.Member, KConstructor> _constructorMap = <ir.Member, KConstructor>{}; |
524 Map<ir.Procedure, KFunction> _methodMap = <ir.Procedure, KFunction>{}; | 532 Map<ir.Procedure, KFunction> _methodMap = <ir.Procedure, KFunction>{}; |
525 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{}; | 533 Map<ir.Field, KField> _fieldMap = <ir.Field, KField>{}; |
526 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = | 534 Map<ir.TreeNode, KLocalFunction> _localFunctionMap = |
527 <ir.TreeNode, KLocalFunction>{}; | 535 <ir.TreeNode, KLocalFunction>{}; |
(...skipping 15 matching lines...) Expand all Loading... |
543 LibraryEntity _getLibrary(ir.Library node, [LibraryEnv libraryEnv]) { | 551 LibraryEntity _getLibrary(ir.Library node, [LibraryEnv libraryEnv]) { |
544 return _libraryMap.putIfAbsent(node, () { | 552 return _libraryMap.putIfAbsent(node, () { |
545 Uri canonicalUri = node.importUri; | 553 Uri canonicalUri = node.importUri; |
546 _libraryEnvs.add(libraryEnv ?? _env.lookupLibrary(canonicalUri)); | 554 _libraryEnvs.add(libraryEnv ?? _env.lookupLibrary(canonicalUri)); |
547 String name = node.name; | 555 String name = node.name; |
548 if (name == null) { | 556 if (name == null) { |
549 // Use the file name as script name. | 557 // Use the file name as script name. |
550 String path = canonicalUri.path; | 558 String path = canonicalUri.path; |
551 name = path.substring(path.lastIndexOf('/') + 1); | 559 name = path.substring(path.lastIndexOf('/') + 1); |
552 } | 560 } |
553 return new KLibrary(_libraryMap.length, name, canonicalUri); | 561 LibraryEntity library = |
| 562 new KLibrary(_libraryMap.length, name, canonicalUri); |
| 563 _libraryList.add(library); |
| 564 return library; |
554 }); | 565 }); |
555 } | 566 } |
556 | 567 |
557 ClassEntity _getClass(ir.Class node, [ClassEnv classEnv]) { | 568 ClassEntity _getClass(ir.Class node, [ClassEnv classEnv]) { |
558 return _classMap.putIfAbsent(node, () { | 569 return _classMap.putIfAbsent(node, () { |
559 KLibrary library = _getLibrary(node.enclosingLibrary); | 570 KLibrary library = _getLibrary(node.enclosingLibrary); |
560 if (classEnv == null) { | 571 if (classEnv == null) { |
561 classEnv = _libraryEnvs[library.libraryIndex].lookupClass(node.name); | 572 classEnv = _libraryEnvs[library.libraryIndex].lookupClass(node.name); |
562 } | 573 } |
563 _classEnvs.add(classEnv); | 574 _classEnvs.add(classEnv); |
564 return new KClass(library, _classMap.length, node.name, | 575 ClassEntity cls = new KClass(library, _classMap.length, node.name, |
565 isAbstract: node.isAbstract); | 576 isAbstract: node.isAbstract); |
| 577 _classList.add(cls); |
| 578 return cls; |
566 }); | 579 }); |
567 } | 580 } |
568 | 581 |
569 TypeVariableEntity _getTypeVariable(ir.TypeParameter node) { | 582 TypeVariableEntity _getTypeVariable(ir.TypeParameter node) { |
570 return _typeVariableMap.putIfAbsent(node, () { | 583 return _typeVariableMap.putIfAbsent(node, () { |
571 if (node.parent is ir.Class) { | 584 if (node.parent is ir.Class) { |
572 ir.Class cls = node.parent; | 585 ir.Class cls = node.parent; |
573 int index = cls.typeParameters.indexOf(node); | 586 int index = cls.typeParameters.indexOf(node); |
574 return new KTypeVariable(_getClass(cls), node.name, index); | 587 return new KTypeVariable(_getClass(cls), node.name, index); |
575 } | 588 } |
(...skipping 14 matching lines...) Expand all Loading... |
590 return new KTypeVariable(_getMethod(procedure), node.name, index); | 603 return new KTypeVariable(_getMethod(procedure), node.name, index); |
591 } | 604 } |
592 } | 605 } |
593 } | 606 } |
594 throw new UnsupportedError('Unsupported type parameter type node $node.'); | 607 throw new UnsupportedError('Unsupported type parameter type node $node.'); |
595 }); | 608 }); |
596 } | 609 } |
597 | 610 |
598 ConstructorEntity _getConstructor(ir.Member node) { | 611 ConstructorEntity _getConstructor(ir.Member node) { |
599 return _constructorMap.putIfAbsent(node, () { | 612 return _constructorMap.putIfAbsent(node, () { |
600 int memberIndex = _memberList.length; | 613 int memberIndex = _memberData.length; |
601 KConstructor constructor; | 614 KConstructor constructor; |
602 KClass enclosingClass = _getClass(node.enclosingClass); | 615 KClass enclosingClass = _getClass(node.enclosingClass); |
603 Name name = getName(node.name); | 616 Name name = getName(node.name); |
604 bool isExternal = node.isExternal; | 617 bool isExternal = node.isExternal; |
605 | 618 |
606 ir.FunctionNode functionNode; | 619 ir.FunctionNode functionNode; |
607 if (node is ir.Constructor) { | 620 if (node is ir.Constructor) { |
608 functionNode = node.function; | 621 functionNode = node.function; |
609 constructor = new KGenerativeConstructor(memberIndex, enclosingClass, | 622 constructor = new KGenerativeConstructor(memberIndex, enclosingClass, |
610 name, _getParameterStructure(functionNode), | 623 name, _getParameterStructure(functionNode), |
611 isExternal: isExternal, isConst: node.isConst); | 624 isExternal: isExternal, isConst: node.isConst); |
612 } else if (node is ir.Procedure) { | 625 } else if (node is ir.Procedure) { |
613 functionNode = node.function; | 626 functionNode = node.function; |
614 bool isFromEnvironment = isExternal && | 627 bool isFromEnvironment = isExternal && |
615 name.text == 'fromEnvironment' && | 628 name.text == 'fromEnvironment' && |
616 const ['int', 'bool', 'String'].contains(enclosingClass.name); | 629 const ['int', 'bool', 'String'].contains(enclosingClass.name); |
617 constructor = new KFactoryConstructor(memberIndex, enclosingClass, name, | 630 constructor = new KFactoryConstructor(memberIndex, enclosingClass, name, |
618 _getParameterStructure(functionNode), | 631 _getParameterStructure(functionNode), |
619 isExternal: isExternal, | 632 isExternal: isExternal, |
620 isConst: node.isConst, | 633 isConst: node.isConst, |
621 isFromEnvironmentConstructor: isFromEnvironment); | 634 isFromEnvironmentConstructor: isFromEnvironment); |
622 } else { | 635 } else { |
623 // TODO(johnniwinther): Convert `node.location` to a [SourceSpan]. | 636 // TODO(johnniwinther): Convert `node.location` to a [SourceSpan]. |
624 throw new SpannableAssertionFailure( | 637 throw new SpannableAssertionFailure( |
625 NO_LOCATION_SPANNABLE, "Unexpected constructor node: ${node}."); | 638 NO_LOCATION_SPANNABLE, "Unexpected constructor node: ${node}."); |
626 } | 639 } |
627 _memberList.add(new ConstructorData(node, functionNode)); | 640 _memberData.add(new ConstructorData(node, functionNode)); |
| 641 _memberList.add(constructor); |
628 return constructor; | 642 return constructor; |
629 }); | 643 }); |
630 } | 644 } |
631 | 645 |
632 FunctionEntity _getMethod(ir.Procedure node) { | 646 FunctionEntity _getMethod(ir.Procedure node) { |
633 return _methodMap.putIfAbsent(node, () { | 647 return _methodMap.putIfAbsent(node, () { |
634 int memberIndex = _memberList.length; | 648 int memberIndex = _memberData.length; |
635 LibraryEntity library; | 649 LibraryEntity library; |
636 ClassEntity enclosingClass; | 650 ClassEntity enclosingClass; |
637 if (node.enclosingClass != null) { | 651 if (node.enclosingClass != null) { |
638 enclosingClass = _getClass(node.enclosingClass); | 652 enclosingClass = _getClass(node.enclosingClass); |
639 library = enclosingClass.library; | 653 library = enclosingClass.library; |
640 } else { | 654 } else { |
641 library = _getLibrary(node.enclosingLibrary); | 655 library = _getLibrary(node.enclosingLibrary); |
642 } | 656 } |
643 Name name = getName(node.name); | 657 Name name = getName(node.name); |
644 bool isStatic = node.isStatic; | 658 bool isStatic = node.isStatic; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 break; | 697 break; |
684 case ir.ProcedureKind.Setter: | 698 case ir.ProcedureKind.Setter: |
685 assert(asyncMarker == AsyncMarker.SYNC); | 699 assert(asyncMarker == AsyncMarker.SYNC); |
686 function = new KSetter( | 700 function = new KSetter( |
687 memberIndex, library, enclosingClass, getName(node.name).setter, | 701 memberIndex, library, enclosingClass, getName(node.name).setter, |
688 isStatic: isStatic, | 702 isStatic: isStatic, |
689 isExternal: isExternal, | 703 isExternal: isExternal, |
690 isAbstract: isAbstract); | 704 isAbstract: isAbstract); |
691 break; | 705 break; |
692 } | 706 } |
693 _memberList.add(new FunctionData(node, node.function)); | 707 _memberData.add(new FunctionData(node, node.function)); |
| 708 _memberList.add(function); |
694 return function; | 709 return function; |
695 }); | 710 }); |
696 } | 711 } |
697 | 712 |
698 FieldEntity _getField(ir.Field node) { | 713 FieldEntity _getField(ir.Field node) { |
699 return _fieldMap.putIfAbsent(node, () { | 714 return _fieldMap.putIfAbsent(node, () { |
700 int memberIndex = _memberList.length; | 715 int memberIndex = _memberData.length; |
701 LibraryEntity library; | 716 LibraryEntity library; |
702 ClassEntity enclosingClass; | 717 ClassEntity enclosingClass; |
703 if (node.enclosingClass != null) { | 718 if (node.enclosingClass != null) { |
704 enclosingClass = _getClass(node.enclosingClass); | 719 enclosingClass = _getClass(node.enclosingClass); |
705 library = enclosingClass.library; | 720 library = enclosingClass.library; |
706 } else { | 721 } else { |
707 library = _getLibrary(node.enclosingLibrary); | 722 library = _getLibrary(node.enclosingLibrary); |
708 } | 723 } |
709 Name name = getName(node.name); | 724 Name name = getName(node.name); |
710 bool isStatic = node.isStatic; | 725 bool isStatic = node.isStatic; |
711 _memberList.add(new FieldData(node)); | 726 _memberData.add(new FieldData(node)); |
712 return new KField(memberIndex, library, enclosingClass, name, | 727 FieldEntity field = new KField(memberIndex, library, enclosingClass, name, |
713 isStatic: isStatic, | 728 isStatic: isStatic, |
714 isAssignable: node.isMutable, | 729 isAssignable: node.isMutable, |
715 isConst: node.isConst); | 730 isConst: node.isConst); |
| 731 _memberList.add(field); |
| 732 return field; |
716 }); | 733 }); |
717 } | 734 } |
718 | 735 |
719 ParameterStructure _getParameterStructure(ir.FunctionNode node) { | 736 ParameterStructure _getParameterStructure(ir.FunctionNode node) { |
720 // TODO(johnniwinther): Cache the computed function type. | 737 // TODO(johnniwinther): Cache the computed function type. |
721 int requiredParameters = node.requiredParameterCount; | 738 int requiredParameters = node.requiredParameterCount; |
722 int positionalParameters = node.positionalParameters.length; | 739 int positionalParameters = node.positionalParameters.length; |
723 List<String> namedParameters = | 740 List<String> namedParameters = |
724 node.namedParameters.map((p) => p.name).toList()..sort(); | 741 node.namedParameters.map((p) => p.name).toList()..sort(); |
725 return new ParameterStructure( | 742 return new ParameterStructure( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 /// compilation. | 793 /// compilation. |
777 void addProgram(ir.Program program) { | 794 void addProgram(ir.Program program) { |
778 _env.addProgram(program); | 795 _env.addProgram(program); |
779 } | 796 } |
780 | 797 |
781 @override | 798 @override |
782 native.BehaviorBuilder get nativeBehaviorBuilder => | 799 native.BehaviorBuilder get nativeBehaviorBuilder => |
783 _nativeBehaviorBuilder ??= new KernelBehaviorBuilder(commonElements); | 800 _nativeBehaviorBuilder ??= new KernelBehaviorBuilder(commonElements); |
784 | 801 |
785 ResolutionImpact computeWorldImpact(KMember member) { | 802 ResolutionImpact computeWorldImpact(KMember member) { |
786 return _memberList[member.memberIndex].getWorldImpact(this); | 803 return _memberData[member.memberIndex].getWorldImpact(this); |
787 } | 804 } |
788 | 805 |
789 /// Returns the kernel [ir.Procedure] node for the [method]. | 806 /// Returns the kernel [ir.Procedure] node for the [method]. |
790 ir.Procedure _lookupProcedure(KFunction method) { | 807 ir.Procedure _lookupProcedure(KFunction method) { |
791 return _memberList[method.memberIndex].node; | 808 return _memberData[method.memberIndex].node; |
792 } | 809 } |
793 | 810 |
794 Iterable<ConstantValue> _getClassMetadata(KClass cls) { | 811 Iterable<ConstantValue> _getClassMetadata(KClass cls) { |
795 return _classEnvs[cls.classIndex].getMetadata(this); | 812 return _classEnvs[cls.classIndex].getMetadata(this); |
796 } | 813 } |
797 } | 814 } |
798 | 815 |
799 /// Implementation of [KernelToElementMapForImpact] that only supports world | 816 /// Implementation of [KernelToElementMapForImpact] that only supports world |
800 /// impact computation. | 817 /// impact computation. |
801 // TODO(johnniwinther): Merge this with [KernelToElementMapForImpactImpl] when | 818 // TODO(johnniwinther): Merge this with [KernelToElementMapForImpactImpl] when |
(...skipping 26 matching lines...) Expand all Loading... |
828 return getConstantValue(field.initializer, | 845 return getConstantValue(field.initializer, |
829 requireConstant: field.isConst, implicitNull: !field.isConst); | 846 requireConstant: field.isConst, implicitNull: !field.isConst); |
830 } | 847 } |
831 | 848 |
832 ir.Library getKernelLibrary(KLibrary entity) => | 849 ir.Library getKernelLibrary(KLibrary entity) => |
833 _libraryEnvs[entity.libraryIndex].library; | 850 _libraryEnvs[entity.libraryIndex].library; |
834 | 851 |
835 ir.Class getKernelClass(KClass entity) => _classEnvs[entity.classIndex].cls; | 852 ir.Class getKernelClass(KClass entity) => _classEnvs[entity.classIndex].cls; |
836 | 853 |
837 bool hasConstantFieldInitializer(covariant KField field) { | 854 bool hasConstantFieldInitializer(covariant KField field) { |
838 FieldData data = _memberList[field.memberIndex]; | 855 FieldData data = _memberData[field.memberIndex]; |
839 return getFieldConstantValue(data.node) != null; | 856 return getFieldConstantValue(data.node) != null; |
840 } | 857 } |
841 | 858 |
842 ConstantValue getConstantFieldInitializer(covariant KField field) { | 859 ConstantValue getConstantFieldInitializer(covariant KField field) { |
843 FieldData data = _memberList[field.memberIndex]; | 860 FieldData data = _memberData[field.memberIndex]; |
844 ConstantValue value = getFieldConstantValue(data.node); | 861 ConstantValue value = getFieldConstantValue(data.node); |
845 assert(value != null, | 862 assert(value != null, |
846 failedAt(field, "Field $field doesn't have a constant initial value.")); | 863 failedAt(field, "Field $field doesn't have a constant initial value.")); |
847 return value; | 864 return value; |
848 } | 865 } |
849 | 866 |
850 void forEachParameter(covariant KFunction function, | 867 void forEachParameter(covariant KFunction function, |
851 void f(DartType type, String name, ConstantValue defaultValue)) { | 868 void f(DartType type, String name, ConstantValue defaultValue)) { |
852 FunctionData data = _memberList[function.memberIndex]; | 869 FunctionData data = _memberData[function.memberIndex]; |
853 data.forEachParameter(this, f); | 870 data.forEachParameter(this, f); |
854 } | 871 } |
855 | 872 |
856 @override | 873 @override |
857 Spannable getSpannable(MemberEntity member, ir.Node node) { | 874 Spannable getSpannable(MemberEntity member, ir.Node node) { |
858 return _getSpannable(member, node); | 875 return _getSpannable(member, node); |
859 } | 876 } |
860 | 877 |
861 @override | 878 @override |
862 ir.Member getMemberNode(MemberEntity member) { | 879 ir.Member getMemberNode(MemberEntity member) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 'KernelElementEnvironment.getTypeVariableBound'); | 961 'KernelElementEnvironment.getTypeVariableBound'); |
945 } | 962 } |
946 | 963 |
947 @override | 964 @override |
948 InterfaceType createInterfaceType( | 965 InterfaceType createInterfaceType( |
949 ClassEntity cls, List<DartType> typeArguments) { | 966 ClassEntity cls, List<DartType> typeArguments) { |
950 return new InterfaceType(cls, typeArguments); | 967 return new InterfaceType(cls, typeArguments); |
951 } | 968 } |
952 | 969 |
953 @override | 970 @override |
954 FunctionType getFunctionType(covariant KFunction function) { | 971 FunctionType getFunctionType(FunctionEntity function) { |
955 return elementMap._getFunctionType(function); | 972 return elementMap._getFunctionType(function); |
956 } | 973 } |
957 | 974 |
958 @override | 975 @override |
959 FunctionType getLocalFunctionType(covariant KLocalFunction function) { | 976 FunctionType getLocalFunctionType(covariant KLocalFunction function) { |
960 return function.functionType; | 977 return function.functionType; |
961 } | 978 } |
962 | 979 |
963 @override | 980 @override |
964 DartType getUnaliasedType(DartType type) => type; | 981 DartType getUnaliasedType(DartType type) => type; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 } | 1085 } |
1069 | 1086 |
1070 @override | 1087 @override |
1071 bool isDeferredLoadLibraryGetter(covariant KMember member) { | 1088 bool isDeferredLoadLibraryGetter(covariant KMember member) { |
1072 // TODO(redemption): Support these. | 1089 // TODO(redemption): Support these. |
1073 return false; | 1090 return false; |
1074 } | 1091 } |
1075 | 1092 |
1076 @override | 1093 @override |
1077 Iterable<ConstantValue> getMemberMetadata(covariant KMember member) { | 1094 Iterable<ConstantValue> getMemberMetadata(covariant KMember member) { |
1078 MemberData memberData = elementMap._memberList[member.memberIndex]; | 1095 MemberData memberData = elementMap._memberData[member.memberIndex]; |
1079 return memberData.getMetadata(elementMap); | 1096 return memberData.getMetadata(elementMap); |
1080 } | 1097 } |
1081 } | 1098 } |
1082 | 1099 |
1083 /// Visitor that converts kernel dart types into [DartType]. | 1100 /// Visitor that converts kernel dart types into [DartType]. |
1084 class DartTypeConverter extends ir.DartTypeVisitor<DartType> { | 1101 class DartTypeConverter extends ir.DartTypeVisitor<DartType> { |
1085 final KernelToElementMapBase elementMap; | 1102 final KernelToElementMapBase elementMap; |
1086 bool topLevel = true; | 1103 bool topLevel = true; |
1087 | 1104 |
1088 DartTypeConverter(this.elementMap); | 1105 DartTypeConverter(this.elementMap); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 | 1457 |
1441 @override | 1458 @override |
1442 ElementEnvironment get elementEnvironment => elementMap.elementEnvironment; | 1459 ElementEnvironment get elementEnvironment => elementMap.elementEnvironment; |
1443 | 1460 |
1444 @override | 1461 @override |
1445 CommonElements get commonElements => elementMap.commonElements; | 1462 CommonElements get commonElements => elementMap.commonElements; |
1446 | 1463 |
1447 @override | 1464 @override |
1448 native.NativeBehavior computeNativeFieldStoreBehavior( | 1465 native.NativeBehavior computeNativeFieldStoreBehavior( |
1449 covariant KField field) { | 1466 covariant KField field) { |
1450 ir.Field node = elementMap._memberList[field.memberIndex].node; | 1467 ir.Field node = elementMap._memberData[field.memberIndex].node; |
1451 return elementMap.getNativeBehaviorForFieldStore(node); | 1468 return elementMap.getNativeBehaviorForFieldStore(node); |
1452 } | 1469 } |
1453 | 1470 |
1454 @override | 1471 @override |
1455 native.NativeBehavior computeNativeFieldLoadBehavior(covariant KField field, | 1472 native.NativeBehavior computeNativeFieldLoadBehavior(covariant KField field, |
1456 {bool isJsInterop}) { | 1473 {bool isJsInterop}) { |
1457 ir.Field node = elementMap._memberList[field.memberIndex].node; | 1474 ir.Field node = elementMap._memberData[field.memberIndex].node; |
1458 return elementMap.getNativeBehaviorForFieldLoad(node, | 1475 return elementMap.getNativeBehaviorForFieldLoad(node, |
1459 isJsInterop: isJsInterop); | 1476 isJsInterop: isJsInterop); |
1460 } | 1477 } |
1461 | 1478 |
1462 @override | 1479 @override |
1463 native.NativeBehavior computeNativeMethodBehavior( | 1480 native.NativeBehavior computeNativeMethodBehavior( |
1464 covariant KFunction function, | 1481 covariant KFunction function, |
1465 {bool isJsInterop}) { | 1482 {bool isJsInterop}) { |
1466 ir.Member node = elementMap._memberList[function.memberIndex].node; | 1483 ir.Member node = elementMap._memberData[function.memberIndex].node; |
1467 return elementMap.getNativeBehaviorForMethod(node, | 1484 return elementMap.getNativeBehaviorForMethod(node, |
1468 isJsInterop: isJsInterop); | 1485 isJsInterop: isJsInterop); |
1469 } | 1486 } |
1470 | 1487 |
1471 @override | 1488 @override |
1472 bool isNativeMethod(covariant KFunction function) { | 1489 bool isNativeMethod(covariant KFunction function) { |
1473 if (!native.maybeEnableNative(function.library.canonicalUri)) return false; | 1490 if (!native.maybeEnableNative(function.library.canonicalUri)) return false; |
1474 ir.Member node = elementMap._memberList[function.memberIndex].node; | 1491 ir.Member node = elementMap._memberData[function.memberIndex].node; |
1475 return node.isExternal && | 1492 return node.isExternal && |
1476 !elementMap.isForeignLibrary(node.enclosingLibrary); | 1493 !elementMap.isForeignLibrary(node.enclosingLibrary); |
1477 } | 1494 } |
1478 | 1495 |
1479 @override | 1496 @override |
1480 bool isJsInteropMember(MemberEntity element) { | 1497 bool isJsInteropMember(MemberEntity element) { |
1481 // TODO(redemption): Compute this. | 1498 // TODO(redemption): Compute this. |
1482 return false; | 1499 return false; |
1483 } | 1500 } |
1484 } | 1501 } |
1485 | 1502 |
| 1503 class JsToFrontendMapImpl extends JsToFrontendMapBase |
| 1504 implements JsToFrontendMap { |
| 1505 final KernelToElementMapBase _frontend; |
| 1506 final KernelToElementMapBase _backend; |
| 1507 |
| 1508 JsToFrontendMapImpl(this._frontend, this._backend); |
| 1509 |
| 1510 LibraryEntity toBackendLibrary(covariant IndexedLibrary library) { |
| 1511 return _backend._libraryList[library.libraryIndex]; |
| 1512 } |
| 1513 |
| 1514 LibraryEntity toFrontendLibrary(covariant IndexedLibrary library) { |
| 1515 return _frontend._libraryList[library.libraryIndex]; |
| 1516 } |
| 1517 |
| 1518 ClassEntity toBackendClass(covariant IndexedClass cls) { |
| 1519 return _backend._classList[cls.classIndex]; |
| 1520 } |
| 1521 |
| 1522 ClassEntity toFrontendClass(covariant IndexedClass cls) { |
| 1523 return _frontend._classList[cls.classIndex]; |
| 1524 } |
| 1525 |
| 1526 MemberEntity toBackendMember(covariant IndexedMember member) { |
| 1527 return _backend._memberList[member.memberIndex]; |
| 1528 } |
| 1529 |
| 1530 MemberEntity toFrontendMember(covariant IndexedMember member) { |
| 1531 return _frontend._memberList[member.memberIndex]; |
| 1532 } |
| 1533 } |
| 1534 |
1486 class JsKernelToElementMap extends KernelToElementMapBase | 1535 class JsKernelToElementMap extends KernelToElementMapBase |
1487 with KernelToElementMapForBuildingMixin | 1536 with KernelToElementMapForBuildingMixin, JsElementCreatorMixin |
1488 implements KernelToWorldBuilder { | 1537 implements KernelToWorldBuilder { |
1489 final JsToFrontendMap _map; | 1538 JsToFrontendMap _jsToFrontendMap; |
1490 final ElementEnvironment _elementEnvironment; | |
1491 final CommonElements _commonElements; | |
1492 final KernelToElementMapForImpactImpl _elementMap; | |
1493 | 1539 |
1494 JsKernelToElementMap( | 1540 Map<ir.Library, JLibrary> _libraryMap = <ir.Library, JLibrary>{}; |
1495 DiagnosticReporter reporter, | 1541 Map<ir.Class, JClass> _classMap = <ir.Class, JClass>{}; |
1496 Environment environment, | 1542 Map<ir.TypeParameter, JTypeVariable> _typeVariableMap = |
1497 this._map, | 1543 <ir.TypeParameter, JTypeVariable>{}; |
1498 this._elementEnvironment, | 1544 Map<ir.Member, JConstructor> _constructorMap = <ir.Member, JConstructor>{}; |
1499 this._commonElements, | 1545 Map<ir.Procedure, JFunction> _methodMap = <ir.Procedure, JFunction>{}; |
1500 this._elementMap) | 1546 Map<ir.Field, JField> _fieldMap = <ir.Field, JField>{}; |
1501 : super(reporter, environment); | 1547 |
| 1548 JsKernelToElementMap(DiagnosticReporter reporter, Environment environment, |
| 1549 KernelToElementMapForImpactImpl _elementMap) |
| 1550 : super(reporter, environment) { |
| 1551 _jsToFrontendMap = new JsToFrontendMapImpl(_elementMap, this); |
| 1552 _env = _elementMap._env; |
| 1553 for (int libraryIndex = 0; |
| 1554 libraryIndex < _elementMap._libraryEnvs.length; |
| 1555 libraryIndex++) { |
| 1556 LibraryEnv env = _elementMap._libraryEnvs[libraryIndex]; |
| 1557 LibraryEntity oldLibrary = _elementMap._libraryList[libraryIndex]; |
| 1558 JLibrary newLibrary = createLibrary(oldLibrary); |
| 1559 _libraryMap[env.library] = newLibrary; |
| 1560 _libraryList.add(newLibrary); |
| 1561 _libraryEnvs.add(env); |
| 1562 } |
| 1563 for (int classIndex = 0; |
| 1564 classIndex < _elementMap._classEnvs.length; |
| 1565 classIndex++) { |
| 1566 ClassEnv env = _elementMap._classEnvs[classIndex]; |
| 1567 ClassEntity oldClass = _elementMap._classList[classIndex]; |
| 1568 IndexedLibrary oldLibrary = oldClass.library; |
| 1569 JLibrary newLibrary = _libraryList[oldLibrary.libraryIndex]; |
| 1570 JClass newClass = createClass(newLibrary, oldClass); |
| 1571 _classMap[env.cls] = newClass; |
| 1572 _classList.add(newClass); |
| 1573 _classEnvs.add(env); |
| 1574 } |
| 1575 for (int memberIndex = 0; |
| 1576 memberIndex < _elementMap._memberData.length; |
| 1577 memberIndex++) { |
| 1578 MemberData data = _elementMap._memberData[memberIndex]; |
| 1579 MemberEntity oldMember = _elementMap._memberList[memberIndex]; |
| 1580 IndexedLibrary oldLibrary = oldMember.library; |
| 1581 IndexedClass oldClass = oldMember.enclosingClass; |
| 1582 JLibrary newLibrary = _libraryList[oldLibrary.libraryIndex]; |
| 1583 JClass newClass = |
| 1584 oldClass != null ? _classList[oldClass.classIndex] : null; |
| 1585 JMember newMember = createMember(newLibrary, newClass, oldMember); |
| 1586 _memberList.add(newMember); |
| 1587 _memberData.add(data); |
| 1588 if (newMember.isField) { |
| 1589 _fieldMap[data.node] = newMember; |
| 1590 } else if (newMember.isConstructor) { |
| 1591 _constructorMap[data.node] = newMember; |
| 1592 } else { |
| 1593 _methodMap[data.node] = newMember; |
| 1594 } |
| 1595 } |
| 1596 } |
| 1597 |
| 1598 JsToFrontendMap get jsToFrontendMap => _jsToFrontendMap; |
1502 | 1599 |
1503 @override | 1600 @override |
1504 Spannable getSpannable(MemberEntity member, ir.Node node) { | 1601 Spannable getSpannable(MemberEntity member, ir.Node node) { |
1505 return _elementMap._getSpannable(_map.toFrontendMember(member), node); | 1602 return _getSpannable(member, node); |
1506 } | 1603 } |
1507 | 1604 |
1508 Iterable<LibraryEntity> get _libraries { | 1605 Iterable<LibraryEntity> get _libraries { |
1509 return _elementMap._libraries.map(_map.toBackendLibrary); | 1606 return _libraryMap.values; |
1510 } | 1607 } |
1511 | 1608 |
1512 @override | 1609 @override |
1513 LibraryEntity _getLibrary(ir.Library node, [LibraryEnv env]) { | 1610 LibraryEntity _getLibrary(ir.Library node, [LibraryEnv env]) { |
1514 return _map.toBackendLibrary(_elementMap.getLibrary(node)); | 1611 LibraryEntity library = _libraryMap[node]; |
| 1612 assert(library != null, "No library entity for $node"); |
| 1613 return library; |
1515 } | 1614 } |
1516 | 1615 |
1517 @override | 1616 @override |
1518 Local _getLocalFunction(ir.TreeNode node) { | 1617 Local _getLocalFunction(ir.TreeNode node) { |
1519 throw new UnsupportedError("JsKernelToElementMap.getLocalFunction"); | 1618 throw new UnsupportedError("JsKernelToElementMap.getLocalFunction"); |
1520 } | 1619 } |
1521 | 1620 |
1522 @override | 1621 @override |
1523 ClassEntity _getClass(ir.Class node, [ClassEnv env]) { | 1622 ClassEntity _getClass(ir.Class node, [ClassEnv env]) { |
1524 return _map.toBackendClass(_elementMap.getClass(node)); | 1623 ClassEntity cls = _classMap[node]; |
| 1624 assert(cls != null, "No class entity for $node"); |
| 1625 return cls; |
1525 } | 1626 } |
1526 | 1627 |
1527 @override | 1628 @override |
1528 TypeVariableEntity _getTypeVariable(ir.TypeParameter node) { | 1629 TypeVariableEntity _getTypeVariable(ir.TypeParameter node) { |
1529 throw new UnsupportedError("JsKernelToElementMap._getTypeVariable"); | 1630 throw new UnsupportedError("JsKernelToElementMap._getTypeVariable"); |
1530 } | 1631 } |
1531 | 1632 |
1532 @override | 1633 @override |
1533 FieldEntity _getField(ir.Field node) { | 1634 FieldEntity _getField(ir.Field node) { |
1534 return _map.toBackendMember(_elementMap.getField(node)); | 1635 FieldEntity field = _fieldMap[node]; |
| 1636 assert(field != null, "No field entity for $node"); |
| 1637 return field; |
1535 } | 1638 } |
1536 | 1639 |
1537 @override | 1640 @override |
1538 FunctionEntity _getMethod(ir.Procedure node) { | 1641 FunctionEntity _getMethod(ir.Procedure node) { |
1539 return _map.toBackendMember(_elementMap.getMethod(node)); | 1642 FunctionEntity function = _methodMap[node]; |
| 1643 assert(function != null, "No function entity for $node"); |
| 1644 return function; |
1540 } | 1645 } |
1541 | 1646 |
1542 @override | 1647 @override |
1543 ConstructorEntity _getConstructor(ir.Member node) { | 1648 ConstructorEntity _getConstructor(ir.Member node) { |
1544 return _map.toBackendMember(_elementMap.getConstructor(node)); | 1649 ConstructorEntity constructor = _constructorMap[node]; |
| 1650 assert(constructor != null, "No constructor entity for $node"); |
| 1651 return constructor; |
1545 } | 1652 } |
1546 | 1653 |
1547 @override | 1654 @override |
1548 ir.Member getMemberNode(MemberEntity member) { | 1655 ir.Member getMemberNode(MemberEntity member) { |
1549 return _elementMap._getMemberNode(_map.toFrontendMember(member)); | 1656 return _getMemberNode(member); |
1550 } | 1657 } |
1551 | 1658 |
1552 @override | 1659 @override |
1553 ir.Class getClassNode(ClassEntity cls) { | 1660 ir.Class getClassNode(ClassEntity cls) { |
1554 return _elementMap._getClassNode(_map.toFrontendClass(cls)); | 1661 return _getClassNode(cls); |
1555 } | 1662 } |
1556 | 1663 |
1557 @override | 1664 @override |
1558 InterfaceType createInterfaceType( | |
1559 ir.Class cls, List<ir.DartType> typeArguments) { | |
1560 return _map | |
1561 .toBackendType(_elementMap.createInterfaceType(cls, typeArguments)); | |
1562 } | |
1563 | |
1564 @override | |
1565 InterfaceType getInterfaceType(ir.InterfaceType type) { | |
1566 return _map.toBackendType(_elementMap.getInterfaceType(type)); | |
1567 } | |
1568 | |
1569 @override | |
1570 List<DartType> getDartTypes(List<ir.DartType> types) { | |
1571 return _elementMap.getDartTypes(types).map(_map.toBackendType).toList(); | |
1572 } | |
1573 | |
1574 @override | |
1575 FunctionType getFunctionType(ir.FunctionNode node) { | |
1576 return _map.toBackendType(_elementMap.getFunctionType(node)); | |
1577 } | |
1578 | |
1579 @override | |
1580 DartType getDartType(ir.DartType type) { | |
1581 return _map.toBackendType(_elementMap.getDartType(type)); | |
1582 } | |
1583 | |
1584 @override | |
1585 ElementEnvironment get elementEnvironment { | |
1586 return _elementEnvironment; | |
1587 } | |
1588 | |
1589 @override | |
1590 CommonElements get commonElements { | |
1591 return _commonElements; | |
1592 } | |
1593 | |
1594 @override | |
1595 ConstantValue computeConstantValue(ConstantExpression constant, | |
1596 {bool requireConstant: true}) { | |
1597 throw new UnsupportedError("JsKernelToElementMap.computeConstantValue"); | |
1598 } | |
1599 | |
1600 @override | |
1601 DiagnosticReporter get reporter { | |
1602 return _elementMap.reporter; | |
1603 } | |
1604 | |
1605 @override | |
1606 ConstantValue getFieldConstantValue(ir.Field field) { | 1665 ConstantValue getFieldConstantValue(ir.Field field) { |
1607 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); | 1666 throw new UnsupportedError("JsKernelToElementMap.getFieldConstantValue"); |
1608 } | 1667 } |
1609 | 1668 |
1610 @override | 1669 @override |
1611 void forEachParameter(FunctionEntity function, | 1670 void forEachParameter(FunctionEntity function, |
1612 void f(DartType type, String name, ConstantValue defaultValue)) { | 1671 void f(DartType type, String name, ConstantValue defaultValue)) { |
1613 throw new UnsupportedError("JsKernelToElementMap.forEachParameter"); | 1672 throw new UnsupportedError("JsKernelToElementMap.forEachParameter"); |
1614 } | 1673 } |
1615 | 1674 |
1616 @override | 1675 @override |
1617 ConstantValue getConstantFieldInitializer(FieldEntity field) { | 1676 ConstantValue getConstantFieldInitializer(FieldEntity field) { |
1618 throw new UnsupportedError( | 1677 throw new UnsupportedError( |
1619 "JsKernelToElementMap.getConstantFieldInitializer"); | 1678 "JsKernelToElementMap.getConstantFieldInitializer"); |
1620 } | 1679 } |
1621 | 1680 |
1622 @override | 1681 @override |
1623 bool hasConstantFieldInitializer(FieldEntity field) { | 1682 bool hasConstantFieldInitializer(FieldEntity field) { |
1624 throw new UnsupportedError( | 1683 throw new UnsupportedError( |
1625 "JsKernelToElementMap.hasConstantFieldInitializer"); | 1684 "JsKernelToElementMap.hasConstantFieldInitializer"); |
1626 } | 1685 } |
1627 } | 1686 } |
OLD | NEW |