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

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

Issue 1152583002: Add constructors to signatures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
1 var math = dart.defineLibrary(math, {}); 1 var math = dart.defineLibrary(math, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var _js_helper = dart.lazyImport(_js_helper); 3 var _js_helper = dart.lazyImport(_js_helper);
4 (function(exports, core, _js_helper) { 4 (function(exports, core, _js_helper) {
5 'use strict'; 5 'use strict';
6 class _JenkinsSmiHash extends core.Object { 6 class _JenkinsSmiHash extends core.Object {
7 static combine(hash, value) { 7 static combine(hash, value) {
8 hash = 536870911 & dart.notNull(hash) + dart.notNull(value); 8 hash = 536870911 & dart.notNull(hash) + dart.notNull(value);
9 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) << 10); 9 hash = 536870911 & dart.notNull(hash) + ((524287 & dart.notNull(hash)) << 10);
10 return dart.notNull(hash) ^ dart.notNull(hash) >> 6; 10 return dart.notNull(hash) ^ dart.notNull(hash) >> 6;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar t.notNull(dy)); 68 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar t.notNull(dy));
69 } 69 }
70 squaredDistanceTo(other) { 70 squaredDistanceTo(other) {
71 dart.as(other, Point$(T)); 71 dart.as(other, Point$(T));
72 let dx = this.x['-'](other.x); 72 let dx = this.x['-'](other.x);
73 let dy = this.y['-'](other.y); 73 let dy = this.y['-'](other.y);
74 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T); 74 return dart.as(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dart.notNull(dy), T);
75 } 75 }
76 } 76 }
77 dart.setSignature(Point, { 77 dart.setSignature(Point, {
78 constructors: () => ({Point: [Point$(T), [T, T]]}),
78 methods: () => ({ 79 methods: () => ({
79 '+': [Point$(T), [Point$(T)]], 80 '+': [Point$(T), [Point$(T)]],
80 '-': [Point$(T), [Point$(T)]], 81 '-': [Point$(T), [Point$(T)]],
81 '*': [Point$(T), [core.num]], 82 '*': [Point$(T), [core.num]],
82 distanceTo: [core.double, [Point$(T)]], 83 distanceTo: [core.double, [Point$(T)]],
83 squaredDistanceTo: [T, [Point$(T)]] 84 squaredDistanceTo: [T, [Point$(T)]]
84 }) 85 })
85 }); 86 });
86 return Point; 87 return Point;
87 }); 88 });
88 let Point = Point$(); 89 let Point = Point$();
89 class Random extends core.Object { 90 class Random extends core.Object {
90 Random(seed) { 91 Random(seed) {
91 if (seed === void 0) 92 if (seed === void 0)
92 seed = null; 93 seed = null;
93 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed); 94 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed);
94 } 95 }
95 } 96 }
97 dart.setSignature(Random, {
98 constructors: () => ({Random: [Random, [], [core.int]]})
99 });
96 let _RectangleBase$ = dart.generic(function(T) { 100 let _RectangleBase$ = dart.generic(function(T) {
97 class _RectangleBase extends core.Object { 101 class _RectangleBase extends core.Object {
98 _RectangleBase() { 102 _RectangleBase() {
99 } 103 }
100 get right() { 104 get right() {
101 return dart.as(this.left['+'](this.width), T); 105 return dart.as(this.left['+'](this.width), T);
102 } 106 }
103 get bottom() { 107 get bottom() {
104 return dart.as(this.top['+'](this.height), T); 108 return dart.as(this.top['+'](this.height), T);
105 } 109 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top) ; 155 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top) ;
152 } 156 }
153 get bottomRight() { 157 get bottomRight() {
154 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t his.top['+'](this.height), T)); 158 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t his.top['+'](this.height), T));
155 } 159 }
156 get bottomLeft() { 160 get bottomLeft() {
157 return new (Point$(T))(this.left, dart.as(this.top['+'](this.height), T) ); 161 return new (Point$(T))(this.left, dart.as(this.top['+'](this.height), T) );
158 } 162 }
159 } 163 }
160 dart.setSignature(_RectangleBase, { 164 dart.setSignature(_RectangleBase, {
165 constructors: () => ({_RectangleBase: [_RectangleBase$(T), []]}),
161 methods: () => ({ 166 methods: () => ({
162 intersection: [Rectangle$(T), [Rectangle$(T)]], 167 intersection: [Rectangle$(T), [Rectangle$(T)]],
163 intersects: [core.bool, [Rectangle$(core.num)]], 168 intersects: [core.bool, [Rectangle$(core.num)]],
164 boundingBox: [Rectangle$(T), [Rectangle$(T)]], 169 boundingBox: [Rectangle$(T), [Rectangle$(T)]],
165 containsRectangle: [core.bool, [Rectangle$(core.num)]], 170 containsRectangle: [core.bool, [Rectangle$(core.num)]],
166 containsPoint: [core.bool, [Point$(core.num)]] 171 containsPoint: [core.bool, [Point$(core.num)]]
167 }) 172 })
168 }); 173 });
169 return _RectangleBase; 174 return _RectangleBase;
170 }); 175 });
171 let _RectangleBase = _RectangleBase$(); 176 let _RectangleBase = _RectangleBase$();
172 let Rectangle$ = dart.generic(function(T) { 177 let Rectangle$ = dart.generic(function(T) {
173 class Rectangle extends _RectangleBase$(T) { 178 class Rectangle extends _RectangleBase$(T) {
174 Rectangle(left, top, width, height) { 179 Rectangle(left, top, width, height) {
175 this.left = left; 180 this.left = left;
176 this.top = top; 181 this.top = top;
177 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0 : width, T); 182 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0 : width, T);
178 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']()) * 0 : height, T); 183 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']()) * 0 : height, T);
179 super._RectangleBase(); 184 super._RectangleBase();
180 } 185 }
181 fromPoints(a, b) { 186 fromPoints(a, b) {
182 let left = dart.as(min(a.x, b.x), T); 187 let left = dart.as(min(a.x, b.x), T);
183 let width = dart.as(max(a.x, b.x)['-'](left), T); 188 let width = dart.as(max(a.x, b.x)['-'](left), T);
184 let top = dart.as(min(a.y, b.y), T); 189 let top = dart.as(min(a.y, b.y), T);
185 let height = dart.as(max(a.y, b.y)['-'](top), T); 190 let height = dart.as(max(a.y, b.y)['-'](top), T);
186 return new (Rectangle$(T))(left, top, width, height); 191 return new (Rectangle$(T))(left, top, width, height);
187 } 192 }
188 } 193 }
189 dart.defineNamedConstructor(Rectangle, 'fromPoints'); 194 dart.defineNamedConstructor(Rectangle, 'fromPoints');
195 dart.setSignature(Rectangle, {
196 constructors: () => ({
197 Rectangle: [Rectangle$(T), [T, T, T, T]],
198 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]]
199 })
200 });
190 return Rectangle; 201 return Rectangle;
191 }); 202 });
192 let Rectangle = Rectangle$(); 203 let Rectangle = Rectangle$();
193 let _width = Symbol('_width'); 204 let _width = Symbol('_width');
194 let _height = Symbol('_height'); 205 let _height = Symbol('_height');
195 let MutableRectangle$ = dart.generic(function(T) { 206 let MutableRectangle$ = dart.generic(function(T) {
196 class MutableRectangle extends _RectangleBase$(T) { 207 class MutableRectangle extends _RectangleBase$(T) {
197 MutableRectangle(left, top, width, height) { 208 MutableRectangle(left, top, width, height) {
198 this.left = left; 209 this.left = left;
199 this.top = top; 210 this.top = top;
(...skipping 22 matching lines...) Expand all
222 } 233 }
223 set height(height) { 234 set height(height) {
224 dart.as(height, T); 235 dart.as(height, T);
225 if (height['<'](0)) 236 if (height['<'](0))
226 height = dart.as(_clampToZero(height), T); 237 height = dart.as(_clampToZero(height), T);
227 this[_height] = height; 238 this[_height] = height;
228 } 239 }
229 } 240 }
230 MutableRectangle[dart.implements] = () => [Rectangle$(T)]; 241 MutableRectangle[dart.implements] = () => [Rectangle$(T)];
231 dart.defineNamedConstructor(MutableRectangle, 'fromPoints'); 242 dart.defineNamedConstructor(MutableRectangle, 'fromPoints');
243 dart.setSignature(MutableRectangle, {
244 constructors: () => ({
245 MutableRectangle: [MutableRectangle$(T), [T, T, T, T]],
246 fromPoints: [MutableRectangle$(T), [Point$(T), Point$(T)]]
247 })
248 });
232 return MutableRectangle; 249 return MutableRectangle;
233 }); 250 });
234 let MutableRectangle = MutableRectangle$(); 251 let MutableRectangle = MutableRectangle$();
235 function _clampToZero(value) { 252 function _clampToZero(value) {
236 dart.assert(dart.notNull(value) < 0); 253 dart.assert(dart.notNull(value) < 0);
237 return -dart.notNull(value) * 0; 254 return -dart.notNull(value) * 0;
238 } 255 }
239 dart.fn(_clampToZero, core.num, [core.num]); 256 dart.fn(_clampToZero, core.num, [core.num]);
240 let E = 2.718281828459045; 257 let E = 2.718281828459045;
241 let LN10 = 2.302585092994046; 258 let LN10 = 2.302585092994046;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 366 }
350 nextDouble() { 367 nextDouble() {
351 return Math.random(); 368 return Math.random();
352 } 369 }
353 nextBool() { 370 nextBool() {
354 return Math.random() < 0.5; 371 return Math.random() < 0.5;
355 } 372 }
356 } 373 }
357 _JSRandom[dart.implements] = () => [Random]; 374 _JSRandom[dart.implements] = () => [Random];
358 dart.setSignature(_JSRandom, { 375 dart.setSignature(_JSRandom, {
376 constructors: () => ({_JSRandom: [_JSRandom, []]}),
359 methods: () => ({ 377 methods: () => ({
360 nextInt: [core.int, [core.int]], 378 nextInt: [core.int, [core.int]],
361 nextDouble: [core.double, []], 379 nextDouble: [core.double, []],
362 nextBool: [core.bool, []] 380 nextBool: [core.bool, []]
363 }) 381 })
364 }); 382 });
365 let _lo = Symbol('_lo'); 383 let _lo = Symbol('_lo');
366 let _hi = Symbol('_hi'); 384 let _hi = Symbol('_hi');
367 let _nextState = Symbol('_nextState'); 385 let _nextState = Symbol('_nextState');
368 class _Random extends core.Object { 386 class _Random extends core.Object {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1; 476 let bits27 = dart.notNull(this[_lo]) & (1 << 27) - 1;
459 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not Null(bits27)) / dart.notNull(_Random._POW2_53_D); 477 return (dart.notNull(bits26) * dart.notNull(_Random._POW2_27_D) + dart.not Null(bits27)) / dart.notNull(_Random._POW2_53_D);
460 } 478 }
461 nextBool() { 479 nextBool() {
462 this[_nextState](); 480 this[_nextState]();
463 return (dart.notNull(this[_lo]) & 1) == 0; 481 return (dart.notNull(this[_lo]) & 1) == 0;
464 } 482 }
465 } 483 }
466 _Random[dart.implements] = () => [Random]; 484 _Random[dart.implements] = () => [Random];
467 dart.setSignature(_Random, { 485 dart.setSignature(_Random, {
486 constructors: () => ({_Random: [_Random, [core.int]]}),
468 methods: () => ({ 487 methods: () => ({
469 [_nextState]: [dart.void, []], 488 [_nextState]: [dart.void, []],
470 nextInt: [core.int, [core.int]], 489 nextInt: [core.int, [core.int]],
471 nextDouble: [core.double, []], 490 nextDouble: [core.double, []],
472 nextBool: [core.bool, []] 491 nextBool: [core.bool, []]
473 }) 492 })
474 }); 493 });
475 _Random._POW2_53_D = 1.0 * 9007199254740992; 494 _Random._POW2_53_D = 1.0 * 9007199254740992;
476 _Random._POW2_27_D = 1.0 * (1 << 27); 495 _Random._POW2_27_D = 1.0 * (1 << 27);
477 _Random._MASK32 = 4294967295; 496 _Random._MASK32 = 4294967295;
(...skipping 20 matching lines...) Expand all
498 exports.sin = sin; 517 exports.sin = sin;
499 exports.cos = cos; 518 exports.cos = cos;
500 exports.tan = tan; 519 exports.tan = tan;
501 exports.acos = acos; 520 exports.acos = acos;
502 exports.asin = asin; 521 exports.asin = asin;
503 exports.atan = atan; 522 exports.atan = atan;
504 exports.sqrt = sqrt; 523 exports.sqrt = sqrt;
505 exports.exp = exp; 524 exports.exp = exp;
506 exports.log = log; 525 exports.log = log;
507 })(math, core, _js_helper); 526 })(math, core, _js_helper);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698