| 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 library dart2js.resolution.members; | 5 library dart2js.resolution.members; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/names.dart' show Selectors; | 8 import '../common/names.dart' show Selectors; |
| 9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
| 10 import '../compile_time_constants.dart'; | 10 import '../compile_time_constants.dart'; |
| (...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2855 : new StaticAccess.staticMethod(method); | 2855 : new StaticAccess.staticMethod(method); |
| 2856 } else { | 2856 } else { |
| 2857 // `a = b`, `a++` or `a += b` where `a` is a field. | 2857 // `a = b`, `a++` or `a += b` where `a` is a field. |
| 2858 assert(invariant(node, member.isField, | 2858 assert(invariant(node, member.isField, |
| 2859 message: "Unexpected element: $member.")); | 2859 message: "Unexpected element: $member.")); |
| 2860 if (node.isComplex) { | 2860 if (node.isComplex) { |
| 2861 // `a++` or `a += b` where `a` is a field. | 2861 // `a++` or `a += b` where `a` is a field. |
| 2862 registry.registerStaticUse(new StaticUse.staticGet(member)); | 2862 registry.registerStaticUse(new StaticUse.staticGet(member)); |
| 2863 } | 2863 } |
| 2864 if (member.isFinal || member.isConst) { | 2864 if (member.isFinal || member.isConst) { |
| 2865 reportAndCreateErroneousElement( | 2865 reportAndCreateErroneousElement(node.selector, name.text, |
| 2866 node.selector, | 2866 MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER, {'name': name}); |
| 2867 name.text, | |
| 2868 MessageKind.UNDEFINED_STATIC_SETTER_BUT_GETTER, | |
| 2869 {'name': name}); | |
| 2870 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); | 2867 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); |
| 2871 semantics = member.isTopLevel | 2868 semantics = member.isTopLevel |
| 2872 ? new StaticAccess.finalTopLevelField(member) | 2869 ? new StaticAccess.finalTopLevelField(member) |
| 2873 : new StaticAccess.finalStaticField(member); | 2870 : new StaticAccess.finalStaticField(member); |
| 2874 } else { | 2871 } else { |
| 2875 registry.registerStaticUse(new StaticUse.staticSet(member)); | 2872 registry.registerStaticUse(new StaticUse.staticSet(member)); |
| 2876 semantics = member.isTopLevel | 2873 semantics = member.isTopLevel |
| 2877 ? new StaticAccess.topLevelField(member) | 2874 ? new StaticAccess.topLevelField(member) |
| 2878 : new StaticAccess.staticField(member); | 2875 : new StaticAccess.staticField(member); |
| 2879 } | 2876 } |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3607 reporter.reportErrorMessage(node, MessageKind.RETURN_IN_GENERATOR, | 3604 reporter.reportErrorMessage(node, MessageKind.RETURN_IN_GENERATOR, |
| 3608 {'modifier': currentAsyncMarker}); | 3605 {'modifier': currentAsyncMarker}); |
| 3609 } | 3606 } |
| 3610 } | 3607 } |
| 3611 visit(node.expression); | 3608 visit(node.expression); |
| 3612 return const NoneResult(); | 3609 return const NoneResult(); |
| 3613 } | 3610 } |
| 3614 | 3611 |
| 3615 ResolutionResult visitYield(Yield node) { | 3612 ResolutionResult visitYield(Yield node) { |
| 3616 if (!resolution.target.supportsAsyncAwait) { | 3613 if (!resolution.target.supportsAsyncAwait) { |
| 3617 reporter.reportErrorMessage( | 3614 reporter.reportErrorMessage(reporter.spanFromToken(node.yieldToken), |
| 3618 reporter.spanFromToken(node.yieldToken), | |
| 3619 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3615 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
| 3620 } else { | 3616 } else { |
| 3621 if (!currentAsyncMarker.isYielding) { | 3617 if (!currentAsyncMarker.isYielding) { |
| 3622 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); | 3618 reporter.reportErrorMessage(node, MessageKind.INVALID_YIELD); |
| 3623 } | 3619 } |
| 3624 ClassElement cls; | 3620 ClassElement cls; |
| 3625 if (currentAsyncMarker.isAsync) { | 3621 if (currentAsyncMarker.isAsync) { |
| 3626 cls = commonElements.streamClass; | 3622 cls = commonElements.streamClass; |
| 3627 } else { | 3623 } else { |
| 3628 cls = commonElements.iterableClass; | 3624 cls = commonElements.iterableClass; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3749 } | 3745 } |
| 3750 | 3746 |
| 3751 ResolutionResult visitThrow(Throw node) { | 3747 ResolutionResult visitThrow(Throw node) { |
| 3752 registry.registerFeature(Feature.THROW_EXPRESSION); | 3748 registry.registerFeature(Feature.THROW_EXPRESSION); |
| 3753 visit(node.expression); | 3749 visit(node.expression); |
| 3754 return const NoneResult(); | 3750 return const NoneResult(); |
| 3755 } | 3751 } |
| 3756 | 3752 |
| 3757 ResolutionResult visitAwait(Await node) { | 3753 ResolutionResult visitAwait(Await node) { |
| 3758 if (!resolution.target.supportsAsyncAwait) { | 3754 if (!resolution.target.supportsAsyncAwait) { |
| 3759 reporter.reportErrorMessage( | 3755 reporter.reportErrorMessage(reporter.spanFromToken(node.awaitToken), |
| 3760 reporter.spanFromToken(node.awaitToken), | |
| 3761 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 3756 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
| 3762 } else { | 3757 } else { |
| 3763 if (!currentAsyncMarker.isAsync) { | 3758 if (!currentAsyncMarker.isAsync) { |
| 3764 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); | 3759 reporter.reportErrorMessage(node, MessageKind.INVALID_AWAIT); |
| 3765 } | 3760 } |
| 3766 ClassElement futureClass = commonElements.futureClass; | 3761 ClassElement futureClass = commonElements.futureClass; |
| 3767 futureClass.ensureResolved(resolution); | 3762 futureClass.ensureResolved(resolution); |
| 3768 } | 3763 } |
| 3769 visit(node.expression); | 3764 visit(node.expression); |
| 3770 return const NoneResult(); | 3765 return const NoneResult(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4015 registry.registerNewStructure(node, structure.resolve(node)); | 4010 registry.registerNewStructure(node, structure.resolve(node)); |
| 4016 }; | 4011 }; |
| 4017 } | 4012 } |
| 4018 | 4013 |
| 4019 analyzeConstantDeferred(node, onAnalyzed: onAnalyzed); | 4014 analyzeConstantDeferred(node, onAnalyzed: onAnalyzed); |
| 4020 } else { | 4015 } else { |
| 4021 // Not constant. | 4016 // Not constant. |
| 4022 if (resolution.commonElements.isSymbolConstructor(constructor) && | 4017 if (resolution.commonElements.isSymbolConstructor(constructor) && |
| 4023 !resolution.mirrorUsageAnalyzerTask | 4018 !resolution.mirrorUsageAnalyzerTask |
| 4024 .hasMirrorUsage(enclosingElement)) { | 4019 .hasMirrorUsage(enclosingElement)) { |
| 4025 reporter.reportHintMessage(reporter.spanFromToken(node.newToken), | 4020 reporter.reportHintMessage( |
| 4021 reporter.spanFromToken(node.newToken), |
| 4026 MessageKind.NON_CONST_BLOAT, | 4022 MessageKind.NON_CONST_BLOAT, |
| 4027 {'name': commonElements.symbolClass.name}); | 4023 {'name': commonElements.symbolClass.name}); |
| 4028 } | 4024 } |
| 4029 registry.registerNewStructure( | 4025 registry.registerNewStructure( |
| 4030 node, | 4026 node, |
| 4031 new NewInvokeStructure( | 4027 new NewInvokeStructure( |
| 4032 new ConstructorAccessSemantics(kind, constructor, type), | 4028 new ConstructorAccessSemantics(kind, constructor, type), |
| 4033 selector)); | 4029 selector)); |
| 4034 } | 4030 } |
| 4035 | 4031 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4287 } | 4283 } |
| 4288 label.setContinueTarget(); | 4284 label.setContinueTarget(); |
| 4289 registry.useLabel(node, label); | 4285 registry.useLabel(node, label); |
| 4290 } | 4286 } |
| 4291 registry.registerTargetOf(node, target); | 4287 registry.registerTargetOf(node, target); |
| 4292 return const NoneResult(); | 4288 return const NoneResult(); |
| 4293 } | 4289 } |
| 4294 | 4290 |
| 4295 ResolutionResult visitAsyncForIn(AsyncForIn node) { | 4291 ResolutionResult visitAsyncForIn(AsyncForIn node) { |
| 4296 if (!resolution.target.supportsAsyncAwait) { | 4292 if (!resolution.target.supportsAsyncAwait) { |
| 4297 reporter.reportErrorMessage( | 4293 reporter.reportErrorMessage(reporter.spanFromToken(node.awaitToken), |
| 4298 reporter.spanFromToken(node.awaitToken), | |
| 4299 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); | 4294 MessageKind.ASYNC_AWAIT_NOT_SUPPORTED); |
| 4300 } else { | 4295 } else { |
| 4301 if (!currentAsyncMarker.isAsync) { | 4296 if (!currentAsyncMarker.isAsync) { |
| 4302 reporter.reportErrorMessage( | 4297 reporter.reportErrorMessage(reporter.spanFromToken(node.awaitToken), |
| 4303 reporter.spanFromToken(node.awaitToken), | |
| 4304 MessageKind.INVALID_AWAIT_FOR_IN); | 4298 MessageKind.INVALID_AWAIT_FOR_IN); |
| 4305 } | 4299 } |
| 4306 registry.registerFeature(Feature.ASYNC_FOR_IN); | 4300 registry.registerFeature(Feature.ASYNC_FOR_IN); |
| 4307 registry.registerDynamicUse(new DynamicUse(Selectors.current, null)); | 4301 registry.registerDynamicUse(new DynamicUse(Selectors.current, null)); |
| 4308 registry.registerDynamicUse(new DynamicUse(Selectors.moveNext, null)); | 4302 registry.registerDynamicUse(new DynamicUse(Selectors.moveNext, null)); |
| 4309 } | 4303 } |
| 4310 visit(node.expression); | 4304 visit(node.expression); |
| 4311 | 4305 |
| 4312 Scope blockScope = new BlockScope(scope); | 4306 Scope blockScope = new BlockScope(scope); |
| 4313 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); | 4307 visitForInDeclaredIdentifierIn(node.declaredIdentifier, node, blockScope); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4791 } | 4785 } |
| 4792 return const NoneResult(); | 4786 return const NoneResult(); |
| 4793 } | 4787 } |
| 4794 } | 4788 } |
| 4795 | 4789 |
| 4796 /// Looks up [name] in [scope] and unwraps the result. | 4790 /// Looks up [name] in [scope] and unwraps the result. |
| 4797 Element lookupInScope( | 4791 Element lookupInScope( |
| 4798 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4792 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
| 4799 return Elements.unwrap(scope.lookup(name), reporter, node); | 4793 return Elements.unwrap(scope.lookup(name), reporter, node); |
| 4800 } | 4794 } |
| OLD | NEW |