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

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

Issue 1323573002: Prepare for computation of NewStructure in Resolution. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix erroneous prefix. 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/resolution/constructors.dart ('k') | tests/co19/co19-dart2js.status » ('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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 CallStructure, 42 CallStructure,
43 Selector, 43 Selector,
44 UniverseSelector; 44 UniverseSelector;
45 45
46 import 'access_semantics.dart'; 46 import 'access_semantics.dart';
47 import 'class_members.dart' show MembersCreator; 47 import 'class_members.dart' show MembersCreator;
48 import 'operators.dart'; 48 import 'operators.dart';
49 import 'send_structure.dart'; 49 import 'send_structure.dart';
50 50
51 import 'constructors.dart' show 51 import 'constructors.dart' show
52 ConstructorResolver; 52 ConstructorResolver,
53 ConstructorResult;
53 import 'label_scope.dart' show 54 import 'label_scope.dart' show
54 StatementScope; 55 StatementScope;
55 import 'registry.dart' show 56 import 'registry.dart' show
56 ResolutionRegistry; 57 ResolutionRegistry;
57 import 'resolution.dart' show 58 import 'resolution.dart' show
58 ResolverTask; 59 ResolverTask;
59 import 'resolution_common.dart' show 60 import 'resolution_common.dart' show
60 MappingVisitor; 61 MappingVisitor;
61 import 'resolution_result.dart'; 62 import 'resolution_result.dart';
62 import 'scope.dart' show 63 import 'scope.dart' show
(...skipping 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3629 if (!enclosingElement.isFactoryConstructor) { 3630 if (!enclosingElement.isFactoryConstructor) {
3630 compiler.reportError( 3631 compiler.reportError(
3631 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); 3632 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY);
3632 compiler.reportHint( 3633 compiler.reportHint(
3633 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD); 3634 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD);
3634 } 3635 }
3635 ConstructorElementX constructor = enclosingElement; 3636 ConstructorElementX constructor = enclosingElement;
3636 bool isConstConstructor = constructor.isConst; 3637 bool isConstConstructor = constructor.isConst;
3637 bool isValidAsConstant = isConstConstructor; 3638 bool isValidAsConstant = isConstConstructor;
3638 ConstructorElement redirectionTarget = resolveRedirectingFactory( 3639 ConstructorElement redirectionTarget = resolveRedirectingFactory(
3639 node, inConstContext: isConstConstructor); 3640 node, inConstContext: isConstConstructor).element;
3640 constructor.immediateRedirectionTarget = redirectionTarget; 3641 constructor.immediateRedirectionTarget = redirectionTarget;
3641 3642
3642 Node constructorReference = node.constructorReference; 3643 Node constructorReference = node.constructorReference;
3643 if (constructorReference is Send) { 3644 if (constructorReference is Send) {
3644 constructor.redirectionDeferredPrefix = 3645 constructor.redirectionDeferredPrefix =
3645 compiler.deferredLoadTask.deferredPrefixElement(constructorReference, 3646 compiler.deferredLoadTask.deferredPrefixElement(constructorReference,
3646 registry.mapping); 3647 registry.mapping);
3647 } 3648 }
3648 3649
3649 registry.setRedirectingTargetConstructor(node, redirectionTarget); 3650 registry.setRedirectingTargetConstructor(node, redirectionTarget);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3807 allowedCategory = oldCategory; 3808 allowedCategory = oldCategory;
3808 sendIsMemberAccess = oldSendIsMemberAccess; 3809 sendIsMemberAccess = oldSendIsMemberAccess;
3809 if (result.kind == ResultKind.CONSTANT) { 3810 if (result.kind == ResultKind.CONSTANT) {
3810 return result; 3811 return result;
3811 } 3812 }
3812 return const NoneResult(); 3813 return const NoneResult();
3813 } 3814 }
3814 3815
3815 ResolutionResult visitNewExpression(NewExpression node) { 3816 ResolutionResult visitNewExpression(NewExpression node) {
3816 bool isValidAsConstant = true; 3817 bool isValidAsConstant = true;
3817 FunctionElement constructor = resolveConstructor(node); 3818 ConstructorElement constructor = resolveConstructor(node).element;
3818 final bool isSymbolConstructor = constructor == compiler.symbolConstructor; 3819 final bool isSymbolConstructor = constructor == compiler.symbolConstructor;
3819 final bool isMirrorsUsedConstant = 3820 final bool isMirrorsUsedConstant =
3820 node.isConst && (constructor == compiler.mirrorsUsedConstructor); 3821 node.isConst && (constructor == compiler.mirrorsUsedConstructor);
3821 Selector callSelector = resolveSelector(node.send, constructor); 3822 Selector callSelector = resolveSelector(node.send, constructor);
3822 ArgumentsResult argumentsResult; 3823 ArgumentsResult argumentsResult;
3823 if (node.isConst) { 3824 if (node.isConst) {
3824 argumentsResult = 3825 argumentsResult =
3825 inConstantContext(() => resolveArguments(node.send.argumentsNode)); 3826 inConstantContext(() => resolveArguments(node.send.argumentsNode));
3826 } else { 3827 } else {
3827 argumentsResult = resolveArguments(node.send.argumentsNode); 3828 argumentsResult = resolveArguments(node.send.argumentsNode);
(...skipping 21 matching lines...) Expand all
3849 InterfaceType type = registry.getType(node); 3850 InterfaceType type = registry.getType(node);
3850 if (node.isConst && type.containsTypeVariables) { 3851 if (node.isConst && type.containsTypeVariables) {
3851 compiler.reportError(node.send.selector, 3852 compiler.reportError(node.send.selector,
3852 MessageKind.TYPE_VARIABLE_IN_CONSTANT); 3853 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
3853 isValidAsConstant = false; 3854 isValidAsConstant = false;
3854 } 3855 }
3855 // TODO(johniwinther): Avoid registration of `type` in face of redirecting 3856 // TODO(johniwinther): Avoid registration of `type` in face of redirecting
3856 // factory constructors. 3857 // factory constructors.
3857 registry.registerInstantiatedType(type); 3858 registry.registerInstantiatedType(type);
3858 if (constructor.isGenerativeConstructor && cls.isAbstract) { 3859 if (constructor.isGenerativeConstructor && cls.isAbstract) {
3859 warning(node, MessageKind.ABSTRACT_CLASS_INSTANTIATION);
3860 registry.registerAbstractClassInstantiation();
3861 isValidAsConstant = false; 3860 isValidAsConstant = false;
3862 } 3861 }
3863 3862
3864 if (isSymbolConstructor) { 3863 if (isSymbolConstructor) {
3865 if (node.isConst) { 3864 if (node.isConst) {
3866 Node argumentNode = node.send.arguments.head; 3865 Node argumentNode = node.send.arguments.head;
3867 ConstantExpression constant = 3866 ConstantExpression constant =
3868 compiler.resolver.constantCompiler.compileNode( 3867 compiler.resolver.constantCompiler.compileNode(
3869 argumentNode, registry.mapping); 3868 argumentNode, registry.mapping);
3870 ConstantValue name = compiler.constants.getConstantValue(constant); 3869 ConstantValue name = compiler.constants.getConstantValue(constant);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3986 return false; 3985 return false;
3987 } 3986 }
3988 return true; 3987 return true;
3989 } 3988 }
3990 3989
3991 /** 3990 /**
3992 * Try to resolve the constructor that is referred to by [node]. 3991 * Try to resolve the constructor that is referred to by [node].
3993 * Note: this function may return an ErroneousFunctionElement instead of 3992 * Note: this function may return an ErroneousFunctionElement instead of
3994 * [:null:], if there is no corresponding constructor, class or library. 3993 * [:null:], if there is no corresponding constructor, class or library.
3995 */ 3994 */
3996 ConstructorElement resolveConstructor(NewExpression node) { 3995 ConstructorResult resolveConstructor(NewExpression node) {
3997 return node.accept(new ConstructorResolver(compiler, this)); 3996 return node.accept(new ConstructorResolver(
3997 compiler, this, inConstContext: node.isConst));
3998 } 3998 }
3999 3999
4000 ConstructorElement resolveRedirectingFactory(RedirectingFactoryBody node, 4000 ConstructorResult resolveRedirectingFactory(RedirectingFactoryBody node,
4001 {bool inConstContext: false}) { 4001 {bool inConstContext: false}) {
4002 return node.accept(new ConstructorResolver(compiler, this, 4002 return node.accept(new ConstructorResolver(
4003 inConstContext: inConstContext)); 4003 compiler, this, inConstContext: inConstContext));
4004 } 4004 }
4005 4005
4006 DartType resolveTypeAnnotation(TypeAnnotation node, 4006 DartType resolveTypeAnnotation(TypeAnnotation node,
4007 {bool malformedIsError: false, 4007 {bool malformedIsError: false,
4008 bool deferredIsMalformed: true}) { 4008 bool deferredIsMalformed: true}) {
4009 DartType type = typeResolver.resolveTypeAnnotation( 4009 DartType type = typeResolver.resolveTypeAnnotation(
4010 this, node, malformedIsError: malformedIsError, 4010 this, node, malformedIsError: malformedIsError,
4011 deferredIsMalformed: deferredIsMalformed); 4011 deferredIsMalformed: deferredIsMalformed);
4012 if (inCheckContext) { 4012 if (inCheckContext) {
4013 registry.registerIsCheck(type); 4013 registry.registerIsCheck(type);
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 } 4644 }
4645 return const NoneResult(); 4645 return const NoneResult();
4646 } 4646 }
4647 } 4647 }
4648 4648
4649 /// Looks up [name] in [scope] and unwraps the result. 4649 /// Looks up [name] in [scope] and unwraps the result.
4650 Element lookupInScope(Compiler compiler, Node node, 4650 Element lookupInScope(Compiler compiler, Node node,
4651 Scope scope, String name) { 4651 Scope scope, String name) {
4652 return Elements.unwrap(scope.lookup(name), compiler, node); 4652 return Elements.unwrap(scope.lookup(name), compiler, node);
4653 } 4653 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/constructors.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698