| OLD | NEW |
| (Empty) |
| 1 dart_library.library('dart/math', null, /* Imports */[ | |
| 2 "dart_runtime/dart", | |
| 3 'dart/core' | |
| 4 ], /* Lazy imports */[ | |
| 5 'dart/_js_helper' | |
| 6 ], function(exports, dart, core, _js_helper) { | |
| 7 'use strict'; | |
| 8 let dartx = dart.dartx; | |
| 9 class _JenkinsSmiHash extends core.Object { | |
| 10 static combine(hash, value) { | |
| 11 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); | |
| 12 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) <<
10); | |
| 13 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; | |
| 14 } | |
| 15 static finish(hash) { | |
| 16 hash = 536870911 & dart.notNull(hash) + ((67108863 & dart.notNull(hash)) <
< 3); | |
| 17 hash = dart.notNull(hash) ^ dart.notNull(hash) >> 11; | |
| 18 return 536870911 & dart.notNull(hash) + ((16383 & dart.notNull(hash)) << 1
5); | |
| 19 } | |
| 20 static hash2(a, b) { | |
| 21 return _JenkinsSmiHash.finish(_JenkinsSmiHash.combine(_JenkinsSmiHash.comb
ine(0, dart.as(a, core.int)), dart.as(b, core.int))); | |
| 22 } | |
| 23 static hash4(a, b, c, d) { | |
| 24 return _JenkinsSmiHash.finish(_JenkinsSmiHash.combine(_JenkinsSmiHash.comb
ine(_JenkinsSmiHash.combine(_JenkinsSmiHash.combine(0, dart.as(a, core.int)), da
rt.as(b, core.int)), dart.as(c, core.int)), dart.as(d, core.int))); | |
| 25 } | |
| 26 } | |
| 27 dart.setSignature(_JenkinsSmiHash, { | |
| 28 statics: () => ({ | |
| 29 combine: [core.int, [core.int, core.int]], | |
| 30 finish: [core.int, [core.int]], | |
| 31 hash2: [core.int, [dart.dynamic, dart.dynamic]], | |
| 32 hash4: [core.int, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic]
] | |
| 33 }), | |
| 34 names: ['combine', 'finish', 'hash2', 'hash4'] | |
| 35 }); | |
| 36 let Point$ = dart.generic(function(T) { | |
| 37 class Point extends core.Object { | |
| 38 Point(x, y) { | |
| 39 this.x = x; | |
| 40 this.y = y; | |
| 41 } | |
| 42 toString() { | |
| 43 return `Point(${this.x}, ${this.y})`; | |
| 44 } | |
| 45 ['=='](other) { | |
| 46 if (!dart.is(other, Point$())) | |
| 47 return false; | |
| 48 return dart.equals(this.x, dart.dload(other, 'x')) && dart.equals(this.y
, dart.dload(other, 'y')); | |
| 49 } | |
| 50 get hashCode() { | |
| 51 return _JenkinsSmiHash.hash2(dart.hashCode(this.x), dart.hashCode(this.y
)); | |
| 52 } | |
| 53 ['+'](other) { | |
| 54 dart.as(other, Point$(T)); | |
| 55 return new (Point$(T))(dart.as(this.x['+'](other.x), T), dart.as(this.y[
'+'](other.y), T)); | |
| 56 } | |
| 57 ['-'](other) { | |
| 58 dart.as(other, Point$(T)); | |
| 59 return new (Point$(T))(dart.as(this.x['-'](other.x), T), dart.as(this.y[
'-'](other.y), T)); | |
| 60 } | |
| 61 ['*'](factor) { | |
| 62 return new (Point$(T))(dart.as(this.x['*'](factor), T), dart.as(this.y['
*'](factor), T)); | |
| 63 } | |
| 64 get magnitude() { | |
| 65 return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*']
(this.y))); | |
| 66 } | |
| 67 distanceTo(other) { | |
| 68 dart.as(other, Point$(T)); | |
| 69 let dx = this.x['-'](other.x); | |
| 70 let dy = this.y['-'](other.y); | |
| 71 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar
t.notNull(dy)); | |
| 72 } | |
| 73 squaredDistanceTo(other) { | |
| 74 dart.as(other, Point$(T)); | |
| 75 let dx = this.x['-'](other.x); | |
| 76 let dy = this.y['-'](other.y); | |
| 77 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) *
dart.notNull(dy), T); | |
| 78 } | |
| 79 } | |
| 80 dart.setSignature(Point, { | |
| 81 constructors: () => ({Point: [Point$(T), [T, T]]}), | |
| 82 methods: () => ({ | |
| 83 '+': [Point$(T), [Point$(T)]], | |
| 84 '-': [Point$(T), [Point$(T)]], | |
| 85 '*': [Point$(T), [core.num]], | |
| 86 distanceTo: [core.double, [Point$(T)]], | |
| 87 squaredDistanceTo: [T, [Point$(T)]] | |
| 88 }) | |
| 89 }); | |
| 90 return Point; | |
| 91 }); | |
| 92 let Point = Point$(); | |
| 93 class Random extends core.Object { | |
| 94 static new(seed) { | |
| 95 if (seed === void 0) | |
| 96 seed = null; | |
| 97 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed); | |
| 98 } | |
| 99 } | |
| 100 dart.setSignature(Random, { | |
| 101 constructors: () => ({new: [Random, [], [core.int]]}) | |
| 102 }); | |
| 103 let _RectangleBase$ = dart.generic(function(T) { | |
| 104 class _RectangleBase extends core.Object { | |
| 105 _RectangleBase() { | |
| 106 } | |
| 107 get right() { | |
| 108 return dart.as(this.left['+'](this.width), T); | |
| 109 } | |
| 110 get bottom() { | |
| 111 return dart.as(this.top['+'](this.height), T); | |
| 112 } | |
| 113 toString() { | |
| 114 return `Rectangle (${this.left}, ${this.top}) ${this.width} x ${this.hei
ght}`; | |
| 115 } | |
| 116 ['=='](other) { | |
| 117 if (!dart.is(other, Rectangle)) | |
| 118 return false; | |
| 119 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')); | |
| 120 } | |
| 121 get hashCode() { | |
| 122 return _JenkinsSmiHash.hash4(dart.hashCode(this.left), dart.hashCode(thi
s.top), dart.hashCode(this.right), dart.hashCode(this.bottom)); | |
| 123 } | |
| 124 intersection(other) { | |
| 125 dart.as(other, Rectangle$(T)); | |
| 126 let x0 = max(this.left, other.left); | |
| 127 let x1 = min(this.left['+'](this.width), other.left['+'](other.width)); | |
| 128 if (dart.notNull(x0) <= dart.notNull(x1)) { | |
| 129 let y0 = max(this.top, other.top); | |
| 130 let y1 = min(this.top['+'](this.height), other.top['+'](other.height))
; | |
| 131 if (dart.notNull(y0) <= dart.notNull(y1)) { | |
| 132 return new (Rectangle$(T))(dart.as(x0, T), dart.as(y0, T), dart.as(d
art.notNull(x1) - dart.notNull(x0), T), dart.as(dart.notNull(y1) - dart.notNull(
y0), T)); | |
| 133 } | |
| 134 } | |
| 135 return null; | |
| 136 } | |
| 137 intersects(other) { | |
| 138 return dart.notNull(this.left['<='](dart.notNull(other.left) + dart.notN
ull(other.width))) && dart.notNull(other.left) <= dart.notNull(this.left['+'](th
is.width)) && dart.notNull(this.top['<='](dart.notNull(other.top) + dart.notNull
(other.height))) && dart.notNull(other.top) <= dart.notNull(this.top['+'](this.h
eight)); | |
| 139 } | |
| 140 boundingBox(other) { | |
| 141 dart.as(other, Rectangle$(T)); | |
| 142 let right = max(this.left['+'](this.width), other.left['+'](other.width)
); | |
| 143 let bottom = max(this.top['+'](this.height), other.top['+'](other.height
)); | |
| 144 let left = min(this.left, other.left); | |
| 145 let top = min(this.top, other.top); | |
| 146 return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(da
rt.notNull(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.
notNull(top), T)); | |
| 147 } | |
| 148 containsRectangle(another) { | |
| 149 return dart.notNull(this.left['<='](another.left)) && dart.notNull(this.
left['+'](this.width)) >= dart.notNull(another.left) + dart.notNull(another.widt
h) && dart.notNull(this.top['<='](another.top)) && dart.notNull(this.top['+'](th
is.height)) >= dart.notNull(another.top) + dart.notNull(another.height); | |
| 150 } | |
| 151 containsPoint(another) { | |
| 152 return another.x[dartx['>=']](this.left) && dart.notNull(another.x) <= d
art.notNull(this.left['+'](this.width)) && another.y[dartx['>=']](this.top) && d
art.notNull(another.y) <= dart.notNull(this.top['+'](this.height)); | |
| 153 } | |
| 154 get topLeft() { | |
| 155 return new (Point$(T))(this.left, this.top); | |
| 156 } | |
| 157 get topRight() { | |
| 158 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top)
; | |
| 159 } | |
| 160 get bottomRight() { | |
| 161 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t
his.top['+'](this.height), T)); | |
| 162 } | |
| 163 get bottomLeft() { | |
| 164 return new (Point$(T))(this.left, dart.as(this.top['+'](this.height), T)
); | |
| 165 } | |
| 166 } | |
| 167 dart.setSignature(_RectangleBase, { | |
| 168 constructors: () => ({_RectangleBase: [_RectangleBase$(T), []]}), | |
| 169 methods: () => ({ | |
| 170 intersection: [Rectangle$(T), [Rectangle$(T)]], | |
| 171 intersects: [core.bool, [Rectangle$(core.num)]], | |
| 172 boundingBox: [Rectangle$(T), [Rectangle$(T)]], | |
| 173 containsRectangle: [core.bool, [Rectangle$(core.num)]], | |
| 174 containsPoint: [core.bool, [Point$(core.num)]] | |
| 175 }) | |
| 176 }); | |
| 177 return _RectangleBase; | |
| 178 }); | |
| 179 let _RectangleBase = _RectangleBase$(); | |
| 180 let Rectangle$ = dart.generic(function(T) { | |
| 181 class Rectangle extends _RectangleBase$(T) { | |
| 182 Rectangle(left, top, width, height) { | |
| 183 this.left = left; | |
| 184 this.top = top; | |
| 185 this.width = dart.as(dart.notNull(width['<'](0)) ? dart.notNull(width['u
nary-']()) * 0 : width, T); | |
| 186 this.height = dart.as(dart.notNull(height['<'](0)) ? dart.notNull(height
['unary-']()) * 0 : height, T); | |
| 187 super._RectangleBase(); | |
| 188 } | |
| 189 static fromPoints(a, b) { | |
| 190 let left = dart.as(min(a.x, b.x), T); | |
| 191 let width = dart.as(max(a.x, b.x)[dartx['-']](left), T); | |
| 192 let top = dart.as(min(a.y, b.y), T); | |
| 193 let height = dart.as(max(a.y, b.y)[dartx['-']](top), T); | |
| 194 return new (Rectangle$(T))(left, top, width, height); | |
| 195 } | |
| 196 } | |
| 197 dart.setSignature(Rectangle, { | |
| 198 constructors: () => ({ | |
| 199 Rectangle: [Rectangle$(T), [T, T, T, T]], | |
| 200 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]] | |
| 201 }) | |
| 202 }); | |
| 203 return Rectangle; | |
| 204 }); | |
| 205 let Rectangle = Rectangle$(); | |
| 206 let _width = Symbol('_width'); | |
| 207 let _height = Symbol('_height'); | |
| 208 let MutableRectangle$ = dart.generic(function(T) { | |
| 209 class MutableRectangle extends _RectangleBase$(T) { | |
| 210 MutableRectangle(left, top, width, height) { | |
| 211 this.left = left; | |
| 212 this.top = top; | |
| 213 this[_width] = dart.as(dart.notNull(width['<'](0)) ? _clampToZero(width)
: width, T); | |
| 214 this[_height] = dart.as(dart.notNull(height['<'](0)) ? _clampToZero(heig
ht) : height, T); | |
| 215 super._RectangleBase(); | |
| 216 } | |
| 217 static fromPoints(a, b) { | |
| 218 let left = dart.as(min(a.x, b.x), T); | |
| 219 let width = dart.as(max(a.x, b.x)[dartx['-']](left), T); | |
| 220 let top = dart.as(min(a.y, b.y), T); | |
| 221 let height = dart.as(max(a.y, b.y)[dartx['-']](top), T); | |
| 222 return new (MutableRectangle$(T))(left, top, width, height); | |
| 223 } | |
| 224 get width() { | |
| 225 return this[_width]; | |
| 226 } | |
| 227 set width(width) { | |
| 228 dart.as(width, T); | |
| 229 if (dart.notNull(width['<'](0))) | |
| 230 width = dart.as(_clampToZero(width), T); | |
| 231 this[_width] = width; | |
| 232 } | |
| 233 get height() { | |
| 234 return this[_height]; | |
| 235 } | |
| 236 set height(height) { | |
| 237 dart.as(height, T); | |
| 238 if (dart.notNull(height['<'](0))) | |
| 239 height = dart.as(_clampToZero(height), T); | |
| 240 this[_height] = height; | |
| 241 } | |
| 242 } | |
| 243 MutableRectangle[dart.implements] = () => [Rectangle$(T)]; | |
| 244 dart.setSignature(MutableRectangle, { | |
| 245 constructors: () => ({ | |
| 246 MutableRectangle: [MutableRectangle$(T), [T, T, T, T]], | |
| 247 fromPoints: [MutableRectangle$(T), [Point$(T), Point$(T)]] | |
| 248 }) | |
| 249 }); | |
| 250 return MutableRectangle; | |
| 251 }); | |
| 252 let MutableRectangle = MutableRectangle$(); | |
| 253 function _clampToZero(value) { | |
| 254 dart.assert(dart.notNull(value) < 0); | |
| 255 return -dart.notNull(value) * 0; | |
| 256 } | |
| 257 dart.fn(_clampToZero, core.num, [core.num]); | |
| 258 let E = 2.718281828459045; | |
| 259 let LN10 = 2.302585092994046; | |
| 260 let LN2 = 0.6931471805599453; | |
| 261 let LOG2E = 1.4426950408889634; | |
| 262 let LOG10E = 0.4342944819032518; | |
| 263 let PI = 3.141592653589793; | |
| 264 let SQRT1_2 = 0.7071067811865476; | |
| 265 let SQRT2 = 1.4142135623730951; | |
| 266 function min(a, b) { | |
| 267 if (!dart.is(a, core.num)) | |
| 268 dart.throw(new core.ArgumentError(a)); | |
| 269 if (!dart.is(b, core.num)) | |
| 270 dart.throw(new core.ArgumentError(b)); | |
| 271 if (dart.notNull(a) > dart.notNull(b)) | |
| 272 return b; | |
| 273 if (dart.notNull(a) < dart.notNull(b)) | |
| 274 return a; | |
| 275 if (typeof b == 'number') { | |
| 276 if (typeof a == 'number') { | |
| 277 if (a == 0.0) { | |
| 278 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no
tNull(b); | |
| 279 } | |
| 280 } | |
| 281 if (a == 0 && dart.notNull(b[dartx.isNegative]) || dart.notNull(b[dartx.is
NaN])) | |
| 282 return b; | |
| 283 return a; | |
| 284 } | |
| 285 return a; | |
| 286 } | |
| 287 dart.fn(min, core.num, [core.num, core.num]); | |
| 288 function max(a, b) { | |
| 289 if (!dart.is(a, core.num)) | |
| 290 dart.throw(new core.ArgumentError(a)); | |
| 291 if (!dart.is(b, core.num)) | |
| 292 dart.throw(new core.ArgumentError(b)); | |
| 293 if (dart.notNull(a) > dart.notNull(b)) | |
| 294 return a; | |
| 295 if (dart.notNull(a) < dart.notNull(b)) | |
| 296 return b; | |
| 297 if (typeof b == 'number') { | |
| 298 if (typeof a == 'number') { | |
| 299 if (a == 0.0) { | |
| 300 return dart.notNull(a) + dart.notNull(b); | |
| 301 } | |
| 302 } | |
| 303 if (dart.notNull(b[dartx.isNaN])) | |
| 304 return b; | |
| 305 return a; | |
| 306 } | |
| 307 if (b == 0 && dart.notNull(a[dartx.isNegative])) | |
| 308 return b; | |
| 309 return a; | |
| 310 } | |
| 311 dart.fn(max, core.num, [core.num, core.num]); | |
| 312 function atan2(a, b) { | |
| 313 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b)); | |
| 314 } | |
| 315 dart.fn(atan2, core.double, [core.num, core.num]); | |
| 316 function pow(x, exponent) { | |
| 317 _js_helper.checkNum(x); | |
| 318 _js_helper.checkNum(exponent); | |
| 319 return Math.pow(x, exponent); | |
| 320 } | |
| 321 dart.fn(pow, core.num, [core.num, core.num]); | |
| 322 function sin(x) { | |
| 323 return Math.sin(_js_helper.checkNum(x)); | |
| 324 } | |
| 325 dart.fn(sin, core.double, [core.num]); | |
| 326 function cos(x) { | |
| 327 return Math.cos(_js_helper.checkNum(x)); | |
| 328 } | |
| 329 dart.fn(cos, core.double, [core.num]); | |
| 330 function tan(x) { | |
| 331 return Math.tan(_js_helper.checkNum(x)); | |
| 332 } | |
| 333 dart.fn(tan, core.double, [core.num]); | |
| 334 function acos(x) { | |
| 335 return Math.acos(_js_helper.checkNum(x)); | |
| 336 } | |
| 337 dart.fn(acos, core.double, [core.num]); | |
| 338 function asin(x) { | |
| 339 return Math.asin(_js_helper.checkNum(x)); | |
| 340 } | |
| 341 dart.fn(asin, core.double, [core.num]); | |
| 342 function atan(x) { | |
| 343 return Math.atan(_js_helper.checkNum(x)); | |
| 344 } | |
| 345 dart.fn(atan, core.double, [core.num]); | |
| 346 function sqrt(x) { | |
| 347 return Math.sqrt(_js_helper.checkNum(x)); | |
| 348 } | |
| 349 dart.fn(sqrt, core.double, [core.num]); | |
| 350 function exp(x) { | |
| 351 return Math.exp(_js_helper.checkNum(x)); | |
| 352 } | |
| 353 dart.fn(exp, core.double, [core.num]); | |
| 354 function log(x) { | |
| 355 return Math.log(_js_helper.checkNum(x)); | |
| 356 } | |
| 357 dart.fn(log, core.double, [core.num]); | |
| 358 let _POW2_32 = 4294967296; | |
| 359 class _JSRandom extends core.Object { | |
| 360 _JSRandom() { | |
| 361 } | |
| 362 nextInt(max) { | |
| 363 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32))
{ | |
| 364 dart.throw(new core.RangeError(`max must be in range 0 < max ≤ 2^32, was
${max}`)); | |
| 365 } | |
| 366 return Math.random() * max >>> 0; | |
| 367 } | |
| 368 nextDouble() { | |
| 369 return Math.random(); | |
| 370 } | |
| 371 nextBool() { | |
| 372 return Math.random() < 0.5; | |
| 373 } | |
| 374 } | |
| 375 _JSRandom[dart.implements] = () => [Random]; | |
| 376 dart.setSignature(_JSRandom, { | |
| 377 constructors: () => ({_JSRandom: [_JSRandom, []]}), | |
| 378 methods: () => ({ | |
| 379 nextInt: [core.int, [core.int]], | |
| 380 nextDouble: [core.double, []], | |
| 381 nextBool: [core.bool, []] | |
| 382 }) | |
| 383 }); | |
| 384 let _lo = Symbol('_lo'); | |
| 385 let _hi = Symbol('_hi'); | |
| 386 let _nextState = Symbol('_nextState'); | |
| 387 class _Random extends core.Object { | |
| 388 _Random(seed) { | |
| 389 this[_lo] = 0; | |
| 390 this[_hi] = 0; | |
| 391 let empty_seed = 0; | |
| 392 if (dart.notNull(seed) < 0) { | |
| 393 empty_seed = -1; | |
| 394 } | |
| 395 do { | |
| 396 let low = dart.notNull(seed) & dart.notNull(_Random._MASK32); | |
| 397 seed = ((dart.notNull(seed) - dart.notNull(low)) / dart.notNull(_POW2_32
))[dartx.truncate](); | |
| 398 let high = dart.notNull(seed) & dart.notNull(_Random._MASK32); | |
| 399 seed = ((dart.notNull(seed) - dart.notNull(high)) / dart.notNull(_POW2_3
2))[dartx.truncate](); | |
| 400 let tmplow = dart.notNull(low) << 21; | |
| 401 let tmphigh = dart.notNull(high) << 21 | dart.notNull(low) >> 11; | |
| 402 tmplow = (~dart.notNull(low) & dart.notNull(_Random._MASK32)) + dart.not
Null(tmplow); | |
| 403 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
| 404 high = ~dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmpl
ow) - dart.notNull(low)) / 4294967296)[dartx.truncate]() & dart.notNull(_Random.
_MASK32); | |
| 405 tmphigh = dart.notNull(high) >> 24; | |
| 406 tmplow = dart.notNull(low) >> 24 | dart.notNull(high) << 8; | |
| 407 low = dart.notNull(low) ^ dart.notNull(tmplow); | |
| 408 high = dart.notNull(high) ^ dart.notNull(tmphigh); | |
| 409 tmplow = dart.notNull(low) * 265; | |
| 410 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
| 411 high = dart.notNull(high) * 265 + ((dart.notNull(tmplow) - dart.notNull(
low)) / 4294967296)[dartx.truncate]() & dart.notNull(_Random._MASK32); | |
| 412 tmphigh = dart.notNull(high) >> 14; | |
| 413 tmplow = dart.notNull(low) >> 14 | dart.notNull(high) << 18; | |
| 414 low = dart.notNull(low) ^ dart.notNull(tmplow); | |
| 415 high = dart.notNull(high) ^ dart.notNull(tmphigh); | |
| 416 tmplow = dart.notNull(low) * 21; | |
| 417 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
| 418 high = dart.notNull(high) * 21 + ((dart.notNull(tmplow) - dart.notNull(l
ow)) / 4294967296)[dartx.truncate]() & dart.notNull(_Random._MASK32); | |
| 419 tmphigh = dart.notNull(high) >> 28; | |
| 420 tmplow = dart.notNull(low) >> 28 | dart.notNull(high) << 4; | |
| 421 low = dart.notNull(low) ^ dart.notNull(tmplow); | |
| 422 high = dart.notNull(high) ^ dart.notNull(tmphigh); | |
| 423 tmplow = dart.notNull(low) << 31; | |
| 424 tmphigh = dart.notNull(high) << 31 | dart.notNull(low) >> 1; | |
| 425 tmplow = dart.notNull(tmplow) + dart.notNull(low); | |
| 426 low = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
| 427 high = dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmplo
w) - dart.notNull(low)) / 4294967296)[dartx.truncate]() & dart.notNull(_Random._
MASK32); | |
| 428 tmplow = dart.notNull(this[_lo]) * 1037; | |
| 429 this[_lo] = dart.notNull(tmplow) & dart.notNull(_Random._MASK32); | |
| 430 this[_hi] = dart.notNull(this[_hi]) * 1037 + ((dart.notNull(tmplow) - da
rt.notNull(this[_lo])) / 4294967296)[dartx.truncate]() & dart.notNull(_Random._M
ASK32); | |
| 431 this[_lo] = dart.notNull(this[_lo]) ^ dart.notNull(low); | |
| 432 this[_hi] = dart.notNull(this[_hi]) ^ dart.notNull(high); | |
| 433 } while (seed != empty_seed); | |
| 434 if (this[_hi] == 0 && this[_lo] == 0) { | |
| 435 this[_lo] = 23063; | |
| 436 } | |
| 437 this[_nextState](); | |
| 438 this[_nextState](); | |
| 439 this[_nextState](); | |
| 440 this[_nextState](); | |
| 441 } | |
| 442 [_nextState]() { | |
| 443 let tmpHi = 4294901760 * dart.notNull(this[_lo]); | |
| 444 let tmpHiLo = dart.notNull(tmpHi) & dart.notNull(_Random._MASK32); | |
| 445 let tmpHiHi = dart.notNull(tmpHi) - dart.notNull(tmpHiLo); | |
| 446 let tmpLo = 55905 * dart.notNull(this[_lo]); | |
| 447 let tmpLoLo = dart.notNull(tmpLo) & dart.notNull(_Random._MASK32); | |
| 448 let tmpLoHi = dart.notNull(tmpLo) - dart.notNull(tmpLoLo); | |
| 449 let newLo = dart.notNull(tmpLoLo) + dart.notNull(tmpHiLo) + dart.notNull(t
his[_hi]); | |
| 450 this[_lo] = dart.notNull(newLo) & dart.notNull(_Random._MASK32); | |
| 451 let newLoHi = dart.notNull(newLo) - dart.notNull(this[_lo]); | |
| 452 this[_hi] = ((dart.notNull(tmpLoHi) + dart.notNull(tmpHiHi) + dart.notNull
(newLoHi)) / dart.notNull(_POW2_32))[dartx.truncate]() & dart.notNull(_Random._M
ASK32); | |
| 453 dart.assert(dart.notNull(this[_lo]) < dart.notNull(_POW2_32)); | |
| 454 dart.assert(dart.notNull(this[_hi]) < dart.notNull(_POW2_32)); | |
| 455 } | |
| 456 nextInt(max) { | |
| 457 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32))
{ | |
| 458 dart.throw(new core.RangeError(`max must be in range 0 < max ≤ 2^32, was
${max}`)); | |
| 459 } | |
| 460 if ((dart.notNull(max) & dart.notNull(max) - 1) == 0) { | |
| 461 this[_nextState](); | |
| 462 return dart.notNull(this[_lo]) & dart.notNull(max) - 1; | |
| 463 } | |
| 464 let rnd32 = null; | |
| 465 let result = null; | |
| 466 do { | |
| 467 this[_nextState](); | |
| 468 rnd32 = this[_lo]; | |
| 469 result = rnd32[dartx.remainder](max); | |
| 470 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >=
dart.notNull(_POW2_32)); | |
| 471 return result; | |
| 472 } | |
| 473 nextDouble() { | |
| 474 this[_nextState](); | |
| 475 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1; | |
| 476 this[_nextState](); | |
| 477 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; | |
| 478 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not
Null(bits27)) / dart.notNull(_Random._POW2_53_D); | |
| 479 } | |
| 480 nextBool() { | |
| 481 this[_nextState](); | |
| 482 return (dart.notNull(this[_lo]) & 1) == 0; | |
| 483 } | |
| 484 } | |
| 485 _Random[dart.implements] = () => [Random]; | |
| 486 dart.setSignature(_Random, { | |
| 487 constructors: () => ({_Random: [_Random, [core.int]]}), | |
| 488 methods: () => ({ | |
| 489 [_nextState]: [dart.void, []], | |
| 490 nextInt: [core.int, [core.int]], | |
| 491 nextDouble: [core.double, []], | |
| 492 nextBool: [core.bool, []] | |
| 493 }) | |
| 494 }); | |
| 495 _Random._POW2_53_D = 1.0 * 9007199254740992; | |
| 496 _Random._POW2_27_D = 1.0 * (1 << 27); | |
| 497 _Random._MASK32 = 4294967295; | |
| 498 // Exports: | |
| 499 exports.Point$ = Point$; | |
| 500 exports.Point = Point; | |
| 501 exports.Random = Random; | |
| 502 exports.Rectangle$ = Rectangle$; | |
| 503 exports.Rectangle = Rectangle; | |
| 504 exports.MutableRectangle$ = MutableRectangle$; | |
| 505 exports.MutableRectangle = MutableRectangle; | |
| 506 exports.E = E; | |
| 507 exports.LN10 = LN10; | |
| 508 exports.LN2 = LN2; | |
| 509 exports.LOG2E = LOG2E; | |
| 510 exports.LOG10E = LOG10E; | |
| 511 exports.PI = PI; | |
| 512 exports.SQRT1_2 = SQRT1_2; | |
| 513 exports.SQRT2 = SQRT2; | |
| 514 exports.min = min; | |
| 515 exports.max = max; | |
| 516 exports.atan2 = atan2; | |
| 517 exports.pow = pow; | |
| 518 exports.sin = sin; | |
| 519 exports.cos = cos; | |
| 520 exports.tan = tan; | |
| 521 exports.acos = acos; | |
| 522 exports.asin = asin; | |
| 523 exports.atan = atan; | |
| 524 exports.sqrt = sqrt; | |
| 525 exports.exp = exp; | |
| 526 exports.log = log; | |
| 527 }); | |
| OLD | NEW |