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

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

Issue 2396173003: Handle constructor declarations. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('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.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 3427 matching lines...) Expand 10 before | Expand all | Expand 10 after
3438 // through the send structure. 3438 // through the send structure.
3439 registry.useElement(node, semantics.setter); 3439 registry.useElement(node, semantics.setter);
3440 registry.useElement(node.selector, semantics.getter); 3440 registry.useElement(node.selector, semantics.getter);
3441 3441
3442 // TODO(23998): Remove these when selectors are only accessed 3442 // TODO(23998): Remove these when selectors are only accessed
3443 // through the send structure. 3443 // through the send structure.
3444 registry.setGetterSelectorInComplexSendSet(node, getterSelector); 3444 registry.setGetterSelectorInComplexSendSet(node, getterSelector);
3445 registry.setSelector(node, setterSelector); 3445 registry.setSelector(node, setterSelector);
3446 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector); 3446 registry.setOperatorSelectorInComplexSendSet(node, operatorSelector);
3447 3447
3448 registry.registerDynamicUse(new DynamicUse(operatorSelector, null));
3449
3450 SendStructure sendStructure; 3448 SendStructure sendStructure;
3451 if (operator.kind == AssignmentOperatorKind.IF_NULL) { 3449 if (operator.kind == AssignmentOperatorKind.IF_NULL) {
3450 registry.registerConstantLiteral(new NullConstantExpression());
3451 registry.registerDynamicUse(new DynamicUse(Selectors.equals, null));
3452 sendStructure = new SetIfNullStructure(semantics); 3452 sendStructure = new SetIfNullStructure(semantics);
3453 } else { 3453 } else {
3454 registry.registerDynamicUse(new DynamicUse(operatorSelector, null));
3454 sendStructure = new CompoundStructure(semantics, operator); 3455 sendStructure = new CompoundStructure(semantics, operator);
3455 } 3456 }
3456 registry.registerSendStructure(node, sendStructure); 3457 registry.registerSendStructure(node, sendStructure);
3457 } 3458 }
3458 } 3459 }
3459 return new ResolutionResult.forElement(semantics.setter); 3460 return new ResolutionResult.forElement(semantics.setter);
3460 } 3461 }
3461 3462
3462 ResolutionResult visitSendSet(SendSet node) { 3463 ResolutionResult visitSendSet(SendSet node) {
3463 if (node.isIndex) { 3464 if (node.isIndex) {
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3881 type), 3882 type),
3882 selector)); 3883 selector));
3883 return new ResolutionResult.forElement(constructor); 3884 return new ResolutionResult.forElement(constructor);
3884 } 3885 }
3885 3886
3886 if (!isInvalid) { 3887 if (!isInvalid) {
3887 // [constructor] might be the implementation element 3888 // [constructor] might be the implementation element
3888 // and only declaration elements may be registered. 3889 // and only declaration elements may be registered.
3889 // TODO(johniwinther): Avoid registration of `type` in face of redirecting 3890 // TODO(johniwinther): Avoid registration of `type` in face of redirecting
3890 // factory constructors. 3891 // factory constructors.
3891 registry.registerStaticUse( 3892 registry.registerStaticUse(node.isConst
3892 node.isConst 3893 ? new StaticUse.constConstructorInvoke(
3893 ? new StaticUse.constConstructorInvoke(
3894 constructor.declaration, callStructure, type) 3894 constructor.declaration, callStructure, type)
3895 : new StaticUse.typedConstructorInvoke( 3895 : new StaticUse.typedConstructorInvoke(
3896 constructor.declaration, callStructure, type)); 3896 constructor.declaration, callStructure, type));
3897 InterfaceType interfaceType = type; 3897 InterfaceType interfaceType = type;
3898 if (interfaceType.typeArguments.any((DartType type) => !type.isDynamic)) { 3898 if (interfaceType.typeArguments.any((DartType type) => !type.isDynamic)) {
3899 registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK); 3899 registry.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
3900 } 3900 }
3901 } 3901 }
3902 3902
3903 ResolutionResult resolutionResult = const NoneResult(); 3903 ResolutionResult resolutionResult = const NoneResult();
3904 if (node.isConst) { 3904 if (node.isConst) {
3905 bool isValidAsConstant = !isInvalid && constructor.isConst; 3905 bool isValidAsConstant = !isInvalid && constructor.isConst;
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
4743 } 4743 }
4744 return const NoneResult(); 4744 return const NoneResult();
4745 } 4745 }
4746 } 4746 }
4747 4747
4748 /// Looks up [name] in [scope] and unwraps the result. 4748 /// Looks up [name] in [scope] and unwraps the result.
4749 Element lookupInScope( 4749 Element lookupInScope(
4750 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4750 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4751 return Elements.unwrap(scope.lookup(name), reporter, node); 4751 return Elements.unwrap(scope.lookup(name), reporter, node);
4752 } 4752 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/kernel_impact.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698