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

Side by Side Diff: frog/leg/resolver.dart

Issue 9139014: Allow for-in to use a previously declared identifier as variable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add more tests Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | frog/leg/ssa/builder.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class TreeElements { 5 class TreeElements {
6 Map<Node, Element> map; 6 Map<Node, Element> map;
7 TreeElements() : map = new LinkedHashMap<Node, Element>(); 7 TreeElements() : map = new LinkedHashMap<Node, Element>();
8 operator []=(Node node, Element element) => map[node] = element; 8 operator []=(Node node, Element element) => map[node] = element;
9 operator [](Node node) => map[node]; 9 operator [](Node node) => map[node];
10 } 10 }
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 cancel(node, 'unimplemented'); 514 cancel(node, 'unimplemented');
515 } 515 }
516 516
517 visitForInStatement(ForInStatement node) { 517 visitForInStatement(ForInStatement node) {
518 visit(node.expression); 518 visit(node.expression);
519 Scope scope = new BlockScope(context); 519 Scope scope = new BlockScope(context);
520 Node declaration = node.declaredIdentifier; 520 Node declaration = node.declaredIdentifier;
521 visitIn(declaration, scope); 521 visitIn(declaration, scope);
522 visitIn(node.body, scope); 522 visitIn(node.body, scope);
523 // TODO(lrn): Also allow a single identifier. 523 // TODO(lrn): Also allow a single identifier.
524 if (declaration is !VariableDefinitions || 524 if ((declaration is !Send || declaration.selector is !Identifier) &&
525 !declaration.definitions.nodes.tail.isEmpty()) { 525 (declaration is !VariableDefinitions ||
526 // The variable declaration is either not a declaration, or it's 526 !declaration.definitions.nodes.tail.isEmpty())) {
527 // declaring more than one variable. 527 // The variable declaration is either not an identifier, not a
528 error(node.declaredIdentifier, MessageKind.GENERIC, 528 // declaration, or it's declaring more than one variable.
529 ["Invalid variable declaration in for-in"]); 529 error(node.declaredIdentifier, MessageKind.INVALID_FOR_IN, []);
530 } 530 }
531 } 531 }
532 532
533 visitLabelledStatement(LabelledStatement node) { 533 visitLabelledStatement(LabelledStatement node) {
534 cancel(node, 'unimplemented'); 534 cancel(node, 'unimplemented');
535 } 535 }
536 536
537 visitLiteralMap(LiteralMap node) { 537 visitLiteralMap(LiteralMap node) {
538 cancel(node, 'unimplemented'); 538 cancel(node, 'unimplemented');
539 } 539 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 class TopScope extends Scope { 752 class TopScope extends Scope {
753 Universe universe; 753 Universe universe;
754 754
755 TopScope(Universe this.universe) : super(null, null); 755 TopScope(Universe this.universe) : super(null, null);
756 Element lookup(SourceString name) => universe.find(name); 756 Element lookup(SourceString name) => universe.find(name);
757 757
758 Element add(Element element) { 758 Element add(Element element) {
759 throw "Cannot add an element in the top scope"; 759 throw "Cannot add an element in the top scope";
760 } 760 }
761 } 761 }
OLDNEW
« no previous file with comments | « no previous file | frog/leg/ssa/builder.dart » ('j') | frog/leg/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698