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

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

Issue 2620023002: Use elements/types in constants/values (Closed)
Patch Set: Created 3 years, 11 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 Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compile_time_constants.dart'; 10 import '../compile_time_constants.dart';
(...skipping 3998 matching lines...) Expand 10 before | Expand all | Expand 10 after
4009 } 4009 }
4010 4010
4011 return resolutionResult; 4011 return resolutionResult;
4012 } 4012 }
4013 4013
4014 void checkConstMapKeysDontOverrideEquals( 4014 void checkConstMapKeysDontOverrideEquals(
4015 Spannable spannable, MapConstantValue map) { 4015 Spannable spannable, MapConstantValue map) {
4016 for (ConstantValue key in map.keys) { 4016 for (ConstantValue key in map.keys) {
4017 if (!key.isObject) continue; 4017 if (!key.isObject) continue;
4018 ObjectConstantValue objectConstant = key; 4018 ObjectConstantValue objectConstant = key;
4019 ResolutionDartType keyType = objectConstant.type; 4019 ResolutionInterfaceType keyType = objectConstant.type;
4020 ClassElement cls = keyType.element; 4020 ClassElement cls = keyType.element;
4021 if (cls == commonElements.stringClass) continue; 4021 if (cls == commonElements.stringClass) continue;
4022 Element equals = cls.lookupMember('=='); 4022 Element equals = cls.lookupMember('==');
4023 if (equals.enclosingClass != commonElements.objectClass) { 4023 if (equals.enclosingClass != commonElements.objectClass) {
4024 reporter.reportErrorMessage(spannable, 4024 reporter.reportErrorMessage(spannable,
4025 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, {'type': keyType}); 4025 MessageKind.CONST_MAP_KEY_OVERRIDES_EQUALS, {'type': keyType});
4026 } 4026 }
4027 } 4027 }
4028 } 4028 }
4029 4029
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
4482 4482
4483 ResolutionDartType typeOfConstant(ConstantValue constant) { 4483 ResolutionDartType typeOfConstant(ConstantValue constant) {
4484 if (constant.isInt) return commonElements.intType; 4484 if (constant.isInt) return commonElements.intType;
4485 if (constant.isBool) return commonElements.boolType; 4485 if (constant.isBool) return commonElements.boolType;
4486 if (constant.isDouble) return commonElements.doubleType; 4486 if (constant.isDouble) return commonElements.doubleType;
4487 if (constant.isString) return commonElements.stringType; 4487 if (constant.isString) return commonElements.stringType;
4488 if (constant.isNull) return commonElements.nullType; 4488 if (constant.isNull) return commonElements.nullType;
4489 if (constant.isFunction) return commonElements.functionType; 4489 if (constant.isFunction) return commonElements.functionType;
4490 assert(constant.isObject); 4490 assert(constant.isObject);
4491 ObjectConstantValue objectConstant = constant; 4491 ObjectConstantValue objectConstant = constant;
4492 return objectConstant.type; 4492 ResolutionInterfaceType type = objectConstant.type;
4493 return type;
4493 } 4494 }
4494 4495
4495 bool overridesEquals(ResolutionDartType type) { 4496 bool overridesEquals(ResolutionDartType type) {
4496 ClassElement cls = type.element; 4497 ClassElement cls = type.element;
4497 Element equals = cls.lookupMember('=='); 4498 Element equals = cls.lookupMember('==');
4498 return equals.enclosingClass != commonElements.objectClass; 4499 return equals.enclosingClass != commonElements.objectClass;
4499 } 4500 }
4500 4501
4501 void checkCaseExpressions(SwitchStatement node) { 4502 void checkCaseExpressions(SwitchStatement node) {
4502 CaseMatch firstCase = null; 4503 CaseMatch firstCase = null;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
4762 } 4763 }
4763 return const NoneResult(); 4764 return const NoneResult();
4764 } 4765 }
4765 } 4766 }
4766 4767
4767 /// Looks up [name] in [scope] and unwraps the result. 4768 /// Looks up [name] in [scope] and unwraps the result.
4768 Element lookupInScope( 4769 Element lookupInScope(
4769 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4770 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4770 return Elements.unwrap(scope.lookup(name), reporter, node); 4771 return Elements.unwrap(scope.lookup(name), reporter, node);
4771 } 4772 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698