webruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1364) hide show
  1. checksums.yaml +7 -0
  2. data/bin/webruby +36 -0
  3. data/driver/driver.c +50 -0
  4. data/driver/main.c +40 -0
  5. data/lib/webruby/app.rb +13 -0
  6. data/lib/webruby/config.rb +61 -0
  7. data/lib/webruby/environment.rb +32 -0
  8. data/lib/webruby/rake/files.rake +66 -0
  9. data/lib/webruby/rake/general.rake +22 -0
  10. data/lib/webruby/rake/mruby.rake +44 -0
  11. data/lib/webruby/utility.rb +132 -0
  12. data/lib/webruby.rb +10 -0
  13. data/modules/emscripten/AUTHORS +89 -0
  14. data/modules/emscripten/LICENSE +68 -0
  15. data/modules/emscripten/README.markdown +14 -0
  16. data/modules/emscripten/cmake/Platform/Emscripten.cmake +61 -0
  17. data/modules/emscripten/cmake/Platform/Emscripten_unix.cmake +24 -0
  18. data/modules/emscripten/em++ +12 -0
  19. data/modules/emscripten/em++.bat +2 -0
  20. data/modules/emscripten/em-config +24 -0
  21. data/modules/emscripten/em-config.bat +2 -0
  22. data/modules/emscripten/emar +24 -0
  23. data/modules/emscripten/emar.bat +2 -0
  24. data/modules/emscripten/emcc +1744 -0
  25. data/modules/emscripten/emcc.bat +2 -0
  26. data/modules/emscripten/emcc.py +5 -0
  27. data/modules/emscripten/emconfigure +27 -0
  28. data/modules/emscripten/emconfigure.bat +2 -0
  29. data/modules/emscripten/emlibtool +11 -0
  30. data/modules/emscripten/emlibtool.bat +2 -0
  31. data/modules/emscripten/emlink.py +293 -0
  32. data/modules/emscripten/emmake +29 -0
  33. data/modules/emscripten/emmake.bat +2 -0
  34. data/modules/emscripten/emranlib +9 -0
  35. data/modules/emscripten/emranlib.bat +2 -0
  36. data/modules/emscripten/emscons +20 -0
  37. data/modules/emscripten/emscripten.py +835 -0
  38. data/modules/emscripten/patches/README +4 -0
  39. data/modules/emscripten/patches/series +2 -0
  40. data/modules/emscripten/scons-tools/closure.py +28 -0
  41. data/modules/emscripten/scons-tools/emscripten.py +359 -0
  42. data/modules/emscripten/scons-tools/llvm.py +33 -0
  43. data/modules/emscripten/src/analyzer.js +1695 -0
  44. data/modules/emscripten/src/compiler.html +48 -0
  45. data/modules/emscripten/src/compiler.js +298 -0
  46. data/modules/emscripten/src/corruptionCheck.js +98 -0
  47. data/modules/emscripten/src/determinstic.js +20 -0
  48. data/modules/emscripten/src/embind/embind.js +1677 -0
  49. data/modules/emscripten/src/embind/emval.js +283 -0
  50. data/modules/emscripten/src/experimental/allow_loopvars_from_memsetcpy_inasm.diff +97 -0
  51. data/modules/emscripten/src/experimental/batching.diff +44 -0
  52. data/modules/emscripten/src/experimental/functypeopt.diff +113 -0
  53. data/modules/emscripten/src/experimental/multiple_heaps.diff +175 -0
  54. data/modules/emscripten/src/experimental/noncallgraphprofiling.diff +197 -0
  55. data/modules/emscripten/src/experimental/optimize_memcpy_for_ta1.diff +124 -0
  56. data/modules/emscripten/src/experimental/remove__label__s.diff +140 -0
  57. data/modules/emscripten/src/experimental/renderer_cache_hash.diff +99 -0
  58. data/modules/emscripten/src/experimental/sdl_key_forwarding.diff +57 -0
  59. data/modules/emscripten/src/experimental/simplifyGeneratedFunctionsDetection.diff +336 -0
  60. data/modules/emscripten/src/experimental/stringCache.diff +147 -0
  61. data/modules/emscripten/src/fastLong.js +299 -0
  62. data/modules/emscripten/src/framework.js +257 -0
  63. data/modules/emscripten/src/gl-matrix.js +1952 -0
  64. data/modules/emscripten/src/headless.js +904 -0
  65. data/modules/emscripten/src/intertyper.js +1050 -0
  66. data/modules/emscripten/src/jsifier.js +1827 -0
  67. data/modules/emscripten/src/library.js +8270 -0
  68. data/modules/emscripten/src/library_browser.js +911 -0
  69. data/modules/emscripten/src/library_egl.js +491 -0
  70. data/modules/emscripten/src/library_gc.js +236 -0
  71. data/modules/emscripten/src/library_gl.js +4452 -0
  72. data/modules/emscripten/src/library_glfw.js +576 -0
  73. data/modules/emscripten/src/library_glut.js +449 -0
  74. data/modules/emscripten/src/library_jansson.js +320 -0
  75. data/modules/emscripten/src/library_openal.js +602 -0
  76. data/modules/emscripten/src/library_sdl.js +2024 -0
  77. data/modules/emscripten/src/library_strtok_r.c +97 -0
  78. data/modules/emscripten/src/library_xlib.js +23 -0
  79. data/modules/emscripten/src/long.js +1609 -0
  80. data/modules/emscripten/src/modules.js +491 -0
  81. data/modules/emscripten/src/parseTools.js +2474 -0
  82. data/modules/emscripten/src/postamble.js +170 -0
  83. data/modules/emscripten/src/postamble_sharedlib.js +16 -0
  84. data/modules/emscripten/src/preamble.js +914 -0
  85. data/modules/emscripten/src/preamble_sharedlib.js +25 -0
  86. data/modules/emscripten/src/relooper/README.markdown +14 -0
  87. data/modules/emscripten/src/relooper/Relooper.cpp +1236 -0
  88. data/modules/emscripten/src/relooper/Relooper.h +250 -0
  89. data/modules/emscripten/src/relooper/doit.sh +70 -0
  90. data/modules/emscripten/src/relooper/emscripten/glue.js +57 -0
  91. data/modules/emscripten/src/relooper/emscripten/test.js +44 -0
  92. data/modules/emscripten/src/relooper/fuzzer.py +116 -0
  93. data/modules/emscripten/src/relooper/ministring.h +35 -0
  94. data/modules/emscripten/src/relooper/paper.pdf +0 -0
  95. data/modules/emscripten/src/relooper/test.cpp +262 -0
  96. data/modules/emscripten/src/relooper/test.txt +155 -0
  97. data/modules/emscripten/src/relooper/test2.c +44 -0
  98. data/modules/emscripten/src/relooper/test2.txt +12 -0
  99. data/modules/emscripten/src/relooper/test3.c +42 -0
  100. data/modules/emscripten/src/relooper/test3.txt +27 -0
  101. data/modules/emscripten/src/relooper/test4.cpp +40 -0
  102. data/modules/emscripten/src/relooper/test4.txt +23 -0
  103. data/modules/emscripten/src/relooper/test5.cpp +40 -0
  104. data/modules/emscripten/src/relooper/test5.txt +32 -0
  105. data/modules/emscripten/src/relooper/test6.cpp +31 -0
  106. data/modules/emscripten/src/relooper/test6.txt +12 -0
  107. data/modules/emscripten/src/relooper/test_dead.cpp +28 -0
  108. data/modules/emscripten/src/relooper/test_dead.txt +9 -0
  109. data/modules/emscripten/src/relooper/test_debug.cpp +30 -0
  110. data/modules/emscripten/src/relooper/test_debug.txt +128 -0
  111. data/modules/emscripten/src/relooper/test_fuzz1.cpp +52 -0
  112. data/modules/emscripten/src/relooper/test_fuzz1.txt +32 -0
  113. data/modules/emscripten/src/relooper/test_fuzz2.cpp +34 -0
  114. data/modules/emscripten/src/relooper/test_fuzz2.txt +13 -0
  115. data/modules/emscripten/src/relooper/test_fuzz3.cpp +36 -0
  116. data/modules/emscripten/src/relooper/test_fuzz3.txt +9 -0
  117. data/modules/emscripten/src/relooper/test_fuzz4.cpp +38 -0
  118. data/modules/emscripten/src/relooper/test_fuzz4.txt +19 -0
  119. data/modules/emscripten/src/relooper/test_fuzz5.cpp +57 -0
  120. data/modules/emscripten/src/relooper/test_fuzz5.txt +52 -0
  121. data/modules/emscripten/src/relooper/test_fuzz6.cpp +322 -0
  122. data/modules/emscripten/src/relooper/test_fuzz6.txt +108 -0
  123. data/modules/emscripten/src/relooper/test_inf.cpp +813 -0
  124. data/modules/emscripten/src/relooper/test_inf.txt +385 -0
  125. data/modules/emscripten/src/relooper/testit.sh +62 -0
  126. data/modules/emscripten/src/relooper/updateit.sh +17 -0
  127. data/modules/emscripten/src/relooper.js +11516 -0
  128. data/modules/emscripten/src/relooper.js.raw.js +11511 -0
  129. data/modules/emscripten/src/runtime.js +546 -0
  130. data/modules/emscripten/src/settings.js +1284 -0
  131. data/modules/emscripten/src/shell.html +92 -0
  132. data/modules/emscripten/src/shell.js +153 -0
  133. data/modules/emscripten/src/shell_sharedlib.js +12 -0
  134. data/modules/emscripten/src/socket.io.js +3870 -0
  135. data/modules/emscripten/src/utility.js +379 -0
  136. data/modules/emscripten/src/wrtcp.js +821 -0
  137. data/modules/emscripten/system/include/AL/al.h +172 -0
  138. data/modules/emscripten/system/include/AL/alc.h +84 -0
  139. data/modules/emscripten/system/include/EGL/egl.h +329 -0
  140. data/modules/emscripten/system/include/EGL/eglext.h +398 -0
  141. data/modules/emscripten/system/include/EGL/eglplatform.h +141 -0
  142. data/modules/emscripten/system/include/GL/freeglut_std.h +628 -0
  143. data/modules/emscripten/system/include/GL/gl.h +2241 -0
  144. data/modules/emscripten/system/include/GL/glew.h +6 -0
  145. data/modules/emscripten/system/include/GL/glext.h +11127 -0
  146. data/modules/emscripten/system/include/GL/glfw.h +518 -0
  147. data/modules/emscripten/system/include/GL/glu.h +353 -0
  148. data/modules/emscripten/system/include/GL/glut.h +21 -0
  149. data/modules/emscripten/system/include/GLES/gl.h +770 -0
  150. data/modules/emscripten/system/include/GLES/glext.h +1278 -0
  151. data/modules/emscripten/system/include/GLES/glplatform.h +30 -0
  152. data/modules/emscripten/system/include/GLES2/gl2.h +621 -0
  153. data/modules/emscripten/system/include/GLES2/gl2ext.h +803 -0
  154. data/modules/emscripten/system/include/GLES2/gl2platform.h +30 -0
  155. data/modules/emscripten/system/include/KHR/khrplatform.h +277 -0
  156. data/modules/emscripten/system/include/SDL/COPYING +19 -0
  157. data/modules/emscripten/system/include/SDL/SDL.h +162 -0
  158. data/modules/emscripten/system/include/SDL/SDL_assert.h +241 -0
  159. data/modules/emscripten/system/include/SDL/SDL_atomic.h +318 -0
  160. data/modules/emscripten/system/include/SDL/SDL_audio.h +509 -0
  161. data/modules/emscripten/system/include/SDL/SDL_blendmode.h +60 -0
  162. data/modules/emscripten/system/include/SDL/SDL_clipboard.h +75 -0
  163. data/modules/emscripten/system/include/SDL/SDL_compat.h +365 -0
  164. data/modules/emscripten/system/include/SDL/SDL_config.h +48 -0
  165. data/modules/emscripten/system/include/SDL/SDL_config.h.in +297 -0
  166. data/modules/emscripten/system/include/SDL/SDL_config_android.h +133 -0
  167. data/modules/emscripten/system/include/SDL/SDL_config_iphoneos.h +148 -0
  168. data/modules/emscripten/system/include/SDL/SDL_config_macosx.h +172 -0
  169. data/modules/emscripten/system/include/SDL/SDL_config_minimal.h +74 -0
  170. data/modules/emscripten/system/include/SDL/SDL_config_nintendods.h +129 -0
  171. data/modules/emscripten/system/include/SDL/SDL_config_pandora.h +125 -0
  172. data/modules/emscripten/system/include/SDL/SDL_config_windows.h +207 -0
  173. data/modules/emscripten/system/include/SDL/SDL_config_wiz.h +119 -0
  174. data/modules/emscripten/system/include/SDL/SDL_copying.h +20 -0
  175. data/modules/emscripten/system/include/SDL/SDL_cpuinfo.h +150 -0
  176. data/modules/emscripten/system/include/SDL/SDL_endian.h +248 -0
  177. data/modules/emscripten/system/include/SDL/SDL_error.h +77 -0
  178. data/modules/emscripten/system/include/SDL/SDL_events.h +639 -0
  179. data/modules/emscripten/system/include/SDL/SDL_gesture.h +91 -0
  180. data/modules/emscripten/system/include/SDL/SDL_gfxPrimitives.h +246 -0
  181. data/modules/emscripten/system/include/SDL/SDL_haptic.h +1200 -0
  182. data/modules/emscripten/system/include/SDL/SDL_hints.h +206 -0
  183. data/modules/emscripten/system/include/SDL/SDL_image.h +138 -0
  184. data/modules/emscripten/system/include/SDL/SDL_input.h +87 -0
  185. data/modules/emscripten/system/include/SDL/SDL_joystick.h +208 -0
  186. data/modules/emscripten/system/include/SDL/SDL_keyboard.h +169 -0
  187. data/modules/emscripten/system/include/SDL/SDL_keycode.h +344 -0
  188. data/modules/emscripten/system/include/SDL/SDL_loadso.h +85 -0
  189. data/modules/emscripten/system/include/SDL/SDL_log.h +211 -0
  190. data/modules/emscripten/system/include/SDL/SDL_main.h +98 -0
  191. data/modules/emscripten/system/include/SDL/SDL_mixer.h +634 -0
  192. data/modules/emscripten/system/include/SDL/SDL_mouse.h +213 -0
  193. data/modules/emscripten/system/include/SDL/SDL_mutex.h +248 -0
  194. data/modules/emscripten/system/include/SDL/SDL_name.h +11 -0
  195. data/modules/emscripten/system/include/SDL/SDL_opengl.h +11116 -0
  196. data/modules/emscripten/system/include/SDL/SDL_opengles.h +38 -0
  197. data/modules/emscripten/system/include/SDL/SDL_opengles2.h +38 -0
  198. data/modules/emscripten/system/include/SDL/SDL_pixels.h +423 -0
  199. data/modules/emscripten/system/include/SDL/SDL_platform.h +160 -0
  200. data/modules/emscripten/system/include/SDL/SDL_power.h +79 -0
  201. data/modules/emscripten/system/include/SDL/SDL_quit.h +58 -0
  202. data/modules/emscripten/system/include/SDL/SDL_rect.h +136 -0
  203. data/modules/emscripten/system/include/SDL/SDL_render.h +615 -0
  204. data/modules/emscripten/system/include/SDL/SDL_revision.h +2 -0
  205. data/modules/emscripten/system/include/SDL/SDL_revision.h.orig +2 -0
  206. data/modules/emscripten/system/include/SDL/SDL_rotozoom.h +123 -0
  207. data/modules/emscripten/system/include/SDL/SDL_rwops.h +220 -0
  208. data/modules/emscripten/system/include/SDL/SDL_scancode.h +398 -0
  209. data/modules/emscripten/system/include/SDL/SDL_shape.h +147 -0
  210. data/modules/emscripten/system/include/SDL/SDL_stdinc.h +764 -0
  211. data/modules/emscripten/system/include/SDL/SDL_surface.h +499 -0
  212. data/modules/emscripten/system/include/SDL/SDL_syswm.h +241 -0
  213. data/modules/emscripten/system/include/SDL/SDL_thread.h +182 -0
  214. data/modules/emscripten/system/include/SDL/SDL_timer.h +108 -0
  215. data/modules/emscripten/system/include/SDL/SDL_touch.h +124 -0
  216. data/modules/emscripten/system/include/SDL/SDL_ttf.h +249 -0
  217. data/modules/emscripten/system/include/SDL/SDL_types.h +29 -0
  218. data/modules/emscripten/system/include/SDL/SDL_version.h +166 -0
  219. data/modules/emscripten/system/include/SDL/SDL_video.h +820 -0
  220. data/modules/emscripten/system/include/SDL/begin_code.h +135 -0
  221. data/modules/emscripten/system/include/SDL/close_code.h +37 -0
  222. data/modules/emscripten/system/include/X11/X.h +717 -0
  223. data/modules/emscripten/system/include/X11/Xatom.h +79 -0
  224. data/modules/emscripten/system/include/X11/Xfuncproto.h +127 -0
  225. data/modules/emscripten/system/include/X11/Xlib.h +4023 -0
  226. data/modules/emscripten/system/include/X11/Xosdefs.h +116 -0
  227. data/modules/emscripten/system/include/X11/Xutil.h +826 -0
  228. data/modules/emscripten/system/include/X11/keysym.h +73 -0
  229. data/modules/emscripten/system/include/X11/keysymdef.h +2389 -0
  230. data/modules/emscripten/system/include/bsd/float.h +91 -0
  231. data/modules/emscripten/system/include/bsd/readme.txt +2 -0
  232. data/modules/emscripten/system/include/bsd/sys/mman.h +180 -0
  233. data/modules/emscripten/system/include/bsd/sys/utsname.h +70 -0
  234. data/modules/emscripten/system/include/dlfcn.h +31 -0
  235. data/modules/emscripten/system/include/emscripten/bind.h +1210 -0
  236. data/modules/emscripten/system/include/emscripten/emscripten.h +388 -0
  237. data/modules/emscripten/system/include/emscripten/val.h +311 -0
  238. data/modules/emscripten/system/include/emscripten/wire.h +393 -0
  239. data/modules/emscripten/system/include/err.h +95 -0
  240. data/modules/emscripten/system/include/execinfo.h +44 -0
  241. data/modules/emscripten/system/include/features.h +3 -0
  242. data/modules/emscripten/system/include/gc.h +70 -0
  243. data/modules/emscripten/system/include/gfx/png.h +3798 -0
  244. data/modules/emscripten/system/include/gfx/pngconf.h +1665 -0
  245. data/modules/emscripten/system/include/gfx/tiff.h +654 -0
  246. data/modules/emscripten/system/include/gfx/tiffconf.h +104 -0
  247. data/modules/emscripten/system/include/gfx/tiffio.h +526 -0
  248. data/modules/emscripten/system/include/gfx/tiffvers.h +9 -0
  249. data/modules/emscripten/system/include/jansson.h +323 -0
  250. data/modules/emscripten/system/include/jansson_config.h +54 -0
  251. data/modules/emscripten/system/include/libc/_ansi.h +135 -0
  252. data/modules/emscripten/system/include/libc/_syslist.h +40 -0
  253. data/modules/emscripten/system/include/libc/alloca.h +21 -0
  254. data/modules/emscripten/system/include/libc/ar.h +69 -0
  255. data/modules/emscripten/system/include/libc/argz.h +33 -0
  256. data/modules/emscripten/system/include/libc/assert.h +46 -0
  257. data/modules/emscripten/system/include/libc/complex.h +124 -0
  258. data/modules/emscripten/system/include/libc/ctype.h +196 -0
  259. data/modules/emscripten/system/include/libc/dirent.h +16 -0
  260. data/modules/emscripten/system/include/libc/endian.h +3 -0
  261. data/modules/emscripten/system/include/libc/envlock.h +15 -0
  262. data/modules/emscripten/system/include/libc/envz.h +16 -0
  263. data/modules/emscripten/system/include/libc/errno.h +11 -0
  264. data/modules/emscripten/system/include/libc/fastmath.h +13 -0
  265. data/modules/emscripten/system/include/libc/fcntl.h +1 -0
  266. data/modules/emscripten/system/include/libc/fnmatch.h +55 -0
  267. data/modules/emscripten/system/include/libc/getopt.h +196 -0
  268. data/modules/emscripten/system/include/libc/glob.h +89 -0
  269. data/modules/emscripten/system/include/libc/grp.h +94 -0
  270. data/modules/emscripten/system/include/libc/iconv.h +62 -0
  271. data/modules/emscripten/system/include/libc/ieeefp.h +256 -0
  272. data/modules/emscripten/system/include/libc/ifaddrs.h +64 -0
  273. data/modules/emscripten/system/include/libc/inttypes.h +290 -0
  274. data/modules/emscripten/system/include/libc/iso646.h +43 -0
  275. data/modules/emscripten/system/include/libc/langinfo.h +316 -0
  276. data/modules/emscripten/system/include/libc/libgen.h +23 -0
  277. data/modules/emscripten/system/include/libc/limits.h +155 -0
  278. data/modules/emscripten/system/include/libc/locale.h +80 -0
  279. data/modules/emscripten/system/include/libc/machine/_default_types.h +121 -0
  280. data/modules/emscripten/system/include/libc/machine/_types.h +8 -0
  281. data/modules/emscripten/system/include/libc/machine/ansi.h +1 -0
  282. data/modules/emscripten/system/include/libc/machine/endian.h +31 -0
  283. data/modules/emscripten/system/include/libc/machine/fastmath.h +100 -0
  284. data/modules/emscripten/system/include/libc/machine/ieeefp.h +376 -0
  285. data/modules/emscripten/system/include/libc/machine/malloc.h +8 -0
  286. data/modules/emscripten/system/include/libc/machine/param.h +1 -0
  287. data/modules/emscripten/system/include/libc/machine/setjmp-dj.h +43 -0
  288. data/modules/emscripten/system/include/libc/machine/setjmp.h +361 -0
  289. data/modules/emscripten/system/include/libc/machine/stdlib.h +8 -0
  290. data/modules/emscripten/system/include/libc/machine/termios.h +1 -0
  291. data/modules/emscripten/system/include/libc/machine/time.h +19 -0
  292. data/modules/emscripten/system/include/libc/machine/types.h +30 -0
  293. data/modules/emscripten/system/include/libc/malloc.h +169 -0
  294. data/modules/emscripten/system/include/libc/math.h +594 -0
  295. data/modules/emscripten/system/include/libc/newlib.h +2 -0
  296. data/modules/emscripten/system/include/libc/paths.h +7 -0
  297. data/modules/emscripten/system/include/libc/process.h +44 -0
  298. data/modules/emscripten/system/include/libc/pthread.h +362 -0
  299. data/modules/emscripten/system/include/libc/pwd.h +78 -0
  300. data/modules/emscripten/system/include/libc/readme.txt +3 -0
  301. data/modules/emscripten/system/include/libc/reent.h +183 -0
  302. data/modules/emscripten/system/include/libc/regdef.h +7 -0
  303. data/modules/emscripten/system/include/libc/regex.h +102 -0
  304. data/modules/emscripten/system/include/libc/sched.h +97 -0
  305. data/modules/emscripten/system/include/libc/search.h +59 -0
  306. data/modules/emscripten/system/include/libc/setjmp.h +20 -0
  307. data/modules/emscripten/system/include/libc/signal.h +30 -0
  308. data/modules/emscripten/system/include/libc/stdarg.h +50 -0
  309. data/modules/emscripten/system/include/libc/stddef.h +64 -0
  310. data/modules/emscripten/system/include/libc/stdint.h +493 -0
  311. data/modules/emscripten/system/include/libc/stdio.h +694 -0
  312. data/modules/emscripten/system/include/libc/stdlib.h +230 -0
  313. data/modules/emscripten/system/include/libc/string.h +105 -0
  314. data/modules/emscripten/system/include/libc/strings.h +35 -0
  315. data/modules/emscripten/system/include/libc/sys/_default_fcntl.h +223 -0
  316. data/modules/emscripten/system/include/libc/sys/_types.h +93 -0
  317. data/modules/emscripten/system/include/libc/sys/cdefs.h +123 -0
  318. data/modules/emscripten/system/include/libc/sys/config.h +255 -0
  319. data/modules/emscripten/system/include/libc/sys/custom_file.h +2 -0
  320. data/modules/emscripten/system/include/libc/sys/dir.h +10 -0
  321. data/modules/emscripten/system/include/libc/sys/dirent.h +58 -0
  322. data/modules/emscripten/system/include/libc/sys/errno.h +190 -0
  323. data/modules/emscripten/system/include/libc/sys/fcntl.h +4 -0
  324. data/modules/emscripten/system/include/libc/sys/features.h +212 -0
  325. data/modules/emscripten/system/include/libc/sys/file.h +2 -0
  326. data/modules/emscripten/system/include/libc/sys/iconvnls.h +77 -0
  327. data/modules/emscripten/system/include/libc/sys/lock.h +24 -0
  328. data/modules/emscripten/system/include/libc/sys/param.h +25 -0
  329. data/modules/emscripten/system/include/libc/sys/queue.h +471 -0
  330. data/modules/emscripten/system/include/libc/sys/reent.h +843 -0
  331. data/modules/emscripten/system/include/libc/sys/resource.h +59 -0
  332. data/modules/emscripten/system/include/libc/sys/sched.h +67 -0
  333. data/modules/emscripten/system/include/libc/sys/signal.h +314 -0
  334. data/modules/emscripten/system/include/libc/sys/stat.h +222 -0
  335. data/modules/emscripten/system/include/libc/sys/stdio.h +27 -0
  336. data/modules/emscripten/system/include/libc/sys/string.h +2 -0
  337. data/modules/emscripten/system/include/libc/sys/syslimits.h +65 -0
  338. data/modules/emscripten/system/include/libc/sys/termios.h +280 -0
  339. data/modules/emscripten/system/include/libc/sys/time.h +85 -0
  340. data/modules/emscripten/system/include/libc/sys/timeb.h +39 -0
  341. data/modules/emscripten/system/include/libc/sys/times.h +28 -0
  342. data/modules/emscripten/system/include/libc/sys/ttydefaults.h +97 -0
  343. data/modules/emscripten/system/include/libc/sys/types.h +481 -0
  344. data/modules/emscripten/system/include/libc/sys/unistd.h +514 -0
  345. data/modules/emscripten/system/include/libc/sys/utime.h +26 -0
  346. data/modules/emscripten/system/include/libc/sys/wait.h +40 -0
  347. data/modules/emscripten/system/include/libc/tar.h +39 -0
  348. data/modules/emscripten/system/include/libc/termios.h +7 -0
  349. data/modules/emscripten/system/include/libc/time.h +273 -0
  350. data/modules/emscripten/system/include/libc/unctrl.h +46 -0
  351. data/modules/emscripten/system/include/libc/unistd.h +6 -0
  352. data/modules/emscripten/system/include/libc/utime.h +12 -0
  353. data/modules/emscripten/system/include/libc/utmp.h +8 -0
  354. data/modules/emscripten/system/include/libc/wchar.h +194 -0
  355. data/modules/emscripten/system/include/libc/wctype.h +47 -0
  356. data/modules/emscripten/system/include/libc/wordexp.h +53 -0
  357. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +91 -0
  358. data/modules/emscripten/system/include/libcxx/LICENSE.txt +76 -0
  359. data/modules/emscripten/system/include/libcxx/__bit_reference +1268 -0
  360. data/modules/emscripten/system/include/libcxx/__config +485 -0
  361. data/modules/emscripten/system/include/libcxx/__debug +193 -0
  362. data/modules/emscripten/system/include/libcxx/__functional_03 +2130 -0
  363. data/modules/emscripten/system/include/libcxx/__functional_base +437 -0
  364. data/modules/emscripten/system/include/libcxx/__functional_base_03 +1087 -0
  365. data/modules/emscripten/system/include/libcxx/__hash_table +1945 -0
  366. data/modules/emscripten/system/include/libcxx/__locale +1435 -0
  367. data/modules/emscripten/system/include/libcxx/__mutex_base +438 -0
  368. data/modules/emscripten/system/include/libcxx/__split_buffer +654 -0
  369. data/modules/emscripten/system/include/libcxx/__sso_allocator +77 -0
  370. data/modules/emscripten/system/include/libcxx/__std_stream +317 -0
  371. data/modules/emscripten/system/include/libcxx/__tree +2293 -0
  372. data/modules/emscripten/system/include/libcxx/__tuple +305 -0
  373. data/modules/emscripten/system/include/libcxx/__tuple_03 +27 -0
  374. data/modules/emscripten/system/include/libcxx/__undef_min_max +19 -0
  375. data/modules/emscripten/system/include/libcxx/algorithm +5458 -0
  376. data/modules/emscripten/system/include/libcxx/array +341 -0
  377. data/modules/emscripten/system/include/libcxx/atomic +1521 -0
  378. data/modules/emscripten/system/include/libcxx/bitset +1081 -0
  379. data/modules/emscripten/system/include/libcxx/cassert +25 -0
  380. data/modules/emscripten/system/include/libcxx/ccomplex +29 -0
  381. data/modules/emscripten/system/include/libcxx/cctype +164 -0
  382. data/modules/emscripten/system/include/libcxx/cerrno +393 -0
  383. data/modules/emscripten/system/include/libcxx/cfenv +82 -0
  384. data/modules/emscripten/system/include/libcxx/cfloat +78 -0
  385. data/modules/emscripten/system/include/libcxx/chrono +898 -0
  386. data/modules/emscripten/system/include/libcxx/cinttypes +259 -0
  387. data/modules/emscripten/system/include/libcxx/ciso646 +25 -0
  388. data/modules/emscripten/system/include/libcxx/climits +48 -0
  389. data/modules/emscripten/system/include/libcxx/clocale +53 -0
  390. data/modules/emscripten/system/include/libcxx/cmath +1683 -0
  391. data/modules/emscripten/system/include/libcxx/codecvt +547 -0
  392. data/modules/emscripten/system/include/libcxx/complex +1526 -0
  393. data/modules/emscripten/system/include/libcxx/complex.h +35 -0
  394. data/modules/emscripten/system/include/libcxx/condition_variable +256 -0
  395. data/modules/emscripten/system/include/libcxx/csetjmp +52 -0
  396. data/modules/emscripten/system/include/libcxx/csignal +58 -0
  397. data/modules/emscripten/system/include/libcxx/cstdarg +48 -0
  398. data/modules/emscripten/system/include/libcxx/cstdbool +32 -0
  399. data/modules/emscripten/system/include/libcxx/cstddef +103 -0
  400. data/modules/emscripten/system/include/libcxx/cstdint +191 -0
  401. data/modules/emscripten/system/include/libcxx/cstdio +175 -0
  402. data/modules/emscripten/system/include/libcxx/cstdlib +172 -0
  403. data/modules/emscripten/system/include/libcxx/cstring +112 -0
  404. data/modules/emscripten/system/include/libcxx/ctgmath +29 -0
  405. data/modules/emscripten/system/include/libcxx/ctime +72 -0
  406. data/modules/emscripten/system/include/libcxx/cwchar +208 -0
  407. data/modules/emscripten/system/include/libcxx/cwctype +213 -0
  408. data/modules/emscripten/system/include/libcxx/deque +2846 -0
  409. data/modules/emscripten/system/include/libcxx/exception +250 -0
  410. data/modules/emscripten/system/include/libcxx/ext/__hash +46 -0
  411. data/modules/emscripten/system/include/libcxx/ext/hash_map +1003 -0
  412. data/modules/emscripten/system/include/libcxx/ext/hash_set +657 -0
  413. data/modules/emscripten/system/include/libcxx/forward_list +1636 -0
  414. data/modules/emscripten/system/include/libcxx/fstream +1415 -0
  415. data/modules/emscripten/system/include/libcxx/functional +2063 -0
  416. data/modules/emscripten/system/include/libcxx/future +2505 -0
  417. data/modules/emscripten/system/include/libcxx/initializer_list +105 -0
  418. data/modules/emscripten/system/include/libcxx/iomanip +504 -0
  419. data/modules/emscripten/system/include/libcxx/ios +988 -0
  420. data/modules/emscripten/system/include/libcxx/iosfwd +194 -0
  421. data/modules/emscripten/system/include/libcxx/iostream +60 -0
  422. data/modules/emscripten/system/include/libcxx/istream +1713 -0
  423. data/modules/emscripten/system/include/libcxx/iterator +1869 -0
  424. data/modules/emscripten/system/include/libcxx/limits +809 -0
  425. data/modules/emscripten/system/include/libcxx/list +2275 -0
  426. data/modules/emscripten/system/include/libcxx/locale +4591 -0
  427. data/modules/emscripten/system/include/libcxx/map +1924 -0
  428. data/modules/emscripten/system/include/libcxx/memory +5437 -0
  429. data/modules/emscripten/system/include/libcxx/mutex +566 -0
  430. data/modules/emscripten/system/include/libcxx/new +117 -0
  431. data/modules/emscripten/system/include/libcxx/numeric +197 -0
  432. data/modules/emscripten/system/include/libcxx/ostream +1286 -0
  433. data/modules/emscripten/system/include/libcxx/queue +717 -0
  434. data/modules/emscripten/system/include/libcxx/random +6750 -0
  435. data/modules/emscripten/system/include/libcxx/ratio +487 -0
  436. data/modules/emscripten/system/include/libcxx/readme.txt +1 -0
  437. data/modules/emscripten/system/include/libcxx/regex +6439 -0
  438. data/modules/emscripten/system/include/libcxx/scoped_allocator +578 -0
  439. data/modules/emscripten/system/include/libcxx/set +1025 -0
  440. data/modules/emscripten/system/include/libcxx/sstream +888 -0
  441. data/modules/emscripten/system/include/libcxx/stack +292 -0
  442. data/modules/emscripten/system/include/libcxx/stdexcept +162 -0
  443. data/modules/emscripten/system/include/libcxx/streambuf +564 -0
  444. data/modules/emscripten/system/include/libcxx/string +3987 -0
  445. data/modules/emscripten/system/include/libcxx/strstream +400 -0
  446. data/modules/emscripten/system/include/libcxx/support/solaris/floatingpoint.h +5 -0
  447. data/modules/emscripten/system/include/libcxx/support/solaris/wchar.h +38 -0
  448. data/modules/emscripten/system/include/libcxx/support/solaris/xlocale.h +146 -0
  449. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +79 -0
  450. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +116 -0
  451. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +113 -0
  452. data/modules/emscripten/system/include/libcxx/support/win32/support.h +115 -0
  453. data/modules/emscripten/system/include/libcxx/system_error +636 -0
  454. data/modules/emscripten/system/include/libcxx/tgmath.h +29 -0
  455. data/modules/emscripten/system/include/libcxx/thread +459 -0
  456. data/modules/emscripten/system/include/libcxx/tuple +1092 -0
  457. data/modules/emscripten/system/include/libcxx/type_traits +3040 -0
  458. data/modules/emscripten/system/include/libcxx/typeindex +103 -0
  459. data/modules/emscripten/system/include/libcxx/typeinfo +124 -0
  460. data/modules/emscripten/system/include/libcxx/unordered_map +1864 -0
  461. data/modules/emscripten/system/include/libcxx/unordered_set +1144 -0
  462. data/modules/emscripten/system/include/libcxx/utility +583 -0
  463. data/modules/emscripten/system/include/libcxx/valarray +4779 -0
  464. data/modules/emscripten/system/include/libcxx/vector +3228 -0
  465. data/modules/emscripten/system/include/memory.h +10 -0
  466. data/modules/emscripten/system/include/mntent.h +23 -0
  467. data/modules/emscripten/system/include/net/arpa/inet.h +32 -0
  468. data/modules/emscripten/system/include/net/arpa/nameser.h +535 -0
  469. data/modules/emscripten/system/include/net/arpa/nameser_compat.h +187 -0
  470. data/modules/emscripten/system/include/net/if.h +87 -0
  471. data/modules/emscripten/system/include/net/netinet/in.h +166 -0
  472. data/modules/emscripten/system/include/net/netinet/tcp.h +246 -0
  473. data/modules/emscripten/system/include/net/resolv.h +389 -0
  474. data/modules/emscripten/system/include/netdb.h +94 -0
  475. data/modules/emscripten/system/include/nl_types.h +19 -0
  476. data/modules/emscripten/system/include/poll.h +3 -0
  477. data/modules/emscripten/system/include/pty.h +6 -0
  478. data/modules/emscripten/system/include/semaphore.h +31 -0
  479. data/modules/emscripten/system/include/spawn.h +105 -0
  480. data/modules/emscripten/system/include/stdbool.h +16 -0
  481. data/modules/emscripten/system/include/sys/bitypes.h +3 -0
  482. data/modules/emscripten/system/include/sys/io.h +14 -0
  483. data/modules/emscripten/system/include/sys/ioctl.h +26 -0
  484. data/modules/emscripten/system/include/sys/poll.h +31 -0
  485. data/modules/emscripten/system/include/sys/select.h +14 -0
  486. data/modules/emscripten/system/include/sys/socket.h +101 -0
  487. data/modules/emscripten/system/include/sys/socketvar.h +3 -0
  488. data/modules/emscripten/system/include/sys/statvfs.h +32 -0
  489. data/modules/emscripten/system/include/sys/sysctl.h +14 -0
  490. data/modules/emscripten/system/include/sys/uio.h +22 -0
  491. data/modules/emscripten/system/include/sys/un.h +66 -0
  492. data/modules/emscripten/system/include/sysexits.h +108 -0
  493. data/modules/emscripten/system/include/unwind.h +154 -0
  494. data/modules/emscripten/system/include/xlocale.h +47 -0
  495. data/modules/emscripten/system/include/zconf.h +428 -0
  496. data/modules/emscripten/system/include/zlib.h +1613 -0
  497. data/modules/emscripten/system/lib/compiler-rt/LICENSE.TXT +97 -0
  498. data/modules/emscripten/system/lib/compiler-rt/divdi3.c +47 -0
  499. data/modules/emscripten/system/lib/compiler-rt/int_endianness.h +116 -0
  500. data/modules/emscripten/system/lib/compiler-rt/int_lib.h +46 -0
  501. data/modules/emscripten/system/lib/compiler-rt/int_math.h +67 -0
  502. data/modules/emscripten/system/lib/compiler-rt/int_types.h +140 -0
  503. data/modules/emscripten/system/lib/compiler-rt/int_util.h +29 -0
  504. data/modules/emscripten/system/lib/compiler-rt/muldi3.c +56 -0
  505. data/modules/emscripten/system/lib/compiler-rt/readme.txt +20 -0
  506. data/modules/emscripten/system/lib/compiler-rt/udivdi3.c +36 -0
  507. data/modules/emscripten/system/lib/compiler-rt/udivmoddi4.c +251 -0
  508. data/modules/emscripten/system/lib/debugging.cpp +24 -0
  509. data/modules/emscripten/system/lib/dlmalloc.c +6299 -0
  510. data/modules/emscripten/system/lib/embind/bind.cpp +63 -0
  511. data/modules/emscripten/system/lib/libc/gen/err.c +49 -0
  512. data/modules/emscripten/system/lib/libc/gen/errx.c +49 -0
  513. data/modules/emscripten/system/lib/libc/gen/verr.c +58 -0
  514. data/modules/emscripten/system/lib/libc/gen/verrx.c +51 -0
  515. data/modules/emscripten/system/lib/libc/gen/vwarn.c +55 -0
  516. data/modules/emscripten/system/lib/libc/gen/vwarnx.c +48 -0
  517. data/modules/emscripten/system/lib/libc/gen/warn.c +49 -0
  518. data/modules/emscripten/system/lib/libc/gen/warnx.c +49 -0
  519. data/modules/emscripten/system/lib/libc/musl/COPYRIGHT +92 -0
  520. data/modules/emscripten/system/lib/libc/musl/readme.txt +1 -0
  521. data/modules/emscripten/system/lib/libc/musl/src/ctype/alpha.h +125 -0
  522. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalnum.c +7 -0
  523. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswalpha.c +14 -0
  524. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswblank.c +8 -0
  525. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswcntrl.c +10 -0
  526. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswctype.c +63 -0
  527. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswdigit.c +9 -0
  528. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswgraph.c +7 -0
  529. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswlower.c +6 -0
  530. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswprint.c +19 -0
  531. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswpunct.c +12 -0
  532. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswspace.c +19 -0
  533. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswupper.c +6 -0
  534. data/modules/emscripten/system/lib/libc/musl/src/ctype/iswxdigit.c +7 -0
  535. data/modules/emscripten/system/lib/libc/musl/src/ctype/nonspacing.h +62 -0
  536. data/modules/emscripten/system/lib/libc/musl/src/ctype/punct.h +109 -0
  537. data/modules/emscripten/system/lib/libc/musl/src/ctype/towctrans.c +268 -0
  538. data/modules/emscripten/system/lib/libc/musl/src/ctype/wcswidth.c +8 -0
  539. data/modules/emscripten/system/lib/libc/musl/src/ctype/wctrans.c +16 -0
  540. data/modules/emscripten/system/lib/libc/musl/src/ctype/wcwidth.c +29 -0
  541. data/modules/emscripten/system/lib/libc/musl/src/ctype/wide.h +42 -0
  542. data/modules/emscripten/system/lib/libc/musl/src/internal/libc.c +22 -0
  543. data/modules/emscripten/system/lib/libc/musl/src/internal/libc.h +71 -0
  544. data/modules/emscripten/system/lib/libc/musl/src/multibyte/btowc.c +7 -0
  545. data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.c +38 -0
  546. data/modules/emscripten/system/lib/libc/musl/src/multibyte/internal.h +22 -0
  547. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mblen.c +17 -0
  548. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrlen.c +18 -0
  549. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbrtowc.c +57 -0
  550. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsinit.c +17 -0
  551. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsnrtowcs.c +65 -0
  552. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbsrtowcs.c +100 -0
  553. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbstowcs.c +7 -0
  554. data/modules/emscripten/system/lib/libc/musl/src/multibyte/mbtowc.c +53 -0
  555. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcrtomb.c +38 -0
  556. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsnrtombs.c +52 -0
  557. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcsrtombs.c +58 -0
  558. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wcstombs.c +7 -0
  559. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctob.c +8 -0
  560. data/modules/emscripten/system/lib/libc/musl/src/multibyte/wctomb.c +18 -0
  561. data/modules/emscripten/system/lib/libc/musl/src/string/wcpcpy.c +6 -0
  562. data/modules/emscripten/system/lib/libc/musl/src/string/wcpncpy.c +6 -0
  563. data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp.c +7 -0
  564. data/modules/emscripten/system/lib/libc/musl/src/string/wcscasecmp_l.c +6 -0
  565. data/modules/emscripten/system/lib/libc/musl/src/string/wcscat.c +7 -0
  566. data/modules/emscripten/system/lib/libc/musl/src/string/wcschr.c +8 -0
  567. data/modules/emscripten/system/lib/libc/musl/src/string/wcscmp.c +7 -0
  568. data/modules/emscripten/system/lib/libc/musl/src/string/wcscpy.c +8 -0
  569. data/modules/emscripten/system/lib/libc/musl/src/string/wcscspn.c +10 -0
  570. data/modules/emscripten/system/lib/libc/musl/src/string/wcsdup.c +11 -0
  571. data/modules/emscripten/system/lib/libc/musl/src/string/wcslen.c +8 -0
  572. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp.c +9 -0
  573. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncasecmp_l.c +6 -0
  574. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncat.c +10 -0
  575. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncmp.c +7 -0
  576. data/modules/emscripten/system/lib/libc/musl/src/string/wcsncpy.c +9 -0
  577. data/modules/emscripten/system/lib/libc/musl/src/string/wcsnlen.c +8 -0
  578. data/modules/emscripten/system/lib/libc/musl/src/string/wcspbrk.c +7 -0
  579. data/modules/emscripten/system/lib/libc/musl/src/string/wcsrchr.c +8 -0
  580. data/modules/emscripten/system/lib/libc/musl/src/string/wcsspn.c +8 -0
  581. data/modules/emscripten/system/lib/libc/musl/src/string/wcsstr.c +108 -0
  582. data/modules/emscripten/system/lib/libc/musl/src/string/wcstok.c +12 -0
  583. data/modules/emscripten/system/lib/libc/musl/src/string/wcswcs.c +6 -0
  584. data/modules/emscripten/system/lib/libc/musl/src/string/wmemchr.c +8 -0
  585. data/modules/emscripten/system/lib/libc/musl/src/string/wmemcmp.c +8 -0
  586. data/modules/emscripten/system/lib/libc/musl/src/string/wmemcpy.c +9 -0
  587. data/modules/emscripten/system/lib/libc/musl/src/string/wmemmove.c +12 -0
  588. data/modules/emscripten/system/lib/libc/musl/src/string/wmemset.c +9 -0
  589. data/modules/emscripten/system/lib/libc/stdlib/getopt_long.c +511 -0
  590. data/modules/emscripten/system/lib/libc/stdlib/strtod.c +305 -0
  591. data/modules/emscripten/system/lib/libc.symbols +81 -0
  592. data/modules/emscripten/system/lib/libcextra.symbols +61 -0
  593. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +91 -0
  594. data/modules/emscripten/system/lib/libcxx/LICENSE.txt +76 -0
  595. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +83 -0
  596. data/modules/emscripten/system/lib/libcxx/bind.cpp +30 -0
  597. data/modules/emscripten/system/lib/libcxx/chrono.cpp +132 -0
  598. data/modules/emscripten/system/lib/libcxx/condition_variable.cpp +81 -0
  599. data/modules/emscripten/system/lib/libcxx/debug.cpp +504 -0
  600. data/modules/emscripten/system/lib/libcxx/exception.cpp +226 -0
  601. data/modules/emscripten/system/lib/libcxx/future.cpp +285 -0
  602. data/modules/emscripten/system/lib/libcxx/hash.cpp +564 -0
  603. data/modules/emscripten/system/lib/libcxx/ios.cpp +455 -0
  604. data/modules/emscripten/system/lib/libcxx/iostream.cpp +68 -0
  605. data/modules/emscripten/system/lib/libcxx/locale.cpp +6093 -0
  606. data/modules/emscripten/system/lib/libcxx/memory.cpp +223 -0
  607. data/modules/emscripten/system/lib/libcxx/mutex.cpp +250 -0
  608. data/modules/emscripten/system/lib/libcxx/new.cpp +205 -0
  609. data/modules/emscripten/system/lib/libcxx/random.cpp +48 -0
  610. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -0
  611. data/modules/emscripten/system/lib/libcxx/regex.cpp +325 -0
  612. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +196 -0
  613. data/modules/emscripten/system/lib/libcxx/string.cpp +687 -0
  614. data/modules/emscripten/system/lib/libcxx/strstream.cpp +329 -0
  615. data/modules/emscripten/system/lib/libcxx/support/solaris/README +4 -0
  616. data/modules/emscripten/system/lib/libcxx/support/solaris/mbsnrtowcs.inc +76 -0
  617. data/modules/emscripten/system/lib/libcxx/support/solaris/wcsnrtombs.inc +93 -0
  618. data/modules/emscripten/system/lib/libcxx/support/solaris/xlocale.c +245 -0
  619. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +94 -0
  620. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +70 -0
  621. data/modules/emscripten/system/lib/libcxx/symbols +2927 -0
  622. data/modules/emscripten/system/lib/libcxx/system_error.cpp +201 -0
  623. data/modules/emscripten/system/lib/libcxx/thread.cpp +208 -0
  624. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +60 -0
  625. data/modules/emscripten/system/lib/libcxx/utility.cpp +17 -0
  626. data/modules/emscripten/system/lib/libcxx/valarray.cpp +54 -0
  627. data/modules/emscripten/system/lib/libcxxabi/CREDITS.TXT +38 -0
  628. data/modules/emscripten/system/lib/libcxxabi/LICENSE.TXT +76 -0
  629. data/modules/emscripten/system/lib/libcxxabi/include/cxa_demangle.h +167 -0
  630. data/modules/emscripten/system/lib/libcxxabi/include/cxxabi.h +175 -0
  631. data/modules/emscripten/system/lib/libcxxabi/lib/buildit +99 -0
  632. data/modules/emscripten/system/lib/libcxxabi/readme.txt +1 -0
  633. data/modules/emscripten/system/lib/libcxxabi/src/abort_message.cpp +50 -0
  634. data/modules/emscripten/system/lib/libcxxabi/src/abort_message.h +33 -0
  635. data/modules/emscripten/system/lib/libcxxabi/src/cxa_aux_runtime.cpp +34 -0
  636. data/modules/emscripten/system/lib/libcxxabi/src/cxa_demangle.cpp +11036 -0
  637. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.cpp +622 -0
  638. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception.hpp +123 -0
  639. data/modules/emscripten/system/lib/libcxxabi/src/cxa_exception_storage.cpp +91 -0
  640. data/modules/emscripten/system/lib/libcxxabi/src/cxa_guard.cpp +231 -0
  641. data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.cpp +125 -0
  642. data/modules/emscripten/system/lib/libcxxabi/src/cxa_handlers.hpp +54 -0
  643. data/modules/emscripten/system/lib/libcxxabi/src/cxa_new_delete.cpp +242 -0
  644. data/modules/emscripten/system/lib/libcxxabi/src/cxa_personality.cpp +1055 -0
  645. data/modules/emscripten/system/lib/libcxxabi/src/cxa_unexpected.cpp +27 -0
  646. data/modules/emscripten/system/lib/libcxxabi/src/cxa_vector.cpp +367 -0
  647. data/modules/emscripten/system/lib/libcxxabi/src/cxa_virtual.cpp +31 -0
  648. data/modules/emscripten/system/lib/libcxxabi/src/exception.cpp +41 -0
  649. data/modules/emscripten/system/lib/libcxxabi/src/fallback_malloc.ipp +174 -0
  650. data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.cpp +1146 -0
  651. data/modules/emscripten/system/lib/libcxxabi/src/private_typeinfo.h +248 -0
  652. data/modules/emscripten/system/lib/libcxxabi/src/stdexcept.cpp +169 -0
  653. data/modules/emscripten/system/lib/libcxxabi/src/typeinfo.cpp +53 -0
  654. data/modules/emscripten/system/lib/libcxxabi/symbols +236 -0
  655. data/modules/emscripten/system/lib/sdl.cpp +13 -0
  656. data/modules/emscripten/system/lib/sdl.symbols +1 -0
  657. data/modules/emscripten/tests/hello_world.js +92 -0
  658. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/CppHeaderParser.py +2347 -0
  659. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/__init__.py +4 -0
  660. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/doc/CppHeaderParser.html +657 -0
  661. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/SampleClass.h +147 -0
  662. data/modules/emscripten/third_party/CppHeaderParser/CppHeaderParser/examples/readSampleClass.py +74 -0
  663. data/modules/emscripten/third_party/CppHeaderParser/PKG-INFO +249 -0
  664. data/modules/emscripten/third_party/CppHeaderParser/README.html +544 -0
  665. data/modules/emscripten/third_party/CppHeaderParser/README.txt +226 -0
  666. data/modules/emscripten/third_party/CppHeaderParser/setup.py +43 -0
  667. data/modules/emscripten/third_party/ansidecl.h +371 -0
  668. data/modules/emscripten/third_party/closure-compiler/COPYING +202 -0
  669. data/modules/emscripten/third_party/closure-compiler/README +292 -0
  670. data/modules/emscripten/third_party/closure-compiler/compiler.jar +0 -0
  671. data/modules/emscripten/third_party/closure-compiler/readme.txt +3 -0
  672. data/modules/emscripten/third_party/cp-demangle.h +161 -0
  673. data/modules/emscripten/third_party/demangle.h +549 -0
  674. data/modules/emscripten/third_party/demangler.py +49 -0
  675. data/modules/emscripten/third_party/gcc_demangler.c +4226 -0
  676. data/modules/emscripten/third_party/gcc_demangler.js +21282 -0
  677. data/modules/emscripten/third_party/jni/emjvm.cpp +133 -0
  678. data/modules/emscripten/third_party/jni/emjvm.h +8 -0
  679. data/modules/emscripten/third_party/jni/emjvm.js +185 -0
  680. data/modules/emscripten/third_party/jni/jni.h +1154 -0
  681. data/modules/emscripten/third_party/libiberty.h +634 -0
  682. data/modules/emscripten/third_party/lzma.js/README.markdown +37 -0
  683. data/modules/emscripten/third_party/lzma.js/doit.sh +37 -0
  684. data/modules/emscripten/third_party/lzma.js/lzip/AUTHORS +7 -0
  685. data/modules/emscripten/third_party/lzma.js/lzip/COPYING +676 -0
  686. data/modules/emscripten/third_party/lzma.js/lzip/ChangeLog +201 -0
  687. data/modules/emscripten/third_party/lzma.js/lzip/INSTALL +56 -0
  688. data/modules/emscripten/third_party/lzma.js/lzip/Makefile +160 -0
  689. data/modules/emscripten/third_party/lzma.js/lzip/Makefile.in +138 -0
  690. data/modules/emscripten/third_party/lzma.js/lzip/NEWS +22 -0
  691. data/modules/emscripten/third_party/lzma.js/lzip/README +77 -0
  692. data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.cc +204 -0
  693. data/modules/emscripten/third_party/lzma.js/lzip/arg_parser.h +106 -0
  694. data/modules/emscripten/third_party/lzma.js/lzip/configure +192 -0
  695. data/modules/emscripten/third_party/lzma.js/lzip/decoder.cc +252 -0
  696. data/modules/emscripten/third_party/lzma.js/lzip/decoder.h +268 -0
  697. data/modules/emscripten/third_party/lzma.js/lzip/encoder.cc +643 -0
  698. data/modules/emscripten/third_party/lzma.js/lzip/encoder.h +582 -0
  699. data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.cc +378 -0
  700. data/modules/emscripten/third_party/lzma.js/lzip/fast_encoder.h +171 -0
  701. data/modules/emscripten/third_party/lzma.js/lzip/lzip.h +264 -0
  702. data/modules/emscripten/third_party/lzma.js/lzip/main.cc +545 -0
  703. data/modules/emscripten/third_party/lzma.js/lzma-decoder.js +27 -0
  704. data/modules/emscripten/third_party/lzma.js/lzma-full.js +27 -0
  705. data/modules/emscripten/third_party/lzma.js/native_test.sh +5 -0
  706. data/modules/emscripten/third_party/lzma.js/post.js +13 -0
  707. data/modules/emscripten/third_party/lzma.js/pre.js +13 -0
  708. data/modules/emscripten/third_party/lzma.js/test-decoder.js +39 -0
  709. data/modules/emscripten/third_party/lzma.js/test-full.html +9 -0
  710. data/modules/emscripten/third_party/lzma.js/test-full.js +78 -0
  711. data/modules/emscripten/third_party/ply/ANNOUNCE +40 -0
  712. data/modules/emscripten/third_party/ply/CHANGES +1093 -0
  713. data/modules/emscripten/third_party/ply/PKG-INFO +22 -0
  714. data/modules/emscripten/third_party/ply/README +271 -0
  715. data/modules/emscripten/third_party/ply/TODO +16 -0
  716. data/modules/emscripten/third_party/ply/doc/internal.html +874 -0
  717. data/modules/emscripten/third_party/ply/doc/makedoc.py +194 -0
  718. data/modules/emscripten/third_party/ply/doc/ply.html +3262 -0
  719. data/modules/emscripten/third_party/ply/example/BASIC/README +79 -0
  720. data/modules/emscripten/third_party/ply/example/BASIC/basic.py +71 -0
  721. data/modules/emscripten/third_party/ply/example/BASIC/basiclex.py +74 -0
  722. data/modules/emscripten/third_party/ply/example/BASIC/basiclog.py +79 -0
  723. data/modules/emscripten/third_party/ply/example/BASIC/basinterp.py +441 -0
  724. data/modules/emscripten/third_party/ply/example/BASIC/basparse.py +424 -0
  725. data/modules/emscripten/third_party/ply/example/BASIC/dim.bas +14 -0
  726. data/modules/emscripten/third_party/ply/example/BASIC/func.bas +5 -0
  727. data/modules/emscripten/third_party/ply/example/BASIC/gcd.bas +22 -0
  728. data/modules/emscripten/third_party/ply/example/BASIC/gosub.bas +13 -0
  729. data/modules/emscripten/third_party/ply/example/BASIC/hello.bas +4 -0
  730. data/modules/emscripten/third_party/ply/example/BASIC/linear.bas +17 -0
  731. data/modules/emscripten/third_party/ply/example/BASIC/maxsin.bas +12 -0
  732. data/modules/emscripten/third_party/ply/example/BASIC/powers.bas +13 -0
  733. data/modules/emscripten/third_party/ply/example/BASIC/rand.bas +4 -0
  734. data/modules/emscripten/third_party/ply/example/BASIC/sales.bas +20 -0
  735. data/modules/emscripten/third_party/ply/example/BASIC/sears.bas +18 -0
  736. data/modules/emscripten/third_party/ply/example/BASIC/sqrt1.bas +5 -0
  737. data/modules/emscripten/third_party/ply/example/BASIC/sqrt2.bas +4 -0
  738. data/modules/emscripten/third_party/ply/example/GardenSnake/GardenSnake.py +709 -0
  739. data/modules/emscripten/third_party/ply/example/GardenSnake/README +5 -0
  740. data/modules/emscripten/third_party/ply/example/README +10 -0
  741. data/modules/emscripten/third_party/ply/example/ansic/README +2 -0
  742. data/modules/emscripten/third_party/ply/example/ansic/clex.py +164 -0
  743. data/modules/emscripten/third_party/ply/example/ansic/cparse.py +863 -0
  744. data/modules/emscripten/third_party/ply/example/calc/calc.py +107 -0
  745. data/modules/emscripten/third_party/ply/example/calcdebug/calc.py +113 -0
  746. data/modules/emscripten/third_party/ply/example/classcalc/calc.py +157 -0
  747. data/modules/emscripten/third_party/ply/example/cleanup.sh +2 -0
  748. data/modules/emscripten/third_party/ply/example/closurecalc/calc.py +130 -0
  749. data/modules/emscripten/third_party/ply/example/hedit/hedit.py +48 -0
  750. data/modules/emscripten/third_party/ply/example/newclasscalc/calc.py +160 -0
  751. data/modules/emscripten/third_party/ply/example/optcalc/README +9 -0
  752. data/modules/emscripten/third_party/ply/example/optcalc/calc.py +119 -0
  753. data/modules/emscripten/third_party/ply/example/unicalc/calc.py +117 -0
  754. data/modules/emscripten/third_party/ply/example/yply/README +41 -0
  755. data/modules/emscripten/third_party/ply/example/yply/ylex.py +112 -0
  756. data/modules/emscripten/third_party/ply/example/yply/yparse.py +217 -0
  757. data/modules/emscripten/third_party/ply/example/yply/yply.py +53 -0
  758. data/modules/emscripten/third_party/ply/ply/__init__.py +4 -0
  759. data/modules/emscripten/third_party/ply/ply/cpp.py +898 -0
  760. data/modules/emscripten/third_party/ply/ply/ctokens.py +133 -0
  761. data/modules/emscripten/third_party/ply/ply/lex.py +1058 -0
  762. data/modules/emscripten/third_party/ply/ply/yacc.py +3276 -0
  763. data/modules/emscripten/third_party/ply/setup.py +31 -0
  764. data/modules/emscripten/third_party/ply/test/README +7 -0
  765. data/modules/emscripten/third_party/ply/test/calclex.py +49 -0
  766. data/modules/emscripten/third_party/ply/test/cleanup.sh +4 -0
  767. data/modules/emscripten/third_party/ply/test/lex_closure.py +54 -0
  768. data/modules/emscripten/third_party/ply/test/lex_doc1.py +26 -0
  769. data/modules/emscripten/third_party/ply/test/lex_dup1.py +29 -0
  770. data/modules/emscripten/third_party/ply/test/lex_dup2.py +33 -0
  771. data/modules/emscripten/third_party/ply/test/lex_dup3.py +31 -0
  772. data/modules/emscripten/third_party/ply/test/lex_empty.py +20 -0
  773. data/modules/emscripten/third_party/ply/test/lex_error1.py +24 -0
  774. data/modules/emscripten/third_party/ply/test/lex_error2.py +26 -0
  775. data/modules/emscripten/third_party/ply/test/lex_error3.py +27 -0
  776. data/modules/emscripten/third_party/ply/test/lex_error4.py +27 -0
  777. data/modules/emscripten/third_party/ply/test/lex_hedit.py +47 -0
  778. data/modules/emscripten/third_party/ply/test/lex_ignore.py +31 -0
  779. data/modules/emscripten/third_party/ply/test/lex_ignore2.py +29 -0
  780. data/modules/emscripten/third_party/ply/test/lex_literal1.py +25 -0
  781. data/modules/emscripten/third_party/ply/test/lex_literal2.py +25 -0
  782. data/modules/emscripten/third_party/ply/test/lex_many_tokens.py +27 -0
  783. data/modules/emscripten/third_party/ply/test/lex_module.py +10 -0
  784. data/modules/emscripten/third_party/ply/test/lex_module_import.py +42 -0
  785. data/modules/emscripten/third_party/ply/test/lex_object.py +55 -0
  786. data/modules/emscripten/third_party/ply/test/lex_opt_alias.py +54 -0
  787. data/modules/emscripten/third_party/ply/test/lex_optimize.py +50 -0
  788. data/modules/emscripten/third_party/ply/test/lex_optimize2.py +50 -0
  789. data/modules/emscripten/third_party/ply/test/lex_optimize3.py +52 -0
  790. data/modules/emscripten/third_party/ply/test/lex_re1.py +27 -0
  791. data/modules/emscripten/third_party/ply/test/lex_re2.py +27 -0
  792. data/modules/emscripten/third_party/ply/test/lex_re3.py +29 -0
  793. data/modules/emscripten/third_party/ply/test/lex_rule1.py +27 -0
  794. data/modules/emscripten/third_party/ply/test/lex_rule2.py +29 -0
  795. data/modules/emscripten/third_party/ply/test/lex_rule3.py +27 -0
  796. data/modules/emscripten/third_party/ply/test/lex_state1.py +40 -0
  797. data/modules/emscripten/third_party/ply/test/lex_state2.py +40 -0
  798. data/modules/emscripten/third_party/ply/test/lex_state3.py +42 -0
  799. data/modules/emscripten/third_party/ply/test/lex_state4.py +41 -0
  800. data/modules/emscripten/third_party/ply/test/lex_state5.py +40 -0
  801. data/modules/emscripten/third_party/ply/test/lex_state_noerror.py +39 -0
  802. data/modules/emscripten/third_party/ply/test/lex_state_norule.py +40 -0
  803. data/modules/emscripten/third_party/ply/test/lex_state_try.py +45 -0
  804. data/modules/emscripten/third_party/ply/test/lex_token1.py +19 -0
  805. data/modules/emscripten/third_party/ply/test/lex_token2.py +22 -0
  806. data/modules/emscripten/third_party/ply/test/lex_token3.py +24 -0
  807. data/modules/emscripten/third_party/ply/test/lex_token4.py +26 -0
  808. data/modules/emscripten/third_party/ply/test/lex_token5.py +31 -0
  809. data/modules/emscripten/third_party/ply/test/lex_token_dup.py +29 -0
  810. data/modules/emscripten/third_party/ply/test/testlex.py +606 -0
  811. data/modules/emscripten/third_party/ply/test/testyacc.py +347 -0
  812. data/modules/emscripten/third_party/ply/test/yacc_badargs.py +68 -0
  813. data/modules/emscripten/third_party/ply/test/yacc_badid.py +77 -0
  814. data/modules/emscripten/third_party/ply/test/yacc_badprec.py +64 -0
  815. data/modules/emscripten/third_party/ply/test/yacc_badprec2.py +68 -0
  816. data/modules/emscripten/third_party/ply/test/yacc_badprec3.py +68 -0
  817. data/modules/emscripten/third_party/ply/test/yacc_badrule.py +68 -0
  818. data/modules/emscripten/third_party/ply/test/yacc_badtok.py +68 -0
  819. data/modules/emscripten/third_party/ply/test/yacc_dup.py +68 -0
  820. data/modules/emscripten/third_party/ply/test/yacc_error1.py +68 -0
  821. data/modules/emscripten/third_party/ply/test/yacc_error2.py +68 -0
  822. data/modules/emscripten/third_party/ply/test/yacc_error3.py +67 -0
  823. data/modules/emscripten/third_party/ply/test/yacc_error4.py +72 -0
  824. data/modules/emscripten/third_party/ply/test/yacc_inf.py +56 -0
  825. data/modules/emscripten/third_party/ply/test/yacc_literal.py +69 -0
  826. data/modules/emscripten/third_party/ply/test/yacc_misplaced.py +68 -0
  827. data/modules/emscripten/third_party/ply/test/yacc_missing1.py +68 -0
  828. data/modules/emscripten/third_party/ply/test/yacc_nested.py +33 -0
  829. data/modules/emscripten/third_party/ply/test/yacc_nodoc.py +67 -0
  830. data/modules/emscripten/third_party/ply/test/yacc_noerror.py +66 -0
  831. data/modules/emscripten/third_party/ply/test/yacc_nop.py +68 -0
  832. data/modules/emscripten/third_party/ply/test/yacc_notfunc.py +66 -0
  833. data/modules/emscripten/third_party/ply/test/yacc_notok.py +67 -0
  834. data/modules/emscripten/third_party/ply/test/yacc_prec1.py +68 -0
  835. data/modules/emscripten/third_party/ply/test/yacc_rr.py +72 -0
  836. data/modules/emscripten/third_party/ply/test/yacc_rr_unused.py +30 -0
  837. data/modules/emscripten/third_party/ply/test/yacc_simple.py +68 -0
  838. data/modules/emscripten/third_party/ply/test/yacc_sr.py +63 -0
  839. data/modules/emscripten/third_party/ply/test/yacc_term1.py +68 -0
  840. data/modules/emscripten/third_party/ply/test/yacc_unused.py +77 -0
  841. data/modules/emscripten/third_party/ply/test/yacc_unused_rule.py +72 -0
  842. data/modules/emscripten/third_party/ply/test/yacc_uprec.py +63 -0
  843. data/modules/emscripten/third_party/ply/test/yacc_uprec2.py +63 -0
  844. data/modules/emscripten/third_party/readme.txt +7 -0
  845. data/modules/emscripten/third_party/websockify/CHANGES.txt +23 -0
  846. data/modules/emscripten/third_party/websockify/LICENSE.txt +16 -0
  847. data/modules/emscripten/third_party/websockify/MANIFEST.in +1 -0
  848. data/modules/emscripten/third_party/websockify/Makefile +11 -0
  849. data/modules/emscripten/third_party/websockify/README.md +168 -0
  850. data/modules/emscripten/third_party/websockify/Windows/Windows Service Readme.txt +39 -0
  851. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Program.cs +24 -0
  852. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.Designer.cs +61 -0
  853. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.cs +19 -0
  854. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/ProjectInstaller.resx +129 -0
  855. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Properties/AssemblyInfo.cs +36 -0
  856. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.Designer.cs +37 -0
  857. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/Service1.cs +41 -0
  858. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.csproj +75 -0
  859. data/modules/emscripten/third_party/websockify/Windows/noVNC Websocket Service Project/noVNC Websocket.sln +20 -0
  860. data/modules/emscripten/third_party/websockify/docs/LICENSE.GPL-3 +621 -0
  861. data/modules/emscripten/third_party/websockify/docs/LICENSE.LGPL-3 +165 -0
  862. data/modules/emscripten/third_party/websockify/docs/LICENSE.MPL-2.0 +373 -0
  863. data/modules/emscripten/third_party/websockify/docs/TODO +9 -0
  864. data/modules/emscripten/third_party/websockify/docs/flash_policy.txt +4 -0
  865. data/modules/emscripten/third_party/websockify/docs/latency_results.txt +114 -0
  866. data/modules/emscripten/third_party/websockify/docs/notes +17 -0
  867. data/modules/emscripten/third_party/websockify/docs/release.txt +9 -0
  868. data/modules/emscripten/third_party/websockify/docs/websockify.1 +110 -0
  869. data/modules/emscripten/third_party/websockify/include/VT100.js +919 -0
  870. data/modules/emscripten/third_party/websockify/include/base64.js +114 -0
  871. data/modules/emscripten/third_party/websockify/include/keysym.js +99 -0
  872. data/modules/emscripten/third_party/websockify/include/util.js +359 -0
  873. data/modules/emscripten/third_party/websockify/include/web-socket-js/README.txt +109 -0
  874. data/modules/emscripten/third_party/websockify/include/web-socket-js/WebSocketMain.swf +0 -0
  875. data/modules/emscripten/third_party/websockify/include/web-socket-js/swfobject.js +4 -0
  876. data/modules/emscripten/third_party/websockify/include/web-socket-js/web_socket.js +391 -0
  877. data/modules/emscripten/third_party/websockify/include/websock.js +422 -0
  878. data/modules/emscripten/third_party/websockify/include/webutil.js +216 -0
  879. data/modules/emscripten/third_party/websockify/include/wsirc.js +235 -0
  880. data/modules/emscripten/third_party/websockify/include/wstelnet.js +335 -0
  881. data/modules/emscripten/third_party/websockify/other/Makefile +14 -0
  882. data/modules/emscripten/third_party/websockify/other/README.md +51 -0
  883. data/modules/emscripten/third_party/websockify/other/launch.sh +108 -0
  884. data/modules/emscripten/third_party/websockify/other/project.clj +13 -0
  885. data/modules/emscripten/third_party/websockify/other/websocket.c +802 -0
  886. data/modules/emscripten/third_party/websockify/other/websocket.h +84 -0
  887. data/modules/emscripten/third_party/websockify/other/websocket.rb +456 -0
  888. data/modules/emscripten/third_party/websockify/other/websockify.c +385 -0
  889. data/modules/emscripten/third_party/websockify/other/websockify.clj +233 -0
  890. data/modules/emscripten/third_party/websockify/other/websockify.js +196 -0
  891. data/modules/emscripten/third_party/websockify/other/websockify.rb +171 -0
  892. data/modules/emscripten/third_party/websockify/other/wswrap +22 -0
  893. data/modules/emscripten/third_party/websockify/rebind +18 -0
  894. data/modules/emscripten/third_party/websockify/rebind.c +94 -0
  895. data/modules/emscripten/third_party/websockify/run +5 -0
  896. data/modules/emscripten/third_party/websockify/setup.py +30 -0
  897. data/modules/emscripten/third_party/websockify/tests/b64_vs_utf8.py +29 -0
  898. data/modules/emscripten/third_party/websockify/tests/base64.html +91 -0
  899. data/modules/emscripten/third_party/websockify/tests/base64.js +12 -0
  900. data/modules/emscripten/third_party/websockify/tests/echo.html +148 -0
  901. data/modules/emscripten/third_party/websockify/tests/echo.py +75 -0
  902. data/modules/emscripten/third_party/websockify/tests/echo.rb +62 -0
  903. data/modules/emscripten/third_party/websockify/tests/latency.html +290 -0
  904. data/modules/emscripten/third_party/websockify/tests/latency.py +75 -0
  905. data/modules/emscripten/third_party/websockify/tests/load.html +250 -0
  906. data/modules/emscripten/third_party/websockify/tests/load.py +167 -0
  907. data/modules/emscripten/third_party/websockify/tests/plain_echo.html +168 -0
  908. data/modules/emscripten/third_party/websockify/tests/simple.html +68 -0
  909. data/modules/emscripten/third_party/websockify/tests/utf8-list.py +22 -0
  910. data/modules/emscripten/third_party/websockify/websockify/__init__.py +2 -0
  911. data/modules/emscripten/third_party/websockify/websockify/websocket.py +982 -0
  912. data/modules/emscripten/third_party/websockify/websockify/websocketproxy.py +393 -0
  913. data/modules/emscripten/third_party/websockify/websockify.py +5 -0
  914. data/modules/emscripten/third_party/websockify/wsirc.html +99 -0
  915. data/modules/emscripten/third_party/websockify/wstelnet.html +74 -0
  916. data/modules/emscripten/tools/__init__.py +0 -0
  917. data/modules/emscripten/tools/__init__.pyc +0 -0
  918. data/modules/emscripten/tools/autodebugger.py +289 -0
  919. data/modules/emscripten/tools/autodebugger_c.py +37 -0
  920. data/modules/emscripten/tools/autodebugger_indenter.py +18 -0
  921. data/modules/emscripten/tools/autodebugger_js.py +47 -0
  922. data/modules/emscripten/tools/autodediffer.py +60 -0
  923. data/modules/emscripten/tools/bindings_generator.py +832 -0
  924. data/modules/emscripten/tools/bisect_pair.py +88 -0
  925. data/modules/emscripten/tools/cache.py +198 -0
  926. data/modules/emscripten/tools/cache.pyc +0 -0
  927. data/modules/emscripten/tools/clean_webconsole.py +34 -0
  928. data/modules/emscripten/tools/crunch-worker.js +124 -0
  929. data/modules/emscripten/tools/diff_autodebugger.py +15 -0
  930. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +5129 -0
  931. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +6861 -0
  932. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +6122 -0
  933. data/modules/emscripten/tools/eliminator/eliminator-test.js +8856 -0
  934. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.html +888 -0
  935. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/README.org +463 -0
  936. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/bin/uglifyjs +317 -0
  937. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/docstyle.css +75 -0
  938. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/object-ast.js +75 -0
  939. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/parse-js.js +1363 -0
  940. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/process.js +2005 -0
  941. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/lib/squeeze-more.js +51 -0
  942. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/package.json +22 -0
  943. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/beautify.js +28 -0
  944. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/testparser.js +402 -0
  945. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
  946. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
  947. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
  948. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
  949. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
  950. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
  951. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
  952. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
  953. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
  954. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
  955. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
  956. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js +1 -0
  957. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
  958. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
  959. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
  960. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
  961. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
  962. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
  963. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
  964. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
  965. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
  966. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
  967. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
  968. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
  969. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
  970. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
  971. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
  972. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
  973. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
  974. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
  975. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
  976. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
  977. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
  978. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
  979. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/mangle.js +1 -0
  980. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
  981. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
  982. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/expected/with.js +1 -0
  983. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
  984. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
  985. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
  986. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
  987. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
  988. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
  989. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
  990. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
  991. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
  992. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
  993. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
  994. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js +16 -0
  995. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
  996. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
  997. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
  998. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
  999. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
  1000. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
  1001. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
  1002. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
  1003. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
  1004. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
  1005. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
  1006. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
  1007. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
  1008. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
  1009. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
  1010. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
  1011. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
  1012. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
  1013. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
  1014. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
  1015. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
  1016. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
  1017. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/mangle.js +5 -0
  1018. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
  1019. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
  1020. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/compress/test/with.js +2 -0
  1021. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/test/unit/scripts.js +55 -0
  1022. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/hoist.js +33 -0
  1023. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument.js +97 -0
  1024. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/instrument2.js +138 -0
  1025. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/tmp/test.js +16 -0
  1026. data/modules/emscripten/tools/eliminator/node_modules/uglify-js/uglify-js.js +17 -0
  1027. data/modules/emscripten/tools/eliminator/safe-eliminator-test-output.js +85 -0
  1028. data/modules/emscripten/tools/eliminator/safe-eliminator-test.js +103 -0
  1029. data/modules/emscripten/tools/emconfiguren.py +19 -0
  1030. data/modules/emscripten/tools/emmaken.py +230 -0
  1031. data/modules/emscripten/tools/emmakenxx.py +18 -0
  1032. data/modules/emscripten/tools/exec_llvm.py +50 -0
  1033. data/modules/emscripten/tools/file2json.py +49 -0
  1034. data/modules/emscripten/tools/file_packager.py +649 -0
  1035. data/modules/emscripten/tools/find_bigfuncs.py +23 -0
  1036. data/modules/emscripten/tools/find_bigis.py +18 -0
  1037. data/modules/emscripten/tools/fix_closure.py +88 -0
  1038. data/modules/emscripten/tools/ie7_fix.py +14 -0
  1039. data/modules/emscripten/tools/js-optimizer.js +3440 -0
  1040. data/modules/emscripten/tools/js_optimizer.py +341 -0
  1041. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  1042. data/modules/emscripten/tools/jsrun.py +27 -0
  1043. data/modules/emscripten/tools/jsrun.pyc +0 -0
  1044. data/modules/emscripten/tools/ll-strip.py +56 -0
  1045. data/modules/emscripten/tools/make_file.py +19 -0
  1046. data/modules/emscripten/tools/make_minigzip.py +13 -0
  1047. data/modules/emscripten/tools/namespacer.py +95 -0
  1048. data/modules/emscripten/tools/nativize_llvm.py +34 -0
  1049. data/modules/emscripten/tools/node_modules/source-map/CHANGELOG.md +58 -0
  1050. data/modules/emscripten/tools/node_modules/source-map/LICENSE +28 -0
  1051. data/modules/emscripten/tools/node_modules/source-map/Makefile.dryice.js +166 -0
  1052. data/modules/emscripten/tools/node_modules/source-map/README.md +347 -0
  1053. data/modules/emscripten/tools/node_modules/source-map/build/assert-shim.js +56 -0
  1054. data/modules/emscripten/tools/node_modules/source-map/build/mini-require.js +152 -0
  1055. data/modules/emscripten/tools/node_modules/source-map/build/prefix-source-map.jsm +20 -0
  1056. data/modules/emscripten/tools/node_modules/source-map/build/prefix-utils.jsm +18 -0
  1057. data/modules/emscripten/tools/node_modules/source-map/build/suffix-browser.js +8 -0
  1058. data/modules/emscripten/tools/node_modules/source-map/build/suffix-source-map.jsm +6 -0
  1059. data/modules/emscripten/tools/node_modules/source-map/build/suffix-utils.jsm +21 -0
  1060. data/modules/emscripten/tools/node_modules/source-map/build/test-prefix.js +8 -0
  1061. data/modules/emscripten/tools/node_modules/source-map/build/test-suffix.js +3 -0
  1062. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/array-set.js +96 -0
  1063. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64-vlq.js +144 -0
  1064. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/base64.js +42 -0
  1065. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/binary-search.js +81 -0
  1066. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-consumer.js +430 -0
  1067. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-map-generator.js +381 -0
  1068. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/source-node.js +353 -0
  1069. data/modules/emscripten/tools/node_modules/source-map/lib/source-map/util.js +117 -0
  1070. data/modules/emscripten/tools/node_modules/source-map/lib/source-map.js +8 -0
  1071. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/LICENSE +58 -0
  1072. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/README.md +119 -0
  1073. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/amdefine.js +299 -0
  1074. data/modules/emscripten/tools/node_modules/source-map/node_modules/amdefine/package.json +33 -0
  1075. data/modules/emscripten/tools/node_modules/source-map/package.json +74 -0
  1076. data/modules/emscripten/tools/node_modules/source-map/test/run-tests.js +73 -0
  1077. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-api.js +26 -0
  1078. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-array-set.js +71 -0
  1079. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64-vlq.js +24 -0
  1080. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-base64.js +35 -0
  1081. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-binary-search.js +54 -0
  1082. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-dog-fooding.js +72 -0
  1083. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-consumer.js +306 -0
  1084. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-map-generator.js +391 -0
  1085. data/modules/emscripten/tools/node_modules/source-map/test/source-map/test-source-node.js +282 -0
  1086. data/modules/emscripten/tools/node_modules/source-map/test/source-map/util.js +152 -0
  1087. data/modules/emscripten/tools/reproduceriter.js +216 -0
  1088. data/modules/emscripten/tools/reproduceriter.py +160 -0
  1089. data/modules/emscripten/tools/response_file.py +28 -0
  1090. data/modules/emscripten/tools/response_file.pyc +0 -0
  1091. data/modules/emscripten/tools/scan_js.py +20 -0
  1092. data/modules/emscripten/tools/scan_ll.py +18 -0
  1093. data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/__init__.py +3 -0
  1094. data/modules/emscripten/tools/scons/site_scons/site_tools/emscripten/emscripten.py +46 -0
  1095. data/modules/emscripten/tools/settings_template_readonly.py +47 -0
  1096. data/modules/emscripten/tools/shared.py +1437 -0
  1097. data/modules/emscripten/tools/shared.pyc +0 -0
  1098. data/modules/emscripten/tools/source-maps/sourcemap2json.js +15 -0
  1099. data/modules/emscripten/tools/source-maps/sourcemapper.js +177 -0
  1100. data/modules/emscripten/tools/split.py +97 -0
  1101. data/modules/emscripten/tools/tempfiles.py +40 -0
  1102. data/modules/emscripten/tools/tempfiles.pyc +0 -0
  1103. data/modules/emscripten/tools/test-js-optimizer-asm-last-output.js +75 -0
  1104. data/modules/emscripten/tools/test-js-optimizer-asm-last.js +91 -0
  1105. data/modules/emscripten/tools/test-js-optimizer-asm-outline-output.js +570 -0
  1106. data/modules/emscripten/tools/test-js-optimizer-asm-outline.js +606 -0
  1107. data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +540 -0
  1108. data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +550 -0
  1109. data/modules/emscripten/tools/test-js-optimizer-asm-regs-min-output.js +36 -0
  1110. data/modules/emscripten/tools/test-js-optimizer-asm-regs-min.js +37 -0
  1111. data/modules/emscripten/tools/test-js-optimizer-asm-regs-output.js +106 -0
  1112. data/modules/emscripten/tools/test-js-optimizer-asm-regs.js +110 -0
  1113. data/modules/emscripten/tools/test-js-optimizer-asm-relocate-output.js +9 -0
  1114. data/modules/emscripten/tools/test-js-optimizer-asm-relocate.js +12 -0
  1115. data/modules/emscripten/tools/test-js-optimizer-output.js +291 -0
  1116. data/modules/emscripten/tools/test-js-optimizer-regs-output.js +232 -0
  1117. data/modules/emscripten/tools/test-js-optimizer-regs.js +237 -0
  1118. data/modules/emscripten/tools/test-js-optimizer-t2-output.js +91 -0
  1119. data/modules/emscripten/tools/test-js-optimizer-t2.js +92 -0
  1120. data/modules/emscripten/tools/test-js-optimizer-t2c-output.js +17 -0
  1121. data/modules/emscripten/tools/test-js-optimizer-t2c.js +18 -0
  1122. data/modules/emscripten/tools/test-js-optimizer-t3-output.js +49 -0
  1123. data/modules/emscripten/tools/test-js-optimizer-t3.js +50 -0
  1124. data/modules/emscripten/tools/test-js-optimizer.js +401 -0
  1125. data/modules/mruby/AUTHORS +18 -0
  1126. data/modules/mruby/CONTRIBUTING.md +65 -0
  1127. data/modules/mruby/ChangeLog +15 -0
  1128. data/modules/mruby/INSTALL +29 -0
  1129. data/modules/mruby/LEGAL +6 -0
  1130. data/modules/mruby/MITL +20 -0
  1131. data/modules/mruby/Makefile +18 -0
  1132. data/modules/mruby/NEWS +13 -0
  1133. data/modules/mruby/README.md +116 -0
  1134. data/modules/mruby/Rakefile +114 -0
  1135. data/modules/mruby/TODO +11 -0
  1136. data/modules/mruby/benchmark/ao-render.rb +315 -0
  1137. data/modules/mruby/benchmark/bm_so_lists.rb +47 -0
  1138. data/modules/mruby/benchmark/fib39.rb +8 -0
  1139. data/modules/mruby/build_config.rb +88 -0
  1140. data/modules/mruby/doc/compile/README.md +376 -0
  1141. data/modules/mruby/doc/mrbgems/README.md +254 -0
  1142. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/README.md +4 -0
  1143. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrbgem.rake +23 -0
  1144. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/mrblib/example.rb +5 -0
  1145. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/src/example.c +20 -0
  1146. data/modules/mruby/examples/mrbgems/c_and_ruby_extension_example/test/example.rb +7 -0
  1147. data/modules/mruby/examples/mrbgems/c_extension_example/README.md +4 -0
  1148. data/modules/mruby/examples/mrbgems/c_extension_example/mrbgem.rake +23 -0
  1149. data/modules/mruby/examples/mrbgems/c_extension_example/src/example.c +20 -0
  1150. data/modules/mruby/examples/mrbgems/c_extension_example/test/example.c +7 -0
  1151. data/modules/mruby/examples/mrbgems/c_extension_example/test/example.rb +3 -0
  1152. data/modules/mruby/examples/mrbgems/ruby_extension_example/README.md +4 -0
  1153. data/modules/mruby/examples/mrbgems/ruby_extension_example/mrbgem.rake +23 -0
  1154. data/modules/mruby/examples/mrbgems/ruby_extension_example/mrblib/example.rb +5 -0
  1155. data/modules/mruby/examples/mrbgems/ruby_extension_example/test/example.rb +3 -0
  1156. data/modules/mruby/examples/targets/ArduinoDue.rb +65 -0
  1157. data/modules/mruby/examples/targets/chipKitMax32.rb +68 -0
  1158. data/modules/mruby/include/mrbconf.h +87 -0
  1159. data/modules/mruby/include/mruby/array.h +63 -0
  1160. data/modules/mruby/include/mruby/class.h +75 -0
  1161. data/modules/mruby/include/mruby/compile.h +176 -0
  1162. data/modules/mruby/include/mruby/data.h +53 -0
  1163. data/modules/mruby/include/mruby/dump.h +151 -0
  1164. data/modules/mruby/include/mruby/gc.h +17 -0
  1165. data/modules/mruby/include/mruby/hash.h +54 -0
  1166. data/modules/mruby/include/mruby/irep.h +40 -0
  1167. data/modules/mruby/include/mruby/khash.h +257 -0
  1168. data/modules/mruby/include/mruby/numeric.h +32 -0
  1169. data/modules/mruby/include/mruby/proc.h +62 -0
  1170. data/modules/mruby/include/mruby/range.h +35 -0
  1171. data/modules/mruby/include/mruby/string.h +78 -0
  1172. data/modules/mruby/include/mruby/value.h +483 -0
  1173. data/modules/mruby/include/mruby/variable.h +78 -0
  1174. data/modules/mruby/include/mruby.h +388 -0
  1175. data/modules/mruby/minirake +477 -0
  1176. data/modules/mruby/mrbgems/default.gembox +61 -0
  1177. data/modules/mruby/mrbgems/full-core.gembox +9 -0
  1178. data/modules/mruby/mrbgems/mruby-array-ext/mrbgem.rake +4 -0
  1179. data/modules/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +204 -0
  1180. data/modules/mruby/mrbgems/mruby-array-ext/src/array.c +140 -0
  1181. data/modules/mruby/mrbgems/mruby-array-ext/test/array.rb +109 -0
  1182. data/modules/mruby/mrbgems/mruby-bin-mirb/mrbgem.rake +5 -0
  1183. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +365 -0
  1184. data/modules/mruby/mrbgems/mruby-bin-mruby/mrbgem.rake +5 -0
  1185. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +243 -0
  1186. data/modules/mruby/mrbgems/mruby-enum-ext/mrbgem.rake +4 -0
  1187. data/modules/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +164 -0
  1188. data/modules/mruby/mrbgems/mruby-enum-ext/test/enum.rb +44 -0
  1189. data/modules/mruby/mrbgems/mruby-eval/mrbgem.rake +4 -0
  1190. data/modules/mruby/mrbgems/mruby-eval/src/eval.c +23 -0
  1191. data/modules/mruby/mrbgems/mruby-fiber/mrbgem.rake +4 -0
  1192. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +251 -0
  1193. data/modules/mruby/mrbgems/mruby-fiber/test/fiber.rb +64 -0
  1194. data/modules/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +4 -0
  1195. data/modules/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +13 -0
  1196. data/modules/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +62 -0
  1197. data/modules/mruby/mrbgems/mruby-hash-ext/test/hash.rb +26 -0
  1198. data/modules/mruby/mrbgems/mruby-math/mrbgem.rake +4 -0
  1199. data/modules/mruby/mrbgems/mruby-math/src/math.c +685 -0
  1200. data/modules/mruby/mrbgems/mruby-math/test/math.rb +136 -0
  1201. data/modules/mruby/mrbgems/mruby-numeric-ext/mrbgem.rake +4 -0
  1202. data/modules/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +31 -0
  1203. data/modules/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +10 -0
  1204. data/modules/mruby/mrbgems/mruby-object-ext/mrbgem.rake +4 -0
  1205. data/modules/mruby/mrbgems/mruby-object-ext/src/object.c +108 -0
  1206. data/modules/mruby/mrbgems/mruby-object-ext/test/nil.rb +11 -0
  1207. data/modules/mruby/mrbgems/mruby-object-ext/test/object.rb +9 -0
  1208. data/modules/mruby/mrbgems/mruby-objectspace/mrbgem.rake +4 -0
  1209. data/modules/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +117 -0
  1210. data/modules/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +38 -0
  1211. data/modules/mruby/mrbgems/mruby-print/mrbgem.rake +4 -0
  1212. data/modules/mruby/mrbgems/mruby-print/mrblib/print.rb +64 -0
  1213. data/modules/mruby/mrbgems/mruby-print/src/print.c +44 -0
  1214. data/modules/mruby/mrbgems/mruby-proc-ext/mrbgem.rake +4 -0
  1215. data/modules/mruby/mrbgems/mruby-proc-ext/mrblib/proc.rb +40 -0
  1216. data/modules/mruby/mrbgems/mruby-proc-ext/src/proc.c +97 -0
  1217. data/modules/mruby/mrbgems/mruby-proc-ext/test/proc.rb +41 -0
  1218. data/modules/mruby/mrbgems/mruby-random/mrbgem.rake +4 -0
  1219. data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.c +193 -0
  1220. data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.h +48 -0
  1221. data/modules/mruby/mrbgems/mruby-random/src/random.c +231 -0
  1222. data/modules/mruby/mrbgems/mruby-random/src/random.h +12 -0
  1223. data/modules/mruby/mrbgems/mruby-random/test/random.rb +32 -0
  1224. data/modules/mruby/mrbgems/mruby-range-ext/mrbgem.rake +4 -0
  1225. data/modules/mruby/mrbgems/mruby-range-ext/src/range.c +141 -0
  1226. data/modules/mruby/mrbgems/mruby-range-ext/test/range.rb +20 -0
  1227. data/modules/mruby/mrbgems/mruby-sprintf/mrbgem.rake +4 -0
  1228. data/modules/mruby/mrbgems/mruby-sprintf/src/kernel.c +30 -0
  1229. data/modules/mruby/mrbgems/mruby-sprintf/src/sprintf.c +1102 -0
  1230. data/modules/mruby/mrbgems/mruby-sprintf/test/sprintf.rb +3 -0
  1231. data/modules/mruby/mrbgems/mruby-string-ext/mrbgem.rake +4 -0
  1232. data/modules/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +52 -0
  1233. data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +175 -0
  1234. data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +112 -0
  1235. data/modules/mruby/mrbgems/mruby-struct/mrbgem.rake +4 -0
  1236. data/modules/mruby/mrbgems/mruby-struct/mrblib/struct.rb +50 -0
  1237. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +818 -0
  1238. data/modules/mruby/mrbgems/mruby-struct/test/struct.rb +77 -0
  1239. data/modules/mruby/mrbgems/mruby-symbol-ext/mrbgem.rake +4 -0
  1240. data/modules/mruby/mrbgems/mruby-symbol-ext/mrblib/symbol.rb +9 -0
  1241. data/modules/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +55 -0
  1242. data/modules/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +12 -0
  1243. data/modules/mruby/mrbgems/mruby-time/mrbgem.rake +4 -0
  1244. data/modules/mruby/mrbgems/mruby-time/src/time.c +749 -0
  1245. data/modules/mruby/mrbgems/mruby-time/test/time.rb +201 -0
  1246. data/modules/mruby/mrbgems/mruby-toplevel-ext/mrbgem.rake +4 -0
  1247. data/modules/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb +11 -0
  1248. data/modules/mruby/mrbgems/mruby-toplevel-ext/test/toplevel.rb +24 -0
  1249. data/modules/mruby/mrblib/array.rb +111 -0
  1250. data/modules/mruby/mrblib/class.rb +26 -0
  1251. data/modules/mruby/mrblib/compar.rb +104 -0
  1252. data/modules/mruby/mrblib/enum.rb +398 -0
  1253. data/modules/mruby/mrblib/error.rb +66 -0
  1254. data/modules/mruby/mrblib/hash.rb +193 -0
  1255. data/modules/mruby/mrblib/init_mrblib.c +14 -0
  1256. data/modules/mruby/mrblib/kernel.rb +46 -0
  1257. data/modules/mruby/mrblib/mrblib.rake +18 -0
  1258. data/modules/mruby/mrblib/numeric.rb +101 -0
  1259. data/modules/mruby/mrblib/print.rb +18 -0
  1260. data/modules/mruby/mrblib/range.rb +40 -0
  1261. data/modules/mruby/mrblib/string.rb +145 -0
  1262. data/modules/mruby/src/array.c +1150 -0
  1263. data/modules/mruby/src/backtrace.c +73 -0
  1264. data/modules/mruby/src/class.c +1942 -0
  1265. data/modules/mruby/src/codegen.c +2864 -0
  1266. data/modules/mruby/src/compar.c +13 -0
  1267. data/modules/mruby/src/crc.c +38 -0
  1268. data/modules/mruby/src/dump.c +542 -0
  1269. data/modules/mruby/src/enum.c +14 -0
  1270. data/modules/mruby/src/error.c +454 -0
  1271. data/modules/mruby/src/error.h +18 -0
  1272. data/modules/mruby/src/etc.c +204 -0
  1273. data/modules/mruby/src/gc.c +1542 -0
  1274. data/modules/mruby/src/hash.c +1261 -0
  1275. data/modules/mruby/src/init.c +62 -0
  1276. data/modules/mruby/src/kernel.c +1105 -0
  1277. data/modules/mruby/src/keywords +50 -0
  1278. data/modules/mruby/src/lex.def +212 -0
  1279. data/modules/mruby/src/load.c +629 -0
  1280. data/modules/mruby/src/mruby_core.rake +28 -0
  1281. data/modules/mruby/src/node.h +117 -0
  1282. data/modules/mruby/src/numeric.c +1418 -0
  1283. data/modules/mruby/src/object.c +593 -0
  1284. data/modules/mruby/src/opcode.h +160 -0
  1285. data/modules/mruby/src/parse.y +6050 -0
  1286. data/modules/mruby/src/pool.c +190 -0
  1287. data/modules/mruby/src/print.c +71 -0
  1288. data/modules/mruby/src/proc.c +209 -0
  1289. data/modules/mruby/src/range.c +442 -0
  1290. data/modules/mruby/src/re.h +13 -0
  1291. data/modules/mruby/src/state.c +200 -0
  1292. data/modules/mruby/src/string.c +2580 -0
  1293. data/modules/mruby/src/symbol.c +456 -0
  1294. data/modules/mruby/src/value_array.h +27 -0
  1295. data/modules/mruby/src/variable.c +1147 -0
  1296. data/modules/mruby/src/vm.c +2129 -0
  1297. data/modules/mruby/tasks/libmruby.rake +18 -0
  1298. data/modules/mruby/tasks/mrbgem_spec.rake +297 -0
  1299. data/modules/mruby/tasks/mrbgems.rake +85 -0
  1300. data/modules/mruby/tasks/mrbgems_test.rake +88 -0
  1301. data/modules/mruby/tasks/mruby_build.rake +211 -0
  1302. data/modules/mruby/tasks/mruby_build_commands.rake +287 -0
  1303. data/modules/mruby/tasks/mruby_build_gem.rake +67 -0
  1304. data/modules/mruby/tasks/ruby_ext.rake +70 -0
  1305. data/modules/mruby/tasks/toolchains/androideabi.rake +126 -0
  1306. data/modules/mruby/tasks/toolchains/clang.rake +8 -0
  1307. data/modules/mruby/tasks/toolchains/gcc.rake +21 -0
  1308. data/modules/mruby/tasks/toolchains/vs2010.rake +3 -0
  1309. data/modules/mruby/tasks/toolchains/vs2012.rake +44 -0
  1310. data/modules/mruby/test/README.md +7 -0
  1311. data/modules/mruby/test/assert.rb +238 -0
  1312. data/modules/mruby/test/driver.c +118 -0
  1313. data/modules/mruby/test/init_mrbtest.c +24 -0
  1314. data/modules/mruby/test/mrbtest.rake +47 -0
  1315. data/modules/mruby/test/report.rb +4 -0
  1316. data/modules/mruby/test/t/argumenterror.rb +21 -0
  1317. data/modules/mruby/test/t/array.rb +309 -0
  1318. data/modules/mruby/test/t/basicobject.rb +11 -0
  1319. data/modules/mruby/test/t/bs_block.rb +489 -0
  1320. data/modules/mruby/test/t/bs_literal.rb +38 -0
  1321. data/modules/mruby/test/t/class.rb +219 -0
  1322. data/modules/mruby/test/t/comparable.rb +72 -0
  1323. data/modules/mruby/test/t/enumerable.rb +108 -0
  1324. data/modules/mruby/test/t/exception.rb +337 -0
  1325. data/modules/mruby/test/t/false.rb +33 -0
  1326. data/modules/mruby/test/t/float.rb +145 -0
  1327. data/modules/mruby/test/t/gc.rb +45 -0
  1328. data/modules/mruby/test/t/hash.rb +310 -0
  1329. data/modules/mruby/test/t/indexerror.rb +10 -0
  1330. data/modules/mruby/test/t/integer.rb +222 -0
  1331. data/modules/mruby/test/t/kernel.rb +425 -0
  1332. data/modules/mruby/test/t/literals.rb +287 -0
  1333. data/modules/mruby/test/t/localjumperror.rb +13 -0
  1334. data/modules/mruby/test/t/methods.rb +109 -0
  1335. data/modules/mruby/test/t/module.rb +344 -0
  1336. data/modules/mruby/test/t/nameerror.rb +32 -0
  1337. data/modules/mruby/test/t/nil.rb +29 -0
  1338. data/modules/mruby/test/t/nomethoderror.rb +13 -0
  1339. data/modules/mruby/test/t/numeric.rb +29 -0
  1340. data/modules/mruby/test/t/object.rb +11 -0
  1341. data/modules/mruby/test/t/proc.rb +56 -0
  1342. data/modules/mruby/test/t/range.rb +82 -0
  1343. data/modules/mruby/test/t/rangeerror.rb +10 -0
  1344. data/modules/mruby/test/t/regexperror.rb +4 -0
  1345. data/modules/mruby/test/t/runtimeerror.rb +6 -0
  1346. data/modules/mruby/test/t/standarderror.rb +10 -0
  1347. data/modules/mruby/test/t/string.rb +483 -0
  1348. data/modules/mruby/test/t/symbol.rb +27 -0
  1349. data/modules/mruby/test/t/syntax.rb +67 -0
  1350. data/modules/mruby/test/t/true.rb +33 -0
  1351. data/modules/mruby/test/t/typeerror.rb +11 -0
  1352. data/modules/mruby/tools/mrbc/mrbc.c +318 -0
  1353. data/modules/mruby/tools/mrbc/mrbc.rake +14 -0
  1354. data/modules/mruby/travis_config.rb +6 -0
  1355. data/modules/mrubymix/LICENSE +21 -0
  1356. data/modules/mrubymix/README.md +6 -0
  1357. data/modules/mrubymix/bin/mrubymix +29 -0
  1358. data/modules/mrubymix/lib/mrubymix.rb +93 -0
  1359. data/modules/mrubymix/mrubymix.gemspec +13 -0
  1360. data/scripts/gen_gems_config.rb +185 -0
  1361. data/scripts/gen_post.rb +104 -0
  1362. data/templates/minimal/Rakefile +36 -0
  1363. data/templates/minimal/app/app.rb +3 -0
  1364. metadata +1408 -0
