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

Unified Diff: lib/runtime/dart/math.js

Issue 1355893003: Rewire DDC to use the analyzer task model (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Fix for identifiers Created 5 years, 3 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
Index: lib/runtime/dart/math.js
diff --git a/lib/runtime/dart/math.js b/lib/runtime/dart/math.js
index 5c172e8e7cf57965dc037bbdd067d34d2feb37ad..d18231341baf7b7658d0fe2c69a6dd9aa1affcfe 100644
--- a/lib/runtime/dart/math.js
+++ b/lib/runtime/dart/math.js
@@ -18,10 +18,10 @@ dart_library.library('dart/math', null, /* Imports */[
return 536870911 & dart.notNull(hash) + ((16383 & dart.notNull(hash)) << 15);
}
static hash2(a, b) {
- return _JenkinsSmiHash.finish(_JenkinsSmiHash.combine(_JenkinsSmiHash.combine(0, dart.as(a, core.int)), dart.as(b, core.int)));
+ return dart.dcall(_JenkinsSmiHash.finish, dart.dcall(_JenkinsSmiHash.combine, dart.dcall(_JenkinsSmiHash.combine, 0, a), b));
}
static hash4(a, b, c, d) {
- return _JenkinsSmiHash.finish(_JenkinsSmiHash.combine(_JenkinsSmiHash.combine(_JenkinsSmiHash.combine(_JenkinsSmiHash.combine(0, dart.as(a, core.int)), dart.as(b, core.int)), dart.as(c, core.int)), dart.as(d, core.int)));
+ return dart.dcall(_JenkinsSmiHash.finish, dart.dcall(_JenkinsSmiHash.combine, dart.dcall(_JenkinsSmiHash.combine, dart.dcall(_JenkinsSmiHash.combine, dart.dcall(_JenkinsSmiHash.combine, 0, a), b), c), d));
}
}
dart.setSignature(_JenkinsSmiHash, {
@@ -48,7 +48,7 @@ dart_library.library('dart/math', null, /* Imports */[
return dart.equals(this.x, dart.dload(other, 'x')) && dart.equals(this.y, dart.dload(other, 'y'));
}
get hashCode() {
- return _JenkinsSmiHash.hash2(dart.hashCode(this.x), dart.hashCode(this.y));
+ return dart.dcall(_JenkinsSmiHash.hash2, dart.hashCode(this.x), dart.hashCode(this.y));
}
['+'](other) {
dart.as(other, Point$(T));
@@ -62,19 +62,19 @@ dart_library.library('dart/math', null, /* Imports */[
return new (Point$(T))(dart.as(this.x['*'](factor), T), dart.as(this.y['*'](factor), T));
}
get magnitude() {
- return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*'](this.y)));
+ return dart.dcall(sqrt, dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*'](this.y)));
}
distanceTo(other) {
dart.as(other, Point$(T));
let dx = this.x['-'](other.x);
let dy = this.y['-'](other.y);
- return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy));
+ return dart.dcall(sqrt, dart.dsend(dart.dsend(dx, '*', dx), '+', dart.dsend(dy, '*', dy)));
}
squaredDistanceTo(other) {
dart.as(other, Point$(T));
let dx = this.x['-'](other.x);
let dy = this.y['-'](other.y);
- return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T);
+ return dart.as(dart.dsend(dart.dsend(dx, '*', dx), '+', dart.dsend(dy, '*', dy)), T);
}
}
dart.setSignature(Point, {
@@ -119,17 +119,17 @@ dart_library.library('dart/math', null, /* Imports */[
return dart.equals(this.left, dart.dload(other, 'left')) && dart.equals(this.top, dart.dload(other, 'top')) && dart.equals(this.right, dart.dload(other, 'right')) && dart.equals(this.bottom, dart.dload(other, 'bottom'));
}
get hashCode() {
- return _JenkinsSmiHash.hash4(dart.hashCode(this.left), dart.hashCode(this.top), dart.hashCode(this.right), dart.hashCode(this.bottom));
+ return dart.dcall(_JenkinsSmiHash.hash4, dart.hashCode(this.left), dart.hashCode(this.top), dart.hashCode(this.right), dart.hashCode(this.bottom));
}
intersection(other) {
dart.as(other, Rectangle$(T));
- let x0 = max(this.left, other.left);
- let x1 = min(this.left['+'](this.width), other.left['+'](other.width));
- if (dart.notNull(x0) <= dart.notNull(x1)) {
- let y0 = max(this.top, other.top);
- let y1 = min(this.top['+'](this.height), other.top['+'](other.height));
- if (dart.notNull(y0) <= dart.notNull(y1)) {
- return new (Rectangle$(T))(dart.as(x0, T), dart.as(y0, T), dart.as(dart.notNull(x1) - dart.notNull(x0), T), dart.as(dart.notNull(y1) - dart.notNull(y0), T));
+ let x0 = dart.dcall(max, this.left, other.left);
+ let x1 = dart.dcall(min, this.left['+'](this.width), other.left['+'](other.width));
+ if (dart.notNull(dart.as(dart.dsend(x0, '<=', x1), core.bool))) {
+ let y0 = dart.dcall(max, this.top, other.top);
+ let y1 = dart.dcall(min, this.top['+'](this.height), other.top['+'](other.height));
+ if (dart.notNull(dart.as(dart.dsend(y0, '<=', y1), core.bool))) {
+ return new (Rectangle$(T))(dart.as(x0, T), dart.as(y0, T), dart.as(dart.dsend(x1, '-', x0), T), dart.as(dart.dsend(y1, '-', y0), T));
}
}
return null;
@@ -139,11 +139,11 @@ dart_library.library('dart/math', null, /* Imports */[
}
boundingBox(other) {
dart.as(other, Rectangle$(T));
- let right = max(this.left['+'](this.width), other.left['+'](other.width));
- let bottom = max(this.top['+'](this.height), other.top['+'](other.height));
- let left = min(this.left, other.left);
- let top = min(this.top, other.top);
- return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(dart.notNull(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.notNull(top), T));
+ let right = dart.dcall(max, this.left['+'](this.width), other.left['+'](other.width));
+ let bottom = dart.dcall(max, this.top['+'](this.height), other.top['+'](other.height));
+ let left = dart.dcall(min, this.left, other.left);
+ let top = dart.dcall(min, this.top, other.top);
+ return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(dart.dsend(right, '-', left), T), dart.as(dart.dsend(bottom, '-', top), T));
}
containsRectangle(another) {
return dart.notNull(this.left['<='](another.left)) && dart.notNull(this.left['+'](this.width)) >= dart.notNull(another.left) + dart.notNull(another.width) && dart.notNull(this.top['<='](another.top)) && dart.notNull(this.top['+'](this.height)) >= dart.notNull(another.top) + dart.notNull(another.height);
@@ -187,10 +187,10 @@ dart_library.library('dart/math', null, /* Imports */[
super._RectangleBase();
}
static fromPoints(a, b) {
- let left = dart.as(min(a.x, b.x), T);
- let width = dart.as(max(a.x, b.x)[dartx['-']](left), T);
- let top = dart.as(min(a.y, b.y), T);
- let height = dart.as(max(a.y, b.y)[dartx['-']](top), T);
+ let left = dart.as(dart.dcall(min, a.x, b.x), T);
+ let width = dart.as(dart.dcall(max, a.x, b.x)[dartx['-']](left), T);
+ let top = dart.as(dart.dcall(min, a.y, b.y), T);
+ let height = dart.as(dart.dcall(max, a.y, b.y)[dartx['-']](top), T);
return new (Rectangle$(T))(left, top, width, height);
}
}
@@ -210,15 +210,15 @@ dart_library.library('dart/math', null, /* Imports */[
MutableRectangle(left, top, width, height) {
this.left = left;
this.top = top;
- this[_width] = dart.as(dart.notNull(width['<'](0)) ? _clampToZero(width) : width, T);
- this[_height] = dart.as(dart.notNull(height['<'](0)) ? _clampToZero(height) : height, T);
+ this[_width] = dart.as(dart.notNull(width['<'](0)) ? dart.dcall(_clampToZero, width) : width, T);
+ this[_height] = dart.as(dart.notNull(height['<'](0)) ? dart.dcall(_clampToZero, height) : height, T);
super._RectangleBase();
}
static fromPoints(a, b) {
- let left = dart.as(min(a.x, b.x), T);
- let width = dart.as(max(a.x, b.x)[dartx['-']](left), T);
- let top = dart.as(min(a.y, b.y), T);
- let height = dart.as(max(a.y, b.y)[dartx['-']](top), T);
+ let left = dart.as(dart.dcall(min, a.x, b.x), T);
+ let width = dart.as(dart.dcall(max, a.x, b.x)[dartx['-']](left), T);
+ let top = dart.as(dart.dcall(min, a.y, b.y), T);
+ let height = dart.as(dart.dcall(max, a.y, b.y)[dartx['-']](top), T);
return new (MutableRectangle$(T))(left, top, width, height);
}
get width() {
@@ -227,7 +227,7 @@ dart_library.library('dart/math', null, /* Imports */[
set width(width) {
dart.as(width, T);
if (dart.notNull(width['<'](0)))
- width = dart.as(_clampToZero(width), T);
+ width = dart.as(dart.dcall(_clampToZero, width), T);
this[_width] = width;
}
get height() {
@@ -236,7 +236,7 @@ dart_library.library('dart/math', null, /* Imports */[
set height(height) {
dart.as(height, T);
if (dart.notNull(height['<'](0)))
- height = dart.as(_clampToZero(height), T);
+ height = dart.as(dart.dcall(_clampToZero, height), T);
this[_height] = height;
}
}
@@ -310,49 +310,49 @@ dart_library.library('dart/math', null, /* Imports */[
}
dart.fn(max, core.num, [core.num, core.num]);
function atan2(a, b) {
- return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b));
+ return dart.as(Math.atan2(dart.dcall(_js_helper.checkNum, a), dart.dcall(_js_helper.checkNum, b)), core.double);
}
dart.fn(atan2, core.double, [core.num, core.num]);
function pow(x, exponent) {
- _js_helper.checkNum(x);
- _js_helper.checkNum(exponent);
- return Math.pow(x, exponent);
+ dart.dcall(_js_helper.checkNum, x);
+ dart.dcall(_js_helper.checkNum, exponent);
+ return dart.as(Math.pow(x, exponent), core.num);
}
dart.fn(pow, core.num, [core.num, core.num]);
function sin(x) {
- return Math.sin(_js_helper.checkNum(x));
+ return dart.as(Math.sin(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(sin, core.double, [core.num]);
function cos(x) {
- return Math.cos(_js_helper.checkNum(x));
+ return dart.as(Math.cos(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(cos, core.double, [core.num]);
function tan(x) {
- return Math.tan(_js_helper.checkNum(x));
+ return dart.as(Math.tan(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(tan, core.double, [core.num]);
function acos(x) {
- return Math.acos(_js_helper.checkNum(x));
+ return dart.as(Math.acos(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(acos, core.double, [core.num]);
function asin(x) {
- return Math.asin(_js_helper.checkNum(x));
+ return dart.as(Math.asin(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(asin, core.double, [core.num]);
function atan(x) {
- return Math.atan(_js_helper.checkNum(x));
+ return dart.as(Math.atan(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(atan, core.double, [core.num]);
function sqrt(x) {
- return Math.sqrt(_js_helper.checkNum(x));
+ return dart.as(Math.sqrt(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(sqrt, core.double, [core.num]);
function exp(x) {
- return Math.exp(_js_helper.checkNum(x));
+ return dart.as(Math.exp(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(exp, core.double, [core.num]);
function log(x) {
- return Math.log(_js_helper.checkNum(x));
+ return dart.as(Math.log(dart.dcall(_js_helper.checkNum, x)), core.double);
}
dart.fn(log, core.double, [core.num]);
let _POW2_32 = 4294967296;
@@ -363,13 +363,13 @@ dart_library.library('dart/math', null, /* Imports */[
if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32)) {
dart.throw(new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${max}`));
}
- return Math.random() * max >>> 0;
+ return dart.as(Math.random() * max >>> 0, core.int);
}
nextDouble() {
- return Math.random();
+ return dart.as(Math.random(), core.double);
}
nextBool() {
- return Math.random() < 0.5;
+ return dart.as(Math.random() < 0.5, core.bool);
}
}
_JSRandom[dart.implements] = () => [Random];
@@ -434,10 +434,10 @@ dart_library.library('dart/math', null, /* Imports */[
if (this[_hi] == 0 && this[_lo] == 0) {
this[_lo] = 23063;
}
- this[_nextState]();
- this[_nextState]();
- this[_nextState]();
- this[_nextState]();
+ dart.dcall(this[_nextState]);
+ dart.dcall(this[_nextState]);
+ dart.dcall(this[_nextState]);
+ dart.dcall(this[_nextState]);
}
[_nextState]() {
let tmpHi = 4294901760 * dart.notNull(this[_lo]);
@@ -458,27 +458,27 @@ dart_library.library('dart/math', null, /* Imports */[
dart.throw(new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${max}`));
}
if ((dart.notNull(max) & dart.notNull(max) - 1) == 0) {
- this[_nextState]();
+ dart.dcall(this[_nextState]);
return dart.notNull(this[_lo]) & dart.notNull(max) - 1;
}
let rnd32 = null;
let result = null;
do {
- this[_nextState]();
+ dart.dcall(this[_nextState]);
rnd32 = this[_lo];
- result = rnd32[dartx.remainder](max);
+ result = dart.dcall(rnd32[dartx.remainder], max);
} while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >= dart.notNull(_POW2_32));
return result;
}
nextDouble() {
- this[_nextState]();
+ dart.dcall(this[_nextState]);
let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1;
- this[_nextState]();
+ dart.dcall(this[_nextState]);
let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1;
return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.notNull(bits27)) / dart.notNull(_Random._POW2_53_D);
}
nextBool() {
- this[_nextState]();
+ dart.dcall(this[_nextState]);
return (dart.notNull(this[_lo]) & 1) == 0;
}
}

Powered by Google App Engine
This is Rietveld 408576698