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

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

Issue 2882863002: Implement full closure inference logic. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend 5 /// This file declares a "shadow hierarchy" of concrete classes which extend
6 /// the kernel class hierarchy, adding methods and fields needed by the 6 /// the kernel class hierarchy, adding methods and fields needed by the
7 /// BodyBuilder. 7 /// BodyBuilder.
8 /// 8 ///
9 /// Instances of these classes may be created using the factory methods in 9 /// Instances of these classes may be created using the factory methods in
10 /// `ast_factory.dart`. 10 /// `ast_factory.dart`.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 @override 295 @override
296 DartType _inferExpression( 296 DartType _inferExpression(
297 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 297 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
298 var asyncMarker = function.asyncMarker; 298 var asyncMarker = function.asyncMarker;
299 bool isAsync = asyncMarker == AsyncMarker.Async || 299 bool isAsync = asyncMarker == AsyncMarker.Async ||
300 asyncMarker == AsyncMarker.AsyncStar; 300 asyncMarker == AsyncMarker.AsyncStar;
301 bool isGenerator = asyncMarker == AsyncMarker.SyncStar || 301 bool isGenerator = asyncMarker == AsyncMarker.SyncStar ||
302 asyncMarker == AsyncMarker.AsyncStar; 302 asyncMarker == AsyncMarker.AsyncStar;
303 return inferrer.inferFunctionExpression( 303 return inferrer.inferFunctionExpression(
304 typeContext, 304 typeContext, typeNeeded, function, isAsync, isGenerator, fileOffset,
305 typeNeeded, 305 (type) {
306 function.body,
307 function.body is ReturnStatement,
308 isAsync,
309 isGenerator,
310 fileOffset, (type) {
311 function.returnType = type; 306 function.returnType = type;
312 }, () => function.functionType); 307 }, () => function.functionType);
313 } 308 }
314 } 309 }
315 310
316 /// Concrete shadow object representing an if statement in kernel form. 311 /// Concrete shadow object representing an if statement in kernel form.
317 class KernelIfStatement extends IfStatement implements KernelStatement { 312 class KernelIfStatement extends IfStatement implements KernelStatement {
318 KernelIfStatement(Expression condition, Statement then, Statement otherwise) 313 KernelIfStatement(Expression condition, Statement then, Statement otherwise)
319 : super(condition, then, otherwise); 314 : super(condition, then, otherwise);
320 315
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 946
952 DartType get _declaredType => _implicitlyTyped ? null : type; 947 DartType get _declaredType => _implicitlyTyped ? null : type;
953 948
954 @override 949 @override
955 void _inferStatement(KernelTypeInferrer inferrer) { 950 void _inferStatement(KernelTypeInferrer inferrer) {
956 inferrer.inferVariableDeclaration( 951 inferrer.inferVariableDeclaration(
957 _implicitlyTyped ? null : type, initializer, fileOffset, (type) { 952 _implicitlyTyped ? null : type, initializer, fileOffset, (type) {
958 this.type = type; 953 this.type = type;
959 }); 954 });
960 } 955 }
956
957 /// Determine whether the given [KernelVariableDeclaration] had an implicit
958 /// type.
959 ///
960 /// This is static to avoid introducing a method that would be visible to
961 /// the kernel.
962 static bool isImplicitlyTyped(KernelVariableDeclaration variable) =>
963 variable._implicitlyTyped;
961 } 964 }
962 965
963 /// Concrete shadow object representing a read from a variable in kernel form. 966 /// Concrete shadow object representing a read from a variable in kernel form.
964 class KernelVariableGet extends VariableGet implements KernelExpression { 967 class KernelVariableGet extends VariableGet implements KernelExpression {
965 final TypePromotionFact<VariableDeclaration> _fact; 968 final TypePromotionFact<VariableDeclaration> _fact;
966 969
967 final TypePromotionScope _scope; 970 final TypePromotionScope _scope;
968 971
969 KernelVariableGet(VariableDeclaration variable, this._fact, this._scope) 972 KernelVariableGet(VariableDeclaration variable, this._fact, this._scope)
970 : super(variable); 973 : super(variable);
(...skipping 17 matching lines...) Expand all
988 : super(variable, value); 991 : super(variable, value);
989 992
990 @override 993 @override
991 DartType _inferExpression( 994 DartType _inferExpression(
992 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 995 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
993 var variable = this.variable as KernelVariableDeclaration; 996 var variable = this.variable as KernelVariableDeclaration;
994 return inferrer.inferVariableSet( 997 return inferrer.inferVariableSet(
995 typeContext, typeNeeded, variable._declaredType, value); 998 typeContext, typeNeeded, variable._declaredType, value);
996 } 999 }
997 } 1000 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698