porffor 0.2.0-fdf0fc5 → 0.14.0-032e4ad08

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 (48) hide show
  1. package/CONTRIBUTING.md +9 -3
  2. package/README.md +17 -14
  3. package/asur/index.js +1 -1
  4. package/byg/index.js +3 -24
  5. package/compiler/2c.js +66 -54
  6. package/compiler/assemble.js +51 -11
  7. package/compiler/builtins/annexb_string.js +10 -10
  8. package/compiler/builtins/annexb_string.ts +4 -3
  9. package/compiler/builtins/array.ts +85 -9
  10. package/compiler/builtins/base64.ts +2 -1
  11. package/compiler/builtins/boolean.ts +2 -2
  12. package/compiler/builtins/crypto.ts +2 -1
  13. package/compiler/builtins/date.ts +2 -3
  14. package/compiler/builtins/error.js +22 -0
  15. package/compiler/builtins/escape.ts +2 -3
  16. package/compiler/builtins/function.ts +1 -1
  17. package/compiler/builtins/int.ts +1 -1
  18. package/compiler/builtins/math.ts +410 -0
  19. package/compiler/builtins/number.ts +4 -7
  20. package/compiler/builtins/object.ts +1 -1
  21. package/compiler/builtins/porffor.d.ts +9 -8
  22. package/compiler/builtins/set.ts +197 -3
  23. package/compiler/builtins/string.ts +2 -1
  24. package/compiler/builtins/symbol.ts +62 -0
  25. package/compiler/builtins.js +41 -15
  26. package/compiler/codegen.js +653 -366
  27. package/compiler/decompile.js +3 -3
  28. package/compiler/embedding.js +2 -2
  29. package/compiler/encoding.js +0 -14
  30. package/compiler/expression.js +1 -1
  31. package/compiler/generated_builtins.js +771 -187
  32. package/compiler/index.js +5 -11
  33. package/compiler/opt.js +7 -7
  34. package/compiler/parse.js +2 -4
  35. package/compiler/precompile.js +18 -25
  36. package/compiler/prefs.js +6 -2
  37. package/compiler/prototype.js +185 -162
  38. package/compiler/wasmSpec.js +5 -0
  39. package/compiler/wrap.js +150 -90
  40. package/package.json +1 -1
  41. package/porffor_tmp.c +202 -0
  42. package/runner/compare.js +0 -1
  43. package/runner/debug.js +1 -6
  44. package/runner/index.js +5 -4
  45. package/runner/profiler.js +15 -42
  46. package/runner/repl.js +20 -10
  47. package/runner/sizes.js +2 -2
  48. package/runner/version.js +10 -8
@@ -1,5 +1,5 @@
1
- import { Blocktype, Opcodes, Valtype } from "./wasmSpec.js";
2
- import { read_ieee754_binary64, read_signedLEB128, read_unsignedLEB128 } from "./encoding.js";
1
+ import { Blocktype, Opcodes, Valtype } from './wasmSpec.js';
2
+ import { read_ieee754_binary64, read_signedLEB128, read_unsignedLEB128 } from './encoding.js';
3
3
 
4
4
  const inv = (obj, keyMap = x => x) => Object.keys(obj).reduce((acc, x) => { acc[keyMap(obj[x])] = x; return acc; }, {});
5
5
  const invOpcodes = inv(Opcodes);
@@ -119,7 +119,7 @@ export const highlightAsm = asm => asm
119
119
  .replace(/(local|global|memory)\.[^\s]*/g, _ => `\x1B[31m${_}\x1B[0m`)
120
120
  .replace(/(i(8|16|32|64)x[0-9]+|v128)(\.[^\s]*)?/g, _ => `\x1B[34m${_}\x1B[0m`)
121
121
  .replace(/(i32|i64|f32|f64|drop)(\.[^\s]*)?/g, _ => `\x1B[36m${_}\x1B[0m`)
122
- .replace(/(return_call|call|br_if|br|return|rethrow|throw)/g, _ => `\x1B[35m${_}\x1B[0m`)
122
+ .replace(/(return_call|call_indirect|call|br_if|br|return|rethrow|throw)/g, _ => `\x1B[35m${_}\x1B[0m`)
123
123
  .replace(/(block|loop|if|end|else|try|catch_all|catch|delegate)/g, _ => `\x1B[95m${_}\x1B[0m`)
124
124
  .replace(/unreachable/g, _ => `\x1B[91m${_}\x1B[0m`)
125
125
  .replace(/ \-?[0-9\.]+/g, _ => ` \x1B[33m${_.slice(1)}\x1B[0m`)
@@ -1,5 +1,5 @@
1
- import { Opcodes, Valtype } from "./wasmSpec.js";
2
- import { signedLEB128, ieee754_binary64 } from "./encoding.js";
1
+ import { Opcodes, Valtype } from './wasmSpec.js';
2
+ import { signedLEB128, ieee754_binary64 } from './encoding.js';
3
3
 
4
4
  export const number = (n, valtype = valtypeBinary) => {
5
5
  switch (valtype) {
@@ -7,21 +7,7 @@ export const codifyString = str => {
7
7
  return out;
8
8
  };
9
9
 
10
- // export const encodeString = str => [
11
- // str.length,
12
- // ...codifyString(str)
13
- // ];
14
10
  export const encodeString = str => unsignedLEB128(str.length).concat(codifyString(str));
15
-
16
- // export const encodeVector = data => [
17
- // ...unsignedLEB128(data.length),
18
- // ...data.flat()
19
- // ];
20
- // export const encodeVector = data => {
21
- // const out = data.flat();
22
- // out.unshift.apply(out, unsignedLEB128(data.length));
23
- // return out;
24
- // };
25
11
  export const encodeVector = data => unsignedLEB128(data.length).concat(data.flat());
26
12
 
27
13
  export const encodeLocal = (count, type) => [
@@ -1,4 +1,4 @@
1
- import { Opcodes } from "./wasmSpec.js";
1
+ import { Opcodes } from './wasmSpec.js';
2
2
 
3
3
  export const operatorOpcode = {
4
4
  i32: {