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

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

Issue 2959763002: Add type inference for assert statements. (Closed)
Patch Set: Created 3 years, 5 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 83 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
84 typeNeeded = 84 typeNeeded =
85 inferrer.listener.asExpressionEnter(this, typeContext) || typeNeeded; 85 inferrer.listener.asExpressionEnter(this, typeContext) || typeNeeded;
86 inferrer.inferExpression(operand, null, false); 86 inferrer.inferExpression(operand, null, false);
87 var inferredType = typeNeeded ? type : null; 87 var inferredType = typeNeeded ? type : null;
88 inferrer.listener.asExpressionExit(this, inferredType); 88 inferrer.listener.asExpressionExit(this, inferredType);
89 return inferredType; 89 return inferredType;
90 } 90 }
91 } 91 }
92 92
93 /// Concrete shadow object representing an assertion statement in kernel form.
94 class KernelAssertStatement extends AssertStatement implements KernelStatement {
95 KernelAssertStatement(Expression condition,
96 {Expression message, int conditionStartOffset, int conditionEndOffset})
97 : super(condition,
98 message: message,
99 conditionStartOffset: conditionStartOffset,
100 conditionEndOffset: conditionEndOffset);
101
102 @override
103 void _inferStatement(KernelTypeInferrer inferrer) {
104 inferrer.listener.assertStatementEnter(this);
105 inferrer.inferExpression(condition, null, false);
106 if (message != null) {
107 inferrer.inferExpression(message, null, false);
108 }
109 inferrer.listener.assertStatementExit(this);
110 }
111 }
112
93 /// Shadow object for [AwaitExpression]. 113 /// Shadow object for [AwaitExpression].
94 class KernelAwaitExpression extends AwaitExpression 114 class KernelAwaitExpression extends AwaitExpression
95 implements KernelExpression { 115 implements KernelExpression {
96 KernelAwaitExpression(Expression operand) : super(operand); 116 KernelAwaitExpression(Expression operand) : super(operand);
97 117
98 @override 118 @override
99 void _collectDependencies(KernelDependencyCollector collector) { 119 void _collectDependencies(KernelDependencyCollector collector) {
100 // Inference dependencies are the dependencies of the awaited expression. 120 // Inference dependencies are the dependencies of the awaited expression.
101 collector.collectDependencies(operand); 121 collector.collectDependencies(operand);
102 } 122 }
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 } 2233 }
2214 2234
2215 transformChildren(v) { 2235 transformChildren(v) {
2216 return internalError("Internal error: Unsupported operation."); 2236 return internalError("Internal error: Unsupported operation.");
2217 } 2237 }
2218 2238
2219 visitChildren(v) { 2239 visitChildren(v) {
2220 return internalError("Internal error: Unsupported operation."); 2240 return internalError("Internal error: Unsupported operation.");
2221 } 2241 }
2222 } 2242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698