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

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

Issue 9619028: Cases in a switch introduce a new scope. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | tests/language/language-leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface TreeElements { 5 interface TreeElements {
6 Element operator[](Node node); 6 Element operator[](Node node);
7 Selector getSelector(Send send); 7 Selector getSelector(Send send);
8 } 8 }
9 9
10 class TreeElementMapping implements TreeElements { 10 class TreeElementMapping implements TreeElements {
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 node.expression.accept(this); 1154 node.expression.accept(this);
1155 StatementElement element = getOrCreateStatementElement(node); 1155 StatementElement element = getOrCreateStatementElement(node);
1156 statementScope.enterLoop(element); 1156 statementScope.enterLoop(element);
1157 node.cases.accept(this); 1157 node.cases.accept(this);
1158 statementScope.exitLoop(); 1158 statementScope.exitLoop();
1159 } 1159 }
1160 1160
1161 visitSwitchCase(SwitchCase node) { 1161 visitSwitchCase(SwitchCase node) {
1162 // TODO(ahe): What about the label? 1162 // TODO(ahe): What about the label?
1163 node.expression.accept(this); 1163 node.expression.accept(this);
1164 node.statements.accept(this); 1164 visitIn(node.statements, new BlockScope(context));
ahe 2012/03/07 22:24:15 I can't find this in the specification.
ngeoffray 2012/03/07 22:31:11 We have a test for it SwitchScopeTest. And the JSO
ahe 2012/04/13 13:50:19 Then you need to file a specification bug.
ngeoffray 2012/04/16 13:49:35 Yes: http://code.google.com/p/dart/issues/detail?i
ahe 2012/04/16 14:51:58 Thank you. Starred it :-)
1165 } 1165 }
1166 1166
1167 visitDefaultCase(DefaultCase node) { 1167 visitDefaultCase(DefaultCase node) {
1168 // TODO(ahe): What about the label? 1168 // TODO(ahe): What about the label?
1169 node.statements.accept(this); 1169 visitIn(node.statements, new BlockScope(context));
1170 } 1170 }
1171 1171
1172 visitTryStatement(TryStatement node) { 1172 visitTryStatement(TryStatement node) {
1173 visit(node.tryBlock); 1173 visit(node.tryBlock);
1174 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) { 1174 if (node.catchBlocks.isEmpty() && node.finallyBlock == null) {
1175 // TODO(ngeoffray): The precise location is 1175 // TODO(ngeoffray): The precise location is
1176 // node.getEndtoken.next. Adjust when issue #1581 is fixed. 1176 // node.getEndtoken.next. Adjust when issue #1581 is fixed.
1177 error(node, MessageKind.NO_CATCH_NOR_FINALLY); 1177 error(node, MessageKind.NO_CATCH_NOR_FINALLY);
1178 } 1178 }
1179 visit(node.catchBlocks); 1179 visit(node.catchBlocks);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 class TopScope extends Scope { 1492 class TopScope extends Scope {
1493 LibraryElement get library() => element; 1493 LibraryElement get library() => element;
1494 1494
1495 TopScope(LibraryElement library) : super(null, library); 1495 TopScope(LibraryElement library) : super(null, library);
1496 Element lookup(SourceString name) => library.find(name); 1496 Element lookup(SourceString name) => library.find(name);
1497 1497
1498 Element add(Element element) { 1498 Element add(Element element) {
1499 throw "Cannot add an element in the top scope"; 1499 throw "Cannot add an element in the top scope";
1500 } 1500 }
1501 } 1501 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698