porffor 0.2.0-fdf0fc5 → 0.14.0-0ad2c8a7c
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.
- package/CONTRIBUTING.md +12 -7
- package/README.md +18 -15
- package/asur/index.js +1 -1
- package/byg/index.js +3 -24
- package/compiler/2c.js +69 -55
- package/compiler/assemble.js +51 -11
- package/compiler/builtins/annexb_string.js +10 -10
- package/compiler/builtins/annexb_string.ts +4 -3
- package/compiler/builtins/array.ts +85 -9
- package/compiler/builtins/base64.ts +2 -1
- package/compiler/builtins/boolean.ts +2 -2
- package/compiler/builtins/console.ts +4 -0
- package/compiler/builtins/crypto.ts +2 -1
- package/compiler/builtins/date.ts +2 -3
- package/compiler/builtins/error.js +22 -0
- package/compiler/builtins/escape.ts +2 -3
- package/compiler/builtins/function.ts +1 -1
- package/compiler/builtins/int.ts +1 -1
- package/compiler/builtins/math.ts +410 -0
- package/compiler/builtins/number.ts +4 -7
- package/compiler/builtins/object.ts +1 -1
- package/compiler/builtins/porffor.d.ts +9 -8
- package/compiler/builtins/set.ts +197 -3
- package/compiler/builtins/string.ts +2 -1
- package/compiler/builtins/symbol.ts +62 -0
- package/compiler/builtins.js +30 -15
- package/compiler/codegen.js +641 -365
- package/compiler/decompile.js +7 -3
- package/compiler/embedding.js +2 -2
- package/compiler/encoding.js +0 -14
- package/compiler/expression.js +1 -1
- package/compiler/generated_builtins.js +781 -187
- package/compiler/index.js +5 -11
- package/compiler/opt.js +7 -7
- package/compiler/parse.js +2 -4
- package/compiler/precompile.js +18 -25
- package/compiler/prefs.js +6 -2
- package/compiler/prototype.js +185 -162
- package/compiler/wasmSpec.js +5 -0
- package/compiler/wrap.js +150 -90
- package/package.json +1 -1
- package/runner/compare.js +0 -1
- package/runner/debug.js +1 -6
- package/runner/index.js +5 -4
- package/runner/profiler.js +15 -42
- package/runner/repl.js +20 -10
- package/runner/sizes.js +2 -2
- package/runner/version.js +10 -8
package/compiler/decompile.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Blocktype, Opcodes, Valtype } from
|
2
|
-
import { read_ieee754_binary64, read_signedLEB128, read_unsignedLEB128 } from
|
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);
|
@@ -89,6 +89,10 @@ export default (wasm, name = '', ind = 0, locals = {}, params = [], returns = []
|
|
89
89
|
if (inst[0] === Opcodes.call || inst[0] === Opcodes.return_call) {
|
90
90
|
const callFunc = funcs.find(x => x.index === inst[1]);
|
91
91
|
if (callFunc) out += ` ;; $${callFunc.name} ${makeSignature(callFunc.params, callFunc.returns)}`;
|
92
|
+
if (globalThis.importFuncs && inst[1] < importFuncs.length) {
|
93
|
+
const importFunc = importFuncs[inst[1]];
|
94
|
+
out += ` ;; import ${importFunc.name} ${makeSignature(new Array(importFunc.params).fill(valtypeBinary), new Array(importFunc.returns).fill(valtypeBinary),)}`;
|
95
|
+
}
|
92
96
|
}
|
93
97
|
|
94
98
|
if (inst[0] === Opcodes.local_get || inst[0] === Opcodes.local_set || inst[0] === Opcodes.local_tee) {
|
@@ -119,7 +123,7 @@ export const highlightAsm = asm => asm
|
|
119
123
|
.replace(/(local|global|memory)\.[^\s]*/g, _ => `\x1B[31m${_}\x1B[0m`)
|
120
124
|
.replace(/(i(8|16|32|64)x[0-9]+|v128)(\.[^\s]*)?/g, _ => `\x1B[34m${_}\x1B[0m`)
|
121
125
|
.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`)
|
126
|
+
.replace(/(return_call|call_indirect|call|br_if|br|return|rethrow|throw)/g, _ => `\x1B[35m${_}\x1B[0m`)
|
123
127
|
.replace(/(block|loop|if|end|else|try|catch_all|catch|delegate)/g, _ => `\x1B[95m${_}\x1B[0m`)
|
124
128
|
.replace(/unreachable/g, _ => `\x1B[91m${_}\x1B[0m`)
|
125
129
|
.replace(/ \-?[0-9\.]+/g, _ => ` \x1B[33m${_.slice(1)}\x1B[0m`)
|
package/compiler/embedding.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Opcodes, Valtype } from
|
2
|
-
import { signedLEB128, ieee754_binary64 } from
|
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) {
|
package/compiler/encoding.js
CHANGED
@@ -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) => [
|
package/compiler/expression.js
CHANGED