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

Unified Diff: pkg/analyzer/lib/src/dart/ast/ast.dart

Issue 1700263002: Add data structures to AST to indicate potentially mutated variables. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Follow Brian's suggestion Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/ast/ast.dart
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index dafbff2a599875377fb12b9562bb0fff78fe640c..4a9826ee757dc032867fbdddfca18f88e424ee9c 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -4722,6 +4722,13 @@ class ForStatementImpl extends StatementImpl implements ForStatement {
*/
abstract class FunctionBodyImpl extends AstNodeImpl implements FunctionBody {
/**
+ * Additional information about local variables and parameters that are
+ * declared within this function body or any enclosing function body. `null`
+ * if resolution has not yet been performed.
+ */
+ LocalVariableInfo localVariableInfo;
+
+ /**
* Return `true` if this function body is asynchronous.
*/
bool get isAsynchronous => false;
@@ -4747,6 +4754,22 @@ abstract class FunctionBodyImpl extends AstNodeImpl implements FunctionBody {
* is no star.
*/
Token get star => null;
+
+ @override
+ bool isPotentiallyMutatedInClosure(VariableElement variable) {
+ if (localVariableInfo == null) {
+ throw new StateError('Resolution has not yet been performed');
+ }
+ return localVariableInfo.potentiallyMutatedInClosure.contains(variable);
+ }
+
+ @override
+ bool isPotentiallyMutatedInScope(VariableElement variable) {
+ if (localVariableInfo == null) {
+ throw new StateError('Resolution has not yet been performed');
+ }
+ return localVariableInfo.potentiallyMutatedInScope.contains(variable);
+ }
}
/**
@@ -6557,6 +6580,26 @@ abstract class LiteralImpl extends ExpressionImpl implements Literal {
}
/**
+ * Additional information about local variables within a function or method
+ * produced at resolution time.
+ */
+class LocalVariableInfo {
+ /**
+ * The set of local variables and parameters that are potentially mutated
+ * within a local function other than the function in which they are declared.
+ */
+ final Set<VariableElement> potentiallyMutatedInClosure =
+ new Set<VariableElement>();
+
+ /**
+ * The set of local variables and parameters that are potentiall mutated
+ * within the scope of their declarations.
+ */
+ final Set<VariableElement> potentiallyMutatedInScope =
+ new Set<VariableElement>();
+}
+
+/**
* A single key/value pair in a map literal.
*
* > mapLiteralEntry ::=
« no previous file with comments | « pkg/analyzer/lib/dart/ast/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698