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