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

Side by Side Diff: pkg/compiler/lib/src/constants/values.dart

Issue 1635053002: dart2js: Match the runtime int is check semantics at compile time. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Incorporate review comments. Created 4 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/constant_system_javascript.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.constants.values; 5 library dart2js.constants.values;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../core_types.dart'; 8 import '../core_types.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart' 10 import '../elements/elements.dart'
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 /** Returns true if the constant is a list, a map or a constructed object. */ 57 /** Returns true if the constant is a list, a map or a constructed object. */
58 bool get isObject => false; 58 bool get isObject => false;
59 bool get isType => false; 59 bool get isType => false;
60 bool get isInterceptor => false; 60 bool get isInterceptor => false;
61 bool get isDummy => false; 61 bool get isDummy => false;
62 62
63 bool get isNaN => false; 63 bool get isNaN => false;
64 bool get isMinusZero => false; 64 bool get isMinusZero => false;
65 bool get isZero => false; 65 bool get isZero => false;
66 bool get isOne => false; 66 bool get isOne => false;
67 bool get isPositiveInfinity => false;
68 bool get isNegativeInfinity => false;
67 69
68 // TODO(johnniwinther): Replace with a 'type' getter. 70 // TODO(johnniwinther): Replace with a 'type' getter.
69 DartType getType(CoreTypes types); 71 DartType getType(CoreTypes types);
70 72
71 List<ConstantValue> getDependencies(); 73 List<ConstantValue> getDependencies();
72 74
73 accept(ConstantValueVisitor visitor, arg); 75 accept(ConstantValueVisitor visitor, arg);
74 76
75 /// The value of this constant in Dart syntax, if possible. 77 /// The value of this constant in Dart syntax, if possible.
76 /// 78 ///
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 274
273 bool get isNaN => primitiveValue.isNaN; 275 bool get isNaN => primitiveValue.isNaN;
274 276
275 // We need to check for the negative sign since -0.0 == 0.0. 277 // We need to check for the negative sign since -0.0 == 0.0.
276 bool get isMinusZero => primitiveValue == 0.0 && primitiveValue.isNegative; 278 bool get isMinusZero => primitiveValue == 0.0 && primitiveValue.isNegative;
277 279
278 bool get isZero => primitiveValue == 0.0; 280 bool get isZero => primitiveValue == 0.0;
279 281
280 bool get isOne => primitiveValue == 1.0; 282 bool get isOne => primitiveValue == 1.0;
281 283
284 bool get isPositiveInfinity => primitiveValue == double.INFINITY;
285
286 bool get isNegativeInfinity => primitiveValue == -double.INFINITY;
287
282 DartType getType(CoreTypes types) => types.doubleType; 288 DartType getType(CoreTypes types) => types.doubleType;
283 289
284 bool operator ==(var other) { 290 bool operator ==(var other) {
285 if (other is !DoubleConstantValue) return false; 291 if (other is !DoubleConstantValue) return false;
286 DoubleConstantValue otherDouble = other; 292 DoubleConstantValue otherDouble = other;
287 double otherValue = otherDouble.primitiveValue; 293 double otherValue = otherDouble.primitiveValue;
288 if (primitiveValue == 0.0 && otherValue == 0.0) { 294 if (primitiveValue == 0.0 && otherValue == 0.0) {
289 return primitiveValue.isNegative == otherValue.isNegative; 295 return primitiveValue.isNegative == otherValue.isNegative;
290 } else if (primitiveValue.isNaN) { 296 } else if (primitiveValue.isNaN) {
291 return otherValue.isNaN; 297 return otherValue.isNaN;
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 758
753 @override 759 @override
754 DartType getType(CoreTypes types) => const DynamicType(); 760 DartType getType(CoreTypes types) => const DynamicType();
755 761
756 @override 762 @override
757 String toStructuredString() => 'NonConstant'; 763 String toStructuredString() => 'NonConstant';
758 764
759 @override 765 @override
760 String unparse() => '>>non-constant<<'; 766 String unparse() => '>>non-constant<<';
761 } 767 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/constant_system_javascript.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698