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

Unified Diff: pkg/analyzer2dart/lib/src/semantic_visitor.dart

Issue 652403005: Support assignment of locals in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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/analyzer2dart/lib/src/modely.dart ('k') | pkg/analyzer2dart/lib/src/tree_shaker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/lib/src/semantic_visitor.dart
diff --git a/pkg/analyzer2dart/lib/src/semantic_visitor.dart b/pkg/analyzer2dart/lib/src/semantic_visitor.dart
index f16b0c2ab80c031c7a992d0e9f1100cf96fb857d..613c5b4da7954eca9342304969d509ce96663567 100644
--- a/pkg/analyzer2dart/lib/src/semantic_visitor.dart
+++ b/pkg/analyzer2dart/lib/src/semantic_visitor.dart
@@ -81,7 +81,7 @@ abstract class SemanticVisitor<R> extends RecursiveAstVisitor<R> {
}
R handleMethodInvocation(MethodInvocation node) {
- AccessSemantics semantics = classifyMethodInvocation(node);
+ AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR);
switch (semantics.kind) {
case AccessKind.DYNAMIC:
return visitDynamicInvocation(node, semantics);
@@ -113,7 +113,7 @@ abstract class SemanticVisitor<R> extends RecursiveAstVisitor<R> {
}
R handlePropertyAccess(PropertyAccess node) {
- return _handlePropertyAccess(node, classifyPropertyAccess(node));
+ return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR));
}
@override
@@ -123,12 +123,12 @@ abstract class SemanticVisitor<R> extends RecursiveAstVisitor<R> {
}
R handlePrefixedIdentifier(PrefixedIdentifier node) {
- return _handlePropertyAccess(node, classifyPrefixedIdentifier(node));
+ return _handlePropertyAccess(node, node.accept(ACCESS_SEMANTICS_VISITOR));
}
@override
R visitSimpleIdentifier(SimpleIdentifier node) {
- AccessSemantics semantics = classifySimpleIdentifier(node);
+ AccessSemantics semantics = node.accept(ACCESS_SEMANTICS_VISITOR);
if (semantics != null) {
return _handlePropertyAccess(node, semantics);
} else {
@@ -186,4 +186,79 @@ abstract class SemanticVisitor<R> extends RecursiveAstVisitor<R> {
'Unexpected ${semantics} in _handlePropertyAccess.');
}
}
+
+ // TODO(johnniwinther,paulberry): Is this a real thing?
Paul Berry 2014/10/27 14:15:56 This will only happen if the call node.leftHand
Johnni Winther 2014/10/27 14:26:18 Ahh. We need an AccessSemantics for index operatio
+ R visitDynamicAssignment(AssignmentExpression node) {
+ return giveUp(node, 'visitDynamicAssignment');
+ }
+
+ R visitDynamicPropertyAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitDynamicPropertyAssignment of $semantics');
+ }
+
+ R visitLocalFunctionAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitLocalFunctionAssignment of $semantics');
+ }
+
+ R visitLocalVariableAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitLocalVariableAssignment of $semantics');
+ }
+
+ R visitParameterAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitParameterAssignment of $semantics');
+ }
+
+ R visitStaticFieldAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitStaticFieldAssignment of $semantics');
+ }
+
+ R visitStaticMethodAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitStaticMethodAssignment of $semantics');
+ }
+
+ R visitStaticPropertyAssignment(AssignmentExpression node,
+ AccessSemantics semantics) {
+ return giveUp(node, 'visitStaticPropertyAssignment of $semantics');
+ }
+
+ @override
+ R visitAssignmentExpression(AssignmentExpression node) {
+ super.visitAssignmentExpression(node);
+ return handleAssignmentExpression(node);
+ }
+
+ R handleAssignmentExpression(AssignmentExpression node) {
+ AccessSemantics semantics =
+ node.leftHandSide.accept(ACCESS_SEMANTICS_VISITOR);
+ if (semantics == null) {
+ return visitDynamicAssignment(node);
+ } else {
+ switch (semantics.kind) {
+ case AccessKind.DYNAMIC:
+ return visitDynamicPropertyAssignment(node, semantics);
+ case AccessKind.LOCAL_FUNCTION:
+ return visitLocalFunctionAssignment(node, semantics);
+ case AccessKind.LOCAL_VARIABLE:
+ return visitLocalVariableAssignment(node, semantics);
+ case AccessKind.PARAMETER:
+ return visitParameterAssignment(node, semantics);
+ case AccessKind.STATIC_FIELD:
+ return visitStaticFieldAssignment(node, semantics);
+ case AccessKind.STATIC_METHOD:
+ return visitStaticMethodAssignment(node, semantics);
+ case AccessKind.STATIC_PROPERTY:
+ return visitStaticPropertyAssignment(node, semantics);
+ default:
+ // Unexpected access kind.
+ return giveUp(node,
+ 'Unexpected ${semantics} in _handlePropertyAccess.');
+ }
+ }
+ }
}
« no previous file with comments | « pkg/analyzer2dart/lib/src/modely.dart ('k') | pkg/analyzer2dart/lib/src/tree_shaker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698