OLD | NEW |
1 var math; | 1 var math; |
2 (function(exports) { | 2 (function(exports) { |
3 'use strict'; | 3 'use strict'; |
4 let E = 2.718281828459045; | 4 let E = 2.718281828459045; |
5 let LN10 = 2.302585092994046; | 5 let LN10 = 2.302585092994046; |
6 let LN2 = 0.6931471805599453; | 6 let LN2 = 0.6931471805599453; |
7 let LOG2E = 1.4426950408889634; | 7 let LOG2E = 1.4426950408889634; |
8 let LOG10E = 0.4342944819032518; | 8 let LOG10E = 0.4342944819032518; |
9 let PI = 3.141592653589793; | 9 let PI = 3.141592653589793; |
10 let SQRT1_2 = 0.7071067811865476; | 10 let SQRT1_2 = 0.7071067811865476; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 return Math.random() * max >>> 0; | 112 return Math.random() * max >>> 0; |
113 } | 113 } |
114 nextDouble() { | 114 nextDouble() { |
115 return Math.random(); | 115 return Math.random(); |
116 } | 116 } |
117 nextBool() { | 117 nextBool() { |
118 return Math.random() < 0.5; | 118 return Math.random() < 0.5; |
119 } | 119 } |
120 } | 120 } |
| 121 let _lo = Symbol('_lo'); |
| 122 let _hi = Symbol('_hi'); |
| 123 let _nextState = Symbol('_nextState'); |
121 class _Random extends dart.Object { | 124 class _Random extends dart.Object { |
122 _Random(seed) { | 125 _Random(seed) { |
123 this._lo = 0; | 126 this[_lo] = 0; |
124 this._hi = 0; | 127 this[_hi] = 0; |
125 let empty_seed = 0; | 128 let empty_seed = 0; |
126 if (seed < 0) { | 129 if (seed < 0) { |
127 empty_seed = -1; | 130 empty_seed = -1; |
128 } | 131 } |
129 do { | 132 do { |
130 let low = seed & _MASK32; | 133 let low = seed & _MASK32; |
131 seed = ((seed - low) / _POW2_32).truncate(); | 134 seed = ((seed - low) / _POW2_32).truncate(); |
132 let high = seed & _MASK32; | 135 let high = seed & _MASK32; |
133 seed = ((seed - high) / _POW2_32).truncate(); | 136 seed = ((seed - high) / _POW2_32).truncate(); |
134 let tmplow = low << 21; | 137 let tmplow = low << 21; |
(...skipping 17 matching lines...) Expand all Loading... |
152 high = high * 21 + ((tmplow - low) / 4294967296).truncate() & _MASK32; | 155 high = high * 21 + ((tmplow - low) / 4294967296).truncate() & _MASK32; |
153 tmphigh = high >> 28; | 156 tmphigh = high >> 28; |
154 tmplow = low >> 28 | high << 4; | 157 tmplow = low >> 28 | high << 4; |
155 low = tmplow; | 158 low = tmplow; |
156 high = tmphigh; | 159 high = tmphigh; |
157 tmplow = low << 31; | 160 tmplow = low << 31; |
158 tmphigh = high << 31 | low >> 1; | 161 tmphigh = high << 31 | low >> 1; |
159 tmplow = low; | 162 tmplow = low; |
160 low = tmplow & _MASK32; | 163 low = tmplow & _MASK32; |
161 high = high + tmphigh + ((tmplow - low) / 4294967296).truncate() & _MASK
32; | 164 high = high + tmphigh + ((tmplow - low) / 4294967296).truncate() & _MASK
32; |
162 tmplow = this._lo * 1037; | 165 tmplow = this[_lo] * 1037; |
163 this._lo = tmplow & _MASK32; | 166 this[_lo] = tmplow & _MASK32; |
164 this._hi = this._hi * 1037 + ((tmplow - this._lo) / 4294967296).truncate
() & _MASK32; | 167 this[_hi] = this[_hi] * 1037 + ((tmplow - this[_lo]) / 4294967296).trunc
ate() & _MASK32; |
165 this._lo = low; | 168 this[_lo] = low; |
166 this._hi = high; | 169 this[_hi] = high; |
167 } while (seed !== empty_seed); | 170 } while (seed !== empty_seed); |
168 if (dart.notNull(this._hi === 0) && dart.notNull(this._lo === 0)) { | 171 if (dart.notNull(this[_hi] === 0) && dart.notNull(this[_lo] === 0)) { |
169 this._lo = 23063; | 172 this[_lo] = 23063; |
170 } | 173 } |
171 this._nextState(); | 174 this[_nextState](); |
172 this._nextState(); | 175 this[_nextState](); |
173 this._nextState(); | 176 this[_nextState](); |
174 this._nextState(); | 177 this[_nextState](); |
175 } | 178 } |
176 _nextState() { | 179 [_nextState]() { |
177 let tmpHi = 4294901760 * this._lo; | 180 let tmpHi = 4294901760 * this[_lo]; |
178 let tmpHiLo = tmpHi & _MASK32; | 181 let tmpHiLo = tmpHi & _MASK32; |
179 let tmpHiHi = tmpHi - tmpHiLo; | 182 let tmpHiHi = tmpHi - tmpHiLo; |
180 let tmpLo = 55905 * this._lo; | 183 let tmpLo = 55905 * this[_lo]; |
181 let tmpLoLo = tmpLo & _MASK32; | 184 let tmpLoLo = tmpLo & _MASK32; |
182 let tmpLoHi = tmpLo - tmpLoLo; | 185 let tmpLoHi = tmpLo - tmpLoLo; |
183 let newLo = tmpLoLo + tmpHiLo + this._hi; | 186 let newLo = tmpLoLo + tmpHiLo + this[_hi]; |
184 this._lo = newLo & _MASK32; | 187 this[_lo] = newLo & _MASK32; |
185 let newLoHi = newLo - this._lo; | 188 let newLoHi = newLo - this[_lo]; |
186 this._hi = ((tmpLoHi + tmpHiHi + newLoHi) / _POW2_32).truncate() & _MASK32
; | 189 this[_hi] = ((tmpLoHi + tmpHiHi + newLoHi) / _POW2_32).truncate() & _MASK3
2; |
187 dart.assert(this._lo < _POW2_32); | 190 dart.assert(this[_lo] < _POW2_32); |
188 dart.assert(this._hi < _POW2_32); | 191 dart.assert(this[_hi] < _POW2_32); |
189 } | 192 } |
190 nextInt(max) { | 193 nextInt(max) { |
191 if (dart.notNull(max <= 0) || dart.notNull(max > _POW2_32)) { | 194 if (dart.notNull(max <= 0) || dart.notNull(max > _POW2_32)) { |
192 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma
x}`); | 195 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma
x}`); |
193 } | 196 } |
194 if ((max & max - 1) === 0) { | 197 if ((max & max - 1) === 0) { |
195 this._nextState(); | 198 this[_nextState](); |
196 return this._lo & max - 1; | 199 return this[_lo] & max - 1; |
197 } | 200 } |
198 let rnd32 = null; | 201 let rnd32 = null; |
199 let result = null; | 202 let result = null; |
200 do { | 203 do { |
201 this._nextState(); | 204 this[_nextState](); |
202 rnd32 = this._lo; | 205 rnd32 = this[_lo]; |
203 result = dart.notNull(rnd32.remainder(max)); | 206 result = dart.notNull(rnd32.remainder(max)); |
204 } while (rnd32 - result + max >= _POW2_32); | 207 } while (rnd32 - result + max >= _POW2_32); |
205 return result; | 208 return result; |
206 } | 209 } |
207 nextDouble() { | 210 nextDouble() { |
208 this._nextState(); | 211 this[_nextState](); |
209 let bits26 = this._lo & (1 << 26) - 1; | 212 let bits26 = this[_lo] & (1 << 26) - 1; |
210 this._nextState(); | 213 this[_nextState](); |
211 let bits27 = this._lo & (1 << 27) - 1; | 214 let bits27 = this[_lo] & (1 << 27) - 1; |
212 return (bits26 * _POW2_27_D + bits27) / _POW2_53_D; | 215 return (bits26 * _POW2_27_D + bits27) / _POW2_53_D; |
213 } | 216 } |
214 nextBool() { | 217 nextBool() { |
215 this._nextState(); | 218 this[_nextState](); |
216 return (this._lo & 1) === 0; | 219 return (this[_lo] & 1) === 0; |
217 } | 220 } |
218 } | 221 } |
219 _Random._POW2_53_D = 1.0 * 9007199254740992; | 222 _Random._POW2_53_D = 1.0 * 9007199254740992; |
220 _Random._POW2_27_D = 1.0 * (1 << 27); | 223 _Random._POW2_27_D = 1.0 * (1 << 27); |
221 _Random._MASK32 = 4294967295; | 224 _Random._MASK32 = 4294967295; |
222 class _JenkinsSmiHash extends dart.Object { | 225 class _JenkinsSmiHash extends dart.Object { |
223 static combine(hash, value) { | 226 static combine(hash, value) { |
224 hash = 536870911 & hash + value; | 227 hash = 536870911 & hash + value; |
225 hash = 536870911 & hash + ((524287 & hash) << 10); | 228 hash = 536870911 & hash + ((524287 & hash) << 10); |
226 return hash ^ hash >> 6; | 229 return hash ^ hash >> 6; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); | 369 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); |
367 let top = dart.as(min(a.y, b.y), T); | 370 let top = dart.as(min(a.y, b.y), T); |
368 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); | 371 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); |
369 return new Rectangle(left, top, width, height); | 372 return new Rectangle(left, top, width, height); |
370 } | 373 } |
371 } | 374 } |
372 dart.defineNamedConstructor(Rectangle, 'fromPoints'); | 375 dart.defineNamedConstructor(Rectangle, 'fromPoints'); |
373 return Rectangle; | 376 return Rectangle; |
374 }); | 377 }); |
375 let Rectangle = Rectangle$(dynamic); | 378 let Rectangle = Rectangle$(dynamic); |
| 379 let _width = Symbol('_width'); |
| 380 let _height = Symbol('_height'); |
376 let MutableRectangle$ = dart.generic(function(T) { | 381 let MutableRectangle$ = dart.generic(function(T) { |
377 class MutableRectangle extends _RectangleBase$(T) { | 382 class MutableRectangle extends _RectangleBase$(T) { |
378 MutableRectangle(left, top, width, height) { | 383 MutableRectangle(left, top, width, height) { |
379 this.left = left; | 384 this.left = left; |
380 this.top = top; | 385 this.top = top; |
381 this._width = dart.as(width['<'](0) ? _clampToZero(width) : width, T); | 386 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); |
382 this._height = dart.as(height['<'](0) ? _clampToZero(height) : height, T
); | 387 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height,
T); |
383 super._RectangleBase(); | 388 super._RectangleBase(); |
384 } | 389 } |
385 MutableRectangle$fromPoints(a, b) { | 390 MutableRectangle$fromPoints(a, b) { |
386 let left = dart.as(min(a.x, b.x), T); | 391 let left = dart.as(min(a.x, b.x), T); |
387 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); | 392 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); |
388 let top = dart.as(min(a.y, b.y), T); | 393 let top = dart.as(min(a.y, b.y), T); |
389 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); | 394 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); |
390 return new MutableRectangle(left, top, width, height); | 395 return new MutableRectangle(left, top, width, height); |
391 } | 396 } |
392 get width() { | 397 get width() { |
393 return this._width; | 398 return this[_width]; |
394 } | 399 } |
395 set width(width) { | 400 set width(width) { |
396 if (width['<'](0)) | 401 if (width['<'](0)) |
397 width = dart.as(_clampToZero(width), T); | 402 width = dart.as(_clampToZero(width), T); |
398 this._width = width; | 403 this[_width] = width; |
399 } | 404 } |
400 get height() { | 405 get height() { |
401 return this._height; | 406 return this[_height]; |
402 } | 407 } |
403 set height(height) { | 408 set height(height) { |
404 if (height['<'](0)) | 409 if (height['<'](0)) |
405 height = dart.as(_clampToZero(height), T); | 410 height = dart.as(_clampToZero(height), T); |
406 this._height = height; | 411 this[_height] = height; |
407 } | 412 } |
408 } | 413 } |
409 dart.defineNamedConstructor(MutableRectangle, 'fromPoints'); | 414 dart.defineNamedConstructor(MutableRectangle, 'fromPoints'); |
410 return MutableRectangle; | 415 return MutableRectangle; |
411 }); | 416 }); |
412 let MutableRectangle = MutableRectangle$(dynamic); | 417 let MutableRectangle = MutableRectangle$(dynamic); |
413 // Function _clampToZero: (num) → num | 418 // Function _clampToZero: (num) → num |
414 function _clampToZero(value) { | 419 function _clampToZero(value) { |
415 dart.assert(dart.notNull(value) < 0); | 420 dart.assert(dart.notNull(value) < 0); |
416 return dart.notNull(-dart.notNull(value)) * 0; | 421 return dart.notNull(-dart.notNull(value)) * 0; |
(...skipping 21 matching lines...) Expand all Loading... |
438 exports.exp = exp; | 443 exports.exp = exp; |
439 exports.log = log; | 444 exports.log = log; |
440 exports.Point = Point; | 445 exports.Point = Point; |
441 exports.Point$ = Point$; | 446 exports.Point$ = Point$; |
442 exports.Random = Random; | 447 exports.Random = Random; |
443 exports.Rectangle = Rectangle; | 448 exports.Rectangle = Rectangle; |
444 exports.Rectangle$ = Rectangle$; | 449 exports.Rectangle$ = Rectangle$; |
445 exports.MutableRectangle = MutableRectangle; | 450 exports.MutableRectangle = MutableRectangle; |
446 exports.MutableRectangle$ = MutableRectangle$; | 451 exports.MutableRectangle$ = MutableRectangle$; |
447 })(math || (math = {})); | 452 })(math || (math = {})); |
OLD | NEW |