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

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

Issue 1880323002: dart2js cleanup: remove unused imports and variables (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge master Created 4 years, 8 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.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 Feature; 9 import '../common/resolution.dart' show Feature;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
11 import '../constants/constructors.dart' 11 import '../constants/constructors.dart'
12 show RedirectingFactoryConstantConstructor; 12 show RedirectingFactoryConstantConstructor;
13 import '../constants/expressions.dart'; 13 import '../constants/expressions.dart';
14 import '../constants/values.dart'; 14 import '../constants/values.dart';
15 import '../core_types.dart'; 15 import '../core_types.dart';
16 import '../dart_types.dart'; 16 import '../dart_types.dart';
17 import '../elements/elements.dart'; 17 import '../elements/elements.dart';
18 import '../elements/modelx.dart' 18 import '../elements/modelx.dart'
19 show 19 show
20 ConstructorElementX, 20 ConstructorElementX,
21 ErroneousElementX, 21 ErroneousElementX,
22 FunctionElementX, 22 FunctionElementX,
23 JumpTargetX, 23 JumpTargetX,
24 LocalFunctionElementX, 24 LocalFunctionElementX,
25 LocalParameterElementX, 25 LocalParameterElementX,
26 LocalVariableElementX,
27 MethodElementX, 26 MethodElementX,
28 ParameterElementX, 27 ParameterElementX,
29 VariableElementX, 28 VariableElementX,
30 VariableList; 29 VariableList;
31 import '../tokens/token.dart' show isUserDefinableOperator; 30 import '../tokens/token.dart' show isUserDefinableOperator;
32 import '../tree/tree.dart'; 31 import '../tree/tree.dart';
33 import '../util/util.dart' show Link;
34 import '../universe/call_structure.dart' show CallStructure; 32 import '../universe/call_structure.dart' show CallStructure;
35 import '../universe/selector.dart' show Selector; 33 import '../universe/selector.dart' show Selector;
36 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; 34 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse;
37 35 import '../util/util.dart' show Link;
38 import 'access_semantics.dart'; 36 import 'access_semantics.dart';
39 import 'class_members.dart' show MembersCreator; 37 import 'class_members.dart' show MembersCreator;
40 import 'operators.dart';
41 import 'send_structure.dart';
42
43 import 'constructors.dart' 38 import 'constructors.dart'
44 show ConstructorResolver, ConstructorResult, ConstructorResultKind; 39 show ConstructorResolver, ConstructorResult, ConstructorResultKind;
45 import 'label_scope.dart' show StatementScope; 40 import 'label_scope.dart' show StatementScope;
41 import 'operators.dart';
46 import 'registry.dart' show ResolutionRegistry; 42 import 'registry.dart' show ResolutionRegistry;
47 import 'resolution.dart' show ResolverTask; 43 import 'resolution.dart' show ResolverTask;
48 import 'resolution_common.dart' show MappingVisitor; 44 import 'resolution_common.dart' show MappingVisitor;
49 import 'resolution_result.dart'; 45 import 'resolution_result.dart';
50 import 'scope.dart' show BlockScope, MethodScope, Scope; 46 import 'scope.dart' show BlockScope, MethodScope, Scope;
47 import 'send_structure.dart';
51 import 'signatures.dart' show SignatureResolver; 48 import 'signatures.dart' show SignatureResolver;
52 import 'variables.dart' show VariableDefinitionsVisitor; 49 import 'variables.dart' show VariableDefinitionsVisitor;
53 50
54 /// The state of constants in resolutions. 51 /// The state of constants in resolutions.
55 enum ConstantState { 52 enum ConstantState {
56 /// Expressions are not required to be constants. 53 /// Expressions are not required to be constants.
57 NON_CONSTANT, 54 NON_CONSTANT,
58 55
59 /// Expressions are required to be constants. 56 /// Expressions are required to be constants.
60 /// 57 ///
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 } 3333 }
3337 return handleUpdate(node, name, semantics); 3334 return handleUpdate(node, name, semantics);
3338 } 3335 }
3339 } 3336 }
3340 } 3337 }
3341 3338
3342 /// Handle update of an entity defined by [semantics]. For instance `a = b`, 3339 /// Handle update of an entity defined by [semantics]. For instance `a = b`,
3343 /// `a++` or `a += b` where [semantics] describe `a`. 3340 /// `a++` or `a += b` where [semantics] describe `a`.
3344 ResolutionResult handleUpdate( 3341 ResolutionResult handleUpdate(
3345 SendSet node, Name name, AccessSemantics semantics) { 3342 SendSet node, Name name, AccessSemantics semantics) {
3346 SendStructure sendStructure;
3347 String operatorText = node.assignmentOperator.source; 3343 String operatorText = node.assignmentOperator.source;
3348 Selector getterSelector = new Selector.getter(name); 3344 Selector getterSelector = new Selector.getter(name);
3349 Selector setterSelector = new Selector.setter(name); 3345 Selector setterSelector = new Selector.setter(name);
3350 if (node.isPrefix || node.isPostfix) { 3346 if (node.isPrefix || node.isPostfix) {
3351 // `e++` or `++e`. 3347 // `e++` or `++e`.
3352 IncDecOperator operator = IncDecOperator.parse(operatorText); 3348 IncDecOperator operator = IncDecOperator.parse(operatorText);
3353 Selector operatorSelector = 3349 Selector operatorSelector =
3354 new Selector.binaryOperator(operator.selectorName); 3350 new Selector.binaryOperator(operator.selectorName);
3355 3351
3356 // TODO(23998): Remove these when selectors are only accessed 3352 // TODO(23998): Remove these when selectors are only accessed
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 } 3557 }
3562 3558
3563 ConstructorElementX constructor = enclosingElement; 3559 ConstructorElementX constructor = enclosingElement;
3564 bool isConstConstructor = constructor.isConst; 3560 bool isConstConstructor = constructor.isConst;
3565 bool isValidAsConstant = isConstConstructor; 3561 bool isValidAsConstant = isConstConstructor;
3566 ConstructorResult result = 3562 ConstructorResult result =
3567 resolveRedirectingFactory(node, inConstContext: isConstConstructor); 3563 resolveRedirectingFactory(node, inConstContext: isConstConstructor);
3568 ConstructorElement redirectionTarget = result.element; 3564 ConstructorElement redirectionTarget = result.element;
3569 constructor.immediateRedirectionTarget = redirectionTarget; 3565 constructor.immediateRedirectionTarget = redirectionTarget;
3570 3566
3571 Node constructorReference = node.constructorReference;
3572 if (result.isDeferred) { 3567 if (result.isDeferred) {
3573 constructor.redirectionDeferredPrefix = result.prefix; 3568 constructor.redirectionDeferredPrefix = result.prefix;
3574 } 3569 }
3575 3570
3576 registry.setRedirectingTargetConstructor(node, redirectionTarget); 3571 registry.setRedirectingTargetConstructor(node, redirectionTarget);
3577 switch (result.kind) { 3572 switch (result.kind) {
3578 case ConstructorResultKind.GENERATIVE: 3573 case ConstructorResultKind.GENERATIVE:
3579 case ConstructorResultKind.FACTORY: 3574 case ConstructorResultKind.FACTORY:
3580 // Register a post process to check for cycles in the redirection chain 3575 // Register a post process to check for cycles in the redirection chain
3581 // and set the actual generative constructor at the end of the chain. 3576 // and set the actual generative constructor at the end of the chain.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 } else { 3760 } else {
3766 argumentsResult = resolveArguments(node.send.argumentsNode); 3761 argumentsResult = resolveArguments(node.send.argumentsNode);
3767 } 3762 }
3768 // TODO(johnniwinther): Avoid the need for a [Selector]. 3763 // TODO(johnniwinther): Avoid the need for a [Selector].
3769 Selector selector = resolveSelector(node.send, constructor); 3764 Selector selector = resolveSelector(node.send, constructor);
3770 CallStructure callStructure = selector.callStructure; 3765 CallStructure callStructure = selector.callStructure;
3771 registry.useElement(node.send, constructor); 3766 registry.useElement(node.send, constructor);
3772 3767
3773 DartType type = result.type; 3768 DartType type = result.type;
3774 ConstructorAccessKind kind; 3769 ConstructorAccessKind kind;
3775 NewStructure newStructure;
3776 bool isInvalid = false; 3770 bool isInvalid = false;
3777 switch (result.kind) { 3771 switch (result.kind) {
3778 case ConstructorResultKind.GENERATIVE: 3772 case ConstructorResultKind.GENERATIVE:
3779 // Ensure that the signature of [constructor] has been computed. 3773 // Ensure that the signature of [constructor] has been computed.
3780 constructor.computeType(resolution); 3774 constructor.computeType(resolution);
3781 if (!callStructure.signatureApplies(constructor.functionSignature)) { 3775 if (!callStructure.signatureApplies(constructor.functionSignature)) {
3782 isInvalid = true; 3776 isInvalid = true;
3783 kind = ConstructorAccessKind.INCOMPATIBLE; 3777 kind = ConstructorAccessKind.INCOMPATIBLE;
3784 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD); 3778 registry.registerFeature(Feature.THROW_NO_SUCH_METHOD);
3785 } else { 3779 } else {
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
4677 } 4671 }
4678 return const NoneResult(); 4672 return const NoneResult();
4679 } 4673 }
4680 } 4674 }
4681 4675
4682 /// Looks up [name] in [scope] and unwraps the result. 4676 /// Looks up [name] in [scope] and unwraps the result.
4683 Element lookupInScope( 4677 Element lookupInScope(
4684 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4678 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4685 return Elements.unwrap(scope.lookup(name), reporter, node); 4679 return Elements.unwrap(scope.lookup(name), reporter, node);
4686 } 4680 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/constructors.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698