porffor 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 (655) hide show
  1. package/CNAME +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +275 -0
  4. package/compiler/builtins/base64.js +92 -0
  5. package/compiler/builtins.js +770 -0
  6. package/compiler/codeGen.js +2027 -0
  7. package/compiler/decompile.js +102 -0
  8. package/compiler/embedding.js +19 -0
  9. package/compiler/encoding.js +217 -0
  10. package/compiler/expression.js +70 -0
  11. package/compiler/index.js +67 -0
  12. package/compiler/opt.js +436 -0
  13. package/compiler/parse.js +8 -0
  14. package/compiler/prototype.js +272 -0
  15. package/compiler/sections.js +154 -0
  16. package/compiler/wasmSpec.js +200 -0
  17. package/compiler/wrap.js +119 -0
  18. package/index.html +1264 -0
  19. package/logo.png +0 -0
  20. package/package.json +23 -0
  21. package/porf.cmd +2 -0
  22. package/runner/compare.js +35 -0
  23. package/runner/index.js +32 -0
  24. package/runner/info.js +54 -0
  25. package/runner/profile.js +47 -0
  26. package/runner/repl.js +99 -0
  27. package/runner/sizes.js +38 -0
  28. package/runner/transform.js +36 -0
  29. package/sw.js +26 -0
  30. package/test/array_1.js +8 -0
  31. package/test/array_push.js +8 -0
  32. package/test/assignop_1.js +15 -0
  33. package/test/bitwise_1.js +6 -0
  34. package/test/bool_1.js +3 -0
  35. package/test/boolean.js +6 -0
  36. package/test/break_1.js +6 -0
  37. package/test/break_2.js +12 -0
  38. package/test/conditional_1.js +3 -0
  39. package/test/conditional_2.js +4 -0
  40. package/test/console_1.js +2 -0
  41. package/test/continue_1.js +6 -0
  42. package/test/continue_2.js +10 -0
  43. package/test/empty.js +1 -0
  44. package/test/ending_exp_1.js +2 -0
  45. package/test/ending_exp_2.js +6 -0
  46. package/test/eq_1.js +4 -0
  47. package/test/eq_2.js +4 -0
  48. package/test/eq_3.js +5 -0
  49. package/test/export_1.js +9 -0
  50. package/test/factorial.js +3 -0
  51. package/test/fibonacci.js +16 -0
  52. package/test/float_div0.js +2 -0
  53. package/test/float_frac.js +2 -0
  54. package/test/float_isfinite.js +29 -0
  55. package/test/float_isinteger.js +13 -0
  56. package/test/float_isnan.js +20 -0
  57. package/test/float_issafeinteger.js +11 -0
  58. package/test/float_large.js +2 -0
  59. package/test/float_math_funcs.js +24 -0
  60. package/test/float_math_random.js +6 -0
  61. package/test/float_nan.js +3 -0
  62. package/test/float_number_values.js +12 -0
  63. package/test/for_1.js +4 -0
  64. package/test/for_2.js +4 -0
  65. package/test/func_1.js +16 -0
  66. package/test/func_2.js +6 -0
  67. package/test/func_3.js +10 -0
  68. package/test/global_1.js +8 -0
  69. package/test/global_2.js +10 -0
  70. package/test/if_1.js +6 -0
  71. package/test/if_2.js +9 -0
  72. package/test/if_3.js +7 -0
  73. package/test/iife_1.js +8 -0
  74. package/test/iife_2.js +8 -0
  75. package/test/index.js +93 -0
  76. package/test/int_number_values.js +6 -0
  77. package/test/logic_1.js +7 -0
  78. package/test/logic_2.js +7 -0
  79. package/test/math_1.js +6 -0
  80. package/test/math_2.js +12 -0
  81. package/test/math_3.js +6 -0
  82. package/test/number_func.js +4 -0
  83. package/test/return_1.js +8 -0
  84. package/test/return_2.js +11 -0
  85. package/test/tailcall_1.js +10 -0
  86. package/test/throw_1.js +2 -0
  87. package/test/throw_2.js +4 -0
  88. package/test/throw_3.js +2 -0
  89. package/test/throw_4.js +3 -0
  90. package/test/try_1.js +7 -0
  91. package/test/unary_1.js +4 -0
  92. package/test/unary_2.js +5 -0
  93. package/test/unary_3.js +6 -0
  94. package/test/unary_4.js +12 -0
  95. package/test/unary_5.js +8 -0
  96. package/test/undefined_1.js +8 -0
  97. package/test/undefined_2.js +10 -0
  98. package/test/updateexp_1.js +9 -0
  99. package/test/vars_1.js +5 -0
  100. package/test/vars_2.js +9 -0
  101. package/test/while_1.js +6 -0
  102. package/test262/compare.js +30 -0
  103. package/test262/index.js +314 -0
  104. package/test262/node_modules/.bin/esparse +12 -0
  105. package/test262/node_modules/.bin/esparse.cmd +17 -0
  106. package/test262/node_modules/.bin/esparse.ps1 +28 -0
  107. package/test262/node_modules/.bin/esvalidate +12 -0
  108. package/test262/node_modules/.bin/esvalidate.cmd +17 -0
  109. package/test262/node_modules/.bin/esvalidate.ps1 +28 -0
  110. package/test262/node_modules/.bin/js-yaml +12 -0
  111. package/test262/node_modules/.bin/js-yaml.cmd +17 -0
  112. package/test262/node_modules/.bin/js-yaml.ps1 +28 -0
  113. package/test262/node_modules/.package-lock.json +0 -0
  114. package/test262/node_modules/@nodelib/fs.scandir/LICENSE +21 -0
  115. package/test262/node_modules/@nodelib/fs.scandir/README.md +171 -0
  116. package/test262/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  117. package/test262/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +19 -0
  118. package/test262/node_modules/@nodelib/fs.scandir/out/constants.d.ts +4 -0
  119. package/test262/node_modules/@nodelib/fs.scandir/out/constants.js +17 -0
  120. package/test262/node_modules/@nodelib/fs.scandir/out/index.d.ts +12 -0
  121. package/test262/node_modules/@nodelib/fs.scandir/out/index.js +26 -0
  122. package/test262/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  123. package/test262/node_modules/@nodelib/fs.scandir/out/providers/async.js +104 -0
  124. package/test262/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +1 -0
  125. package/test262/node_modules/@nodelib/fs.scandir/out/providers/common.js +13 -0
  126. package/test262/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +5 -0
  127. package/test262/node_modules/@nodelib/fs.scandir/out/providers/sync.js +54 -0
  128. package/test262/node_modules/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  129. package/test262/node_modules/@nodelib/fs.scandir/out/settings.js +24 -0
  130. package/test262/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  131. package/test262/node_modules/@nodelib/fs.scandir/out/types/index.js +2 -0
  132. package/test262/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +2 -0
  133. package/test262/node_modules/@nodelib/fs.scandir/out/utils/fs.js +19 -0
  134. package/test262/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +2 -0
  135. package/test262/node_modules/@nodelib/fs.scandir/out/utils/index.js +5 -0
  136. package/test262/node_modules/@nodelib/fs.scandir/package.json +44 -0
  137. package/test262/node_modules/@nodelib/fs.stat/LICENSE +21 -0
  138. package/test262/node_modules/@nodelib/fs.stat/README.md +126 -0
  139. package/test262/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  140. package/test262/node_modules/@nodelib/fs.stat/out/adapters/fs.js +17 -0
  141. package/test262/node_modules/@nodelib/fs.stat/out/index.d.ts +12 -0
  142. package/test262/node_modules/@nodelib/fs.stat/out/index.js +26 -0
  143. package/test262/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  144. package/test262/node_modules/@nodelib/fs.stat/out/providers/async.js +36 -0
  145. package/test262/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +3 -0
  146. package/test262/node_modules/@nodelib/fs.stat/out/providers/sync.js +23 -0
  147. package/test262/node_modules/@nodelib/fs.stat/out/settings.d.ts +16 -0
  148. package/test262/node_modules/@nodelib/fs.stat/out/settings.js +16 -0
  149. package/test262/node_modules/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  150. package/test262/node_modules/@nodelib/fs.stat/out/types/index.js +2 -0
  151. package/test262/node_modules/@nodelib/fs.stat/package.json +37 -0
  152. package/test262/node_modules/@nodelib/fs.walk/LICENSE +21 -0
  153. package/test262/node_modules/@nodelib/fs.walk/README.md +215 -0
  154. package/test262/node_modules/@nodelib/fs.walk/out/index.d.ts +14 -0
  155. package/test262/node_modules/@nodelib/fs.walk/out/index.js +34 -0
  156. package/test262/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  157. package/test262/node_modules/@nodelib/fs.walk/out/providers/async.js +30 -0
  158. package/test262/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +4 -0
  159. package/test262/node_modules/@nodelib/fs.walk/out/providers/index.js +9 -0
  160. package/test262/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +12 -0
  161. package/test262/node_modules/@nodelib/fs.walk/out/providers/stream.js +34 -0
  162. package/test262/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +10 -0
  163. package/test262/node_modules/@nodelib/fs.walk/out/providers/sync.js +14 -0
  164. package/test262/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  165. package/test262/node_modules/@nodelib/fs.walk/out/readers/async.js +97 -0
  166. package/test262/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +7 -0
  167. package/test262/node_modules/@nodelib/fs.walk/out/readers/common.js +31 -0
  168. package/test262/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  169. package/test262/node_modules/@nodelib/fs.walk/out/readers/reader.js +11 -0
  170. package/test262/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +15 -0
  171. package/test262/node_modules/@nodelib/fs.walk/out/readers/sync.js +59 -0
  172. package/test262/node_modules/@nodelib/fs.walk/out/settings.d.ts +30 -0
  173. package/test262/node_modules/@nodelib/fs.walk/out/settings.js +26 -0
  174. package/test262/node_modules/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  175. package/test262/node_modules/@nodelib/fs.walk/out/types/index.js +2 -0
  176. package/test262/node_modules/@nodelib/fs.walk/package.json +44 -0
  177. package/test262/node_modules/argparse/CHANGELOG.md +185 -0
  178. package/test262/node_modules/argparse/LICENSE +21 -0
  179. package/test262/node_modules/argparse/README.md +257 -0
  180. package/test262/node_modules/argparse/index.js +3 -0
  181. package/test262/node_modules/argparse/lib/action/append/constant.js +47 -0
  182. package/test262/node_modules/argparse/lib/action/append.js +53 -0
  183. package/test262/node_modules/argparse/lib/action/count.js +40 -0
  184. package/test262/node_modules/argparse/lib/action/help.js +47 -0
  185. package/test262/node_modules/argparse/lib/action/store/constant.js +43 -0
  186. package/test262/node_modules/argparse/lib/action/store/false.js +27 -0
  187. package/test262/node_modules/argparse/lib/action/store/true.js +26 -0
  188. package/test262/node_modules/argparse/lib/action/store.js +50 -0
  189. package/test262/node_modules/argparse/lib/action/subparsers.js +149 -0
  190. package/test262/node_modules/argparse/lib/action/version.js +47 -0
  191. package/test262/node_modules/argparse/lib/action.js +146 -0
  192. package/test262/node_modules/argparse/lib/action_container.js +482 -0
  193. package/test262/node_modules/argparse/lib/argparse.js +14 -0
  194. package/test262/node_modules/argparse/lib/argument/error.js +50 -0
  195. package/test262/node_modules/argparse/lib/argument/exclusive.js +54 -0
  196. package/test262/node_modules/argparse/lib/argument/group.js +75 -0
  197. package/test262/node_modules/argparse/lib/argument_parser.js +1161 -0
  198. package/test262/node_modules/argparse/lib/const.js +21 -0
  199. package/test262/node_modules/argparse/lib/help/added_formatters.js +87 -0
  200. package/test262/node_modules/argparse/lib/help/formatter.js +795 -0
  201. package/test262/node_modules/argparse/lib/namespace.js +76 -0
  202. package/test262/node_modules/argparse/lib/utils.js +57 -0
  203. package/test262/node_modules/argparse/package.json +34 -0
  204. package/test262/node_modules/braces/CHANGELOG.md +184 -0
  205. package/test262/node_modules/braces/LICENSE +21 -0
  206. package/test262/node_modules/braces/README.md +593 -0
  207. package/test262/node_modules/braces/index.js +170 -0
  208. package/test262/node_modules/braces/lib/compile.js +57 -0
  209. package/test262/node_modules/braces/lib/constants.js +57 -0
  210. package/test262/node_modules/braces/lib/expand.js +113 -0
  211. package/test262/node_modules/braces/lib/parse.js +333 -0
  212. package/test262/node_modules/braces/lib/stringify.js +32 -0
  213. package/test262/node_modules/braces/lib/utils.js +112 -0
  214. package/test262/node_modules/braces/package.json +77 -0
  215. package/test262/node_modules/esprima/ChangeLog +235 -0
  216. package/test262/node_modules/esprima/LICENSE.BSD +21 -0
  217. package/test262/node_modules/esprima/README.md +46 -0
  218. package/test262/node_modules/esprima/bin/esparse.js +139 -0
  219. package/test262/node_modules/esprima/bin/esvalidate.js +236 -0
  220. package/test262/node_modules/esprima/dist/esprima.js +6709 -0
  221. package/test262/node_modules/esprima/package.json +112 -0
  222. package/test262/node_modules/fast-glob/LICENSE +21 -0
  223. package/test262/node_modules/fast-glob/README.md +859 -0
  224. package/test262/node_modules/fast-glob/out/index.d.ts +40 -0
  225. package/test262/node_modules/fast-glob/out/index.js +102 -0
  226. package/test262/node_modules/fast-glob/out/managers/tasks.d.ts +22 -0
  227. package/test262/node_modules/fast-glob/out/managers/tasks.js +110 -0
  228. package/test262/node_modules/fast-glob/out/providers/async.d.ts +9 -0
  229. package/test262/node_modules/fast-glob/out/providers/async.js +23 -0
  230. package/test262/node_modules/fast-glob/out/providers/filters/deep.d.ts +16 -0
  231. package/test262/node_modules/fast-glob/out/providers/filters/deep.js +62 -0
  232. package/test262/node_modules/fast-glob/out/providers/filters/entry.d.ts +16 -0
  233. package/test262/node_modules/fast-glob/out/providers/filters/entry.js +63 -0
  234. package/test262/node_modules/fast-glob/out/providers/filters/error.d.ts +8 -0
  235. package/test262/node_modules/fast-glob/out/providers/filters/error.js +15 -0
  236. package/test262/node_modules/fast-glob/out/providers/matchers/matcher.d.ts +33 -0
  237. package/test262/node_modules/fast-glob/out/providers/matchers/matcher.js +45 -0
  238. package/test262/node_modules/fast-glob/out/providers/matchers/partial.d.ts +4 -0
  239. package/test262/node_modules/fast-glob/out/providers/matchers/partial.js +38 -0
  240. package/test262/node_modules/fast-glob/out/providers/provider.d.ts +19 -0
  241. package/test262/node_modules/fast-glob/out/providers/provider.js +48 -0
  242. package/test262/node_modules/fast-glob/out/providers/stream.d.ts +11 -0
  243. package/test262/node_modules/fast-glob/out/providers/stream.js +31 -0
  244. package/test262/node_modules/fast-glob/out/providers/sync.d.ts +9 -0
  245. package/test262/node_modules/fast-glob/out/providers/sync.js +23 -0
  246. package/test262/node_modules/fast-glob/out/providers/transformers/entry.d.ts +8 -0
  247. package/test262/node_modules/fast-glob/out/providers/transformers/entry.js +26 -0
  248. package/test262/node_modules/fast-glob/out/readers/async.d.ts +10 -0
  249. package/test262/node_modules/fast-glob/out/readers/async.js +35 -0
  250. package/test262/node_modules/fast-glob/out/readers/reader.d.ts +15 -0
  251. package/test262/node_modules/fast-glob/out/readers/reader.js +33 -0
  252. package/test262/node_modules/fast-glob/out/readers/stream.d.ts +14 -0
  253. package/test262/node_modules/fast-glob/out/readers/stream.js +55 -0
  254. package/test262/node_modules/fast-glob/out/readers/sync.d.ts +12 -0
  255. package/test262/node_modules/fast-glob/out/readers/sync.js +43 -0
  256. package/test262/node_modules/fast-glob/out/settings.d.ts +164 -0
  257. package/test262/node_modules/fast-glob/out/settings.js +57 -0
  258. package/test262/node_modules/fast-glob/out/types/index.d.ts +31 -0
  259. package/test262/node_modules/fast-glob/out/types/index.js +2 -0
  260. package/test262/node_modules/fast-glob/out/utils/array.d.ts +2 -0
  261. package/test262/node_modules/fast-glob/out/utils/array.js +22 -0
  262. package/test262/node_modules/fast-glob/out/utils/errno.d.ts +2 -0
  263. package/test262/node_modules/fast-glob/out/utils/errno.js +7 -0
  264. package/test262/node_modules/fast-glob/out/utils/fs.d.ts +4 -0
  265. package/test262/node_modules/fast-glob/out/utils/fs.js +19 -0
  266. package/test262/node_modules/fast-glob/out/utils/index.d.ts +8 -0
  267. package/test262/node_modules/fast-glob/out/utils/index.js +17 -0
  268. package/test262/node_modules/fast-glob/out/utils/path.d.ts +13 -0
  269. package/test262/node_modules/fast-glob/out/utils/path.js +68 -0
  270. package/test262/node_modules/fast-glob/out/utils/pattern.d.ts +47 -0
  271. package/test262/node_modules/fast-glob/out/utils/pattern.js +188 -0
  272. package/test262/node_modules/fast-glob/out/utils/stream.d.ts +4 -0
  273. package/test262/node_modules/fast-glob/out/utils/stream.js +17 -0
  274. package/test262/node_modules/fast-glob/out/utils/string.d.ts +2 -0
  275. package/test262/node_modules/fast-glob/out/utils/string.js +11 -0
  276. package/test262/node_modules/fast-glob/package.json +81 -0
  277. package/test262/node_modules/fastq/.github/dependabot.yml +11 -0
  278. package/test262/node_modules/fastq/.github/workflows/ci.yml +50 -0
  279. package/test262/node_modules/fastq/LICENSE +13 -0
  280. package/test262/node_modules/fastq/README.md +309 -0
  281. package/test262/node_modules/fastq/bench.js +66 -0
  282. package/test262/node_modules/fastq/example.js +14 -0
  283. package/test262/node_modules/fastq/example.mjs +11 -0
  284. package/test262/node_modules/fastq/index.d.ts +37 -0
  285. package/test262/node_modules/fastq/package.json +52 -0
  286. package/test262/node_modules/fastq/queue.js +289 -0
  287. package/test262/node_modules/fastq/test/example.ts +81 -0
  288. package/test262/node_modules/fastq/test/promise.js +248 -0
  289. package/test262/node_modules/fastq/test/test.js +566 -0
  290. package/test262/node_modules/fastq/test/tsconfig.json +11 -0
  291. package/test262/node_modules/fill-range/LICENSE +21 -0
  292. package/test262/node_modules/fill-range/README.md +237 -0
  293. package/test262/node_modules/fill-range/index.js +249 -0
  294. package/test262/node_modules/fill-range/package.json +69 -0
  295. package/test262/node_modules/glob-parent/CHANGELOG.md +110 -0
  296. package/test262/node_modules/glob-parent/LICENSE +15 -0
  297. package/test262/node_modules/glob-parent/README.md +137 -0
  298. package/test262/node_modules/glob-parent/index.js +42 -0
  299. package/test262/node_modules/glob-parent/package.json +48 -0
  300. package/test262/node_modules/graceful-fs/LICENSE +15 -0
  301. package/test262/node_modules/graceful-fs/README.md +143 -0
  302. package/test262/node_modules/graceful-fs/clone.js +23 -0
  303. package/test262/node_modules/graceful-fs/graceful-fs.js +448 -0
  304. package/test262/node_modules/graceful-fs/legacy-streams.js +118 -0
  305. package/test262/node_modules/graceful-fs/package.json +53 -0
  306. package/test262/node_modules/graceful-fs/polyfills.js +355 -0
  307. package/test262/node_modules/is-extglob/LICENSE +21 -0
  308. package/test262/node_modules/is-extglob/README.md +107 -0
  309. package/test262/node_modules/is-extglob/index.js +20 -0
  310. package/test262/node_modules/is-extglob/package.json +69 -0
  311. package/test262/node_modules/is-glob/LICENSE +21 -0
  312. package/test262/node_modules/is-glob/README.md +206 -0
  313. package/test262/node_modules/is-glob/index.js +150 -0
  314. package/test262/node_modules/is-glob/package.json +81 -0
  315. package/test262/node_modules/is-number/LICENSE +21 -0
  316. package/test262/node_modules/is-number/README.md +187 -0
  317. package/test262/node_modules/is-number/index.js +18 -0
  318. package/test262/node_modules/is-number/package.json +82 -0
  319. package/test262/node_modules/js-yaml/CHANGELOG.md +557 -0
  320. package/test262/node_modules/js-yaml/LICENSE +21 -0
  321. package/test262/node_modules/js-yaml/README.md +299 -0
  322. package/test262/node_modules/js-yaml/bin/js-yaml.js +132 -0
  323. package/test262/node_modules/js-yaml/dist/js-yaml.js +3989 -0
  324. package/test262/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
  325. package/test262/node_modules/js-yaml/index.js +7 -0
  326. package/test262/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
  327. package/test262/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
  328. package/test262/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
  329. package/test262/node_modules/js-yaml/lib/js-yaml/loader.js +1644 -0
  330. package/test262/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
  331. package/test262/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
  332. package/test262/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
  333. package/test262/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
  334. package/test262/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
  335. package/test262/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
  336. package/test262/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
  337. package/test262/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
  338. package/test262/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
  339. package/test262/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
  340. package/test262/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
  341. package/test262/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
  342. package/test262/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
  343. package/test262/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
  344. package/test262/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
  345. package/test262/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
  346. package/test262/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
  347. package/test262/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
  348. package/test262/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
  349. package/test262/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
  350. package/test262/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
  351. package/test262/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
  352. package/test262/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
  353. package/test262/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
  354. package/test262/node_modules/js-yaml/lib/js-yaml.js +39 -0
  355. package/test262/node_modules/js-yaml/package.json +49 -0
  356. package/test262/node_modules/klaw/CHANGELOG.md +62 -0
  357. package/test262/node_modules/klaw/LICENSE +15 -0
  358. package/test262/node_modules/klaw/README.md +252 -0
  359. package/test262/node_modules/klaw/package.json +40 -0
  360. package/test262/node_modules/klaw/src/index.js +56 -0
  361. package/test262/node_modules/merge2/LICENSE +21 -0
  362. package/test262/node_modules/merge2/README.md +144 -0
  363. package/test262/node_modules/merge2/index.js +144 -0
  364. package/test262/node_modules/merge2/package.json +43 -0
  365. package/test262/node_modules/micromatch/LICENSE +21 -0
  366. package/test262/node_modules/micromatch/README.md +1011 -0
  367. package/test262/node_modules/micromatch/index.js +467 -0
  368. package/test262/node_modules/micromatch/package.json +119 -0
  369. package/test262/node_modules/picomatch/CHANGELOG.md +136 -0
  370. package/test262/node_modules/picomatch/LICENSE +21 -0
  371. package/test262/node_modules/picomatch/README.md +708 -0
  372. package/test262/node_modules/picomatch/index.js +3 -0
  373. package/test262/node_modules/picomatch/lib/constants.js +179 -0
  374. package/test262/node_modules/picomatch/lib/parse.js +1091 -0
  375. package/test262/node_modules/picomatch/lib/picomatch.js +342 -0
  376. package/test262/node_modules/picomatch/lib/scan.js +391 -0
  377. package/test262/node_modules/picomatch/lib/utils.js +64 -0
  378. package/test262/node_modules/picomatch/package.json +81 -0
  379. package/test262/node_modules/queue-microtask/LICENSE +20 -0
  380. package/test262/node_modules/queue-microtask/README.md +90 -0
  381. package/test262/node_modules/queue-microtask/index.d.ts +2 -0
  382. package/test262/node_modules/queue-microtask/index.js +9 -0
  383. package/test262/node_modules/queue-microtask/package.json +55 -0
  384. package/test262/node_modules/reusify/.coveralls.yml +1 -0
  385. package/test262/node_modules/reusify/.travis.yml +28 -0
  386. package/test262/node_modules/reusify/LICENSE +22 -0
  387. package/test262/node_modules/reusify/README.md +145 -0
  388. package/test262/node_modules/reusify/benchmarks/createNoCodeFunction.js +30 -0
  389. package/test262/node_modules/reusify/benchmarks/fib.js +13 -0
  390. package/test262/node_modules/reusify/benchmarks/reuseNoCodeFunction.js +38 -0
  391. package/test262/node_modules/reusify/package.json +45 -0
  392. package/test262/node_modules/reusify/reusify.js +33 -0
  393. package/test262/node_modules/reusify/test.js +66 -0
  394. package/test262/node_modules/run-parallel/LICENSE +20 -0
  395. package/test262/node_modules/run-parallel/README.md +85 -0
  396. package/test262/node_modules/run-parallel/index.js +51 -0
  397. package/test262/node_modules/run-parallel/package.json +58 -0
  398. package/test262/node_modules/sprintf-js/LICENSE +24 -0
  399. package/test262/node_modules/sprintf-js/README.md +88 -0
  400. package/test262/node_modules/sprintf-js/bower.json +14 -0
  401. package/test262/node_modules/sprintf-js/demo/angular.html +20 -0
  402. package/test262/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
  403. package/test262/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
  404. package/test262/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
  405. package/test262/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
  406. package/test262/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
  407. package/test262/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
  408. package/test262/node_modules/sprintf-js/gruntfile.js +36 -0
  409. package/test262/node_modules/sprintf-js/package.json +22 -0
  410. package/test262/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
  411. package/test262/node_modules/sprintf-js/src/sprintf.js +208 -0
  412. package/test262/node_modules/sprintf-js/test/test.js +82 -0
  413. package/test262/node_modules/test262-stream/.jshintignore +2 -0
  414. package/test262/node_modules/test262-stream/.jshintrc +6 -0
  415. package/test262/node_modules/test262-stream/.travis.yml +5 -0
  416. package/test262/node_modules/test262-stream/CONTRIBUTING.md +37 -0
  417. package/test262/node_modules/test262-stream/LICENSE-MICROSOFT.txt +27 -0
  418. package/test262/node_modules/test262-stream/LICENSE.txt +27 -0
  419. package/test262/node_modules/test262-stream/README.md +71 -0
  420. package/test262/node_modules/test262-stream/lib/builder.js +46 -0
  421. package/test262/node_modules/test262-stream/lib/compile.js +24 -0
  422. package/test262/node_modules/test262-stream/lib/create-scenarios.js +29 -0
  423. package/test262/node_modules/test262-stream/lib/index.js +187 -0
  424. package/test262/node_modules/test262-stream/lib/test-file.js +150 -0
  425. package/test262/node_modules/test262-stream/package.json +26 -0
  426. package/test262/node_modules/test262-stream/test/collateral/invalid-missing-harness/fake-test262/test/a-test-file.js +16 -0
  427. package/test262/node_modules/test262-stream/test/collateral/invalid-version-other-accepted/fake-test262/harness/assert.js +17 -0
  428. package/test262/node_modules/test262-stream/test/collateral/invalid-version-other-accepted/fake-test262/harness/doneprintHandle.js +6 -0
  429. package/test262/node_modules/test262-stream/test/collateral/invalid-version-other-accepted/fake-test262/harness/sta.js +12 -0
  430. package/test262/node_modules/test262-stream/test/collateral/invalid-version-other-accepted/fake-test262/package.json +3 -0
  431. package/test262/node_modules/test262-stream/test/collateral/invalid-version-other-accepted/fake-test262/test/strict.js +9 -0
  432. package/test262/node_modules/test262-stream/test/collateral/invalid-version-unsupported/fake-test262/harness/assert.js +17 -0
  433. package/test262/node_modules/test262-stream/test/collateral/invalid-version-unsupported/fake-test262/harness/doneprintHandle.js +6 -0
  434. package/test262/node_modules/test262-stream/test/collateral/invalid-version-unsupported/fake-test262/harness/sta.js +12 -0
  435. package/test262/node_modules/test262-stream/test/collateral/invalid-version-unsupported/fake-test262/package.json +3 -0
  436. package/test262/node_modules/test262-stream/test/collateral/invalid-version-unsupported/fake-test262/test/strict.js +9 -0
  437. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/asyncNegative_default.js +49 -0
  438. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/asyncNegative_strict_mode.js +50 -0
  439. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/async_default.js +48 -0
  440. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/async_strict_mode.js +49 -0
  441. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/bothStrict_default.js +46 -0
  442. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/bothStrict_strict_mode.js +47 -0
  443. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/error_default.js +39 -0
  444. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/error_strict_mode.js +40 -0
  445. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/module_default.js +37 -0
  446. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/module_strict_mode.js +38 -0
  447. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/negative-empty_default.js +37 -0
  448. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/negative-empty_strict_mode.js +38 -0
  449. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/noStrict_default.js +36 -0
  450. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/rawNoStrict_default.js +14 -0
  451. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/rawStrict_default.js +15 -0
  452. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-content/test/strict_strict_mode.js +41 -0
  453. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/asyncNegative_default.json +22 -0
  454. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/asyncNegative_strict_mode.json +22 -0
  455. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/async_default.json +18 -0
  456. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/async_strict_mode.json +18 -0
  457. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/bothStrict_default.json +24 -0
  458. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/bothStrict_strict_mode.json +24 -0
  459. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/error_default.json +19 -0
  460. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/error_strict_mode.json +19 -0
  461. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/module_default.json +17 -0
  462. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/module_strict_mode.json +17 -0
  463. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/negative-empty_default.json +19 -0
  464. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/negative-empty_strict_mode.json +19 -0
  465. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/noStrict_default.json +17 -0
  466. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/rawNoStrict_default.json +14 -0
  467. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/rawStrict_default.json +14 -0
  468. package/test262/node_modules/test262-stream/test/collateral/valid-default/expected-metadata/test/strict_strict_mode.json +21 -0
  469. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/harness/assert.js +17 -0
  470. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/harness/doneprintHandle.js +6 -0
  471. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/harness/sta.js +12 -0
  472. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/async.js +10 -0
  473. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/asyncNegative.js +11 -0
  474. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/bothStrict.js +15 -0
  475. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/error.js +8 -0
  476. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/module.js +6 -0
  477. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/module_FIXTURE.js +2 -0
  478. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/negative-empty.js +6 -0
  479. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/noStrict.js +5 -0
  480. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/rawNoStrict.js +14 -0
  481. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/rawStrict.js +15 -0
  482. package/test262/node_modules/test262-stream/test/collateral/valid-default/fake-test262/test/strict.js +9 -0
  483. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/expected-content/test/bothStrict_default.js +46 -0
  484. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/expected-content/test/bothStrict_strict_mode.js +47 -0
  485. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_default.json +24 -0
  486. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/expected-metadata/test/bothStrict_strict_mode.json +24 -0
  487. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/harness/assert.js +17 -0
  488. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/harness/doneprintHandle.js +6 -0
  489. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/harness/sta.js +12 -0
  490. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/bothStrict.js +15 -0
  491. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-0_FIXTURE.js +2 -0
  492. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-1_FIXTURE.js +2 -0
  493. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-2_FIXTURE.js +2 -0
  494. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-3_FIXTURE.js +2 -0
  495. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-4_FIXTURE.js +2 -0
  496. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-5_FIXTURE.js +2 -0
  497. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-6_FIXTURE.js +2 -0
  498. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-7_FIXTURE.js +2 -0
  499. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-8_FIXTURE.js +2 -0
  500. package/test262/node_modules/test262-stream/test/collateral/valid-extra-files/fake-test262/test/zzz-9_FIXTURE.txt +2 -0
  501. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-content/test/raw_default.js +15 -0
  502. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_default.js +38 -0
  503. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-content/test/runtime_strict_mode.js +39 -0
  504. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/raw_default.json +14 -0
  505. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_default.json +15 -0
  506. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/expected-metadata/test/runtime_strict_mode.json +15 -0
  507. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/assert.js +17 -0
  508. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/fake-test262/harness/sta.js +12 -0
  509. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/raw.js +15 -0
  510. package/test262/node_modules/test262-stream/test/collateral/valid-insertionindex-with-copyright/fake-test262/test/runtime.js +7 -0
  511. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_default.js +11 -0
  512. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/asyncNegative_strict_mode.js +12 -0
  513. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/async_default.js +10 -0
  514. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/async_strict_mode.js +11 -0
  515. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_default.js +15 -0
  516. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/bothStrict_strict_mode.js +16 -0
  517. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/error_default.js +8 -0
  518. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/error_strict_mode.js +9 -0
  519. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/module_default.js +6 -0
  520. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/module_strict_mode.js +7 -0
  521. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_default.js +6 -0
  522. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/negative-empty_strict_mode.js +7 -0
  523. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/noStrict_default.js +5 -0
  524. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/rawNoStrict_default.js +14 -0
  525. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/rawStrict_default.js +15 -0
  526. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-content/test/strict_strict_mode.js +10 -0
  527. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_default.json +18 -0
  528. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/asyncNegative_strict_mode.json +18 -0
  529. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/async_default.json +14 -0
  530. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/async_strict_mode.json +14 -0
  531. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_default.json +21 -0
  532. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/bothStrict_strict_mode.json +21 -0
  533. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/error_default.json +16 -0
  534. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/error_strict_mode.json +16 -0
  535. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/module_default.json +14 -0
  536. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/module_strict_mode.json +14 -0
  537. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_default.json +16 -0
  538. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/negative-empty_strict_mode.json +16 -0
  539. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/noStrict_default.json +14 -0
  540. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/rawNoStrict_default.json +14 -0
  541. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/rawStrict_default.json +14 -0
  542. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/expected-metadata/test/strict_strict_mode.json +18 -0
  543. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/harness/assert.js +17 -0
  544. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/harness/doneprintHandle.js +6 -0
  545. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/harness/sta.js +12 -0
  546. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/async.js +10 -0
  547. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/asyncNegative.js +11 -0
  548. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/bothStrict.js +15 -0
  549. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/error.js +8 -0
  550. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/module.js +6 -0
  551. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/module_FIXTURE.js +2 -0
  552. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/negative-empty.js +6 -0
  553. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/noStrict.js +5 -0
  554. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/rawNoStrict.js +14 -0
  555. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/rawStrict.js +15 -0
  556. package/test262/node_modules/test262-stream/test/collateral/valid-omit-runtime/fake-test262/test/strict.js +9 -0
  557. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/expected-content/test/strict_strict_mode.js +41 -0
  558. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/expected-metadata/test/strict_strict_mode.json +21 -0
  559. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/fake-test262/harness/assert.js +17 -0
  560. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/fake-test262/harness/doneprintHandle.js +6 -0
  561. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/fake-test262/harness/sta.js +12 -0
  562. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/fake-test262/package.json +3 -0
  563. package/test262/node_modules/test262-stream/test/collateral/valid-version-ignored/fake-test262/test/strict.js +9 -0
  564. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/expected-content/test/strict_strict_mode.js +41 -0
  565. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/expected-metadata/test/strict_strict_mode.json +21 -0
  566. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/fake-test262/harness/assert.js +17 -0
  567. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/fake-test262/harness/doneprintHandle.js +6 -0
  568. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/fake-test262/harness/sta.js +12 -0
  569. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/fake-test262/package.json +3 -0
  570. package/test262/node_modules/test262-stream/test/collateral/valid-version-supported/fake-test262/test/strict.js +9 -0
  571. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_default.js +44 -0
  572. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/missing-raw-flag_strict_mode.js +45 -0
  573. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-and-license-on-same-line_default.js +20 -0
  574. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls-multiline-block_default.js +18 -0
  575. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ls_default.js +17 -0
  576. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-and-license-on-same-line_default.js +20 -0
  577. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps-multiline-block_default.js +18 -0
  578. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw-with-ps_default.js +17 -0
  579. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/rawWithLicense_default.js +21 -0
  580. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-content/test/raw_default.js +17 -0
  581. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_default.json +22 -0
  582. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/missing-raw-flag_strict_mode.json +22 -0
  583. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-and-license-on-same-line_default.json +21 -0
  584. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls-multiline-block_default.json +21 -0
  585. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ls_default.json +21 -0
  586. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-and-license-on-same-line_default.json +21 -0
  587. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps-multiline-block_default.json +21 -0
  588. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw-with-ps_default.json +21 -0
  589. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/rawWithLicense_default.json +21 -0
  590. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/expected-metadata/test/raw_default.json +21 -0
  591. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/harness/assert.js +17 -0
  592. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/harness/doneprintHandle.js +6 -0
  593. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/harness/sta.js +12 -0
  594. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/missing-raw-flag.js +13 -0
  595. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-and-license-on-same-line.js +20 -0
  596. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls-multiline-block.js +18 -0
  597. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ls.js +17 -0
  598. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-and-license-on-same-line.js +20 -0
  599. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps-multiline-block.js +18 -0
  600. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw-with-ps.js +17 -0
  601. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/raw.js +17 -0
  602. package/test262/node_modules/test262-stream/test/collateral/valid-with-hashbang/fake-test262/test/rawWithLicense.js +21 -0
  603. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/custom-includes/assert.js +17 -0
  604. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/custom-includes/doneprintHandle.js +9 -0
  605. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/custom-includes/sta.js +13 -0
  606. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-content/test/async_default.js +52 -0
  607. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-content/test/async_strict_mode.js +53 -0
  608. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-content/test/bothStrict_default.js +47 -0
  609. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-content/test/bothStrict_strict_mode.js +48 -0
  610. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-metadata/test/async_default.json +18 -0
  611. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-metadata/test/async_strict_mode.json +18 -0
  612. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_default.json +24 -0
  613. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/expected-metadata/test/bothStrict_strict_mode.json +24 -0
  614. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/fake-test262/harness/assert.js +17 -0
  615. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/fake-test262/harness/doneprintHandle.js +6 -0
  616. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/fake-test262/test/async.js +10 -0
  617. package/test262/node_modules/test262-stream/test/collateral/valid-with-includes/fake-test262/test/bothStrict.js +15 -0
  618. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_default.js +49 -0
  619. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/async/asyncNegative_strict_mode.js +50 -0
  620. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/async/async_default.js +48 -0
  621. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/async/async_strict_mode.js +49 -0
  622. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/bothStrict_default.js +46 -0
  623. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/bothStrict_strict_mode.js +47 -0
  624. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/strict/no/noStrict_default.js +36 -0
  625. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-content/test/strict/no/rawNoStrict_default.js +14 -0
  626. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_default.json +22 -0
  627. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/async/asyncNegative_strict_mode.json +22 -0
  628. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/async/async_default.json +18 -0
  629. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/async/async_strict_mode.json +18 -0
  630. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_default.json +24 -0
  631. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/bothStrict_strict_mode.json +24 -0
  632. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/strict/no/noStrict_default.json +17 -0
  633. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/expected-metadata/test/strict/no/rawNoStrict_default.json +14 -0
  634. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/harness/assert.js +17 -0
  635. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/harness/doneprintHandle.js +6 -0
  636. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/harness/sta.js +12 -0
  637. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/async/async.js +10 -0
  638. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/async/asyncNegative.js +11 -0
  639. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/bothStrict.js +15 -0
  640. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/error.js +8 -0
  641. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/negative-empty.js +6 -0
  642. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/strict/no/noStrict.js +5 -0
  643. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/strict/no/rawNoStrict.js +14 -0
  644. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/strict/rawStrict.js +15 -0
  645. package/test262/node_modules/test262-stream/test/collateral/valid-with-paths/fake-test262/test/strict/strict.js +9 -0
  646. package/test262/node_modules/test262-stream/test/test.js +319 -0
  647. package/test262/node_modules/to-regex-range/LICENSE +21 -0
  648. package/test262/node_modules/to-regex-range/README.md +305 -0
  649. package/test262/node_modules/to-regex-range/index.js +288 -0
  650. package/test262/node_modules/to-regex-range/package.json +88 -0
  651. package/test262/package-lock.json +279 -0
  652. package/test262/package.json +6 -0
  653. package/test262/prelude.js +75 -0
  654. package/test262/results.json +1 -0
  655. package/util/enum.js +20 -0
