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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_field_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_field_builder; 5 library fasta.kernel_field_builder;
6 6
7 import 'package:kernel/ast.dart' 7 import 'package:kernel/ast.dart'
8 show DartType, Expression, Field, Name, NullLiteral; 8 show DartType, Expression, Field, Name, NullLiteral;
9 9
10 import '../../scanner/token.dart' show Token; 10 import '../../scanner/token.dart' show Token;
(...skipping 19 matching lines...) Expand all
30 import 'kernel_shadow_ast.dart' show KernelField; 30 import 'kernel_shadow_ast.dart' show KernelField;
31 31
32 class KernelFieldBuilder extends FieldBuilder<Expression> { 32 class KernelFieldBuilder extends FieldBuilder<Expression> {
33 final KernelField field; 33 final KernelField field;
34 final List<MetadataBuilder> metadata; 34 final List<MetadataBuilder> metadata;
35 final KernelTypeBuilder type; 35 final KernelTypeBuilder type;
36 final Token initializerTokenForInference; 36 final Token initializerTokenForInference;
37 final bool hasInitializer; 37 final bool hasInitializer;
38 38
39 KernelFieldBuilder( 39 KernelFieldBuilder(
40 String documentationComment,
40 this.metadata, 41 this.metadata,
41 this.type, 42 this.type,
42 String name, 43 String name,
43 int modifiers, 44 int modifiers,
44 Builder compilationUnit, 45 Builder compilationUnit,
45 int charOffset, 46 int charOffset,
46 this.initializerTokenForInference, 47 this.initializerTokenForInference,
47 this.hasInitializer) 48 this.hasInitializer)
48 : field = new KernelField(null, fileUri: compilationUnit?.relativeFileUri) 49 : field = new KernelField(null, fileUri: compilationUnit?.relativeFileUri)
49 ..fileOffset = charOffset, 50 ..fileOffset = charOffset,
50 super(name, modifiers, compilationUnit, charOffset); 51 super(
52 documentationComment, name, modifiers, compilationUnit, charOffset);
51 53
52 void set initializer(Expression value) { 54 void set initializer(Expression value) {
53 if (!hasInitializer && value is! NullLiteral && !isConst && !isFinal) { 55 if (!hasInitializer && value is! NullLiteral && !isConst && !isFinal) {
54 internalProblem( 56 internalProblem(
55 messageInternalProblemAlreadyInitialized, charOffset, fileUri); 57 messageInternalProblemAlreadyInitialized, charOffset, fileUri);
56 } 58 }
57 field.initializer = value..parent = field; 59 field.initializer = value..parent = field;
58 } 60 }
59 61
60 bool get isEligibleForInference => 62 bool get isEligibleForInference =>
61 type == null && (hasInitializer || isInstanceMember); 63 type == null && (hasInitializer || isInstanceMember);
62 64
63 Field build(SourceLibraryBuilder library) { 65 Field build(SourceLibraryBuilder library) {
66 field.documentationComment = documentationComment;
64 field.name ??= new Name(name, library.target); 67 field.name ??= new Name(name, library.target);
65 if (type != null) { 68 if (type != null) {
66 field.type = type.build(library); 69 field.type = type.build(library);
67 } 70 }
68 bool isInstanceMember = !isStatic && !isTopLevel; 71 bool isInstanceMember = !isStatic && !isTopLevel;
69 field 72 field
70 ..isFinal = isFinal 73 ..isFinal = isFinal
71 ..isConst = isConst 74 ..isConst = isConst
72 ..hasImplicitGetter = isInstanceMember 75 ..hasImplicitGetter = isInstanceMember
73 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal 76 ..hasImplicitSetter = isInstanceMember && !isConst && !isFinal
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 113 }
111 } 114 }
112 } 115 }
113 116
114 @override 117 @override
115 DartType get builtType => field.type; 118 DartType get builtType => field.type;
116 119
117 @override 120 @override
118 bool get hasImplicitType => type == null; 121 bool get hasImplicitType => type == null;
119 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698