nirguna 1.1.0 → 1.2.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.
- package/ChangeLog +30 -0
- package/package.json +4 -4
- package/packages/compiler-fasm/compiler.js +5 -2
- package/packages/compiler-wasm/compiler.js +1 -1
- package/packages/printer-fasm/printer/printer.js +0 -30
- package/packages/printer-fasm/printer/visitors/assignment-expression.js +0 -47
- package/packages/printer-fasm/printer/visitors/block-statement.js +0 -7
- package/packages/printer-fasm/printer/visitors/call-expression.js +0 -56
- package/packages/printer-fasm/printer/visitors/expression-statement/expression-statement.js +0 -34
- package/packages/printer-fasm/printer/visitors/expression-statement/print-in-out.js +0 -37
- package/packages/printer-fasm/printer/visitors/expression-statement/print-jmp-far.js +0 -30
- package/packages/printer-fasm/printer/visitors/labeled-statement.js +0 -14
- package/packages/printer-fasm/printer/visitors/member-expression.js +0 -5
- package/packages/printer-fasm/printer/visitors/sequence-expression.js +0 -17
- package/packages/printer-fasm/printer/visitors/string-literal.js +0 -55
- package/packages/printer-fasm/printer/visitors/tagged-template-expression.js +0 -4
- package/packages/printer-fasm/printer.js +0 -7
- package/packages/transformer-wasm/transformer.js +0 -20
package/ChangeLog
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
2026.03.02, v1.2.0
|
|
2
|
+
|
|
3
|
+
fix:
|
|
4
|
+
- 64da4e4 @putout/plugin-nirguna: putout version
|
|
5
|
+
|
|
6
|
+
feature:
|
|
7
|
+
- 1a9f176 @nirguna/printer-fasm: move out
|
|
8
|
+
- d77d729 nirguna: c8 -> superc8
|
|
9
|
+
- f46a6a7 @nirguna/plugin-fasm: apply-registers: remove uncovered
|
|
10
|
+
- 322637b @nirguna/plugin-bundler-fasm: apply-async: add
|
|
11
|
+
- 49c729a @nirguna/plugin-fasm: insert-target, convert-args-to-regs: move out targets
|
|
12
|
+
- 4ff8507 @nirguna/plugin-fasm: add-label-prefix: AwaitExpression
|
|
13
|
+
- 3fd806d @nirguna/plugin-wasm: apply-types: returnType
|
|
14
|
+
- 2c7cee8 root: c8 v11.0.0
|
|
15
|
+
|
|
16
|
+
2026.02.24, v1.1.1
|
|
17
|
+
|
|
18
|
+
fix:
|
|
19
|
+
- 5ba529b @putout/plugin-fasm: add-label-prefix: exclude CallExpression callee
|
|
20
|
+
- a6c2c3d @putout/plugin-fasm: insert-target: filter
|
|
21
|
+
|
|
22
|
+
feature:
|
|
23
|
+
- dde51ae @nirguna/transformer-wasm: publish
|
|
24
|
+
- c44bb5c @putout/plugin-wasm: convert-binary-to-call
|
|
25
|
+
- 4c250e1 @putout/plugin-wasm: convert-binary-to-function
|
|
26
|
+
- 448d50a @putout/plugin-wasm: apply-types: async
|
|
27
|
+
- 9f30e51 @putout/plugin-fasm: convert-args-to-regs: insert-target: improve support
|
|
28
|
+
- 8d44159 nemesis: target: boot, kernel, nemesis
|
|
29
|
+
- 0ab6c1f @putout/transform-fasm: insert-target
|
|
30
|
+
|
|
1
31
|
2026.02.22, v1.1.0
|
|
2
32
|
|
|
3
33
|
fix:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nirguna",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"@nirguna/plugin-optimizer-fasm": "^1.0.0",
|
|
40
40
|
"@nirguna/plugin-optimizer-wasm": "^1.0.0",
|
|
41
41
|
"@nirguna/plugin-wasm": "^1.0.0",
|
|
42
|
+
"@nirguna/printer-fasm": "^1.0.0",
|
|
42
43
|
"@nirguna/transformer-fasm": "^1.0.0",
|
|
44
|
+
"@nirguna/transformer-wasm": "^1.0.0",
|
|
43
45
|
"@putout/babel": "^5.2.12",
|
|
44
46
|
"@putout/plugin-assignment": "^2.0.0",
|
|
45
47
|
"@putout/plugin-esm": "^10.0.1",
|
|
@@ -67,7 +69,6 @@
|
|
|
67
69
|
"@nirguna/runner-wasm": "*",
|
|
68
70
|
"@putout/plugin-printer": "^7.1.1",
|
|
69
71
|
"@putout/test": "^15.1.1",
|
|
70
|
-
"c8": "^10.0.0",
|
|
71
72
|
"eslint": "^10.0.1",
|
|
72
73
|
"eslint-plugin-n": "^17.0.0",
|
|
73
74
|
"eslint-plugin-putout": "^31.0.1",
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
"montag": "^1.2.1",
|
|
77
78
|
"nodemon": "^3.0.1",
|
|
78
79
|
"redlint": "^6.1.1",
|
|
80
|
+
"superc8": "^12.0.0",
|
|
79
81
|
"supertape": "^12.4.0"
|
|
80
82
|
},
|
|
81
83
|
"imports": {
|
|
@@ -88,11 +90,9 @@
|
|
|
88
90
|
"#optimizer-fasm": "./packages/optimizer-fasm/optimizer.js",
|
|
89
91
|
"#optimizer-wasm": "./packages/optimizer-wasm/optimizer.js",
|
|
90
92
|
"#printer-wasm": "./packages/printer-wasm/printer.js",
|
|
91
|
-
"#printer-fasm": "./packages/printer-fasm/printer.js",
|
|
92
93
|
"#translator-wasm": "./packages/translator-wasm/translator.js",
|
|
93
94
|
"#test-wasm": "./packages/test-wasm/test.js",
|
|
94
95
|
"#translator-fasm": "./packages/translator-fasm/translator.js",
|
|
95
|
-
"#transformer-wasm": "./packages/transformer-wasm/transformer.js",
|
|
96
96
|
"#operator-wasm": "./packages/operator-wasm/index.js",
|
|
97
97
|
"#nirguna": "./lib/nirguna.js"
|
|
98
98
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {transform} from '@nirguna/transformer-fasm';
|
|
2
|
-
import {print} from '
|
|
2
|
+
import {print} from '@nirguna/printer-fasm';
|
|
3
3
|
import {translate} from '#translator-fasm';
|
|
4
4
|
import {optimize} from '#optimizer-fasm';
|
|
5
5
|
|
|
@@ -25,7 +25,10 @@ export const compile = async (source, options = {}) => {
|
|
|
25
25
|
places,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
const [code, compilePlaces] = transform(source,
|
|
28
|
+
const [code, compilePlaces] = transform(source, {
|
|
29
|
+
...config,
|
|
30
|
+
target,
|
|
31
|
+
});
|
|
29
32
|
|
|
30
33
|
if (compilePlaces.length) {
|
|
31
34
|
emitLastStateChange('transform', compilePlaces);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {print as putoutPrint} from '@putout/printer';
|
|
2
|
-
import {CallExpression} from './visitors/call-expression.js';
|
|
3
|
-
import {MemberExpression} from './visitors/member-expression.js';
|
|
4
|
-
import {BlockStatement} from './visitors/block-statement.js';
|
|
5
|
-
import {LabeledStatement} from './visitors/labeled-statement.js';
|
|
6
|
-
import {ExpressionStatement} from './visitors/expression-statement/expression-statement.js';
|
|
7
|
-
import {SequenceExpression} from './visitors/sequence-expression.js';
|
|
8
|
-
import {AssignmentExpression} from './visitors/assignment-expression.js';
|
|
9
|
-
import {TaggedTemplateExpression} from './visitors/tagged-template-expression.js';
|
|
10
|
-
import {StringLiteral} from './visitors/string-literal.js';
|
|
11
|
-
|
|
12
|
-
export const print = (ast) => {
|
|
13
|
-
return putoutPrint(ast, {
|
|
14
|
-
semantics: {
|
|
15
|
-
comments: false,
|
|
16
|
-
maxElementLengthInOneLine: 100,
|
|
17
|
-
},
|
|
18
|
-
visitors: {
|
|
19
|
-
AssignmentExpression,
|
|
20
|
-
CallExpression,
|
|
21
|
-
MemberExpression,
|
|
22
|
-
BlockStatement,
|
|
23
|
-
LabeledStatement,
|
|
24
|
-
ExpressionStatement,
|
|
25
|
-
SequenceExpression,
|
|
26
|
-
StringLiteral,
|
|
27
|
-
TaggedTemplateExpression,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {visitors, maybeVisitor} from '@putout/printer';
|
|
2
|
-
import {types} from '@putout/babel';
|
|
3
|
-
|
|
4
|
-
const {isMemberExpression} = types;
|
|
5
|
-
|
|
6
|
-
export const AssignmentExpression = (path, printer, semantics) => {
|
|
7
|
-
const left = path.get('left');
|
|
8
|
-
const right = path.get('right');
|
|
9
|
-
|
|
10
|
-
if (isMemberExpression(left) && left.node.computed) {
|
|
11
|
-
const {write, traverse} = printer;
|
|
12
|
-
const object = path.get('left.object');
|
|
13
|
-
const property = path.get('left.property');
|
|
14
|
-
|
|
15
|
-
write('mov ');
|
|
16
|
-
write('[');
|
|
17
|
-
traverse(object);
|
|
18
|
-
write(':');
|
|
19
|
-
traverse(property);
|
|
20
|
-
write(']');
|
|
21
|
-
write(',');
|
|
22
|
-
write.space();
|
|
23
|
-
traverse(right);
|
|
24
|
-
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (isMemberExpression(right) && right.node.computed) {
|
|
29
|
-
const {write, traverse} = printer;
|
|
30
|
-
const object = path.get('right.object');
|
|
31
|
-
const property = path.get('right.property');
|
|
32
|
-
|
|
33
|
-
write('mov ');
|
|
34
|
-
traverse(left);
|
|
35
|
-
write(',');
|
|
36
|
-
write.space();
|
|
37
|
-
write('[');
|
|
38
|
-
traverse(object);
|
|
39
|
-
write(':');
|
|
40
|
-
traverse(property);
|
|
41
|
-
write(']');
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return maybeVisitor(visitors.AssignmentExpression, path, printer, semantics);
|
|
47
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const {isArray} = Array;
|
|
2
|
-
|
|
3
|
-
const parseArgs = (path) => {
|
|
4
|
-
const argsPath = path.get('arguments');
|
|
5
|
-
|
|
6
|
-
if (!isArray(argsPath))
|
|
7
|
-
return [];
|
|
8
|
-
|
|
9
|
-
return argsPath;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function CallExpression(path, {indent, print, maybe, traverse}) {
|
|
13
|
-
const args = parseArgs(path);
|
|
14
|
-
const isParentCall = tooLong(args) && path.parentPath.isCallExpression();
|
|
15
|
-
|
|
16
|
-
const callee = path.get('callee');
|
|
17
|
-
|
|
18
|
-
traverse(callee);
|
|
19
|
-
|
|
20
|
-
maybe.print.space(args.length);
|
|
21
|
-
|
|
22
|
-
const n = args.length - 1;
|
|
23
|
-
|
|
24
|
-
maybe.indent.inc(isParentCall);
|
|
25
|
-
|
|
26
|
-
for (const [i, arg] of args.entries()) {
|
|
27
|
-
const isObject = arg.isObjectExpression();
|
|
28
|
-
|
|
29
|
-
if (isParentCall && !isObject && n)
|
|
30
|
-
print.breakline();
|
|
31
|
-
|
|
32
|
-
print(arg);
|
|
33
|
-
|
|
34
|
-
if (isParentCall && n) {
|
|
35
|
-
print(',');
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (i < n)
|
|
40
|
-
print(', ');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (isParentCall) {
|
|
44
|
-
indent.dec();
|
|
45
|
-
maybe.print.breakline(n);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function tooLong(args) {
|
|
50
|
-
for (const arg of args) {
|
|
51
|
-
if (arg.isIdentifier() && arg.node.name.length > 10)
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {isNext, exists} from '@putout/printer/is';
|
|
2
|
-
import {isJmpFar, printJmpFar} from './print-jmp-far.js';
|
|
3
|
-
import {isInOut, printInOut} from './print-in-out.js';
|
|
4
|
-
|
|
5
|
-
export const ExpressionStatement = (path, printer) => {
|
|
6
|
-
const {
|
|
7
|
-
maybe,
|
|
8
|
-
print,
|
|
9
|
-
indent,
|
|
10
|
-
traverse,
|
|
11
|
-
} = printer;
|
|
12
|
-
|
|
13
|
-
const expression = path.get('expression');
|
|
14
|
-
|
|
15
|
-
if (isJmpFar(expression)) {
|
|
16
|
-
printJmpFar(expression, printer);
|
|
17
|
-
maybe.print.breakline(isNext(path));
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (isInOut(expression)) {
|
|
23
|
-
printInOut(expression, printer);
|
|
24
|
-
print.breakline();
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
indent();
|
|
30
|
-
traverse(expression);
|
|
31
|
-
|
|
32
|
-
const next = path.getNextSibling();
|
|
33
|
-
maybe.print.newline(exists(next));
|
|
34
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
isCallExpression,
|
|
5
|
-
isMemberExpression,
|
|
6
|
-
} = types;
|
|
7
|
-
|
|
8
|
-
export const isInOut = (expression) => {
|
|
9
|
-
if (!isCallExpression(expression))
|
|
10
|
-
return false;
|
|
11
|
-
|
|
12
|
-
const {callee} = expression.node;
|
|
13
|
-
|
|
14
|
-
if (!isMemberExpression(callee))
|
|
15
|
-
return false;
|
|
16
|
-
|
|
17
|
-
const {object, property} = callee;
|
|
18
|
-
|
|
19
|
-
if (object.name !== 'io')
|
|
20
|
-
return false;
|
|
21
|
-
|
|
22
|
-
return /^(in|out)$/.test(property.name);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export function printInOut(path, printer) {
|
|
26
|
-
const {print} = printer;
|
|
27
|
-
const callee = path.get('callee');
|
|
28
|
-
const property = callee.get('property');
|
|
29
|
-
|
|
30
|
-
print(property);
|
|
31
|
-
print(' ');
|
|
32
|
-
const [arg1, arg2] = path.get('arguments');
|
|
33
|
-
|
|
34
|
-
print(arg1);
|
|
35
|
-
print(', ');
|
|
36
|
-
print(arg2);
|
|
37
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
isCallExpression,
|
|
5
|
-
isMemberExpression,
|
|
6
|
-
} = types;
|
|
7
|
-
|
|
8
|
-
export const isJmpFar = (expression) => {
|
|
9
|
-
if (!isCallExpression(expression))
|
|
10
|
-
return false;
|
|
11
|
-
|
|
12
|
-
const {callee} = expression.node;
|
|
13
|
-
|
|
14
|
-
if (!isMemberExpression(callee))
|
|
15
|
-
return false;
|
|
16
|
-
|
|
17
|
-
const {object, property} = callee;
|
|
18
|
-
|
|
19
|
-
return object.name === 'jmp' && property.name === 'far';
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function printJmpFar(path, printer) {
|
|
23
|
-
const {print} = printer;
|
|
24
|
-
const callee = path.get('callee');
|
|
25
|
-
const [first] = path.node.arguments;
|
|
26
|
-
|
|
27
|
-
print(callee);
|
|
28
|
-
print(' ');
|
|
29
|
-
print(first.value);
|
|
30
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {exists} from '@putout/printer/is';
|
|
2
|
-
|
|
3
|
-
export const LabeledStatement = (path, {print, maybe}) => {
|
|
4
|
-
const prev = path.getPrevSibling();
|
|
5
|
-
const next = path.getNextSibling();
|
|
6
|
-
|
|
7
|
-
maybe.print.breakline(exists(prev));
|
|
8
|
-
|
|
9
|
-
print('__label');
|
|
10
|
-
print(':');
|
|
11
|
-
print.breakline();
|
|
12
|
-
print('__body');
|
|
13
|
-
maybe.print.breakline(exists(next));
|
|
14
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {types} from '@putout/babel';
|
|
2
|
-
|
|
3
|
-
const {isMemberExpression} = types;
|
|
4
|
-
|
|
5
|
-
export const SequenceExpression = (path, {traverse, maybe, write}) => {
|
|
6
|
-
const expressions = path.get('expressions');
|
|
7
|
-
const n = expressions.length - 1;
|
|
8
|
-
|
|
9
|
-
for (const [i, expression] of expressions.entries()) {
|
|
10
|
-
traverse(expression);
|
|
11
|
-
|
|
12
|
-
if (isMemberExpression(expression) || n > 1 && i < n)
|
|
13
|
-
write(',');
|
|
14
|
-
|
|
15
|
-
maybe.write(i < n, ' ');
|
|
16
|
-
}
|
|
17
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export const StringLiteral = (path, {write}, semantics) => {
|
|
2
|
-
const {value, raw = `'${value}'`} = path.node;
|
|
3
|
-
|
|
4
|
-
if (path.parentPath.isJSXAttribute()) {
|
|
5
|
-
write(`"${value}"`);
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const newValue = raw.slice(1, -1);
|
|
10
|
-
write.quote();
|
|
11
|
-
write(maybeEscape(newValue, semantics));
|
|
12
|
-
write.quote();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const maybeEscape = (value, {escapeDoubleQuote, escapeSingleQuote}) => {
|
|
16
|
-
const list = value.split('');
|
|
17
|
-
const slash = '\\';
|
|
18
|
-
|
|
19
|
-
if (escapeSingleQuote)
|
|
20
|
-
return escape(list, {
|
|
21
|
-
slash,
|
|
22
|
-
quote: `'`,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (escapeDoubleQuote)
|
|
26
|
-
return escape(list, {
|
|
27
|
-
slash,
|
|
28
|
-
quote: `"`,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return value;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const escape = (list, {slash, quote}) => {
|
|
35
|
-
const result = [];
|
|
36
|
-
|
|
37
|
-
for (const [index, char] of list.entries()) {
|
|
38
|
-
const prev = list[index - 1];
|
|
39
|
-
const next = list[index + 1];
|
|
40
|
-
|
|
41
|
-
if (char === slash && next === quote) {
|
|
42
|
-
result.push(quote);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (char === quote && prev !== slash) {
|
|
47
|
-
result.push(`${slash}${char}`);
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
result.push(char);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return result.join('');
|
|
55
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import putout from 'putout';
|
|
2
|
-
import * as removeNestedBlocks from '@putout/plugin-remove-nested-blocks';
|
|
3
|
-
import * as esm from '@putout/plugin-esm';
|
|
4
|
-
import * as nirguna from '@nirguna/plugin-nirguna';
|
|
5
|
-
import * as wasm from '@nirguna/plugin-wasm';
|
|
6
|
-
|
|
7
|
-
export const transform = (source) => {
|
|
8
|
-
const {code, places} = putout(source, {
|
|
9
|
-
fix: true,
|
|
10
|
-
isTS: true,
|
|
11
|
-
plugins: [
|
|
12
|
-
['nirguna/wasm', wasm],
|
|
13
|
-
['nirguna/nirguna', nirguna],
|
|
14
|
-
['esm', esm],
|
|
15
|
-
['remove-nested-blocks', removeNestedBlocks],
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return [code, places];
|
|
20
|
-
};
|