webruby 0.2.2 → 0.2.4

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 (245) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/config.rb +4 -9
  3. data/lib/webruby/rake/files.rake +2 -2
  4. data/modules/emscripten/AUTHORS +9 -1
  5. data/modules/emscripten/CONTRIBUTING.markdown +5 -0
  6. data/modules/emscripten/ChangeLog +435 -0
  7. data/modules/emscripten/cmake/Modules/FindOpenAL.cmake +26 -0
  8. data/modules/emscripten/cmake/Platform/Emscripten.cmake +9 -2
  9. data/modules/emscripten/em++ +0 -2
  10. data/modules/emscripten/emcc +92 -32
  11. data/modules/emscripten/emlink.py +16 -13
  12. data/modules/emscripten/emmake +1 -1
  13. data/modules/emscripten/emrun +918 -0
  14. data/modules/emscripten/emrun.bat +2 -0
  15. data/modules/emscripten/emscripten.py +545 -20
  16. data/modules/emscripten/src/analyzer.js +6 -1
  17. data/modules/emscripten/src/compiler.js +25 -16
  18. data/modules/emscripten/src/emrun_postjs.js +20 -0
  19. data/modules/emscripten/{tests → src}/hello_world.js +0 -0
  20. data/modules/emscripten/src/intertyper.js +45 -16
  21. data/modules/emscripten/src/jsifier.js +78 -48
  22. data/modules/emscripten/src/library.js +381 -96
  23. data/modules/emscripten/src/library_browser.js +50 -53
  24. data/modules/emscripten/src/library_egl.js +66 -24
  25. data/modules/emscripten/src/library_fs.js +122 -90
  26. data/modules/emscripten/src/library_gl.js +739 -353
  27. data/modules/emscripten/src/library_glfw.js +9 -3
  28. data/modules/emscripten/src/library_glut.js +10 -5
  29. data/modules/emscripten/src/library_idbfs.js +14 -14
  30. data/modules/emscripten/src/library_memfs.js +65 -41
  31. data/modules/emscripten/src/library_nodefs.js +61 -9
  32. data/modules/emscripten/src/library_openal.js +4 -4
  33. data/modules/emscripten/src/library_path.js +9 -13
  34. data/modules/emscripten/src/library_sdl.js +301 -64
  35. data/modules/emscripten/src/library_sockfs.js +7 -5
  36. data/modules/emscripten/src/modules.js +62 -22
  37. data/modules/emscripten/src/parseTools.js +135 -102
  38. data/modules/emscripten/src/postamble.js +3 -4
  39. data/modules/emscripten/src/preamble.js +49 -29
  40. data/modules/emscripten/src/proxyClient.js +1 -1
  41. data/modules/emscripten/src/proxyWorker.js +10 -10
  42. data/modules/emscripten/src/relooper/Relooper.cpp +15 -4
  43. data/modules/emscripten/src/runtime.js +32 -8
  44. data/modules/emscripten/src/settings.js +25 -8
  45. data/modules/emscripten/src/shell.html +6 -3
  46. data/modules/emscripten/src/shell.js +13 -11
  47. data/modules/emscripten/src/simd.js +602 -432
  48. data/modules/emscripten/src/struct_info.json +22 -2
  49. data/modules/emscripten/src/utility.js +32 -17
  50. data/modules/emscripten/system/include/SDL/SDL_events.h +1 -0
  51. data/modules/emscripten/system/include/compat/ctype.h +17 -0
  52. data/modules/emscripten/system/include/compat/wchar.h +23 -0
  53. data/modules/emscripten/system/include/compat/wctype.h +23 -0
  54. data/modules/emscripten/system/include/emscripten/emmintrin.h +87 -0
  55. data/modules/emscripten/system/include/emscripten/emscripten.h +30 -4
  56. data/modules/emscripten/system/include/emscripten/vector.h +29 -1
  57. data/modules/emscripten/system/include/emscripten/xmmintrin.h +131 -0
  58. data/modules/emscripten/system/include/libcxx/CREDITS.TXT +9 -1
  59. data/modules/emscripten/system/include/libcxx/__bit_reference +8 -8
  60. data/modules/emscripten/system/include/libcxx/__config +95 -17
  61. data/modules/emscripten/system/include/libcxx/__debug +25 -4
  62. data/modules/emscripten/system/include/libcxx/__functional_03 +7 -7
  63. data/modules/emscripten/system/include/libcxx/__functional_base +169 -9
  64. data/modules/emscripten/system/include/libcxx/__functional_base_03 +1 -1
  65. data/modules/emscripten/system/include/libcxx/__hash_table +25 -25
  66. data/modules/emscripten/system/include/libcxx/__locale +21 -19
  67. data/modules/emscripten/system/include/libcxx/__mutex_base +2 -33
  68. data/modules/emscripten/system/include/libcxx/__split_buffer +9 -9
  69. data/modules/emscripten/system/include/libcxx/__std_stream +14 -0
  70. data/modules/emscripten/system/include/libcxx/__tree +35 -26
  71. data/modules/emscripten/system/include/libcxx/__tuple +15 -15
  72. data/modules/emscripten/system/include/libcxx/__tuple_03 +2 -2
  73. data/modules/emscripten/system/include/libcxx/__undef_min_max +8 -0
  74. data/modules/emscripten/system/include/libcxx/algorithm +121 -110
  75. data/modules/emscripten/system/include/libcxx/array +15 -15
  76. data/modules/emscripten/system/include/libcxx/bitset +4 -4
  77. data/modules/emscripten/system/include/libcxx/chrono +51 -17
  78. data/modules/emscripten/system/include/libcxx/cmath +25 -23
  79. data/modules/emscripten/system/include/libcxx/codecvt +21 -18
  80. data/modules/emscripten/system/include/libcxx/complex +48 -7
  81. data/modules/emscripten/system/include/libcxx/cstddef +1 -1
  82. data/modules/emscripten/system/include/libcxx/cstdio +8 -1
  83. data/modules/emscripten/system/include/libcxx/cstdlib +1 -1
  84. data/modules/emscripten/system/include/libcxx/cwchar +1 -1
  85. data/modules/emscripten/system/include/libcxx/deque +26 -12
  86. data/modules/emscripten/system/include/libcxx/dynarray +311 -0
  87. data/modules/emscripten/system/include/libcxx/exception +4 -4
  88. data/modules/emscripten/system/include/libcxx/ext/__hash +3 -3
  89. data/modules/emscripten/system/include/libcxx/ext/hash_map +19 -15
  90. data/modules/emscripten/system/include/libcxx/ext/hash_set +7 -3
  91. data/modules/emscripten/system/include/libcxx/forward_list +33 -7
  92. data/modules/emscripten/system/include/libcxx/fstream +4 -4
  93. data/modules/emscripten/system/include/libcxx/functional +200 -170
  94. data/modules/emscripten/system/include/libcxx/future +83 -39
  95. data/modules/emscripten/system/include/libcxx/initializer_list +24 -11
  96. data/modules/emscripten/system/include/libcxx/iomanip +147 -0
  97. data/modules/emscripten/system/include/libcxx/ios +24 -16
  98. data/modules/emscripten/system/include/libcxx/iosfwd +19 -19
  99. data/modules/emscripten/system/include/libcxx/istream +13 -8
  100. data/modules/emscripten/system/include/libcxx/iterator +108 -417
  101. data/modules/emscripten/system/include/libcxx/limits +8 -4
  102. data/modules/emscripten/system/include/libcxx/list +28 -8
  103. data/modules/emscripten/system/include/libcxx/locale +153 -390
  104. data/modules/emscripten/system/include/libcxx/map +280 -100
  105. data/modules/emscripten/system/include/libcxx/memory +49 -97
  106. data/modules/emscripten/system/include/libcxx/mutex +2 -2
  107. data/modules/emscripten/system/include/libcxx/new +43 -14
  108. data/modules/emscripten/system/include/libcxx/numeric +2 -2
  109. data/modules/emscripten/system/include/libcxx/optional +697 -0
  110. data/modules/emscripten/system/include/libcxx/ostream +17 -8
  111. data/modules/emscripten/system/include/libcxx/queue +5 -5
  112. data/modules/emscripten/system/include/libcxx/random +53 -51
  113. data/modules/emscripten/system/include/libcxx/ratio +11 -11
  114. data/modules/emscripten/system/include/libcxx/readme.txt +1 -1
  115. data/modules/emscripten/system/include/libcxx/regex +23 -20
  116. data/modules/emscripten/system/include/libcxx/scoped_allocator +1 -1
  117. data/modules/emscripten/system/include/libcxx/set +166 -2
  118. data/modules/emscripten/system/include/libcxx/shared_mutex +419 -0
  119. data/modules/emscripten/system/include/libcxx/sstream +4 -4
  120. data/modules/emscripten/system/include/libcxx/stack +3 -3
  121. data/modules/emscripten/system/include/libcxx/streambuf +5 -5
  122. data/modules/emscripten/system/include/libcxx/string +372 -324
  123. data/modules/emscripten/system/include/libcxx/support/ibm/limits.h +99 -0
  124. data/modules/emscripten/system/include/libcxx/support/ibm/support.h +54 -0
  125. data/modules/emscripten/system/include/libcxx/support/ibm/xlocale.h +326 -0
  126. data/modules/emscripten/system/include/libcxx/support/win32/limits_win32.h +6 -6
  127. data/modules/emscripten/system/include/libcxx/support/win32/locale_win32.h +15 -15
  128. data/modules/emscripten/system/include/libcxx/support/win32/math_win32.h +2 -0
  129. data/modules/emscripten/system/include/libcxx/support/win32/support.h +6 -1
  130. data/modules/emscripten/system/include/libcxx/system_error +14 -8
  131. data/modules/emscripten/system/include/libcxx/thread +7 -8
  132. data/modules/emscripten/system/include/libcxx/tuple +29 -88
  133. data/modules/emscripten/system/include/libcxx/type_traits +253 -209
  134. data/modules/emscripten/system/include/libcxx/typeindex +3 -3
  135. data/modules/emscripten/system/include/libcxx/unordered_map +162 -101
  136. data/modules/emscripten/system/include/libcxx/unordered_set +79 -2
  137. data/modules/emscripten/system/include/libcxx/utility +20 -20
  138. data/modules/emscripten/system/include/libcxx/valarray +23 -23
  139. data/modules/emscripten/system/include/libcxx/vector +114 -91
  140. data/modules/emscripten/system/lib/libc/musl/src/regex/regcomp.c +3352 -0
  141. data/modules/emscripten/system/lib/libc/musl/src/regex/regerror.c +35 -0
  142. data/modules/emscripten/system/lib/libc/musl/src/regex/regexec.c +1011 -0
  143. data/modules/emscripten/system/lib/libc/musl/src/regex/tre-mem.c +158 -0
  144. data/modules/emscripten/system/lib/libc/musl/src/regex/tre.h +231 -0
  145. data/modules/emscripten/system/lib/libcextra.symbols +7 -0
  146. data/modules/emscripten/system/lib/libcxx/CREDITS.TXT +9 -1
  147. data/modules/emscripten/system/lib/libcxx/algorithm.cpp +1 -0
  148. data/modules/emscripten/system/lib/libcxx/debug.cpp +66 -42
  149. data/modules/emscripten/system/lib/libcxx/exception.cpp +88 -16
  150. data/modules/emscripten/system/lib/libcxx/future.cpp +6 -0
  151. data/modules/emscripten/system/lib/libcxx/ios.cpp +7 -2
  152. data/modules/emscripten/system/lib/libcxx/iostream.cpp +8 -8
  153. data/modules/emscripten/system/lib/libcxx/locale.cpp +38 -11
  154. data/modules/emscripten/system/lib/libcxx/mutex.cpp +3 -0
  155. data/modules/emscripten/system/lib/libcxx/new.cpp +44 -10
  156. data/modules/emscripten/system/lib/libcxx/optional.cpp +25 -0
  157. data/modules/emscripten/system/lib/libcxx/random.cpp +26 -0
  158. data/modules/emscripten/system/lib/libcxx/readme.txt +1 -1
  159. data/modules/emscripten/system/lib/libcxx/shared_mutex.cpp +101 -0
  160. data/modules/emscripten/system/lib/libcxx/stdexcept.cpp +11 -7
  161. data/modules/emscripten/system/lib/libcxx/string.cpp +3 -1
  162. data/modules/emscripten/system/lib/libcxx/strstream.cpp +7 -7
  163. data/modules/emscripten/system/lib/libcxx/support/win32/locale_win32.cpp +12 -13
  164. data/modules/emscripten/system/lib/libcxx/support/win32/support.cpp +33 -36
  165. data/modules/emscripten/system/lib/libcxx/symbols +187 -168
  166. data/modules/emscripten/system/lib/libcxx/system_error.cpp +1 -0
  167. data/modules/emscripten/system/lib/libcxx/thread.cpp +7 -3
  168. data/modules/emscripten/system/lib/libcxx/typeinfo.cpp +9 -6
  169. data/modules/emscripten/system/lib/libcxx/valarray.cpp +2 -0
  170. data/modules/emscripten/third_party/lzma.js/doit.bat +4 -0
  171. data/modules/emscripten/third_party/lzma.js/doit.sh +9 -2
  172. data/modules/emscripten/tools/cache.py +5 -7
  173. data/modules/emscripten/tools/cache.pyc +0 -0
  174. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +7 -0
  175. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  176. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +3 -0
  177. data/modules/emscripten/tools/eliminator/eliminator-test.js +9 -1
  178. data/modules/emscripten/tools/file_packager.py +93 -50
  179. data/modules/emscripten/tools/js-optimizer.js +98 -48
  180. data/modules/emscripten/tools/js_optimizer.py +4 -4
  181. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  182. data/modules/emscripten/tools/jsrun.py +1 -1
  183. data/modules/emscripten/tools/jsrun.pyc +0 -0
  184. data/modules/emscripten/tools/response_file.py +6 -0
  185. data/modules/emscripten/tools/response_file.pyc +0 -0
  186. data/modules/emscripten/tools/settings_template_readonly.py +2 -0
  187. data/modules/emscripten/tools/shared.py +88 -34
  188. data/modules/emscripten/tools/shared.pyc +0 -0
  189. data/modules/emscripten/tools/split.py +21 -13
  190. data/modules/mruby/build_config.rb +7 -1
  191. data/modules/mruby/doc/compile/README.md +5 -9
  192. data/modules/mruby/include/mrbconf.h +5 -2
  193. data/modules/mruby/include/mruby/array.h +1 -0
  194. data/modules/mruby/include/mruby/compile.h +2 -4
  195. data/modules/mruby/include/mruby/dump.h +7 -16
  196. data/modules/mruby/include/mruby/hash.h +1 -1
  197. data/modules/mruby/include/mruby/irep.h +14 -2
  198. data/modules/mruby/include/mruby/khash.h +8 -7
  199. data/modules/mruby/include/mruby/string.h +1 -0
  200. data/modules/mruby/include/mruby/value.h +5 -2
  201. data/modules/mruby/include/mruby.h +12 -13
  202. data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +16 -6
  203. data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +18 -30
  204. data/modules/mruby/mrbgems/mruby-fiber/src/fiber.c +21 -0
  205. data/modules/mruby/mrbgems/mruby-math/src/math.c +1 -1
  206. data/modules/mruby/mrbgems/mruby-random/src/random.c +144 -47
  207. data/modules/mruby/mrbgems/mruby-random/test/random.rb +44 -0
  208. data/modules/mruby/mrbgems/mruby-struct/src/struct.c +5 -5
  209. data/modules/mruby/mrblib/numeric.rb +99 -33
  210. data/modules/mruby/src/array.c +11 -4
  211. data/modules/mruby/src/backtrace.c +2 -2
  212. data/modules/mruby/src/class.c +49 -30
  213. data/modules/mruby/src/codegen.c +131 -79
  214. data/modules/mruby/src/debug.c +1 -1
  215. data/modules/mruby/src/dump.c +213 -163
  216. data/modules/mruby/src/error.c +17 -17
  217. data/modules/mruby/src/error.h +1 -1
  218. data/modules/mruby/src/etc.c +10 -0
  219. data/modules/mruby/src/gc.c +35 -17
  220. data/modules/mruby/src/hash.c +5 -5
  221. data/modules/mruby/src/kernel.c +36 -14
  222. data/modules/mruby/src/load.c +238 -296
  223. data/modules/mruby/src/numeric.c +18 -98
  224. data/modules/mruby/src/object.c +3 -5
  225. data/modules/mruby/src/parse.y +63 -56
  226. data/modules/mruby/src/proc.c +8 -5
  227. data/modules/mruby/src/re.h +0 -1
  228. data/modules/mruby/src/state.c +65 -27
  229. data/modules/mruby/src/string.c +3 -31
  230. data/modules/mruby/src/symbol.c +3 -3
  231. data/modules/mruby/src/variable.c +12 -5
  232. data/modules/mruby/src/vm.c +90 -72
  233. data/modules/mruby/tasks/mruby_build.rake +10 -1
  234. data/modules/mruby/tasks/toolchains/gcc.rake +12 -2
  235. data/modules/mruby/tasks/toolchains/{vs2012.rake → visualcpp.rake} +1 -1
  236. data/modules/mruby/test/driver.c +3 -3
  237. data/modules/mruby/test/t/array.rb +5 -5
  238. data/modules/mruby/test/t/class.rb +14 -1
  239. data/modules/mruby/test/t/kernel.rb +4 -0
  240. data/modules/mruby/test/t/module.rb +4 -4
  241. data/modules/mruby/test/t/nameerror.rb +1 -1
  242. data/modules/mruby/tools/mrbc/mrbc.c +23 -17
  243. data/modules/mruby/travis_config.rb +10 -1
  244. metadata +28 -5
  245. data/modules/mruby/tasks/toolchains/vs2010.rake +0 -3
