webruby 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/config.rb +4 -9
  3. data/lib/webruby/rake/files.rake +2 -2
  4. data/modules/emscripten/AUTHORS +9 -1
  5. data/modules/emscripten/CONTRIBUTING.markdown +5 -0
  6. data/modules/emscripten/ChangeLog +435 -0
  7. data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
  8. data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
  9. data/modules/emscripten/em++ +0 -2
  10. data/modules/emscripten/emcc +92 -32
  11. data/modules/emscripten/emlink.py +16 -13
  12. data/modules/emscripten/emmake +1 -1
  13. data/modules/emscripten/emrun +918 -0
  14. data/modules/emscripten/emrun.bat +2 -0
  15. data/modules/emscripten/emscripten.py +545 -20
  16. data/modules/emscripten/src/analyzer.js +6 -1
  17. data/modules/emscripten/src/compiler.js +25 -16
  18. data/modules/emscripten/src/emrun_postjs.js +20 -0
  19. data/modules/emscripten/{tests → src}/hello_world.js +0 -0
  20. data/modules/emscripten/src/intertyper.js +45 -16
  21. data/modules/emscripten/src/jsifier.js +78 -48
  22. data/modules/emscripten/src/library.js +381 -96
  23. data/modules/emscripten/src/library_browser.js +50 -53
  24. data/modules/emscripten/src/library_egl.js +66 -24
  25. data/modules/emscripten/src/library_fs.js +122 -90
  26. data/modules/emscripten/src/library_gl.js +739 -353
  27. data/modules/emscripten/src/library_glfw.js +9 -3
  28. data/modules/emscripten/src/library_glut.js +10 -5
  29. data/modules/emscripten/src/library_idbfs.js +14 -14
  30. data/modules/emscripten/src/library_memfs.js +65 -41
  31. data/modules/emscripten/src/library_nodefs.js +61 -9
  32. data/modules/emscripten/src/library_openal.js +4 -4
  33. data/modules/emscripten/src/library_path.js +9 -13
  34. data/modules/emscripten/src/library_sdl.js +301 -64
  35. data/modules/emscripten/src/library_sockfs.js +7 -5
  36. data/modules/emscripten/src/modules.js +62 -22
  37. data/modules/emscripten/src/parseTools.js +135 -102
  38. data/modules/emscripten/src/postamble.js +3 -4
  39. data/modules/emscripten/src/preamble.js +49 -29
  40. data/modules/emscripten/src/proxyClient.js +1 -1
  41. data/modules/emscripten/src/proxyWorker.js +10 -10
  42. data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
  43. data/modules/emscripten/src/runtime.js +32 -8
  44. data/modules/emscripten/src/settings.js +25 -8
  45. data/modules/emscripten/src/shell.html +6 -3
  46. data/modules/emscripten/src/shell.js +13 -11
  47. data/modules/emscripten/src/simd.js +602 -432
  48. data/modules/emscripten/src/struct_info.json +22 -2
  49. data/modules/emscripten/src/utility.js +32 -17
  50. data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
  51. data/modules/emscripten/system/include/compat/ctype.h +17 -0
  52. data/modules/emscripten/system/include/compat/wchar.h +23 -0
  53. data/modules/emscripten/system/include/compat/wctype.h +23 -0
  54. data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
  55. data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
  56. data/modules/emscripten/system/include/emscripten/vector.h +29 -1
  57. data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
  58. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
  59. data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
  60. data/modules/emscripten/system/include/libcxx/__config +95 -17
  61. data/modules/emscripten/system/include/libcxx/__debug +25 -4
  62. data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
  63. data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
  64. data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
  65. data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
  66. data/modules/emscripten/system/include/libcxx/__locale +21 -19
  67. data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
  68. data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
  69. data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
  70. data/modules/emscripten/system/include/libcxx/__tree +35 -26
  71. data/modules/emscripten/system/include/libcxx/__tuple +15 -15
  72. data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
  73. data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
  74. data/modules/emscripten/system/include/libcxx/algorithm +121 -110
  75. data/modules/emscripten/system/include/libcxx/array +15 -15
  76. data/modules/emscripten/system/include/libcxx/bitset +4 -4
  77. data/modules/emscripten/system/include/libcxx/chrono +51 -17
  78. data/modules/emscripten/system/include/libcxx/cmath +25 -23
  79. data/modules/emscripten/system/include/libcxx/codecvt +21 -18
  80. data/modules/emscripten/system/include/libcxx/complex +48 -7
  81. data/modules/emscripten/system/include/libcxx/cstddef +1 -1
  82. data/modules/emscripten/system/include/libcxx/cstdio +8 -1
  83. data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
  84. data/modules/emscripten/system/include/libcxx/cwchar +1 -1
  85. data/modules/emscripten/system/include/libcxx/deque +26 -12
  86. data/modules/emscripten/system/include/libcxx/dynarray +311 -0
  87. data/modules/emscripten/system/include/libcxx/exception +4 -4
  88. data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
  89. data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
  90. data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
  91. data/modules/emscripten/system/include/libcxx/forward_list +33 -7
  92. data/modules/emscripten/system/include/libcxx/fstream +4 -4
  93. data/modules/emscripten/system/include/libcxx/functional +200 -170
  94. data/modules/emscripten/system/include/libcxx/future +83 -39
  95. data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
  96. data/modules/emscripten/system/include/libcxx/iomanip +147 -0
  97. data/modules/emscripten/system/include/libcxx/ios +24 -16
  98. data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
  99. data/modules/emscripten/system/include/libcxx/istream +13 -8
  100. data/modules/emscripten/system/include/libcxx/iterator +108 -417
  101. data/modules/emscripten/system/include/libcxx/limits +8 -4
  102. data/modules/emscripten/system/include/libcxx/list +28 -8
  103. data/modules/emscripten/system/include/libcxx/locale +153 -390
  104. data/modules/emscripten/system/include/libcxx/map +280 -100
  105. data/modules/emscripten/system/include/libcxx/memory +49 -97
  106. data/modules/emscripten/system/include/libcxx/mutex +2 -2
  107. data/modules/emscripten/system/include/libcxx/new +43 -14
  108. data/modules/emscripten/system/include/libcxx/numeric +2 -2
  109. data/modules/emscripten/system/include/libcxx/optional +697 -0
  110. data/modules/emscripten/system/include/libcxx/ostream +17 -8
  111. data/modules/emscripten/system/include/libcxx/queue +5 -5
  112. data/modules/emscripten/system/include/libcxx/random +53 -51
  113. data/modules/emscripten/system/include/libcxx/ratio +11 -11
  114. data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
  115. data/modules/emscripten/system/include/libcxx/regex +23 -20
  116. data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
  117. data/modules/emscripten/system/include/libcxx/set +166 -2
  118. data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
  119. data/modules/emscripten/system/include/libcxx/sstream +4 -4
  120. data/modules/emscripten/system/include/libcxx/stack +3 -3
  121. data/modules/emscripten/system/include/libcxx/streambuf +5 -5
  122. data/modules/emscripten/system/include/libcxx/string +372 -324
  123. data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
  124. data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
  125. data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
  126. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
  127. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
  128. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
  129. data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
  130. data/modules/emscripten/system/include/libcxx/system_error +14 -8
  131. data/modules/emscripten/system/include/libcxx/thread +7 -8
  132. data/modules/emscripten/system/include/libcxx/tuple +29 -88
  133. data/modules/emscripten/system/include/libcxx/type_traits +253 -209
  134. data/modules/emscripten/system/include/libcxx/typeindex +3 -3
  135. data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
  136. data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
  137. data/modules/emscripten/system/include/libcxx/utility +20 -20
  138. data/modules/emscripten/system/include/libcxx/valarray +23 -23
  139. data/modules/emscripten/system/include/libcxx/vector +114 -91
  140. data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
  141. data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
  142. data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
  143. data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
  144. data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
  145. data/modules/emscripten/system/lib/libcextra.symbols +7 -0
  146. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
  147. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
  148. data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
  149. data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
  150. data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
  151. data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
  152. data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
  153. data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
  154. data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
  155. data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
  156. data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
  157. data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
  158. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
  159. data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
  160. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
  161. data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
  162. data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
  163. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
  164. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
  165. data/modules/emscripten/system/lib/libcxx/symbols +187 -168
  166. data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
  167. data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
  168. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
  169. data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
  170. data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
  171. data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
  172. data/modules/emscripten/tools/cache.py +5 -7
  173. data/modules/emscripten/tools/cache.pyc +0 -0
  174. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
  175. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  176. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
  177. data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
  178. data/modules/emscripten/tools/file_packager.py +93 -50
  179. data/modules/emscripten/tools/js-optimizer.js +98 -48
  180. data/modules/emscripten/tools/js_optimizer.py +4 -4
  181. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  182. data/modules/emscripten/tools/jsrun.py +1 -1
  183. data/modules/emscripten/tools/jsrun.pyc +0 -0
  184. data/modules/emscripten/tools/response_file.py +6 -0
  185. data/modules/emscripten/tools/response_file.pyc +0 -0
  186. data/modules/emscripten/tools/settings_template_readonly.py +2 -0
  187. data/modules/emscripten/tools/shared.py +88 -34
  188. data/modules/emscripten/tools/shared.pyc +0 -0
  189. data/modules/emscripten/tools/split.py +21 -13
  190. data/modules/mruby/build_config.rb +7 -1
  191. data/modules/mruby/doc/compile/README.md +5 -9
  192. data/modules/mruby/include/mrbconf.h +5 -2
  193. data/modules/mruby/include/mruby/array.h +1 -0
  194. data/modules/mruby/include/mruby/compile.h +2 -4
  195. data/modules/mruby/include/mruby/dump.h +7 -16
  196. data/modules/mruby/include/mruby/hash.h +1 -1
  197. data/modules/mruby/include/mruby/irep.h +14 -2
  198. data/modules/mruby/include/mruby/khash.h +8 -7
  199. data/modules/mruby/include/mruby/string.h +1 -0
  200. data/modules/mruby/include/mruby/value.h +5 -2
  201. data/modules/mruby/include/mruby.h +12 -13
  202. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
  203. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
  204. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
  205. data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
  206. data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
  207. data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
  208. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
  209. data/modules/mruby/mrblib/numeric.rb +99 -33
  210. data/modules/mruby/src/array.c +11 -4
  211. data/modules/mruby/src/backtrace.c +2 -2
  212. data/modules/mruby/src/class.c +49 -30
  213. data/modules/mruby/src/codegen.c +131 -79
  214. data/modules/mruby/src/debug.c +1 -1
  215. data/modules/mruby/src/dump.c +213 -163
  216. data/modules/mruby/src/error.c +17 -17
  217. data/modules/mruby/src/error.h +1 -1
  218. data/modules/mruby/src/etc.c +10 -0
  219. data/modules/mruby/src/gc.c +35 -17
  220. data/modules/mruby/src/hash.c +5 -5
  221. data/modules/mruby/src/kernel.c +36 -14
  222. data/modules/mruby/src/load.c +238 -296
  223. data/modules/mruby/src/numeric.c +18 -98
  224. data/modules/mruby/src/object.c +3 -5
  225. data/modules/mruby/src/parse.y +63 -56
  226. data/modules/mruby/src/proc.c +8 -5
  227. data/modules/mruby/src/re.h +0 -1
  228. data/modules/mruby/src/state.c +65 -27
  229. data/modules/mruby/src/string.c +3 -31
  230. data/modules/mruby/src/symbol.c +3 -3
  231. data/modules/mruby/src/variable.c +12 -5
  232. data/modules/mruby/src/vm.c +90 -72
  233. data/modules/mruby/tasks/mruby_build.rake +10 -1
  234. data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
  235. data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
  236. data/modules/mruby/test/driver.c +3 -3
  237. data/modules/mruby/test/t/array.rb +5 -5
  238. data/modules/mruby/test/t/class.rb +14 -1
  239. data/modules/mruby/test/t/kernel.rb +4 -0
  240. data/modules/mruby/test/t/module.rb +4 -4
  241. data/modules/mruby/test/t/nameerror.rb +1 -1
  242. data/modules/mruby/tools/mrbc/mrbc.c +23 -17
  243. data/modules/mruby/travis_config.rb +10 -1
  244. metadata +28 -5
  245. data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -20,8 +20,10 @@
