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

Side by Side Diff: lib/runtime/dart/math.js

Issue 1047023002: use == and != to enable handling null/undefined (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | lib/runtime/dart/typed_data.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var math; 1 var math;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class _JenkinsSmiHash extends core.Object { 4 class _JenkinsSmiHash extends core.Object {
5 static combine(hash, value) { 5 static combine(hash, value) {
6 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); 6 hash = 536870911 & dart.notNull(hash) + dart.notNull(value);
7 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) << 10); 7 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) << 10);
8 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; 8 return dart.notNull(hash) ^ dart.notNull(hash) >> 6;
9 } 9 }
10 static finish(hash) { 10 static finish(hash) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T); 59 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T);
60 } 60 }
61 } 61 }
62 return Point; 62 return Point;
63 }); 63 });
64 let Point = Point$(dart.dynamic); 64 let Point = Point$(dart.dynamic);
65 class Random extends core.Object { 65 class Random extends core.Object {
66 Random(seed) { 66 Random(seed) {
67 if (seed === void 0) 67 if (seed === void 0)
68 seed = null; 68 seed = null;
69 return seed === null ? new _JSRandom() : new _Random(seed); 69 return seed == null ? new _JSRandom() : new _Random(seed);
70 } 70 }
71 } 71 }
72 let _RectangleBase$ = dart.generic(function(T) { 72 let _RectangleBase$ = dart.generic(function(T) {
73 class _RectangleBase extends core.Object { 73 class _RectangleBase extends core.Object {
74 _RectangleBase() { 74 _RectangleBase() {
75 } 75 }
76 get right() { 76 get right() {
77 return dart.as(this.left['+'](this.width), T); 77 return dart.as(this.left['+'](this.width), T);
78 } 78 }
79 get bottom() { 79 get bottom() {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (!dart.is(a, core.num)) 212 if (!dart.is(a, core.num))
213 throw new core.ArgumentError(a); 213 throw new core.ArgumentError(a);
214 if (!dart.is(b, core.num)) 214 if (!dart.is(b, core.num))
215 throw new core.ArgumentError(b); 215 throw new core.ArgumentError(b);
216 if (dart.notNull(a) > dart.notNull(b)) 216 if (dart.notNull(a) > dart.notNull(b))
217 return b; 217 return b;
218 if (dart.notNull(a) < dart.notNull(b)) 218 if (dart.notNull(a) < dart.notNull(b))
219 return a; 219 return a;
220 if (typeof b == 'number') { 220 if (typeof b == 'number') {
221 if (typeof a == 'number') { 221 if (typeof a == 'number') {
222 if (a === 0.0) { 222 if (a == 0.0) {
223 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no tNull(b); 223 return (dart.notNull(a) + dart.notNull(b)) * dart.notNull(a) * dart.no tNull(b);
224 } 224 }
225 } 225 }
226 if (a === 0 && dart.notNull(b.isNegative) || dart.notNull(b.isNaN)) 226 if (a == 0 && dart.notNull(b.isNegative) || dart.notNull(b.isNaN))
227 return b; 227 return b;
228 return a; 228 return a;
229 } 229 }
230 return a; 230 return a;
231 } 231 }
232 // Function max: (num, num) → num 232 // Function max: (num, num) → num
233 function max(a, b) { 233 function max(a, b) {
234 if (!dart.is(a, core.num)) 234 if (!dart.is(a, core.num))
235 throw new core.ArgumentError(a); 235 throw new core.ArgumentError(a);
236 if (!dart.is(b, core.num)) 236 if (!dart.is(b, core.num))
237 throw new core.ArgumentError(b); 237 throw new core.ArgumentError(b);
238 if (dart.notNull(a) > dart.notNull(b)) 238 if (dart.notNull(a) > dart.notNull(b))
239 return a; 239 return a;
240 if (dart.notNull(a) < dart.notNull(b)) 240 if (dart.notNull(a) < dart.notNull(b))
241 return b; 241 return b;
242 if (typeof b == 'number') { 242 if (typeof b == 'number') {
243 if (typeof a == 'number') { 243 if (typeof a == 'number') {
244 if (a === 0.0) { 244 if (a == 0.0) {
245 return dart.notNull(a) + dart.notNull(b); 245 return dart.notNull(a) + dart.notNull(b);
246 } 246 }
247 } 247 }
248 if (b.isNaN) 248 if (b.isNaN)
249 return b; 249 return b;
250 return a; 250 return a;
251 } 251 }
252 if (b === 0 && dart.notNull(a.isNegative)) 252 if (b == 0 && dart.notNull(a.isNegative))
253 return b; 253 return b;
254 return a; 254 return a;
255 } 255 }
256 // Function atan2: (num, num) → double 256 // Function atan2: (num, num) → double
257 function atan2(a, b) { 257 function atan2(a, b) {
258 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b)); 258 return Math.atan2(_js_helper.checkNum(a), _js_helper.checkNum(b));
259 } 259 }
260 // Function pow: (num, num) → num 260 // Function pow: (num, num) → num
261 function pow(x, exponent) { 261 function pow(x, exponent) {
262 _js_helper.checkNum(x); 262 _js_helper.checkNum(x);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 tmplow = dart.notNull(low) << 31; 361 tmplow = dart.notNull(low) << 31;
362 tmphigh = dart.notNull(high) << 31 | dart.notNull(low) >> 1; 362 tmphigh = dart.notNull(high) << 31 | dart.notNull(low) >> 1;
363 tmplow = low; 363 tmplow = low;
364 low = dart.notNull(tmplow) & dart.notNull(_Random[_MASK32]); 364 low = dart.notNull(tmplow) & dart.notNull(_Random[_MASK32]);
365 high = dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmplo w) - dart.notNull(low)) / 4294967296).truncate() & dart.notNull(_Random[_MASK32] ); 365 high = dart.notNull(high) + dart.notNull(tmphigh) + ((dart.notNull(tmplo w) - dart.notNull(low)) / 4294967296).truncate() & dart.notNull(_Random[_MASK32] );
366 tmplow = dart.notNull(this[_lo]) * 1037; 366 tmplow = dart.notNull(this[_lo]) * 1037;
367 this[_lo] = dart.notNull(tmplow) & dart.notNull(_Random[_MASK32]); 367 this[_lo] = dart.notNull(tmplow) & dart.notNull(_Random[_MASK32]);
368 this[_hi] = dart.notNull(this[_hi]) * 1037 + ((dart.notNull(tmplow) - da rt.notNull(this[_lo])) / 4294967296).truncate() & dart.notNull(_Random[_MASK32]) ; 368 this[_hi] = dart.notNull(this[_hi]) * 1037 + ((dart.notNull(tmplow) - da rt.notNull(this[_lo])) / 4294967296).truncate() & dart.notNull(_Random[_MASK32]) ;
369 this[_lo] = low; 369 this[_lo] = low;
370 this[_hi] = high; 370 this[_hi] = high;
371 } while (seed !== empty_seed); 371 } while (seed != empty_seed);
372 if (this[_hi] === 0 && this[_lo] === 0) { 372 if (this[_hi] == 0 && this[_lo] == 0) {
373 this[_lo] = 23063; 373 this[_lo] = 23063;
374 } 374 }
375 this[_nextState](); 375 this[_nextState]();
376 this[_nextState](); 376 this[_nextState]();
377 this[_nextState](); 377 this[_nextState]();
378 this[_nextState](); 378 this[_nextState]();
379 } 379 }
380 [_nextState]() { 380 [_nextState]() {
381 let tmpHi = 4294901760 * dart.notNull(this[_lo]); 381 let tmpHi = 4294901760 * dart.notNull(this[_lo]);
382 let tmpHiLo = dart.notNull(tmpHi) & dart.notNull(_Random[_MASK32]); 382 let tmpHiLo = dart.notNull(tmpHi) & dart.notNull(_Random[_MASK32]);
383 let tmpHiHi = dart.notNull(tmpHi) - dart.notNull(tmpHiLo); 383 let tmpHiHi = dart.notNull(tmpHi) - dart.notNull(tmpHiLo);
384 let tmpLo = 55905 * dart.notNull(this[_lo]); 384 let tmpLo = 55905 * dart.notNull(this[_lo]);
385 let tmpLoLo = dart.notNull(tmpLo) & dart.notNull(_Random[_MASK32]); 385 let tmpLoLo = dart.notNull(tmpLo) & dart.notNull(_Random[_MASK32]);
386 let tmpLoHi = dart.notNull(tmpLo) - dart.notNull(tmpLoLo); 386 let tmpLoHi = dart.notNull(tmpLo) - dart.notNull(tmpLoLo);
387 let newLo = dart.notNull(tmpLoLo) + dart.notNull(tmpHiLo) + dart.notNull(t his[_hi]); 387 let newLo = dart.notNull(tmpLoLo) + dart.notNull(tmpHiLo) + dart.notNull(t his[_hi]);
388 this[_lo] = dart.notNull(newLo) & dart.notNull(_Random[_MASK32]); 388 this[_lo] = dart.notNull(newLo) & dart.notNull(_Random[_MASK32]);
389 let newLoHi = dart.notNull(newLo) - dart.notNull(this[_lo]); 389 let newLoHi = dart.notNull(newLo) - dart.notNull(this[_lo]);
390 this[_hi] = ((dart.notNull(tmpLoHi) + dart.notNull(tmpHiHi) + dart.notNull (newLoHi)) / dart.notNull(_POW2_32)).truncate() & dart.notNull(_Random[_MASK32]) ; 390 this[_hi] = ((dart.notNull(tmpLoHi) + dart.notNull(tmpHiHi) + dart.notNull (newLoHi)) / dart.notNull(_POW2_32)).truncate() & dart.notNull(_Random[_MASK32]) ;
391 dart.assert(dart.notNull(this[_lo]) < dart.notNull(_POW2_32)); 391 dart.assert(dart.notNull(this[_lo]) < dart.notNull(_POW2_32));
392 dart.assert(dart.notNull(this[_hi]) < dart.notNull(_POW2_32)); 392 dart.assert(dart.notNull(this[_hi]) < dart.notNull(_POW2_32));
393 } 393 }
394 nextInt(max) { 394 nextInt(max) {
395 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32)) { 395 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32)) {
396 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma x}`); 396 throw new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${ma x}`);
397 } 397 }
398 if ((dart.notNull(max) & dart.notNull(max) - 1) === 0) { 398 if ((dart.notNull(max) & dart.notNull(max) - 1) == 0) {
399 this[_nextState](); 399 this[_nextState]();
400 return dart.notNull(this[_lo]) & dart.notNull(max) - 1; 400 return dart.notNull(this[_lo]) & dart.notNull(max) - 1;
401 } 401 }
402 let rnd32 = null; 402 let rnd32 = null;
403 let result = null; 403 let result = null;
404 do { 404 do {
405 this[_nextState](); 405 this[_nextState]();
406 rnd32 = this[_lo]; 406 rnd32 = this[_lo];
407 result = rnd32.remainder(max); 407 result = rnd32.remainder(max);
408 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >= dart.notNull(_POW2_32)); 408 } while (dart.notNull(rnd32) - dart.notNull(result) + dart.notNull(max) >= dart.notNull(_POW2_32));
409 return result; 409 return result;
410 } 410 }
411 nextDouble() { 411 nextDouble() {
412 this[_nextState](); 412 this[_nextState]();
413 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1; 413 let bits26 = dart.notNull(this[_lo]) & (1 << 26) - 1;
414 this[_nextState](); 414 this[_nextState]();
415 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; 415 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1;
416 return (dart.notNull(bits26) * dart.notNull(_Random[_POW2_27_D]) + dart.no tNull(bits27)) / dart.notNull(_Random[_POW2_53_D]); 416 return (dart.notNull(bits26) * dart.notNull(_Random[_POW2_27_D]) + dart.no tNull(bits27)) / dart.notNull(_Random[_POW2_53_D]);
417 } 417 }
418 nextBool() { 418 nextBool() {
419 this[_nextState](); 419 this[_nextState]();
420 return (dart.notNull(this[_lo]) & 1) === 0; 420 return (dart.notNull(this[_lo]) & 1) == 0;
421 } 421 }
422 } 422 }
423 _Random._POW2_53_D = 1.0 * 9007199254740992; 423 _Random._POW2_53_D = 1.0 * 9007199254740992;
424 _Random._POW2_27_D = 1.0 * (1 << 27); 424 _Random._POW2_27_D = 1.0 * (1 << 27);
425 _Random._MASK32 = 4294967295; 425 _Random._MASK32 = 4294967295;
426 // Exports: 426 // Exports:
427 exports.Point = Point; 427 exports.Point = Point;
428 exports.Point$ = Point$; 428 exports.Point$ = Point$;
429 exports.Random = Random; 429 exports.Random = Random;
430 exports.Rectangle = Rectangle; 430 exports.Rectangle = Rectangle;
(...skipping 15 matching lines...) Expand all
446 exports.sin = sin; 446 exports.sin = sin;
447 exports.cos = cos; 447 exports.cos = cos;
448 exports.tan = tan; 448 exports.tan = tan;
449 exports.acos = acos; 449 exports.acos = acos;
450 exports.asin = asin; 450 exports.asin = asin;
451 exports.atan = atan; 451 exports.atan = atan;
452 exports.sqrt = sqrt; 452 exports.sqrt = sqrt;
453 exports.exp = exp; 453 exports.exp = exp;
454 exports.log = log; 454 exports.log = log;
455 })(math || (math = {})); 455 })(math || (math = {}));
OLDNEW
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | lib/runtime/dart/typed_data.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698