@@ -246,7 +246,7 @@ var EXITSTATUS = 0;
246
246
  var undef = 0;
247
247
  // tempInt is used for 32-bit signed values or smaller. tempBigInt is used
248
248
  // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
249
- var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
249
+ var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD, tempDouble, tempFloat;
250
250
  #if USE_TYPED_ARRAYS == 2
251
251
  var tempI64, tempI64b;
252
252
  var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;
@@ -585,16 +585,16 @@ function UTF16ToString(ptr) {
585
585
  }
586
586
  Module['UTF16ToString'] = UTF16ToString;
587
587
 
588
- // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
588
+ // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
589
589
  // null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.
590
590
  function stringToUTF16(str, outPtr) {
591
591
  for(var i = 0; i < str.length; ++i) {
592
592
  // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
593
593
  var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
594
- {{{ makeSetValue('outPtr', 'i*2', 'codeUnit', 'i16') }}}
594
+ {{{ makeSetValue('outPtr', 'i*2', 'codeUnit', 'i16') }}};
595
595
  }
596
596
  // Null-terminate the pointer to the HEAP.
597
- {{{ makeSetValue('outPtr', 'str.length*2', 0, 'i16') }}}
597
+ {{{ makeSetValue('outPtr', 'str.length*2', 0, 'i16') }}};
598
598
  }
