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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 25478009: Handle compile-time constness for conditionals and type literal calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 compiler.backend.registerTypeVariableExpression(mapping); 2434 compiler.backend.registerTypeVariableExpression(mapping);
2435 // Set the type of the node to [Type] to mark this send as a 2435 // Set the type of the node to [Type] to mark this send as a
2436 // type variable expression. 2436 // type variable expression.
2437 mapping.setType(node, compiler.typeClass.computeType(compiler)); 2437 mapping.setType(node, compiler.typeClass.computeType(compiler));
2438 world.registerTypeLiteral(target, mapping); 2438 world.registerTypeLiteral(target, mapping);
2439 } else if (target.impliesType() && !sendIsMemberAccess) { 2439 } else if (target.impliesType() && !sendIsMemberAccess) {
2440 // Set the type of the node to [Type] to mark this send as a 2440 // Set the type of the node to [Type] to mark this send as a
2441 // type literal. 2441 // type literal.
2442 mapping.setType(node, compiler.typeClass.computeType(compiler)); 2442 mapping.setType(node, compiler.typeClass.computeType(compiler));
2443 world.registerTypeLiteral(target, mapping); 2443 world.registerTypeLiteral(target, mapping);
2444 analyzeConstant(node); 2444
2445 // Don't try to make constants of calls to type literals.
2446 analyzeConstant(node, isConst: !node.isCall);
2445 } 2447 }
2446 } 2448 }
2447 2449
2448 bool resolvedArguments = false; 2450 bool resolvedArguments = false;
2449 if (node.isOperator) { 2451 if (node.isOperator) {
2450 String operatorString = node.selector.asOperator().source.stringValue; 2452 String operatorString = node.selector.asOperator().source.stringValue;
2451 if (identical(operatorString, 'is')) { 2453 if (identical(operatorString, 'is')) {
2452 DartType type = 2454 DartType type =
2453 resolveTypeExpression(node.typeAnnotationFromIsCheckOrCast); 2455 resolveTypeExpression(node.typeAnnotationFromIsCheckOrCast);
2454 if (type != null) { 2456 if (type != null) {
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
2885 } else if (isMirrorsUsedConstant) { 2887 } else if (isMirrorsUsedConstant) {
2886 compiler.mirrorUsageAnalyzerTask.validate(node, mapping); 2888 compiler.mirrorUsageAnalyzerTask.validate(node, mapping);
2887 } 2889 }
2888 if (node.isConst()) { 2890 if (node.isConst()) {
2889 analyzeConstant(node); 2891 analyzeConstant(node);
2890 } 2892 }
2891 2893
2892 return null; 2894 return null;
2893 } 2895 }
2894 2896
2895 void analyzeConstant(Node node) { 2897 void analyzeConstant(Node node, {bool isConst: true}) {
2896 addPostProcessAction(enclosingElement, () { 2898 addPostProcessAction(enclosingElement, () {
2897 mapping.setConstant(node, 2899 compiler.constantHandler.compileNodeWithDefinitions(
2898 compiler.constantHandler.compileNodeWithDefinitions( 2900 node, mapping, isConst: isConst);
2899 node, mapping, isConst: true));
2900 }); 2901 });
2901 } 2902 }
2902 2903
2903 bool validateSymbol(Node node, String name, {bool reportError: true}) { 2904 bool validateSymbol(Node node, String name, {bool reportError: true}) {
2904 if (name.isEmpty) return true; 2905 if (name.isEmpty) return true;
2905 if (name.startsWith('_')) { 2906 if (name.startsWith('_')) {
2906 if (reportError) { 2907 if (reportError) {
2907 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER, 2908 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER,
2908 {'value': name}); 2909 {'value': name});
2909 } 2910 }
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4484 return e; 4485 return e;
4485 } 4486 }
4486 4487
4487 /// Assumed to be called by [resolveRedirectingFactory]. 4488 /// Assumed to be called by [resolveRedirectingFactory].
4488 Element visitReturn(Return node) { 4489 Element visitReturn(Return node) {
4489 Node expression = node.expression; 4490 Node expression = node.expression;
4490 return finishConstructorReference(visit(expression), 4491 return finishConstructorReference(visit(expression),
4491 expression, expression); 4492 expression, expression);
4492 } 4493 }
4493 } 4494 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698