Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: pkg/compiler/lib/src/resolution/class_members.dart

Issue 2031293002: Don't crash when tree shaking is disabled (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/serialization/model_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.resolution.compute_members; 5 library dart2js.resolution.compute_members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Identifiers, Names; 8 import '../common/names.dart' show Identifiers, Names;
9 import '../common/resolution.dart' show Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 classMembers, interfaceMembers); 869 classMembers, interfaceMembers);
870 } 870 }
871 871
872 static Iterable<String> _EMPTY_MEMBERS_NAMES = const <String>[]; 872 static Iterable<String> _EMPTY_MEMBERS_NAMES = const <String>[];
873 873
874 /// Compute the members by the name [name] for this class. [names] collects 874 /// Compute the members by the name [name] for this class. [names] collects
875 /// the set of possible variations of [name], including getter, setter and 875 /// the set of possible variations of [name], including getter, setter and
876 /// and private names. 876 /// and private names.
877 void computeClassMember( 877 void computeClassMember(
878 Resolution resolution, String name, Setlet<Name> names) { 878 Resolution resolution, String name, Setlet<Name> names) {
879 // TODO(johnniwinther): Should we assert that the class has been resolved
880 // instead?
881 ensureResolved(resolution);
879 if (isMemberComputed(name)) return; 882 if (isMemberComputed(name)) return;
880 if (Name.isPrivateName(name)) { 883 if (Name.isPrivateName(name)) {
881 names 884 names
882 ..add(new Name(name, library)) 885 ..add(new Name(name, library))
883 ..add(new Name(name, library, isSetter: true)); 886 ..add(new Name(name, library, isSetter: true));
884 } 887 }
885 MembersCreator creator = _prepareCreator(resolution); 888 MembersCreator creator = _prepareCreator(resolution);
886 creator.computeMembersByName(name, names); 889 creator.computeMembersByName(name, names);
887 if (computedMemberNames == null) { 890 if (computedMemberNames == null) {
888 computedMemberNames = _EMPTY_MEMBERS_NAMES; 891 computedMemberNames = _EMPTY_MEMBERS_NAMES;
889 } 892 }
890 if (name != Identifiers.call) { 893 if (name != Identifiers.call) {
891 Setlet<String> set; 894 Setlet<String> set;
892 if (identical(computedMemberNames, _EMPTY_MEMBERS_NAMES)) { 895 if (identical(computedMemberNames, _EMPTY_MEMBERS_NAMES)) {
893 computedMemberNames = set = new Setlet<String>(); 896 computedMemberNames = set = new Setlet<String>();
894 } else { 897 } else {
895 set = computedMemberNames; 898 set = computedMemberNames;
896 } 899 }
897 set.add(name); 900 set.add(name);
898 } 901 }
899 } 902 }
900 903
901 void computeAllClassMembers(Resolution resolution) { 904 void computeAllClassMembers(Resolution resolution) {
905 // TODO(johnniwinther): Should we assert that the class has been resolved
906 // instead?
907 ensureResolved(resolution);
902 if (areAllMembersComputed()) return; 908 if (areAllMembersComputed()) return;
903 MembersCreator creator = _prepareCreator(resolution); 909 MembersCreator creator = _prepareCreator(resolution);
904 creator.computeAllMembers(); 910 creator.computeAllMembers();
905 computedMemberNames = null; 911 computedMemberNames = null;
906 assert(invariant(this, areAllMembersComputed())); 912 assert(invariant(this, areAllMembersComputed()));
907 } 913 }
908 914
909 bool areAllMembersComputed() { 915 bool areAllMembersComputed() {
910 return computedMemberNames == null && classMembers != null; 916 return computedMemberNames == null && classMembers != null;
911 } 917 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 message: "Members have not been fully computed for $this.")); 952 message: "Members have not been fully computed for $this."));
947 if (interfaceMembersAreClassMembers) { 953 if (interfaceMembersAreClassMembers) {
948 classMembers.forEach((_, member) { 954 classMembers.forEach((_, member) {
949 if (!member.isStatic) f(member); 955 if (!member.isStatic) f(member);
950 }); 956 });
951 } else { 957 } else {
952 interfaceMembers.forEach((_, member) => f(member)); 958 interfaceMembers.forEach((_, member) => f(member));
953 } 959 }
954 } 960 }
955 } 961 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/serialization/model_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698