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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 11014010: Made assert a keyword. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renamed Assert to assertHelper. Switched parser to use parseArguments. Added assert argument checki… Created 8 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
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 629208757c5f4cbf5be975e972492ce5beddb2f0..be7504c164a46c961ce4594beedf89a806dfa5fa 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1401,33 +1401,22 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
return (str === '&&' || str == '||' || str == '!');
}
- /**
- * Check the lexical scope chain for a declaration with the name "assert".
- *
- * This is used to detect whether "assert(x)" is actually an assertion or
- * just a call expression.
- * It does not check fields inherited from a superclass.
- */
- bool isAssertInLexicalScope() {
- return scope.lexicalLookup(const SourceString("assert")) !== null;
- }
-
- /** Check if [node] is the expression of the current expression statement. */
- bool isExpressionStatementExpression(Node node) {
- return currentExpressionStatement !== null &&
- currentExpressionStatement.expression === node;
- }
-
Element resolveSend(Send node) {
Selector selector = resolveSelector(node);
if (node.receiver === null) {
- // If this send is the expression of an expression statement, and is on
- // the form "assert(expr);", and there is no declaration with name
- // "assert" in the lexical scope, then this is actually an assertion.
- if (isExpressionStatementExpression(node) &&
- selector.isAssertSyntax() &&
- !isAssertInLexicalScope()) {
+ // If this send is of the form "assert(expr);", then
+ // this is an assertion.
+ if (selector.isAssert()) {
+ if (selector.argumentCount != 1) {
+ error(node.selector,
+ MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
+ [selector.argumentCount]);
+ } else if (selector.namedArgumentCount != 0) {
+ error(node.selector,
+ MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
+ [selector.namedArgumentCount]);
+ }
return compiler.assertMethod;
}
return node.selector.accept(this);

Powered by Google App Engine
This is Rietveld 408576698