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

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

Powered by Google App Engine
This is Rietveld 408576698