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

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

Issue 1700153002: Wrapperless dart:html and friends (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: A couple more tweaks Created 4 years, 10 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/js.js ('k') | lib/runtime/dart/mirrors.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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 class Random extends core.Object { 92 class Random extends core.Object {
93 static new(seed) { 93 static new(seed) {
94 if (seed === void 0) seed = null; 94 if (seed === void 0) seed = null;
95 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed); 95 return seed == null ? dart.const(new _JSRandom()) : new _Random(seed);
96 } 96 }
97 } 97 }
98 dart.setSignature(Random, { 98 dart.setSignature(Random, {
99 constructors: () => ({new: [Random, [], [core.int]]}) 99 constructors: () => ({new: [Random, [], [core.int]]})
100 }); 100 });
101 const _RectangleBase$ = dart.generic(function(T) { 101 const _RectangleBase$ = dart.generic(function(T) {
102 dart.defineExtensionNames([
103 'right',
104 'bottom',
105 'toString',
106 '==',
107 'hashCode',
108 'intersection',
109 'intersects',
110 'boundingBox',
111 'containsRectangle',
112 'containsPoint',
113 'topLeft',
114 'topRight',
115 'bottomRight',
116 'bottomLeft'
117 ]);
102 class _RectangleBase extends core.Object { 118 class _RectangleBase extends core.Object {
103 _RectangleBase() { 119 _RectangleBase() {
104 } 120 }
105 get right() { 121 get [dartx.right]() {
106 return dart.notNull(this.left) + dart.notNull(this.width); 122 return dart.notNull(this[dartx.left]) + dart.notNull(this[dartx.width]);
107 } 123 }
108 get bottom() { 124 get [dartx.bottom]() {
109 return dart.notNull(this.top) + dart.notNull(this.height); 125 return dart.notNull(this[dartx.top]) + dart.notNull(this[dartx.height]);
110 } 126 }
111 toString() { 127 toString() {
112 return `Rectangle (${this.left}, ${this.top}) ${this.width} x ${this.hei ght}`; 128 return `Rectangle (${this[dartx.left]}, ${this[dartx.top]}) ${this[dartx .width]} x ${this[dartx.height]}`;
113 } 129 }
114 ['=='](other) { 130 ['=='](other) {
115 if (!dart.is(other, Rectangle)) return false; 131 if (!dart.is(other, Rectangle)) return false;
116 return dart.equals(this.left, dart.dload(other, 'left')) && dart.equals( this.top, dart.dload(other, 'top')) && dart.equals(this.right, dart.dload(other, 'right')) && dart.equals(this.bottom, dart.dload(other, 'bottom')); 132 return dart.equals(this[dartx.left], dart.dload(other, 'left')) && dart. equals(this[dartx.top], dart.dload(other, 'top')) && dart.equals(this[dartx.righ t], dart.dload(other, 'right')) && dart.equals(this[dartx.bottom], dart.dload(ot her, 'bottom'));
117 } 133 }
118 get hashCode() { 134 get hashCode() {
119 return _JenkinsSmiHash.hash4(dart.hashCode(this.left), dart.hashCode(thi s.top), dart.hashCode(this.right), dart.hashCode(this.bottom)); 135 return _JenkinsSmiHash.hash4(dart.hashCode(this[dartx.left]), dart.hashC ode(this[dartx.top]), dart.hashCode(this[dartx.right]), dart.hashCode(this[dartx .bottom]));
120 } 136 }
121 intersection(other) { 137 [dartx.intersection](other) {
122 dart.as(other, Rectangle$(T)); 138 dart.as(other, Rectangle$(T));
123 let x0 = max(this.left, other.left); 139 let x0 = max(this[dartx.left], other[dartx.left]);
124 let x1 = min(dart.notNull(this.left) + dart.notNull(this.width), dart.no tNull(other.left) + dart.notNull(other.width)); 140 let x1 = min(dart.notNull(this[dartx.left]) + dart.notNull(this[dartx.wi dth]), dart.notNull(other[dartx.left]) + dart.notNull(other[dartx.width]));
125 if (dart.notNull(x0) <= dart.notNull(x1)) { 141 if (dart.notNull(x0) <= dart.notNull(x1)) {
126 let y0 = max(this.top, other.top); 142 let y0 = max(this[dartx.top], other[dartx.top]);
127 let y1 = min(dart.notNull(this.top) + dart.notNull(this.height), dart. notNull(other.top) + dart.notNull(other.height)); 143 let y1 = min(dart.notNull(this[dartx.top]) + dart.notNull(this[dartx.h eight]), dart.notNull(other[dartx.top]) + dart.notNull(other[dartx.height]));
128 if (dart.notNull(y0) <= dart.notNull(y1)) { 144 if (dart.notNull(y0) <= dart.notNull(y1)) {
129 return new (Rectangle$(T))(x0, y0, dart.notNull(x1) - dart.notNull(x 0), dart.notNull(y1) - dart.notNull(y0)); 145 return new (Rectangle$(T))(x0, y0, dart.notNull(x1) - dart.notNull(x 0), dart.notNull(y1) - dart.notNull(y0));
130 } 146 }
131 } 147 }
132 return null; 148 return null;
133 } 149 }
134 intersects(other) { 150 [dartx.intersects](other) {
135 return dart.notNull(this.left) <= dart.notNull(other.left) + dart.notNul l(other.width) && dart.notNull(other.left) <= dart.notNull(this.left) + dart.not Null(this.width) && dart.notNull(this.top) <= dart.notNull(other.top) + dart.not Null(other.height) && dart.notNull(other.top) <= dart.notNull(this.top) + dart.n otNull(this.height); 151 return dart.notNull(this[dartx.left]) <= dart.notNull(other[dartx.left]) + dart.notNull(other[dartx.width]) && dart.notNull(other[dartx.left]) <= dart.n otNull(this[dartx.left]) + dart.notNull(this[dartx.width]) && dart.notNull(this[ dartx.top]) <= dart.notNull(other[dartx.top]) + dart.notNull(other[dartx.height] ) && dart.notNull(other[dartx.top]) <= dart.notNull(this[dartx.top]) + dart.notN ull(this[dartx.height]);
136 } 152 }
137 boundingBox(other) { 153 [dartx.boundingBox](other) {
138 dart.as(other, Rectangle$(T)); 154 dart.as(other, Rectangle$(T));
139 let right = max(dart.notNull(this.left) + dart.notNull(this.width), dart .notNull(other.left) + dart.notNull(other.width)); 155 let right = max(dart.notNull(this[dartx.left]) + dart.notNull(this[dartx .width]), dart.notNull(other[dartx.left]) + dart.notNull(other[dartx.width]));
140 let bottom = max(dart.notNull(this.top) + dart.notNull(this.height), dar t.notNull(other.top) + dart.notNull(other.height)); 156 let bottom = max(dart.notNull(this[dartx.top]) + dart.notNull(this[dartx .height]), dart.notNull(other[dartx.top]) + dart.notNull(other[dartx.height]));
141 let left = min(this.left, other.left); 157 let left = min(this[dartx.left], other[dartx.left]);
142 let top = min(this.top, other.top); 158 let top = min(this[dartx.top], other[dartx.top]);
143 return new (Rectangle$(T))(left, top, dart.notNull(right) - dart.notNull (left), dart.notNull(bottom) - dart.notNull(top)); 159 return new (Rectangle$(T))(left, top, dart.notNull(right) - dart.notNull (left), dart.notNull(bottom) - dart.notNull(top));
144 } 160 }
145 containsRectangle(another) { 161 [dartx.containsRectangle](another) {
146 return dart.notNull(this.left) <= dart.notNull(another.left) && dart.not Null(this.left) + dart.notNull(this.width) >= dart.notNull(another.left) + dart. notNull(another.width) && dart.notNull(this.top) <= dart.notNull(another.top) && dart.notNull(this.top) + dart.notNull(this.height) >= dart.notNull(another.top) + dart.notNull(another.height); 162 return dart.notNull(this[dartx.left]) <= dart.notNull(another[dartx.left ]) && dart.notNull(this[dartx.left]) + dart.notNull(this[dartx.width]) >= dart.n otNull(another[dartx.left]) + dart.notNull(another[dartx.width]) && dart.notNull (this[dartx.top]) <= dart.notNull(another[dartx.top]) && dart.notNull(this[dartx .top]) + dart.notNull(this[dartx.height]) >= dart.notNull(another[dartx.top]) + dart.notNull(another[dartx.height]);
147 } 163 }
148 containsPoint(another) { 164 [dartx.containsPoint](another) {
149 return dart.notNull(another.x) >= dart.notNull(this.left) && dart.notNul l(another.x) <= dart.notNull(this.left) + dart.notNull(this.width) && dart.notNu ll(another.y) >= dart.notNull(this.top) && dart.notNull(another.y) <= dart.notNu ll(this.top) + dart.notNull(this.height); 165 return dart.notNull(another.x) >= dart.notNull(this[dartx.left]) && dart .notNull(another.x) <= dart.notNull(this[dartx.left]) + dart.notNull(this[dartx. width]) && dart.notNull(another.y) >= dart.notNull(this[dartx.top]) && dart.notN ull(another.y) <= dart.notNull(this[dartx.top]) + dart.notNull(this[dartx.height ]);
150 } 166 }
151 get topLeft() { 167 get [dartx.topLeft]() {
152 return new (Point$(T))(this.left, this.top); 168 return new (Point$(T))(this[dartx.left], this[dartx.top]);
153 } 169 }
154 get topRight() { 170 get [dartx.topRight]() {
155 return new (Point$(T))(dart.notNull(this.left) + dart.notNull(this.width ), this.top); 171 return new (Point$(T))(dart.notNull(this[dartx.left]) + dart.notNull(thi s[dartx.width]), this[dartx.top]);
156 } 172 }
157 get bottomRight() { 173 get [dartx.bottomRight]() {
158 return new (Point$(T))(dart.notNull(this.left) + dart.notNull(this.width ), dart.notNull(this.top) + dart.notNull(this.height)); 174 return new (Point$(T))(dart.notNull(this[dartx.left]) + dart.notNull(thi s[dartx.width]), dart.notNull(this[dartx.top]) + dart.notNull(this[dartx.height] ));
159 } 175 }
160 get bottomLeft() { 176 get [dartx.bottomLeft]() {
161 return new (Point$(T))(this.left, dart.notNull(this.top) + dart.notNull( this.height)); 177 return new (Point$(T))(this[dartx.left], dart.notNull(this[dartx.top]) + dart.notNull(this[dartx.height]));
162 } 178 }
163 } 179 }
164 dart.setSignature(_RectangleBase, { 180 dart.setSignature(_RectangleBase, {
165 constructors: () => ({_RectangleBase: [_RectangleBase$(T), []]}), 181 constructors: () => ({_RectangleBase: [_RectangleBase$(T), []]}),
166 methods: () => ({ 182 methods: () => ({
167 intersection: [Rectangle$(T), [Rectangle$(T)]], 183 [dartx.intersection]: [Rectangle$(T), [Rectangle$(T)]],
168 intersects: [core.bool, [Rectangle$(core.num)]], 184 [dartx.intersects]: [core.bool, [Rectangle$(core.num)]],
169 boundingBox: [Rectangle$(T), [Rectangle$(T)]], 185 [dartx.boundingBox]: [Rectangle$(T), [Rectangle$(T)]],
170 containsRectangle: [core.bool, [Rectangle$(core.num)]], 186 [dartx.containsRectangle]: [core.bool, [Rectangle$(core.num)]],
171 containsPoint: [core.bool, [Point$(core.num)]] 187 [dartx.containsPoint]: [core.bool, [Point$(core.num)]]
172 }) 188 })
173 }); 189 });
174 return _RectangleBase; 190 return _RectangleBase;
175 }); 191 });
176 let _RectangleBase = _RectangleBase$(); 192 let _RectangleBase = _RectangleBase$();
177 const Rectangle$ = dart.generic(function(T) { 193 const Rectangle$ = dart.generic(function(T) {
194 dart.defineExtensionNames([
195 'left',
196 'top',
197 'width',
198 'height'
199 ]);
178 class Rectangle extends _RectangleBase$(T) { 200 class Rectangle extends _RectangleBase$(T) {
201 get [dartx.left]() {
202 return this.left;
203 }
204 get [dartx.top]() {
205 return this.top;
206 }
207 get [dartx.width]() {
208 return this.width;
209 }
210 get [dartx.height]() {
211 return this.height;
212 }
179 Rectangle(left, top, width, height) { 213 Rectangle(left, top, width, height) {
180 this.left = left; 214 this[dartx.left] = left;
181 this.top = top; 215 this[dartx.top] = top;
182 this.width = dart.notNull(width) < 0 ? -dart.notNull(width) * 0 : width; 216 this[dartx.width] = dart.notNull(width) < 0 ? -dart.notNull(width) * 0 : width;
183 this.height = dart.notNull(height) < 0 ? -dart.notNull(height) * 0 : hei ght; 217 this[dartx.height] = dart.notNull(height) < 0 ? -dart.notNull(height) * 0 : height;
184 super._RectangleBase(); 218 super._RectangleBase();
185 } 219 }
186 static fromPoints(a, b) { 220 static fromPoints(a, b) {
187 let left = min(a.x, b.x); 221 let left = min(a.x, b.x);
188 let width = dart.notNull(max(a.x, b.x)) - dart.notNull(left); 222 let width = dart.notNull(max(a.x, b.x)) - dart.notNull(left);
189 let top = min(a.y, b.y); 223 let top = min(a.y, b.y);
190 let height = dart.notNull(max(a.y, b.y)) - dart.notNull(top); 224 let height = dart.notNull(max(a.y, b.y)) - dart.notNull(top);
191 return new (Rectangle$(T))(left, top, width, height); 225 return new (Rectangle$(T))(left, top, width, height);
192 } 226 }
193 } 227 }
228 dart.virtualField(Rectangle, dartx.left);
229 dart.virtualField(Rectangle, dartx.top);
230 dart.virtualField(Rectangle, dartx.width);
231 dart.virtualField(Rectangle, dartx.height);
194 dart.setSignature(Rectangle, { 232 dart.setSignature(Rectangle, {
195 constructors: () => ({ 233 constructors: () => ({
196 Rectangle: [Rectangle$(T), [T, T, T, T]], 234 Rectangle: [Rectangle$(T), [T, T, T, T]],
197 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]] 235 fromPoints: [Rectangle$(T), [Point$(T), Point$(T)]]
198 }) 236 })
199 }); 237 });
200 return Rectangle; 238 return Rectangle;
201 }); 239 });
202 let Rectangle = Rectangle$(); 240 let Rectangle = Rectangle$();
203 const _width = Symbol('_width'); 241 const _width = Symbol('_width');
(...skipping 25 matching lines...) Expand all
229 get height() { 267 get height() {
230 return this[_height]; 268 return this[_height];
231 } 269 }
232 set height(height) { 270 set height(height) {
233 dart.as(height, T); 271 dart.as(height, T);
234 if (dart.notNull(height) < 0) height = _clampToZero(height); 272 if (dart.notNull(height) < 0) height = _clampToZero(height);
235 this[_height] = height; 273 this[_height] = height;
236 } 274 }
237 } 275 }
238 MutableRectangle[dart.implements] = () => [Rectangle$(T)]; 276 MutableRectangle[dart.implements] = () => [Rectangle$(T)];
277 dart.virtualField(MutableRectangle, 'left');
278 dart.virtualField(MutableRectangle, 'top');
239 dart.setSignature(MutableRectangle, { 279 dart.setSignature(MutableRectangle, {
240 constructors: () => ({ 280 constructors: () => ({
241 MutableRectangle: [MutableRectangle$(T), [T, T, T, T]], 281 MutableRectangle: [MutableRectangle$(T), [T, T, T, T]],
242 fromPoints: [MutableRectangle$(T), [Point$(T), Point$(T)]] 282 fromPoints: [MutableRectangle$(T), [Point$(T), Point$(T)]]
243 }) 283 })
244 }); 284 });
285 dart.defineExtensionMembers(MutableRectangle, ['left', 'top', 'width', 'heig ht']);
245 return MutableRectangle; 286 return MutableRectangle;
246 }); 287 });
247 let MutableRectangle = MutableRectangle$(); 288 let MutableRectangle = MutableRectangle$();
248 function _clampToZero(value) { 289 function _clampToZero(value) {
249 dart.assert(dart.notNull(value) < 0); 290 dart.assert(dart.notNull(value) < 0);
250 return -dart.notNull(value) * 0; 291 return -dart.notNull(value) * 0;
251 } 292 }
252 dart.fn(_clampToZero, core.num, [core.num]); 293 dart.fn(_clampToZero, core.num, [core.num]);
253 const E = 2.718281828459045; 294 const E = 2.718281828459045;
254 const LN10 = 2.302585092994046; 295 const LN10 = 2.302585092994046;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 exports.sin = sin; 543 exports.sin = sin;
503 exports.cos = cos; 544 exports.cos = cos;
504 exports.tan = tan; 545 exports.tan = tan;
505 exports.acos = acos; 546 exports.acos = acos;
506 exports.asin = asin; 547 exports.asin = asin;
507 exports.atan = atan; 548 exports.atan = atan;
508 exports.sqrt = sqrt; 549 exports.sqrt = sqrt;
509 exports.exp = exp; 550 exports.exp = exp;
510 exports.log = log; 551 exports.log = log;
511 }); 552 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/js.js ('k') | lib/runtime/dart/mirrors.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698