OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 patch class Simd128Float32 { | |
6 /* patch */ factory Simd128Float32(double x, double y, double z, double w) { | |
7 //return new _Simd128Float32Dart(x, y, z, w); | |
8 return new _Simd128Float32(x, y, z, w); | |
9 } | |
10 /* patch */ factory Simd128Float32.zero() { | |
11 //return new _Simd128Float32Dart.zero(); | |
12 return new _Simd128Float32.zero(); | |
13 } | |
14 } | |
15 | |
16 patch class Simd128Mask { | |
17 /* patch */ factory Simd128Mask(int x, int y, int z, int w) { | |
18 //return new _Simd128MaskDart(x, y, z, w); | |
19 return new _Simd128Mask(x, y, z, w); | |
20 } | |
21 /* patch */ factory Simd128Mask.bool(bool x, bool y, bool z, bool w) { | |
22 //return new _Simd128MaskDart.bool(x, y, z, w); | |
23 return new _Simd128Mask.bool(x, y, z, w); | |
24 } | |
25 } | |
26 | |
27 | |
28 patch class Simd128Float32List { | |
29 /* patch */ factory Simd128Float32List(int length) { | |
30 return new _Simd128Float32Array(length); | |
31 } | |
32 | |
33 /* patch */ factory Simd128Float32List.transferable(int length) { | |
34 return _newTransferable(length); | |
35 } | |
36 | |
37 /* patch */ factory Simd128Float32List.view(ByteArray array, | |
38 [int start = 0, int length]) { | |
39 return new _Simd128Float32ArrayView(array, start, length); | |
40 } | |
41 | |
42 static _ExternalSimd128Float32Array _newTransferable(int length) | |
43 native "Simd128Float32List_newTransferable"; | |
44 } | |
45 | |
46 | |
47 // Expose native square root. | |
48 double _sqrt(double x) native "Math_sqrt"; | |
49 class _Simd128Float32Dart implements Simd128Float32 { | |
50 final Float32List storage = new Float32List(4); | |
sra1
2013/02/19 01:13:45
Should storage be public?
| |
51 _Simd128Float32Dart.empty() { | |
52 } | |
53 _Simd128Float32Dart.copy(Float32List other) { | |
54 storage[0] = other.storage[0]; | |
55 storage[1] = other.storage[1]; | |
56 storage[2] = other.storage[2]; | |
57 storage[3] = other.storage[3]; | |
58 } | |
59 factory _Simd128Float32Dart(double x, double y, double z, double w) { | |
60 var instance = new _Simd128Float32Dart.empty(); | |
61 instance.storage[0] = x; | |
62 instance.storage[1] = y; | |
63 instance.storage[2] = z; | |
64 instance.storage[3] = w; | |
65 return instance; | |
66 } | |
67 factory _Simd128Float32Dart.zero() { | |
68 var instance = new _Simd128Float32Dart.empty(); | |
69 return instance; | |
70 } | |
71 Simd128Float32 operator+(Simd128Float32 other) { | |
72 var instance = new _Simd128Float32Dart.copy(this); | |
73 instance.storage[0] += other.storage[0]; | |
74 instance.storage[1] += other.storage[1]; | |
75 instance.storage[2] += other.storage[2]; | |
76 instance.storage[3] += other.storage[3]; | |
77 return instance; | |
78 } | |
79 Simd128Float32 operator-() { | |
80 var instance = new _Simd128Float32Dart.copy(this); | |
81 instance.storage[0] *= -1.0; | |
82 instance.storage[1] *= -1.0; | |
83 instance.storage[2] *= -1.0; | |
84 instance.storage[3] *= -1.0; | |
85 return instance; | |
86 } | |
87 Simd128Float32 operator-(Simd128Float32 other) { | |
88 var instance = new _Simd128Float32Dart.copy(this); | |
89 instance.storage[0] -= other.storage[0]; | |
90 instance.storage[1] -= other.storage[1]; | |
91 instance.storage[2] -= other.storage[2]; | |
92 instance.storage[3] -= other.storage[3]; | |
93 return instance; | |
94 } | |
95 Simd128Float32 operator*(Simd128Float32 other) { | |
96 var instance = new _Simd128Float32Dart.copy(this); | |
97 instance.storage[0] *= other.storage[0]; | |
98 instance.storage[1] *= other.storage[1]; | |
99 instance.storage[2] *= other.storage[2]; | |
100 instance.storage[3] *= other.storage[3]; | |
101 return instance; | |
102 } | |
103 Simd128Float32 operator/(Simd128Float32 other) { | |
104 var instance = new _Simd128Float32Dart.copy(this); | |
105 instance.storage[0] /= other.storage[0]; | |
106 instance.storage[1] /= other.storage[1]; | |
107 instance.storage[2] /= other.storage[2]; | |
108 instance.storage[3] /= other.storage[3]; | |
109 return instance; | |
110 } | |
111 Simd128Mask operator<(Simd128Float32 other) { | |
sra1
2013/02/19 01:13:45
I'm a little nervous about a comparison operations
| |
112 bool _x = storage[0] < other.storage[0]; | |
113 bool _y = storage[1] < other.storage[1]; | |
114 bool _z = storage[2] < other.storage[2]; | |
115 bool _w = storage[3] < other.storage[3]; | |
116 return new Simd128Mask.bool(_x, _y, _z, _w); | |
117 } | |
118 Simd128Mask operator<=(Simd128Float32 other) { | |
119 bool _x = storage[0] <= other.storage[0]; | |
120 bool _y = storage[1] <= other.storage[1]; | |
121 bool _z = storage[2] <= other.storage[2]; | |
122 bool _w = storage[3] <= other.storage[3]; | |
123 return new Simd128Mask.bool(_x, _y, _z, _w); | |
124 } | |
125 Simd128Mask operator>(Simd128Float32 other) { | |
126 bool _x = storage[0] > other.storage[0]; | |
127 bool _y = storage[1] > other.storage[1]; | |
128 bool _z = storage[2] > other.storage[2]; | |
129 bool _w = storage[3] > other.storage[3]; | |
130 return new Simd128Mask.bool(_x, _y, _z, _w); | |
131 } | |
132 Simd128Mask operator>=(Simd128Float32 other) { | |
133 bool _x = storage[0] >= other.storage[0]; | |
134 bool _y = storage[1] >= other.storage[1]; | |
135 bool _z = storage[2] >= other.storage[2]; | |
136 bool _w = storage[3] >= other.storage[3]; | |
137 return new Simd128Mask.bool(_x, _y, _z, _w); | |
138 } | |
139 Simd128Mask operator==(Simd128Float32 other) { | |
140 bool _x = storage[0] == other.storage[0]; | |
141 bool _y = storage[1] == other.storage[1]; | |
142 bool _z = storage[2] == other.storage[2]; | |
143 bool _w = storage[3] == other.storage[3]; | |
144 return new Simd128Mask.bool(_x, _y, _z, _w); | |
145 } | |
146 Simd128Float32 scale(double s) { | |
147 var instance = new _Simd128Float32Dart.copy(this); | |
148 instance.storage[0] *= s; | |
149 instance.storage[1] *= s; | |
150 instance.storage[2] *= s; | |
151 instance.storage[3] *= s; | |
152 return instance; | |
153 } | |
154 Simd128Float32 abs() { | |
155 var instance = new _Simd128Float32Dart.copy(this); | |
156 instance.storage[0] = instance.storage[0].abs(); | |
157 instance.storage[1] = instance.storage[1].abs(); | |
158 instance.storage[2] = instance.storage[2].abs(); | |
159 instance.storage[3] = instance.storage[3].abs(); | |
160 return instance; | |
161 } | |
162 Simd128Float32 clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit) { | |
163 var instance = new _Simd128Float32Dart.copy(this); | |
164 if (instance.storage[0] > upperLimit.storage[0]) { | |
165 instance.storage[0] = upperLimit.storage[0]; | |
166 } | |
167 if (instance.storage[1] > upperLimit.storage[1]) { | |
168 instance.storage[1] = upperLimit.storage[1]; | |
169 } | |
170 if (instance.storage[2] > upperLimit.storage[2]) { | |
171 instance.storage[2] = upperLimit.storage[2]; | |
172 } | |
173 if (instance.storage[3] > upperLimit.storage[3]) { | |
174 instance.storage[3] = upperLimit.storage[3]; | |
175 } | |
176 if (instance.storage[0] < lowerLimit.storage[0]) { | |
177 instance.storage[0] = lowerLimit.storage[0]; | |
178 } | |
179 if (instance.storage[1] < lowerLimit.storage[1]) { | |
180 instance.storage[1] = lowerLimit.storage[1]; | |
181 } | |
182 if (instance.storage[2] < lowerLimit.storage[2]) { | |
183 instance.storage[2] = lowerLimit.storage[2]; | |
184 } | |
185 if (instance.storage[3] < lowerLimit.storage[3]) { | |
186 instance.storage[3] = lowerLimit.storage[3]; | |
187 } | |
188 return instance; | |
189 } | |
190 double get x => storage[0]; | |
191 double get y => storage[1]; | |
192 double get z => storage[2]; | |
193 double get w => storage[3]; | |
194 Simd128Float32 get xxxx { | |
195 var instance = new _Simd128Float32Dart.copy(this); | |
196 instance.storage[1] = instance.storage[0]; | |
197 instance.storage[2] = instance.storage[0]; | |
198 instance.storage[3] = instance.storage[0]; | |
199 return instance; | |
200 } | |
201 Simd128Float32 get yyyy { | |
202 var instance = new _Simd128Float32Dart.copy(this); | |
203 instance.storage[0] = instance.storage[1]; | |
204 instance.storage[2] = instance.storage[1]; | |
205 instance.storage[3] = instance.storage[1]; | |
206 return instance; | |
207 } | |
208 Simd128Float32 get zzzz { | |
209 var instance = new _Simd128Float32Dart.copy(this); | |
210 instance.storage[0] = instance.storage[2]; | |
211 instance.storage[1] = instance.storage[2]; | |
212 instance.storage[3] = instance.storage[2]; | |
213 return instance; | |
214 } | |
215 Simd128Float32 get wwww { | |
216 var instance = new _Simd128Float32Dart.copy(this); | |
217 instance.storage[0] = instance.storage[3]; | |
218 instance.storage[1] = instance.storage[3]; | |
219 instance.storage[2] = instance.storage[3]; | |
220 return instance; | |
221 } | |
222 Simd128Float32 setX(double x) { | |
223 var instance = new _Simd128Float32Dart.copy(this); | |
224 instance.storage[0] = x; | |
225 return instance; | |
226 } | |
227 Simd128Float32 setY(double y) { | |
228 var instance = new _Simd128Float32Dart.copy(this); | |
229 instance.storage[1] = y; | |
230 return instance; | |
231 } | |
232 Simd128Float32 setZ(double z) { | |
233 var instance = new _Simd128Float32Dart.copy(this); | |
234 instance.storage[2] = z; | |
235 return instance; | |
236 } | |
237 Simd128Float32 setW(double w) { | |
238 var instance = new _Simd128Float32Dart.copy(this); | |
239 instance.storage[3] = w; | |
240 return instance; | |
241 } | |
242 Simd128Float32 min(Simd128 other) { | |
243 var instance = new _Simd128Float32Dart.copy(this); | |
244 if (instance.storage[0] > other.storage[0]) { | |
245 instance.storage[0] = other.storage[0]; | |
246 } | |
247 if (instance.storage[1] > other.storage[1]) { | |
248 instance.storage[1] = other.storage[1]; | |
249 } | |
250 if (instance.storage[2] > other.storage[2]) { | |
251 instance.storage[2] = other.storage[2]; | |
252 } | |
253 if (instance.storage[3] > other.storage[3]) { | |
254 instance.storage[3] = other.storage[3]; | |
255 } | |
256 return instance; | |
257 } | |
258 Simd128Float32 max(Simd128 other) { | |
259 var instance = new _Simd128Float32Dart.copy(this); | |
260 if (instance.storage[0] < other.storage[0]) { | |
261 instance.storage[0] = other.storage[0]; | |
262 } | |
263 if (instance.storage[1] < other.storage[1]) { | |
264 instance.storage[1] = other.storage[1]; | |
265 } | |
266 if (instance.storage[2] < other.storage[2]) { | |
267 instance.storage[2] = other.storage[2]; | |
268 } | |
269 if (instance.storage[3] < other.storage[3]) { | |
270 instance.storage[3] = other.storage[3]; | |
271 } | |
272 return instance; | |
273 } | |
274 Simd128Float32 sqrt() { | |
275 var instance = new _Simd128Float32Dart.copy(this); | |
276 instance.storage[0] = _sqrt(instance.storage[0]); | |
277 instance.storage[1] = _sqrt(instance.storage[1]); | |
278 instance.storage[2] = _sqrt(instance.storage[2]); | |
279 instance.storage[3] = _sqrt(instance.storage[3]); | |
280 return instance; | |
281 } | |
282 Simd128Float32 reciprocal() { | |
283 var instance = new _Simd128Float32Dart.copy(this); | |
284 instance.storage[0] = (1.0 / instance.storage[0]); | |
285 instance.storage[1] = (1.0 / instance.storage[1]); | |
286 instance.storage[2] = (1.0 / instance.storage[2]); | |
287 instance.storage[3] = (1.0 / instance.storage[3]); | |
288 return instance; | |
289 } | |
290 Simd128Float32 reciprocalSqrt() { | |
291 var instance = new _Simd128Float32Dart.copy(this); | |
292 instance.storage[0] = _sqrt(1.0 / instance.storage[0]); | |
293 instance.storage[1] = _sqrt(1.0 / instance.storage[1]); | |
294 instance.storage[2] = _sqrt(1.0 / instance.storage[2]); | |
295 instance.storage[3] = _sqrt(1.0 / instance.storage[3]); | |
296 return instance; | |
297 } | |
298 Simd128Mask toSimd128Mask() { | |
299 Uint32List view = new Uint32List.view(storage.asByteArray()); | |
300 return new Simd128Mask(view[0], view[1], view[2], view[3]); | |
301 } | |
302 } | |
303 | |
304 class _Simd128MaskDart implements Simd128Mask { | |
305 final Uint32List storage = new Uint32List(4); | |
306 _Simd128MaskDart.empty() { | |
307 } | |
308 _Simd128MaskDart.copy(_Simd128MaskDart other) { | |
309 storage[0] = other.storage[0]; | |
310 storage[1] = other.storage[1]; | |
311 storage[2] = other.storage[2]; | |
312 storage[3] = other.storage[3]; | |
313 } | |
314 factory _Simd128MaskDart(int x, int y, int z, int w) { | |
315 var instance = new _Simd128MaskDart.empty(); | |
316 instance.storage[0] = x; | |
317 instance.storage[1] = y; | |
318 instance.storage[2] = z; | |
319 instance.storage[3] = w; | |
320 return instance; | |
321 } | |
322 factory _Simd128MaskDart.bool(bool x, bool y, bool z, bool w) { | |
323 var instance = new _Simd128MaskDart.empty(); | |
324 instance.storage[0] = x ? 0xFFFFFFFF : 0x0; | |
325 instance.storage[1] = y ? 0xFFFFFFFF : 0x0; | |
326 instance.storage[2] = z ? 0xFFFFFFFF : 0x0; | |
327 instance.storage[3] = w ? 0xFFFFFFFF : 0x0; | |
328 return instance; | |
329 } | |
330 Simd128Mask operator|(Simd128Mask other) { | |
331 var instance = new _Simd128MaskDart.copy(this); | |
332 instance.storage[0] |= other.storage[0]; | |
333 instance.storage[1] |= other.storage[1]; | |
334 instance.storage[2] |= other.storage[2]; | |
335 instance.storage[3] |= other.storage[3]; | |
336 return instance; | |
337 } | |
338 Simd128Mask operator&(Simd128Mask other) { | |
339 var instance = new _Simd128MaskDart.copy(this); | |
340 instance.storage[0] &= other.storage[0]; | |
341 instance.storage[1] &= other.storage[1]; | |
342 instance.storage[2] &= other.storage[2]; | |
343 instance.storage[3] &= other.storage[3]; | |
344 return instance; | |
345 } | |
346 Simd128Mask operator^(Simd128Mask other) { | |
347 var instance = new _Simd128MaskDart.copy(this); | |
348 instance.storage[0] ^= other.storage[0]; | |
349 instance.storage[1] ^= other.storage[1]; | |
350 instance.storage[2] ^= other.storage[2]; | |
351 instance.storage[3] ^= other.storage[3]; | |
352 return instance; | |
353 } | |
354 int get x => storage[0]; | |
355 int get y => storage[1]; | |
356 int get z => storage[2]; | |
357 int get w => storage[3]; | |
358 Simd128Mask setX(int x) { | |
359 var instance = new _Simd128MaskDart.copy(this); | |
360 instance.storage[0] = x & 0xFFFFFFFF; | |
361 return instance; | |
362 } | |
363 Simd128Mask setY(int y) { | |
364 var instance = new _Simd128MaskDart.copy(this); | |
365 instance.storage[1] = y & 0xFFFFFFFF; | |
366 return instance; | |
367 } | |
368 Simd128Mask setZ(int z) { | |
369 var instance = new _Simd128MaskDart.copy(this); | |
370 instance.storage[2] = z & 0xFFFFFFFF; | |
371 return instance; | |
372 } | |
373 Simd128Mask setW(int w) { | |
374 var instance = new _Simd128MaskDart.copy(this); | |
375 instance.storage[3] = w & 0xFFFFFFFF; | |
376 return instance; | |
377 } | |
378 bool get flagX => storage[0] != 0x0; | |
379 bool get flagY => storage[1] != 0x0; | |
380 bool get flagZ => storage[2] != 0x0; | |
381 bool get flagW => storage[3] != 0x0; | |
382 Simd128Mask setFlagX(bool x) { | |
383 var instance = new _Simd128MaskDart.copy(this); | |
384 instance.storage[0] = x ? 0xFFFFFFFF : 0x0; | |
385 return instance; | |
386 } | |
387 Simd128Mask setFlagY(bool y) { | |
388 var instance = new _Simd128MaskDart.copy(this); | |
389 instance.storage[1] = y ? 0xFFFFFFFF : 0x0; | |
390 return instance; | |
391 } | |
392 Simd128Mask setFlagZ(bool z) { | |
393 var instance = new _Simd128MaskDart.copy(this); | |
394 instance.storage[2] = z ? 0xFFFFFFFF : 0x0; | |
395 return instance; | |
396 } | |
397 Simd128Mask setFlagW(bool w) { | |
398 var instance = new _Simd128MaskDart.copy(this); | |
399 instance.storage[3] = w ? 0xFFFFFFFF : 0x0; | |
400 return instance; | |
401 } | |
402 Simd128Float32 select(Simd128Float32 trueValue, Simd128Float32 falseValue) { | |
403 Simd128Mask trueMask = trueValue.toSimd128Mask(); | |
sra1
2013/02/19 01:13:45
These are not so much masks as raw 'bits' or 'byte
| |
404 Simd128Mask falseMask = falseValue.toSimd128Mask(); | |
405 var instance = new _Simd128MaskDart.empty(); | |
406 instance.storage[0] = (storage[0] & trueMask.storage[0]); | |
407 instance.storage[1] = (storage[1] & trueMask.storage[1]); | |
408 instance.storage[2] = (storage[2] & trueMask.storage[2]); | |
409 instance.storage[3] = (storage[3] & trueMask.storage[3]); | |
410 instance.storage[0] |= (~storage[0] & falseMask.storage[0]); | |
411 instance.storage[1] |= (~storage[1] & falseMask.storage[1]); | |
412 instance.storage[2] |= (~storage[2] & falseMask.storage[2]); | |
413 instance.storage[3] |= (~storage[3] & falseMask.storage[3]); | |
414 return instance.toSimd128Float32(); | |
415 } | |
416 Simd128Float32 toSimd128Float32() { | |
417 Float32List view = new Float32List.view(storage.asByteArray()); | |
418 return new Simd128Float32(view[0], view[1], view[2], view[3]); | |
419 } | |
420 } | |
421 | |
422 class _Simd128Float32 implements Simd128Float32 { | |
423 factory _Simd128Float32(double x, double y, double z, double w) | |
424 native "Simd128Float32_fromDoubles"; | |
425 factory _Simd128Float32.zero() native "Simd128Float32_zero"; | |
426 Simd128Float32 operator+(Simd128Float32 other) { | |
427 return _add(other); | |
428 } | |
429 Simd128Float32 _add(Simd128Float32 other) native "Simd128Float32_add"; | |
430 Simd128Float32 operator-() { | |
431 return _negate(); | |
432 } | |
433 Simd128Float32 _negate() native "Simd128Float32_negate"; | |
434 Simd128Float32 operator-(Simd128Float32 other) { | |
435 return _sub(other); | |
436 } | |
437 Simd128Float32 _sub(Simd128Float32 other) native "Simd128Float32_sub"; | |
438 Simd128Float32 operator*(Simd128Float32 other) { | |
439 return _mul(other); | |
440 } | |
441 Simd128Float32 _mul(Simd128Float32 other) native "Simd128Float32_mul"; | |
442 Simd128Float32 operator/(Simd128Float32 other) { | |
443 return _div(other); | |
444 } | |
445 Simd128Float32 _div(Simd128Float32 other) native "Simd128Float32_div"; | |
446 Simd128Mask operator<(Simd128Float32 other) { | |
447 return _cmplt(other); | |
448 } | |
449 Simd128Mask _cmplt(Simd128Float32 other) native "Simd128Float32_cmplt"; | |
450 Simd128Mask operator<=(Simd128Float32 other) { | |
451 return _cmplte(other); | |
452 } | |
453 Simd128Mask _cmplte(Simd128Float32 other) native "Simd128Float32_cmplte"; | |
454 Simd128Mask operator>(Simd128Float32 other) { | |
455 return _cmpgt(other); | |
456 } | |
457 Simd128Mask _cmpgt(Simd128Float32 other) native "Simd128Float32_cmpgt"; | |
458 Simd128Mask operator>=(Simd128Float32 other) { | |
459 return _cmpgte(other); | |
460 } | |
461 Simd128Mask _cmpgte(Simd128Float32 other) native "Simd128Float32_cmpgte"; | |
462 Simd128Mask operator==(Simd128Float32 other) { | |
463 return _cmpequal(other); | |
464 } | |
465 Simd128Mask _cmpequal(Simd128Float32 other) native "Simd128Float32_cmpequal"; | |
466 Simd128Float32 scale(double s) { | |
467 return _scale(s); | |
468 } | |
469 Simd128Float32 _scale(double s) native "Simd128Float32_scale"; | |
470 Simd128Float32 abs() { | |
471 return _abs(); | |
472 } | |
473 Simd128Float32 _abs() native "Simd128Float32_abs"; | |
474 Simd128Float32 clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit) { | |
475 return _clamp(lowerLimit, upperLimit); | |
476 } | |
477 Simd128Float32 _clamp(Simd128Float32 lowerLimit, Simd128Float32 upperLimit) | |
478 native "Simd128Float32_clamp"; | |
479 double get x native "Simd128Float32_getX"; | |
480 double get y native "Simd128Float32_getY"; | |
481 double get z native "Simd128Float32_getZ"; | |
482 double get w native "Simd128Float32_getW"; | |
483 Simd128Float32 get xxxx native "Simd128Float32_getXXXX"; | |
484 Simd128Float32 get yyyy native "Simd128Float32_getYYYY"; | |
485 Simd128Float32 get zzzz native "Simd128Float32_getZZZZ"; | |
486 Simd128Float32 get wwww native "Simd128Float32_getWWWW"; | |
487 Simd128Float32 setX(double x) native "Simd128Float32_setX"; | |
488 Simd128Float32 setY(double y) native "Simd128Float32_setY"; | |
489 Simd128Float32 setZ(double z) native "Simd128Float32_setZ"; | |
490 Simd128Float32 setW(double w) native "Simd128Float32_setW"; | |
491 Simd128Float32 min(Simd128 other) { | |
492 return _min(other); | |
493 } | |
494 Simd128Float32 _min(Simd128Float32 other) native "Simd128Float32_min"; | |
495 Simd128Float32 max(Simd128 other) { | |
496 return _max(other); | |
497 } | |
498 Simd128Float32 _max(Simd128Float32 other) native "Simd128Float32_max"; | |
499 Simd128Float32 sqrt() { | |
500 return _sqrt(); | |
501 } | |
502 Simd128Float32 _sqrt() native "Simd128Float32_sqrt"; | |
503 Simd128Float32 reciprocal() { | |
504 return _reciprocal(); | |
505 } | |
506 Simd128Float32 _reciprocal() native "Simd128Float32_reciprocal"; | |
507 Simd128Float32 reciprocalSqrt() { | |
508 return _reciprocalSqrt(); | |
509 } | |
510 Simd128Float32 _reciprocalSqrt() native "Simd128Float32_reciprocalSqrt"; | |
511 Simd128Mask toSimd128Mask() { | |
512 return _toSimd128Mask(); | |
513 } | |
514 Simd128Mask _toSimd128Mask() native "Simd128Float32_toSimd128Mask"; | |
515 } | |
516 | |
517 class _Simd128Mask implements Simd128Mask { | |
518 factory _Simd128Mask(int x, int y, int z, int w) | |
519 native "Simd128Mask_fromInts"; | |
520 factory _Simd128Mask.bool(bool x, bool y, bool z, bool w) | |
521 native "Simd128Mask_fromBools"; | |
522 Simd128Mask operator|(Simd128Mask other) { | |
523 return _or(other); | |
524 } | |
525 Simd128Mask _or(Simd128Mask other) native "Simd128Mask_or"; | |
526 Simd128Mask operator&(Simd128Mask other) { | |
527 return _and(other); | |
528 } | |
529 Simd128Mask _and(Simd128Mask other) native "Simd128Mask_and"; | |
530 Simd128Mask operator^(Simd128Mask other) { | |
531 return _xor(other); | |
532 } | |
533 Simd128Mask _xor(Simd128Mask other) native "Simd128Mask_xor"; | |
534 int get x native "Simd128Mask_getX"; | |
535 int get y native "Simd128Mask_getY"; | |
536 int get z native "Simd128Mask_getZ"; | |
537 int get w native "Simd128Mask_getW"; | |
538 Simd128Mask setX(int x) native "Simd128Mask_setX"; | |
539 Simd128Mask setY(int y) native "Simd128Mask_setY"; | |
540 Simd128Mask setZ(int z) native "Simd128Mask_setZ"; | |
541 Simd128Mask setW(int w) native "Simd128Mask_setW"; | |
542 bool get flagX native "Simd128Mask_getFlagX"; | |
543 bool get flagY native "Simd128Mask_getFlagY"; | |
544 bool get flagZ native "Simd128Mask_getFlagZ"; | |
545 bool get flagW native "Simd128Mask_getFlagW"; | |
546 Simd128Mask setFlagX(bool x) native "Simd128Mask_setFlagX"; | |
547 Simd128Mask setFlagY(bool y) native "Simd128Mask_setFlagY"; | |
548 Simd128Mask setFlagZ(bool z) native "Simd128Mask_setFlagZ"; | |
549 Simd128Mask setFlagW(bool w) native "Simd128Mask_setFlagW"; | |
550 Simd128Float32 select(Simd128Float32 trueValue, Simd128Float32 falseValue) { | |
551 return _select(trueValue, falseValue); | |
552 } | |
553 Simd128Float32 _select(Simd128Float32 trueValue, Simd128Float32 falseValue) | |
554 native "Simd128Mask_select"; | |
555 Simd128Float32 toSimd128Float32() { | |
556 return _toSimd128Float32(); | |
557 } | |
558 Simd128Float32 _toSimd128Float32() native "Simd128Mask_toSimd128Float32"; | |
559 } | |
560 | |
561 | |
562 class _Simd128Float32Array extends _ByteArrayBase implements Simd128Float32List { | |
563 factory _Simd128Float32Array(int length) { | |
564 return _new(length); | |
565 } | |
566 factory _Simd128Float32Array.view(ByteArray array, | |
567 [int start = 0, int length]) { | |
568 if (length == null) { | |
569 length = (array.lengthInBytes() - start) ~/ _BYTES_PER_ELEMENT; | |
570 } | |
571 return new _Simd128Float32ArrayView(array, start, length); | |
572 } | |
573 Simd128Float32 operator[](int index) { | |
574 return _getIndexed(index); | |
575 } | |
576 int operator[]=(int index, Simd128Float32 value) { | |
577 _setIndexed(index, value); | |
578 } | |
579 Iterator<Simd128Float32> get iterator { | |
580 return new _ByteArrayIterator<Simd128Float32>(this); | |
581 } | |
582 List<Simd128Float32> getRange(int start, int length) { | |
583 _rangeCheck(this.length, start, length); | |
584 List<Simd128Float32> result = _new(length); | |
585 result.setRange(0, length, this, start); | |
586 return result; | |
587 } | |
588 void setRange(int start, int length, List<Simd128Float32> from, | |
589 [int startFrom = 0]) { | |
590 if (from is _Simd128Float32Array) { | |
591 _setRange(start * _BYTES_PER_ELEMENT, | |
592 length * _BYTES_PER_ELEMENT, | |
593 from, | |
594 startFrom * _BYTES_PER_ELEMENT); | |
595 } else { | |
596 Arrays.copy(from, startFrom, this, start, length); | |
597 } | |
598 } | |
599 String toString() { | |
600 return Collections.collectionToString(this); | |
601 } | |
602 int bytesPerElement() { | |
603 return _BYTES_PER_ELEMENT; | |
604 } | |
605 int lengthInBytes() { | |
606 return _length() * _BYTES_PER_ELEMENT; | |
607 } | |
608 static const int _BYTES_PER_ELEMENT = 16; | |
609 static _Simd128Float32Array _new(int length) native "Simd128Float32Array_new"; | |
610 Simd128Float32 _getIndexed(int index) native "Simd128Float32Array_getIndexed"; | |
611 int _setIndexed(int index, Simd128Float32 value) | |
612 native "Simd128Float32Array_setIndexed"; | |
613 } | |
614 | |
615 | |
616 class _Simd128Float32ArrayView extends _ByteArrayViewBase | |
617 implements Simd128Float32List { | |
618 _Simd128Float32ArrayView(ByteArray array, | |
619 [int offsetInBytes = 0, int _length]) | |
620 : super(array, _requireInteger(offsetInBytes), | |
621 _requireIntegerOrNull( | |
622 _length, | |
623 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT))) { | |
624 _rangeCheck(array.lengthInBytes(), _offset, length * _BYTES_PER_ELEMENT); | |
625 } | |
626 | |
627 Simd128Float32 operator[](int index) { | |
628 if (index < 0 || index >= length) { | |
629 String message = "$index must be in the range [0..$length)"; | |
630 throw new RangeError(message); | |
631 } | |
632 return _array.getSimd128Float32(_offset + (index * _BYTES_PER_ELEMENT)); | |
633 } | |
634 | |
635 void operator[]=(int index, Simd128Float32 value) { | |
636 if (index < 0 || index >= length) { | |
637 String message = "$index must be in the range [0..$length)"; | |
638 throw new RangeError(message); | |
639 } | |
640 _array.setSimd128Float32(_offset + (index * _BYTES_PER_ELEMENT), value); | |
641 } | |
642 | |
643 Iterator<Simd128Float32> get iterator { | |
644 return new _ByteArrayIterator<Simd128Float32>(this); | |
645 } | |
646 | |
647 List<Simd128Float32> getRange(int start, int length) { | |
648 _rangeCheck(this.length, start, length); | |
649 List<Simd128Float32> result = new Float32List(length); | |
650 result.setRange(0, length, this, start); | |
651 return result; | |
652 } | |
653 | |
654 void setRange(int start, int length, List<Simd128Float32> from, | |
655 [int startFrom = 0]) { | |
656 Arrays.copy(from, startFrom, this, start, length); | |
657 } | |
658 | |
659 String toString() { | |
660 return Collections.collectionToString(this); | |
661 } | |
662 | |
663 int bytesPerElement() { | |
664 return _BYTES_PER_ELEMENT; | |
665 } | |
666 | |
667 int lengthInBytes() { | |
668 return length * _BYTES_PER_ELEMENT; | |
669 } | |
670 | |
671 ByteArray asByteArray([int start = 0, int length]) { | |
672 if (length == null) { | |
673 length = this.lengthInBytes(); | |
674 } | |
675 _rangeCheck(this.length, start, length); | |
676 return _array.subByteArray(_offset + start, length); | |
677 } | |
678 | |
679 static const int _BYTES_PER_ELEMENT = 16; | |
680 } | |
681 | |
682 | |
683 class _ExternalSimd128Float32Array extends _ByteArrayBase | |
684 implements Simd128Float32List { | |
685 Simd128Float32 operator[](int index) { | |
686 return _getIndexed(index); | |
687 } | |
688 | |
689 int operator[]=(int index, Simd128Float32 value) { | |
690 _setIndexed(index, value); | |
691 } | |
692 | |
693 Iterator<Simd128Float32> get iterator { | |
694 return new _ByteArrayIterator<Simd128Float32>(this); | |
695 } | |
696 | |
697 List<Simd128Float32> getRange(int start, int length) { | |
698 _rangeCheck(this.length, start, length); | |
699 List<Simd128Float32> result = new Simd128Float32List(length); | |
700 result.setRange(0, length, this, start); | |
701 return result; | |
702 } | |
703 | |
704 void setRange(int start, int length, List<Simd128Float32> from, | |
705 [int startFrom = 0]) { | |
706 if (from is _ExternalSimd128Float32Array) { | |
707 _setRange(start * _BYTES_PER_ELEMENT, | |
708 length * _BYTES_PER_ELEMENT, | |
709 from, | |
710 startFrom * _BYTES_PER_ELEMENT); | |
711 } else { | |
712 Arrays.copy(from, startFrom, this, start, length); | |
713 } | |
714 } | |
715 | |
716 String toString() { | |
717 return Collections.collectionToString(this); | |
718 } | |
719 | |
720 int bytesPerElement() { | |
721 return _BYTES_PER_ELEMENT; | |
722 } | |
723 | |
724 int lengthInBytes() { | |
725 return _length() * _BYTES_PER_ELEMENT; | |
726 } | |
727 | |
728 static const int _BYTES_PER_ELEMENT = 16; | |
729 | |
730 Simd128Float32 _getIndexed(int index) | |
731 native "ExternalSimd128Float32Array_getIndexed"; | |
732 int _setIndexed(int index, Simd128Float32 value) | |
733 native "ExternalSimd128Float32Array_setIndexed"; | |
734 } | |
OLD | NEW |