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

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

Issue 2913743003: Change the approach of front_end top level inference to match the spec. (Closed)
Patch Set: Created 3 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
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.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9 9
10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional;
11 11
12 import '../parser/identifier_context.dart' show IdentifierContext; 12 import '../parser/identifier_context.dart' show IdentifierContext;
13 13
14 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'; 14 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
15 15
16 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; 16 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
17 17
18 import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart'
19 show FieldNode;
20
21 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' 18 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'
22 show TypeInferrer; 19 show TypeInferrer;
23 20
24 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' 21 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'
25 show TypePromoter; 22 show TypePromoter;
26 23
27 import 'package:kernel/ast.dart'; 24 import 'package:kernel/ast.dart';
28 25
29 import 'package:kernel/clone.dart' show CloneVisitor; 26 import 'package:kernel/clone.dart' show CloneVisitor;
30 27
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 final bool enableNative; 84 final bool enableNative;
88 85
89 @override 86 @override
90 final Uri uri; 87 final Uri uri;
91 88
92 final TypeInferrer _typeInferrer; 89 final TypeInferrer _typeInferrer;
93 90
94 @override 91 @override
95 final TypePromoter<Expression, VariableDeclaration> typePromoter; 92 final TypePromoter<Expression, VariableDeclaration> typePromoter;
96 93
97 /// If not `null`, dependencies on fields are accumulated into this list.
98 ///
99 /// If `null`, no dependency information is recorded.
100 final List<FieldNode> fieldDependencies;
101
102 /// Only used when [member] is a constructor. It tracks if an implicit super 94 /// Only used when [member] is a constructor. It tracks if an implicit super
103 /// initializer is needed. 95 /// initializer is needed.
104 /// 96 ///
105 /// An implicit super initializer isn't needed 97 /// An implicit super initializer isn't needed
106 /// 98 ///
107 /// 1. if the current class is Object, 99 /// 1. if the current class is Object,
108 /// 2. if there is an explicit super initializer, 100 /// 2. if there is an explicit super initializer,
109 /// 3. if there is a redirecting (this) initializer, or 101 /// 3. if there is a redirecting (this) initializer, or
110 /// 4. if a compile-time error prevented us from generating code for an 102 /// 4. if a compile-time error prevented us from generating code for an
111 /// initializer. This avoids cascading errors. 103 /// initializer. This avoids cascading errors.
(...skipping 28 matching lines...) Expand all
140 BodyBuilder( 132 BodyBuilder(
141 KernelLibraryBuilder library, 133 KernelLibraryBuilder library,
142 this.member, 134 this.member,
143 Scope scope, 135 Scope scope,
144 this.formalParameterScope, 136 this.formalParameterScope,
145 this.hierarchy, 137 this.hierarchy,
146 this.coreTypes, 138 this.coreTypes,
147 this.classBuilder, 139 this.classBuilder,
148 this.isInstanceMember, 140 this.isInstanceMember,
149 this.uri, 141 this.uri,
150 this._typeInferrer, 142 this._typeInferrer)
151 {this.fieldDependencies})
152 : enclosingScope = scope, 143 : enclosingScope = scope,
153 library = library, 144 library = library,
154 enableNative = (library.uri.scheme == "dart" || library.isPatch), 145 enableNative = (library.uri.scheme == "dart" || library.isPatch),
155 needsImplicitSuperInitializer = 146 needsImplicitSuperInitializer =
156 coreTypes.objectClass != classBuilder?.cls, 147 coreTypes.objectClass != classBuilder?.cls,
157 typePromoter = _typeInferrer.typePromoter, 148 typePromoter = _typeInferrer.typePromoter,
158 super(scope); 149 super(scope);
159 150
160 bool get hasParserError => recoverableErrors.isNotEmpty; 151 bool get hasParserError => recoverableErrors.isNotEmpty;
161 152
(...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2773 fileUri: message.uri); 2764 fileUri: message.uri);
2774 } 2765 }
2775 2766
2776 @override 2767 @override
2777 void debugEvent(String name) { 2768 void debugEvent(String name) {
2778 // printEvent(name); 2769 // printEvent(name);
2779 } 2770 }
2780 2771
2781 @override 2772 @override
2782 StaticGet makeStaticGet(Member readTarget, Token token) { 2773 StaticGet makeStaticGet(Member readTarget, Token token) {
2783 // TODO(paulberry): only record the dependencies mandated by the top level
2784 // type inference spec.
2785 if (fieldDependencies != null && readTarget is KernelField) {
2786 var fieldNode = _typeInferrer.getFieldNodeForReadTarget(readTarget);
2787 if (fieldNode != null) {
2788 fieldDependencies.add(fieldNode);
2789 }
2790 }
2791 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); 2774 return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token);
2792 } 2775 }
2793 } 2776 }
2794 2777
2795 class Identifier { 2778 class Identifier {
2796 final Token token; 2779 final Token token;
2797 String get name => token.lexeme; 2780 String get name => token.lexeme;
2798 2781
2799 Identifier(this.token); 2782 Identifier(this.token);
2800 2783
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 if (starToken == null) { 3224 if (starToken == null) {
3242 return AsyncMarker.Async; 3225 return AsyncMarker.Async;
3243 } else { 3226 } else {
3244 assert(identical(starToken.stringValue, "*")); 3227 assert(identical(starToken.stringValue, "*"));
3245 return AsyncMarker.AsyncStar; 3228 return AsyncMarker.AsyncStar;
3246 } 3229 }
3247 } else { 3230 } else {
3248 return internalError("Unknown async modifier: $asyncToken"); 3231 return internalError("Unknown async modifier: $asyncToken");
3249 } 3232 }
3250 } 3233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698