nirguna 1.2.3 → 1.2.5
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/ChangeLog +93 -0
- package/README.md +1 -1
- package/package.json +6 -11
- package/packages/compiler-fasm/compiler.js +1 -1
- package/packages/compiler-wasm/compiler.js +2 -2
- package/packages/translator-fasm/dump.js +0 -68
- package/packages/translator-fasm/translator.js +0 -15
- package/packages/translator-wasm/translator.js +0 -51
package/ChangeLog
CHANGED
|
@@ -1,3 +1,96 @@
|
|
|
1
|
+
2026.07.08, v1.2.5
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- f13f271 feat: @nirguna/parser-wasm: add support for start section test: add fixture start-section.wast -> start-section-fix.js feat: add Start visitor to parse (start ) attach pending comments to all visited nodes, not just Func
|
|
5
|
+
- f7378dc @nirguna/printer-wasm: VariableDeclaration: newline
|
|
6
|
+
- 6e8a36a @nirguna/printer-wasm: indent
|
|
7
|
+
- 5497424 @nirguna/printer-wasm: print export on exported globals
|
|
8
|
+
- 9ff53d6 @nirguna/parser-wasm: include export kind in the export marker
|
|
9
|
+
- 0f96250 @nirguna/printer-wasm: print a block-bodied if consequent
|
|
10
|
+
- cdbb52e @nirguna/parser-wasm: match printer-wasm's br/br_if/loop representation
|
|
11
|
+
- 0558d25 @nirguna/printer-wasm: remove trailing space after a block's label
|
|
12
|
+
- 1143d50 @nirguna/parser-wasm: stop dropping exported globals
|
|
13
|
+
- 362d7c7 @nirguna/parser-wasm: stop crashing on float constants
|
|
14
|
+
- 5e7f565 @nirguna/parser-wasm: call
|
|
15
|
+
- 3ca5241 @putout/nirguna-parser-wasm: stop dropping multi-value return types
|
|
16
|
+
- 9b510cb @putout/nirguna-parser-wasm: only export functions that are actually exported
|
|
17
|
+
- 0e95d33 @putout/nirguna-parser-wasm: keep separated exports and their comments as standalone nodes
|
|
18
|
+
- 81317d4 @putout/nirguna-parser-wasm: keep import param names and return type
|
|
19
|
+
- 0601715 @putout/nirguna-parser-wasm: handle call instruction with no arguments
|
|
20
|
+
- 8f359e6 @nirguna/parser-wasm: get rid of util
|
|
21
|
+
- 70fb091 @nirguna/plugin-fasm: convert-assign-to-mov: isArrayExpression -> isArrayPattern
|
|
22
|
+
|
|
23
|
+
feature:
|
|
24
|
+
- ba7c812 @nirguna/translator-wasm: move out to package
|
|
25
|
+
- dba795a @nirguna/translator-fasm: move out
|
|
26
|
+
- 9797662 @nirguna/printer: ExpressionStatement: printWasmExport: simplify
|
|
27
|
+
- 079b43c @nirguna/printer-wasm: print export marker calls back to WAST
|
|
28
|
+
- a6043f3 @nirguna/printer-wasm: ExpressionStatement: apply type checker
|
|
29
|
+
- a391277 @nirguna/printer-wasm: loop inside block
|
|
30
|
+
- d05b2e8 @nirguna/printer: indent
|
|
31
|
+
- 0a371da @nirguna/printer: loop
|
|
32
|
+
- 4dcb795 @nirguna/printer-wasm: escover v6.5.2
|
|
33
|
+
- 49303bd @nirguna/printer-wasm: escover v6.5.2
|
|
34
|
+
- 1e70d8a @nirguna/printer: block
|
|
35
|
+
- 06081ce @nirguna/printer-wasm: revert: continue, label
|
|
36
|
+
- 98b47ad @nirguna/parser-wasm: func: emitBlockStatement: add
|
|
37
|
+
- 48ef1ff @nirguna/printer-wasm: add support of global
|
|
38
|
+
- 3785622 @nirguna/parser-wasm: add support of global
|
|
39
|
+
- fc1641a @nirguna/printer-wasm: continue, label
|
|
40
|
+
- c958886 @putout/nirguna-printer-wasm: add support of multi-value return types
|
|
41
|
+
- eeb14d1 @putout/nirguna-parser-wasm: add support of block, loop, br, br_if
|
|
42
|
+
- 3ec6679 @nirguna/parser-wasm: export
|
|
43
|
+
- bc06507 @putout/nirguna-printer-wasm: add support of comments, fix double space and empty module
|
|
44
|
+
- 5f8aadd @nirguna/parser-wasm: comments
|
|
45
|
+
- bc2c4b1 @nirguna/parser-wasm: bin: add
|
|
46
|
+
- 90823be @nirguna/printer-wasm: bin: add
|
|
47
|
+
- 58b3fa5 @putout/nirguna-parser-wasm: add support of if/else
|
|
48
|
+
- 5b75b42 ModuleExports: add support
|
|
49
|
+
- c87630f @nirguna/parser-wasm: comments
|
|
50
|
+
- a99f106 @nirguna/parser-wasm: move out visitors
|
|
51
|
+
- db25ea1 @nirguna/parser-wasm: parse: visitors: module-import
|
|
52
|
+
- 8a52b9d @nirguna/parser-wasm: builders: move out
|
|
53
|
+
- fa287e1 @nirguna/parser-wasm: simplify
|
|
54
|
+
- 1236fad @nirguna/parser-wasm: improve import support
|
|
55
|
+
- aadfb59 @nirguna/parser-wasm: print: rm useless visitors
|
|
56
|
+
- e6c2b3b @nirguna/parser-wasm: simplify
|
|
57
|
+
- a3deb7c @putout/parser-wasm: split print/parse
|
|
58
|
+
- 5cb1313 @nirguna/parser-wasm: add
|
|
59
|
+
- 8e39c19 @nirguna/format-floppy: fatfs-wasm v4.0.0
|
|
60
|
+
- 3132486 nirguna: typescript v6.0.3
|
|
61
|
+
- 4ab3499 root: montag v2.0.1
|
|
62
|
+
- 63128ab root: eslint-plugin-n: drop
|
|
63
|
+
- 9ee2044 root: supertape v13.2.0
|
|
64
|
+
- 8a655c2 @putout/plugin-fasm: convert-function-to-label: rm dead code
|
|
65
|
+
- c81765d @putout/plugin-fasm: convert-linux-write-to-syscall: rm unused
|
|
66
|
+
- 1628a80 @putout/plugin-fasm: extract-labeled-block: rm unused
|
|
67
|
+
- 593a66c nemesis: get-char: includes
|
|
68
|
+
- 0f26697 @nirguna/plugin-fasm: split-includes-to-if-sequence: structuralClone
|
|
69
|
+
- e22846b nemesis: get-char: keys: move out
|
|
70
|
+
- 6522e88 @putout/plugin-fasm: split-include-to-if-sequence: add
|
|
71
|
+
|
|
72
|
+
2026.03.12, v1.2.4
|
|
73
|
+
|
|
74
|
+
fix:
|
|
75
|
+
- 04177ee nemesis: gets: rm cmp before if
|
|
76
|
+
|
|
77
|
+
feature:
|
|
78
|
+
- f141470 @nirguna/printer-fasm: @putout/printer v18.4.5
|
|
79
|
+
- 9c5da5b @nirguna/printer-wasm: @putout/plugin-printer v8.7.2
|
|
80
|
+
- 9db3c25 @nirguna/printer-fasm: @putout/plugin-printer v8.7.2
|
|
81
|
+
- fbe460f nemesis: mov out help
|
|
82
|
+
- 2bc5620 nemesis: dir -> ls
|
|
83
|
+
- e18914d nemesis: reuse constant
|
|
84
|
+
- 2942583 @nirguna/printer-wasm: coverage
|
|
85
|
+
- 996f6df @nirguna/printer-wasm: rm unused
|
|
86
|
+
- 0a82979 @nirguna/printer-wasm: FunctionDeclaration: rm unused
|
|
87
|
+
- 77ae252 @nirguna/printer-wasm: IfStatement: rm unused
|
|
88
|
+
- 2d1e42f @nigrung/printer-wasm: CallExpression: remove unused
|
|
89
|
+
- c45e041 @nirguna/printer-wasm: print-wasm-import: simplify
|
|
90
|
+
- 175531a @nirguna/printer-wasm: isWastMemory: simplify
|
|
91
|
+
- 42e64e2 @nirguna/printer-wasm: IfStatement: simplify
|
|
92
|
+
- b169a9d @nirguna/printer-wasm: IfStatement: simplify
|
|
93
|
+
|
|
1
94
|
2026.03.04, v1.2.3
|
|
2
95
|
|
|
3
96
|
feature:
|
package/README.md
CHANGED
|
@@ -68,7 +68,6 @@ Also we can compile it to binary representation with `nirguna fasm example/fn.ts
|
|
|
68
68
|
|
|
69
69
|
```sh
|
|
70
70
|
$ hexdump example/fn.bin
|
|
71
|
-
|
|
72
71
|
0000000 b866 0001 0000 bb66 0002 0000 0166 c3d8
|
|
73
72
|
0000010
|
|
74
73
|
```
|
|
@@ -133,6 +132,7 @@ const {x} = run(binary, {
|
|
|
133
132
|
});
|
|
134
133
|
|
|
135
134
|
x(1, 2);
|
|
135
|
+
|
|
136
136
|
// outputs
|
|
137
137
|
3;
|
|
138
138
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nirguna",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Compile JavaScript to WASM and FASM",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"@nirguna/printer-wasm": "^1.0.0",
|
|
44
44
|
"@nirguna/transformer-fasm": "^1.0.0",
|
|
45
45
|
"@nirguna/transformer-wasm": "^1.0.0",
|
|
46
|
+
"@nirguna/translator-fasm": "^1.0.0",
|
|
47
|
+
"@nirguna/translator-wasm": "^1.0.0",
|
|
46
48
|
"@putout/babel": "^5.2.12",
|
|
47
49
|
"@putout/plugin-assignment": "^2.0.0",
|
|
48
50
|
"@putout/plugin-esm": "^10.0.1",
|
|
49
51
|
"@putout/plugin-remove-nested-blocks": "^9.0.0",
|
|
50
52
|
"@putout/plugin-remove-useless-operand": "^3.0.0",
|
|
51
|
-
"@putout/printer": "^18.0.0",
|
|
52
53
|
"@typescript-eslint/typescript-estree": "^8.32.1",
|
|
53
54
|
"chalk": "^5.4.1",
|
|
54
|
-
"fasm.js": "^1.0.7",
|
|
55
55
|
"hexdump-nodejs": "^0.1.0",
|
|
56
56
|
"iced-x86": "^1.21.0",
|
|
57
57
|
"just-snake-case": "^3.2.0",
|
|
58
58
|
"putout": "^42.0.12",
|
|
59
59
|
"try-catch": "^4.0.9",
|
|
60
60
|
"try-to-catch": "^4.0.5",
|
|
61
|
-
"typescript": "^
|
|
61
|
+
"typescript": "^6.0.3",
|
|
62
62
|
"wabt": "^1.0.37",
|
|
63
63
|
"yargs-parser": "^22.0.0"
|
|
64
64
|
},
|
|
@@ -67,19 +67,16 @@
|
|
|
67
67
|
],
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@nirguna/operator-fasm": "^1.0.0",
|
|
70
|
-
"@nirguna/runner-wasm": "*",
|
|
71
|
-
"@putout/plugin-printer": "^7.1.1",
|
|
72
70
|
"@putout/test": "^15.1.1",
|
|
73
71
|
"eslint": "^10.0.1",
|
|
74
|
-
"eslint-plugin-n": "^17.0.0",
|
|
75
72
|
"eslint-plugin-putout": "^31.0.1",
|
|
76
73
|
"just-kebab-case": "^4.2.0",
|
|
77
74
|
"madrun": "^13.0.0",
|
|
78
|
-
"montag": "^
|
|
75
|
+
"montag": "^2.0.1",
|
|
79
76
|
"nodemon": "^3.0.1",
|
|
80
77
|
"redlint": "^6.1.1",
|
|
81
78
|
"superc8": "^12.0.0",
|
|
82
|
-
"supertape": "^
|
|
79
|
+
"supertape": "^13.2.0"
|
|
83
80
|
},
|
|
84
81
|
"imports": {
|
|
85
82
|
"#cli-args": "./packages/cli-args/index.js",
|
|
@@ -90,9 +87,7 @@
|
|
|
90
87
|
"#compiler-fasm": "./packages/compiler-fasm/compiler.js",
|
|
91
88
|
"#optimizer-fasm": "./packages/optimizer-fasm/optimizer.js",
|
|
92
89
|
"#optimizer-wasm": "./packages/optimizer-wasm/optimizer.js",
|
|
93
|
-
"#translator-wasm": "./packages/translator-wasm/translator.js",
|
|
94
90
|
"#test-wasm": "./packages/test-wasm/test.js",
|
|
95
|
-
"#translator-fasm": "./packages/translator-fasm/translator.js",
|
|
96
91
|
"#operator-wasm": "./packages/operator-wasm/index.js",
|
|
97
92
|
"#nirguna": "./lib/nirguna.js"
|
|
98
93
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {transform} from '@nirguna/transformer-fasm';
|
|
2
2
|
import {print} from '@nirguna/printer-fasm';
|
|
3
|
-
import {translate} from '
|
|
3
|
+
import {translate} from '@nirguna/translator-fasm';
|
|
4
4
|
import {optimize} from '#optimizer-fasm';
|
|
5
5
|
|
|
6
6
|
const noop = () => {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {transform} from '@nirguna/transformer-wasm';
|
|
2
2
|
import {print} from '@nirguna/printer-wasm';
|
|
3
|
-
import {translate} from '
|
|
3
|
+
import {translate} from '@nirguna/translator-wasm';
|
|
4
4
|
import {optimize} from '#optimizer-wasm';
|
|
5
5
|
|
|
6
6
|
const noop = () => {};
|
|
@@ -58,6 +58,6 @@ export const compile = async (source, options = {}) => {
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
emitLastStateChange('translate', places);
|
|
61
|
+
|
|
61
62
|
return [binary, places];
|
|
62
63
|
};
|
|
63
|
-
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Decoder,
|
|
3
|
-
DecoderOptions,
|
|
4
|
-
Formatter,
|
|
5
|
-
FormatterSyntax,
|
|
6
|
-
} from 'iced-x86';
|
|
7
|
-
|
|
8
|
-
function parseBitness(source) {
|
|
9
|
-
if (source.startsWith('use32'))
|
|
10
|
-
return 32;
|
|
11
|
-
|
|
12
|
-
return 16;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const dump = (source, binary) => {
|
|
16
|
-
const exampleRip = 0x0000000000007c00n;
|
|
17
|
-
const hexBytesColumnByteLength = 10;
|
|
18
|
-
const bitness = parseBitness(source);
|
|
19
|
-
|
|
20
|
-
const decoder = new Decoder(bitness, binary, DecoderOptions.None);
|
|
21
|
-
|
|
22
|
-
decoder.ip = exampleRip;
|
|
23
|
-
// This decodes all bytes. There's also `decode()` which decodes the next instruction,
|
|
24
|
-
// `decodeInstructions(count)` which decodes `count` instructions and `decodeOut(instruction)`
|
|
25
|
-
// which overwrites an existing instruction.
|
|
26
|
-
const instructions = decoder.decodeAll();
|
|
27
|
-
|
|
28
|
-
// Create a nasm formatter. It supports: Masm, Nasm, Gas (AT&T) and Intel (XED).
|
|
29
|
-
// There's also `FastFormatter` which uses less code (smaller wasm files).
|
|
30
|
-
// const formatter = new FastFormatter();
|
|
31
|
-
const formatter = new Formatter(FormatterSyntax.Intel);
|
|
32
|
-
|
|
33
|
-
// Change some options, there are many more
|
|
34
|
-
formatter.digitSeparator = '`';
|
|
35
|
-
formatter.firstOperandCharIndex = 10;
|
|
36
|
-
// Format the instructions
|
|
37
|
-
|
|
38
|
-
const output = instructions.map((instruction) => {
|
|
39
|
-
// Eg. "00007FFAC46ACDB2 488DAC2400FFFFFF lea rbp,[rsp-100h]"
|
|
40
|
-
let line = instruction.ip.toString(16);
|
|
41
|
-
|
|
42
|
-
line += ' ';
|
|
43
|
-
const startIndex = Number(instruction.ip - exampleRip);
|
|
44
|
-
|
|
45
|
-
for (const b of binary.slice(startIndex, startIndex + instruction.length)) {
|
|
46
|
-
line += ('0' + b.toString(16))
|
|
47
|
-
.substr(-2)
|
|
48
|
-
.toUpperCase();
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (let i = instruction.length; i < hexBytesColumnByteLength; i++)
|
|
52
|
-
line += ' ';
|
|
53
|
-
|
|
54
|
-
line += ' ';
|
|
55
|
-
line += formatter.format(instruction);
|
|
56
|
-
|
|
57
|
-
return line;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Free wasm memory
|
|
61
|
-
for (const instruction of instructions)
|
|
62
|
-
instruction.free();
|
|
63
|
-
|
|
64
|
-
formatter.free();
|
|
65
|
-
decoder.free();
|
|
66
|
-
|
|
67
|
-
return output.join('\n');
|
|
68
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as fasm from 'fasm.js';
|
|
2
|
-
import {dump} from './dump.js';
|
|
3
|
-
|
|
4
|
-
export const translate = async (source, options = {}) => {
|
|
5
|
-
const {type} = options;
|
|
6
|
-
const [binary, places] = await fasm.translate(source);
|
|
7
|
-
|
|
8
|
-
if (type === 'dump')
|
|
9
|
-
return [
|
|
10
|
-
dump(source, binary),
|
|
11
|
-
[],
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
return [binary, places];
|
|
15
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import createWabt from 'wabt';
|
|
2
|
-
import {tryCatch} from 'try-catch';
|
|
3
|
-
|
|
4
|
-
export const translate = async (wast, options = {}) => {
|
|
5
|
-
const {name = 'nirguna.wast', type} = options;
|
|
6
|
-
|
|
7
|
-
const {parseWat} = await createWabt();
|
|
8
|
-
const [error, parsedWat] = tryCatch(parseWat, name, wast);
|
|
9
|
-
|
|
10
|
-
if (error)
|
|
11
|
-
return [null, toPlaces(name, error)];
|
|
12
|
-
|
|
13
|
-
const {log, buffer} = parsedWat.toBinary({
|
|
14
|
-
log: type === 'dump',
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return [
|
|
18
|
-
log || buffer,
|
|
19
|
-
[],
|
|
20
|
-
];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
function toPlaces(name, error) {
|
|
24
|
-
const [, first] = error.message.split('\n');
|
|
25
|
-
|
|
26
|
-
const list = first
|
|
27
|
-
.replace(`${name}�`, '')
|
|
28
|
-
.split(':');
|
|
29
|
-
|
|
30
|
-
list.shift();
|
|
31
|
-
|
|
32
|
-
const [line, column] = list;
|
|
33
|
-
|
|
34
|
-
list.shift();
|
|
35
|
-
list.shift();
|
|
36
|
-
list.shift();
|
|
37
|
-
|
|
38
|
-
const messageRaw = list
|
|
39
|
-
.join(':')
|
|
40
|
-
.slice(1);
|
|
41
|
-
|
|
42
|
-
const message = messageRaw[0].toUpperCase() + messageRaw.slice(1);
|
|
43
|
-
|
|
44
|
-
return [{
|
|
45
|
-
message,
|
|
46
|
-
position: {
|
|
47
|
-
line: Number(line),
|
|
48
|
-
column: Number(column),
|
|
49
|
-
},
|
|
50
|
-
}];
|
|
51
|
-
}
|