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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart

Issue 2721623002: Let parser handle factory modifiers. (Closed)
Patch Set: Handle factory modifiers correctly in dart2js. Created 3 years, 9 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.kernel_library_builder; 5 library fasta.kernel_library_builder;
6 6
7 import 'package:kernel/ast.dart'; 7 import 'package:kernel/ast.dart';
8 8
9 import 'package:kernel/clone.dart' show 9 import 'package:kernel/clone.dart' show
10 CloneVisitor; 10 CloneVisitor;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 procedure = new KernelProcedureBuilder(metadata, modifiers, returnType, 160 procedure = new KernelProcedureBuilder(metadata, modifiers, returnType,
161 name, typeVariables, formals, asyncModifier, kind, this, charOffset, 161 name, typeVariables, formals, asyncModifier, kind, this, charOffset,
162 nativeMethodName); 162 nativeMethodName);
163 } 163 }
164 addBuilder(name, procedure, charOffset); 164 addBuilder(name, procedure, charOffset);
165 if (nativeMethodName != null) { 165 if (nativeMethodName != null) {
166 addNativeMethod(procedure); 166 addNativeMethod(procedure);
167 } 167 }
168 } 168 }
169 169
170 void addFactoryMethod(List<MetadataBuilder> metadata, 170 void addFactoryMethod(List<MetadataBuilder> metadata, int modifiers,
171 ConstructorReferenceBuilder constructorName, 171 ConstructorReferenceBuilder constructorName,
172 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier, 172 List<FormalParameterBuilder> formals, AsyncMarker asyncModifier,
173 ConstructorReferenceBuilder redirectionTarget, int charOffset, 173 ConstructorReferenceBuilder redirectionTarget, int charOffset,
174 String nativeMethodName) { 174 String nativeMethodName) {
175 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`. 175 // Nested declaration began in `OutlineBuilder.beginFactoryMethod`.
176 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration = 176 DeclarationBuilder<KernelTypeBuilder> factoryDeclaration =
177 endNestedDeclaration(); 177 endNestedDeclaration();
178 String name = constructorName.name; 178 String name = constructorName.name;
179 int index = name.indexOf("."); 179 int index = name.indexOf(".");
180 name = index == -1 ? "" : name.substring(index + 1); 180 name = index == -1 ? "" : name.substring(index + 1);
181 assert(constructorName.suffix == null); 181 assert(constructorName.suffix == null);
182 KernelProcedureBuilder procedure = new KernelProcedureBuilder(metadata, 182 KernelProcedureBuilder procedure = new KernelProcedureBuilder(metadata,
183 staticMask, null, name, <TypeVariableBuilder>[], formals, asyncModifier, 183 staticMask | modifiers, null, name, <TypeVariableBuilder>[], formals,
184 ProcedureKind.Factory, this, charOffset, nativeMethodName, 184 asyncModifier, ProcedureKind.Factory, this, charOffset,
185 redirectionTarget); 185 nativeMethodName, redirectionTarget);
186 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration); 186 currentDeclaration.addFactoryDeclaration(procedure, factoryDeclaration);
187 addBuilder(name, procedure, charOffset); 187 addBuilder(name, procedure, charOffset);
188 if (nativeMethodName != null) { 188 if (nativeMethodName != null) {
189 addNativeMethod(procedure); 189 addNativeMethod(procedure);
190 } 190 }
191 } 191 }
192 192
193 void addEnum(List<MetadataBuilder> metadata, String name, 193 void addEnum(List<MetadataBuilder> metadata, String name,
194 List<String> constants, int charOffset) { 194 List<String> constants, int charOffset) {
195 addBuilder(name, 195 addBuilder(name,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 } 357 }
358 358
359 bool isConstructorName(String name, String className) { 359 bool isConstructorName(String name, String className) {
360 if (name.startsWith(className)) { 360 if (name.startsWith(className)) {
361 if (name.length == className.length) return true; 361 if (name.length == className.length) return true;
362 if (name.startsWith(".", className.length)) return true; 362 if (name.startsWith(".", className.length)) return true;
363 } 363 }
364 return false; 364 return false;
365 } 365 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698