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.
- package/CONTRIBUTING.md +9 -3
- package/README.md +17 -14
- package/asur/index.js +1 -1
- package/byg/index.js +3 -24
- package/compiler/2c.js +66 -54
- 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/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 +41 -15
- package/compiler/codegen.js +653 -366
- package/compiler/decompile.js +3 -3
- package/compiler/embedding.js +2 -2
- package/compiler/encoding.js +0 -14
- package/compiler/expression.js +1 -1
- package/compiler/generated_builtins.js +771 -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/porffor_tmp.c +202 -0
- 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);
|
@@ -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`)
|
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