@@ -0,0 +1,2474 @@
1
+ //"use strict";
2
+
3
+ // Various tools for parsing LLVM. Utilities of various sorts, that are
4
+ // specific to Emscripten (and hence not in utility.js).
5
+
6
+ // Does simple 'macro' substitution, using Django-like syntax,
7
+ // {{{ code }}} will be replaced with |eval(code)|.
8
+ function processMacros(text) {
9
+ return text.replace(/{{{([^}]|}(?!}))+}}}/g, function(str) {
10
+ str = str.substr(3, str.length-6);
11
+ var ret = eval(str);
12
+ return ret ? ret.toString() : '';
13
+ });
14
+ }
15
+
16
+ // Simple #if/else/endif preprocessing for a file. Checks if the
17
+ // ident checked is true in our global.
18
+ function preprocess(text) {
19
+ var lines = text.split('\n');
20
+ var ret = '';
21
+ var showStack = [];
22
+ for (var i = 0; i < lines.length; i++) {
23
+ var line = lines[i];
24
+ if (line[line.length-1] == '\r') {
25
+ line = line.substr(0, line.length-1); // Windows will have '\r' left over from splitting over '\r\n'
26
+ }
27
+ if (!line[0] || line[0] != '#') {
28
+ if (showStack.indexOf(false) == -1) {
29
+ ret += line + '\n';
30
+ }
31
+ } else {
32
+ if (line[1] && line[1] == 'i') { // if
33
+ var parts = line.split(' ');
34
+ var ident = parts[1];
35
+ var op = parts[2];
36
+ var value = parts[3];
37
+ if (op) {
38
+ assert(op === '==')
39
+ showStack.push(ident in this && this[ident] == value);
40
+ } else {
41
+ showStack.push(ident in this && this[ident] > 0);
42
+ }
43
+ } else if (line[2] && line[2] == 'l') { // else
44
+ showStack.push(!showStack.pop());
45
+ } else if (line[2] && line[2] == 'n') { // endif
46
+ showStack.pop();
47
+ } else {
48
+ throw "Unclear preprocessor command: " + line;
49
+ }
50
+ }
51
+ }
52
+ assert(showStack.length == 0);
53
+ return ret;
54
+ }
55
+
56
+ function addPointing(type) { return type + '*' }
57
+ function removePointing(type, num) {
58
+ if (num === 0) return type;
59
+ assert(type.substr(type.length-(num ? num : 1)).replace(/\*/g, '') === ''); //, 'Error in removePointing with ' + [type, num, type.substr(type.length-(num ? num : 1))]);
60
+ return type.substr(0, type.length-(num ? num : 1));
61
+ }
62
+
63
+ function pointingLevels(type) {
64
+ if (!type) return 0;
65
+ var ret = 0;
66
+ var len1 = type.length - 1;
67
+ while (type[len1-ret] && type[len1-ret] === '*') {
68
+ ret++;
69
+ }
70
+ return ret;
71
+ }
72
+
73
+ function removeAllPointing(type) {
74
+ return removePointing(type, pointingLevels(type));
75
+ }
76
+
77
+ function toNiceIdent(ident) {
78
+ assert(ident);
79
+ if (parseFloat(ident) == ident) return ident;
80
+ if (ident == 'null') return '0'; // see parseNumerical
81
+ if (ident == 'undef') return '0';
82
+ return ident.replace('%', '$').replace(/["&\\ \.@:<>,\*\[\]\(\)-]/g, '_');
83
+ }
84
+
85
+ // Kind of a hack. In some cases we have strings that we do not want
86
+ // to |toNiceIdent|, as they are the output of previous processing. We
87
+ // should refactor everything into an object, with an explicit flag
88
+ // saying what has been |toNiceIdent|ed. Until then, this will detect
89
+ // simple idents that are in need of |toNiceIdent|ation. Or, we should
90
+ // ensure that processed strings never start with %,@, e.g. by always
91
+ // enclosing them in ().
92
+ function toNiceIdentCarefully(ident) {
93
+ if (ident[0] == '%' || ident[0] == '@') ident = toNiceIdent(ident);
94
+ return ident;
95
+ }
96
+
97
+ // Returns true if ident is a niceIdent (see toNiceIdent). If loose
98
+ // is true, then also allow () and spaces.
99
+ function isNiceIdent(ident, loose) {
100
+ if (loose) {
101
+ return /^\(?[$_]+[\w$_\d ]*\)?$/.test(ident);
102
+ } else {
103
+ return /^[$_]+[\w$_\d]*$/.test(ident);
104
+ }
105
+ }
106
+
107
+ function isJSVar(ident) {
108
+ return /^\(?[$_]?[\w$_\d ]*\)+$/.test(ident);
109
+
110
+ }
111
+
112
+ function isLocalVar(ident) {
113
+ return ident[0] == '$';
114
+ }
115
+
116
+ function isStructPointerType(type) {
117
+ // This test is necessary for clang - in llvm-gcc, we
118
+ // could check for %struct. The downside is that %1 can
119
+ // be either a variable or a structure, and we guess it is
120
+ // a struct, which can lead to |call i32 %5()| having
121
+ // |%5()| as a function call (like |i32 (i8*)| etc.). So
122
+ // we must check later on, in call(), where we have more
123
+ // context, to differentiate such cases.
124
+ // A similar thing happens in isStructType()
125
+ return !Runtime.isNumberType(type) && type[0] == '%';
126
+ }
127
+
128
+ function isPointerType(type) {
129
+ return type[type.length-1] == '*';
130
+ }
131
+
132
+ function isArrayType(type) {
133
+ return /^\[\d+\ x\ (.*)\]/.test(type);
134
+ }
135
+
136
+ function isStructType(type) {
137
+ if (isPointerType(type)) return false;
138
+ if (isArrayType(type)) return true;
139
+ if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
140
+ // See comment in isStructPointerType()
141
+ return type[0] == '%';
142
+ }
143
+
144
+ function isStructuralType(type) {
145
+ return /^{ ?[^}]* ?}$/.test(type); // { i32, i8 } etc. - anonymous struct types
146
+ }
147
+
148
+ function getStructuralTypeParts(type) { // split { i32, i8 } etc. into parts
149
+ return type.replace(/[ {}]/g, '').split(',');
150
+ }
151
+
152
+ function getStructureTypeParts(type) {
153
+ if (isStructuralType(type)) {
154
+ return type.replace(/[ {}]/g, '').split(',');
155
+ } else {
156
+ var typeData = Types.types[type];
157
+ assert(typeData, type);
158
+ return typeData.fields;
159
+ }
160
+ }
161
+
162
+ function getStructuralTypePartBits(part) {
163
+ return Math.ceil((getBits(part) || 32)/32)*32; // simple 32-bit alignment. || 32 is for pointers
164
+ }
165
+
166
+ function isIntImplemented(type) {
167
+ return type[0] == 'i' || isPointerType(type);
168
+ }
169
+
170
+ // Note: works for iX types and structure types, not pointers (even though they are implemented as ints)
171
+ function getBits(type, allowPointers) {
172
+ if (allowPointers && isPointerType(type)) return 32;
173
+ if (!type) return 0;
174
+ if (type[0] == 'i') {
175
+ var left = type.substr(1);
176
+ if (!isNumber(left)) return 0;
177
+ return parseInt(left);
178
+ }
179
+ if (isStructuralType(type)) {
180
+ return sum(getStructuralTypeParts(type).map(getStructuralTypePartBits));
181
+ }
182
+ if (isStructType(type)) {
183
+ var typeData = Types.types[type];
184
+ if (typeData === undefined) return 0;
185
+ return typeData.flatSize*8;
186
+ }
187
+ return 0;
188
+ }
189
+
190
+ function getNumIntChunks(type) {
191
+ return Math.ceil(getBits(type, true)/32);
192
+ }
193
+
194
+ function isIdenticallyImplemented(type1, type2) {
195
+ var floats = +(type1 in Runtime.FLOAT_TYPES) + +(type2 in Runtime.FLOAT_TYPES);
196
+ if (floats == 2) return true;
197
+ if (floats == 1) return false;
198
+ return getNumIntChunks(type1) == getNumIntChunks(type2);
199
+ }
200
+
201
+ function isIllegalType(type) {
202
+ var bits = getBits(type);
203
+ return bits > 0 && (bits >= 64 || !isPowerOfTwo(bits));
204
+ }
205
+
206
+ function isVoidType(type) {
207
+ return type == 'void';
208
+ }
209
+
210
+ // Detects a function definition, ([...|type,[type,...]])
211
+ function isFunctionDef(token, out) {
212
+ var text = token.text;
213
+ var nonPointing = removeAllPointing(text);
214
+ if (nonPointing[0] != '(' || nonPointing.substr(-1) != ')')
215
+ return false;
216
+ if (nonPointing === '()') return true;
217
+ if (!token.item) return false;
218
+ var fail = false;
219
+ var segments = splitTokenList(token.item.tokens);
220
+ segments.forEach(function(segment) {
221
+ var subtext = segment[0].text;
222
+ fail = fail || segment.length > 1 || !(isType(subtext) || subtext == '...');
223
+ });
224
+ if (out) {
225
+ out.segments = segments;
226
+ out.numArgs = segments.length;
227
+ }
228
+ return !fail;
229
+ }
230
+
231
+ function isPossiblyFunctionType(type) {
232
+ // A quick but unreliable way to see if something is a function type. Yes is just 'maybe', no is definite.
233
+ var len = type.length;
234
+ return type[len-2] == ')' && type[len-1] == '*';
235
+ }
236
+
237
+ function isFunctionType(type, out) {
238
+ if (!isPossiblyFunctionType(type)) return false;
239
+ type = type.substr(0, type.length-1); // remove final '*'
240
+ var firstOpen = type.indexOf('(');
241
+ if (firstOpen <= 0) return false;
242
+ type = type.replace(/"[^"]+"/g, '".."');
243
+ var lastOpen = type.lastIndexOf('(');
244
+ var returnType;
245
+ if (firstOpen == lastOpen) {
246
+ returnType = getReturnType(type);
247
+ if (!isType(returnType)) return false;
248
+ } else {
249
+ returnType = 'i8*'; // some pointer type, no point in analyzing further
250
+ }
251
+ if (out) out.returnType = returnType;
252
+ // find ( that starts the arguments
253
+ var depth = 0, i = type.length-1, argText = null;
254
+ while (i >= 0) {
255
+ var curr = type[i];
256
+ if (curr == ')') depth++;
257
+ else if (curr == '(') {
258
+ depth--;
259
+ if (depth == 0) {
260
+ argText = type.substr(i);
261
+ break;
262
+ }
263
+ }
264
+ i--;
265
+ }
266
+ assert(argText);
267
+ return isFunctionDef({ text: argText, item: tokenize(argText.substr(1, argText.length-2), true) }, out);
268
+ }
269
+
270
+ function getReturnType(type) {
271
+ if (pointingLevels(type) > 1) return '*'; // the type of a call can be either the return value, or the entire function. ** or more means it is a return value
272
+ var lastOpen = type.lastIndexOf('(');
273
+ if (lastOpen > 0) {
274
+ return type.substr(0, lastOpen-1);
275
+ }
276
+ return type;
277
+ }
278
+
279
+ var isTypeCache = {}; // quite hot, optimize as much as possible
280
+ function isType(type) {
281
+ if (type in isTypeCache) return isTypeCache[type];
282
+ var ret = isPointerType(type) || isVoidType(type) || Runtime.isNumberType(type) || isStructType(type) || isFunctionType(type);
283
+ isTypeCache[type] = ret;
284
+ return ret;
285
+ }
286
+
287
+ function isVarArgsFunctionType(type) {
288
+ // assumes this is known to be a function type already
289
+ var varArgsSuffix = '...)*';
290
+ return type.substr(-varArgsSuffix.length) == varArgsSuffix;
291
+ }
292
+
293
+ function getNumLegalizedVars(type) { // how many legalized variables are needed to represent this type
294
+ if (type in Runtime.FLOAT_TYPES) return 1;
295
+ return Math.max(getNumIntChunks(type), 1);
296
+ }
297
+
298
+ function countNormalArgs(type, out, legalized) {
299
+ out = out || {};
300
+ if (!isFunctionType(type, out)) return -1;
301
+ var ret = 0;
302
+ if (out.segments) {
303
+ for (var i = 0; i < out.segments.length; i++) {
304
+ ret += legalized ? getNumLegalizedVars(out.segments[i][0].text) : 1;
305
+ }
306
+ }
307
+ if (isVarArgsFunctionType(type)) ret--;
308
+ return ret;
309
+ }
310
+
311
+ function addIdent(token) {
312
+ token.ident = token.text;
313
+ return token;
314
+ }
315
+
316
+ function combineTokens(tokens) {
317
+ var ret = {
318
+ lineNum: tokens[0].lineNum,
319
+ text: '',
320
+ tokens: []
321
+ };
322
+ tokens.forEach(function(token) {
323
+ ret.text += token.text;
324
+ ret.tokens.push(token);
325
+ });
326
+ return ret;
327
+ }
328
+
329
+ function compareTokens(a, b) {
330
+ var aId = a.__uid__;
331
+ var bId = b.__uid__;
332
+ a.__uid__ = 0;
333
+ b.__uid__ = 0;
334
+ var ret = JSON.stringify(a) == JSON.stringify(b);
335
+ a.__uid__ = aId;
336
+ b.__uid__ = bId;
337
+ return ret;
338
+ }
339
+
340
+ function getTokenIndexByText(tokens, text) {
341
+ var i = 0;
342
+ while (tokens[i] && tokens[i].text != text) i++;
343
+ return i;
344
+ }
345
+
346
+ function findTokenText(item, text) {
347
+ return findTokenTextAfter(item, text, 0);
348
+ }
349
+
350
+ function findTokenTextAfter(item, text, startAt) {
351
+ for (var i = startAt; i < item.tokens.length; i++) {
352
+ if (item.tokens[i].text == text) return i;
353
+ }
354
+ return -1;
355
+ }
356
+
357
+ var SPLIT_TOKEN_LIST_SPLITTERS = set(',', 'to'); // 'to' can separate parameters as well...
358
+
359
+ // Splits a list of tokens separated by commas. For example, a list of arguments in a function call
360
+ function splitTokenList(tokens) {
361
+ if (tokens.length == 0) return [];
362
+ if (!tokens.slice) tokens = tokens.tokens;
363
+ if (tokens.slice(-1)[0].text != ',') tokens.push({text:','});
364
+ var ret = [];
365
+ var seg = [];
366
+ for (var i = 0; i < tokens.length; i++) {
367
+ var token = tokens[i];
368
+ if (token.text in SPLIT_TOKEN_LIST_SPLITTERS) {
369
+ ret.push(seg);
370
+ seg = [];
371
+ } else if (token.text == ';') {
372
+ ret.push(seg);
373
+ break;
374
+ } else {
375
+ seg.push(token);
376
+ }
377
+ }
378
+ return ret;
379
+ }
380
+
381
+ function parseParamTokens(params) {
382
+ if (params.length === 0) return [];
383
+ var ret = [];
384
+ if (params[params.length-1].text != ',') {
385
+ params.push({ text: ',' });
386
+ }
387
+ var anonymousIndex = 0;
388
+ while (params.length > 0) {
389
+ var i = 0;
390
+ while (params[i].text != ',') i++;
391
+ var segment = params.slice(0, i);
392
+ params = params.slice(i+1);
393
+ segment = cleanSegment(segment);
394
+ var byVal = 0;
395
+ if (segment[1] && segment[1].text === 'byval') {
396
+ // handle 'byval' and 'byval align X'. We store the alignment in 'byVal'
397
+ byVal = QUANTUM_SIZE;
398
+ segment.splice(1, 1);
399
+ if (segment[1] && segment[1].text === 'align') {
400
+ assert(isNumber(segment[2].text));
401
+ byVal = parseInt(segment[2].text);
402
+ segment.splice(1, 2);
403
+ }
404
+ }
405
+ if (segment.length == 1) {
406
+ if (segment[0].text == '...') {
407
+ ret.push({
408
+ intertype: 'varargs',
409
+ type: 'i8*',
410
+ ident: 'varrp' // the conventional name we have for this
411
+ });
412
+ } else {
413
+ // Clang sometimes has a parameter with just a type,
414
+ // no name... the name is implied to be %{the index}
415
+ ret.push({
416
+ intertype: 'value',
417
+ type: segment[0].text,
418
+ ident: toNiceIdent('%') + anonymousIndex
419
+ });
420
+ Types.needAnalysis[ret[ret.length-1].type] = 0;
421
+ anonymousIndex ++;
422
+ }
423
+ } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) {
424
+ ret.push(parseLLVMFunctionCall(segment));
425
+ } else if (segment[1].text === 'blockaddress') {
426
+ ret.push(parseBlockAddress(segment));
427
+ } else {
428
+ if (segment[2] && segment[2].text == 'to') { // part of bitcast params
429
+ segment = segment.slice(0, 2);
430
+ }
431
+ while (segment.length > 2) {
432
+ segment[0].text += segment[1].text;
433
+ segment.splice(1, 1); // TODO: merge tokens nicely
434
+ }
435
+ ret.push({
436
+ intertype: 'value',
437
+ type: segment[0].text,
438
+ ident: toNiceIdent(parseNumerical(segment[1].text, segment[0].text))
439
+ });
440
+ Types.needAnalysis[removeAllPointing(ret[ret.length-1].type)] = 0;
441
+ }
442
+ ret[ret.length-1].byVal = byVal;
443
+ }
444
+ return ret;
445
+ }
446
+
447
+ function hasVarArgs(params) {
448
+ for (var i = 0; i < params.length; i++) {
449
+ if (params[i].intertype == 'varargs') {
450
+ return true;
451
+ }
452
+ }
453
+ return false;
454
+ }
455
+
456
+ var UNINDEXABLE_GLOBALS = set(
457
+ '_llvm_global_ctors' // special-cased
458
+ );
459
+
460
+ function isIndexableGlobal(ident) {
461
+ if (!(ident in Variables.globals)) return false;
462
+ if (ident in UNINDEXABLE_GLOBALS) {
463
+ Variables.globals[ident].unIndexable = true;
464
+ return false;
465
+ }
466
+ var data = Variables.globals[ident];
467
+ return !data.alias && !data.external;
468
+ }
469
+
470
+ function isBSS(item) {
471
+ if (!USE_BSS) {
472
+ return false;
473
+ }
474
+
475
+ if (item.external) return false; // externals are typically implemented in a JS library, and must be accessed by name, explicitly
476
+
477
+ // return true if a global is uninitialized or initialized to 0
478
+ return (item.value && item.value.intertype === 'emptystruct') ||
479
+ (item.value && item.value.value !== undefined && item.value.value === '0');
480
+ }
481
+
482
+ function makeGlobalDef(ident) {
483
+ if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return '';
484
+ return 'var ' + ident + ';';
485
+ }
486
+
487
+ function makeGlobalUse(ident) {
488
+ if (!NAMED_GLOBALS && isIndexableGlobal(ident)) {
489
+ var index = Variables.indexedGlobals[ident];
490
+ if (index === undefined) {
491
+ // we are accessing this before we index globals, likely from the library. mark as unindexable
492
+ UNINDEXABLE_GLOBALS[ident] = 1;
493
+ return ident;
494
+ }
495
+ var ret = (Runtime.GLOBAL_BASE + index).toString();
496
+ if (SIDE_MODULE) ret = '(H_BASE+' + ret + ')';
497
+ return ret;
498
+ }
499
+ return ident;
500
+ }
501
+
502
+ function sortGlobals(globals) {
503
+ var ks = keys(globals);
504
+ ks.sort();
505
+ var inv = invertArray(ks);
506
+ return values(globals).sort(function(a, b) {
507
+ // sort globals based on if they need to be explicitly initialized or not (moving
508
+ // values that don't need to be to the end of the array). if equal, sort by name.
509
+ return (Number(isBSS(a)) - Number(isBSS(b))) ||
510
+ (inv[b.ident] - inv[a.ident]);
511
+ });
512
+ }
513
+
514
+ function finalizeParam(param) {
515
+ if (param.intertype in PARSABLE_LLVM_FUNCTIONS) {
516
+ return finalizeLLVMFunctionCall(param);
517
+ } else if (param.intertype === 'blockaddress') {
518
+ return finalizeBlockAddress(param);
519
+ } else if (param.intertype === 'jsvalue') {
520
+ return param.ident;
521
+ } else {
522
+ if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) {
523
+ return parseI64Constant(param.ident);
524
+ }
525
+ var ret = toNiceIdent(param.ident);
526
+ if (ret in Variables.globals) {
527
+ ret = makeGlobalUse(ret);
528
+ }
529
+ return ret;
530
+ }
531
+ }
532
+
533
+ // Segment ==> Parameter
534
+ function parseLLVMSegment(segment) {
535
+ var type;
536
+ if (segment.length == 1) {
537
+ if (isType(segment[0].text)) {
538
+ Types.needAnalysis[segment[0].text] = 0;
539
+ return {
540
+ intertype: 'type',
541
+ ident: toNiceIdent(segment[0].text),
542
+ type: segment[0].text
543
+ };
544
+ } else {
545
+ return {
546
+ intertype: 'value',
547
+ ident: toNiceIdent(segment[0].text),
548
+ type: 'i32'
549
+ };
550
+ }
551
+ } else if (segment[1].type && segment[1].type == '{') {
552
+ type = segment[0].text;
553
+ Types.needAnalysis[type] = 0;
554
+ return {
555
+ intertype: 'structvalue',
556
+ params: splitTokenList(segment[1].tokens).map(parseLLVMSegment),
557
+ type: type
558
+ };
559
+ } else if (segment[0].text in PARSABLE_LLVM_FUNCTIONS) {
560
+ return parseLLVMFunctionCall([{text: '?'}].concat(segment));
561
+ } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) {
562
+ return parseLLVMFunctionCall(segment);
563
+ } else if (segment[1].text === 'blockaddress') {
564
+ return parseBlockAddress(segment);
565
+ } else {
566
+ type = segment[0].text;
567
+ Types.needAnalysis[type] = 0;
568
+ return {
569
+ intertype: 'value',
570
+ ident: toNiceIdent(segment[1].text),
571
+ type: type
572
+ };
573
+ }
574
+ }
575
+
576
+ function cleanSegment(segment) {
577
+ while (segment.length >= 2 && ['noalias', 'sret', 'nocapture', 'nest', 'zeroext', 'signext'].indexOf(segment[1].text) != -1) {
578
+ segment.splice(1, 1);
579
+ }
580
+ return segment;
581
+ }
582
+
583
+ var MATHOPS = set(['add', 'sub', 'sdiv', 'udiv', 'mul', 'icmp', 'zext', 'urem', 'srem', 'fadd', 'fsub', 'fmul', 'fdiv', 'fcmp', 'frem', 'uitofp', 'sitofp', 'fpext', 'fptrunc', 'fptoui', 'fptosi', 'trunc', 'sext', 'select', 'shl', 'shr', 'ashl', 'ashr', 'lshr', 'lshl', 'xor', 'or', 'and', 'ptrtoint', 'inttoptr']);
584
+
585
+ var PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast');
586
+ mergeInto(PARSABLE_LLVM_FUNCTIONS, MATHOPS);
587
+
588
+ // Parses a function call of form
589
+ // TYPE functionname MODIFIERS (...)
590
+ // e.g.
591
+ // i32* getelementptr inbounds (...)
592
+ function parseLLVMFunctionCall(segment) {
593
+ segment = segment.slice(0);
594
+ segment = cleanSegment(segment);
595
+ // Remove additional modifiers
596
+ var variant = null;
597
+ if (!segment[2] || !segment[2].item) {
598
+ variant = segment.splice(2, 1)[0];
599
+ if (variant && variant.text) variant = variant.text; // needed for mathops
600
+ }
601
+ assertTrue(['inreg', 'byval'].indexOf(segment[1].text) == -1);
602
+ assert(segment[1].text in PARSABLE_LLVM_FUNCTIONS);
603
+ while (!segment[2].item) {
604
+ segment.splice(2, 1); // Remove modifiers
605
+ if (!segment[2]) throw 'Invalid segment!';
606
+ }
607
+ var intertype = segment[1].text;
608
+ var type = segment[0].text;
609
+ if (type === '?') {
610
+ if (intertype === 'getelementptr') {
611
+ type = '*'; // a pointer, we can easily say, this is
612
+ } else if (segment[2].item.tokens.slice(-2)[0].text === 'to') {
613
+ type = segment[2].item.tokens.slice(-1)[0].text;
614
+ }
615
+ }
616
+ var ret = {
617
+ intertype: intertype,
618
+ variant: variant,
619
+ type: type,
620
+ params: parseParamTokens(segment[2].item.tokens)
621
+ };
622
+ Types.needAnalysis[ret.type] = 0;
623
+ ret.ident = toNiceIdent(ret.params[0].ident || 'NOIDENT');
624
+ return ret;
625
+ }
626
+
627
+ // Gets an array of tokens, we parse out the first
628
+ // 'ident' - either a simple ident of one token, or
629
+ // an LLVM internal function that generates an ident.
630
+ // We shift out of the array list the tokens that
631
+ // we ate.
632
+ function eatLLVMIdent(tokens) {
633
+ var ret;
634
+ if (tokens[0].text in PARSABLE_LLVM_FUNCTIONS) {
635
+ var item = parseLLVMFunctionCall([{text: '?'}].concat(tokens.slice(0,2))); // TODO: Handle more cases, return a full object, process it later
636
+ if (item.intertype == 'bitcast') checkBitcast(item);
637
+ ret = item.ident;
638
+ tokens.shift();
639
+ tokens.shift();
640
+ } else {
641
+ ret = tokens[0].text;
642
+ tokens.shift();
643
+ }
644
+ return ret;
645
+ }
646
+
647
+ function cleanOutTokens(filterOut, tokens, indexes) {
648
+ if (typeof indexes !== 'object') indexes = [indexes];
649
+ for (var i = indexes.length-1; i >=0; i--) {
650
+ var index = indexes[i];
651
+ while (index < tokens.length && tokens[index].text in filterOut) {
652
+ tokens.splice(index, 1);
653
+ }
654
+ }
655
+ }
656
+
657
+ function _IntToHex(x) {
658
+ assert(x >= 0 && x <= 15);
659
+ if (x <= 9) {
660
+ return String.fromCharCode('0'.charCodeAt(0) + x);
661
+ } else {
662
+ return String.fromCharCode('A'.charCodeAt(0) + x - 10);
663
+ }
664
+ }
665
+
666
+ function IEEEUnHex(stringy) {
667
+ stringy = stringy.substr(2); // leading '0x';
668
+ if (stringy.replace(/0/g, '') === '') return 0;
669
+ while (stringy.length < 16) stringy = '0' + stringy;
670
+ if (FAKE_X86_FP80 && stringy.length > 16) {
671
+ stringy = stringy.substr(stringy.length-16, 16);
672
+ assert(TARGET_X86, 'must only see >64 bit floats in x86, as fp80s');
673
+ warnOnce('.ll contains floating-point values with more than 64 bits. Faking values for them. If they are used, this will almost certainly break horribly!');
674
+ }
675
+ assert(stringy.length === 16, 'Can only unhex 16-digit double numbers, nothing platform-specific'); // |long double| can cause x86_fp80 which causes this
676
+ var top = eval('0x' + stringy[0]);
677
+ var neg = !!(top & 8); // sign
678
+ if (neg) {
679
+ stringy = _IntToHex(top & ~8) + stringy.substr(1);
680
+ }
681
+ var a = eval('0x' + stringy.substr(0, 8)); // top half
682
+ var b = eval('0x' + stringy.substr(8)); // bottom half
683
+ var e = a >> ((52 - 32) & 0x7ff); // exponent
684
+ a = a & 0xfffff;
685
+ if (e === 0x7ff) {
686
+ if (a == 0 && b == 0) {
687
+ return neg ? '-Infinity' : 'Infinity';
688
+ } else {
689
+ return 'NaN';
690
+ }
691
+ }
692
+ e -= 1023; // offset
693
+ var absolute = ((((a | 0x100000) * 1.0) / Math.pow(2,52-32)) * Math.pow(2, e)) + (((b * 1.0) / Math.pow(2, 52)) * Math.pow(2, e));
694
+ return (absolute * (neg ? -1 : 1)).toString();
695
+ }
696
+
697
+ // Given an expression like (VALUE=VALUE*2,VALUE<10?VALUE:t+1) , this will
698
+ // replace VALUE with value. If value is not a simple identifier of a variable,
699
+ // value will be replaced with tempVar.
700
+ function makeInlineCalculation(expression, value, tempVar) {
701
+ if (!isNiceIdent(value, true)) {
702
+ expression = tempVar + '=' + value + ',' + expression;
703
+ value = tempVar;
704
+ }
705
+ return '(' + expression.replace(/VALUE/g, value) + ')';
706
+ }
707
+
708
+ // Makes a proper runtime value for a 64-bit value from low and high i32s. low and high are assumed to be unsigned.
709
+ function makeI64(low, high) {
710
+ high = high || '0';
711
+ if (USE_TYPED_ARRAYS == 2) {
712
+ return '[' + makeSignOp(low, 'i32', 'un', 1, 1) + ',' + makeSignOp(high, 'i32', 'un', 1, 1) + ']';
713
+ } else {
714
+ if (high) return RuntimeGenerator.makeBigInt(low, high);
715
+ return low;
716
+ }
717
+ }
718
+
719
+ // XXX Make all i64 parts signed
720
+
721
+ // Splits a number (an integer in a double, possibly > 32 bits) into an USE_TYPED_ARRAYS == 2 i64 value.
722
+ // Will suffer from rounding. mergeI64 does the opposite.
723
+ function splitI64(value, floatConversion) {
724
+ // We need to min here, since our input might be a double, and large values are rounded, so they can
725
+ // be slightly higher than expected. And if we get 4294967296, that will turn into a 0 if put into a
726
+ // HEAP32 or |0'd, etc.
727
+ var lowInput = legalizedI64s ? value : 'VALUE';
728
+ if (floatConversion && ASM_JS) lowInput = asmFloatToInt(lowInput);
729
+ if (legalizedI64s) {
730
+ return [lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor((' + value + ')/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0'];
731
+ } else {
732
+ return makeInlineCalculation(makeI64(lowInput + '>>>0', asmCoercion('Math.min(' + asmCoercion('Math.floor(VALUE/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0'), value, 'tempBigIntP');
733
+ }
734
+ }
735
+ function mergeI64(value, unsigned) {
736
+ assert(USE_TYPED_ARRAYS == 2);
737
+ if (legalizedI64s) {
738
+ return RuntimeGenerator.makeBigInt(value + '$0', value + '$1', unsigned);
739
+ } else {
740
+ return makeInlineCalculation(RuntimeGenerator.makeBigInt('VALUE[0]', 'VALUE[1]', unsigned), value, 'tempI64');
741
+ }
742
+ }
743
+
744
+ // Takes an i64 value and changes it into the [low, high] form used in i64 mode 1. In that
745
+ // mode, this is a no-op
746
+ function ensureI64_1(value) {
747
+ if (USE_TYPED_ARRAYS == 2) return value;
748
+ return splitI64(value, 1);
749
+ }
750
+
751
+ function makeCopyI64(value) {
752
+ assert(USE_TYPED_ARRAYS == 2);
753
+ return value + '.slice(0)';
754
+ }
755
+
756
+ // Given a string representation of an integer of arbitrary size, return it
757
+ // split up into 32-bit chunks
758
+ function parseArbitraryInt(str, bits) {
759
+ // We parse the string into a vector of digits, base 10. This is convenient to work on.
760
+
761
+ assert(bits > 0); // NB: we don't check that the value in str can fit in this amount of bits
762
+
763
+ function str2vec(s) { // index 0 is the highest value
764
+ var ret = [];
765
+ for (var i = 0; i < s.length; i++) {
766
+ ret.push(s.charCodeAt(i) - '0'.charCodeAt(0));
767
+ }
768
+ return ret;
769
+ }
770
+
771
+ function divide2(v) { // v /= 2
772
+ for (var i = v.length-1; i >= 0; i--) {
773
+ var d = v[i];
774
+ var r = d % 2;
775
+ d = Math.floor(d/2);
776
+ v[i] = d;
777
+ if (r) {
778
+ assert(i+1 < v.length);
779
+ var d2 = v[i+1];
780
+ d2 += 5;
781
+ if (d2 >= 10) {
782
+ v[i] = d+1;
783
+ d2 -= 10;
784
+ }
785
+ v[i+1] = d2;
786
+ }
787
+ }
788
+ }
789
+
790
+ function mul2(v) { // v *= 2
791
+ for (var i = v.length-1; i >= 0; i--) {
792
+ var d = v[i]*2;
793
+ r = d >= 10;
794
+ v[i] = d%10;
795
+ var j = i-1;
796
+ if (r) {
797
+ if (j < 0) {
798
+ v.unshift(1);
799
+ break;
800
+ }
801
+ v[j] += 0.5; // will be multiplied
802
+ }
803
+ }
804
+ }
805
+
806
+ function subtract(v, w) { // v -= w. we assume v >= w
807
+ while (v.length > w.length) w.splice(0, 0, 0);
808
+ for (var i = 0; i < v.length; i++) {
809
+ v[i] -= w[i];
810
+ if (v[i] < 0) {
811
+ v[i] += 10;
812
+ // find something to take from
813
+ var j = i-1;
814
+ while (v[j] == 0) {
815
+ v[j] = 9;
816
+ j--;
817
+ assert(j >= 0);
818
+ }
819
+ v[j]--;
820
+ }
821
+ }
822
+ }
823
+
824
+ function isZero(v) {
825
+ for (var i = 0; i < v.length; i++) {
826
+ if (v[i] > 0) return false;
827
+ }
828
+ return true;
829
+ }
830
+
831
+ var v;
832
+
833
+ if (str[0] == '-') {
834
+ // twos-complement is needed
835
+ str = str.substr(1);
836
+ v = str2vec('1');
837
+ for (var i = 0; i < bits; i++) {
838
+ mul2(v);
839
+ }
840
+ subtract(v, str2vec(str));
841
+ } else {
842
+ v = str2vec(str);
843
+ }
844
+
845
+ var bitsv = [];
846
+ while (!isZero(v)) {
847
+ bitsv.push((v[v.length-1] % 2 != 0)+0);
848
+ v[v.length-1] = v[v.length-1] & 0xfe;
849
+ divide2(v);
850
+ }
851
+
852
+ var ret = zeros(Math.ceil(bits/32));
853
+ for (var i = 0; i < bitsv.length; i++) {
854
+ ret[Math.floor(i/32)] += bitsv[i]*Math.pow(2, i % 32);
855
+ }
856
+ return ret;
857
+ }
858
+
859
+ function parseI64Constant(str, legalized) {
860
+ if (!isNumber(str)) {
861
+ // This is a variable. Copy it, so we do not modify the original
862
+ return legalizedI64s ? str : makeCopyI64(str);
863
+ }
864
+
865
+ var parsed = parseArbitraryInt(str, 64);
866
+ if (legalizedI64s || legalized) return parsed;
867
+ return '[' + parsed[0] + ',' + parsed[1] + ']';
868
+ }
869
+
870
+ function parseNumerical(value, type) {
871
+ if ((!type || type == 'double' || type == 'float') && (value.substr && value.substr(0,2) == '0x')) {
872
+ // Hexadecimal double value, as the llvm docs say,
873
+ // "The one non-intuitive notation for constants is the hexadecimal form of floating point constants."
874
+ value = IEEEUnHex(value);
875
+ } else if (USE_TYPED_ARRAYS == 2 && isIllegalType(type)) {
876
+ return value; // do not parseFloat etc., that can lead to loss of precision
877
+ } else if (value == 'null') {
878
+ // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
879
+ value = '0';
880
+ } else if (value === 'true') {
881
+ return '1';
882
+ } else if (value === 'false') {
883
+ return '0';
884
+ }
885
+ if (isNumber(value)) {
886
+ var ret = parseFloat(value); // will change e.g. 5.000000e+01 to 50
887
+ if (type in Runtime.FLOAT_TYPES && value[0] == '-' && ret === 0) return '-0'; // fix negative 0, toString makes it 0
888
+ return ret.toString();
889
+ } else {
890
+ return value;
891
+ }
892
+ }
893
+
894
+ // \0Dsometext is really '\r', then sometext
895
+ // This function returns an array of int values
896
+ function parseLLVMString(str) {
897
+ var ret = [];
898
+ var i = 0;
899
+ while (i < str.length) {
900
+ var chr = str[i];
901
+ if (chr != '\\') {
902
+ ret.push(chr.charCodeAt(0));
903
+ i++;
904
+ } else {
905
+ ret.push(eval('0x' + str[i+1]+str[i+2]));
906
+ i += 3;
907
+ }
908
+ }
909
+ return ret;
910
+ }
911
+
912
+ function getLabelIds(labels) {
913
+ return labels.map(function(label) { return label.ident });
914
+ }
915
+
916
+ function cleanLabel(label) {
917
+ if (label[0] == 'B') {
918
+ return label.substr(5);
919
+ } else {
920
+ return label;
921
+ }
922
+ }
923
+
924
+ function getOldLabel(label) {
925
+ var parts = label.split('|');
926
+ return parts[parts.length-1];
927
+ }
928
+
929
+ function calcAllocatedSize(type) {
930
+ if (pointingLevels(type) == 0 && isStructType(type)) {
931
+ return Types.types[type].flatSize; // makeEmptyStruct(item.allocatedType).length;
932
+ } else {
933
+ return Runtime.getNativeTypeSize(type); // We can really get away with '1', though, at least on the stack...
934
+ }
935
+ }
936
+
937
+ // Generates the type signature for a structure, for each byte, the type that is there.
938
+ // i32, 0, 0, 0 - for example, an int32 is here, then nothing to do for the 3 next bytes, naturally
939
+ function generateStructTypes(type) {
940
+ if (isArray(type)) return type; // already in the form of [type, type,...]
941
+ if (Runtime.isNumberType(type) || isPointerType(type)) {
942
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
943
+ return ['i64', 0, 0, 0, 'i32', 0, 0, 0];
944
+ }
945
+ return [type].concat(zeros(Runtime.getNativeFieldSize(type)-1));
946
+ }
947
+
948
+ // Avoid multiple concats by finding the size first. This is much faster
949
+ var typeData = Types.types[type];
950
+ var size = typeData.flatSize;
951
+ var ret = new Array(size);
952
+ var index = 0;
953
+ function add(typeData) {
954
+ var start = index;
955
+ for (var i = 0; i < typeData.fields.length; i++) {
956
+ var type = typeData.fields[i];
957
+ if (!SAFE_HEAP && isPointerType(type)) type = '*'; // do not include unneeded type names without safe heap
958
+ if (Runtime.isNumberType(type) || isPointerType(type)) {
959
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
960
+ ret[index++] = 'i64';
961
+ ret[index++] = 0;
962
+ ret[index++] = 0;
963
+ ret[index++] = 0;
964
+ ret[index++] = 'i32';
965
+ ret[index++] = 0;
966
+ ret[index++] = 0;
967
+ ret[index++] = 0;
968
+ continue;
969
+ }
970
+ ret[index++] = type;
971
+ } else {
972
+ add(Types.types[type]);
973
+ }
974
+ var more = (i+1 < typeData.fields.length ? typeData.flatIndexes[i+1] : typeData.flatSize) - (index - start);
975
+ for (var j = 0; j < more; j++) {
976
+ ret[index++] = 0;
977
+ }
978
+ }
979
+ }
980
+ add(typeData);
981
+ assert(index == size);
982
+ return ret;
983
+ }
984
+
985
+ // Flow blocks
986
+
987
+ function recurseBlock(block, func) {
988
+ var ret = [];
989
+ if (block.type == 'reloop') {
990
+ ret.push(func(block.inner));
991
+ } else if (block.type == 'multiple') {
992
+ block.entryLabels.forEach(function(entryLabel) { ret.push(func(entryLabel.block)) });
993
+ }
994
+ ret.push(func(block.next));
995
+ return ret;
996
+ }
997
+
998
+ function getActualLabelId(labelId) {
999
+ return labelId.split('|').slice(-1)[0];
1000
+ }
1001
+
1002
+ // Misc
1003
+
1004
+ function indentify(text, indent) {
1005
+ if (text.length > 1024*1024) return text; // Don't try to indentify huge strings - we may run out of memory
1006
+ if (typeof indent === 'number') {
1007
+ var len = indent;
1008
+ indent = '';
1009
+ for (var i = 0; i < len; i++) indent += ' ';
1010
+ }
1011
+ return text.replace(/\n/g, '\n' + indent);
1012
+ }
1013
+
1014
+ // Correction tools
1015
+
1016
+ function correctSpecificSign() {
1017
+ if (!Framework.currItem) return false;
1018
+ if (Framework.currItem.funcData.ident.indexOf('emscripten_autodebug') >= 0) return 1; // always correct in the autodebugger code!
1019
+ return (CORRECT_SIGNS === 2 && Debugging.getIdentifier() in CORRECT_SIGNS_LINES) ||
1020
+ (CORRECT_SIGNS === 3 && !(Debugging.getIdentifier() in CORRECT_SIGNS_LINES));
1021
+ }
1022
+ function correctSigns() {
1023
+ return CORRECT_SIGNS === 1 || correctSpecificSign();
1024
+ }
1025
+
1026
+ function correctSpecificOverflow() {
1027
+ if (!Framework.currItem) return false;
1028
+ return (CORRECT_OVERFLOWS === 2 && Debugging.getIdentifier() in CORRECT_OVERFLOWS_LINES) ||
1029
+ (CORRECT_OVERFLOWS === 3 && !(Debugging.getIdentifier() in CORRECT_OVERFLOWS_LINES));
1030
+ }
1031
+ function correctOverflows() {
1032
+ return CORRECT_OVERFLOWS === 1 || correctSpecificOverflow();
1033
+ }
1034
+
1035
+ function correctSpecificRounding() {
1036
+ if (!Framework.currItem) return false;
1037
+ return (CORRECT_ROUNDINGS === 2 && Debugging.getIdentifier() in CORRECT_ROUNDINGS_LINES) ||
1038
+ (CORRECT_ROUNDINGS === 3 && !(Debugging.getIdentifier() in CORRECT_ROUNDINGS_LINES));
1039
+ }
1040
+ function correctRoundings() {
1041
+ return CORRECT_ROUNDINGS === 1 || correctSpecificRounding();
1042
+ }
1043
+
1044
+ function checkSpecificSafeHeap() {
1045
+ if (!Framework.currItem) return false;
1046
+ return (SAFE_HEAP === 2 && Debugging.getIdentifier() in SAFE_HEAP_LINES) ||
1047
+ (SAFE_HEAP === 3 && !(Debugging.getIdentifier() in SAFE_HEAP_LINES));
1048
+ }
1049
+ function checkSafeHeap() {
1050
+ return SAFE_HEAP === 1 || checkSpecificSafeHeap();
1051
+ }
1052
+
1053
+ function getHeapOffset(offset, type, forceAsm) {
1054
+ if (USE_TYPED_ARRAYS !== 2) {
1055
+ return offset;
1056
+ }
1057
+
1058
+ if (Runtime.getNativeFieldSize(type) > 4) {
1059
+ if (type == 'i64' || TARGET_X86) {
1060
+ type = 'i32'; // XXX we emulate 64-bit values as 32 in x86, and also in le32 but only i64, not double
1061
+ }
1062
+ }
1063
+
1064
+ var sz = Runtime.getNativeTypeSize(type);
1065
+ var shifts = Math.log(sz)/Math.LN2;
1066
+ offset = '(' + offset + ')';
1067
+ if (shifts != 0) {
1068
+ if (CHECK_HEAP_ALIGN) {
1069
+ return '((CHECK_ALIGN_' + sz + '(' + offset + '|0)|0)>>' + shifts + ')';
1070
+ } else {
1071
+ return '(' + offset + '>>' + shifts + ')';
1072
+ }
1073
+ } else {
1074
+ // we need to guard against overflows here, HEAP[U]8 expects a guaranteed int
1075
+ return isJSVar(offset) ? offset : '(' + offset + '|0)';
1076
+ }
1077
+ }
1078
+
1079
+ function makeVarDef(js) {
1080
+ if (!ASM_JS) js = 'var ' + js;
1081
+ return js;
1082
+ }
1083
+
1084
+ function asmEnsureFloat(value, type) { // ensures that a float type has either 5.5 (clearly a float) or +5 (float due to asm coercion)
1085
+ if (!ASM_JS) return value;
1086
+ // coerce if missing a '.', or if smaller than 1, so could be 1e-5 which has no .
1087
+ if (type in Runtime.FLOAT_TYPES && isNumber(value) && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) {
1088
+ return '(+(' + value + '))';
1089
+ } else {
1090
+ return value;
1091
+ }
1092
+ }
1093
+
1094
+ function asmInitializer(type, impl) {
1095
+ if (type in Runtime.FLOAT_TYPES) {
1096
+ return '+0';
1097
+ } else {
1098
+ return '0';
1099
+ }
1100
+ }
1101
+
1102
+ function asmCoercion(value, type, signedness) {
1103
+ if (!ASM_JS) return value;
1104
+ if (type == 'void') {
1105
+ return value;
1106
+ } else if (type in Runtime.FLOAT_TYPES) {
1107
+ if (isNumber(value)) {
1108
+ return asmEnsureFloat(value, type);
1109
+ } else {
1110
+ if (signedness) {
1111
+ if (signedness == 'u') {
1112
+ value = '(' + value + ')>>>0';
1113
+ } else {
1114
+ value = '(' + value + ')|0';
1115
+ }
1116
+ }
1117
+ return '(+(' + value + '))';
1118
+ }
1119
+ } else {
1120
+ return '((' + value + ')|0)';
1121
+ }
1122
+ }
1123
+
1124
+ function asmFloatToInt(x) {
1125
+ return '(~~(' + x + '))';
1126
+ }
1127
+
1128
+ function makeGetTempDouble(i, type, forSet) { // get an aliased part of the tempDouble temporary storage
1129
+ // Cannot use makeGetValue because it uses us
1130
+ // this is a unique case where we *can* use HEAPF64
1131
+ var slab = type == 'double' ? 'HEAPF64' : makeGetSlabs(null, type)[0];
1132
+ var ptr = getFastValue('tempDoublePtr', '+', Runtime.getNativeTypeSize(type)*i);
1133
+ var offset;
1134
+ if (type == 'double') {
1135
+ offset = '(' + ptr + ')>>3';
1136
+ } else {
1137
+ offset = getHeapOffset(ptr, type);
1138
+ }
1139
+ var ret = slab + '[' + offset + ']';
1140
+ if (!forSet) ret = asmCoercion(ret, type);
1141
+ return ret;
1142
+ }
1143
+
1144
+ function makeSetTempDouble(i, type, value) {
1145
+ return makeGetTempDouble(i, type, true) + '=' + asmEnsureFloat(value, type);
1146
+ }
1147
+
1148
+ var asmPrintCounter = 0;
1149
+
1150
+ // See makeSetValue
1151
+ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe, forceAsm) {
1152
+ if (UNALIGNED_MEMORY) align = 1;
1153
+ else if (FORCE_ALIGNED_MEMORY && !isIllegalType(type)) align = 8;
1154
+
1155
+ if (isStructType(type)) {
1156
+ var typeData = Types.types[type];
1157
+ var ret = [];
1158
+ for (var i = 0; i < typeData.fields.length; i++) {
1159
+ ret.push('f' + i + ': ' + makeGetValue(ptr, pos + typeData.flatIndexes[i], typeData.fields[i], noNeedFirst, unsigned));
1160
+ }
1161
+ return '{ ' + ret.join(', ') + ' }';
1162
+ }
1163
+
1164
+ // In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in le32
1165
+ // we need this code path if we are not fully aligned.
1166
+ if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double' && (TARGET_X86 || align < 8)) {
1167
+ return '(' + makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align)) + ',' +
1168
+ makeSetTempDouble(1, 'i32', makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align)) + ',' +
1169
+ makeGetTempDouble(0, 'double') + ')';
1170
+ }
1171
+
1172
+ if (USE_TYPED_ARRAYS == 2 && align) {
1173
+ // Alignment is important here. May need to split this up
1174
+ var bytes = Runtime.getNativeTypeSize(type);
1175
+ if (DOUBLE_MODE == 0 && type == 'double') bytes = 4; // we will really only read 4 bytes here
1176
+ if (bytes > align) {
1177
+ var ret = '(';
1178
+ if (isIntImplemented(type)) {
1179
+ if (bytes == 4 && align == 2) {
1180
+ // Special case that we can optimize
1181
+ ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore) + '|' +
1182
+ '(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore) + '<<16)';
1183
+ } else { // XXX we cannot truly handle > 4... (in x86)
1184
+ ret = '';
1185
+ for (var i = 0; i < bytes; i++) {
1186
+ ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore) + (i > 0 ? '<<' + (8*i) : '') + ')';
1187
+ if (i < bytes-1) ret += '|';
1188
+ }
1189
+ ret = '(' + makeSignOp(ret, type, unsigned ? 'un' : 're', true);
1190
+ }
1191
+ } else {
1192
+ if (type == 'float') {
1193
+ ret += 'copyTempFloat(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'float');
1194
+ } else {
1195
+ ret += 'copyTempDouble(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'double');
1196
+ }
1197
+ }
1198
+ ret += ')';
1199
+ return ret;
1200
+ }
1201
+ }
1202
+
1203
+ var offset = calcFastOffset(ptr, pos, noNeedFirst);
1204
+ if (SAFE_HEAP && !noSafe) {
1205
+ var printType = type;
1206
+ if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"';
1207
+ if (printType[0] === '#') printType = printType.substr(1);
1208
+ return asmCoercion('SAFE_HEAP_LOAD(' + asmCoercion(offset, 'i32') + ', ' + (ASM_JS ? 0 : printType) + ', ' + (!!unsigned+0) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')', type);
1209
+ } else {
1210
+ var ret = makeGetSlabs(ptr, type, false, unsigned)[0] + '[' + getHeapOffset(offset, type, forceAsm) + ']';
1211
+ if (ASM_JS && (phase == 'funcs' || forceAsm)) {
1212
+ ret = asmCoercion(ret, type);
1213
+ }
1214
+ if (ASM_HEAP_LOG) {
1215
+ ret = makeInlineCalculation('(asmPrint' + (type in Runtime.FLOAT_TYPES ? 'Float' : 'Int') + '(' + (asmPrintCounter++) + ',' + asmCoercion('VALUE', type) + '), VALUE)', ret,
1216
+ 'temp' + (type in Runtime.FLOAT_TYPES ? 'Double' : 'Int'));
1217
+ }
1218
+ return ret;
1219
+ }
1220
+ }
1221
+
1222
+ function makeGetValueAsm(ptr, pos, type, unsigned) {
1223
+ return makeGetValue(ptr, pos, type, null, unsigned, null, null, null, true);
1224
+ }
1225
+
1226
+ function indexizeFunctions(value, type) {
1227
+ assert((type && type !== '?') || (typeof value === 'string' && value.substr(0, 6) === 'CHECK_'), 'No type given for function indexizing');
1228
+ assert(value !== type, 'Type set to value');
1229
+ var out = {};
1230
+ if (type && isFunctionType(type, out) && value[0] === '_') { // checking for _ differentiates from $ (local vars)
1231
+ // add signature to library functions that we now know need indexing
1232
+ var sig = Functions.implementedFunctions[value] || Functions.unimplementedFunctions[value];
1233
+ if (!sig) {
1234
+ sig = Functions.unimplementedFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : []);
1235
+ }
1236
+ return Functions.getIndex(value, undefined, sig);
1237
+ }
1238
+ return value;
1239
+ }
1240
+
1241
+ //! @param ptr The pointer. Used to find both the slab and the offset in that slab. If the pointer
1242
+ //! is just an integer, then this is almost redundant, but in general the pointer type
1243
+ //! may in the future include information about which slab as well. So, for now it is
1244
+ //! possible to put |0| here, but if a pointer is available, that is more future-proof.
1245
+ //! @param pos The position in that slab - the offset. Added to any offset in the pointer itself.
1246
+ //! @param value The value to set.
1247
+ //! @param type A string defining the type. Used to find the slab (IHEAP, FHEAP, etc.).
1248
+ //! 'null' means, in the context of SAFE_HEAP, that we should accept all types;
1249
+ //! which means we should write to all slabs, ignore type differences if any on reads, etc.
1250
+ //! @param noNeedFirst Whether to ignore the offset in the pointer itself.
1251
+ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign, forceAsm) {
1252
+ if (UNALIGNED_MEMORY && !forcedAlign) align = 1;
1253
+ else if (FORCE_ALIGNED_MEMORY && !isIllegalType(type)) align = 8;
1254
+
1255
+ sep = sep || ';';
1256
+ if (isStructType(type)) {
1257
+ var typeData = Types.types[type];
1258
+ var ret = [];
1259
+ // We can receive either an object - an object literal that was in the .ll - or a string,
1260
+ // which is the ident of an aggregate struct
1261
+ if (typeof value === 'string') {
1262
+ value = range(typeData.fields.length).map(function(i) { return value + '.f' + i });
1263
+ }
1264
+ for (var i = 0; i < typeData.fields.length; i++) {
1265
+ ret.push(makeSetValue(ptr, getFastValue(pos, '+', typeData.flatIndexes[i]), value[i], typeData.fields[i], noNeedFirst));
1266
+ }
1267
+ return ret.join('; ');
1268
+ }
1269
+
1270
+ if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double' && (TARGET_X86 || align < 8)) {
1271
+ return '(' + makeSetTempDouble(0, 'double', value) + ',' +
1272
+ makeSetValue(ptr, pos, makeGetTempDouble(0, 'i32'), 'i32', noNeedFirst, ignore, align, noSafe, ',') + ',' +
1273
+ makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), makeGetTempDouble(1, 'i32'), 'i32', noNeedFirst, ignore, align, noSafe, ',') + ')';
1274
+ } else if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
1275
+ return '(tempI64 = [' + splitI64(value) + '],' +
1276
+ makeSetValue(ptr, pos, 'tempI64[0]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ',' +
1277
+ makeSetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'tempI64[1]', 'i32', noNeedFirst, ignore, align, noSafe, ',') + ')';
1278
+ }
1279
+
1280
+ var bits = getBits(type);
1281
+ var needSplitting = bits > 0 && !isPowerOfTwo(bits); // an unnatural type like i24
1282
+ if (USE_TYPED_ARRAYS == 2 && (align || needSplitting)) {
1283
+ // Alignment is important here, or we need to split this up for other reasons.
1284
+ var bytes = Runtime.getNativeTypeSize(type);
1285
+ if (DOUBLE_MODE == 0 && type == 'double') bytes = 4; // we will really only read 4 bytes here
1286
+ if (bytes > align || needSplitting) {
1287
+ var ret = '';
1288
+ if (isIntImplemented(type)) {
1289
+ if (bytes == 4 && align == 2) {
1290
+ // Special case that we can optimize
1291
+ ret += 'tempBigInt=' + value + sep;
1292
+ ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep;
1293
+ ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2);
1294
+ } else {
1295
+ ret += 'tempBigInt=' + value + sep;
1296
+ for (var i = 0; i < bytes; i++) {
1297
+ ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
1298
+ if (i < bytes-1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
1299
+ }
1300
+ }
1301
+ } else {
1302
+ ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8, null, null, true) + sep;
1303
+ ret += makeCopyValues(getFastValue(ptr, '+', pos), 'tempDoublePtr', Runtime.getNativeTypeSize(type), type, null, align, sep);
1304
+ }
1305
+ return ret;
1306
+ }
1307
+ }
1308
+
1309
+ value = indexizeFunctions(value, type);
1310
+ var offset = calcFastOffset(ptr, pos, noNeedFirst);
1311
+ if (SAFE_HEAP && !noSafe) {
1312
+ var printType = type;
1313
+ if (printType !== 'null' && printType[0] !== '#') printType = '"' + safeQuote(printType) + '"';
1314
+ if (printType[0] === '#') printType = printType.substr(1);
1315
+ return 'SAFE_HEAP_STORE(' + asmCoercion(offset, 'i32') + ', ' + asmCoercion(value, type) + ', ' + (ASM_JS ? 0 : printType) + ', ' + ((!checkSafeHeap() || ignore)|0) + ')';
1316
+ } else {
1317
+ return makeGetSlabs(ptr, type, true).map(function(slab) { return slab + '[' + getHeapOffset(offset, type, forceAsm) + ']=' + value }).join(sep);
1318
+ }
1319
+ }
1320
+
1321
+ function makeSetValueAsm(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign) {
1322
+ return makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign, true);
1323
+ }
1324
+
1325
+ var UNROLL_LOOP_MAX = 8;
1326
+
1327
+ function makeSetValues(ptr, pos, value, type, num, align) {
1328
+ function unroll(type, num, jump, value$) {
1329
+ jump = jump || 1;
1330
+ value$ = value$ || value;
1331
+ return range(num).map(function(i) {
1332
+ return makeSetValue(ptr, getFastValue(pos, '+', i*jump), value$, type);
1333
+ }).join('; ');
1334
+ }
1335
+ if (USE_TYPED_ARRAYS <= 1) {
1336
+ if (isNumber(num) && parseInt(num) <= UNROLL_LOOP_MAX) {
1337
+ return unroll(type, num);
1338
+ }
1339
+ return 'for (var $$dest = ' + getFastValue(ptr, '+', pos) + ', $$stop = $$dest + ' + num + '; $$dest < $$stop; $$dest++) {\n' +
1340
+ makeSetValue('$$dest', '0', value, type) + '\n}';
1341
+ } else { // USE_TYPED_ARRAYS == 2
1342
+ // If we don't know how to handle this at compile-time, or handling it is best done in a large amount of code, call memset
1343
+ // TODO: optimize the case of numeric num but non-numeric value
1344
+ if (!isNumber(num) || !isNumber(value) || (parseInt(num)/align >= UNROLL_LOOP_MAX)) {
1345
+ return '_memset(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + ', ' + asmCoercion(value, 'i32') + ', ' + asmCoercion(num, 'i32') + ')';
1346
+ }
1347
+ num = parseInt(num);
1348
+ value = parseInt(value);
1349
+ if (value < 0) value += 256; // make it unsigned
1350
+ var values = {
1351
+ 1: value,
1352
+ 2: value | (value << 8),
1353
+ 4: value | (value << 8) | (value << 16) | (value << 24)
1354
+ };
1355
+ var ret = [];
1356
+ [4, 2, 1].forEach(function(possibleAlign) {
1357
+ if (num == 0) return;
1358
+ if (align >= possibleAlign) {
1359
+ ret.push(unroll('i' + (possibleAlign*8), Math.floor(num/possibleAlign), possibleAlign, values[possibleAlign]));
1360
+ pos = getFastValue(pos, '+', Math.floor(num/possibleAlign)*possibleAlign);
1361
+ num %= possibleAlign;
1362
+ }
1363
+ });
1364
+ return ret.join('; ');
1365
+ }
1366
+ }
1367
+
1368
+ var TYPED_ARRAY_SET_MIN = Infinity; // .set() as memcpy seems to just slow us down
1369
+
1370
+ function makeCopyValues(dest, src, num, type, modifier, align, sep) {
1371
+ sep = sep || ';';
1372
+ function unroll(type, num, jump) {
1373
+ jump = jump || 1;
1374
+ return range(num).map(function(i) {
1375
+ if (USE_TYPED_ARRAYS <= 1 && type === 'null') {
1376
+ // Null is special-cased: We copy over all heaps
1377
+ return makeGetSlabs(dest, 'null', true).map(function(slab) {
1378
+ return slab + '[' + getFastValue(dest, '+', i) + ']=' + slab + '[' + getFastValue(src, '+', i) + ']';
1379
+ }).join(sep) + (SAFE_HEAP ? sep + 'SAFE_HEAP_COPY_HISTORY(' + getFastValue(dest, '+', i) + ', ' + getFastValue(src, '+', i) + ')' : '');
1380
+ } else {
1381
+ return makeSetValue(dest, i*jump, makeGetValue(src, i*jump, type), type);
1382
+ }
1383
+ }).join(sep);
1384
+ }
1385
+ if (USE_TYPED_ARRAYS <= 1) {
1386
+ if (isNumber(num) && parseInt(num) <= UNROLL_LOOP_MAX) {
1387
+ return unroll(type, num);
1388
+ }
1389
+ var oldDest = dest, oldSrc = src;
1390
+ dest = '$$dest';
1391
+ src = '$$src';
1392
+ return 'for (var $$src = ' + oldSrc + ', $$dest = ' + oldDest + ', $$stop = $$src + ' + num + '; $$src < $$stop; $$src++, $$dest++) {\n' +
1393
+ unroll(type, 1) + ' }';
1394
+ } else { // USE_TYPED_ARRAYS == 2
1395
+ // If we don't know how to handle this at compile-time, or handling it is best done in a large amount of code, call memset
1396
+ if (!isNumber(num)) num = stripCorrections(num);
1397
+ if (!isNumber(align)) align = stripCorrections(align);
1398
+ if (!isNumber(num) || (parseInt(num)/align >= UNROLL_LOOP_MAX)) {
1399
+ return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)';
1400
+ }
1401
+ num = parseInt(num);
1402
+ if (ASM_JS) {
1403
+ dest = stripCorrections(dest); // remove corrections, since we will be correcting after we add anyhow,
1404
+ src = stripCorrections(src); // and in the heap assignment expression
1405
+ }
1406
+ var ret = [];
1407
+ [4, 2, 1].forEach(function(possibleAlign) {
1408
+ if (num == 0) return;
1409
+ if (align >= possibleAlign) {
1410
+ ret.push(unroll('i' + (possibleAlign*8), Math.floor(num/possibleAlign), possibleAlign));
1411
+ src = getFastValue(src, '+', Math.floor(num/possibleAlign)*possibleAlign);
1412
+ dest = getFastValue(dest, '+', Math.floor(num/possibleAlign)*possibleAlign);
1413
+ num %= possibleAlign;
1414
+ }
1415
+ });
1416
+ return ret.join(sep);
1417
+ }
1418
+ }
1419
+
1420
+ function makeHEAPView(which, start, end) {
1421
+ // Assumes USE_TYPED_ARRAYS == 2
1422
+ var size = parseInt(which.replace('U', '').replace('F', ''))/8;
1423
+ var mod = size == 1 ? '' : ('>>' + log2(size));
1424
+ return 'HEAP' + which + '.subarray((' + start + ')' + mod + ',(' + end + ')' + mod + ')';
1425
+ }
1426
+
1427
+ var PLUS_MUL = set('+', '*');
1428
+ var MUL_DIV = set('*', '/');
1429
+ var PLUS_MINUS = set('+', '-');
1430
+ var TWO_TWENTY = Math.pow(2, 20);
1431
+
1432
+ // Given two values and an operation, returns the result of that operation.
1433
+ // Tries to do as much as possible at compile time.
1434
+ // Leaves overflows etc. unhandled, *except* for integer multiply, in order to be efficient with Math.imul
1435
+ function getFastValue(a, op, b, type) {
1436
+ a = a.toString();
1437
+ b = b.toString();
1438
+ a = a == 'true' ? '1' : (a == 'false' ? '0' : a);
1439
+ b = b == 'true' ? '1' : (b == 'false' ? '0' : b);
1440
+ if (isNumber(a) && isNumber(b)) {
1441
+ if (op == 'pow') {
1442
+ return Math.pow(a, b).toString();
1443
+ } else {
1444
+ var value = eval(a + op + '(' + b + ')'); // parens protect us from "5 - -12" being seen as "5--12" which is "(5--)12"
1445
+ if (op == '/' && type in Runtime.INT_TYPES) value = value|0; // avoid emitting floats
1446
+ return value.toString();
1447
+ }
1448
+ }
1449
+ if (op == 'pow') {
1450
+ if (a == '2' && isIntImplemented(type)) {
1451
+ return '(1 << (' + b + '))';
1452
+ }
1453
+ return 'Math.pow(' + a + ', ' + b + ')';
1454
+ }
1455
+ if (op in PLUS_MUL && isNumber(a)) { // if one of them is a number, keep it last
1456
+ var c = b;
1457
+ b = a;
1458
+ a = c;
1459
+ }
1460
+ if (op in MUL_DIV) {
1461
+ if (op == '*') {
1462
+ if (a == 0 || b == 0) {
1463
+ return '0';
1464
+ } else if (a == 1) {
1465
+ return b;
1466
+ } else if (b == 1) {
1467
+ return a;
1468
+ } else if (isNumber(b) && type && isIntImplemented(type) && Runtime.getNativeTypeSize(type) <= 32) {
1469
+ var shifts = Math.log(parseFloat(b))/Math.LN2;
1470
+ if (shifts % 1 == 0) {
1471
+ return '(' + a + '<<' + shifts + ')';
1472
+ }
1473
+ }
1474
+ if (!(type in Runtime.FLOAT_TYPES)) {
1475
+ // if guaranteed small enough to not overflow into a double, do a normal multiply
1476
+ var bits = getBits(type) || 32; // default is 32-bit multiply for things like getelementptr indexes
1477
+ // Note that we can emit simple multiple in non-asm.js mode, but asm.js will not parse "16-bit" multiple, so must do imul there
1478
+ if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY) || (bits < 32 && !ASM_JS)) {
1479
+ return '(((' + a + ')*(' + b + '))&' + ((Math.pow(2, bits)-1)|0) + ')'; // keep a non-eliminatable coercion directly on this
1480
+ }
1481
+ return '(Math.imul(' + a + ',' + b + ')|0)';
1482
+ }
1483
+ } else {
1484
+ if (a == '0') {
1485
+ return '0';
1486
+ } else if (b == 1) {
1487
+ return a;
1488
+ } // Doing shifts for division is problematic, as getting the rounding right on negatives is tricky
1489
+ }
1490
+ } else if (op in PLUS_MINUS) {
1491
+ if (b[0] == '-') {
1492
+ op = op == '+' ? '-' : '+';
1493
+ b = b.substr(1);
1494
+ }
1495
+ if (a == 0) {
1496
+ return op == '+' ? b : '(-' + b + ')';
1497
+ } else if (b == 0) {
1498
+ return a;
1499
+ }
1500
+ }
1501
+ return '(' + a + ')' + op + '(' + b + ')';
1502
+ }
1503
+
1504
+ function getFastValues(list, op, type) {
1505
+ assert(op == '+');
1506
+ var changed = true;
1507
+ while (changed) {
1508
+ changed = false;
1509
+ for (var i = 0; i < list.length-1; i++) {
1510
+ var fast = getFastValue(list[i], op, list[i+1], type);
1511
+ var raw = list[i] + op + list[i+1];
1512
+ if (fast.length < raw.length || fast.indexOf(op) < 0) {
1513
+ list[i] = fast;
1514
+ list.splice(i+1, 1);
1515
+ i--;
1516
+ changed = true;
1517
+ break;
1518
+ }
1519
+ }
1520
+ }
1521
+ if (list.length == 1) return list[0];
1522
+ return list.reduce(function(a, b) { return a + op + b });
1523
+ }
1524
+
1525
+ function calcFastOffset(ptr, pos, noNeedFirst) {
1526
+ var offset = noNeedFirst ? '0' : makeGetPos(ptr);
1527
+ return getFastValue(offset, '+', pos, 'i32');
1528
+ }
1529
+
1530
+ function makeGetPos(ptr) {
1531
+ return ptr;
1532
+ }
1533
+
1534
+ var IHEAP_FHEAP = set('IHEAP', 'IHEAPU', 'FHEAP');
1535
+
1536
+ var temp64f = new Float64Array(1);
1537
+ var temp32f = new Float32Array(temp64f.buffer);
1538
+ var temp32 = new Uint32Array(temp64f.buffer);
1539
+ var temp16 = new Uint16Array(temp64f.buffer);
1540
+ var temp8 = new Uint8Array(temp64f.buffer);
1541
+ var memoryInitialization = [];
1542
+
1543
+ function writeInt8s(slab, i, value, type) {
1544
+ var currSize;
1545
+ switch (type) {
1546
+ case 'i1':
1547
+ case 'i8': temp8[0] = value; currSize = 1; break;
1548
+ case 'i16': temp16[0] = value; currSize = 2; break;
1549
+ case 'float': temp32f[0] = value; currSize = 4; break;
1550
+ case 'double': temp64f[0] = value; currSize = 8; break;
1551
+ case 'i64': // fall through, i64 is two i32 chunks
1552
+ case 'i32': // fall through, i32 can be a pointer
1553
+ default: {
1554
+ if (type == 'i32' || type == 'i64' || type[type.length-1] == '*') {
1555
+ if (!isNumber(value)) { // function table stuff, etc.
1556
+ slab[i] = value;
1557
+ slab[i+1] = slab[i+2] = slab[i+3] = 0;
1558
+ return 4;
1559
+ }
1560
+ temp32[0] = value;
1561
+ currSize = 4;
1562
+ } else {
1563
+ throw 'what? ' + types[i];
1564
+ }
1565
+ }
1566
+ }
1567
+ for (var j = 0; j < currSize; j++) {
1568
+ slab[i+j] = temp8[j];
1569
+ }
1570
+ return currSize;
1571
+ }
1572
+
1573
+ function makePointer(slab, pos, allocator, type, ptr, finalMemoryInitialization) {
1574
+ assert(type, 'makePointer requires type info');
1575
+ if (typeof slab == 'string' && (slab.substr(0, 4) === 'HEAP' || (USE_TYPED_ARRAYS == 1 && slab in IHEAP_FHEAP))) return pos;
1576
+ var types = generateStructTypes(type);
1577
+ if (typeof slab == 'object') {
1578
+ for (var i = 0; i < slab.length; i++) {
1579
+ var curr = slab[i];
1580
+ if (isNumber(curr)) {
1581
+ slab[i] = parseFloat(curr); // fix "5" to 5 etc.
1582
+ } else if (curr == 'undef') {
1583
+ slab[i] = 0;
1584
+ }
1585
+ }
1586
+ }
1587
+ // compress type info and data if possible
1588
+ if (USE_TYPED_ARRAYS != 2) {
1589
+ var de;
1590
+ try {
1591
+ // compress all-zeros into a number (which will become zeros(..)).
1592
+ // note that we cannot always eval the slab, e.g., if it contains ident,0,0 etc. In that case, no compression TODO: ensure we get arrays here, not str
1593
+ var evaled = typeof slab === 'string' ? eval(slab) : slab;
1594
+ de = dedup(evaled);
1595
+ if (de.length === 1 && de[0] == 0) {
1596
+ slab = types.length;
1597
+ }
1598
+ // TODO: if not all zeros, at least filter out items with type === 0. requires cleverness to know how to skip at runtime though. also
1599
+ // be careful of structure padding
1600
+ } catch(e){}
1601
+ de = dedup(types);
1602
+ if (de.length === 1) {
1603
+ types = de[0];
1604
+ } else if (de.length === 2 && typeof slab === 'number') {
1605
+ // If slab is all zeros, we can compress types even if we have i32,0,0,0,i32,0,0,0 etc. - we do not need the zeros
1606
+ de = de.filter(function(x) { return x !== 0 });
1607
+ if (de.length === 1) {
1608
+ types = de[0];
1609
+ }
1610
+ }
1611
+ } else { // USE_TYPED_ARRAYS == 2
1612
+ if (!finalMemoryInitialization) {
1613
+ // XXX This heavily assumes the target endianness is the same as our current endianness! XXX
1614
+ var i = 0;
1615
+ while (i < slab.length) {
1616
+ var currType = types[i];
1617
+ if (!currType) { i++; continue }
1618
+ i += writeInt8s(slab, i, slab[i], currType);
1619
+ }
1620
+ types = 'i8';
1621
+ }
1622
+ }
1623
+ if (allocator == 'ALLOC_NONE' && USE_TYPED_ARRAYS == 2) {
1624
+ if (!finalMemoryInitialization) {
1625
+ // writing out into memory, without a normal allocation. We put all of these into a single big chunk.
1626
+ assert(typeof slab == 'object');
1627
+ assert(slab.length % QUANTUM_SIZE == 0, slab.length); // must be aligned already
1628
+ if (SIDE_MODULE && typeof ptr == 'string') {
1629
+ ptr = parseInt(ptr.substring(ptr.indexOf('+'), ptr.length-1)); // parse into (H_BASE+X)
1630
+ }
1631
+ var offset = ptr - Runtime.GLOBAL_BASE;
1632
+ for (var i = 0; i < slab.length; i++) {
1633
+ memoryInitialization[offset + i] = slab[i];
1634
+ }
1635
+ return '';
1636
+ }
1637
+ // This is the final memory initialization
1638
+ types = 'i8';
1639
+ }
1640
+
1641
+ // JS engines sometimes say array initializers are too large. Work around that by chunking and calling concat to combine at runtime
1642
+ var chunkSize = JS_CHUNK_SIZE;
1643
+ function chunkify(array) {
1644
+ // break very large slabs into parts
1645
+ var ret = '';
1646
+ var index = 0;
1647
+ while (index < array.length) {
1648
+ ret = (ret ? ret + '.concat(' : '') + '[' + array.slice(index, index + chunkSize).map(JSON.stringify) + ']' + (ret ? ')\n' : '');
1649
+ index += chunkSize;
1650
+ }
1651
+ return ret;
1652
+ }
1653
+ if (typeof slab == 'object' && slab.length > chunkSize) {
1654
+ slab = chunkify(slab);
1655
+ }
1656
+ if (typeof types == 'object') {
1657
+ while (types.length < slab.length) types.push(0);
1658
+ }
1659
+ if (typeof types != 'string' && types.length > chunkSize) {
1660
+ types = chunkify(types);
1661
+ } else {
1662
+ types = JSON.stringify(types);
1663
+ }
1664
+ if (typeof slab == 'object') slab = '[' + slab.join(',') + ']';
1665
+ return 'allocate(' + slab + ', ' + types + (allocator ? ', ' + allocator : '') + (allocator == 'ALLOC_NONE' ? ', ' + ptr : '') + ')';
1666
+ }
1667
+
1668
+ function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
1669
+ assert(type);
1670
+ if (!USE_TYPED_ARRAYS) {
1671
+ return ['HEAP'];
1672
+ } else if (USE_TYPED_ARRAYS == 1) {
1673
+ if (type in Runtime.FLOAT_TYPES || type === 'int64') { // XXX should be i64, no?
1674
+ return ['FHEAP']; // If USE_FHEAP is false, will fail at runtime. At compiletime we do need it for library stuff.
1675
+ } else if (type in Runtime.INT_TYPES || isPointerType(type)) {
1676
+ return [unsigned ? 'IHEAPU' : 'IHEAP'];
1677
+ } else {
1678
+ assert(allowMultiple, 'Unknown slab type and !allowMultiple: ' + type);
1679
+ if (USE_FHEAP) {
1680
+ return ['IHEAP', 'FHEAP']; // unknown, so assign to both typed arrays
1681
+ } else {
1682
+ return ['IHEAP'];
1683
+ }
1684
+ }
1685
+ } else { // USE_TYPED_ARRAYS == 2)
1686
+ if (isPointerType(type)) type = 'i32'; // Hardcoded 32-bit
1687
+ switch(type) {
1688
+ case 'i1': case 'i8': return [unsigned ? 'HEAPU8' : 'HEAP8']; break;
1689
+ case 'i16': return [unsigned ? 'HEAPU16' : 'HEAP16']; break;
1690
+ case 'i32': case 'i64': return [unsigned ? 'HEAPU32' : 'HEAP32']; break;
1691
+ case 'double': {
1692
+ if (TARGET_LE32) return ['HEAPF64']; // in le32, we do have the ability to assume 64-bit alignment
1693
+ // otherwise, fall through to float
1694
+ }
1695
+ case 'float': return ['HEAPF32'];
1696
+ default: {
1697
+ throw 'what, exactly, can we do for unknown types in TA2?! ' + new Error().stack;
1698
+ }
1699
+ }
1700
+ }
1701
+ return [];
1702
+ }
1703
+
1704
+ function checkBitcast(item) {
1705
+ // Warn about some types of casts, then fall through to the handling code below
1706
+ var oldType = item.params[0].type;
1707
+ var newType = item.type;
1708
+ if (isPossiblyFunctionType(oldType) && isPossiblyFunctionType(newType)) {
1709
+ var oldInfo = {}, newInfo = {};
1710
+ var oldCount = countNormalArgs(oldType, oldInfo);
1711
+ var newCount = countNormalArgs(newType, newInfo);
1712
+ var warned = false;
1713
+ function showWarning() {
1714
+ if (warned) return;
1715
+ warned = true;
1716
+ if (VERBOSE) {
1717
+ warnOnce('Casting potentially incompatible function pointer ' + oldType + ' to ' + newType + ', for ' + item.params[0].ident.slice(1));
1718
+ } else {
1719
+ warnOnce('Casting a function pointer type to a potentially incompatible one (use -s VERBOSE=1 to see more)');
1720
+ }
1721
+ warnOnce('See https://github.com/kripken/emscripten/wiki/CodeGuidlinesAndLimitations#function-pointer-issues for more information on dangerous function pointer casts');
1722
+ if (ASM_JS) warnOnce('Incompatible function pointer casts are very dangerous with ASM_JS=1, you should investigate and correct these');
1723
+ }
1724
+ if (oldCount != newCount && oldCount && newCount) showWarning();
1725
+ if (ASM_JS) {
1726
+ if (oldCount != newCount) showWarning();
1727
+ else if (!isIdenticallyImplemented(oldInfo.returnType, newInfo.returnType)) {
1728
+ showWarning();
1729
+ } else {
1730
+ for (var i = 0; i < oldCount; i++) {
1731
+ if (!isIdenticallyImplemented(oldInfo.segments[i][0].text, newInfo.segments[i][0].text)) {
1732
+ showWarning();
1733
+ break;
1734
+ }
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ }
1740
+
1741
+ function finalizeLLVMFunctionCall(item, noIndexizeFunctions) {
1742
+ if (item.intertype == 'getelementptr') { // TODO finalizeLLVMParameter on the ident and the indexes?
1743
+ return makePointer(makeGetSlabs(item.ident, item.type)[0], getGetElementPtrIndexes(item), null, item.type);
1744
+ }
1745
+ if (item.intertype == 'bitcast') checkBitcast(item);
1746
+ var temp = {
1747
+ op: item.intertype,
1748
+ variant: item.variant,
1749
+ type: item.type,
1750
+ params: item.params.slice(0) // XXX slice?
1751
+ };
1752
+ return processMathop(temp);
1753
+ }
1754
+
1755
+ function getGetElementPtrIndexes(item) {
1756
+ var type = item.params[0].type;
1757
+ if (USE_TYPED_ARRAYS == 2) {
1758
+ // GEP indexes are marked as i64s, but they are just numbers to us
1759
+ item.params.forEach(function(param) { param.type = 'i32' });
1760
+ }
1761
+ item.params = item.params.map(finalizeLLVMParameter);
1762
+ var ident = item.params[0];
1763
+
1764
+ // struct pointer, struct*, and getting a ptr to an element in that struct. Param 1 is which struct, then we have items in that
1765
+ // struct, and possibly further substructures, all embedded
1766
+ // can also be to 'blocks': [8 x i32]*, not just structs
1767
+ type = removePointing(type);
1768
+ var indexes = [makeGetPos(ident)];
1769
+ var offset = item.params[1];
1770
+ if (offset != 0) {
1771
+ if (isStructType(type)) {
1772
+ indexes.push(getFastValue(Types.types[type].flatSize, '*', offset, 'i32'));
1773
+ } else {
1774
+ indexes.push(getFastValue(Runtime.getNativeTypeSize(type), '*', offset, 'i32'));
1775
+ }
1776
+ }
1777
+ item.params.slice(2, item.params.length).forEach(function(arg, i) {
1778
+ var curr = arg;
1779
+ // TODO: If index is constant, optimize
1780
+ var typeData = Types.types[type];
1781
+ assert(typeData || i == item.params.length - 3); // can be null, when we get to the end (a basic type)
1782
+ if (isStructType(type) && typeData.needsFlattening) {
1783
+ if (typeData.flatFactor) {
1784
+ indexes.push(getFastValue(curr, '*', typeData.flatFactor, 'i32'));
1785
+ } else {
1786
+ if (isNumber(curr)) {
1787
+ indexes.push(typeData.flatIndexes[curr]);
1788
+ } else {
1789
+ indexes.push(toNiceIdent(type) + '___FLATTENER[' + curr + ']'); // TODO: If curr is constant, optimize out the flattener struct
1790
+ }
1791
+ }
1792
+ } else {
1793
+ if (curr != 0) {
1794
+ indexes.push(curr);
1795
+ }
1796
+ }
1797
+ if (typeData) {
1798
+ if (isArrayType(type)) {
1799
+ type = typeData.fields[0]; // all the same, so accept even out-of-bounds this way
1800
+ } else {
1801
+ assert(isNumber(curr)); // cannot be dynamic
1802
+ type = typeData.fields[curr];
1803
+ }
1804
+ assert(type);
1805
+ }
1806
+ });
1807
+
1808
+ var ret = getFastValues(indexes, '+', 'i32');
1809
+
1810
+ ret = handleOverflow(ret, 32); // XXX - we assume a 32-bit arch here. If you fail on this, change to 64
1811
+
1812
+ return ret;
1813
+ }
1814
+
1815
+ function handleOverflow(text, bits) {
1816
+ // TODO: handle overflows of i64s
1817
+ if (!bits) return text;
1818
+ var correct = correctOverflows();
1819
+ warnOnce(!correct || bits <= 32, 'Cannot correct overflows of this many bits: ' + bits);
1820
+ if (CHECK_OVERFLOWS) return 'CHECK_OVERFLOW(' + text + ', ' + bits + ', ' + Math.floor(correctSpecificOverflow()) + ')';
1821
+ if (!correct) return text;
1822
+ if (bits == 32) {
1823
+ return '((' + text + ')|0)';
1824
+ } else if (bits < 32) {
1825
+ return '((' + text + ')&' + (Math.pow(2, bits) - 1) + ')';
1826
+ } else {
1827
+ return text; // We warned about this earlier
1828
+ }
1829
+ }
1830
+
1831
+ function makeLLVMStruct(values) {
1832
+ if (USE_TYPED_ARRAYS == 2) {
1833
+ return 'DEPRECATED' + (new Error().stack) + 'XXX';
1834
+ } else {
1835
+ return '{ ' + values.map(function(value, i) { return 'f' + i + ': ' + value }).join(', ') + ' }'
1836
+ }
1837
+ }
1838
+
1839
+ function makeStructuralReturn(values, inAsm) {
1840
+ if (USE_TYPED_ARRAYS == 2) {
1841
+ var i = -1;
1842
+ return 'return ' + asmCoercion(values.slice(1).map(function(value) {
1843
+ i++;
1844
+ return ASM_JS ? (inAsm ? 'tempRet' + i + ' = ' + value : 'asm["setTempRet' + i + '"](' + value + ')')
1845
+ : 'tempRet' + i + ' = ' + value;
1846
+ }).concat([values[0]]).join(','), 'i32');
1847
+ } else {
1848
+ var i = 0;
1849
+ return 'return { ' + values.map(function(value) {
1850
+ return 'f' + (i++) + ': ' + value;
1851
+ }).join(', ') + ' }';
1852
+ }
1853
+ }
1854
+
1855
+ function makeStructuralAccess(ident, i) {
1856
+ if (USE_TYPED_ARRAYS == 2) {
1857
+ return ident + '$' + i;
1858
+ } else {
1859
+ return ident + '.f' + i;
1860
+ }
1861
+ }
1862
+
1863
+ function makeThrow(what) {
1864
+ return 'throw ' + what + (DISABLE_EXCEPTION_CATCHING == 1 ? ' + " - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."' : '') + ';';
1865
+ }
1866
+
1867
+ // From parseLLVMSegment
1868
+ function finalizeLLVMParameter(param, noIndexizeFunctions) {
1869
+ var ret;
1870
+ if (isNumber(param)) {
1871
+ return param;
1872
+ } else if (typeof param === 'string') {
1873
+ return toNiceIdentCarefully(param);
1874
+ } else if (param.intertype in PARSABLE_LLVM_FUNCTIONS) {
1875
+ ret = finalizeLLVMFunctionCall(param, noIndexizeFunctions);
1876
+ } else if (param.ident == 'zeroinitializer') {
1877
+ if (isStructType(param.type)) {
1878
+ return makeLLVMStruct(zeros(Types.types[param.type].fields.length));
1879
+ } else {
1880
+ return '0';
1881
+ }
1882
+ } else if (param.intertype == 'value') {
1883
+ ret = param.ident;
1884
+ if (ret in Variables.globals) {
1885
+ ret = makeGlobalUse(ret);
1886
+ }
1887
+ if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) {
1888
+ ret = parseI64Constant(ret);
1889
+ }
1890
+ ret = parseNumerical(ret, param.type);
1891
+ ret = asmEnsureFloat(ret, param.type);
1892
+ } else if (param.intertype == 'structvalue') {
1893
+ ret = makeLLVMStruct(param.params.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) }));
1894
+ } else if (param.intertype === 'blockaddress') {
1895
+ return finalizeBlockAddress(param);
1896
+ } else if (param.intertype === 'type') {
1897
+ return param.ident; // we don't really want the type here
1898
+ } else if (param.intertype == 'mathop') {
1899
+ return processMathop(param);
1900
+ } else {
1901
+ throw 'invalid llvm parameter: ' + param.intertype;
1902
+ }
1903
+ assert(param.type || (typeof param === 'string' && param.substr(0, 6) === 'CHECK_'), 'Missing type for param!');
1904
+ if (!noIndexizeFunctions) ret = indexizeFunctions(ret, param.type);
1905
+ return ret;
1906
+ }
1907
+
1908
+ function makeComparison(a, op, b, type) {
1909
+ assert(type);
1910
+ if (!isIllegalType(type)) {
1911
+ return asmCoercion(a, type) + op + asmCoercion(b, type);
1912
+ } else {
1913
+ assert(type == 'i64');
1914
+ return asmCoercion(a + '$0', 'i32') + op + asmCoercion(b + '$0', 'i32') + ' & ' +
1915
+ asmCoercion(a + '$1', 'i32') + op + asmCoercion(b + '$1', 'i32');
1916
+ }
1917
+ }
1918
+
1919
+ function makeSignOp(value, type, op, force, ignore) {
1920
+ if (USE_TYPED_ARRAYS == 2 && type == 'i64') {
1921
+ return value; // these are always assumed to be two 32-bit unsigneds.
1922
+ }
1923
+
1924
+ if (isPointerType(type)) type = 'i32'; // Pointers are treated as 32-bit ints
1925
+ if (!value) return value;
1926
+ var bits, full;
1927
+ if (type in Runtime.INT_TYPES) {
1928
+ bits = parseInt(type.substr(1));
1929
+ full = op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(ignore || (correctSpecificSign())) + ')';
1930
+ // Always sign/unsign constants at compile time, regardless of CHECK/CORRECT
1931
+ if (isNumber(value)) {
1932
+ return eval(full).toString();
1933
+ }
1934
+ }
1935
+ if ((ignore || !correctSigns()) && !CHECK_SIGNS && !force) return value;
1936
+ if (type in Runtime.INT_TYPES) {
1937
+ // shortcuts
1938
+ if (!CHECK_SIGNS || ignore) {
1939
+ if (bits === 32) {
1940
+ if (op === 're') {
1941
+ return '(' + getFastValue(value, '|', '0') + ')';
1942
+ } else {
1943
+
1944
+ return '(' + getFastValue(value, '>>>', '0') + ')';
1945
+ // Alternatively, we can consider the lengthier
1946
+ // return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + ' + VALUE', value, 'tempBigInt');
1947
+ // which does not always turn us into a 32-bit *un*signed value
1948
+ }
1949
+ } else if (bits < 32) {
1950
+ if (op === 're') {
1951
+ return makeInlineCalculation('(VALUE << ' + (32-bits) + ') >> ' + (32-bits), value, 'tempInt');
1952
+ } else {
1953
+ return '(' + getFastValue(value, '&', Math.pow(2, bits)-1) + ')';
1954
+ }
1955
+ } else { // bits > 32
1956
+ if (op === 're') {
1957
+ return makeInlineCalculation('VALUE >= ' + Math.pow(2, bits-1) + ' ? VALUE-' + Math.pow(2, bits) + ' : VALUE', value, 'tempBigIntS');
1958
+ } else {
1959
+ return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + '+VALUE', value, 'tempBigIntS');
1960
+ }
1961
+ }
1962
+ }
1963
+ return full;
1964
+ }
1965
+ return value;
1966
+ }
1967
+
1968
+ // @param floatConversion Means that we are receiving a float and rounding it to
1969
+ // an integer. We must be careful here, the input has *not*
1970
+ // already been converted to a signed/unsigned value (that
1971
+ // would already do rounding, before us!)
1972
+ function makeRounding(value, bits, signed, floatConversion) {
1973
+ // TODO: handle roundings of i64s
1974
+ assert(bits);
1975
+ if (!ASM_JS) {
1976
+ // C rounds to 0 (-5.5 to -5, +5.5 to 5), while JS has no direct way to do that.
1977
+ if (bits <= 32 && signed) return '((' + value + ')&-1)'; // This is fast and even correct, for all cases. Note that it is the same
1978
+ // as |0, but &-1 hints to the js optimizer that this is a rounding correction
1979
+ // Do Math.floor, which is reasonably fast, if we either don't care, or if we can be sure
1980
+ // the value is non-negative
1981
+ if (!correctRoundings() || (!signed && !floatConversion)) return 'Math.floor(' + value + ')';
1982
+ // We are left with >32 bits signed, or a float conversion. Check and correct inline
1983
+ // Note that if converting a float, we may have the wrong sign at this point! But, we have
1984
+ // been rounded properly regardless, and we will be sign-corrected later when actually used, if
1985
+ // necessary.
1986
+ return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
1987
+ } else {
1988
+ // asm.js mode, cleaner refactoring of this function as well. TODO: use in non-asm case, most of this
1989
+ if (floatConversion && bits <= 32) {
1990
+ return '(~~(' + value + '))'; // explicit float-to-int conversion
1991
+ }
1992
+
1993
+ if (bits <= 32) {
1994
+ if (signed) {
1995
+ return '((' + value + ')&-1)'; // &-1 (instead of |0) hints to the js optimizer that this is a rounding correction
1996
+ } else {
1997
+ return '((' + value + ')>>>0)';
1998
+ }
1999
+ }
2000
+ // Math.floor is reasonably fast if we don't care about corrections (and even correct if unsigned)
2001
+ if (!correctRoundings() || !signed) return 'Math.floor(' + value + ')';
2002
+ // We are left with >32 bits
2003
+ return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
2004
+ }
2005
+ }
2006
+
2007
+ function makeIsNaN(value) {
2008
+ if (ASM_JS) return makeInlineCalculation('((VALUE) != (VALUE))', value, 'tempDouble');
2009
+ return 'isNaN(' + value + ')';
2010
+ }
2011
+
2012
+ // fptoui and fptosi are not in these, because we need to be careful about what we do there. We can't
2013
+ // just sign/unsign the input first.
2014
+ var UNSIGNED_OP = set('udiv', 'urem', 'uitofp', 'zext', 'lshr');
2015
+ var SIGNED_OP = set('sdiv', 'srem', 'sitofp', 'sext', 'ashr');
2016
+
2017
+ function isUnsignedOp(op, variant) {
2018
+ return op in UNSIGNED_OP || (variant && variant[0] == 'u');
2019
+ }
2020
+ function isSignedOp(op, variant) {
2021
+ return op in SIGNED_OP || (variant && variant[0] == 's');
2022
+ }
2023
+
2024
+ var legalizedI64s = USE_TYPED_ARRAYS == 2; // We do not legalize globals, but do legalize function lines. This will be true in the latter case
2025
+
2026
+ function processMathop(item) {
2027
+ var op = item.op;
2028
+ var variant = item.variant;
2029
+ var type = item.type;
2030
+ var paramTypes = ['', '', '', ''];
2031
+ var idents = [];
2032
+ for (var i = 0; i < 3; i++) {
2033
+ if (item.params[i]) {
2034
+ paramTypes[i] = item.params[i].type || type;
2035
+ idents[i] = finalizeLLVMParameter(item.params[i]);
2036
+ if (!isNumber(idents[i]) && !isNiceIdent(idents[i])) {
2037
+ idents[i] = '(' + idents[i] + ')'; // we may have nested expressions. So enforce the order of operations we want
2038
+ }
2039
+ } else {
2040
+ idents[i] = null; // just so it exists for purposes of reading idents[1] etc. later on, and no exception is thrown
2041
+ }
2042
+ }
2043
+ var originalIdents = idents.slice(0);
2044
+ if (isUnsignedOp(op, variant)) {
2045
+ idents[0] = makeSignOp(idents[0], paramTypes[0], 'un');
2046
+ idents[1] = makeSignOp(idents[1], paramTypes[1], 'un');
2047
+ } else if (isSignedOp(op, variant)) {
2048
+ idents[0] = makeSignOp(idents[0], paramTypes[0], 're');
2049
+ idents[1] = makeSignOp(idents[1], paramTypes[1], 're');
2050
+ }
2051
+ var bits = null;
2052
+ if (item.type[0] === 'i') {
2053
+ bits = parseInt(item.type.substr(1));
2054
+ }
2055
+ var bitsBefore = parseInt((item.params[0] ? item.params[0].type : item.type).substr(1)); // remove i to leave the number of bits left after this
2056
+ var bitsLeft = parseInt(((item.params[1] && item.params[1].ident) ? item.params[1].ident : item.type).substr(1)); // remove i to leave the number of bits left after this operation
2057
+ var rawBits = getBits(item.type);
2058
+ assert(rawBits <= 64);
2059
+
2060
+ function integerizeBignum(value) {
2061
+ return makeInlineCalculation('VALUE-VALUE%1', value, 'tempBigIntI');
2062
+ }
2063
+
2064
+ if ((type == 'i64' || paramTypes[0] == 'i64' || paramTypes[1] == 'i64' || idents[1] == '(i64)' || rawBits > 32) && USE_TYPED_ARRAYS == 2) {
2065
+ // this code assumes i64 for the most part
2066
+ if (ASSERTIONS && rawBits > 1 && rawBits < 64) {
2067
+ warnOnce('processMathop processing illegal non-i64 value');
2068
+ if (VERBOSE) printErr([op, item.type, rawBits, type, paramTypes, idents]);
2069
+ }
2070
+
2071
+ var warnI64_1 = function() {
2072
+ warnOnce('Arithmetic on 64-bit integers in mode 1 is rounded and flaky, like mode 0!');
2073
+ };
2074
+ // In ops that can be either legalized or not, we need to differentiate how we access low and high parts
2075
+ var low1 = idents[0] + (legalizedI64s ? '$0' : '[0]');
2076
+ var high1 = idents[0] + (legalizedI64s ? '$1' : '[1]');
2077
+ var low2 = idents[1] + (legalizedI64s ? '$0' : '[0]');
2078
+ var high2 = idents[1] + (legalizedI64s ? '$1' : '[1]');
2079
+ function finish(result) {
2080
+ // If this is in legalization mode, steal the assign and assign into two vars
2081
+ if (legalizedI64s) {
2082
+ assert(item.assignTo);
2083
+ var ret = 'var ' + item.assignTo + '$0 = ' + result[0] + '; var ' + item.assignTo + '$1 = ' + result[1] + ';';
2084
+ item.assignTo = null;
2085
+ return ret;
2086
+ } else {
2087
+ return result;
2088
+ }
2089
+ }
2090
+ function i64PreciseOp(type, lastArg) {
2091
+ Types.preciseI64MathUsed = true;
2092
+ return finish(['(i64Math' + (ASM_JS ? '_' : '.') + type + '(' + asmCoercion(low1, 'i32') + ',' + asmCoercion(high1, 'i32') + ',' + asmCoercion(low2, 'i32') + ',' + asmCoercion(high2, 'i32') +
2093
+ (lastArg ? ',' + asmCoercion(+lastArg, 'i32') : '') + '),' + makeGetValue('tempDoublePtr', 0, 'i32') + ')', makeGetValue('tempDoublePtr', Runtime.getNativeTypeSize('i32'), 'i32')]);
2094
+ }
2095
+ function preciseCall(name) {
2096
+ Types.preciseI64MathUsed = true;
2097
+ return finish([asmCoercion(name + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + ')', 'i32'), 'tempRet0']);
2098
+ }
2099
+ function i64PreciseLib(type) {
2100
+ return preciseCall('_i64' + type[0].toUpperCase() + type.substr(1));
2101
+ }
2102
+ switch (op) {
2103
+ // basic integer ops
2104
+ case 'or': {
2105
+ return '[' + idents[0] + '[0] | ' + idents[1] + '[0], ' + idents[0] + '[1] | ' + idents[1] + '[1]]';
2106
+ }
2107
+ case 'and': {
2108
+ return '[' + idents[0] + '[0] & ' + idents[1] + '[0], ' + idents[0] + '[1] & ' + idents[1] + '[1]]';
2109
+ }
2110
+ case 'xor': {
2111
+ return '[' + idents[0] + '[0] ^ ' + idents[1] + '[0], ' + idents[0] + '[1] ^ ' + idents[1] + '[1]]';
2112
+ }
2113
+ case 'shl':
2114
+ case 'ashr':
2115
+ case 'lshr': {
2116
+ throw 'shifts should have been legalized!';
2117
+ }
2118
+ case 'uitofp': case 'sitofp': return RuntimeGenerator.makeBigInt(low1, high1, op[0] == 'u');
2119
+ case 'fptoui': case 'fptosi': return finish(splitI64(idents[0], true));
2120
+ case 'icmp': {
2121
+ switch (variant) {
2122
+ case 'uge': return '((' + high1 + '>>>0) >= (' + high2 + '>>>0)) & ((((' + high1 + '>>>0) > (' + high2 + '>>>0)) | ' +
2123
+ '(' + low1 + '>>>0) >= (' + low2 + '>>>0)))';
2124
+ case 'sge': return '((' + high1 + '|0) >= (' + high2 + '|0)) & ((((' + high1 + '|0) > (' + high2 + '|0)) | ' +
2125
+ '(' + low1 + '>>>0) >= (' + low2 + '>>>0)))';
2126
+ case 'ule': return '((' + high1 + '>>>0) <= (' + high2 + '>>>0)) & ((((' + high1 + '>>>0) < (' + high2 + '>>>0)) | ' +
2127
+ '(' + low1 + '>>>0) <= (' + low2 + '>>>0)))';
2128
+ case 'sle': return '((' + high1 + '|0) <= (' + high2 + '|0)) & ((((' + high1 + '|0) < (' + high2 + '|0)) | ' +
2129
+ '(' + low1 + '>>>0) <= (' + low2 + '>>>0)))';
2130
+ case 'ugt': return '((' + high1 + '>>>0) > (' + high2 + '>>>0)) | ((((' + high1 + '>>>0) == (' + high2 + '>>>0) & ' +
2131
+ '(' + low1 + '>>>0) > (' + low2 + '>>>0))))';
2132
+ case 'sgt': return '((' + high1 + '|0) > (' + high2 + '|0)) | ((((' + high1 + '|0) == (' + high2 + '|0) & ' +
2133
+ '(' + low1 + '>>>0) > (' + low2 + '>>>0))))';
2134
+ case 'ult': return '((' + high1 + '>>>0) < (' + high2 + '>>>0)) | ((((' + high1 + '>>>0) == (' + high2 + '>>>0) & ' +
2135
+ '(' + low1 + '>>>0) < (' + low2 + '>>>0))))';
2136
+ case 'slt': return '((' + high1 + '|0) < (' + high2 + '|0)) | ((((' + high1 + '|0) == (' + high2 + '|0) & ' +
2137
+ '(' + low1 + '>>>0) < (' + low2 + '>>>0))))';
2138
+ case 'ne': return '((' + low1 + '|0) != (' + low2 + '|0)) | ((' + high1 + '|0) != (' + high2 + '|0))';
2139
+ case 'eq': return '((' + low1 + '|0) == (' + low2 + '|0)) & ((' + high1 + '|0) == (' + high2 + '|0))';
2140
+ default: throw 'Unknown icmp variant: ' + variant;
2141
+ }
2142
+ }
2143
+ case 'zext': return makeI64(idents[0], 0);
2144
+ case 'sext': return makeInlineCalculation(makeI64('VALUE', 'VALUE<0 ? 4294967295 : 0'), idents[0], 'tempBigIntD');
2145
+ case 'trunc': {
2146
+ return '((' + idents[0] + '[0]) & ' + (Math.pow(2, bitsLeft)-1) + ')';
2147
+ }
2148
+ case 'select': return idents[0] + ' ? ' + makeCopyI64(idents[1]) + ' : ' + makeCopyI64(idents[2]);
2149
+ case 'ptrtoint': return makeI64(idents[0], 0);
2150
+ case 'inttoptr': {
2151
+ var m = /\(?\[(\d+),\d+\]\)?/.exec(idents[0]);
2152
+ if (m) return m[1]; // constant, can just parse it right now
2153
+ return '(' + idents[0] + '[0])'; // just directly truncate the i64 to a 'pointer', which is an i32
2154
+ }
2155
+ // Dangerous, rounded operations. TODO: Fully emulate
2156
+ case 'add': {
2157
+ if (PRECISE_I64_MATH) {
2158
+ return i64PreciseLib('add');
2159
+ } else {
2160
+ warnI64_1();
2161
+ return finish(splitI64(mergeI64(idents[0]) + '+' + mergeI64(idents[1]), true));
2162
+ }
2163
+ }
2164
+ case 'sub': {
2165
+ if (PRECISE_I64_MATH) {
2166
+ return i64PreciseLib('subtract');
2167
+ } else {
2168
+ warnI64_1();
2169
+ return finish(splitI64(mergeI64(idents[0]) + '-' + mergeI64(idents[1]), true));
2170
+ }
2171
+ }
2172
+ case 'sdiv': case 'udiv': {
2173
+ if (PRECISE_I64_MATH) {
2174
+ return preciseCall(op[0] === 'u' ? '___udivdi3' : '___divdi3');
2175
+ } else {
2176
+ warnI64_1();
2177
+ return finish(splitI64(makeRounding(mergeI64(idents[0], op[0] === 'u') + '/' + mergeI64(idents[1], op[0] === 'u'), bits, op[0] === 's'), true));
2178
+ }
2179
+ }
2180
+ case 'mul': {
2181
+ if (PRECISE_I64_MATH) {
2182
+ return preciseCall('___muldi3');
2183
+ } else {
2184
+ warnI64_1();
2185
+ return finish(splitI64(mergeI64(idents[0], op[0] === 'u') + '*' + mergeI64(idents[1], op[0] === 'u'), true));
2186
+ }
2187
+ }
2188
+ case 'urem': case 'srem': {
2189
+ if (PRECISE_I64_MATH) {
2190
+ return preciseCall(op[0] === 'u' ? '___uremdi3' : '___remdi3');
2191
+ } else {
2192
+ warnI64_1();
2193
+ return finish(splitI64(mergeI64(idents[0], op[0] === 'u') + '%' + mergeI64(idents[1], op[0] === 'u'), true));
2194
+ }
2195
+ }
2196
+ case 'bitcast': {
2197
+ // Pointers are not 64-bit, so there is really only one possible type of bitcast here, int to float or vice versa
2198
+ assert(USE_TYPED_ARRAYS == 2, 'Can only bitcast ints <-> floats with typed arrays mode 2');
2199
+ var inType = item.params[0].type;
2200
+ var outType = item.type;
2201
+ if (inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) {
2202
+ if (legalizedI64s) {
2203
+ return '(' + makeSetTempDouble(0, 'i32', idents[0] + '$0') + ', ' + makeSetTempDouble(1, 'i32', idents[0] + '$1') + ', ' + makeGetTempDouble(0, 'double') + ')';
2204
+ } else {
2205
+ return makeInlineCalculation(makeSetTempDouble(0, 'i32', 'VALUE[0]') + ',' + makeSetTempDouble(1, 'i32', 'VALUE[1]') + ',' + makeGetTempDouble(0, 'double'), idents[0], 'tempI64');
2206
+ }
2207
+ } else if (inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES) {
2208
+ if (legalizedI64s) {
2209
+ return makeSetTempDouble(0, 'double', idents[0]) + '; ' + finish([makeGetTempDouble(0, 'i32'), makeGetTempDouble(1, 'i32')]);
2210
+ } else {
2211
+ return '(' + makeSetTempDouble(0, 'double', idents[0]) + ',[' + makeGetTempDouble(0, 'i32') + ',' + makeGetTempDouble(1, 'i32') + '])';
2212
+ }
2213
+ } else {
2214
+ throw 'Invalid USE_TYPED_ARRAYS == 2 bitcast: ' + dump(item) + ' : ' + item.params[0].type;
2215
+ }
2216
+ }
2217
+ default: throw 'Unsupported i64 mode 1 op: ' + item.op + ' : ' + dump(item);
2218
+ }
2219
+ }
2220
+
2221
+ switch (op) {
2222
+ // basic integer ops
2223
+ case 'add': return handleOverflow(getFastValue(idents[0], '+', idents[1], item.type), bits);
2224
+ case 'sub': return handleOverflow(getFastValue(idents[0], '-', idents[1], item.type), bits);
2225
+ case 'sdiv': case 'udiv': return makeRounding(getFastValue(idents[0], '/', idents[1], item.type), bits, true);
2226
+ case 'mul': return getFastValue(idents[0], '*', idents[1], item.type); // overflow handling is already done in getFastValue for '*'
2227
+ case 'urem': case 'srem': return makeRounding(getFastValue(idents[0], '%', idents[1], item.type), bits, true);
2228
+ case 'or': {
2229
+ if (bits > 32) {
2230
+ assert(bits === 64, 'Too many bits for or: ' + bits);
2231
+ dprint('Warning: 64 bit OR - precision limit may be hit on llvm line ' + item.lineNum);
2232
+ return 'Runtime.or64(' + idents[0] + ', ' + idents[1] + ')';
2233
+ }
2234
+ return idents[0] + ' | ' + idents[1];
2235
+ }
2236
+ case 'and': {
2237
+ if (bits > 32) {
2238
+ assert(bits === 64, 'Too many bits for and: ' + bits);
2239
+ dprint('Warning: 64 bit AND - precision limit may be hit on llvm line ' + item.lineNum);
2240
+ return 'Runtime.and64(' + idents[0] + ', ' + idents[1] + ')';
2241
+ }
2242
+ return idents[0] + ' & ' + idents[1];
2243
+ }
2244
+ case 'xor': {
2245
+ if (bits > 32) {
2246
+ assert(bits === 64, 'Too many bits for xor: ' + bits);
2247
+ dprint('Warning: 64 bit XOR - precision limit may be hit on llvm line ' + item.lineNum);
2248
+ return 'Runtime.xor64(' + idents[0] + ', ' + idents[1] + ')';
2249
+ }
2250
+ return idents[0] + ' ^ ' + idents[1];
2251
+ }
2252
+ case 'shl': {
2253
+ if (bits > 32) return idents[0] + '*' + getFastValue(2, 'pow', idents[1]);
2254
+ return idents[0] + ' << ' + idents[1];
2255
+ }
2256
+ case 'ashr': {
2257
+ if (bits > 32) return integerizeBignum(idents[0] + '/' + getFastValue(2, 'pow', idents[1]));
2258
+ if (bits === 32) return originalIdents[0] + ' >> ' + idents[1]; // No need to reSign in this case
2259
+ return idents[0] + ' >> ' + idents[1];
2260
+ }
2261
+ case 'lshr': {
2262
+ if (bits > 32) return integerizeBignum(idents[0] + '/' + getFastValue(2, 'pow', idents[1]));
2263
+ if (bits === 32) return originalIdents[0] + ' >>> ' + idents[1]; // No need to unSign in this case
2264
+ return idents[0] + ' >>> ' + idents[1];
2265
+ }
2266
+ // basic float ops
2267
+ case 'fadd': return getFastValue(idents[0], '+', idents[1], item.type);
2268
+ case 'fsub': return getFastValue(idents[0], '-', idents[1], item.type);
2269
+ case 'fdiv': return getFastValue(idents[0], '/', idents[1], item.type);
2270
+ case 'fmul': return getFastValue(idents[0], '*', idents[1], item.type);
2271
+ case 'frem': return getFastValue(idents[0], '%', idents[1], item.type);
2272
+ case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double', op[0]);
2273
+ case 'fptoui': case 'fptosi': return makeRounding(idents[0], bitsLeft, op === 'fptosi', true);
2274
+
2275
+ // TODO: We sometimes generate false instead of 0, etc., in the *cmps. It seemed slightly faster before, but worth rechecking
2276
+ // Note that with typed arrays, these become 0 when written. So that is a potential difference with non-typed array runs.
2277
+ case 'icmp': {
2278
+ switch (variant) {
2279
+ case 'uge': case 'sge': return idents[0] + ' >= ' + idents[1];
2280
+ case 'ule': case 'sle': return idents[0] + ' <= ' + idents[1];
2281
+ case 'ugt': case 'sgt': return idents[0] + ' > ' + idents[1];
2282
+ case 'ult': case 'slt': return idents[0] + ' < ' + idents[1];
2283
+ // We use loose comparisons, which allows false == 0 to be true, etc. Ditto in fcmp
2284
+ case 'ne': case 'eq': {
2285
+ // We must sign them, so we do not compare -1 to 255 (could have unsigned them both too)
2286
+ // since LLVM tells us if <=, >= etc. comparisons are signed, but not == and !=.
2287
+ idents[0] = makeSignOp(idents[0], paramTypes[0], 're');
2288
+ idents[1] = makeSignOp(idents[1], paramTypes[1], 're');
2289
+ return idents[0] + (variant === 'eq' ? '==' : '!=') + idents[1];
2290
+ }
2291
+ default: throw 'Unknown icmp variant: ' + variant;
2292
+ }
2293
+ }
2294
+ case 'fcmp': {
2295
+ switch (variant) {
2296
+ // TODO 'o' ones should be 'ordered (no NaN) and',
2297
+ // 'u' ones should be 'unordered or'.
2298
+ case 'uge': case 'oge': return idents[0] + ' >= ' + idents[1];
2299
+ case 'ule': case 'ole': return idents[0] + ' <= ' + idents[1];
2300
+ case 'ugt': case 'ogt': return idents[0] + ' > ' + idents[1];
2301
+ case 'ult': case 'olt': return idents[0] + ' < ' + idents[1];
2302
+ case 'une': case 'one': return idents[0] + ' != ' + idents[1];
2303
+ case 'ueq': case 'oeq': return idents[0] + ' == ' + idents[1];
2304
+ case 'ord': return '!' + makeIsNaN(idents[0]) + ' & !' + makeIsNaN(idents[1]);
2305
+ case 'uno': return makeIsNaN(idents[0]) + ' | ' + makeIsNaN(idents[1]);
2306
+ case 'true': return '1';
2307
+ default: throw 'Unknown fcmp variant: ' + variant;
2308
+ }
2309
+ }
2310
+ // Note that zext has sign checking, see above. We must guard against -33 in i8 turning into -33 in i32
2311
+ // then unsigning that i32... which would give something huge.
2312
+ case 'zext': {
2313
+ if (EXPLICIT_ZEXT && bitsBefore == 1 && bitsLeft > 1) {
2314
+ return '(' + originalIdents[0] + '?1:0)'; // explicit bool-to-int conversion, work around v8 issue 2513
2315
+ break;
2316
+ }
2317
+ // otherwise, fall through
2318
+ }
2319
+ case 'fpext': case 'sext': return idents[0];
2320
+ case 'fptrunc': return idents[0];
2321
+ case 'select': return idents[0] + ' ? ' + asmEnsureFloat(idents[1], item.type) + ' : ' + asmEnsureFloat(idents[2], item.type);
2322
+ case 'ptrtoint': case 'inttoptr': {
2323
+ var ret = '';
2324
+ if (QUANTUM_SIZE == 1) {
2325
+ warnOnce('.ll contains ptrtoint and/or inttoptr. These may be dangerous in QUANTUM == 1. ' +
2326
+ 'The safest thing is to investigate every appearance, and modify the source code to avoid this. ' +
2327
+ 'Emscripten will print a list of the .ll lines, and also annotate the .js.');
2328
+ dprint(' ' + op + ' on .ll line ' + item.lineNum);
2329
+ idents[0] += ' /* Warning: ' + op + ', .ll line ' + item.lineNum + ' */';
2330
+ }
2331
+ if (op == 'inttoptr' || bitsLeft >= 32) return idents[0];
2332
+ // For ptrtoint and <32 bits, fall through into trunc since we need to truncate here
2333
+ }
2334
+ case 'trunc': {
2335
+ // Unlike extending, which we just 'do' (by doing nothing),
2336
+ // truncating can change the number, e.g. by truncating to an i1
2337
+ // in order to get the first bit
2338
+ assert(bitsLeft <= 32, 'Cannot truncate to more than 32 bits, since we use a native & op');
2339
+ return '((' + idents[0] + ') & ' + (Math.pow(2, bitsLeft)-1) + ')';
2340
+ }
2341
+ case 'bitcast': {
2342
+ // Most bitcasts are no-ops for us. However, the exception is int to float and float to int
2343
+ var inType = item.params[0].type;
2344
+ var outType = item.type;
2345
+ if ((inType in Runtime.INT_TYPES && outType in Runtime.FLOAT_TYPES) ||
2346
+ (inType in Runtime.FLOAT_TYPES && outType in Runtime.INT_TYPES)) {
2347
+ assert(USE_TYPED_ARRAYS == 2, 'Can only bitcast ints <-> floats with typed arrays mode 2');
2348
+ if (inType in Runtime.INT_TYPES) {
2349
+ return '(' + makeSetTempDouble(0, 'i32', idents[0]) + ',' + makeGetTempDouble(0, 'float') + ')';
2350
+ } else {
2351
+ return '(' + makeSetTempDouble(0, 'float', idents[0]) + ',' + makeGetTempDouble(0, 'i32') + ')';
2352
+ }
2353
+ }
2354
+ return idents[0];
2355
+ }
2356
+ default: throw 'Unknown mathcmp op: ' + item.op;
2357
+ }
2358
+ }
2359
+
2360
+ // Walks through some intertype data, calling a function at every item. If
2361
+ // the function returns true, will stop the walk.
2362
+ // TODO: Use this more in analyzer, possibly also in jsifier
2363
+ function walkInterdata(item, pre, post, obj) {
2364
+ if (!item || !item.intertype) return false;
2365
+ if (pre && pre(item, obj)) return true;
2366
+ var originalObj = obj;
2367
+ if (obj && obj.replaceWith) obj = obj.replaceWith; // allow pre to replace the object we pass to all its children
2368
+ if (item.value && walkInterdata(item.value, pre, post, obj)) return true;
2369
+ // TODO if (item.pointer && walkInterdata(item.pointer, pre, post, obj)) return true;
2370
+ if (item.dependent && walkInterdata(item.dependent, pre, post, obj)) return true;
2371
+ var i;
2372
+ if (item.params) {
2373
+ for (i = 0; i <= item.params.length; i++) {
2374
+ if (walkInterdata(item.params[i], pre, post, obj)) return true;
2375
+ }
2376
+ }
2377
+ if (item.possibleVars) { // other attributes that might contain interesting data; here, variables
2378
+ var box = { intertype: 'value', ident: '' };
2379
+ for (i = 0; i <= item.possibleVars.length; i++) {
2380
+ box.ident = item[item.possibleVars[i]];
2381
+ if (walkInterdata(box, pre, post, obj)) return true;
2382
+ }
2383
+ }
2384
+ return post && post(item, originalObj, obj);
2385
+ }
2386
+
2387
+ // Separate from walkInterdata so that the former is as fast as possible
2388
+ // If the callback returns a value, we replace the current item with that
2389
+ // value, and do *not* walk the children.
2390
+ function walkAndModifyInterdata(item, pre) {
2391
+ if (!item || !item.intertype) return false;
2392
+ var ret = pre(item);
2393
+ if (ret) return ret;
2394
+ var repl;
2395
+ if (item.value && (repl = walkAndModifyInterdata(item.value, pre))) item.value = repl;
2396
+ if (item.pointer && (repl = walkAndModifyInterdata(item.pointer, pre))) item.pointer = repl;
2397
+ if (item.dependent && (repl = walkAndModifyInterdata(item.dependent, pre))) item.dependent = repl;
2398
+ if (item.params) {
2399
+ for (var i = 0; i <= item.params.length; i++) {
2400
+ if (repl = walkAndModifyInterdata(item.params[i], pre)) item.params[i] = repl;
2401
+ }
2402
+ }
2403
+ // Ignore possibleVars because we can't replace them anyhow
2404
+ }
2405
+
2406
+ function parseBlockAddress(segment) {
2407
+ return { intertype: 'blockaddress', func: toNiceIdent(segment[2].item.tokens[0].text), label: toNiceIdent(segment[2].item.tokens[2].text), type: 'i32' };
2408
+ }
2409
+
2410
+ function finalizeBlockAddress(param) {
2411
+ return '{{{ BA_' + param.func + '|' + param.label + ' }}}'; // something python will replace later
2412
+ }
2413
+
2414
+ function stripCorrections(param) {
2415
+ var m;
2416
+ while (true) {
2417
+ if (m = /^\((.*)\)$/.exec(param)) {
2418
+ param = m[1];
2419
+ continue;
2420
+ }
2421
+ if (m = /^\(([$_\w]+)\)&\d+$/.exec(param)) {
2422
+ param = m[1];
2423
+ continue;
2424
+ }
2425
+ if (m = /^\(([$_\w()]+)\)\|0$/.exec(param)) {
2426
+ param = m[1];
2427
+ continue;
2428
+ }
2429
+ if (m = /^\(([$_\w()]+)\)\>>>0$/.exec(param)) {
2430
+ param = m[1];
2431
+ continue;
2432
+ }
2433
+ if (m = /CHECK_OVERFLOW\(([^,)]*),.*/.exec(param)) {
2434
+ param = m[1];
2435
+ continue;
2436
+ }
2437
+ break;
2438
+ }
2439
+ return param;
2440
+ }
2441
+
2442
+ function getImplementationType(varInfo) {
2443
+ if (varInfo.impl == 'nativized') {
2444
+ return removePointing(varInfo.type);
2445
+ }
2446
+ return varInfo.type;
2447
+ }
2448
+
2449
+ function charCode(char) {
2450
+ return char.charCodeAt(0);
2451
+ }
2452
+
2453
+ function getTypeFromHeap(suffix) {
2454
+ switch (suffix) {
2455
+ case '8': return 'i8';
2456
+ case '16': return 'i16';
2457
+ case '32': return 'i32';
2458
+ case 'F32': return 'float';
2459
+ case 'F64': return 'double';
2460
+ default: throw 'getTypeFromHeap? ' + suffix;
2461
+ }
2462
+ }
2463
+
2464
+ // Generates code that prints without printf(), but just putchar (so can be directly inline in asm.js)
2465
+ function makePrintChars(s, sep) {
2466
+ sep = sep || ';';
2467
+ var ret = '';
2468
+ for (var i = 0; i < s.length; i++) {
2469
+ ret += '_putchar(' + s.charCodeAt(i) + ')' + sep;
2470
+ }
2471
+ ret += '_putchar(10)';
2472
+ return ret;
2473
+ }
2474
+