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

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

Issue 2933643002: Implement type inference for assignments to a static variable. (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) 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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 } 1442 }
1443 1443
1444 /// Common base class for shadow objects representing statements in kernel 1444 /// Common base class for shadow objects representing statements in kernel
1445 /// form. 1445 /// form.
1446 abstract class KernelStatement extends Statement { 1446 abstract class KernelStatement extends Statement {
1447 /// Calls back to [inferrer] to perform type inference for whatever concrete 1447 /// Calls back to [inferrer] to perform type inference for whatever concrete
1448 /// type of [KernelStatement] this is. 1448 /// type of [KernelStatement] this is.
1449 void _inferStatement(KernelTypeInferrer inferrer); 1449 void _inferStatement(KernelTypeInferrer inferrer);
1450 } 1450 }
1451 1451
1452 /// Concrete shadow object representing an assignment to a static variable.
1453 class KernelStaticAssignment extends KernelComplexAssignment {
1454 KernelStaticAssignment(Expression rhs) : super(rhs);
1455
1456 @override
1457 DartType _inferExpression(
1458 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
1459 typeNeeded = inferrer.listener.staticAssignEnter(desugared, typeContext) ||
1460 typeNeeded;
1461 // TODO(paulberry): record the appropriate types on let variables and
1462 // conditional expressions.
1463 DartType writeContext;
1464 var write = this.write;
1465 if (write is StaticSet) {
1466 writeContext = write.target.setterType;
1467 }
1468 var inferredType = _inferRhs(inferrer, writeContext);
1469 inferrer.listener.staticAssignExit(desugared, inferredType);
1470 return inferredType;
1471 }
1472 }
1473
1452 /// Concrete shadow object representing a read of a static variable in kernel 1474 /// Concrete shadow object representing a read of a static variable in kernel
1453 /// form. 1475 /// form.
1454 class KernelStaticGet extends StaticGet implements KernelExpression { 1476 class KernelStaticGet extends StaticGet implements KernelExpression {
1455 KernelStaticGet(Member target) : super(target); 1477 KernelStaticGet(Member target) : super(target);
1456 1478
1457 @override 1479 @override
1458 void _collectDependencies(KernelDependencyCollector collector) { 1480 void _collectDependencies(KernelDependencyCollector collector) {
1459 // A simple or qualified identifier referring to a top level function, 1481 // A simple or qualified identifier referring to a top level function,
1460 // static variable, field, getter; or a static class variable, static getter 1482 // static variable, field, getter; or a static class variable, static getter
1461 // or method; or an instance method; has the inferred type of the referent. 1483 // or method; or an instance method; has the inferred type of the referent.
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 } 2137 }
2116 2138
2117 transformChildren(v) { 2139 transformChildren(v) {
2118 return internalError("Internal error: Unsupported operation."); 2140 return internalError("Internal error: Unsupported operation.");
2119 } 2141 }
2120 2142
2121 visitChildren(v) { 2143 visitChildren(v) {
2122 return internalError("Internal error: Unsupported operation."); 2144 return internalError("Internal error: Unsupported operation.");
2123 } 2145 }
2124 } 2146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698