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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_number.dart

Issue 1079253002: Use native behavior for dead code elimination (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler
9 * recognizes this class as an interceptor, and changes references to 9 * recognizes this class as an interceptor, and changes references to
10 * [:this:] to actually use the receiver of the method, which is 10 * [:this:] to actually use the receiver of the method, which is
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 bool get isFinite => JS('bool', r'isFinite(#)', this); 52 bool get isFinite => JS('bool', r'isFinite(#)', this);
53 53
54 num remainder(num b) { 54 num remainder(num b) {
55 checkNull(b); // TODO(ngeoffray): This is not specified but co19 tests it. 55 checkNull(b); // TODO(ngeoffray): This is not specified but co19 tests it.
56 if (b is! num) throw new ArgumentError(b); 56 if (b is! num) throw new ArgumentError(b);
57 return JS('num', r'# % #', this, b); 57 return JS('num', r'# % #', this, b);
58 } 58 }
59 59
60 num abs() => JS('num', r'Math.abs(#)', this); 60 num abs() => JS('returns:num;effects:none;depends:none;throws:never',
61 r'Math.abs(#)', this);
61 62
62 num get sign => this > 0 ? 1 : this < 0 ? -1 : this; 63 num get sign => this > 0 ? 1 : this < 0 ? -1 : this;
63 64
64 static const int _MIN_INT32 = -0x80000000; 65 static const int _MIN_INT32 = -0x80000000;
65 static const int _MAX_INT32 = 0x7FFFFFFF; 66 static const int _MAX_INT32 = 0x7FFFFFFF;
66 67
67 int toInt() { 68 int toInt() {
68 if (this >= _MIN_INT32 && this <= _MAX_INT32) { 69 if (this >= _MIN_INT32 && this <= _MAX_INT32) {
69 return JS('int', '# | 0', this); 70 return JS('int', '# | 0', this);
70 } 71 }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 458 }
458 459
459 class JSDouble extends JSNumber implements double { 460 class JSDouble extends JSNumber implements double {
460 const JSDouble(); 461 const JSDouble();
461 Type get runtimeType => double; 462 Type get runtimeType => double;
462 } 463 }
463 464
464 class JSPositiveInt extends JSInt {} 465 class JSPositiveInt extends JSInt {}
465 class JSUInt32 extends JSPositiveInt {} 466 class JSUInt32 extends JSPositiveInt {}
466 class JSUInt31 extends JSUInt32 {} 467 class JSUInt31 extends JSUInt32 {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698