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

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

Issue 1050723002: partially implement instance of checks and some codegen fixes (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
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 19 matching lines...) Expand all
30 } 30 }
31 ['=='](other) { 31 ['=='](other) {
32 if (!dart.is(other, Point)) 32 if (!dart.is(other, Point))
33 return false; 33 return false;
34 return dart.notNull(dart.equals(this.x, dart.dload(other, 'x'))) && dart .notNull(dart.equals(this.y, dart.dload(other, 'y'))); 34 return dart.notNull(dart.equals(this.x, dart.dload(other, 'x'))) && dart .notNull(dart.equals(this.y, dart.dload(other, 'y')));
35 } 35 }
36 get hashCode() { 36 get hashCode() {
37 return _JenkinsSmiHash.hash2(this.x.hashCode, this.y.hashCode); 37 return _JenkinsSmiHash.hash2(this.x.hashCode, this.y.hashCode);
38 } 38 }
39 ['+'](other) { 39 ['+'](other) {
40 return new Point(dart.as(this.x['+'](other.x), T), dart.as(this.y['+'](o ther.y), T)); 40 return new (Point$(T))(dart.as(this.x['+'](other.x), T), dart.as(this.y[ '+'](other.y), T));
41 } 41 }
42 ['-'](other) { 42 ['-'](other) {
43 return new Point(dart.as(this.x['-'](other.x), T), dart.as(this.y['-'](o ther.y), T)); 43 return new (Point$(T))(dart.as(this.x['-'](other.x), T), dart.as(this.y[ '-'](other.y), T));
44 } 44 }
45 ['*'](factor) { 45 ['*'](factor) {
46 return new Point(dart.as(this.x['*'](factor), T), dart.as(this.y['*'](fa ctor), T)); 46 return new (Point$(T))(dart.as(this.x['*'](factor), T), dart.as(this.y[' *'](factor), T));
47 } 47 }
48 get magnitude() { 48 get magnitude() {
49 return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*'] (this.y))); 49 return sqrt(dart.notNull(this.x['*'](this.x)) + dart.notNull(this.y['*'] (this.y)));
50 } 50 }
51 distanceTo(other) { 51 distanceTo(other) {
52 let dx = this.x['-'](other.x); 52 let dx = this.x['-'](other.x);
53 let dy = this.y['-'](other.y); 53 let dy = this.y['-'](other.y);
54 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar t.notNull(dy)); 54 return sqrt(dart.notNull(dx) * dart.notNull(dx) + dart.notNull(dy) * dar t.notNull(dy));
55 } 55 }
56 squaredDistanceTo(other) { 56 squaredDistanceTo(other) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 get hashCode() { 90 get hashCode() {
91 return _JenkinsSmiHash.hash4(this.left.hashCode, this.top.hashCode, this .right.hashCode, this.bottom.hashCode); 91 return _JenkinsSmiHash.hash4(this.left.hashCode, this.top.hashCode, this .right.hashCode, this.bottom.hashCode);
92 } 92 }
93 intersection(other) { 93 intersection(other) {
94 let x0 = max(this.left, other.left); 94 let x0 = max(this.left, other.left);
95 let x1 = min(this.left['+'](this.width), other.left['+'](other.width)); 95 let x1 = min(this.left['+'](this.width), other.left['+'](other.width));
96 if (dart.notNull(x0) <= dart.notNull(x1)) { 96 if (dart.notNull(x0) <= dart.notNull(x1)) {
97 let y0 = max(this.top, other.top); 97 let y0 = max(this.top, other.top);
98 let y1 = min(this.top['+'](this.height), other.top['+'](other.height)) ; 98 let y1 = min(this.top['+'](this.height), other.top['+'](other.height)) ;
99 if (dart.notNull(y0) <= dart.notNull(y1)) { 99 if (dart.notNull(y0) <= dart.notNull(y1)) {
100 return new Rectangle(dart.as(x0, T), dart.as(y0, T), dart.as(dart.no tNull(x1) - dart.notNull(x0), T), dart.as(dart.notNull(y1) - dart.notNull(y0), T )); 100 return new (Rectangle$(T))(dart.as(x0, T), dart.as(y0, T), dart.as(d art.notNull(x1) - dart.notNull(x0), T), dart.as(dart.notNull(y1) - dart.notNull( y0), T));
101 } 101 }
102 } 102 }
103 return null; 103 return null;
104 } 104 }
105 intersects(other) { 105 intersects(other) {
106 return dart.notNull(this.left['<='](dart.notNull(other.left) + dart.notN ull(other.width))) && dart.notNull(other.left) <= dart.notNull(this.left['+'](th is.width)) && dart.notNull(this.top['<='](dart.notNull(other.top) + dart.notNull (other.height))) && dart.notNull(other.top) <= dart.notNull(this.top['+'](this.h eight)); 106 return dart.notNull(this.left['<='](dart.notNull(other.left) + dart.notN ull(other.width))) && dart.notNull(other.left) <= dart.notNull(this.left['+'](th is.width)) && dart.notNull(this.top['<='](dart.notNull(other.top) + dart.notNull (other.height))) && dart.notNull(other.top) <= dart.notNull(this.top['+'](this.h eight));
107 } 107 }
108 boundingBox(other) { 108 boundingBox(other) {
109 let right = max(this.left['+'](this.width), other.left['+'](other.width) ); 109 let right = max(this.left['+'](this.width), other.left['+'](other.width) );
110 let bottom = max(this.top['+'](this.height), other.top['+'](other.height )); 110 let bottom = max(this.top['+'](this.height), other.top['+'](other.height ));
111 let left = min(this.left, other.left); 111 let left = min(this.left, other.left);
112 let top = min(this.top, other.top); 112 let top = min(this.top, other.top);
113 return new Rectangle(dart.as(left, T), dart.as(top, T), dart.as(dart.not Null(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart.notNul l(top), T)); 113 return new (Rectangle$(T))(dart.as(left, T), dart.as(top, T), dart.as(da rt.notNull(right) - dart.notNull(left), T), dart.as(dart.notNull(bottom) - dart. notNull(top), T));
114 } 114 }
115 containsRectangle(another) { 115 containsRectangle(another) {
116 return dart.notNull(this.left['<='](another.left)) && dart.notNull(this. left['+'](this.width)) >= dart.notNull(another.left) + dart.notNull(another.widt h) && dart.notNull(this.top['<='](another.top)) && dart.notNull(this.top['+'](th is.height)) >= dart.notNull(another.top) + dart.notNull(another.height); 116 return dart.notNull(this.left['<='](another.left)) && dart.notNull(this. left['+'](this.width)) >= dart.notNull(another.left) + dart.notNull(another.widt h) && dart.notNull(this.top['<='](another.top)) && dart.notNull(this.top['+'](th is.height)) >= dart.notNull(another.top) + dart.notNull(another.height);
117 } 117 }
118 containsPoint(another) { 118 containsPoint(another) {
119 return core.num['>='](another.x, this.left) && dart.notNull(another.x) < = dart.notNull(this.left['+'](this.width)) && core.num['>='](another.y, this.top ) && dart.notNull(another.y) <= dart.notNull(this.top['+'](this.height)); 119 return core.num['>='](another.x, this.left) && dart.notNull(another.x) < = dart.notNull(this.left['+'](this.width)) && core.num['>='](another.y, this.top ) && dart.notNull(another.y) <= dart.notNull(this.top['+'](this.height));
120 } 120 }
121 get topLeft() { 121 get topLeft() {
122 return new Point(this.left, this.top); 122 return new (Point$(T))(this.left, this.top);
123 } 123 }
124 get topRight() { 124 get topRight() {
125 return new Point(dart.as(this.left['+'](this.width), T), this.top); 125 return new (Point$(T))(dart.as(this.left['+'](this.width), T), this.top) ;
126 } 126 }
127 get bottomRight() { 127 get bottomRight() {
128 return new Point(dart.as(this.left['+'](this.width), T), dart.as(this.to p['+'](this.height), T)); 128 return new (Point$(T))(dart.as(this.left['+'](this.width), T), dart.as(t his.top['+'](this.height), T));
129 } 129 }
130 get bottomLeft() { 130 get bottomLeft() {
131 return new Point(this.left, dart.as(this.top['+'](this.height), T)); 131 return new (Point$(T))(this.left, dart.as(this.top['+'](this.height), T) );
132 } 132 }
133 } 133 }
134 return _RectangleBase; 134 return _RectangleBase;
135 }); 135 });
136 let _RectangleBase = _RectangleBase$(dart.dynamic); 136 let _RectangleBase = _RectangleBase$(dart.dynamic);
137 let Rectangle$ = dart.generic(function(T) { 137 let Rectangle$ = dart.generic(function(T) {
138 class Rectangle extends _RectangleBase$(T) { 138 class Rectangle extends _RectangleBase$(T) {
139 Rectangle(left, top, width, height) { 139 Rectangle(left, top, width, height) {
140 this.left = left; 140 this.left = left;
141 this.top = top; 141 this.top = top;
142 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0 : width, T); 142 this.width = dart.as(width['<'](0) ? dart.notNull(width['unary-']()) * 0 : width, T);
143 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']()) * 0 : height, T); 143 this.height = dart.as(height['<'](0) ? dart.notNull(height['unary-']()) * 0 : height, T);
144 super._RectangleBase(); 144 super._RectangleBase();
145 } 145 }
146 fromPoints(a, b) { 146 fromPoints(a, b) {
147 let left = dart.as(min(a.x, b.x), T); 147 let left = dart.as(min(a.x, b.x), T);
148 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); 148 let width = dart.as(core.num['-'](max(a.x, b.x), left), T);
149 let top = dart.as(min(a.y, b.y), T); 149 let top = dart.as(min(a.y, b.y), T);
150 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); 150 let height = dart.as(core.num['-'](max(a.y, b.y), top), T);
151 return new Rectangle(left, top, width, height); 151 return new (Rectangle$(T))(left, top, width, height);
152 } 152 }
153 } 153 }
154 dart.defineNamedConstructor(Rectangle, 'fromPoints'); 154 dart.defineNamedConstructor(Rectangle, 'fromPoints');
155 return Rectangle; 155 return Rectangle;
156 }); 156 });
157 let Rectangle = Rectangle$(dart.dynamic); 157 let Rectangle = Rectangle$(dart.dynamic);
158 let _width = Symbol('_width'); 158 let _width = Symbol('_width');
159 let _height = Symbol('_height'); 159 let _height = Symbol('_height');
160 let MutableRectangle$ = dart.generic(function(T) { 160 let MutableRectangle$ = dart.generic(function(T) {
161 class MutableRectangle extends _RectangleBase$(T) { 161 class MutableRectangle extends _RectangleBase$(T) {
162 MutableRectangle(left, top, width, height) { 162 MutableRectangle(left, top, width, height) {
163 this.left = left; 163 this.left = left;
164 this.top = top; 164 this.top = top;
165 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T); 165 this[_width] = dart.as(width['<'](0) ? _clampToZero(width) : width, T);
166 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height, T); 166 this[_height] = dart.as(height['<'](0) ? _clampToZero(height) : height, T);
167 super._RectangleBase(); 167 super._RectangleBase();
168 } 168 }
169 fromPoints(a, b) { 169 fromPoints(a, b) {
170 let left = dart.as(min(a.x, b.x), T); 170 let left = dart.as(min(a.x, b.x), T);
171 let width = dart.as(core.num['-'](max(a.x, b.x), left), T); 171 let width = dart.as(core.num['-'](max(a.x, b.x), left), T);
172 let top = dart.as(min(a.y, b.y), T); 172 let top = dart.as(min(a.y, b.y), T);
173 let height = dart.as(core.num['-'](max(a.y, b.y), top), T); 173 let height = dart.as(core.num['-'](max(a.y, b.y), top), T);
174 return new MutableRectangle(left, top, width, height); 174 return new (MutableRectangle$(T))(left, top, width, height);
175 } 175 }
176 get width() { 176 get width() {
177 return this[_width]; 177 return this[_width];
178 } 178 }
179 set width(width) { 179 set width(width) {
180 if (width['<'](0)) 180 if (width['<'](0))
181 width = dart.as(_clampToZero(width), T); 181 width = dart.as(_clampToZero(width), T);
182 this[_width] = width; 182 this[_width] = width;
183 } 183 }
184 get height() { 184 get height() {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 exports.sin = sin; 449 exports.sin = sin;
450 exports.cos = cos; 450 exports.cos = cos;
451 exports.tan = tan; 451 exports.tan = tan;
452 exports.acos = acos; 452 exports.acos = acos;
453 exports.asin = asin; 453 exports.asin = asin;
454 exports.atan = atan; 454 exports.atan = atan;
455 exports.sqrt = sqrt; 455 exports.sqrt = sqrt;
456 exports.exp = exp; 456 exports.exp = exp;
457 exports.log = log; 457 exports.log = log;
458 })(math || (math = {})); 458 })(math || (math = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698