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