@@ -0,0 +1,436 @@
1
+ import { Opcodes, Valtype } from "./wasmSpec.js";
2
+ import { number } from "./embedding.js";
3
+
4
+ // deno compat
5
+ if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
6
+ const textEncoder = new TextEncoder();
7
+ globalThis.process = { argv: ['', '', ...Deno.args], stdout: { write: str => Deno.writeAllSync(Deno.stdout, textEncoder.encode(str)) } };
8
+ }
9
+
10
+ const performWasmOp = (op, a, b) => {
11
+ switch (op) {
12
+ case Opcodes.add: return a + b;
13
+ case Opcodes.sub: return a - b;
14
+ case Opcodes.mul: return a * b;
15
+ }
16
+ };
17
+
18
+ export default (funcs, globals) => {
19
+ const optLevel = parseInt(process.argv.find(x => x.startsWith('-O'))?.[2] ?? 1);
20
+ if (optLevel === 0) return;
21
+
22
+ const tailCall = process.argv.includes('-tail-call');
23
+ if (tailCall) log('opt', 'tail call proposal is not widely implemented! (you used -tail-call)');
24
+
25
+ if (optLevel >= 2 && !process.argv.includes('-opt-no-inline')) {
26
+ // inline pass (very WIP)
27
+ // get candidates for inlining
28
+ // todo: pick smart in future (if func is used <N times? or?)
29
+ const callsSelf = f => f.wasm.some(x => x[0] === Opcodes.call && x[1] === f.index);
30
+ const suitableReturns = wasm => wasm.reduce((acc, x) => acc + (x[0] === Opcodes.return), 0) <= 1;
31
+ const candidates = funcs.filter(x => x.name !== 'main' && Object.keys(x.locals).length === x.params.length && (x.returns.length === 0 || suitableReturns(x.wasm)) && !callsSelf(x) && !x.throws).reverse();
32
+ if (optLog) {
33
+ log('opt', `found inline candidates: ${candidates.map(x => x.name).join(', ')} (${candidates.length}/${funcs.length - 1})`);
34
+
35
+ let reasons = {};
36
+ for (const f of funcs) {
37
+ if (f.name === 'main') continue;
38
+ reasons[f.name] = [];
39
+
40
+ if (f.name === 'main') reasons[f.name].push('main');
41
+ if (Object.keys(f.locals).length !== f.params.length) reasons[f.name].push('cannot inline funcs with locals yet');
42
+ if (f.returns.length !== 0 && !suitableReturns(f.wasm)) reasons[f.name].push('cannot inline funcs with multiple returns yet');
43
+ if (callsSelf(f)) reasons[f.name].push('cannot inline func calling itself');
44
+ if (f.throws) reasons[f.name].push('will not inline funcs throwing yet');
45
+ }
46
+
47
+ if (Object.values(reasons).some(x => x.length > 0)) console.log(` reasons not:\n${Object.keys(reasons).filter(x => reasons[x].length > 0).map(x => ` ${x}: ${reasons[x].join(', ')}`).join('\n')}\n`)
48
+ }
49
+
50
+ for (const c of candidates) {
51
+ const cWasm = c.wasm;
52
+
53
+ for (const t of funcs) {
54
+ const tWasm = t.wasm;
55
+ if (t.name === c.name) continue; // skip self
56
+
57
+ for (let i = 0; i < tWasm.length; i++) {
58
+ const inst = tWasm[i];
59
+ if (inst[0] === Opcodes.call && inst[1] === c.index) {
60
+ if (optLog) log('opt', `inlining call for ${c.name} (in ${t.name})`);
61
+ tWasm.splice(i, 1); // remove this call
62
+
63
+ // add params as locals and set in reverse order
64
+ const paramIdx = {};
65
+ let localIdx = Math.max(-1, ...Object.values(t.locals).map(x => x.idx)) + 1;
66
+ for (let j = c.params.length - 1; j >= 0; j--) {
67
+ const name = `__porf_inline_${c.name}_param_${j}`;
68
+
69
+ if (t.locals[name] === undefined) {
70
+ t.locals[name] = { idx: localIdx++, type: c.params[j] };
71
+ }
72
+
73
+ const idx = t.locals[name].idx;
74
+ paramIdx[j] = idx;
75
+
76
+ tWasm.splice(i, 0, [ Opcodes.local_set, idx ]);
77
+ i++;
78
+ }
79
+
80
+ let iWasm = cWasm.slice().map(x => x.slice()); // deep clone arr (depth 2)
81
+ // remove final return
82
+ if (iWasm.length !== 0 && iWasm[iWasm.length - 1][0] === Opcodes.return) iWasm = iWasm.slice(0, -1);
83
+
84
+ // adjust local operands to go to correct param index
85
+ for (const inst of iWasm) {
86
+ if ((inst[0] === Opcodes.local_get || inst[0] === Opcodes.local_set) && inst[1] < c.params.length) {
87
+ if (optLog) log('opt', `replacing local operand in inlined wasm (${inst[1]} -> ${paramIdx[inst[1]]})`);
88
+ inst[1] = paramIdx[inst[1]];
89
+ }
90
+ }
91
+
92
+ tWasm.splice(i, 0, ...iWasm);
93
+ i += iWasm.length;
94
+ }
95
+ }
96
+
97
+ if (t.index > c.index) t.index--; // adjust index if after removed func
98
+ if (c.memory) t.memory = true;
99
+ }
100
+
101
+ funcs.splice(funcs.indexOf(c), 1); // remove func from funcs
102
+ }
103
+ }
104
+
105
+ if (process.argv.includes('-opt-inline-only')) return;
106
+
107
+ // wasm transform pass
108
+ for (const f of funcs) {
109
+ const wasm = f.wasm;
110
+
111
+ let depth = [];
112
+
113
+ let getCount = {}, setCount = {};
114
+ for (const x in f.locals) {
115
+ getCount[f.locals[x].idx] = 0;
116
+ setCount[f.locals[x].idx] = 0;
117
+ }
118
+
119
+ // main pass
120
+ for (let i = 0; i < wasm.length; i++) {
121
+ let inst = wasm[i];
122
+
123
+ if (inst[0] === Opcodes.if || inst[0] === Opcodes.loop || inst[0] === Opcodes.block) depth.push(inst[0]);
124
+ if (inst[0] === Opcodes.end) depth.pop();
125
+
126
+ if (inst[0] === Opcodes.local_get) getCount[inst[1]]++;
127
+ if (inst[0] === Opcodes.local_set || inst[0] === Opcodes.local_tee) setCount[inst[1]]++;
128
+
129
+ if (inst[0] === Opcodes.block) {
130
+ // remove unneeded blocks (no brs inside)
131
+ // block
132
+ // ...
133
+ // end
134
+ // -->
135
+ // ...
136
+
137
+ let hasBranch = false, j = i, depth = 0;
138
+ for (; j < wasm.length; j++) {
139
+ const op = wasm[j][0];
140
+ if (op === Opcodes.if || op === Opcodes.block || op === Opcodes.loop || op === Opcodes.try) depth++;
141
+ if (op === Opcodes.end) {
142
+ depth--;
143
+ if (depth <= 0) break;
144
+ }
145
+ if (op === Opcodes.br) {
146
+ hasBranch = true;
147
+ break;
148
+ }
149
+ }
150
+
151
+ if (!hasBranch) {
152
+ wasm.splice(i, 1); // remove this inst (block)
153
+ i--;
154
+ inst = wasm[i];
155
+
156
+ wasm.splice(j - 1, 1); // remove end of this block
157
+
158
+ if (optLog) log('opt', `removed unneeded block in for loop`);
159
+ }
160
+ }
161
+
162
+ if (i < 1) continue;
163
+ let lastInst = wasm[i - 1];
164
+
165
+ if (lastInst[1] === inst[1] && lastInst[0] === Opcodes.local_set && inst[0] === Opcodes.local_get) {
166
+ // replace set, get -> tee (sets and returns)
167
+ // local.set 0
168
+ // local.get 0
169
+ // -->
170
+ // local.tee 0
171
+
172
+ lastInst[0] = Opcodes.local_tee; // replace last inst opcode (set -> tee)
173
+ wasm.splice(i, 1); // remove this inst (get)
174
+
175
+ getCount[inst[1]]--;
176
+ i--;
177
+ // if (optLog) log('opt', `consolidated set, get -> tee`);
178
+ continue;
179
+ }
180
+
181
+ if ((lastInst[0] === Opcodes.local_get || lastInst[0] === Opcodes.global_get) && inst[0] === Opcodes.drop) {
182
+ // replace get, drop -> nothing
183
+ // local.get 0
184
+ // drop
185
+ // -->
186
+ //
187
+
188
+ getCount[lastInst[1]]--;
189
+
190
+ wasm.splice(i - 1, 2); // remove this inst and last
191
+ i -= 2;
192
+ continue;
193
+ }
194
+
195
+ if (lastInst[0] === Opcodes.local_tee && inst[0] === Opcodes.drop) {
196
+ // replace tee, drop -> set
197
+ // local.tee 0
198
+ // drop
199
+ // -->
200
+ // local.set 0
201
+
202
+ getCount[lastInst[1]]--;
203
+
204
+ lastInst[0] = Opcodes.local_set; // change last op
205
+
206
+ wasm.splice(i, 1); // remove this inst
207
+ i--;
208
+ continue;
209
+ }
210
+
211
+ if ((lastInst[0] === Opcodes.i32_const || lastInst[0] === Opcodes.i64_const || lastInst[0] === Opcodes.f64_const) && inst[0] === Opcodes.drop) {
212
+ // replace const, drop -> <nothing>
213
+ // i32.const 0
214
+ // drop
215
+ // -->
216
+ // <nothing>>
217
+
218
+ wasm.splice(i - 1, 2); // remove this inst
219
+ i -= 2;
220
+ continue;
221
+ }
222
+
223
+ if (inst[0] === Opcodes.eq && lastInst[0] === Opcodes.const && lastInst[1] === 0 && valtype !== 'f64') {
224
+ // replace const 0, eq -> eqz
225
+ // i32.const 0
226
+ // i32.eq
227
+ // -->
228
+ // i32.eqz
229
+
230
+ inst[0] = Opcodes.eqz[0][0]; // eq -> eqz
231
+ wasm.splice(i - 1, 1); // remove const 0
232
+ i--;
233
+ continue;
234
+ }
235
+
236
+ if (inst[0] === Opcodes.i32_wrap_i64 && (lastInst[0] === Opcodes.i64_extend_i32_s || lastInst[0] === Opcodes.i64_extend_i32_u)) {
237
+ // remove unneeded i32 -> i64 -> i32
238
+ // i64.extend_i32_s
239
+ // i32.wrap_i64
240
+ // -->
241
+ // <nothing>
242
+
243
+ wasm.splice(i - 1, 2); // remove this inst and last
244
+ i -= 2;
245
+ // if (optLog) log('opt', `removed redundant i32 -> i64 -> i32 conversion ops`);
246
+ continue;
247
+ }
248
+
249
+ if (inst[0] === Opcodes.i32_trunc_sat_f64_s[0] && (lastInst[0] === Opcodes.f64_convert_i32_u || lastInst[0] === Opcodes.f64_convert_i32_s)) {
250
+ // remove unneeded i32 -> f64 -> i32
251
+ // f64.convert_i32_s || f64.convert_i32_u
252
+ // i32.trunc_sat_f64_s || i32.trunc_sat_f64_u
253
+ // -->
254
+ // <nothing>
255
+
256
+ wasm.splice(i - 1, 2); // remove this inst and last
257
+ i -= 2;
258
+ // if (optLog) log('opt', `removed redundant i32 -> f64 -> i32 conversion ops`);
259
+ continue;
260
+ }
261
+
262
+ if (tailCall && lastInst[0] === Opcodes.call && inst[0] === Opcodes.return) {
263
+ // replace call, return with tail calls (return_call)
264
+ // call X
265
+ // return
266
+ // -->
267
+ // return_call X
268
+
269
+ lastInst[0] = Opcodes.return_call; // change last inst return -> return_call
270
+
271
+ wasm.splice(i, 1); // remove this inst (return)
272
+ i--;
273
+ if (optLog) log('opt', `tail called return, call`);
274
+ continue;
275
+ }
276
+
277
+ if (false && i === wasm.length - 1 && inst[0] === Opcodes.return) {
278
+ // replace final return, end -> end (wasm has implicit return)
279
+ // return
280
+ // end
281
+ // -->
282
+ // end
283
+
284
+ wasm.splice(i, 1); // remove this inst (return)
285
+ i--;
286
+ // if (optLog) log('opt', `removed redundant return at end`);
287
+ continue;
288
+ }
289
+
290
+ if (i < 2) continue;
291
+ const lastLastInst = wasm[i - 2];
292
+
293
+ if (depth.length === 2) {
294
+ // hack to remove unneeded before get in for loops with (...; i++)
295
+ if (lastLastInst[0] === Opcodes.end && lastInst[1] === inst[1] && lastInst[0] === Opcodes.local_get && inst[0] === Opcodes.local_get) {
296
+ // local.get 1
297
+ // local.get 1
298
+ // -->
299
+ // local.get 1
300
+
301
+ // remove drop at the end as well
302
+ if (wasm[i + 4][0] === Opcodes.drop) {
303
+ wasm.splice(i + 4, 1);
304
+ }
305
+
306
+ wasm.splice(i, 1); // remove this inst (second get)
307
+ i--;
308
+ continue;
309
+ }
310
+ }
311
+
312
+ if (lastLastInst[1] === inst[1] && inst[0] === Opcodes.local_get && lastInst[0] === Opcodes.local_tee && lastLastInst[0] === Opcodes.local_set) {
313
+ // local.set x
314
+ // local.tee y
315
+ // local.get x
316
+ // -->
317
+ // <nothing>
318
+
319
+ wasm.splice(i - 2, 3); // remove this, last, 2nd last insts
320
+ if (optLog) log('opt', `removed redundant inline param local handling`);
321
+ i -= 3;
322
+ continue;
323
+ }
324
+ }
325
+
326
+ if (optLevel < 2) continue;
327
+
328
+ if (optLog) log('opt', `get counts: ${Object.keys(f.locals).map(x => `${x} (${f.locals[x].idx}): ${getCount[f.locals[x].idx]}`).join(', ')}`);
329
+
330
+ // remove unneeded var: remove pass
331
+ // locals only got once. we don't need to worry about sets/else as these are only candidates and we will check for matching set + get insts in wasm
332
+ let unneededCandidates = Object.keys(getCount).filter(x => getCount[x] === 0 || (getCount[x] === 1 && setCount[x] === 0)).map(x => parseInt(x));
333
+ if (optLog) log('opt', `found unneeded locals candidates: ${unneededCandidates.join(', ')} (${unneededCandidates.length}/${Object.keys(getCount).length})`);
334
+
335
+ // note: disabled for now due to instability
336
+ if (unneededCandidates.length > 0 && false) for (let i = 0; i < wasm.length; i++) {
337
+ if (i < 1) continue;
338
+
339
+ const inst = wasm[i];
340
+ const lastInst = wasm[i - 1];
341
+
342
+ if (lastInst[1] === inst[1] && lastInst[0] === Opcodes.local_set && inst[0] === Opcodes.local_get && unneededCandidates.includes(inst[1])) {
343
+ // local.set N
344
+ // local.get N
345
+ // -->
346
+ // <nothing>
347
+
348
+ wasm.splice(i - 1, 2); // remove insts
349
+ i -= 2;
350
+ delete f.locals[Object.keys(f.locals)[inst[1]]]; // remove from locals
351
+ if (optLog) log('opt', `removed redundant local (get set ${inst[1]})`);
352
+ }
353
+
354
+ if (inst[0] === Opcodes.local_tee && unneededCandidates.includes(inst[1])) {
355
+ // local.tee N
356
+ // -->
357
+ // <nothing>
358
+
359
+ wasm.splice(i, 1); // remove inst
360
+ i--;
361
+
362
+ const localName = Object.keys(f.locals)[inst[1]];
363
+ const removedIdx = f.locals[localName].idx;
364
+ delete f.locals[localName]; // remove from locals
365
+
366
+ // fix locals index for locals after
367
+ for (const x in f.locals) {
368
+ const local = f.locals[x];
369
+ if (local.idx > removedIdx) local.idx--;
370
+ }
371
+
372
+ for (const inst of wasm) {
373
+ if ((inst[0] === Opcodes.local_get || inst[0] === Opcodes.local_set || inst[0] === Opcodes.local_tee) && inst[1] > removedIdx) inst[1]--;
374
+ }
375
+
376
+ unneededCandidates.splice(unneededCandidates.indexOf(inst[1]), 1);
377
+ unneededCandidates = unneededCandidates.map(x => x > removedIdx ? (x - 1) : x);
378
+
379
+ if (optLog) log('opt', `removed redundant local ${localName} (tee ${inst[1]})`);
380
+ }
381
+ }
382
+
383
+ const useCount = {};
384
+ for (const x in f.locals) useCount[f.locals[x].idx] = 0;
385
+
386
+ // final pass
387
+ depth = [];
388
+ for (let i = 0; i < wasm.length; i++) {
389
+ let inst = wasm[i];
390
+ if (inst[0] === Opcodes.local_get || inst[0] === Opcodes.local_set || inst[0] === Opcodes.local_tee) useCount[inst[1]]++;
391
+
392
+ if (inst[0] === Opcodes.if || inst[0] === Opcodes.loop || inst[0] === Opcodes.block) depth.push(inst[0]);
393
+ if (inst[0] === Opcodes.end) depth.pop();
394
+
395
+ if (i < 2) continue;
396
+ const lastInst = wasm[i - 1];
397
+ const lastLastInst = wasm[i - 2];
398
+
399
+ // todo: add more math ops
400
+ if (optLevel >= 3 && (inst[0] === Opcodes.add || inst[0] === Opcodes.sub || inst[0] === Opcodes.mul) && lastLastInst[0] === Opcodes.const && lastInst[0] === Opcodes.const) {
401
+ // inline const math ops
402
+ // i32.const a
403
+ // i32.const b
404
+ // i32.add
405
+ // -->
406
+ // i32.const a + b
407
+
408
+ // does not work with leb encoded
409
+ if (lastInst.length > 2 || lastLastInst.length > 2) continue;
410
+
411
+ let a = lastLastInst[1];
412
+ let b = lastInst[1];
413
+
414
+ const val = performWasmOp(inst[0], a, b);
415
+ if (optLog) log('opt', `inlined math op (${a} ${inst[0].toString(16)} ${b} -> ${val})`);
416
+
417
+ wasm.splice(i - 2, 3, ...number(val)); // remove consts, math op and add new const
418
+ i -= 2;
419
+ }
420
+ }
421
+
422
+ const localIdxs = Object.values(f.locals).map(x => x.idx);
423
+ // remove unused locals (cleanup)
424
+ for (const x in useCount) {
425
+ if (useCount[x] === 0) {
426
+ const name = Object.keys(f.locals)[localIdxs.indexOf(parseInt(x))];
427
+ if (optLog) log('opt', `removed internal local ${x} (${name})`);
428
+ delete f.locals[name];
429
+ }
430
+ }
431
+
432
+ if (optLog) log('opt', `final use counts: ${Object.keys(f.locals).map(x => `${x} (${f.locals[x].idx}): ${useCount[f.locals[x].idx]}`).join(', ')}`);
433
+ }
434
+
435
+ // return funcs;
436
+ };
@@ -0,0 +1,8 @@
1
+ const { parse } = (await import(globalThis.document ? 'https://esm.sh/acorn' : 'acorn'));
2
+
3
+ export default (input, flags) => {
4
+ return parse(input, {
5
+ ecmaVersion: 'latest',
6
+ sourceType: flags.includes('module') ? 'module' : 'script'
7
+ });
8
+ };