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 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 470 |
| 471 SendSet send = tree.asSendSet(); | 471 SendSet send = tree.asSendSet(); |
| 472 if (send != null) { | 472 if (send != null) { |
| 473 // TODO(johnniwinther): Avoid analyzing initializers if | 473 // TODO(johnniwinther): Avoid analyzing initializers if |
| 474 // [Compiler.analyzeSignaturesOnly] is set. | 474 // [Compiler.analyzeSignaturesOnly] is set. |
| 475 visitor.visit(send.arguments.head); | 475 visitor.visit(send.arguments.head); |
| 476 } else if (element.modifiers.isConst()) { | 476 } else if (element.modifiers.isConst()) { |
| 477 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER); | 477 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER); |
| 478 } | 478 } |
| 479 | 479 |
| 480 visitor.addPostProcessAction(element, () { | |
|
karlklose
2013/10/02 11:08:55
Add a TODO to check if we need a constant.
Johnni Winther
2013/10/02 12:39:33
Reverted this change. The constant is only needed
| |
| 481 compiler.constantHandler.compileVariable( | |
| 482 element, isConst: element.modifiers.isConst()); | |
| 483 }); | |
| 484 | |
| 480 if (Elements.isStaticOrTopLevelField(element)) { | 485 if (Elements.isStaticOrTopLevelField(element)) { |
| 481 visitor.addPostProcessAction(element, () { | |
| 482 compiler.constantHandler.compileVariable( | |
| 483 element, isConst: element.modifiers.isConst()); | |
| 484 }); | |
| 485 if (tree.asSendSet() != null) { | 486 if (tree.asSendSet() != null) { |
| 486 if (!element.modifiers.isConst()) { | 487 if (!element.modifiers.isConst()) { |
| 487 // TODO(johnniwinther): Determine the const-ness eagerly to avoid | 488 // TODO(johnniwinther): Determine the const-ness eagerly to avoid |
| 488 // unnecessary registrations. | 489 // unnecessary registrations. |
| 489 compiler.backend.registerLazyField(visitor.mapping); | 490 compiler.backend.registerLazyField(visitor.mapping); |
| 490 } | 491 } |
| 491 } else { | 492 } else { |
| 492 compiler.enqueuer.resolution.registerInstantiatedClass( | 493 compiler.enqueuer.resolution.registerInstantiatedClass( |
| 493 compiler.nullClass, visitor.mapping); | 494 compiler.nullClass, visitor.mapping); |
| 494 } | 495 } |
| (...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2434 compiler.backend.registerTypeVariableExpression(mapping); | 2435 compiler.backend.registerTypeVariableExpression(mapping); |
| 2435 // Set the type of the node to [Type] to mark this send as a | 2436 // Set the type of the node to [Type] to mark this send as a |
| 2436 // type variable expression. | 2437 // type variable expression. |
| 2437 mapping.setType(node, compiler.typeClass.computeType(compiler)); | 2438 mapping.setType(node, compiler.typeClass.computeType(compiler)); |
| 2438 world.registerTypeLiteral(target, mapping); | 2439 world.registerTypeLiteral(target, mapping); |
| 2439 } else if (target.impliesType() && !sendIsMemberAccess) { | 2440 } else if (target.impliesType() && !sendIsMemberAccess) { |
| 2440 // Set the type of the node to [Type] to mark this send as a | 2441 // Set the type of the node to [Type] to mark this send as a |
| 2441 // type literal. | 2442 // type literal. |
| 2442 mapping.setType(node, compiler.typeClass.computeType(compiler)); | 2443 mapping.setType(node, compiler.typeClass.computeType(compiler)); |
| 2443 world.registerTypeLiteral(target, mapping); | 2444 world.registerTypeLiteral(target, mapping); |
| 2444 analyzeConstant(node); | 2445 |
| 2446 // Don't try to make constants of calls to type literals. | |
| 2447 analyzeConstant(node, isConst: !node.isCall); | |
| 2445 } | 2448 } |
| 2446 } | 2449 } |
| 2447 | 2450 |
| 2448 bool resolvedArguments = false; | 2451 bool resolvedArguments = false; |
| 2449 if (node.isOperator) { | 2452 if (node.isOperator) { |
| 2450 String operatorString = node.selector.asOperator().source.stringValue; | 2453 String operatorString = node.selector.asOperator().source.stringValue; |
| 2451 if (identical(operatorString, 'is')) { | 2454 if (identical(operatorString, 'is')) { |
| 2452 DartType type = | 2455 DartType type = |
| 2453 resolveTypeExpression(node.typeAnnotationFromIsCheckOrCast); | 2456 resolveTypeExpression(node.typeAnnotationFromIsCheckOrCast); |
| 2454 if (type != null) { | 2457 if (type != null) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2885 } else if (isMirrorsUsedConstant) { | 2888 } else if (isMirrorsUsedConstant) { |
| 2886 compiler.mirrorUsageAnalyzerTask.validate(node, mapping); | 2889 compiler.mirrorUsageAnalyzerTask.validate(node, mapping); |
| 2887 } | 2890 } |
| 2888 if (node.isConst()) { | 2891 if (node.isConst()) { |
| 2889 analyzeConstant(node); | 2892 analyzeConstant(node); |
| 2890 } | 2893 } |
| 2891 | 2894 |
| 2892 return null; | 2895 return null; |
| 2893 } | 2896 } |
| 2894 | 2897 |
| 2895 void analyzeConstant(Node node) { | 2898 void analyzeConstant(Node node, {bool isConst: true}) { |
| 2896 addPostProcessAction(enclosingElement, () { | 2899 addPostProcessAction(enclosingElement, () { |
| 2897 mapping.setConstant(node, | 2900 compiler.constantHandler.compileNodeWithDefinitions( |
| 2898 compiler.constantHandler.compileNodeWithDefinitions( | 2901 node, mapping, isConst: isConst); |
| 2899 node, mapping, isConst: true)); | |
| 2900 }); | 2902 }); |
| 2901 } | 2903 } |
| 2902 | 2904 |
| 2903 bool validateSymbol(Node node, String name, {bool reportError: true}) { | 2905 bool validateSymbol(Node node, String name, {bool reportError: true}) { |
| 2904 if (name.isEmpty) return true; | 2906 if (name.isEmpty) return true; |
| 2905 if (name.startsWith('_')) { | 2907 if (name.startsWith('_')) { |
| 2906 if (reportError) { | 2908 if (reportError) { |
| 2907 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER, | 2909 compiler.reportError(node, MessageKind.PRIVATE_IDENTIFIER, |
| 2908 {'value': name}); | 2910 {'value': name}); |
| 2909 } | 2911 } |
| (...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4483 return e; | 4485 return e; |
| 4484 } | 4486 } |
| 4485 | 4487 |
| 4486 /// Assumed to be called by [resolveRedirectingFactory]. | 4488 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4487 Element visitReturn(Return node) { | 4489 Element visitReturn(Return node) { |
| 4488 Node expression = node.expression; | 4490 Node expression = node.expression; |
| 4489 return finishConstructorReference(visit(expression), | 4491 return finishConstructorReference(visit(expression), |
| 4490 expression, expression); | 4492 expression, expression); |
| 4491 } | 4493 } |
| 4492 } | 4494 } |
| OLD | NEW |