20
20
  https://github.com/johnmccutchan/ecmascript_simd/blob/master/src/ecmascript_simd.js
21
21
  */
22
22
 
23
+ "use strict";
24
+
23
25
  /**
24
- * Construct a new instance of a float32x4 number.
26
+ * Construct a new instance of float32x4 number.
25
27
  * @param {double} value used for x lane.
26
28
  * @param {double} value used for y lane.
27
29
  * @param {double} value used for z lane.
@@ -40,7 +42,7 @@ function float32x4(x, y, z, w) {
40
42
  }
41
43
 
42
44
  /**
43
- * Construct a new instance of a float32x4 number with 0.0 in all lanes.
45
+ * Construct a new instance of float32x4 number with 0.0 in all lanes.
44
46
  * @constructor
45
47
  */
46
48
  float32x4.zero = function() {
@@ -48,7 +50,7 @@ float32x4.zero = function() {
48
50
  }
49
51
 
50
52
  /**
51
- * Construct a new instance of a float32x4 number with the same value
53
+ * Construct a new instance of float32x4 number with the same value
52
54
  * in all lanes.
53
55
  * @param {double} value used for all lanes.
54
56
  * @constructor
@@ -87,18 +89,18 @@ Object.defineProperty(float32x4.prototype, 'signMask', {
87
89
  });
88
90
 
89
91
  /**
90
- * Construct a new instance of a uint32x4 number.
92
+ * Construct a new instance of int32x4 number.
91
93
  * @param {integer} 32-bit unsigned value used for x lane.
92
94
  * @param {integer} 32-bit unsigned value used for y lane.
93
95
  * @param {integer} 32-bit unsigned value used for z lane.
94
96
  * @param {integer} 32-bit unsigned value used for w lane.
95
97
  * @constructor
96
98
  */
97
- function uint32x4(x, y, z, w) {
98
- if (!(this instanceof uint32x4)) {
99
- return new uint32x4(x, y, z, w);
99
+ function int32x4(x, y, z, w) {
100
+ if (!(this instanceof int32x4)) {
101
+ return new int32x4(x, y, z, w);
100
102
  }
101
- this.storage_ = new Uint32Array(4);
103
+ this.storage_ = new Int32Array(4);
102
104
  this.storage_[0] = x;
103
105
  this.storage_[1] = y;
104
106
  this.storage_[2] = z;
@@ -106,7 +108,7 @@ function uint32x4(x, y, z, w) {
106
108
  }
107
109
 
108
110
  /**
109
- * Construct a new instance of a uint32x4 number with 0xFFFFFFFF or 0x0 in each
111
+ * Construct a new instance of int32x4 number with 0xFFFFFFFF or 0x0 in each
110
112
  * lane, depending on the truth value in x, y, z, and w.
111
113
  * @param {boolean} flag used for x lane.
112
114
  * @param {boolean} flag used for y lane.
@@ -114,59 +116,59 @@ function uint32x4(x, y, z, w) {
114
116
  * @param {boolean} flag used for w lane.
115
117
  * @constructor
116
118
  */
117
- uint32x4.bool = function(x, y, z, w) {
118
- return uint32x4(x ? 0xFFFFFFFF : 0x0,
119
- y ? 0xFFFFFFFF : 0x0,
120
- z ? 0xFFFFFFFF : 0x0,
121
- w ? 0xFFFFFFFF : 0x0);
119
+ int32x4.bool = function(x, y, z, w) {
120
+ return int32x4(x ? -1 : 0x0,
121
+ y ? -1 : 0x0,
122
+ z ? -1 : 0x0,
123
+ w ? -1 : 0x0);
122
124
  }
123
125
 
124
126
  /**
125
- * Construct a new instance of a uint32x4 number with the same value
127
+ * Construct a new instance of int32x4 number with the same value
126
128
  * in all lanes.
127
129
  * @param {integer} value used for all lanes.
128
130
  * @constructor
129
131
  */
130
- uint32x4.splat = function(s) {
131
- return uint32x4(s, s, s, s);
132
+ int32x4.splat = function(s) {
133
+ return int32x4(s, s, s, s);
132
134
  }
133
135
 
134
- Object.defineProperty(uint32x4.prototype, 'x', {
136
+ Object.defineProperty(int32x4.prototype, 'x', {
135
137
  get: function() { return this.storage_[0]; }
136
138
  });
137
139
 
138
- Object.defineProperty(uint32x4.prototype, 'y', {
140
+ Object.defineProperty(int32x4.prototype, 'y', {
139
141
  get: function() { return this.storage_[1]; }
140
142
  });
141
143
 
142
- Object.defineProperty(uint32x4.prototype, 'z', {
144
+ Object.defineProperty(int32x4.prototype, 'z', {
143
145
  get: function() { return this.storage_[2]; }
144
146
  });
145
147
 
146
- Object.defineProperty(uint32x4.prototype, 'w',
148
+ Object.defineProperty(int32x4.prototype, 'w',
147
149
  { get: function() { return this.storage_[3]; }
148
150
  });
149
151
 
150
- Object.defineProperty(uint32x4.prototype, 'flagX', {
152
+ Object.defineProperty(int32x4.prototype, 'flagX', {
151
153
  get: function() { return this.storage_[0] != 0x0; }
152
154
  });
153
155
 
154
- Object.defineProperty(uint32x4.prototype, 'flagY', {
156
+ Object.defineProperty(int32x4.prototype, 'flagY', {
155
157
  get: function() { return this.storage_[1] != 0x0; }
156
158
  });
157
159
 
158
- Object.defineProperty(uint32x4.prototype, 'flagZ', {
160
+ Object.defineProperty(int32x4.prototype, 'flagZ', {
159
161
  get: function() { return this.storage_[2] != 0x0; }
160
162
  });
161
163
 
162
- Object.defineProperty(uint32x4.prototype, 'flagW',
164
+ Object.defineProperty(int32x4.prototype, 'flagW',
163
165
  { get: function() { return this.storage_[3] != 0x0; }
164
166
  });
165
167
 
166
168
  /**
167
169
  * Extract the sign bit from each lane return them in the first 4 bits.
168
170
  */
169
- Object.defineProperty(uint32x4.prototype, 'signMask', {
171
+ Object.defineProperty(int32x4.prototype, 'signMask', {
170
172
  get: function() {
171
173
  var mx = (this.storage_[0] & 0x80000000) >>> 31;
172
174
  var my = (this.storage_[1] & 0x80000000) >>> 31;
@@ -287,414 +289,583 @@ Float32x4Array.prototype.setAt = function(i, v) {
287
289
  this.storage_[i*4+3] = v.w;
288
290
  }
289
291
 
292
+
293
+ function Int32x4Array(a, b, c) {
294
+
295
+ function isNumber(o) {
296
+ return typeof o == "number" || (typeof o == "object" && o.constructor === Number);
297
+ }
298
+
299
+ function isTypedArray(o) {
300
+ return (o instanceof Int8Array) ||
301
+ (o instanceof Uint8Array) ||
302
+ (o instanceof Uint8ClampedArray) ||
303
+ (o instanceof Int16Array) ||
304
+ (o instanceof Uint16Array) ||
305
+ (o instanceof Int32Array) ||
306
+ (o instanceof Uint32Array) ||
307
+ (o instanceof Float32Array) ||
308
+ (o instanceof Float64Array) ||
309
+ (o instanceof Int32x4Array) ||
310
+ (o instanceof Float32x4Array);
311
+ }
312
+
313
+ function isArrayBuffer(o) {
314
+ return (o instanceof ArrayBuffer);
315
+ }
316
+
317
+ if (isNumber(a)) {
318
+ this.storage_ = new Int32Array(a*4);
319
+ this.length_ = a;
320
+ this.byteOffset_ = 0;
321
+ return;
322
+ } else if (isTypedArray(a)) {
323
+ if (!(a instanceof Int32x4Array)) {
324
+ throw "Copying typed array of non-Int32x4Array is unimplemented.";
325
+ }
326
+ this.storage_ = new Int32Array(a.length * 4);
327
+ this.length_ = a.length;
328
+ this.byteOffset_ = 0;
329
+ // Copy floats.
330
+ for (var i = 0; i < a.length*4; i++) {
331
+ this.storage_[i] = a.storage_[i];
332
+ }
333
+ } else if (isArrayBuffer(a)) {
334
+ if ((b != undefined) && (b % Int32x4Array.BYTES_PER_ELEMENT) != 0) {
335
+ throw "byteOffset must be a multiple of 16.";
336
+ }
337
+ if (c != undefined) {
338
+ c *= 4;
339
+ this.storage_ = new Int32Array(a, b, c);
340
+ }
341
+ else {
342
+ // Note: new Int32Array(a, b) is NOT equivalent to new Float32Array(a, b, undefined)
343
+ this.storage_ = new Int32Array(a, b);
344
+ }
345
+ this.length_ = this.storage_.length / 4;
346
+ this.byteOffset_ = b != undefined ? b : 0;
347
+ } else {
348
+ throw "Unknown type of first argument.";
349
+ }
350
+ }
351
+
352
+ Object.defineProperty(Int32x4Array.prototype, 'length',
353
+ { get: function() { return this.length_; }
354
+ });
355
+
356
+ Object.defineProperty(Int32x4Array.prototype, 'byteLength',
357
+ { get: function() { return this.length_ * Int32x4Array.BYTES_PER_ELEMENT; }
358
+ });
359
+
360
+ Object.defineProperty(Int32x4Array, 'BYTES_PER_ELEMENT',
361
+ { get: function() { return 16; }
362
+ });
363
+
364
+ Object.defineProperty(Int32x4Array.prototype, 'BYTES_PER_ELEMENT',
365
+ { get: function() { return 16; }
366
+ });
367
+
368
+ Object.defineProperty(Int32x4Array.prototype, 'byteOffset',
369
+ { get: function() { return this.byteOffset_; }
370
+ });
371
+
372
+ Object.defineProperty(Int32x4Array.prototype, 'buffer',
373
+ { get: function() { return this.storage_.buffer; }
374
+ });
375
+
376
+ Int32x4Array.prototype.getAt = function(i) {
377
+ if (i < 0) {
378
+ throw "Index must be >= 0.";
379
+ }
380
+ if (i >= this.length) {
381
+ throw "Index out of bounds.";
382
+ }
383
+ var x = this.storage_[i*4+0];
384
+ var y = this.storage_[i*4+1];
385
+ var z = this.storage_[i*4+2];
386
+ var w = this.storage_[i*4+3];
387
+ return float32x4(x, y, z, w);
388
+ }
389
+
390
+ Int32x4Array.prototype.setAt = function(i, v) {
391
+ if (i < 0) {
392
+ throw "Index must be >= 0.";
393
+ }
394
+ if (i >= this.length) {
395
+ throw "Index out of bounds.";
396
+ }
397
+ if (!(v instanceof int32x4)) {
398
+ throw "Value is not a int32x4.";
399
+ }
400
+ this.storage_[i*4+0] = v.x;
401
+ this.storage_[i*4+1] = v.y;
402
+ this.storage_[i*4+2] = v.z;
403
+ this.storage_[i*4+3] = v.w;
404
+ }
405
+
290
406
  var SIMD = (function () {
291
407
  return {
292
- /**
293
- * @return {float32x4} New instance of float32x4 with absolute values of
294
- * t.
295
- */
296
- abs: function(t) {
297
- return new float32x4(Math.abs(t.x), Math.abs(t.y), Math.abs(t.z),
298
- Math.abs(t.w));
299
- },
300
- /**
301
- * @return {float32x4} New instance of float32x4 with negated values of
302
- * t.
303
- */
304
- neg: function(t) {
305
- return new float32x4(-t.x, -t.y, -t.z, -t.w);
306
- },
307
- /**
308
- * @return {float32x4} New instance of float32x4 with a + b.
309
- */
310
- add: function(a, b) {
311
- return new float32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
312
- },
313
- /**
314
- * @return {float32x4} New instance of float32x4 with a - b.
315
- */
316
- sub: function(a, b) {
317
- return new float32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
318
- },
319
- /**
320
- * @return {float32x4} New instance of float32x4 with a * b.
321
- */
322
- mul: function(a, b) {
323
- return new float32x4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
324
- },
325
- /**
326
- * @return {float32x4} New instance of float32x4 with a / b.
327
- */
328
- div: function(a, b) {
329
- return new float32x4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
330
- },
331
- /**
332
- * @return {float32x4} New instance of float32x4 with t's values clamped
333
- * between lowerLimit and upperLimit.
334
- */
335
- clamp: function(t, lowerLimit, upperLimit) {
336
- var cx = t.x < lowerLimit.x ? lowerLimit.x : t.x;
337
- var cy = t.y < lowerLimit.y ? lowerLimit.y : t.y;
338
- var cz = t.z < lowerLimit.z ? lowerLimit.z : t.z;
339
- var cw = t.w < lowerLimit.w ? lowerLimit.w : t.w;
340
- cx = cx > upperLimit.x ? upperLimit.x : cx;
341
- cy = cy > upperLimit.y ? upperLimit.y : cy;
342
- cz = cz > upperLimit.z ? upperLimit.z : cz;
343
- cw = cw > upperLimit.w ? upperLimit.w : cw;
344
- return new float32x4(cx, cy, cz, cw);
345
- },
346
- /**
347
- * @return {float32x4} New instance of float32x4 with the minimum value of
348
- * t and other.
349
- */
350
- min: function(t, other) {
351
- var cx = t.x > other.x ? other.x : t.x;
352
- var cy = t.y > other.y ? other.y : t.y;
353
- var cz = t.z > other.z ? other.z : t.z;
354
- var cw = t.w > other.w ? other.w : t.w;
355
- return new float32x4(cx, cy, cz, cw);
356
- },
357
- /**
358
- * @return {float32x4} New instance of float32x4 with the maximum value of
359
- * t and other.
360
- */
361
- max: function(t, other) {
362
- var cx = t.x < other.x ? other.x : t.x;
363
- var cy = t.y < other.y ? other.y : t.y;
364
- var cz = t.z < other.z ? other.z : t.z;
365
- var cw = t.w < other.w ? other.w : t.w;
366
- return new float32x4(cx, cy, cz, cw);
367
- },
368
- /**
369
- * @return {float32x4} New instance of float32x4 with reciprocal value of
370
- * t.
371
- */
372
- reciprocal: function(t) {
373
- return new float32x4(1.0 / t.x, 1.0 / t.y, 1.0 / t.z, 1.0 / t.w);
374
- },
375
- /**
376
- * @return {float32x4} New instance of float32x4 with square root of the
377
- * reciprocal value of t.
378
- */
379
- reciprocalSqrt: function(t) {
380
- return new float32x4(Math.sqrt(1.0 / t.x), Math.sqrt(1.0 / t.y),
381
- Math.sqrt(1.0 / t.z), Math.sqrt(1.0 / t.w));
382
- },
383
- /**
384
- * @return {float32x4} New instance of float32x4 with values of t
385
- * scaled by s.
386
- */
387
- scale: function(t, s) {
388
- return new float32x4(s * t.x, s * t.y, s * t.z, s * t.w);
389
- },
390
- /**
391
- * @return {float32x4} New instance of float32x4 with square root of
392
- * values of t.
393
- */
394
- sqrt: function(t) {
395
- return new float32x4(Math.sqrt(t.x), Math.sqrt(t.y),
396
- Math.sqrt(t.z), Math.sqrt(t.w));
397
- },
398
- /**
399
- * @param {float32x4} t An instance of float32x4 to be shuffled.
400
- * @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
401
- * @return {float32x4} New instance of float32x4 with lanes shuffled.
402
- */
403
- shuffle: function(t, mask) {
404
- var _x = (mask) & 0x3;
405
- var _y = (mask >> 2) & 0x3;
406
- var _z = (mask >> 4) & 0x3;
407
- var _w = (mask >> 6) & 0x3;
408
- return new float32x4(t.storage_[_x], t.storage_[_y], t.storage_[_z],
409
- t.storage_[_w]);
408
+ float32x4: {
409
+ /**
410
+ * @return {float32x4} New instance of float32x4 with absolute values of
411
+ * t.
412
+ */
413
+ abs: function(t) {
414
+ return new float32x4(Math.abs(t.x), Math.abs(t.y), Math.abs(t.z),
415
+ Math.abs(t.w));
416
+ },
417
+ /**
418
+ * @return {float32x4} New instance of float32x4 with negated values of
419
+ * t.
420
+ */
421
+ neg: function(t) {
422
+ return new float32x4(-t.x, -t.y, -t.z, -t.w);
423
+ },
424
+ /**
425
+ * @return {float32x4} New instance of float32x4 with a + b.
426
+ */
427
+ add: function(a, b) {
428
+ return new float32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
429
+ },
430
+ /**
431
+ * @return {float32x4} New instance of float32x4 with a - b.
432
+ */
433
+ sub: function(a, b) {
434
+ return new float32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
435
+ },
436
+ /**
437
+ * @return {float32x4} New instance of float32x4 with a * b.
438
+ */
439
+ mul: function(a, b) {
440
+ return new float32x4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
441
+ },
442
+ /**
443
+ * @return {float32x4} New instance of float32x4 with a / b.
444
+ */
445
+ div: function(a, b) {
446
+ return new float32x4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
447
+ },
448
+ /**
449
+ * @return {float32x4} New instance of float32x4 with t's values clamped
450
+ * between lowerLimit and upperLimit.
451
+ */
452
+ clamp: function(t, lowerLimit, upperLimit) {
453
+ var cx = t.x < lowerLimit.x ? lowerLimit.x : t.x;
454
+ var cy = t.y < lowerLimit.y ? lowerLimit.y : t.y;
455
+ var cz = t.z < lowerLimit.z ? lowerLimit.z : t.z;
456
+ var cw = t.w < lowerLimit.w ? lowerLimit.w : t.w;
457
+ cx = cx > upperLimit.x ? upperLimit.x : cx;
458
+ cy = cy > upperLimit.y ? upperLimit.y : cy;
459
+ cz = cz > upperLimit.z ? upperLimit.z : cz;
460
+ cw = cw > upperLimit.w ? upperLimit.w : cw;
461
+ return new float32x4(cx, cy, cz, cw);
462
+ },
463
+ /**
464
+ * @return {float32x4} New instance of float32x4 with the minimum value of
465
+ * t and other.
466
+ */
467
+ min: function(t, other) {
468
+ var cx = t.x > other.x ? other.x : t.x;
469
+ var cy = t.y > other.y ? other.y : t.y;
470
+ var cz = t.z > other.z ? other.z : t.z;
471
+ var cw = t.w > other.w ? other.w : t.w;
472
+ return new float32x4(cx, cy, cz, cw);
473
+ },
474
+ /**
475
+ * @return {float32x4} New instance of float32x4 with the maximum value of
476
+ * t and other.
477
+ */
478
+ max: function(t, other) {
479
+ var cx = t.x < other.x ? other.x : t.x;
480
+ var cy = t.y < other.y ? other.y : t.y;
481
+ var cz = t.z < other.z ? other.z : t.z;
482
+ var cw = t.w < other.w ? other.w : t.w;
483
+ return new float32x4(cx, cy, cz, cw);
484
+ },
485
+ /**
486
+ * @return {float32x4} New instance of float32x4 with reciprocal value of
487
+ * t.
488
+ */
489
+ reciprocal: function(t) {
490
+ return new float32x4(1.0 / t.x, 1.0 / t.y, 1.0 / t.z, 1.0 / t.w);
491
+ },
492
+ /**
493
+ * @return {float32x4} New instance of float32x4 with square root of the
494
+ * reciprocal value of t.
495
+ */
496
+ reciprocalSqrt: function(t) {
497
+ return new float32x4(Math.sqrt(1.0 / t.x), Math.sqrt(1.0 / t.y),
498
+ Math.sqrt(1.0 / t.z), Math.sqrt(1.0 / t.w));
499
+ },
500
+ /**
501
+ * @return {float32x4} New instance of float32x4 with values of t
502
+ * scaled by s.
503
+ */
504
+ scale: function(t, s) {
505
+ return new float32x4(s * t.x, s * t.y, s * t.z, s * t.w);
506
+ },
507
+ /**
508
+ * @return {float32x4} New instance of float32x4 with square root of
509
+ * values of t.
510
+ */
511
+ sqrt: function(t) {
512
+ return new float32x4(Math.sqrt(t.x), Math.sqrt(t.y),
513
+ Math.sqrt(t.z), Math.sqrt(t.w));
514
+ },
515
+ /**
516
+ * @param {float32x4} t An instance of float32x4 to be shuffled.
517
+ * @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
518
+ * @return {float32x4} New instance of float32x4 with lanes shuffled.
519
+ */
520
+ shuffle: function(t, mask) {
521
+ var _x = (mask) & 0x3;
522
+ var _y = (mask >> 2) & 0x3;
523
+ var _z = (mask >> 4) & 0x3;
524
+ var _w = (mask >> 6) & 0x3;
525
+ return new float32x4(t.storage_[_x], t.storage_[_y], t.storage_[_z],
526
+ t.storage_[_w]);
527
+ },
528
+ /**
529
+ * @param {float32x4} t1 An instance of float32x4 to be shuffled. XY lanes in result
530
+ * @param {float32x4} t2 An instance of float32x4 to be shuffled. ZW lanes in result
531
+ * @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
532
+ * @return {float32x4} New instance of float32x4 with lanes shuffled.
533
+ */
534
+ shuffleMix: function(t1, t2, mask) {
535
+ var _x = (mask) & 0x3;
536
+ var _y = (mask >> 2) & 0x3;
537
+ var _z = (mask >> 4) & 0x3;
538
+ var _w = (mask >> 6) & 0x3;
539
+ return new float32x4(t1.storage_[_x], t1.storage_[_y], t2.storage_[_z],
540
+ t2.storage_[_w]);
541
+ },
542
+ /**
543
+ * @param {double} value used for x lane.
544
+ * @return {float32x4} New instance of float32x4 with the values in t and
545
+ * x replaced with {x}.
546
+ */
547
+ withX: function(t, x) {
548
+ return new float32x4(x, t.y, t.z, t.w);
549
+ },
550
+ /**
551
+ * @param {double} value used for y lane.
552
+ * @return {float32x4} New instance of float32x4 with the values in t and
553
+ * y replaced with {y}.
554
+ */
555
+ withY: function(t, y) {
556
+ return new float32x4(t.x, y, t.z, t.w);
557
+ },
558
+ /**
559
+ * @param {double} value used for z lane.
560
+ * @return {float32x4} New instance of float32x4 with the values in t and
561
+ * z replaced with {z}.
562
+ */
563
+ withZ: function(t, z) {
564
+ return new float32x4(t.x, t.y, z, t.w);
565
+ },
566
+ /**
567
+ * @param {double} value used for w lane.
568
+ * @return {float32x4} New instance of float32x4 with the values in t and
569
+ * w replaced with {w}.
570
+ */
571
+ withW: function(t, w) {
572
+ return new float32x4(t.x, t.y, t.z, w);
573
+ },
574
+ /**
575
+ * @param {float32x4} t An instance of float32x4.
576
+ * @param {float32x4} other An instance of float32x4.
577
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
578
+ * the result of t < other.
579
+ */
580
+ lessThan: function(t, other) {
581
+ var cx = t.x < other.x;
582
+ var cy = t.y < other.y;
583
+ var cz = t.z < other.z;
584
+ var cw = t.w < other.w;
585
+ return int32x4.bool(cx, cy, cz, cw);
586
+ },
587
+ /**
588
+ * @param {float32x4} t An instance of float32x4.
589
+ * @param {float32x4} other An instance of float32x4.
590
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
591
+ * the result of t <= other.
592
+ */
593
+ lessThanOrEqual: function(t, other) {
594
+ var cx = t.x <= other.x;
595
+ var cy = t.y <= other.y;
596
+ var cz = t.z <= other.z;
597
+ var cw = t.w <= other.w;
598
+ return int32x4.bool(cx, cy, cz, cw);
599
+ },
600
+ /**
601
+ * @param {float32x4} t An instance of float32x4.
602
+ * @param {float32x4} other An instance of float32x4.
603
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
604
+ * the result of t == other.
605
+ */
606
+ equal: function(t, other) {
607
+ var cx = t.x == other.x;
608
+ var cy = t.y == other.y;
609
+ var cz = t.z == other.z;
610
+ var cw = t.w == other.w;
611
+ return int32x4.bool(cx, cy, cz, cw);
612
+ },
613
+ /**
614
+ * @param {float32x4} t An instance of float32x4.
615
+ * @param {float32x4} other An instance of float32x4.
616
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
617
+ * the result of t != other.
618
+ */
619
+ notEqual: function(t, other) {
620
+ var cx = t.x != other.x;
621
+ var cy = t.y != other.y;
622
+ var cz = t.z != other.z;
623
+ var cw = t.w != other.w;
624
+ return int32x4.bool(cx, cy, cz, cw);
625
+ },
626
+ /**
627
+ * @param {float32x4} t An instance of float32x4.
628
+ * @param {float32x4} other An instance of float32x4.
629
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
630
+ * the result of t >= other.
631
+ */
632
+ greaterThanOrEqual: function(t, other) {
633
+ var cx = t.x >= other.x;
634
+ var cy = t.y >= other.y;
635
+ var cz = t.z >= other.z;
636
+ var cw = t.w >= other.w;
637
+ return int32x4.bool(cx, cy, cz, cw);
638
+ },
639
+ /**
640
+ * @param {float32x4} t An instance of float32x4.
641
+ * @param {float32x4} other An instance of float32x4.
642
+ * @return {int32x4} 0xFFFFFFFF or 0x0 in each lane depending on
643
+ * the result of t > other.
644
+ */
645
+ greaterThan: function(t, other) {
646
+ var cx = t.x > other.x;
647
+ var cy = t.y > other.y;
648
+ var cz = t.z > other.z;
649
+ var cw = t.w > other.w;
650
+ return int32x4.bool(cx, cy, cz, cw);
651
+ },
652
+ /**
653
+ * @param {float32x4} t An instance of float32x4.
654
+ * @return {int32x4} a bit-wise copy of t as a int32x4.
655
+ */
656
+ bitsToInt32x4: function(t) {
657
+ var alias = new Int32Array(t.storage_.buffer);
658
+ return new int32x4(alias[0], alias[1], alias[2], alias[3]);
659
+ },
660
+ /**
661
+ * @param {float32x4} t An instance of float32x4.
662
+ * @return {int32x4} with a integer to float conversion of t.
663
+ */
664
+ toInt32x4: function(t) {
665
+ var a = new int32x4(t.storage_[0], t.storage_[1], t.storage_[2],
666
+ t.storage_[3]);
667
+ return a;
668
+ }
410
669
  },
411
- /**
412
- * @param {double} value used for x lane.
413
- * @return {float32x4} New instance of float32x4 with the values in t and
414
- * x replaced with {x}.
415
- */
416
- withX: function(t, x) {
417
- return new float32x4(x, t.y, t.z, t.w);
418
- },
419
- /**
420
- * @param {double} value used for y lane.
421
- * @return {float32x4} New instance of float32x4 with the values in t and
422
- * y replaced with {y}.
423
- */
424
- withY: function(t, y) {
425
- return new float32x4(t.x, y, t.z, t.w);
426
- },
427
- /**
428
- * @param {double} value used for z lane.
429
- * @return {float32x4} New instance of float32x4 with the values in t and
430
- * z replaced with {z}.
431
- */
432
- withZ: function(t, z) {
433
- return new float32x4(t.x, t.y, z, t.w);
434
- },
435
- /**
436
- * @param {double} value used for w lane.
437
- * @return {float32x4} New instance of float32x4 with the values in t and
438
- * w replaced with {w}.
439
- */
440
- withW: function(t, w) {
441
- return new float32x4(t.x, t.y, t.z, w);
442
- },
443
- /**
444
- * @param {float32x4} t An instance of a float32x4.
445
- * @param {float32x4} other An instance of a float32x4.
446
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
447
- * the result of t < other.
448
- */
449
- lessThan: function(t, other) {
450
- var cx = t.x < other.x;
451
- var cy = t.y < other.y;
452
- var cz = t.z < other.z;
453
- var cw = t.w < other.w;
454
- return uint32x4.bool(cx, cy, cz, cw);
455
- },
456
- /**
457
- * @param {float32x4} t An instance of a float32x4.
458
- * @param {float32x4} other An instance of a float32x4.
459
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
460
- * the result of t <= other.
461
- */
462
- lessThanOrEqual: function(t, other) {
463
- var cx = t.x <= other.x;
464
- var cy = t.y <= other.y;
465
- var cz = t.z <= other.z;
466
- var cw = t.w <= other.w;
467
- return uint32x4.bool(cx, cy, cz, cw);
468
- },
469
- /**
470
- * @param {float32x4} t An instance of a float32x4.
471
- * @param {float32x4} other An instance of a float32x4.
472
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
473
- * the result of t == other.
474
- */
475
- equal: function(t, other) {
476
- var cx = t.x == other.x;
477
- var cy = t.y == other.y;
478
- var cz = t.z == other.z;
479
- var cw = t.w == other.w;
480
- return uint32x4.bool(cx, cy, cz, cw);
481
- },
482
- /**
483
- * @param {float32x4} t An instance of a float32x4.
484
- * @param {float32x4} other An instance of a float32x4.
485
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
486
- * the result of t != other.
487
- */
488
- notEqual: function(t, other) {
489
- var cx = t.x != other.x;
490
- var cy = t.y != other.y;
491
- var cz = t.z != other.z;
492
- var cw = t.w != other.w;
493
- return uint32x4.bool(cx, cy, cz, cw);
494
- },
495
- /**
496
- * @param {float32x4} t An instance of a float32x4.
497
- * @param {float32x4} other An instance of a float32x4.
498
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
499
- * the result of t >= other.
500
- */
501
- greaterThanOrEqual: function(t, other) {
502
- var cx = t.x >= other.x;
503
- var cy = t.y >= other.y;
504
- var cz = t.z >= other.z;
505
- var cw = t.w >= other.w;
506
- return uint32x4.bool(cx, cy, cz, cw);
507
- },
508
- /**
509
- * @param {float32x4} t An instance of a float32x4.
510
- * @param {float32x4} other An instance of a float32x4.
511
- * @return {uint32x4} 0xFFFFFFFF or 0x0 in each lane depending on
512
- * the result of t > other.
513
- */
514
- greaterThan: function(t, other) {
515
- var cx = t.x > other.x;
516
- var cy = t.y > other.y;
517
- var cz = t.z > other.z;
518
- var cw = t.w > other.w;
519
- return uint32x4.bool(cx, cy, cz, cw);
520
- },
521
- /**
522
- * @param {uint32x4} a An instance of a uint32x4.
523
- * @param {uint32x4} b An instance of a uint32x4.
524
- * @return {uint32x4} New instance of uint32x4 with values of a & b.
525
- */
526
- and: function(a, b) {
527
- return new uint32x4(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w);
528
- },
529
- /**
530
- * @param {uint32x4} a An instance of a uint32x4.
531
- * @param {uint32x4} b An instance of a uint32x4.
532
- * @return {uint32x4} New instance of uint32x4 with values of a | b.
533
- */
534
- or: function(a, b) {
535
- return new uint32x4(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w);
536
- },
537
- /**
538
- * @param {uint32x4} a An instance of a uint32x4.
539
- * @param {uint32x4} b An instance of a uint32x4.
540
- * @return {uint32x4} New instance of uint32x4 with values of a ^ b.
541
- */
542
- xor: function(a, b) {
543
- return new uint32x4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w);
544
- },
545
- /**
546
- * @param {uint32x4} t An instance of a uint32x4.
547
- * @return {uint32x4} New instance of uint32x4 with values of ~a
548
- */
549
- negu32: function(t) {
550
- return new uint32x4(~t.x, ~t.y, ~t.z, ~t.w);
551
- },
552
- /**
553
- * @param {uint32x4} a An instance of uint32x4.
554
- * @param {uint32x4} b An instance of uint32x4.
555
- * @return {uint32x4} New instance of uint32x4 with values of a + b.
556
- */
557
- addu32: function(a, b) {
558
- return new uint32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
559
- },
560
- /**
561
- * @param {uint32x4} a An instance of uint32x4.
562
- * @param {uint32x4} b An instance of uint32x4.
563
- * @return {uint32x4} New instance of uint32x4 with values of a - b.
564
- */
565
- subu32: function(a, b) {
566
- return new uint32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
567
- },
568
- /**
569
- * @param {uint32x4} a An instance of uint32x4.
570
- * @param {uint32x4} b An instance of uint32x4.
571
- * @return {uint32x4} New instance of uint32x4 with values of a * b.
572
- */
573
- mulu32: function(a, b) {
574
- return new uint32x4(Math.imul(a.x, b.x), Math.imul(a.y, b.y),
575
- Math.imul(a.z, b.z), Math.imul(a.w, b.w));
576
- },
577
- /**
578
- * @param {float32x4}
579
- */
580
- select: function(t, trueValue, falseValue) {
581
- var tv = SIMD.float32x4BitsToUint32x4(trueValue);
582
- var fv = SIMD.float32x4BitsToUint32x4(falseValue);
583
- var tr = SIMD.and(t, tv);
584
- var fr = SIMD.and(SIMD.negu32(t), fv);
585
- return SIMD.uint32x4BitsToFloat32x4(SIMD.or(tr, fr));
586
- },
587
- /**
588
- * @param {uint32x4} t An instance of a uint32x4.
589
- * @param {integer} 32-bit value used for x lane.
590
- * @return {uint32x4} New instance of uint32x4 with the values in t and
591
- * x lane replaced with {x}.
592
- */
593
- withXu32: function(t, x) {
594
- return new uint32x4(x, t.y, t.z, t.w);
595
- },
596
- /**
597
- * param {uint32x4} t An instance of a uint32x4.
598
- * @param {integer} 32-bit value used for y lane.
599
- * @return {uint32x4} New instance of uint32x4 with the values in t and
600
- * y lane replaced with {y}.
601
- */
602
- withYu32: function(t, y) {
603
- return new uint32x4(t.x, y, t.z, t.w);
604
- },
605
- /**
606
- * @param {uint32x4} t An instance of a uint32x4.
607
- * @param {integer} 32-bit value used for z lane.
608
- * @return {uint32x4} New instance of uint32x4 with the values in t and
609
- * z lane replaced with {z}.
610
- */
611
- withZu32: function(t, z) {
612
- return new uint32x4(t.x, t.y, z, t.w);
613
- },
614
- /**
615
- * @param {integer} 32-bit value used for w lane.
616
- * @return {uint32x4} New instance of uint32x4 with the values in t and
617
- * w lane replaced with {w}.
618
- */
619
- withWu32: function(t, w) {
620
- return new uint32x4(t.x, t.y, t.z, w);
621
- },
622
- /**
623
- * @param {uint32x4} t An instance of a uint32x4.
624
- * @param {boolean} x flag used for x lane.
625
- * @return {uint32x4} New instance of uint32x4 with the values in t and
626
- * x lane replaced with {x}.
627
- */
628
- withFlagX: function(t, flagX) {
629
- var x = flagX ? 0xFFFFFFFF : 0x0;
630
- return new uint32x4(x, t.y, t.z, t.w);
631
- },
632
- /**
633
- * @param {uint32x4} t An instance of a uint32x4.
634
- * @param {boolean} y flag used for y lane.
635
- * @return {uint32x4} New instance of uint32x4 with the values in t and
636
- * y lane replaced with {y}.
637
- */
638
- withFlagY: function(t, flagY) {
639
- var y = flagY ? 0xFFFFFFFF : 0x0;
640
- return new uint32x4(t.x, y, t.z, t.w);
641
- },
642
- /**
643
- * @param {uint32x4} t An instance of a uint32x4.
644
- * @param {boolean} z flag used for z lane.
645
- * @return {uint32x4} New instance of uint32x4 with the values in t and
646
- * z lane replaced with {z}.
647
- */
648
- withFlagZ: function(t, flagZ) {
649
- var z = flagZ ? 0xFFFFFFFF : 0x0;
650
- return new uint32x4(t.x, t.y, z, t.w);
651
- },
652
- /**
653
- * @param {uint32x4} t An instance of a uint32x4.
654
- * @param {boolean} w flag used for w lane.
655
- * @return {uint32x4} New instance of uint32x4 with the values in t and
656
- * w lane replaced with {w}.
657
- */
658
- withFlagW: function(t, flagW) {
659
- var w = flagW ? 0xFFFFFFFF : 0x0;
660
- return new uint32x4(t.x, t.y, t.z, w);
661
- },
662
- /**
663
- * @param {float32x4} t An instance of a float32x4.
664
- * @return {uint32x4} a bit-wise copy of t as a uint32x4.
665
- */
666
- float32x4BitsToUint32x4: function(t) {
667
- var alias = new Uint32Array(t.storage_.buffer);
668
- return new uint32x4(alias[0], alias[1], alias[2], alias[3]);
669
- },
670
- /**
671
- * @param {uint32x4} t An instance of a uint32x4.
672
- * @return {float32x4} a bit-wise copy of t as a float32x4.
673
- */
674
- uint32x4BitsToFloat32x4: function(t) {
675
- var alias = new Float32Array(t.storage_.buffer);
676
- return new float32x4(alias[0], alias[1], alias[2], alias[3]);
677
- },
678
- /**
679
- * @param {uint32x4} t An instance of a uint32x4.
680
- * @return {float32x4} with a float to integer conversion copy of t.
681
- */
682
- uint32x4ToFloat32x4: function(t) {
683
- var a = float32x4.zero();
684
- a.storage_[0] = t.storage_[0];
685
- a.storage_[1] = t.storage_[1];
686
- a.storage_[2] = t.storage_[2];
687
- a.storage_[3] = t.storage_[3];
688
- return a;
689
- },
690
- /**
691
- * @param {float32x4} t An instance of a float32x4.
692
- * @return {uint32x4} with a integer to float conversion of t.
693
- */
694
- float32x4ToUint32x4: function(t) {
695
- var a = new uint32x4(t.storage_[0], t.storage_[1], t.storage_[2],
696
- t.storage_[3]);
697
- return a;
670
+ int32x4: {
671
+ /**
672
+ * @param {int32x4} a An instance of int32x4.
673
+ * @param {int32x4} b An instance of int32x4.
674
+ * @return {int32x4} New instance of int32x4 with values of a & b.
675
+ */
676
+ and: function(a, b) {
677
+ return new int32x4(a.x & b.x, a.y & b.y, a.z & b.z, a.w & b.w);
678
+ },
679
+ /**
680
+ * @param {int32x4} a An instance of int32x4.
681
+ * @param {int32x4} b An instance of int32x4.
682
+ * @return {int32x4} New instance of int32x4 with values of a | b.
683
+ */
684
+ or: function(a, b) {
685
+ return new int32x4(a.x | b.x, a.y | b.y, a.z | b.z, a.w | b.w);
686
+ },
687
+ /**
688
+ * @param {int32x4} a An instance of int32x4.
689
+ * @param {int32x4} b An instance of int32x4.
690
+ * @return {int32x4} New instance of int32x4 with values of a ^ b.
691
+ */
692
+ xor: function(a, b) {
693
+ return new int32x4(a.x ^ b.x, a.y ^ b.y, a.z ^ b.z, a.w ^ b.w);
694
+ },
695
+ /**
696
+ * @param {int32x4} t An instance of int32x4.
697
+ * @return {int32x4} New instance of int32x4 with values of ~t
698
+ */
699
+ not: function(t) {
700
+ return new int32x4(~t.x, ~t.y, ~t.z, ~t.w);
701
+ },
702
+ /**
703
+ * @param {int32x4} t An instance of int32x4.
704
+ * @return {int32x4} New instance of int32x4 with values of -t
705
+ */
706
+ neg: function(t) {
707
+ return new int32x4(-t.x, -t.y, -t.z, -t.w);
708
+ },
709
+ /**
710
+ * @param {int32x4} a An instance of int32x4.
711
+ * @param {int32x4} b An instance of int32x4.
712
+ * @return {int32x4} New instance of int32x4 with values of a + b.
713
+ */
714
+ add: function(a, b) {
715
+ return new int32x4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
716
+ },
717
+ /**
718
+ * @param {int32x4} a An instance of int32x4.
719
+ * @param {int32x4} b An instance of int32x4.
720
+ * @return {int32x4} New instance of int32x4 with values of a - b.
721
+ */
722
+ sub: function(a, b) {
723
+ return new int32x4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
724
+ },
725
+ /**
726
+ * @param {int32x4} a An instance of int32x4.
727
+ * @param {int32x4} b An instance of int32x4.
728
+ * @return {int32x4} New instance of int32x4 with values of a * b.
729
+ */
730
+ mul: function(a, b) {
731
+ return new int32x4(Math.imul(a.x, b.x), Math.imul(a.y, b.y),
732
+ Math.imul(a.z, b.z), Math.imul(a.w, b.w));
733
+ },
734
+ /**
735
+ * @param {int32x4} t An instance of float32x4 to be shuffled.
736
+ * @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
737
+ * @return {int32x4} New instance of float32x4 with lanes shuffled.
738
+ */
739
+ shuffle: function(t, mask) {
740
+ var _x = (mask) & 0x3;
741
+ var _y = (mask >> 2) & 0x3;
742
+ var _z = (mask >> 4) & 0x3;
743
+ var _w = (mask >> 6) & 0x3;
744
+ return new int32x4(t.storage_[_x], t.storage_[_y], t.storage_[_z],
745
+ t.storage_[_w]);
746
+ },
747
+ /**
748
+ * @param {int32x4} t1 An instance of float32x4 to be shuffled. XY lanes in result
749
+ * @param {int32x4} t2 An instance of float32x4 to be shuffled. ZW lanes in result
750
+ * @param {integer} mask One of the 256 shuffle masks, for example, SIMD.XXXX.
751
+ * @return {int32x4} New instance of float32x4 with lanes shuffled.
752
+ */
753
+ shuffleMix: function(t1, t2, mask) {
754
+ var _x = (mask) & 0x3;
755
+ var _y = (mask >> 2) & 0x3;
756
+ var _z = (mask >> 4) & 0x3;
757
+ var _w = (mask >> 6) & 0x3;
758
+ return new int32x4(t1.storage_[_x], t1.storage_[_y], t2.storage_[_z],
759
+ t2.storage_[_w]);
760
+ },
761
+ /**
762
+ * @param {float32x4}
763
+ */
764
+ select: function(t, trueValue, falseValue) {
765
+ var tv = SIMD.float32x4.bitsToInt32x4(trueValue);
766
+ var fv = SIMD.float32x4.bitsToInt32x4(falseValue);
767
+ var tr = SIMD.int32x4.and(t, tv);
768
+ var fr = SIMD.int32x4.and(SIMD.int32x4.not(t), fv);
769
+ return SIMD.int32x4.bitsToFloat32x4(SIMD.int32x4.or(tr, fr));
770
+ },
771
+ /**
772
+ * @param {int32x4} t An instance of int32x4.
773
+ * @param {integer} 32-bit value used for x lane.
774
+ * @return {int32x4} New instance of int32x4 with the values in t and
775
+ * x lane replaced with {x}.
776
+ */
777
+ withX: function(t, x) {
778
+ return new int32x4(x, t.y, t.z, t.w);
779
+ },
780
+ /**
781
+ * param {int32x4} t An instance of int32x4.
782
+ * @param {integer} 32-bit value used for y lane.
783
+ * @return {int32x4} New instance of int32x4 with the values in t and
784
+ * y lane replaced with {y}.
785
+ */
786
+ withY: function(t, y) {
787
+ return new int32x4(t.x, y, t.z, t.w);
788
+ },
789
+ /**
790
+ * @param {int32x4} t An instance of int32x4.
791
+ * @param {integer} 32-bit value used for z lane.
792
+ * @return {int32x4} New instance of int32x4 with the values in t and
793
+ * z lane replaced with {z}.
794
+ */
795
+ withZ: function(t, z) {
796
+ return new int32x4(t.x, t.y, z, t.w);
797
+ },
798
+ /**
799
+ * @param {integer} 32-bit value used for w lane.
800
+ * @return {int32x4} New instance of int32x4 with the values in t and
801
+ * w lane replaced with {w}.
802
+ */
803
+ withW: function(t, w) {
804
+ return new int32x4(t.x, t.y, t.z, w);
805
+ },
806
+ /**
807
+ * @param {int32x4} t An instance of int32x4.
808
+ * @param {boolean} x flag used for x lane.
809
+ * @return {int32x4} New instance of int32x4 with the values in t and
810
+ * x lane replaced with {x}.
811
+ */
812
+ withFlagX: function(t, flagX) {
813
+ var x = flagX ? 0xFFFFFFFF : 0x0;
814
+ return new int32x4(x, t.y, t.z, t.w);
815
+ },
816
+ /**
817
+ * @param {int32x4} t An instance of int32x4.
818
+ * @param {boolean} y flag used for y lane.
819
+ * @return {int32x4} New instance of int32x4 with the values in t and
820
+ * y lane replaced with {y}.
821
+ */
822
+ withFlagY: function(t, flagY) {
823
+ var y = flagY ? 0xFFFFFFFF : 0x0;
824
+ return new int32x4(t.x, y, t.z, t.w);
825
+ },
826
+ /**
827
+ * @param {int32x4} t An instance of int32x4.
828
+ * @param {boolean} z flag used for z lane.
829
+ * @return {int32x4} New instance of int32x4 with the values in t and
830
+ * z lane replaced with {z}.
831
+ */
832
+ withFlagZ: function(t, flagZ) {
833
+ var z = flagZ ? 0xFFFFFFFF : 0x0;
834
+ return new int32x4(t.x, t.y, z, t.w);
835
+ },
836
+ /**
837
+ * @param {int32x4} t An instance of int32x4.
838
+ * @param {boolean} w flag used for w lane.
839
+ * @return {int32x4} New instance of int32x4 with the values in t and
840
+ * w lane replaced with {w}.
841
+ */
842
+ withFlagW: function(t, flagW) {
843
+ var w = flagW ? 0xFFFFFFFF : 0x0;
844
+ return new int32x4(t.x, t.y, t.z, w);
845
+ },
846
+ /**
847
+ * @param {int32x4} t An instance of int32x4.
848
+ * @return {float32x4} a bit-wise copy of t as a float32x4.
849
+ */
850
+ bitsToFloat32x4: function(t) {
851
+ var temp_storage = new Int32Array([t.storage_[0], t.storage_[1], t.storage_[2], t.storage_[3]]);
852
+ var alias = new Float32Array(temp_storage.buffer);
853
+ var fx4 = float32x4.zero();
854
+ fx4.storage_ = alias;
855
+ return fx4;
856
+ },
857
+ /**
858
+ * @param {int32x4} t An instance of int32x4.
859
+ * @return {float32x4} with a float to integer conversion copy of t.
860
+ */
861
+ toFloat32x4: function(t) {
862
+ var a = float32x4.zero();
863
+ a.storage_[0] = t.storage_[0];
864
+ a.storage_[1] = t.storage_[1];
865
+ a.storage_[2] = t.storage_[2];
866
+ a.storage_[3] = t.storage_[3];
867
+ return a;
868
+ }
698
869
  }
699
870
  }
700
871
  })();
@@ -955,4 +1126,3 @@ Object.defineProperty(SIMD, 'WWWX', { get: function() { return 0x3F; } });
955
1126
  Object.defineProperty(SIMD, 'WWWY', { get: function() { return 0x7F; } });
956
1127
  Object.defineProperty(SIMD, 'WWWZ', { get: function() { return 0xBF; } });
957
1128
  Object.defineProperty(SIMD, 'WWWW', { get: function() { return 0xFF; } });
958
-