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

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

Issue 2991993002: Reapply 47ecf72 after it was reverted in e431e93e872d9a1c97a5177ebb09d5416f1d659a. (Closed)
Patch Set: Created 3 years, 4 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_procedure_builder; 5 library fasta.kernel_procedure_builder;
6 6
7 import 'package:kernel/ast.dart' 7 import 'package:kernel/ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 AsyncMarker, 10 AsyncMarker,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 abstract class KernelFunctionBuilder 75 abstract class KernelFunctionBuilder
76 extends ProcedureBuilder<KernelTypeBuilder> { 76 extends ProcedureBuilder<KernelTypeBuilder> {
77 final String nativeMethodName; 77 final String nativeMethodName;
78 78
79 FunctionNode function; 79 FunctionNode function;
80 80
81 Statement actualBody; 81 Statement actualBody;
82 82
83 KernelFunctionBuilder( 83 KernelFunctionBuilder(
84 String documentationComment,
84 List<MetadataBuilder> metadata, 85 List<MetadataBuilder> metadata,
85 int modifiers, 86 int modifiers,
86 KernelTypeBuilder returnType, 87 KernelTypeBuilder returnType,
87 String name, 88 String name,
88 List<TypeVariableBuilder> typeVariables, 89 List<TypeVariableBuilder> typeVariables,
89 List<FormalParameterBuilder> formals, 90 List<FormalParameterBuilder> formals,
90 KernelLibraryBuilder compilationUnit, 91 KernelLibraryBuilder compilationUnit,
91 int charOffset, 92 int charOffset,
92 this.nativeMethodName) 93 this.nativeMethodName)
93 : super(metadata, modifiers, returnType, name, typeVariables, formals, 94 : super(documentationComment, metadata, modifiers, returnType, name,
94 compilationUnit, charOffset); 95 typeVariables, formals, compilationUnit, charOffset);
95 96
96 void set body(Statement newBody) { 97 void set body(Statement newBody) {
97 if (newBody != null) { 98 if (newBody != null) {
98 if (isAbstract) { 99 if (isAbstract) {
99 return internalProblem(messageInternalProblemBodyOnAbstractMethod, 100 return internalProblem(messageInternalProblemBodyOnAbstractMethod,
100 newBody.fileOffset, fileUri); 101 newBody.fileOffset, fileUri);
101 } 102 }
102 if (isExternal) { 103 if (isExternal) {
103 return library.addCompileTimeError( 104 return library.addCompileTimeError(
104 messageExternalMethodWithBody, newBody.fileOffset, fileUri); 105 messageExternalMethodWithBody, newBody.fileOffset, fileUri);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 201
201 class KernelProcedureBuilder extends KernelFunctionBuilder { 202 class KernelProcedureBuilder extends KernelFunctionBuilder {
202 final KernelProcedure procedure; 203 final KernelProcedure procedure;
203 final int charOpenParenOffset; 204 final int charOpenParenOffset;
204 205
205 AsyncMarker actualAsyncModifier = AsyncMarker.Sync; 206 AsyncMarker actualAsyncModifier = AsyncMarker.Sync;
206 207
207 final ConstructorReferenceBuilder redirectionTarget; 208 final ConstructorReferenceBuilder redirectionTarget;
208 209
209 KernelProcedureBuilder( 210 KernelProcedureBuilder(
211 String documentationComment,
210 List<MetadataBuilder> metadata, 212 List<MetadataBuilder> metadata,
211 int modifiers, 213 int modifiers,
212 KernelTypeBuilder returnType, 214 KernelTypeBuilder returnType,
213 String name, 215 String name,
214 List<TypeVariableBuilder> typeVariables, 216 List<TypeVariableBuilder> typeVariables,
215 List<FormalParameterBuilder> formals, 217 List<FormalParameterBuilder> formals,
216 ProcedureKind kind, 218 ProcedureKind kind,
217 KernelLibraryBuilder compilationUnit, 219 KernelLibraryBuilder compilationUnit,
218 int charOffset, 220 int charOffset,
219 this.charOpenParenOffset, 221 this.charOpenParenOffset,
220 int charEndOffset, 222 int charEndOffset,
221 [String nativeMethodName, 223 [String nativeMethodName,
222 this.redirectionTarget]) 224 this.redirectionTarget])
223 : procedure = new KernelProcedure(null, kind, null, returnType == null, 225 : procedure = new KernelProcedure(null, kind, null, returnType == null,
224 fileUri: compilationUnit?.relativeFileUri) 226 fileUri: compilationUnit?.relativeFileUri)
225 ..fileOffset = charOffset 227 ..fileOffset = charOffset
226 ..fileEndOffset = charEndOffset, 228 ..fileEndOffset = charEndOffset,
227 super(metadata, modifiers, returnType, name, typeVariables, formals, 229 super(
228 compilationUnit, charOffset, nativeMethodName); 230 documentationComment,
231 metadata,
232 modifiers,
233 returnType,
234 name,
235 typeVariables,
236 formals,
237 compilationUnit,
238 charOffset,
239 nativeMethodName);
229 240
230 ProcedureKind get kind => procedure.kind; 241 ProcedureKind get kind => procedure.kind;
231 242
232 AsyncMarker get asyncModifier => actualAsyncModifier; 243 AsyncMarker get asyncModifier => actualAsyncModifier;
233 244
234 Statement get body { 245 Statement get body {
235 if (actualBody == null && 246 if (actualBody == null &&
236 redirectionTarget == null && 247 redirectionTarget == null &&
237 !isAbstract && 248 !isAbstract &&
238 !isExternal) { 249 !isExternal) {
(...skipping 30 matching lines...) Expand all
269 if (procedure.name == null) { 280 if (procedure.name == null) {
270 procedure.function = buildFunction(library); 281 procedure.function = buildFunction(library);
271 procedure.function.parent = procedure; 282 procedure.function.parent = procedure;
272 procedure.function.fileOffset = charOpenParenOffset; 283 procedure.function.fileOffset = charOpenParenOffset;
273 procedure.function.fileEndOffset = procedure.fileEndOffset; 284 procedure.function.fileEndOffset = procedure.fileEndOffset;
274 procedure.isAbstract = isAbstract; 285 procedure.isAbstract = isAbstract;
275 procedure.isStatic = isStatic; 286 procedure.isStatic = isStatic;
276 procedure.isExternal = isExternal; 287 procedure.isExternal = isExternal;
277 procedure.isConst = isConst; 288 procedure.isConst = isConst;
278 procedure.name = new Name(name, library.target); 289 procedure.name = new Name(name, library.target);
290 procedure.documentationComment = documentationComment;
279 } 291 }
280 if (isEligibleForTopLevelInference) { 292 if (isEligibleForTopLevelInference) {
281 library.loader.typeInferenceEngine.recordMember(procedure); 293 library.loader.typeInferenceEngine.recordMember(procedure);
282 } 294 }
283 return procedure; 295 return procedure;
284 } 296 }
285 297
286 Procedure get target => procedure; 298 Procedure get target => procedure;
287 299
288 @override 300 @override
(...skipping 14 matching lines...) Expand all
303 315
304 final int charOpenParenOffset; 316 final int charOpenParenOffset;
305 317
306 bool hasMovedSuperInitializer = false; 318 bool hasMovedSuperInitializer = false;
307 319
308 SuperInitializer superInitializer; 320 SuperInitializer superInitializer;
309 321
310 RedirectingInitializer redirectingInitializer; 322 RedirectingInitializer redirectingInitializer;
311 323
312 KernelConstructorBuilder( 324 KernelConstructorBuilder(
325 String documentationComment,
313 List<MetadataBuilder> metadata, 326 List<MetadataBuilder> metadata,
314 int modifiers, 327 int modifiers,
315 KernelTypeBuilder returnType, 328 KernelTypeBuilder returnType,
316 String name, 329 String name,
317 List<TypeVariableBuilder> typeVariables, 330 List<TypeVariableBuilder> typeVariables,
318 List<FormalParameterBuilder> formals, 331 List<FormalParameterBuilder> formals,
319 KernelLibraryBuilder compilationUnit, 332 KernelLibraryBuilder compilationUnit,
320 int charOffset, 333 int charOffset,
321 this.charOpenParenOffset, 334 this.charOpenParenOffset,
322 int charEndOffset, 335 int charEndOffset,
323 [String nativeMethodName]) 336 [String nativeMethodName])
324 : constructor = new Constructor(null) 337 : constructor = new Constructor(null)
325 ..fileOffset = charOffset 338 ..fileOffset = charOffset
326 ..fileEndOffset = charEndOffset, 339 ..fileEndOffset = charEndOffset,
327 super(metadata, modifiers, returnType, name, typeVariables, formals, 340 super(
328 compilationUnit, charOffset, nativeMethodName); 341 documentationComment,
342 metadata,
343 modifiers,
344 returnType,
345 name,
346 typeVariables,
347 formals,
348 compilationUnit,
349 charOffset,
350 nativeMethodName);
329 351
330 bool get isInstanceMember => false; 352 bool get isInstanceMember => false;
331 353
332 bool get isConstructor => true; 354 bool get isConstructor => true;
333 355
334 AsyncMarker get asyncModifier => AsyncMarker.Sync; 356 AsyncMarker get asyncModifier => AsyncMarker.Sync;
335 357
336 ProcedureKind get kind => null; 358 ProcedureKind get kind => null;
337 359
338 bool get isRedirectingGenerativeConstructor { 360 bool get isRedirectingGenerativeConstructor {
339 return isRedirectingGenerativeConstructorImplementation(constructor); 361 return isRedirectingGenerativeConstructorImplementation(constructor);
340 } 362 }
341 363
342 Constructor build(SourceLibraryBuilder library) { 364 Constructor build(SourceLibraryBuilder library) {
343 if (constructor.name == null) { 365 if (constructor.name == null) {
344 constructor.function = buildFunction(library); 366 constructor.function = buildFunction(library);
345 constructor.function.parent = constructor; 367 constructor.function.parent = constructor;
346 constructor.function.fileOffset = charOpenParenOffset; 368 constructor.function.fileOffset = charOpenParenOffset;
347 constructor.function.fileEndOffset = constructor.fileEndOffset; 369 constructor.function.fileEndOffset = constructor.fileEndOffset;
348 constructor.isConst = isConst; 370 constructor.isConst = isConst;
349 constructor.isExternal = isExternal; 371 constructor.isExternal = isExternal;
350 constructor.name = new Name(name, library.target); 372 constructor.name = new Name(name, library.target);
373 constructor.documentationComment = documentationComment;
351 } 374 }
352 return constructor; 375 return constructor;
353 } 376 }
354 377
355 FunctionNode buildFunction(LibraryBuilder library) { 378 FunctionNode buildFunction(LibraryBuilder library) {
356 // TODO(ahe): Should complain if another type is explicitly set. 379 // TODO(ahe): Should complain if another type is explicitly set.
357 return super.buildFunction(library)..returnType = const VoidType(); 380 return super.buildFunction(library)..returnType = const VoidType();
358 } 381 }
359 382
360 Constructor get target => constructor; 383 Constructor get target => constructor;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 435 }
413 } 436 }
414 initializers.add(initializer..parent = constructor); 437 initializers.add(initializer..parent = constructor);
415 initializers.add(superInitializer); 438 initializers.add(superInitializer);
416 return; 439 return;
417 } 440 }
418 initializers.add(initializer); 441 initializers.add(initializer);
419 initializer.parent = constructor; 442 initializer.parent = constructor;
420 } 443 }
421 } 444 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698