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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1346093003: Revert "Add optional message to assert in Dart2js - continued" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « pkg/compiler/lib/src/parser/parser.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('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 library dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common/names.dart' show 7 import '../common/names.dart' show
8 Selectors; 8 Selectors;
9 import '../compiler.dart' show 9 import '../compiler.dart' show
10 Compiler; 10 Compiler;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 compiler.resolver.constantCompiler.compileConstant(parameter); 494 compiler.resolver.constantCompiler.compileConstant(parameter);
495 }); 495 });
496 }); 496 });
497 if (inCheckContext) { 497 if (inCheckContext) {
498 functionParameters.forEachParameter((ParameterElement element) { 498 functionParameters.forEachParameter((ParameterElement element) {
499 registry.registerIsCheck(element.type); 499 registry.registerIsCheck(element.type);
500 }); 500 });
501 } 501 }
502 } 502 }
503 503
504 ResolutionResult visitAssert(Assert node) {
505 // TODO(sra): We could completely ignore the assert in production mode if we
506 // didn't need it to be resolved for type checking.
507 registry.registerAssert(node.hasMessage);
508 visit(node.condition);
509 visit(node.message);
510 return const NoneResult();
511 }
512
513 ResolutionResult visitCascade(Cascade node) { 504 ResolutionResult visitCascade(Cascade node) {
514 visit(node.expression); 505 visit(node.expression);
515 return const NoneResult(); 506 return const NoneResult();
516 } 507 }
517 508
518 ResolutionResult visitCascadeReceiver(CascadeReceiver node) { 509 ResolutionResult visitCascadeReceiver(CascadeReceiver node) {
519 visit(node.expression); 510 visit(node.expression);
520 return const NoneResult(); 511 return const NoneResult();
521 } 512 }
522 513
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 Selector selector = callStructure.callSelector; 1521 Selector selector = callStructure.callSelector;
1531 // TODO(23998): Remove this when all information goes through the 1522 // TODO(23998): Remove this when all information goes through the
1532 // [SendStructure]. 1523 // [SendStructure].
1533 registry.setSelector(node, selector); 1524 registry.setSelector(node, selector);
1534 registry.registerDynamicInvocation(new UniverseSelector(selector, null)); 1525 registry.registerDynamicInvocation(new UniverseSelector(selector, null));
1535 registry.registerSendStructure(node, 1526 registry.registerSendStructure(node,
1536 new InvokeStructure(const DynamicAccess.expression(), selector)); 1527 new InvokeStructure(const DynamicAccess.expression(), selector));
1537 return const NoneResult(); 1528 return const NoneResult();
1538 } 1529 }
1539 1530
1531 /// Handle a, possibly invalid, assertion, like `assert(cond)` or `assert()`.
1532 ResolutionResult handleAssert(Send node) {
1533 assert(invariant(node, node.isCall,
1534 message: "Unexpected assert: $node"));
1535 // If this send is of the form "assert(expr);", then
1536 // this is an assertion.
1537
1538 CallStructure callStructure =
1539 resolveArguments(node.argumentsNode).callStructure;
1540 SendStructure sendStructure = const AssertStructure();
1541 if (callStructure.argumentCount != 1) {
1542 compiler.reportError(
1543 node.selector,
1544 MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
1545 {'argumentCount': callStructure.argumentCount});
1546 sendStructure = const InvalidAssertStructure();
1547 } else if (callStructure.namedArgumentCount != 0) {
1548 compiler.reportError(
1549 node.selector,
1550 MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
1551 {'argumentCount': callStructure.namedArgumentCount});
1552 sendStructure = const InvalidAssertStructure();
1553 }
1554 registry.registerAssert(node);
1555 registry.registerSendStructure(node, sendStructure);
1556 return const AssertResult();
1557 }
1558
1540 /// Handle access of a property of [name] on `this`, like `this.name` and 1559 /// Handle access of a property of [name] on `this`, like `this.name` and
1541 /// `this.name()`, or `name` and `name()` in instance context. 1560 /// `this.name()`, or `name` and `name()` in instance context.
1542 ResolutionResult handleThisPropertyAccess(Send node, Name name) { 1561 ResolutionResult handleThisPropertyAccess(Send node, Name name) {
1543 AccessSemantics semantics = new DynamicAccess.thisProperty(name); 1562 AccessSemantics semantics = new DynamicAccess.thisProperty(name);
1544 return handleDynamicAccessSemantics(node, name, semantics); 1563 return handleDynamicAccessSemantics(node, name, semantics);
1545 } 1564 }
1546 1565
1547 /// Handle update of a property of [name] on `this`, like `this.name = b` and 1566 /// Handle update of a property of [name] on `this`, like `this.name = b` and
1548 /// `this.name++`, or `name = b` and `name++` in instance context. 1567 /// `this.name++`, or `name = b` and `name++` in instance context.
1549 ResolutionResult handleThisPropertyUpdate( 1568 ResolutionResult handleThisPropertyUpdate(
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 3026
3008 /// Handle an unqualified [Send], that is where the `node.receiver` is null, 3027 /// Handle an unqualified [Send], that is where the `node.receiver` is null,
3009 /// like `a`, `a()`, `this()`, `assert()`, and `(){}()`. 3028 /// like `a`, `a()`, `this()`, `assert()`, and `(){}()`.
3010 ResolutionResult handleUnqualifiedSend(Send node) { 3029 ResolutionResult handleUnqualifiedSend(Send node) {
3011 Identifier selector = node.selector.asIdentifier(); 3030 Identifier selector = node.selector.asIdentifier();
3012 if (selector == null) { 3031 if (selector == null) {
3013 // `(){}()` and `(foo)()`. 3032 // `(){}()` and `(foo)()`.
3014 return handleExpressionInvoke(node); 3033 return handleExpressionInvoke(node);
3015 } 3034 }
3016 String text = selector.source; 3035 String text = selector.source;
3017 if (text == 'this') { 3036 if (text == 'assert') {
3037 // `assert()`.
3038 return handleAssert(node);
3039 } else if (text == 'this') {
3018 // `this()`. 3040 // `this()`.
3019 return handleThisAccess(node); 3041 return handleThisAccess(node);
3020 } 3042 }
3021 // `name` or `name()` 3043 // `name` or `name()`
3022 Name name = new Name(text, enclosingElement.library); 3044 Name name = new Name(text, enclosingElement.library);
3023 Element element = lookupInScope(compiler, node, scope, text); 3045 Element element = lookupInScope(compiler, node, scope, text);
3024 if (element == null) { 3046 if (element == null) {
3025 if (text == 'dynamic') { 3047 if (text == 'dynamic') {
3026 // `dynamic` or `dynamic()` where 'dynamic' is not declared in the 3048 // `dynamic` or `dynamic()` where 'dynamic' is not declared in the
3027 // current scope. 3049 // current scope.
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
4648 } 4670 }
4649 return const NoneResult(); 4671 return const NoneResult();
4650 } 4672 }
4651 } 4673 }
4652 4674
4653 /// Looks up [name] in [scope] and unwraps the result. 4675 /// Looks up [name] in [scope] and unwraps the result.
4654 Element lookupInScope(Compiler compiler, Node node, 4676 Element lookupInScope(Compiler compiler, Node node,
4655 Scope scope, String name) { 4677 Scope scope, String name) {
4656 return Elements.unwrap(scope.lookup(name), compiler, node); 4678 return Elements.unwrap(scope.lookup(name), compiler, node);
4657 } 4679 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/parser.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698