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

Unified Diff: runtime/lib/integers.dart

Issue 2035453002: Pixels class prototype and test (not to be committed). Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: work in progress Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/double.dart ('k') | runtime/lib/pixels.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/integers.dart
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart
index 0c5b11985bad5dd6648392883097aec8ee5f26cc..f524a7df3982e9e66ce4cdcaf27ca5ad3e965cb6 100644
--- a/runtime/lib/integers.dart
+++ b/runtime/lib/integers.dart
@@ -92,13 +92,16 @@ abstract class _IntegerImplementation {
return other._greaterThanFromInteger(this);
}
bool operator >=(num other) {
- return (this == other) || (this > other);
+ return (this == other) || (this > other);
}
bool operator <=(num other) {
return (this == other) || (this < other);
}
bool _greaterThanFromInteger(int other)
native "Integer_greaterThanFromInteger";
+ bool _greaterThanFromPixels(pixels other) {
+ return other._value > (this << _Pixels._SCALING_BITS);
+ }
bool operator ==(other) {
if (other is num) {
return other._equalToInteger(this);
@@ -106,6 +109,9 @@ abstract class _IntegerImplementation {
return false;
}
bool _equalToInteger(int other) native "Integer_equalToInteger";
+ bool _equalToPixels(pixels other) {
+ return (this << _Pixels._SCALING_BITS) == other._value;
+ }
int abs() {
return this < 0 ? -this : this;
}
@@ -200,8 +206,10 @@ abstract class _IntegerImplementation {
int toInt() { return this; }
double toDouble() { return new _Double.fromInteger(this); }
+ pixels toPixels() { return new _Pixels.fromInteger(this); }
_Bigint _toBigint() { return new _Bigint._fromInt(this); }
- num _toBigintOrDouble() { return _toBigint(); }
+ num _toBigintIfInteger() { return _toBigint(); }
+ num _toDoubleOrPixels() { return new _Pixels.fromInteger(this); }
String toStringAsFixed(int fractionDigits) {
return this.toDouble().toStringAsFixed(fractionDigits);
« no previous file with comments | « runtime/lib/double.dart ('k') | runtime/lib/pixels.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698