Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 abstract class TreeElements { | 5 abstract class TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 DartType getType(TypeAnnotation annotation); | 8 DartType getType(TypeAnnotation annotation); |
| 9 bool isParameterChecked(Element element); | 9 bool isParameterChecked(Element element); |
| 10 } | 10 } |
| (...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1260 visit(node.condition); | 1260 visit(node.condition); |
| 1261 visit(node.thenPart); | 1261 visit(node.thenPart); |
| 1262 visit(node.elsePart); | 1262 visit(node.elsePart); |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 static bool isLogicalOperator(Identifier op) { | 1265 static bool isLogicalOperator(Identifier op) { |
| 1266 String str = op.source.stringValue; | 1266 String str = op.source.stringValue; |
| 1267 return (str === '&&' || str == '||' || str == '!'); | 1267 return (str === '&&' || str == '||' || str == '!'); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 /** | |
| 1271 * Check the lexical scope chain for a declaration with the name "assert". | |
| 1272 * | |
| 1273 * This is used to detect whether "assert(x)" is actually an assertion or | |
| 1274 * just a call expression. | |
| 1275 * It does not check fields inherited from a superclass. | |
| 1276 */ | |
| 1277 bool isAssertInLexicalScope() { | |
| 1278 return scope.lexicalLookup(const SourceString("assert")) !== null; | |
| 1279 } | |
| 1280 | |
| 1281 /** Check if [node] is the expression of the current expression statement. */ | 1270 /** Check if [node] is the expression of the current expression statement. */ |
| 1282 bool isExpressionStatementExpression(Node node) { | 1271 bool isExpressionStatementExpression(Node node) { |
| 1283 return currentExpressionStatement !== null && | 1272 return currentExpressionStatement !== null && |
| 1284 currentExpressionStatement.expression === node; | 1273 currentExpressionStatement.expression === node; |
| 1285 } | 1274 } |
| 1286 | 1275 |
| 1287 Element resolveSend(Send node) { | 1276 Element resolveSend(Send node) { |
| 1288 Selector selector = resolveSelector(node); | 1277 Selector selector = resolveSelector(node); |
| 1289 | 1278 |
| 1290 if (node.receiver === null) { | 1279 if (node.receiver === null) { |
|
ahe
2012/10/10 08:44:13
Not sure this check is needed.
aam-me
2012/10/11 05:35:25
If I understand correctly, this check is used to s
ahe
2012/10/11 05:44:08
Yes. I'm being stupid :-)
| |
| 1291 // If this send is the expression of an expression statement, and is on | 1280 // If this send is the expression of an expression statement, and is on |
| 1292 // the form "assert(expr);", and there is no declaration with name | 1281 // the form "assert(expr);", and there is no declaration with name |
| 1293 // "assert" in the lexical scope, then this is actually an assertion. | 1282 // "assert" in the lexical scope, then this is actually an assertion. |
| 1294 if (isExpressionStatementExpression(node) && | 1283 if (isExpressionStatementExpression(node) && |
|
ahe
2012/10/10 08:44:13
I don't think this check is needed. This must be t
| |
| 1295 selector.isAssertSyntax() && | 1284 selector.isAssertSyntax()) { |
| 1296 !isAssertInLexicalScope()) { | |
| 1297 return compiler.assertMethod; | 1285 return compiler.assertMethod; |
| 1298 } | 1286 } |
| 1299 return node.selector.accept(this); | 1287 return node.selector.accept(this); |
| 1300 } | 1288 } |
| 1301 | 1289 |
| 1302 var oldCategory = allowedCategory; | 1290 var oldCategory = allowedCategory; |
| 1303 allowedCategory |= | 1291 allowedCategory |= |
| 1304 ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER; | 1292 ElementCategory.CLASS | ElementCategory.PREFIX | ElementCategory.SUPER; |
| 1305 Element resolvedReceiver = visit(node.receiver); | 1293 Element resolvedReceiver = visit(node.receiver); |
| 1306 allowedCategory = oldCategory; | 1294 allowedCategory = oldCategory; |
| (...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2880 | 2868 |
| 2881 Element localLookup(SourceString name) => library.find(name); | 2869 Element localLookup(SourceString name) => library.find(name); |
| 2882 Element lookup(SourceString name) => localLookup(name); | 2870 Element lookup(SourceString name) => localLookup(name); |
| 2883 Element lexicalLookup(SourceString name) => localLookup(name); | 2871 Element lexicalLookup(SourceString name) => localLookup(name); |
| 2884 | 2872 |
| 2885 Element add(Element newElement) { | 2873 Element add(Element newElement) { |
| 2886 throw "Cannot add an element in the top scope"; | 2874 throw "Cannot add an element in the top scope"; |
| 2887 } | 2875 } |
| 2888 String toString() => '$element'; | 2876 String toString() => '$element'; |
| 2889 } | 2877 } |
| OLD | NEW |