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

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

Issue 1483813002: Use const for const/final top-levels, types, symbols. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebased after vsm's regen Created 5 years 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/js.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 dart_library.library('dart/math', null, /* Imports */[ 1 dart_library.library('dart/math', null, /* Imports */[
2 "dart/_runtime", 2 "dart/_runtime",
3 'dart/core' 3 'dart/core'
4 ], /* Lazy imports */[ 4 ], /* Lazy imports */[
5 'dart/_js_helper' 5 'dart/_js_helper'
6 ], function(exports, dart, core, _js_helper) { 6 ], function(exports, dart, core, _js_helper) {
7 'use strict'; 7 'use strict';
8 let dartx = dart.dartx; 8 let dartx = dart.dartx;
9 class _JenkinsSmiHash extends core.Object { 9 class _JenkinsSmiHash extends core.Object {
10 static combine(hash, value) { 10 static combine(hash, value) {
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 dart.setSignature(_JenkinsSmiHash, { 27 dart.setSignature(_JenkinsSmiHash, {
28 statics: () => ({ 28 statics: () => ({
29 combine: [core.int, [core.int, core.int]], 29 combine: [core.int, [core.int, core.int]],
30 finish: [core.int, [core.int]], 30 finish: [core.int, [core.int]],
31 hash2: [core.int, [dart.dynamic, dart.dynamic]], 31 hash2: [core.int, [dart.dynamic, dart.dynamic]],
32 hash4: [core.int, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic] ] 32 hash4: [core.int, [dart.dynamic, dart.dynamic, dart.dynamic, dart.dynamic] ]
33 }), 33 }),
34 names: ['combine', 'finish', 'hash2', 'hash4'] 34 names: ['combine', 'finish', 'hash2', 'hash4']
35 }); 35 });
36 let Point$ = dart.generic(function(T) { 36 const Point$ = dart.generic(function(T) {
37 class Point extends core.Object { 37 class Point extends core.Object {
38 Point(x, y) { 38 Point(x, y) {
39 this.x = x; 39 this.x = x;
40 this.y = y; 40 this.y = y;
41 } 41 }
42 toString() { 42 toString() {
43 return `Point(${this.x}, ${this.y})`; 43 return `Point(${this.x}, ${this.y})`;
44 } 44 }
45 ['=='](other) { 45 ['=='](other) {
46 if (!dart.is(other, Point$())) 46 if (!dart.is(other, Point$()))
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 class Random extends core.Object { 93 class Random extends core.Object {
94 static new(seed) { 94 static new(seed) {
95 if (seed === void 0) 95 if (seed === void 0)
96 seed = null; 96 seed = null;
97 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed); 97 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed);
98 } 98 }
99 } 99 }
100 dart.setSignature(Random, { 100 dart.setSignature(Random, {
101 constructors: () => ({new: [Random, [], [core.int]]}) 101 constructors: () => ({new: [Random, [], [core.int]]})
102 }); 102 });
103 let _RectangleBase$ = dart.generic(function(T) { 103 const _RectangleBase$ = dart.generic(function(T) {
104 class _RectangleBase extends core.Object { 104 class _RectangleBase extends core.Object {
105 _RectangleBase() { 105 _RectangleBase() {
106 } 106 }
107 get right() { 107 get right() {
108 return dart.notNull(this.left) + dart.notNull(this.width); 108 return dart.notNull(this.left) + dart.notNull(this.width);
109 } 109 }
110 get bottom() { 110 get bottom() {
111 return dart.notNull(this.top) + dart.notNull(this.height); 111 return dart.notNull(this.top) + dart.notNull(this.height);
112 } 112 }
113 toString() { 113 toString() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 intersection: [Rectangle$(T), [Rectangle$(T)]], 170 intersection: [Rectangle$(T), [Rectangle$(T)]],
171 intersects: [core.bool, [Rectangle$(core.num)]], 171 intersects: [core.bool, [Rectangle$(core.num)]],
172 boundingBox: [Rectangle$(T), [Rectangle$(T)]], 172 boundingBox: [Rectangle$(T), [Rectangle$(T)]],
173 containsRectangle: [core.bool, [Rectangle$(core.num)]], 173 containsRectangle: [core.bool, [Rectangle$(core.num)]],
174 containsPoint: [core.bool, [Point$(core.num)]] 174 containsPoint: [core.bool, [Point$(core.num)]]
175 }) 175 })
176 }); 176 });
177 return _RectangleBase; 177 return _RectangleBase;
178 }); 178 });
179 let _RectangleBase = _RectangleBase$(); 179 let _RectangleBase = _RectangleBase$();
180 let Rectangle$ = dart.generic(function(T) { 180 const Rectangle$ = dart.generic(function(T) {
181 class Rectangle extends _RectangleBase$(T) { 181 class Rectangle extends _RectangleBase$(T) {
182 Rectangle(left, top, width, height) { 182 Rectangle(left, top, width, height) {
183 this.left = left; 183 this.left = left;
184 this.top = top; 184 this.top = top;
185 this.width = dart.notNull(width) < 0 ? -dart.notNull(width) * 0 : width; 185 this.width = dart.notNull(width) < 0 ? -dart.notNull(width) * 0 : width;
186 this.height = dart.notNull(height) < 0 ? -dart.notNull(height) * 0 : hei ght; 186 this.height = dart.notNull(height) < 0 ? -dart.notNull(height) * 0 : hei ght;
187 super._RectangleBase(); 187 super._RectangleBase();
188 } 188 }
189 static fromPoints(a, b) { 189 static fromPoints(a, b) {
190 let left = min(a.x, b.x); 190 let left = min(a.x, b.x);
191 let width = dart.notNull(max(a.x, b.x)) - dart.notNull(left); 191 let width = dart.notNull(max(a.x, b.x)) - dart.notNull(left);
192 let top = min(a.y, b.y); 192 let top = min(a.y, b.y);
193 let height = dart.notNull(max(a.y, b.y)) - dart.notNull(top); 193 let height = dart.notNull(max(a.y, b.y)) - dart.notNull(top);
194 return new (Rectangle$(T))(left, top, width, height); 194 return new (Rectangle$(T))(left, top, width, height);
195 } 195 }
196 } 196 }
197 dart.setSignature(Rectangle, { 197 dart.setSignature(Rectangle, {
198 constructors: () => ({ 198 constructors: () => ({
199 Rectangle: [Rectangle$(T), [T, T, T, T]], 199 Rectangle: [Rectangle$(T), [T, T, T, T]],
200 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]] 200 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]]
201 }) 201 })
202 }); 202 });
203 return Rectangle; 203 return Rectangle;
204 }); 204 });
205 let Rectangle = Rectangle$(); 205 let Rectangle = Rectangle$();
206 let _width = Symbol('_width'); 206 const _width = Symbol('_width');
207 let _height = Symbol('_height'); 207 const _height = Symbol('_height');
208 let MutableRectangle$ = dart.generic(function(T) { 208 const MutableRectangle$ = dart.generic(function(T) {
209 class MutableRectangle extends _RectangleBase$(T) { 209 class MutableRectangle extends _RectangleBase$(T) {
210 MutableRectangle(left, top, width, height) { 210 MutableRectangle(left, top, width, height) {
211 this.left = left; 211 this.left = left;
212 this.top = top; 212 this.top = top;
213 this[_width] = dart.notNull(width) < 0 ? _clampToZero(width) : width; 213 this[_width] = dart.notNull(width) < 0 ? _clampToZero(width) : width;
214 this[_height] = dart.notNull(height) < 0 ? _clampToZero(height) : height ; 214 this[_height] = dart.notNull(height) < 0 ? _clampToZero(height) : height ;
215 super._RectangleBase(); 215 super._RectangleBase();
216 } 216 }
217 static fromPoints(a, b) { 217 static fromPoints(a, b) {
218 let left = min(a.x, b.x); 218 let left = min(a.x, b.x);
(...skipping 29 matching lines...) Expand all
248 }) 248 })
249 }); 249 });
250 return MutableRectangle; 250 return MutableRectangle;
251 }); 251 });
252 let MutableRectangle = MutableRectangle$(); 252 let MutableRectangle = MutableRectangle$();
253 function _clampToZero(value) { 253 function _clampToZero(value) {
254 dart.assert(dart.notNull(value) < 0); 254 dart.assert(dart.notNull(value) < 0);
255 return -dart.notNull(value) * 0; 255 return -dart.notNull(value) * 0;
256 } 256 }
257 dart.fn(_clampToZero, core.num, [core.num]); 257 dart.fn(_clampToZero, core.num, [core.num]);
258 let E = 2.718281828459045; 258 const E = 2.718281828459045;
259 let LN10 = 2.302585092994046; 259 const LN10 = 2.302585092994046;
260 let LN2 = 0.6931471805599453; 260 const LN2 = 0.6931471805599453;
261 let LOG2E = 1.4426950408889634; 261 const LOG2E = 1.4426950408889634;
262 let LOG10E = 0.4342944819032518; 262 const LOG10E = 0.4342944819032518;
263 let PI = 3.141592653589793; 263 const PI = 3.141592653589793;
264 let SQRT1_2 = 0.7071067811865476; 264 const SQRT1_2 = 0.7071067811865476;
265 let SQRT2 = 1.4142135623730951; 265 const SQRT2 = 1.4142135623730951;
266 function min(a, b) { 266 function min(a, b) {
267 if (!(typeof a == 'number')) 267 if (!(typeof a == 'number'))
268 dart.throw(new core.ArgumentError(a)); 268 dart.throw(new core.ArgumentError(a));
269 if (!(typeof b == 'number')) 269 if (!(typeof b == 'number'))
270 dart.throw(new core.ArgumentError(b)); 270 dart.throw(new core.ArgumentError(b));
271 if (dart.notNull(a) > dart.notNull(b)) 271 if (dart.notNull(a) > dart.notNull(b))
272 return b; 272 return b;
273 if (dart.notNull(a) < dart.notNull(b)) 273 if (dart.notNull(a) < dart.notNull(b))
274 return a; 274 return a;
275 if (typeof b == 'number') { 275 if (typeof b == 'number') {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 348 }
349 dart.fn(sqrt, core.double, [core.num]); 349 dart.fn(sqrt, core.double, [core.num]);
350 function exp(x) { 350 function exp(x) {
351 return Math.exp(_js_helper.checkNum(x)); 351 return Math.exp(_js_helper.checkNum(x));
352 } 352 }
353 dart.fn(exp, core.double, [core.num]); 353 dart.fn(exp, core.double, [core.num]);
354 function log(x) { 354 function log(x) {
355 return Math.log(_js_helper.checkNum(x)); 355 return Math.log(_js_helper.checkNum(x));
356 } 356 }
357 dart.fn(log, core.double, [core.num]); 357 dart.fn(log, core.double, [core.num]);
358 let _POW2_32 = 4294967296; 358 const _POW2_32 = 4294967296;
359 class _JSRandom extends core.Object { 359 class _JSRandom extends core.Object {
360 _JSRandom() { 360 _JSRandom() {
361 } 361 }
362 nextInt(max) { 362 nextInt(max) {
363 if (dart.notNull(max) <= 0 || dart.notNull(max) > dart.notNull(_POW2_32)) { 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}`)); 364 dart.throw(new core.RangeError(`max must be in range 0 < max ≤ 2^32, was ${max}`));
365 } 365 }
366 return Math.random() * max >>> 0; 366 return Math.random() * max >>> 0;
367 } 367 }
368 nextDouble() { 368 nextDouble() {
369 return Math.random(); 369 return Math.random();
370 } 370 }
371 nextBool() { 371 nextBool() {
372 return Math.random() < 0.5; 372 return Math.random() < 0.5;
373 } 373 }
374 } 374 }
375 _JSRandom[dart.implements] = () => [Random]; 375 _JSRandom[dart.implements] = () => [Random];
376 dart.setSignature(_JSRandom, { 376 dart.setSignature(_JSRandom, {
377 constructors: () => ({_JSRandom: [_JSRandom, []]}), 377 constructors: () => ({_JSRandom: [_JSRandom, []]}),
378 methods: () => ({ 378 methods: () => ({
379 nextInt: [core.int, [core.int]], 379 nextInt: [core.int, [core.int]],
380 nextDouble: [core.double, []], 380 nextDouble: [core.double, []],
381 nextBool: [core.bool, []] 381 nextBool: [core.bool, []]
382 }) 382 })
383 }); 383 });
384 let _lo = Symbol('_lo'); 384 const _lo = Symbol('_lo');
385 let _hi = Symbol('_hi'); 385 const _hi = Symbol('_hi');
386 let _nextState = Symbol('_nextState'); 386 const _nextState = Symbol('_nextState');
387 class _Random extends core.Object { 387 class _Random extends core.Object {
388 _Random(seed) { 388 _Random(seed) {
389 this[_lo] = 0; 389 this[_lo] = 0;
390 this[_hi] = 0; 390 this[_hi] = 0;
391 let empty_seed = 0; 391 let empty_seed = 0;
392 if (dart.notNull(seed) < 0) { 392 if (dart.notNull(seed) < 0) {
393 empty_seed = -1; 393 empty_seed = -1;
394 } 394 }
395 do { 395 do {
396 let low = dart.notNull(seed) & dart.notNull(_Random._MASK32); 396 let low = dart.notNull(seed) & dart.notNull(_Random._MASK32);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 exports.sin = sin; 518 exports.sin = sin;
519 exports.cos = cos; 519 exports.cos = cos;
520 exports.tan = tan; 520 exports.tan = tan;
521 exports.acos = acos; 521 exports.acos = acos;
522 exports.asin = asin; 522 exports.asin = asin;
523 exports.atan = atan; 523 exports.atan = atan;
524 exports.sqrt = sqrt; 524 exports.sqrt = sqrt;
525 exports.exp = exp; 525 exports.exp = exp;
526 exports.log = log; 526 exports.log = log;
527 }); 527 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/js.js ('k') | lib/runtime/dart/typed_data.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698