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

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

Issue 1308153007: Revert "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
« 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;
54 import 'label_scope.dart' show 53 import 'label_scope.dart' show
55 StatementScope; 54 StatementScope;
56 import 'registry.dart' show 55 import 'registry.dart' show
57 ResolutionRegistry; 56 ResolutionRegistry;
58 import 'resolution.dart' show 57 import 'resolution.dart' show
59 ResolverTask; 58 ResolverTask;
60 import 'resolution_common.dart' show 59 import 'resolution_common.dart' show
61 MappingVisitor; 60 MappingVisitor;
62 import 'resolution_result.dart'; 61 import 'resolution_result.dart';
63 import 'scope.dart' show 62 import 'scope.dart' show
(...skipping 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 if (!enclosingElement.isFactoryConstructor) { 3629 if (!enclosingElement.isFactoryConstructor) {
3631 compiler.reportError( 3630 compiler.reportError(
3632 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY); 3631 node, MessageKind.FACTORY_REDIRECTION_IN_NON_FACTORY);
3633 compiler.reportHint( 3632 compiler.reportHint(
3634 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD); 3633 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD);
3635 } 3634 }
3636 ConstructorElementX constructor = enclosingElement; 3635 ConstructorElementX constructor = enclosingElement;
3637 bool isConstConstructor = constructor.isConst; 3636 bool isConstConstructor = constructor.isConst;
3638 bool isValidAsConstant = isConstConstructor; 3637 bool isValidAsConstant = isConstConstructor;
3639 ConstructorElement redirectionTarget = resolveRedirectingFactory( 3638 ConstructorElement redirectionTarget = resolveRedirectingFactory(
3640 node, inConstContext: isConstConstructor).element; 3639 node, inConstContext: isConstConstructor);
3641 constructor.immediateRedirectionTarget = redirectionTarget; 3640 constructor.immediateRedirectionTarget = redirectionTarget;
3642 3641
3643 Node constructorReference = node.constructorReference; 3642 Node constructorReference = node.constructorReference;
3644 if (constructorReference is Send) { 3643 if (constructorReference is Send) {
3645 constructor.redirectionDeferredPrefix = 3644 constructor.redirectionDeferredPrefix =
3646 compiler.deferredLoadTask.deferredPrefixElement(constructorReference, 3645 compiler.deferredLoadTask.deferredPrefixElement(constructorReference,
3647 registry.mapping); 3646 registry.mapping);
3648 } 3647 }
3649 3648
3650 registry.setRedirectingTargetConstructor(node, redirectionTarget); 3649 registry.setRedirectingTargetConstructor(node, redirectionTarget);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3808 allowedCategory = oldCategory; 3807 allowedCategory = oldCategory;
3809 sendIsMemberAccess = oldSendIsMemberAccess; 3808 sendIsMemberAccess = oldSendIsMemberAccess;
3810 if (result.kind == ResultKind.CONSTANT) { 3809 if (result.kind == ResultKind.CONSTANT) {
3811 return result; 3810 return result;
3812 } 3811 }
3813 return const NoneResult(); 3812 return const NoneResult();
3814 } 3813 }
3815 3814
3816 ResolutionResult visitNewExpression(NewExpression node) { 3815 ResolutionResult visitNewExpression(NewExpression node) {
3817 bool isValidAsConstant = true; 3816 bool isValidAsConstant = true;
3818 ConstructorElement constructor = resolveConstructor(node).element; 3817 FunctionElement constructor = resolveConstructor(node);
3819 final bool isSymbolConstructor = constructor == compiler.symbolConstructor; 3818 final bool isSymbolConstructor = constructor == compiler.symbolConstructor;
3820 final bool isMirrorsUsedConstant = 3819 final bool isMirrorsUsedConstant =
3821 node.isConst && (constructor == compiler.mirrorsUsedConstructor); 3820 node.isConst && (constructor == compiler.mirrorsUsedConstructor);
3822 Selector callSelector = resolveSelector(node.send, constructor); 3821 Selector callSelector = resolveSelector(node.send, constructor);
3823 ArgumentsResult argumentsResult; 3822 ArgumentsResult argumentsResult;
3824 if (node.isConst) { 3823 if (node.isConst) {
3825 argumentsResult = 3824 argumentsResult =
3826 inConstantContext(() => resolveArguments(node.send.argumentsNode)); 3825 inConstantContext(() => resolveArguments(node.send.argumentsNode));
3827 } else { 3826 } else {
3828 argumentsResult = resolveArguments(node.send.argumentsNode); 3827 argumentsResult = resolveArguments(node.send.argumentsNode);
(...skipping 21 matching lines...) Expand all
3850 InterfaceType type = registry.getType(node); 3849 InterfaceType type = registry.getType(node);
3851 if (node.isConst && type.containsTypeVariables) { 3850 if (node.isConst && type.containsTypeVariables) {
3852 compiler.reportError(node.send.selector, 3851 compiler.reportError(node.send.selector,
3853 MessageKind.TYPE_VARIABLE_IN_CONSTANT); 3852 MessageKind.TYPE_VARIABLE_IN_CONSTANT);
3854 isValidAsConstant = false; 3853 isValidAsConstant = false;
3855 } 3854 }
3856 // TODO(johniwinther): Avoid registration of `type` in face of redirecting 3855 // TODO(johniwinther): Avoid registration of `type` in face of redirecting
3857 // factory constructors. 3856 // factory constructors.
3858 registry.registerInstantiatedType(type); 3857 registry.registerInstantiatedType(type);
3859 if (constructor.isGenerativeConstructor && cls.isAbstract) { 3858 if (constructor.isGenerativeConstructor && cls.isAbstract) {
3859 warning(node, MessageKind.ABSTRACT_CLASS_INSTANTIATION);
3860 registry.registerAbstractClassInstantiation();
3860 isValidAsConstant = false; 3861 isValidAsConstant = false;
3861 } 3862 }
3862 3863
3863 if (isSymbolConstructor) { 3864 if (isSymbolConstructor) {
3864 if (node.isConst) { 3865 if (node.isConst) {
3865 Node argumentNode = node.send.arguments.head; 3866 Node argumentNode = node.send.arguments.head;
3866 ConstantExpression constant = 3867 ConstantExpression constant =
3867 compiler.resolver.constantCompiler.compileNode( 3868 compiler.resolver.constantCompiler.compileNode(
3868 argumentNode, registry.mapping); 3869 argumentNode, registry.mapping);
3869 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
3985 return false; 3986 return false;
3986 } 3987 }
3987 return true; 3988 return true;
3988 } 3989 }
3989 3990
3990 /** 3991 /**
3991 * Try to resolve the constructor that is referred to by [node]. 3992 * Try to resolve the constructor that is referred to by [node].
3992 * Note: this function may return an ErroneousFunctionElement instead of 3993 * Note: this function may return an ErroneousFunctionElement instead of
3993 * [:null:], if there is no corresponding constructor, class or library. 3994 * [:null:], if there is no corresponding constructor, class or library.
3994 */ 3995 */
3995 ConstructorResult resolveConstructor(NewExpression node) { 3996 ConstructorElement resolveConstructor(NewExpression node) {
3996 return node.accept(new ConstructorResolver( 3997 return node.accept(new ConstructorResolver(compiler, this));
3997 compiler, this, inConstContext: node.isConst));
3998 } 3998 }
3999 3999
4000 ConstructorResult resolveRedirectingFactory(RedirectingFactoryBody node, 4000 ConstructorElement resolveRedirectingFactory(RedirectingFactoryBody node,
4001 {bool inConstContext: false}) { 4001 {bool inConstContext: false}) {
4002 return node.accept(new ConstructorResolver( 4002 return node.accept(new ConstructorResolver(compiler, this,
4003 compiler, this, inConstContext: inConstContext)); 4003 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