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

Side by Side Diff: pkg/front_end/lib/src/fasta/builder/library_builder.dart

Issue 2788913002: Prepare for separate setter scope. (Closed)
Patch Set: Address comments. Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.library_builder; 5 library fasta.library_builder;
6 6
7 import '../combinator.dart' show Combinator; 7 import '../combinator.dart' show Combinator;
8 8
9 import '../errors.dart' show InputError, internalError, printUnexpected; 9 import '../errors.dart' show InputError, internalError, printUnexpected;
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 /// 101 ///
102 /// If [constructorName] is null or the empty string, it's assumed to be an 102 /// If [constructorName] is null or the empty string, it's assumed to be an
103 /// unnamed constructor. 103 /// unnamed constructor.
104 Builder getConstructor(String className, 104 Builder getConstructor(String className,
105 {String constructorName, bool isPrivate: false}) { 105 {String constructorName, bool isPrivate: false}) {
106 constructorName ??= ""; 106 constructorName ??= "";
107 Builder cls = (isPrivate ? members : exports)[className]; 107 Builder cls = (isPrivate ? members : exports)[className];
108 if (cls is ClassBuilder) { 108 if (cls is ClassBuilder) {
109 // TODO(ahe): This code is similar to code in `endNewExpression` in 109 // TODO(ahe): This code is similar to code in `endNewExpression` in
110 // `body_builder.dart`, try to share it. 110 // `body_builder.dart`, try to share it.
111 Builder constructor = cls.findConstructorOrFactory(constructorName); 111 Builder constructor =
112 cls.findConstructorOrFactory(constructorName, -1, null);
112 if (constructor == null) { 113 if (constructor == null) {
113 // Fall-through to internal error below. 114 // Fall-through to internal error below.
114 } else if (constructor.isConstructor) { 115 } else if (constructor.isConstructor) {
115 if (!cls.isAbstract) { 116 if (!cls.isAbstract) {
116 return constructor; 117 return constructor;
117 } 118 }
118 } else if (constructor.isFactory) { 119 } else if (constructor.isFactory) {
119 return constructor; 120 return constructor;
120 } 121 }
121 } 122 }
122 throw internalError("Internal error: No constructor named" 123 throw internalError("Internal error: No constructor named"
123 " '$className::$constructorName' in '$uri'."); 124 " '$className::$constructorName' in '$uri'.");
124 } 125 }
125 126
126 int finishTypeVariables(ClassBuilder object) => 0; 127 int finishTypeVariables(ClassBuilder object) => 0;
127 128
128 void becomeCoreLibrary(dynamicType, voidType) { 129 void becomeCoreLibrary(dynamicType, voidType) {
129 addBuilder("dynamic", 130 addBuilder("dynamic",
130 new DynamicTypeBuilder<T, dynamic>(dynamicType, this, -1), -1); 131 new DynamicTypeBuilder<T, dynamic>(dynamicType, this, -1), -1);
131 addBuilder("void", new VoidTypeBuilder<T, dynamic>(voidType, this, -1), -1); 132 addBuilder("void", new VoidTypeBuilder<T, dynamic>(voidType, this, -1), -1);
132 } 133 }
134
135 void forEach(void f(String name, Builder builder)) {
136 members.forEach(f);
137 }
138
139 /// Don't use for scope lookup. Only use when an element is known to exist
140 /// (and not a setter).
141 Builder operator [](String name) {
142 return members[name] ?? internalError("Not found: '$name'.");
143 }
144
145 Builder lookup(String name, int charOffset, Uri fileUri) {
146 return members[name];
147 }
133 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698