@nirguna/plugin-fasm 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/README.md
CHANGED
|
@@ -46,4 +46,4 @@ Transforms:
|
|
|
46
46
|
- ✅[`remove-useless-braces`](https://putout.cloudcmd.io/#/gist/140689014540d48d501c1fa50b3694ca/e1521db4f951c38c17a6c3af46456c47f1f3a1a8);
|
|
47
47
|
- ✅[`remove-useless-promise`](https://putout.cloudcmd.io/#/gist/d21eb87bc77b53e54c28b1ae8442a403/1b35064142068e623a564f578517c2aace55ceba);
|
|
48
48
|
- ✅[`switch-cmp-operands`](https://putout.cloudcmd.io/#/gist/cdf71331f1024c9c966d4756c6159684/9d3f2ebeb41cd096de7919f0c39bc75cbaf5ce0c);
|
|
49
|
-
- ✅[`insert-target`](https://putout.cloudcmd.io/#/gist/e7e3f495fdfde1b065117fc0ae41873c/b6fe3dc81d33c81d332ce5d551b8a2fb40b63d70);
|
|
49
|
+
- ✅[`insert-target`](https://putout.cloudcmd.io/#/gist/e7e3f495fdfde1b065117fc0ae41873c/b6fe3dc81d33c81d332ce5d551b8a2fb40b63d70);
|
|
@@ -41,8 +41,15 @@ function getIds(path, name) {
|
|
|
41
41
|
if (isMemberExpression(path.parentPath))
|
|
42
42
|
return;
|
|
43
43
|
|
|
44
|
-
if (name
|
|
45
|
-
|
|
44
|
+
if (name !== path.node.name)
|
|
45
|
+
return;
|
|
46
|
+
|
|
47
|
+
const calleePath = path.parentPath.get('callee');
|
|
48
|
+
|
|
49
|
+
if (calleePath === path)
|
|
50
|
+
return;
|
|
51
|
+
|
|
52
|
+
ids.push(path);
|
|
46
53
|
},
|
|
47
54
|
});
|
|
48
55
|
|
|
@@ -80,6 +80,21 @@ export const replace = () => ({
|
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
+
const TARGET = {
|
|
84
|
+
linux: {
|
|
85
|
+
size: 8,
|
|
86
|
+
bits: 'i64',
|
|
87
|
+
},
|
|
88
|
+
kernel: {
|
|
89
|
+
size: 2,
|
|
90
|
+
bits: 'i16',
|
|
91
|
+
},
|
|
92
|
+
boot: {
|
|
93
|
+
size: 2,
|
|
94
|
+
bits: 'i16',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
83
98
|
const REG = {
|
|
84
99
|
i16: {
|
|
85
100
|
eax: 'ax',
|
|
@@ -104,7 +119,19 @@ const BYTES = {
|
|
|
104
119
|
i64: 8,
|
|
105
120
|
};
|
|
106
121
|
|
|
122
|
+
function getTarget({scope}) {
|
|
123
|
+
const programPath = scope.getProgramParent().path;
|
|
124
|
+
const {target} = programPath.node.extra;
|
|
125
|
+
|
|
126
|
+
return target;
|
|
127
|
+
}
|
|
128
|
+
|
|
107
129
|
function getBytes(path) {
|
|
130
|
+
const target = getTarget(path);
|
|
131
|
+
|
|
132
|
+
if (target)
|
|
133
|
+
return TARGET[target].size;
|
|
134
|
+
|
|
108
135
|
const {returnType} = path.node;
|
|
109
136
|
|
|
110
137
|
if (!returnType)
|
|
@@ -116,6 +143,14 @@ function getBytes(path) {
|
|
|
116
143
|
}
|
|
117
144
|
|
|
118
145
|
function getRegister(path, reg) {
|
|
146
|
+
const target = getTarget(path);
|
|
147
|
+
|
|
148
|
+
if (target) {
|
|
149
|
+
const {bits} = TARGET[target];
|
|
150
|
+
|
|
151
|
+
return REG[bits][reg];
|
|
152
|
+
}
|
|
153
|
+
|
|
119
154
|
const {returnType} = path.node;
|
|
120
155
|
|
|
121
156
|
if (!returnType)
|
|
@@ -15,9 +15,14 @@ const TARGET = {
|
|
|
15
15
|
}`,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export const report = (path, {
|
|
18
|
+
export const report = (path, {options}) => {
|
|
19
|
+
const {target} = options;
|
|
20
|
+
return `Insert target: '${target}'`;
|
|
21
|
+
};
|
|
19
22
|
|
|
20
|
-
export const fix = (path, {
|
|
23
|
+
export const fix = (path, {options}) => {
|
|
24
|
+
const {target} = options;
|
|
25
|
+
|
|
21
26
|
path.node.extra.target = target;
|
|
22
27
|
path.node.body.unshift(template.ast(TARGET[target]));
|
|
23
28
|
};
|
package/package.json
CHANGED