599
599
  Module['stringToUTF16'] = stringToUTF16;
600
600
 
@@ -620,7 +620,7 @@ function UTF32ToString(ptr) {
620
620
  }
621
621
  Module['UTF32ToString'] = UTF32ToString;
622
622
 
623
- // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
623
+ // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr',
624
624
  // null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,
625
625
  // but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.
626
626
  function stringToUTF32(str, outPtr) {
@@ -632,11 +632,11 @@ function stringToUTF32(str, outPtr) {
632
632
  var trailSurrogate = str.charCodeAt(++iCodeUnit);
633
633
  codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
634
634
  }
635
- {{{ makeSetValue('outPtr', 'iChar*4', 'codeUnit', 'i32') }}}
635
+ {{{ makeSetValue('outPtr', 'iChar*4', 'codeUnit', 'i32') }}};
636
636
  ++iChar;
637
637
  }
638
638
  // Null-terminate the pointer to the HEAP.
639
- {{{ makeSetValue('outPtr', 'iChar*4', 0, 'i32') }}}
639
+ {{{ makeSetValue('outPtr', 'iChar*4', 0, 'i32') }}};
640
640
  }
641
641
  Module['stringToUTF32'] = stringToUTF32;
642
642
 
@@ -646,6 +646,10 @@ function demangle(func) {
646
646
  if (func[0] !== '_') return func;
647
647
  if (func[1] !== '_') return func; // C function
648
648
  if (func[2] !== 'Z') return func;
649
+ switch (func[3]) {
650
+ case 'n': return 'operator new()';
651
+ case 'd': return 'operator delete()';
652
+ }
649
653
  var i = 3;
650
654
  // params, etc.
651
655
  var basicTypes = {
@@ -678,7 +682,7 @@ function demangle(func) {
678
682
  var subs = [];
679
683
  function parseNested() {
680
684
  i++;
681
- if (func[i] === 'K') i++;
685
+ if (func[i] === 'K') i++; // ignore const
682
686
  var parts = [];
683
687
  while (func[i] !== 'E') {
684
688
  if (func[i] === 'S') { // substitution
@@ -689,6 +693,11 @@ function demangle(func) {
689
693
  i = next+1;
690
694
  continue;
691
695
  }
696
+ if (func[i] === 'C') { // constructor
697
+ parts.push(parts[parts.length-1]);
698
+ i += 2;
699
+ continue;
700
+ }
692
701
  var size = parseInt(func.substr(i));
693
702
  var pre = size.toString().length;
694
703
  if (!size || !pre) { i--; break; } // counter i++ below us
@@ -700,6 +709,7 @@ function demangle(func) {
700
709
  i++; // skip E
701
710
  return parts;
702
711
  }
712
+ var first = true;
703
713
  function parse(rawList, limit, allowVoid) { // main parser
704
714
  limit = limit || Infinity;
705
715
  var ret = '', list = [];
@@ -707,21 +717,22 @@ function demangle(func) {
707
717
  return '(' + list.join(', ') + ')';
708
718
  }
709
719
  var name;
710
- if (func[i] !== 'N') {
720
+ if (func[i] === 'N') {
721
+ // namespaced N-E
722
+ name = parseNested().join('::');
723
+ limit--;
724
+ if (limit === 0) return rawList ? [name] : name;
725
+ } else {
711
726
  // not namespaced
712
- if (func[i] === 'K') i++;
727
+ if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L'
713
728
  var size = parseInt(func.substr(i));
714
729
  if (size) {
715
730
  var pre = size.toString().length;
716
731
  name = func.substr(i + pre, size);
717
732
  i += pre + size;
718
733
  }
719
- } else {
720
- // namespaced N-E
721
- name = parseNested().join('::');
722
- limit--;
723
- if (limit === 0) return rawList ? [name] : name;
724
734
  }
735
+ first = false;
725
736
  if (func[i] === 'I') {
726
737
  i++;
727
738
  var iList = parse(true);
@@ -1032,7 +1043,7 @@ function writeStringToMemory(string, buffer, dontAddNull) {
1032
1043
  var i = 0;
1033
1044
  while (i < array.length) {
1034
1045
  var chr = array[i];
1035
- {{{ makeSetValue('buffer', 'i', 'chr', 'i8') }}}
1046
+ {{{ makeSetValue('buffer', 'i', 'chr', 'i8') }}};
1036
1047
  i = i + 1;
1037
1048
  }
1038
1049
  }
@@ -1050,9 +1061,9 @@ function writeAsciiToMemory(str, buffer, dontAddNull) {
1050
1061
  #if ASSERTIONS
1051
1062
  assert(str.charCodeAt(i) === str.charCodeAt(i)&0xff);
1052
1063
  #endif
1053
- {{{ makeSetValue('buffer', 'i', 'str.charCodeAt(i)', 'i8') }}}
1064
+ {{{ makeSetValue('buffer', 'i', 'str.charCodeAt(i)', 'i8') }}};
1054
1065
  }
1055
- if (!dontAddNull) {{{ makeSetValue('buffer', 'str.length', 0, 'i8') }}}
1066
+ if (!dontAddNull) {{{ makeSetValue('buffer', 'str.length', 0, 'i8') }}};
1056
1067
  }
1057
1068
  Module['writeAsciiToMemory'] = writeAsciiToMemory;
1058
1069
 
@@ -1060,7 +1071,7 @@ Module['writeAsciiToMemory'] = writeAsciiToMemory;
1060
1071
  {{{ reSign }}}
1061
1072
 
1062
1073
  #if PRECISE_I32_MUL
1063
- if (!Math['imul']) Math['imul'] = function(a, b) {
1074
+ if (!Math['imul']) Math['imul'] = function imul(a, b) {
1064
1075
  var ah = a >>> 16;
1065
1076
  var al = a & 0xffff;
1066
1077
  var bh = b >>> 16;
@@ -1068,17 +1079,22 @@ if (!Math['imul']) Math['imul'] = function(a, b) {
1068
1079
  return (al*bl + ((ah*bl + al*bh) << 16))|0;
1069
1080
  };
1070
1081
  #else
1071
- Math['imul'] = function(a, b) {
1082
+ Math['imul'] = function imul(a, b) {
1072
1083
  return (a*b)|0; // fast but imprecise
1073
1084
  };
1074
1085
  #endif
1075
1086
  Math.imul = Math['imul'];
1076
1087
 
1077
- #if TO_FLOAT32
1078
- if (!Math['toFloat32']) Math['toFloat32'] = function(x) {
1079
- return x;
1080
- };
1081
- Math.toFloat32 = Math['toFloat32'];
1088
+ #if PRECISE_F32
1089
+ #if PRECISE_F32 == 1
1090
+ if (!Math['fround']) {
1091
+ var froundBuffer = new Float32Array(1);
1092
+ Math['fround'] = function(x) { froundBuffer[0] = x; return froundBuffer[0] };
1093
+ }
1094
+ #else // 2
1095
+ if (!Math['fround']) Math['fround'] = function(x) { return x };
1096
+ #endif
1097
+ Math.fround = Math['fround'];
1082
1098
  #endif
1083
1099
 
1084
1100
  var Math_abs = Math.abs;
@@ -1096,7 +1112,7 @@ var Math_ceil = Math.ceil;
1096
1112
  var Math_floor = Math.floor;
1097
1113
  var Math_pow = Math.pow;
1098
1114
  var Math_imul = Math.imul;
1099
- var Math_toFloat32 = Math.toFloat32;
1115
+ var Math_fround = Math.fround;
1100
1116
  var Math_min = Math.min;
1101
1117
 
1102
1118
  // A counter of dependencies for calling run(). If we need to
@@ -1107,19 +1123,21 @@ var Math_min = Math.min;
1107
1123
  // it happens right before run - run will be postponed until
1108
1124
  // the dependencies are met.
1109
1125
  var runDependencies = 0;
1110
- var runDependencyTracking = {};
1111
1126
  var runDependencyWatcher = null;
1112
1127
  var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
1128
+ #if ASSERTIONS
1129
+ var runDependencyTracking = {};
1130
+ #endif
1113
1131
 
1114
1132
  function addRunDependency(id) {
1115
1133
  runDependencies++;
1116
1134
  if (Module['monitorRunDependencies']) {
1117
1135
  Module['monitorRunDependencies'](runDependencies);
1118
1136
  }
1137
+ #if ASSERTIONS
1119
1138
  if (id) {
1120
1139
  assert(!runDependencyTracking[id]);
1121
1140
  runDependencyTracking[id] = 1;
1122
- #if ASSERTIONS
1123
1141
  if (runDependencyWatcher === null && typeof setInterval !== 'undefined') {
1124
1142
  // Check for missing dependencies every few seconds
1125
1143
  runDependencyWatcher = setInterval(function() {
@@ -1136,10 +1154,10 @@ function addRunDependency(id) {
1136
1154
  }
1137
1155
  }, 10000);
1138
1156
  }
1139
- #endif
1140
1157
  } else {
1141
1158
  Module.printErr('warning: run dependency added without ID');
1142
1159
  }
1160
+ #endif
1143
1161
  }
1144
1162
  Module['addRunDependency'] = addRunDependency;
1145
1163
  function removeRunDependency(id) {
@@ -1147,12 +1165,14 @@ function removeRunDependency(id) {
1147
1165
  if (Module['monitorRunDependencies']) {
1148
1166
  Module['monitorRunDependencies'](runDependencies);
1149
1167
  }
1168
+ #if ASSERTIONS
1150
1169
  if (id) {
1151
1170
  assert(runDependencyTracking[id]);
1152
1171
  delete runDependencyTracking[id];
1153
1172
  } else {
1154
1173
  Module.printErr('warning: run dependency removed without ID');
1155
1174
  }
1175
+ #endif
1156
1176
  if (runDependencies == 0) {
1157
1177
  if (runDependencyWatcher !== null) {
1158
1178
  clearInterval(runDependencyWatcher);
@@ -5,7 +5,7 @@ Module.ctx = Module.canvas.getContext('2d');
5
5
 
6
6
  var worker = new Worker('{{{ filename }}}.js');
7
7
 
8
- worker.onmessage = function(event) {
8
+ worker.onmessage = function worker_onmessage(event) {
9
9
  var data = event.data;
10
10
  switch (data.target) {
11
11
  case 'stdout': {
@@ -2,12 +2,12 @@
2
2
  function EventListener() {
3
3
  this.listeners = {};
4
4
 
5
- this.addEventListener = function(event, func) {
5
+ this.addEventListener = function addEventListener(event, func) {
6
6
  if (!this.listeners[event]) this.listeners[event] = [];
7
7
  this.listeners[event].push(func);
8
8
  };
9
9
 
10
- this.fireEvent = function(event) {
10
+ this.fireEvent = function fireEvent(event) {
11
11
  event.preventDefault = function(){};
12
12
 
13
13
  if (event.type in this.listeners) {
@@ -22,17 +22,17 @@ var window = this;
22
22
  var windowExtra = new EventListener();
23
23
  for (var x in windowExtra) window[x] = windowExtra[x];
24
24
 
25
- window.close = function() {
25
+ window.close = function window_close() {
26
26
  postMessage({ target: 'window', method: 'close' });
27
27
  };
28
28
 
29
29
  var document = new EventListener();
30
30
 
31
- document.createElement = function(what) {
31
+ document.createElement = function document_createElement(what) {
32
32
  switch(what) {
33
33
  case 'canvas': {
34
34
  var canvas = new EventListener();
35
- canvas.ensureData = function() {
35
+ canvas.ensureData = function canvas_ensureData() {
36
36
  if (!canvas.data || canvas.data.width !== canvas.width || canvas.data.height !== canvas.height) {
37
37
  canvas.data = {
38
38
  width: canvas.width,
@@ -42,7 +42,7 @@ document.createElement = function(what) {
42
42
  postMessage({ target: 'canvas', op: 'resize', width: canvas.width, height: canvas.height });
43
43
  }
44
44
  };
45
- canvas.getContext = function(type) {
45
+ canvas.getContext = function canvas_getContext(type) {
46
46
  assert(type == '2d');
47
47
  return {
48
48
  getImageData: function(x, y, w, h) {
@@ -63,7 +63,7 @@ document.createElement = function(what) {
63
63
  };
64
64
  };
65
65
  canvas.boundingClientRect = {};
66
- canvas.getBoundingClientRect = function() {
66
+ canvas.getBoundingClientRect = function canvas_getBoundingClientRect() {
67
67
  return {
68
68
  width: canvas.boundingClientRect.width,
69
69
  height: canvas.boundingClientRect.height,
@@ -89,10 +89,10 @@ Module.canvas = document.createElement('canvas');
89
89
 
90
90
  Module.setStatus = function(){};
91
91
 
92
- Module.print = function(x) {
92
+ Module.print = function Module_print(x) {
93
93
  postMessage({ target: 'stdout', content: x });
94
94
  };
95
- Module.printErr = function(x) {
95
+ Module.printErr = function Module_printErr(x) {
96
96
  postMessage({ target: 'stderr', content: x });
97
97
  };
98
98
 
@@ -112,7 +112,7 @@ function messageResender() {
112
112
  }
113
113
  }
114
114
 
115
- onmessage = function(message) {
115
+ onmessage = function onmessage(message) {
116
116
  if (!calledMain) {
117
117
  if (!messageBuffer) {
118
118
  messageBuffer = [];
@@ -6,7 +6,12 @@
6
6
  #include <list>
7
7
  #include <stack>
8
8
 
9
+ #if EMSCRIPTEN
9
10
  #include "ministring.h"
11
+ #else
12
+ #include <string>
13
+ typedef std::string ministring;
14
+ #endif
10
15
 
11
16
  template <class T, class U> bool contains(const T& container, const U& contained) {
12
17
  return container.find(contained) != container.end();
@@ -66,11 +71,7 @@ static int AsmJS = 0;
66
71
 
67
72
  // Indenter
68
73
 
69
- #if EMSCRIPTEN
70
74
  int Indenter::CurrIndent = 1;
71
- #else
72
- int Indenter::CurrIndent = 0;
73
- #endif
74
75
 
75
76
  // Branch
76
77
 
@@ -541,6 +542,16 @@ void Relooper::Calculate(Block *Entry) {
541
542
  for (BlockSet::iterator iter = Curr->BranchesIn.begin(); iter != Curr->BranchesIn.end(); iter++) {
542
543
  Queue.insert(*iter);
543
544
  }
545
+ #if 0
546
+ // Add elements it leads to, if they are dead ends. There is no reason not to hoist dead ends
547
+ // into loops, as it can avoid multiple entries after the loop
548
+ for (BlockBranchMap::iterator iter = Curr->BranchesOut.begin(); iter != Curr->BranchesOut.end(); iter++) {
549
+ Block *Target = iter->first;
550
+ if (Target->BranchesIn.size() <= 1 && Target->BranchesOut.size() == 0) {
551
+ Queue.insert(Target);
552
+ }
553
+ }
554
+ #endif
544
555
  }
545
556
  }
546
557
  assert(InnerBlocks.size() > 0);
@@ -82,8 +82,8 @@ var RuntimeGenerator = {
82
82
  // Rounding is inevitable if the number is large. This is a particular problem for small negative numbers
83
83
  // (-1 will be rounded!), so handle negatives separately and carefully
84
84
  makeBigInt: function(low, high, unsigned) {
85
- var unsignedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'float') + '+(' + asmCoercion(makeSignOp(high, 'i32', 'un', 1, 1), 'float') + '*' + asmEnsureFloat(4294967296, 'float') + '))';
86
- var signedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'float') + '+(' + asmCoercion(makeSignOp(high, 'i32', 're', 1, 1), 'float') + '*' + asmEnsureFloat(4294967296, 'float') + '))';
85
+ var unsignedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'double') + '+(' + asmCoercion(makeSignOp(high, 'i32', 'un', 1, 1), 'double') + '*' + asmEnsureFloat(4294967296, 'double') + '))';
86
+ var signedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'double') + '+(' + asmCoercion(makeSignOp(high, 'i32', 're', 1, 1), 'double') + '*' + asmEnsureFloat(4294967296, 'double') + '))';
87
87
  if (typeof unsigned === 'string') return '(' + unsigned + ' ? ' + unsignedRet + ' : ' + signedRet + ')';
88
88
  return unsigned ? unsignedRet : signedRet;
89
89
  }
@@ -145,7 +145,7 @@ var Runtime = {
145
145
  //! @param type The type, by name.
146
146
  getNativeTypeSize: function(type) {
147
147
  #if QUANTUM_SIZE == 1
148
- return 1;
148
+ return 1;
149
149
  #else
150
150
  switch (type) {
151
151
  case 'i1': case 'i8': return 1;
@@ -161,6 +161,8 @@ var Runtime = {
161
161
  var bits = parseInt(type.substr(1));
162
162
  assert(bits % 8 === 0);
163
163
  return bits/8;
164
+ } else {
165
+ return 0;
164
166
  }
165
167
  }
166
168
  }
@@ -183,8 +185,11 @@ var Runtime = {
183
185
  // type can be a native type or a struct (or null, for structs we only look at size here)
184
186
  getAlignSize: function(type, size, vararg) {
185
187
  // we align i64s and doubles on 64-bit boundaries, unlike x86
188
+ #if TARGET_LE32 == 1
189
+ if (vararg) return 8;
190
+ #endif
186
191
  #if TARGET_LE32
187
- if (type == 'i64' || type == 'double' || vararg) return 8;
192
+ if (!vararg && (type == 'i64' || type == 'double')) return 8;
188
193
  if (!type) return Math.min(size, 8); // align structures internally to 64 bits
189
194
  #endif
190
195
  return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);
@@ -224,9 +229,16 @@ var Runtime = {
224
229
  // bN, large number field, like a [N x i8]
225
230
  size = field.substr(1)|0;
226
231
  alignSize = 1;
227
- } else {
228
- assert(field[0] === '<', field); // assumed to be a vector type, if none of the above
232
+ } else if (field[0] === '<') {
233
+ // vector type
229
234
  size = alignSize = Types.types[field].flatSize; // fully aligned
235
+ } else if (field[0] === 'i') {
236
+ // illegal integer field, that could not be legalized because it is an internal structure field
237
+ // it is ok to have such fields, if we just use them as markers of field size and nothing more complex
238
+ size = alignSize = parseInt(field.substr(1))/8;
239
+ assert(size % 1 === 0, 'cannot handle non-byte-size field ' + field);
240
+ } else {
241
+ assert(false, 'invalid type for calculateStructAlignment');
230
242
  }
231
243
  if (type.packed) alignSize = 1;
232
244
  type.alignSize = Math.max(type.alignSize, alignSize);
@@ -372,6 +384,18 @@ var Runtime = {
372
384
  #endif
373
385
  },
374
386
 
387
+ getAsmConst: function(code, numArgs) {
388
+ // code is a constant string on the heap, so we can cache these
389
+ if (!Runtime.asmConstCache) Runtime.asmConstCache = {};
390
+ var func = Runtime.asmConstCache[code];
391
+ if (func) return func;
392
+ var args = [];
393
+ for (var i = 0; i < numArgs; i++) {
394
+ args.push(String.fromCharCode(36) + i); // $0, $1 etc
395
+ }
396
+ return Runtime.asmConstCache[code] = eval('(function(' + args.join(',') + '){ ' + Pointer_stringify(code) + ' })'); // new Function does not allow upvars in node
397
+ },
398
+
375
399
  warnOnce: function(text) {
376
400
  if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};
377
401
  if (!Runtime.warnOnce.shown[text]) {
@@ -385,7 +409,7 @@ var Runtime = {
385
409
  getFuncWrapper: function(func, sig) {
386
410
  assert(sig);
387
411
  if (!Runtime.funcWrappers[func]) {
388
- Runtime.funcWrappers[func] = function() {
412
+ Runtime.funcWrappers[func] = function dynCall_wrapper() {
389
413
  return Runtime.dynCall(sig, func, arguments);
390
414
  };
391
415
  }
@@ -443,7 +467,7 @@ var Runtime = {
443
467
  buffer.length = 0;
444
468
  return ret;
445
469
  }
446
- this.processJSString = function(string) {
470
+ this.processJSString = function processJSString(string) {
447
471
  string = unescape(encodeURIComponent(string));
448
472
  var ret = [];
449
473
  for (var i = 0; i < string.length; i++) {
@@ -23,7 +23,8 @@ var QUANTUM_SIZE = 4; // This is the size of an individual field in a structure.
23
23
  // Changing this from the default of 4 is deprecated.
24
24
 
25
25
  var TARGET_X86 = 0; // For i386-pc-linux-gnu
26
- var TARGET_LE32 = 1; // For le32-unknown-nacl
26
+ var TARGET_LE32 = 1; // For le32-unknown-nacl. 1 is normal, 2 is for the fastcomp llvm
27
+ // backend using pnacl abi simplification
27
28
 
28
29
  var CORRECT_SIGNS = 1; // Whether we make sure to convert unsigned values to signed values.
29
30
  // Decreases performance with additional runtime checks. Might not be
@@ -115,7 +116,13 @@ var PRECISE_I64_MATH = 1; // If enabled, i64 addition etc. is emulated - which i
115
116
  var PRECISE_I32_MUL = 1; // If enabled, i32 multiplication is done with full precision, which means it is
116
117
  // correct even if the value exceeds the JS double-integer limit of ~52 bits (otherwise,
117
118
  // rounding will occur above that range).
118
- var TO_FLOAT32 = 0; // Use Math.toFloat32
119
+ var PRECISE_F32 = 0; // 0: Use JS numbers for floating-point values. These are 64-bit and do not model C++
120
+ // floats exactly, which are 32-bit.
121
+ // 1: Model C++ floats precisely, using Math.fround, polyfilling when necessary. This
122
+ // can be slow if the polyfill is used on heavy float32 computation.
123
+ // 2: Model C++ floats precisely using Math.fround if available in the JS engine, otherwise
124
+ // use an empty polyfill. This will have less of a speed penalty than using the full
125
+ // polyfill in cases where engine support is not present.
119
126
 
120
127
  var CLOSURE_ANNOTATIONS = 0; // If set, the generated code will be annotated for the closure
121
128
  // compiler. This potentially lets closure optimize the code better.
@@ -217,6 +224,10 @@ var GL_UNSAFE_OPTS = 1; // Enables some potentially-unsafe optimizations in GL e
217
224
  var FULL_ES2 = 0; // Forces support for all GLES2 features, not just the WebGL-friendly subset.
218
225
  var LEGACY_GL_EMULATION = 0; // Includes code to emulate various desktop GL features. Incomplete but useful
219
226
  // in some cases, see https://github.com/kripken/emscripten/wiki/OpenGL-support
227
+ var GL_FFP_ONLY = 0; // If you specified LEGACY_GL_EMULATION = 1 and only use fixed function pipeline in your code,
228
+ // you can also set this to 1 to signal the GL emulation layer that it can perform extra
229
+ // optimizations by knowing that the user code does not use shaders at all. If
230
+ // LEGACY_GL_EMULATION = 0, this setting has no effect.
220
231
 
221
232
  var STB_IMAGE = 0; // Enables building of stb-image, a tiny public-domain library for decoding images, allowing
222
233
  // decoding of images without using the browser's built-in decoders. The benefit is that this
@@ -384,13 +395,16 @@ var FAKE_X86_FP80 = 1; // Replaces x86_fp80 with double. This loses precision. I
384
395
 
385
396
  var GC_SUPPORT = 1; // Enables GC, see gc.h (this does not add overhead, so it is on by default)
386
397
 
387
- var WARN_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will warn on any undefined symbols that
388
- // are not resolved by the library_*.js files. We by default
389
- // do not warn because (1) it is normal in large projects to
398
+ var WARN_ON_UNDEFINED_SYMBOLS = 1; // If set to 1, we will warn on any undefined symbols that
399
+ // are not resolved by the library_*.js files. Note that
400
+ // it is common in large projects to
390
401
  // not implement everything, when you know what is not
391
402
  // going to actually be called (and don't want to mess with
392
- // the existing buildsystem), and (2) functions might be
393
- // implemented later on, say in --pre-js
403
+ // the existing buildsystem), and functions might be
404
+ // implemented later on, say in --pre-js, so you may
405
+ // want to build with -s WARN_ON_UNDEFINED_SYMBOLS=0 to
406
+ // disable the warnings if they annoy you.
407
+ // See also ERROR_ON_UNDEFINED_SYMBOLS
394
408
 
395
409
  var ERROR_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will give a compile-time error on any
396
410
  // undefined symbols (see WARN_ON_UNDEFINED_SYMBOLS).
@@ -410,7 +424,8 @@ var HEADLESS = 0; // If 1, will include shim code that tries to 'fake' a browser
410
424
  var BENCHMARK = 0; // If 1, will just time how long main() takes to execute, and not
411
425
  // print out anything at all whatsoever. This is useful for benchmarking.
412
426
 
413
- var ASM_JS = 0; // If 1, generate code in asm.js format.
427
+ var ASM_JS = 0; // If 1, generate code in asm.js format. If 2, emits the same code except
428
+ // for omitting 'use asm'
414
429
 
415
430
  var PGO = 0; // Enables profile-guided optimization in the form of runtime checks for
416
431
  // which functions are actually called. Emits a list during shutdown that you
@@ -421,6 +436,8 @@ var DEAD_FUNCTIONS = []; // Functions on this list are not converted to JS, and
421
436
  // reducing code size.
422
437
  // If a dead function is actually called, you will get a runtime
423
438
  // error.
439
+ // This can affect both functions in compiled code, and system
440
+ // library functions (e.g., you can use this to kill printf).
424
441
  // TODO: options to lazily load such functions
425
442
 
426
443
  var EXPLICIT_ZEXT = 0; // If 1, generate an explicit conversion of zext i1 to i32, using ?:
@@ -50,7 +50,7 @@
50
50
  //text = text.replace(/>/g, "&gt;");
51
51
  //text = text.replace('\n', '<br>', 'g');
52
52
  element.value += text + "\n";
53
- element.scrollTop = 99999; // focus on bottom
53
+ element.scrollTop = element.scrollHeight; // focus on bottom
54
54
  };
55
55
  })(),
56
56
  printErr: function(text) {
@@ -63,8 +63,11 @@
63
63
  },
64
64
  canvas: document.getElementById('canvas'),
65
65
  setStatus: function(text) {
66
- if (Module.setStatus.interval) clearInterval(Module.setStatus.interval);
66
+ if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
67
+ if (text === Module.setStatus.text) return;
67
68
  var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
69
+ var now = Date.now();
70
+ if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
68
71
  var statusElement = document.getElementById('status');
69
72
  var progressElement = document.getElementById('progress');
70
73
  if (m) {
@@ -87,6 +90,6 @@
87
90
  };
88
91
  Module.setStatus('Downloading...');
89
92
  </script>
90
- <script async type='text/javascript'>{{{ SCRIPT_CODE }}}</script>
93
+ {{{ SCRIPT }}}
91
94
  </body>
92
95
  </html>
@@ -38,17 +38,17 @@ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIR
38
38
  if (ENVIRONMENT_IS_NODE) {
39
39
  // Expose functionality in the same simple way that the shells work
40
40
  // Note that we pollute the global namespace here, otherwise we break in node
41
- Module['print'] = function(x) {
41
+ Module['print'] = function print(x) {
42
42
  process['stdout'].write(x + '\n');
43
43
  };
44
- Module['printErr'] = function(x) {
44
+ Module['printErr'] = function printErr(x) {
45
45
  process['stderr'].write(x + '\n');
46
46
  };
47
47
 
48
48
  var nodeFS = require('fs');
49
49
  var nodePath = require('path');
50
50
 
51
- Module['read'] = function(filename, binary) {
51
+ Module['read'] = function read(filename, binary) {
52
52
  filename = nodePath['normalize'](filename);
53
53
  var ret = nodeFS['readFileSync'](filename);
54
54
  // The path is absolute if the normalized version is the same as the resolved.
@@ -60,9 +60,9 @@ if (ENVIRONMENT_IS_NODE) {
60
60
  return ret;
61
61
  };
62
62
 
63
- Module['readBinary'] = function(filename) { return Module['read'](filename, true) };
63
+ Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) };
64
64
 
65
- Module['load'] = function(f) {
65
+ Module['load'] = function load(f) {
66
66
  globalEval(read(f));
67
67
  };
68
68
 
@@ -77,10 +77,10 @@ else if (ENVIRONMENT_IS_SHELL) {
77
77
  if (typeof read != 'undefined') {
78
78
  Module['read'] = read;
79
79
  } else {
80
- Module['read'] = function() { throw 'no read() available (jsc?)' };
80
+ Module['read'] = function read() { throw 'no read() available (jsc?)' };
81
81
  }
82
82
 
83
- Module['readBinary'] = function(f) {
83
+ Module['readBinary'] = function readBinary(f) {
84
84
  return read(f, 'binary');
85
85
  };
86
86
 
@@ -91,9 +91,11 @@ else if (ENVIRONMENT_IS_SHELL) {
91
91
  }
92
92
 
93
93
  this['{{{ EXPORT_NAME }}}'] = Module;
94
+
95
+ eval("if (typeof gc === 'function' && gc.toString().indexOf('[native code]') > 0) var gc = undefined"); // wipe out the SpiderMonkey shell 'gc' function, which can confuse closure (uses it as a minified name, and it is then initted to a non-falsey value unexpectedly)
94
96
  }
95
97
  else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
96
- Module['read'] = function(url) {
98
+ Module['read'] = function read(url) {
97
99
  var xhr = new XMLHttpRequest();
98
100
  xhr.open('GET', url, false);
99
101
  xhr.send(null);
@@ -105,10 +107,10 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
105
107
  }
106
108
 
107
109
  if (typeof console !== 'undefined') {
108
- Module['print'] = function(x) {
110
+ Module['print'] = function print(x) {
109
111
  console.log(x);
110
112
  };
111
- Module['printErr'] = function(x) {
113
+ Module['printErr'] = function printErr(x) {
112
114
  console.log(x);
113
115
  };
114
116
  } else {
@@ -136,7 +138,7 @@ function globalEval(x) {
136
138
  eval.call(null, x);
137
139
  }
138
140
  if (!Module['load'] == 'undefined' && Module['read']) {
139
- Module['load'] = function(f) {
141
+ Module['load'] = function load(f) {
140
142
  globalEval(Module['read'](f));
141
143
  };
142
144
  }