vitest-pool-assemblyscript 0.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/BINARYEN_VERSION +1 -0
- package/LICENSE +53 -0
- package/README.md +607 -0
- package/assembly/compare.ts +219 -0
- package/assembly/describe.ts +104 -0
- package/assembly/expect.ts +335 -0
- package/assembly/index.ts +14 -0
- package/assembly/options.ts +198 -0
- package/assembly/test.ts +147 -0
- package/assembly/tsconfig.json +6 -0
- package/binding.gyp +62 -0
- package/dist/ast-visitor-DC3SuTzs.mjs +310 -0
- package/dist/ast-visitor-DC3SuTzs.mjs.map +1 -0
- package/dist/compile-runner-8h0dBwG2.mjs +80 -0
- package/dist/compile-runner-8h0dBwG2.mjs.map +1 -0
- package/dist/compiler/transforms/strip-inline.d.mts +18 -0
- package/dist/compiler/transforms/strip-inline.d.mts.map +1 -0
- package/dist/compiler/transforms/strip-inline.mjs +38 -0
- package/dist/compiler/transforms/strip-inline.mjs.map +1 -0
- package/dist/compiler-CN6BRK_N.mjs +295 -0
- package/dist/compiler-CN6BRK_N.mjs.map +1 -0
- package/dist/config/index-v3.d.mts +111 -0
- package/dist/config/index-v3.d.mts.map +1 -0
- package/dist/config/index-v3.mjs +11 -0
- package/dist/config/index-v3.mjs.map +1 -0
- package/dist/config/index.d.mts +4 -0
- package/dist/config/index.mjs +8 -0
- package/dist/constants-CA50WBdr.mjs +130 -0
- package/dist/constants-CA50WBdr.mjs.map +1 -0
- package/dist/coverage-merge-0WqdC-dq.mjs +22 -0
- package/dist/coverage-merge-0WqdC-dq.mjs.map +1 -0
- package/dist/coverage-provider/index.d.mts +15 -0
- package/dist/coverage-provider/index.d.mts.map +1 -0
- package/dist/coverage-provider/index.mjs +535 -0
- package/dist/coverage-provider/index.mjs.map +1 -0
- package/dist/custom-provider-options-CF5C1kXb.d.mts +26 -0
- package/dist/custom-provider-options-CF5C1kXb.d.mts.map +1 -0
- package/dist/debug-IeEHsxy0.mjs +195 -0
- package/dist/debug-IeEHsxy0.mjs.map +1 -0
- package/dist/index-internal.d.mts +23 -0
- package/dist/index-internal.d.mts.map +1 -0
- package/dist/index-internal.mjs +4 -0
- package/dist/index-v3.d.mts +7 -0
- package/dist/index-v3.d.mts.map +1 -0
- package/dist/index-v3.mjs +206 -0
- package/dist/index-v3.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +8 -0
- package/dist/load-user-imports-J9eaAW0_.mjs +801 -0
- package/dist/load-user-imports-J9eaAW0_.mjs.map +1 -0
- package/dist/pool-runner-init-CEwLyNI3.d.mts +8 -0
- package/dist/pool-runner-init-CEwLyNI3.d.mts.map +1 -0
- package/dist/pool-runner-init-d5qScS41.mjs +400 -0
- package/dist/pool-runner-init-d5qScS41.mjs.map +1 -0
- package/dist/pool-thread/compile-worker-thread.d.mts +7 -0
- package/dist/pool-thread/compile-worker-thread.d.mts.map +1 -0
- package/dist/pool-thread/compile-worker-thread.mjs +42 -0
- package/dist/pool-thread/compile-worker-thread.mjs.map +1 -0
- package/dist/pool-thread/test-worker-thread.d.mts +7 -0
- package/dist/pool-thread/test-worker-thread.d.mts.map +1 -0
- package/dist/pool-thread/test-worker-thread.mjs +39 -0
- package/dist/pool-thread/test-worker-thread.mjs.map +1 -0
- package/dist/pool-thread/v3-tinypool-thread.d.mts +7 -0
- package/dist/pool-thread/v3-tinypool-thread.d.mts.map +1 -0
- package/dist/pool-thread/v3-tinypool-thread.mjs +57 -0
- package/dist/pool-thread/v3-tinypool-thread.mjs.map +1 -0
- package/dist/resolve-config-as1w-Qyz.mjs +65 -0
- package/dist/resolve-config-as1w-Qyz.mjs.map +1 -0
- package/dist/test-runner-B2BpyPNK.mjs +142 -0
- package/dist/test-runner-B2BpyPNK.mjs.map +1 -0
- package/dist/types-8KKo9Hbf.d.mts +228 -0
- package/dist/types-8KKo9Hbf.d.mts.map +1 -0
- package/dist/vitest-file-tasks-BUwzh375.mjs +61 -0
- package/dist/vitest-file-tasks-BUwzh375.mjs.map +1 -0
- package/dist/vitest-tasks-BKS7689f.mjs +319 -0
- package/dist/vitest-tasks-BKS7689f.mjs.map +1 -0
- package/dist/worker-rpc-channel-lbhK7Qz8.mjs +25 -0
- package/dist/worker-rpc-channel-lbhK7Qz8.mjs.map +1 -0
- package/package.json +112 -0
- package/prebuilds/linux-x64/vitest-pool-assemblyscript.glibc.node +0 -0
- package/scripts/install.js +91 -0
- package/scripts/setup-binaryen.js +179 -0
- package/src/native-instrumentation/addon.cpp +788 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { ASNodeKind } from "./constants-CA50WBdr.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/util/ast-visitor.ts
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for AST visitors.
|
|
6
|
+
*
|
|
7
|
+
* Subclasses override hook methods to perform tasks during traversal:
|
|
8
|
+
* - beforeVisit: Called before visiting each node (e.g., strip decorators)
|
|
9
|
+
* - onFunctionDeclaration: Called when visiting a function declaration
|
|
10
|
+
* - onMethodDeclaration: Called when visiting a method declaration
|
|
11
|
+
* - onVariableDeclaration: Called when visiting a variable declaration
|
|
12
|
+
* - onClassEnter/onClassExit: Called when entering/exiting a class
|
|
13
|
+
*/
|
|
14
|
+
var ASTVisitor = class {
|
|
15
|
+
/**
|
|
16
|
+
* Visit all statements in a source file
|
|
17
|
+
*/
|
|
18
|
+
visitSource(source) {
|
|
19
|
+
for (const stmt of source.statements) this.visitNode(stmt);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hook called before visiting each node.
|
|
23
|
+
* Override to perform pre-visit tasks (e.g., stripping decorators).
|
|
24
|
+
*/
|
|
25
|
+
beforeVisit(_node) {}
|
|
26
|
+
/**
|
|
27
|
+
* Hook called when entering a class declaration.
|
|
28
|
+
* Override to track class context.
|
|
29
|
+
*/
|
|
30
|
+
onClassEnter(_node) {}
|
|
31
|
+
/**
|
|
32
|
+
* Hook called when exiting a class declaration.
|
|
33
|
+
* Override to restore class context.
|
|
34
|
+
*/
|
|
35
|
+
onClassExit(_node) {}
|
|
36
|
+
/**
|
|
37
|
+
* Hook called when visiting a function declaration.
|
|
38
|
+
* Override to extract function info or perform other tasks.
|
|
39
|
+
* Return false to skip recursing into the function body.
|
|
40
|
+
*/
|
|
41
|
+
onFunctionDeclaration(_node) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hook called when visiting a method declaration.
|
|
46
|
+
* Override to extract method info or perform other tasks.
|
|
47
|
+
* Return false to skip recursing into the method body.
|
|
48
|
+
*/
|
|
49
|
+
onMethodDeclaration(_node) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Hook called when visiting a variable declaration.
|
|
54
|
+
* Override to handle variable declarations (e.g., arrow functions).
|
|
55
|
+
* Return false to skip recursing into the initializer.
|
|
56
|
+
*/
|
|
57
|
+
onVariableDeclaration(_node) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Main visitor dispatch - routes to specific handler based on node kind
|
|
62
|
+
*/
|
|
63
|
+
visitNode(node) {
|
|
64
|
+
this.beforeVisit(node);
|
|
65
|
+
switch (node.kind) {
|
|
66
|
+
case ASNodeKind.NamedType:
|
|
67
|
+
case ASNodeKind.FunctionType:
|
|
68
|
+
case ASNodeKind.TypeName:
|
|
69
|
+
case ASNodeKind.TypeParameter: break;
|
|
70
|
+
case ASNodeKind.Parameter: {
|
|
71
|
+
const param = node;
|
|
72
|
+
if (param.initializer) this.visitNode(param.initializer);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case ASNodeKind.Identifier:
|
|
76
|
+
case ASNodeKind.False:
|
|
77
|
+
case ASNodeKind.Literal:
|
|
78
|
+
case ASNodeKind.Null:
|
|
79
|
+
case ASNodeKind.Omitted:
|
|
80
|
+
case ASNodeKind.Super:
|
|
81
|
+
case ASNodeKind.This:
|
|
82
|
+
case ASNodeKind.True:
|
|
83
|
+
case ASNodeKind.Constructor:
|
|
84
|
+
case ASNodeKind.Compiled: break;
|
|
85
|
+
case ASNodeKind.Assertion: {
|
|
86
|
+
const expr = node;
|
|
87
|
+
this.visitNode(expr.expression);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case ASNodeKind.Binary: {
|
|
91
|
+
const expr = node;
|
|
92
|
+
this.visitNode(expr.left);
|
|
93
|
+
this.visitNode(expr.right);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case ASNodeKind.Call: {
|
|
97
|
+
const expr = node;
|
|
98
|
+
this.visitNode(expr.expression);
|
|
99
|
+
for (const arg of expr.args) this.visitNode(arg);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case ASNodeKind.Class: {
|
|
103
|
+
const expr = node;
|
|
104
|
+
this.visitNode(expr.declaration);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case ASNodeKind.Comma: {
|
|
108
|
+
const expr = node;
|
|
109
|
+
for (const e of expr.expressions) this.visitNode(e);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case ASNodeKind.ElementAccess: {
|
|
113
|
+
const expr = node;
|
|
114
|
+
this.visitNode(expr.expression);
|
|
115
|
+
this.visitNode(expr.elementExpression);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case ASNodeKind.Function: {
|
|
119
|
+
const expr = node;
|
|
120
|
+
this.visitNode(expr.declaration);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case ASNodeKind.InstanceOf: {
|
|
124
|
+
const expr = node;
|
|
125
|
+
this.visitNode(expr.expression);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case ASNodeKind.New: {
|
|
129
|
+
const expr = node;
|
|
130
|
+
for (const arg of expr.args) this.visitNode(arg);
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case ASNodeKind.Parenthesized: {
|
|
134
|
+
const expr = node;
|
|
135
|
+
this.visitNode(expr.expression);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case ASNodeKind.PropertyAccess: {
|
|
139
|
+
const expr = node;
|
|
140
|
+
this.visitNode(expr.expression);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case ASNodeKind.Ternary: {
|
|
144
|
+
const expr = node;
|
|
145
|
+
this.visitNode(expr.condition);
|
|
146
|
+
this.visitNode(expr.ifThen);
|
|
147
|
+
this.visitNode(expr.ifElse);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case ASNodeKind.UnaryPostfix: {
|
|
151
|
+
const expr = node;
|
|
152
|
+
this.visitNode(expr.operand);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case ASNodeKind.UnaryPrefix: {
|
|
156
|
+
const expr = node;
|
|
157
|
+
this.visitNode(expr.operand);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case ASNodeKind.Break:
|
|
161
|
+
case ASNodeKind.Continue:
|
|
162
|
+
case ASNodeKind.Empty:
|
|
163
|
+
case ASNodeKind.Export:
|
|
164
|
+
case ASNodeKind.ExportDefault:
|
|
165
|
+
case ASNodeKind.ExportImport:
|
|
166
|
+
case ASNodeKind.Import:
|
|
167
|
+
case ASNodeKind.Module: break;
|
|
168
|
+
case ASNodeKind.Block: {
|
|
169
|
+
const stmt = node;
|
|
170
|
+
for (const s of stmt.statements) this.visitNode(s);
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case ASNodeKind.Do: {
|
|
174
|
+
const stmt = node;
|
|
175
|
+
this.visitNode(stmt.body);
|
|
176
|
+
this.visitNode(stmt.condition);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case ASNodeKind.Expression: {
|
|
180
|
+
const stmt = node;
|
|
181
|
+
this.visitNode(stmt.expression);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case ASNodeKind.For: {
|
|
185
|
+
const stmt = node;
|
|
186
|
+
if (stmt.initializer) this.visitNode(stmt.initializer);
|
|
187
|
+
if (stmt.condition) this.visitNode(stmt.condition);
|
|
188
|
+
if (stmt.incrementor) this.visitNode(stmt.incrementor);
|
|
189
|
+
this.visitNode(stmt.body);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case ASNodeKind.ForOf: {
|
|
193
|
+
const stmt = node;
|
|
194
|
+
this.visitNode(stmt.variable);
|
|
195
|
+
this.visitNode(stmt.iterable);
|
|
196
|
+
this.visitNode(stmt.body);
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
case ASNodeKind.If: {
|
|
200
|
+
const stmt = node;
|
|
201
|
+
this.visitNode(stmt.condition);
|
|
202
|
+
this.visitNode(stmt.ifTrue);
|
|
203
|
+
if (stmt.ifFalse) this.visitNode(stmt.ifFalse);
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
case ASNodeKind.Return: {
|
|
207
|
+
const stmt = node;
|
|
208
|
+
if (stmt.value) this.visitNode(stmt.value);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case ASNodeKind.Switch: {
|
|
212
|
+
const stmt = node;
|
|
213
|
+
this.visitNode(stmt.condition);
|
|
214
|
+
for (const switchCase of stmt.cases) this.visitNode(switchCase);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case ASNodeKind.Throw: {
|
|
218
|
+
const stmt = node;
|
|
219
|
+
this.visitNode(stmt.value);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case ASNodeKind.Try: {
|
|
223
|
+
const stmt = node;
|
|
224
|
+
for (const s of stmt.bodyStatements) this.visitNode(s);
|
|
225
|
+
if (stmt.catchStatements) for (const s of stmt.catchStatements) this.visitNode(s);
|
|
226
|
+
if (stmt.finallyStatements) for (const s of stmt.finallyStatements) this.visitNode(s);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
case ASNodeKind.Variable: {
|
|
230
|
+
const stmt = node;
|
|
231
|
+
for (const decl of stmt.declarations) this.visitNode(decl);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case ASNodeKind.Void: {
|
|
235
|
+
const stmt = node;
|
|
236
|
+
this.visitNode(stmt.expression);
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case ASNodeKind.While: {
|
|
240
|
+
const stmt = node;
|
|
241
|
+
this.visitNode(stmt.condition);
|
|
242
|
+
this.visitNode(stmt.body);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
case ASNodeKind.SwitchCase: {
|
|
246
|
+
const stmt = node;
|
|
247
|
+
if (stmt.label) this.visitNode(stmt.label);
|
|
248
|
+
for (const s of stmt.statements) this.visitNode(s);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case ASNodeKind.ImportDeclaration:
|
|
252
|
+
case ASNodeKind.TypeDeclaration: break;
|
|
253
|
+
case ASNodeKind.ClassDeclaration: {
|
|
254
|
+
const decl = node;
|
|
255
|
+
this.onClassEnter(decl);
|
|
256
|
+
for (const member of decl.members) this.visitNode(member);
|
|
257
|
+
this.onClassExit(decl);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
case ASNodeKind.EnumDeclaration: {
|
|
261
|
+
const decl = node;
|
|
262
|
+
for (const value of decl.values) this.visitNode(value);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
case ASNodeKind.EnumValueDeclaration: {
|
|
266
|
+
const decl = node;
|
|
267
|
+
if (decl.initializer) this.visitNode(decl.initializer);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case ASNodeKind.FieldDeclaration: {
|
|
271
|
+
const decl = node;
|
|
272
|
+
if (decl.initializer) this.visitNode(decl.initializer);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
case ASNodeKind.FunctionDeclaration: {
|
|
276
|
+
const decl = node;
|
|
277
|
+
if (this.onFunctionDeclaration(decl) && decl.body) this.visitNode(decl.body);
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case ASNodeKind.InterfaceDeclaration: {
|
|
281
|
+
const decl = node;
|
|
282
|
+
for (const member of decl.members) this.visitNode(member);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
case ASNodeKind.MethodDeclaration: {
|
|
286
|
+
const decl = node;
|
|
287
|
+
if (this.onMethodDeclaration(decl) && decl.body) this.visitNode(decl.body);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case ASNodeKind.NamespaceDeclaration: {
|
|
291
|
+
const decl = node;
|
|
292
|
+
for (const member of decl.members) this.visitNode(member);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
case ASNodeKind.VariableDeclaration: {
|
|
296
|
+
const decl = node;
|
|
297
|
+
if (this.onVariableDeclaration(decl) && decl.initializer) this.visitNode(decl.initializer);
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case ASNodeKind.ExportMember:
|
|
301
|
+
case ASNodeKind.IndexSignature:
|
|
302
|
+
case ASNodeKind.Comment:
|
|
303
|
+
case ASNodeKind.Decorator: break;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
export { ASTVisitor };
|
|
310
|
+
//# sourceMappingURL=ast-visitor-DC3SuTzs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-visitor-DC3SuTzs.mjs","names":[],"sources":["../src/util/ast-visitor.ts"],"sourcesContent":["/**\n * Base AST Visitor for AssemblyScript\n *\n * Provides reusable walking logic for traversing AS AST nodes.\n * Subclasses override hook methods to perform specific tasks.\n *\n * Used by:\n * - ast-parser.ts: Extract function metadata for coverage\n * - strip-inline.mts: Strip @inline decorators\n */\n\nimport {\n Node,\n Source,\n BlockStatement,\n FunctionDeclaration,\n MethodDeclaration,\n ClassDeclaration,\n NamespaceDeclaration,\n VariableStatement,\n VariableDeclaration,\n FunctionExpression,\n ExpressionStatement,\n BinaryExpression,\n PropertyAccessExpression,\n IfStatement,\n WhileStatement,\n DoStatement,\n ForStatement,\n ForOfStatement,\n SwitchStatement,\n SwitchCase,\n TryStatement,\n ThrowStatement,\n ReturnStatement,\n CallExpression,\n NewExpression,\n ParenthesizedExpression,\n TernaryExpression,\n CommaExpression,\n AssertionExpression,\n InstanceOfExpression,\n ElementAccessExpression,\n UnaryPostfixExpression,\n UnaryPrefixExpression,\n ClassExpression,\n ParameterNode,\n EnumDeclaration,\n EnumValueDeclaration,\n FieldDeclaration,\n InterfaceDeclaration,\n VoidStatement,\n} from 'assemblyscript';\n\nimport { ASNodeKind } from '../types/constants.js';\n\n/**\n * Abstract base class for AST visitors.\n *\n * Subclasses override hook methods to perform tasks during traversal:\n * - beforeVisit: Called before visiting each node (e.g., strip decorators)\n * - onFunctionDeclaration: Called when visiting a function declaration\n * - onMethodDeclaration: Called when visiting a method declaration\n * - onVariableDeclaration: Called when visiting a variable declaration\n * - onClassEnter/onClassExit: Called when entering/exiting a class\n */\nexport abstract class ASTVisitor {\n /**\n * Visit all statements in a source file\n */\n visitSource(source: Source): void {\n for (const stmt of source.statements) {\n this.visitNode(stmt);\n }\n }\n\n /**\n * Hook called before visiting each node.\n * Override to perform pre-visit tasks (e.g., stripping decorators).\n */\n protected beforeVisit(_node: Node): void {}\n\n /**\n * Hook called when entering a class declaration.\n * Override to track class context.\n */\n protected onClassEnter(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when exiting a class declaration.\n * Override to restore class context.\n */\n protected onClassExit(_node: ClassDeclaration): void {}\n\n /**\n * Hook called when visiting a function declaration.\n * Override to extract function info or perform other tasks.\n * Return false to skip recursing into the function body.\n */\n protected onFunctionDeclaration(_node: FunctionDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a method declaration.\n * Override to extract method info or perform other tasks.\n * Return false to skip recursing into the method body.\n */\n protected onMethodDeclaration(_node: MethodDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Hook called when visiting a variable declaration.\n * Override to handle variable declarations (e.g., arrow functions).\n * Return false to skip recursing into the initializer.\n */\n protected onVariableDeclaration(_node: VariableDeclaration): boolean {\n return true; // Continue recursion by default\n }\n\n /**\n * Main visitor dispatch - routes to specific handler based on node kind\n */\n visitNode(node: Node): void {\n // Call pre-visit hook\n this.beforeVisit(node);\n\n // Recurse into children based on node kind\n switch (node.kind) {\n // Type nodes - no children to visit\n case ASNodeKind.NamedType:\n case ASNodeKind.FunctionType:\n case ASNodeKind.TypeName:\n case ASNodeKind.TypeParameter:\n break;\n\n // Parameter - may have default value\n case ASNodeKind.Parameter: {\n const param = node as ParameterNode;\n if (param.initializer) this.visitNode(param.initializer);\n break;\n }\n\n // Simple expressions - no children\n case ASNodeKind.Identifier:\n case ASNodeKind.False:\n case ASNodeKind.Literal:\n case ASNodeKind.Null:\n case ASNodeKind.Omitted:\n case ASNodeKind.Super:\n case ASNodeKind.This:\n case ASNodeKind.True:\n case ASNodeKind.Constructor:\n case ASNodeKind.Compiled:\n break;\n\n // Expressions with children\n case ASNodeKind.Assertion: {\n const expr = node as AssertionExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Binary: {\n const expr = node as BinaryExpression;\n this.visitNode(expr.left);\n this.visitNode(expr.right);\n break;\n }\n case ASNodeKind.Call: {\n const expr = node as CallExpression;\n this.visitNode(expr.expression);\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Class: {\n const expr = node as ClassExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.Comma: {\n const expr = node as CommaExpression;\n for (const e of expr.expressions) this.visitNode(e);\n break;\n }\n case ASNodeKind.ElementAccess: {\n const expr = node as ElementAccessExpression;\n this.visitNode(expr.expression);\n this.visitNode(expr.elementExpression);\n break;\n }\n case ASNodeKind.Function: {\n const expr = node as FunctionExpression;\n this.visitNode(expr.declaration);\n break;\n }\n case ASNodeKind.InstanceOf: {\n const expr = node as InstanceOfExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.New: {\n const expr = node as NewExpression;\n for (const arg of expr.args) this.visitNode(arg);\n break;\n }\n case ASNodeKind.Parenthesized: {\n const expr = node as ParenthesizedExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.PropertyAccess: {\n const expr = node as PropertyAccessExpression;\n this.visitNode(expr.expression);\n break;\n }\n case ASNodeKind.Ternary: {\n const expr = node as TernaryExpression;\n this.visitNode(expr.condition);\n this.visitNode(expr.ifThen);\n this.visitNode(expr.ifElse);\n break;\n }\n case ASNodeKind.UnaryPostfix: {\n const expr = node as UnaryPostfixExpression;\n this.visitNode(expr.operand);\n break;\n }\n case ASNodeKind.UnaryPrefix: {\n const expr = node as UnaryPrefixExpression;\n this.visitNode(expr.operand);\n break;\n }\n\n // Statements with no interesting children\n case ASNodeKind.Break:\n case ASNodeKind.Continue:\n case ASNodeKind.Empty:\n case ASNodeKind.Export:\n case ASNodeKind.ExportDefault:\n case ASNodeKind.ExportImport:\n case ASNodeKind.Import:\n case ASNodeKind.Module:\n break;\n\n // Statements with children\n case ASNodeKind.Block: {\n const stmt = node as BlockStatement;\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n case ASNodeKind.Do: {\n const stmt = node as DoStatement;\n this.visitNode(stmt.body);\n this.visitNode(stmt.condition);\n break;\n }\n case ASNodeKind.Expression: {\n const stmt = node as ExpressionStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.For: {\n const stmt = node as ForStatement;\n if (stmt.initializer) this.visitNode(stmt.initializer);\n if (stmt.condition) this.visitNode(stmt.condition);\n if (stmt.incrementor) this.visitNode(stmt.incrementor);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.ForOf: {\n const stmt = node as ForOfStatement;\n this.visitNode(stmt.variable);\n this.visitNode(stmt.iterable);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.If: {\n const stmt = node as IfStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.ifTrue);\n if (stmt.ifFalse) this.visitNode(stmt.ifFalse);\n break;\n }\n case ASNodeKind.Return: {\n const stmt = node as ReturnStatement;\n if (stmt.value) this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Switch: {\n const stmt = node as SwitchStatement;\n this.visitNode(stmt.condition);\n for (const switchCase of stmt.cases) this.visitNode(switchCase);\n break;\n }\n case ASNodeKind.Throw: {\n const stmt = node as ThrowStatement;\n this.visitNode(stmt.value);\n break;\n }\n case ASNodeKind.Try: {\n const stmt = node as TryStatement;\n for (const s of stmt.bodyStatements) this.visitNode(s);\n if (stmt.catchStatements) {\n for (const s of stmt.catchStatements) this.visitNode(s);\n }\n if (stmt.finallyStatements) {\n for (const s of stmt.finallyStatements) this.visitNode(s);\n }\n break;\n }\n case ASNodeKind.Variable: {\n const stmt = node as VariableStatement;\n for (const decl of stmt.declarations) this.visitNode(decl);\n break;\n }\n case ASNodeKind.Void: {\n const stmt = node as VoidStatement;\n this.visitNode(stmt.expression);\n break;\n }\n case ASNodeKind.While: {\n const stmt = node as WhileStatement;\n this.visitNode(stmt.condition);\n this.visitNode(stmt.body);\n break;\n }\n case ASNodeKind.SwitchCase: {\n const stmt = node as SwitchCase;\n if (stmt.label) this.visitNode(stmt.label);\n for (const s of stmt.statements) this.visitNode(s);\n break;\n }\n\n // Declaration statements\n case ASNodeKind.ImportDeclaration:\n case ASNodeKind.TypeDeclaration:\n break;\n\n case ASNodeKind.ClassDeclaration: {\n const decl = node as ClassDeclaration;\n this.onClassEnter(decl);\n for (const member of decl.members) this.visitNode(member);\n this.onClassExit(decl);\n break;\n }\n case ASNodeKind.EnumDeclaration: {\n const decl = node as EnumDeclaration;\n for (const value of decl.values) this.visitNode(value);\n break;\n }\n case ASNodeKind.EnumValueDeclaration: {\n const decl = node as EnumValueDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FieldDeclaration: {\n const decl = node as FieldDeclaration;\n if (decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n case ASNodeKind.FunctionDeclaration: {\n const decl = node as FunctionDeclaration;\n const shouldRecurse = this.onFunctionDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.InterfaceDeclaration: {\n const decl = node as InterfaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.MethodDeclaration: {\n const decl = node as MethodDeclaration;\n const shouldRecurse = this.onMethodDeclaration(decl);\n if (shouldRecurse && decl.body) this.visitNode(decl.body);\n break;\n }\n case ASNodeKind.NamespaceDeclaration: {\n const decl = node as NamespaceDeclaration;\n for (const member of decl.members) this.visitNode(member);\n break;\n }\n case ASNodeKind.VariableDeclaration: {\n const decl = node as VariableDeclaration;\n const shouldRecurse = this.onVariableDeclaration(decl);\n if (shouldRecurse && decl.initializer) this.visitNode(decl.initializer);\n break;\n }\n\n // Special nodes - no action needed\n case ASNodeKind.ExportMember:\n case ASNodeKind.IndexSignature:\n case ASNodeKind.Comment:\n case ASNodeKind.Decorator:\n break;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkEA,IAAsB,aAAtB,MAAiC;;;;CAI/B,YAAY,QAAsB;AAChC,OAAK,MAAM,QAAQ,OAAO,WACxB,MAAK,UAAU,KAAK;;;;;;CAQxB,AAAU,YAAY,OAAmB;;;;;CAMzC,AAAU,aAAa,OAA+B;;;;;CAMtD,AAAU,YAAY,OAA+B;;;;;;CAOrD,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;;;CAQT,AAAU,oBAAoB,OAAmC;AAC/D,SAAO;;;;;;;CAQT,AAAU,sBAAsB,OAAqC;AACnE,SAAO;;;;;CAMT,UAAU,MAAkB;AAE1B,OAAK,YAAY,KAAK;AAGtB,UAAQ,KAAK,MAAb;GAEE,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,cACd;GAGF,KAAK,WAAW,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,KAAK;AACvB,SAAK,MAAM,UAAU,KAAK,QAAS,MAAK,UAAU,OAAO;AACzD,SAAK,YAAY,KAAK;AACtB;;GAEF,KAAK,WAAW,iBAAiB;IAC/B,MAAM,OAAO;AACb,SAAK,MAAM,SAAS,KAAK,OAAQ,MAAK,UAAU,MAAM;AACtD;;GAEF,KAAK,WAAW,sBAAsB;IACpC,MAAM,OAAO;AACb,QAAI,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACtD;;GAEF,KAAK,WAAW,kBAAkB;IAChC,MAAM,OAAO;AACb,QAAI,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACtD;;GAEF,KAAK,WAAW,qBAAqB;IACnC,MAAM,OAAO;AAEb,QADsB,KAAK,sBAAsB,KAAK,IACjC,KAAK,KAAM,MAAK,UAAU,KAAK,KAAK;AACzD;;GAEF,KAAK,WAAW,sBAAsB;IACpC,MAAM,OAAO;AACb,SAAK,MAAM,UAAU,KAAK,QAAS,MAAK,UAAU,OAAO;AACzD;;GAEF,KAAK,WAAW,mBAAmB;IACjC,MAAM,OAAO;AAEb,QADsB,KAAK,oBAAoB,KAAK,IAC/B,KAAK,KAAM,MAAK,UAAU,KAAK,KAAK;AACzD;;GAEF,KAAK,WAAW,sBAAsB;IACpC,MAAM,OAAO;AACb,SAAK,MAAM,UAAU,KAAK,QAAS,MAAK,UAAU,OAAO;AACzD;;GAEF,KAAK,WAAW,qBAAqB;IACnC,MAAM,OAAO;AAEb,QADsB,KAAK,sBAAsB,KAAK,IACjC,KAAK,YAAa,MAAK,UAAU,KAAK,YAAY;AACvE;;GAIF,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW;GAChB,KAAK,WAAW,UACd"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { POOL_ERROR_NAMES, POOL_INTERNAL_PATHS } from "./constants-CA50WBdr.mjs";
|
|
2
|
+
import { createPoolErrorFromAnyError, debug, getTestErrorFromPoolError } from "./debug-IeEHsxy0.mjs";
|
|
3
|
+
import { failFile, getFullTaskHierarchy, prepareFileTaskForCollection } from "./vitest-file-tasks-BUwzh375.mjs";
|
|
4
|
+
import { getTaskLogLabel, getTaskLogPrefix } from "./vitest-tasks-BKS7689f.mjs";
|
|
5
|
+
import { executeWASMDiscovery, flushRpcUpdates, reportFileCollected, reportFileError, reportFileQueued, reportUserConsoleLogs } from "./load-user-imports-J9eaAW0_.mjs";
|
|
6
|
+
import { compileAssemblyScript } from "./compiler-CN6BRK_N.mjs";
|
|
7
|
+
import { basename, relative } from "node:path";
|
|
8
|
+
|
|
9
|
+
//#region src/pool-thread/runner/compile-runner.ts
|
|
10
|
+
/**
|
|
11
|
+
* Worker thread test runner logic for AssemblyScript Pool
|
|
12
|
+
*/
|
|
13
|
+
let threadCompilationCount = 0;
|
|
14
|
+
async function runCompileAndDiscover(file, logModule, rpc, poolOptions, projectRoot, collectCoverage, relativeUserCoverageExclusions, threadImports, diffOptions, testNamePattern, allowOnly) {
|
|
15
|
+
const base = basename(file.filepath);
|
|
16
|
+
const fileLogPrefix = getTaskLogPrefix(logModule, base, file);
|
|
17
|
+
const fileLogLabel = getTaskLogLabel(base, file);
|
|
18
|
+
debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for "${file.filepath}" at ${Date.now()}`);
|
|
19
|
+
const runStart = performance.now();
|
|
20
|
+
let compilation;
|
|
21
|
+
try {
|
|
22
|
+
await reportFileQueued(rpc, file, logModule, fileLogLabel);
|
|
23
|
+
const instrumentationOptions = {
|
|
24
|
+
relativeExcludedFiles: [
|
|
25
|
+
relative(projectRoot, file.filepath),
|
|
26
|
+
...POOL_INTERNAL_PATHS,
|
|
27
|
+
...relativeUserCoverageExclusions
|
|
28
|
+
],
|
|
29
|
+
excludedLibraryFilePrefix: "~lib/",
|
|
30
|
+
coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,
|
|
31
|
+
coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax
|
|
32
|
+
};
|
|
33
|
+
const compilerOptions = {
|
|
34
|
+
stripInline: poolOptions.stripInline,
|
|
35
|
+
projectRoot,
|
|
36
|
+
shouldInstrument: collectCoverage,
|
|
37
|
+
instrumentationOptions,
|
|
38
|
+
extraFlags: poolOptions.extraCompilerFlags
|
|
39
|
+
};
|
|
40
|
+
const { binary, sourceMap, debugInfo, compileTiming } = await compileAssemblyScript(file.filepath, compilerOptions, logModule, fileLogLabel);
|
|
41
|
+
file.setupDuration = compileTiming;
|
|
42
|
+
threadCompilationCount++;
|
|
43
|
+
debug(`${fileLogPrefix} - TIMING compileAssemblyScript total (thread comp # ${threadCompilationCount}): ${compileTiming.toFixed(2)} ms`);
|
|
44
|
+
const logMessages = [];
|
|
45
|
+
const handleLog = (msg, isError = false) => {
|
|
46
|
+
logMessages.push({
|
|
47
|
+
msg,
|
|
48
|
+
time: Date.now(),
|
|
49
|
+
isError
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const discoverStart = performance.now();
|
|
53
|
+
await executeWASMDiscovery(binary, sourceMap, base, poolOptions, collectCoverage, handleLog, file, logModule, threadImports, diffOptions);
|
|
54
|
+
prepareFileTaskForCollection(file, testNamePattern, allowOnly);
|
|
55
|
+
file.collectDuration = performance.now() - discoverStart;
|
|
56
|
+
debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);
|
|
57
|
+
await Promise.all([reportUserConsoleLogs(rpc, logMessages, logModule, base, file), reportFileCollected(rpc, file, logModule, fileLogLabel)]);
|
|
58
|
+
debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\n${getFullTaskHierarchy(file)}`);
|
|
59
|
+
debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${(performance.now() - runStart).toFixed(2)} ms`);
|
|
60
|
+
compilation = {
|
|
61
|
+
filePath: file.filepath,
|
|
62
|
+
binary,
|
|
63
|
+
sourceMap,
|
|
64
|
+
debugInfo
|
|
65
|
+
};
|
|
66
|
+
} catch (error) {
|
|
67
|
+
failFile(file, getTestErrorFromPoolError(createPoolErrorFromAnyError(`${fileLogLabel} - runCompileAndDiscover failure in worker`, POOL_ERROR_NAMES.WASMExecutionHarnessError, error)), runStart);
|
|
68
|
+
await reportFileQueued(rpc, file, logModule, fileLogLabel);
|
|
69
|
+
await reportFileError(rpc, file, logModule, fileLogLabel);
|
|
70
|
+
debug(`${fileLogPrefix} - Reported file error`);
|
|
71
|
+
} finally {
|
|
72
|
+
await flushRpcUpdates(rpc);
|
|
73
|
+
debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);
|
|
74
|
+
}
|
|
75
|
+
return compilation;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { runCompileAndDiscover };
|
|
80
|
+
//# sourceMappingURL=compile-runner-8h0dBwG2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-runner-8h0dBwG2.mjs","names":[],"sources":["../src/pool-thread/runner/compile-runner.ts"],"sourcesContent":["/**\n * Worker thread test runner logic for AssemblyScript Pool\n */\n\nimport { basename, relative } from 'node:path';\nimport type { File } from '@vitest/runner/types';\nimport type { SerializedDiffOptions } from '@vitest/utils/diff';\n\nimport type {\n AssemblyScriptCompilerOptions,\n AssemblyScriptConsoleLog,\n AssemblyScriptConsoleLogHandler,\n InstrumentationOptions,\n ResolvedAssemblyScriptPoolOptions,\n ThreadImports,\n WASMCompilation,\n WorkerRPC,\n} from '../../types/types.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n POOL_ERROR_NAMES,\n POOL_INTERNAL_PATHS,\n} from '../../types/constants.js';\nimport { executeWASMDiscovery } from '../../wasm-executor/index.js';\nimport { debug } from '../../util/debug.js';\nimport {\n reportFileQueued,\n reportFileCollected,\n reportUserConsoleLogs,\n flushRpcUpdates,\n reportFileError,\n} from '../rpc-reporter.js';\nimport { createPoolErrorFromAnyError, getTestErrorFromPoolError } from '../../util/pool-errors.js';\nimport { compileAssemblyScript } from '../../compiler/index.js';\nimport {\n getTaskLogLabel,\n getTaskLogPrefix,\n} from '../../util/vitest-tasks.js';\nimport {\n failFile,\n getFullTaskHierarchy,\n prepareFileTaskForCollection,\n} from '../../util/vitest-file-tasks.js';\n\nlet threadCompilationCount: number = 0;\n\nexport async function runCompileAndDiscover(\n file: File,\n logModule: string,\n rpc: WorkerRPC,\n poolOptions: ResolvedAssemblyScriptPoolOptions,\n projectRoot: string,\n collectCoverage: boolean,\n relativeUserCoverageExclusions: string[],\n threadImports: ThreadImports,\n diffOptions?: SerializedDiffOptions,\n testNamePattern?: RegExp,\n allowOnly?: boolean,\n): Promise<WASMCompilation | undefined> {\n const base = basename(file.filepath);\n const fileLogPrefix = getTaskLogPrefix(logModule, base, file);\n const fileLogLabel = getTaskLogLabel(base, file);\n\n debug(`${fileLogPrefix} - Beginning runCompileAndDiscover for \"${file.filepath}\" at ${Date.now()}`);\n\n const runStart = performance.now();\n let compilation: WASMCompilation | undefined;\n\n try {\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n\n // TODO - move to options helpers\n const relativeTestFilePath = relative(projectRoot, file.filepath);\n const instrumentationOptions: InstrumentationOptions = {\n relativeExcludedFiles: [\n relativeTestFilePath,\n ...POOL_INTERNAL_PATHS,\n ...relativeUserCoverageExclusions,\n ],\n excludedLibraryFilePrefix: ASSEMBLYSCRIPT_LIB_PREFIX,\n coverageMemoryPagesMin: poolOptions.coverageMemoryPagesInitial,\n coverageMemoryPagesMax: poolOptions.coverageMemoryPagesMax,\n };\n const compilerOptions: AssemblyScriptCompilerOptions = {\n stripInline: poolOptions.stripInline,\n projectRoot: projectRoot,\n shouldInstrument: collectCoverage,\n instrumentationOptions,\n extraFlags: poolOptions.extraCompilerFlags\n };\n\n const { binary, sourceMap, debugInfo, compileTiming } = await compileAssemblyScript(\n file.filepath,\n compilerOptions,\n logModule,\n fileLogLabel\n );\n file.setupDuration = compileTiming;\n threadCompilationCount++;\n\n debug(`${fileLogPrefix} - TIMING compileAssemblyScript total `\n + `(thread comp # ${threadCompilationCount}): ${compileTiming.toFixed(2)} ms`\n );\n \n const logMessages: AssemblyScriptConsoleLog[] = [];\n const handleLog: AssemblyScriptConsoleLogHandler = (msg: string, isError: boolean = false): void => {\n logMessages.push({ msg, time: Date.now(), isError });\n };\n \n const discoverStart = performance.now();\n\n await executeWASMDiscovery(\n binary,\n sourceMap,\n base,\n poolOptions,\n collectCoverage,\n handleLog,\n file,\n logModule,\n threadImports,\n diffOptions\n );\n\n // set skips when using only and/or user test name pattern, skip file task if all tests skipped\n prepareFileTaskForCollection(file, testNamePattern, allowOnly);\n\n file.collectDuration = performance.now() - discoverStart;\n debug(`${fileLogPrefix} - TIMING Discovery Phase: ${file.collectDuration.toFixed(2)} ms`);\n\n // vitest collect - report discovery results\n await Promise.all([\n // Report user console logs\n reportUserConsoleLogs(rpc, logMessages, logModule, base, file),\n\n // Report onCollected with collected and filtered tasks\n reportFileCollected(rpc, file, logModule, fileLogLabel),\n ]);\n\n debug(() => `${fileLogPrefix} - Collected Test Suite Hierarchy:\\n${getFullTaskHierarchy(file)}`);\n\n const totalTime = performance.now() - runStart;\n debug(`${fileLogPrefix} - TIMING Compilation and Discovery: ${totalTime.toFixed(2)} ms`);\n\n compilation = {\n filePath: file.filepath,\n binary,\n sourceMap,\n debugInfo,\n };\n } catch (error) {\n const poolError = createPoolErrorFromAnyError(\n `${fileLogLabel} - runCompileAndDiscover failure in worker`,\n POOL_ERROR_NAMES.WASMExecutionHarnessError,\n error\n );\n const testError = getTestErrorFromPoolError(poolError);\n\n failFile(file, testError, runStart);\n\n await reportFileQueued(rpc, file, logModule, fileLogLabel);\n await reportFileError(rpc, file, logModule, fileLogLabel);\n\n debug(`${fileLogPrefix} - Reported file error`);\n } finally {\n await flushRpcUpdates(rpc);\n debug(`${fileLogPrefix} - runCompileAndDiscover Completed`);\n }\n\n return compilation;\n}\n"],"mappings":";;;;;;;;;;;;AA4CA,IAAI,yBAAiC;AAErC,eAAsB,sBACpB,MAC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AAoB,KAAK,MAAM,WAAW,aAAa,CACxD,CAAC;AAEF,cAAY,GAAG,cAAc,sCAAsC,qBAAqB,KAAK,GAAG;AAGhG,QAAM,GAAG,cAAc,wCADL,YAAY,KAAK,GAAG,UACkC,QAAQ,EAAE,CAAC,KAAK;AAExF,gBAAc;GACZ,UAAU,KAAK;GACf;GACA;GACA;GACD;UACM,OAAO;AAQd,WAAS,MAFS,0BALA,4BAChB,GAAG,aAAa,6CAChB,iBAAiB,2BACjB,MACD,CACqD,EAE5B,SAAS;AAEnC,QAAM,iBAAiB,KAAK,MAAM,WAAW,aAAa;AAC1D,QAAM,gBAAgB,KAAK,MAAM,WAAW,aAAa;AAEzD,QAAM,GAAG,cAAc,wBAAwB;WACvC;AACR,QAAM,gBAAgB,IAAI;AAC1B,QAAM,GAAG,cAAc,oCAAoC;;AAG7D,QAAO"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Parser } from "assemblyscript";
|
|
2
|
+
import { Transform } from "assemblyscript/transform";
|
|
3
|
+
|
|
4
|
+
//#region src/compiler/transforms/strip-inline.d.mts
|
|
5
|
+
/**
|
|
6
|
+
* AssemblyScript compiler transform that strips @inline decorators
|
|
7
|
+
*/
|
|
8
|
+
declare class StripInlineTransform extends Transform {
|
|
9
|
+
private visitor;
|
|
10
|
+
/**
|
|
11
|
+
* Called after parsing is complete, before the program is initialized.
|
|
12
|
+
* This is the ideal time to modify the AST.
|
|
13
|
+
*/
|
|
14
|
+
afterParse(_parser: Parser): void;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { StripInlineTransform as default };
|
|
18
|
+
//# sourceMappingURL=strip-inline.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-inline.d.mts","names":[],"sources":["../../../src/compiler/transforms/strip-inline.mts"],"mappings":";;;;;;;cA+CM,oBAAA,SAA6B,SAAA;EAAA,QACzB,OAAA;;;;;EAMR,UAAA,CAAW,OAAA,EAAS,MAAA;AAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ASDecoratorKind, ASSourceKind } from "../../constants-CA50WBdr.mjs";
|
|
2
|
+
import { ASTVisitor } from "../../ast-visitor-DC3SuTzs.mjs";
|
|
3
|
+
import { Transform } from "assemblyscript/transform";
|
|
4
|
+
|
|
5
|
+
//#region src/compiler/transforms/strip-inline.mts
|
|
6
|
+
/**
|
|
7
|
+
* Visitor that strips @inline decorators from nodes
|
|
8
|
+
*/
|
|
9
|
+
var StripInlineVisitor = class extends ASTVisitor {
|
|
10
|
+
/**
|
|
11
|
+
* Strip @inline decorator from a node if present
|
|
12
|
+
*/
|
|
13
|
+
beforeVisit(node) {
|
|
14
|
+
if ("decorators" in node && node.decorators) {
|
|
15
|
+
const filtered = node.decorators.filter((decorator) => decorator.decoratorKind !== ASDecoratorKind.Inline);
|
|
16
|
+
node.decorators = filtered.length > 0 ? filtered : null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* AssemblyScript compiler transform that strips @inline decorators
|
|
22
|
+
*/
|
|
23
|
+
var StripInlineTransform = class extends Transform {
|
|
24
|
+
visitor = new StripInlineVisitor();
|
|
25
|
+
/**
|
|
26
|
+
* Called after parsing is complete, before the program is initialized.
|
|
27
|
+
* This is the ideal time to modify the AST.
|
|
28
|
+
*/
|
|
29
|
+
afterParse(_parser) {
|
|
30
|
+
const userSources = this.program.sources.filter((source) => (source.sourceKind === ASSourceKind.User || source.sourceKind === ASSourceKind.UserEntry) && !source.normalizedPath.startsWith("~lib/"));
|
|
31
|
+
for (const source of userSources) this.visitor.visitSource(source);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var strip_inline_default = StripInlineTransform;
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { strip_inline_default as default };
|
|
38
|
+
//# sourceMappingURL=strip-inline.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-inline.mjs","names":[],"sources":["../../../src/compiler/transforms/strip-inline.mts"],"sourcesContent":["/**\n * AssemblyScript Transform to strip @inline decorators\n *\n * Production code uses @inline decorators for performance. When functions are inlined,\n * coverage instrumentation can't track their execution. This transform removes @inline\n * decorators from the AST during test compilation, allowing coverage instrumentation\n * to properly track function calls.\n * \n * - Hooks into the AssemblyScript compiler's `afterParse` lifecycle\n * - Walks through all parsed source files before compilation begins\n * - Uses shared ASTVisitor to recurse into ALL node types\n * - Strips @inline decorators from any node that has them in user code\n *\n * @see https://www.assemblyscript.org/compiler.html#transforms\n * @see https://github.com/AssemblyScript/assemblyscript/blob/main/src/ast.ts\n */\n\nimport { Node, Parser, Source, DecoratorNode } from 'assemblyscript';\nimport { Transform } from 'assemblyscript/transform';\n\nimport { ASTVisitor } from '../../util/ast-visitor.js';\nimport {\n ASSEMBLYSCRIPT_LIB_PREFIX,\n ASDecoratorKind,\n ASSourceKind,\n} from '../../types/constants.js';\n\n/**\n * Visitor that strips @inline decorators from nodes\n */\nclass StripInlineVisitor extends ASTVisitor {\n /**\n * Strip @inline decorator from a node if present\n */\n protected beforeVisit(node: Node): void {\n if ('decorators' in node && node.decorators) {\n const filtered = (node.decorators as DecoratorNode[]).filter(\n (decorator: DecoratorNode) => decorator.decoratorKind !== ASDecoratorKind.Inline\n );\n node.decorators = filtered.length > 0 ? filtered : null;\n }\n }\n}\n\n/**\n * AssemblyScript compiler transform that strips @inline decorators\n */\nclass StripInlineTransform extends Transform {\n private visitor = new StripInlineVisitor();\n\n /**\n * Called after parsing is complete, before the program is initialized.\n * This is the ideal time to modify the AST.\n */\n afterParse(_parser: Parser): void {\n const sources = (this as Transform).program.sources;\n\n // Filter to user source files only\n const userSources = sources.filter((source: Source) =>\n (source.sourceKind === ASSourceKind.User || source.sourceKind === ASSourceKind.UserEntry)\n && !source.normalizedPath.startsWith(ASSEMBLYSCRIPT_LIB_PREFIX)\n );\n\n for (const source of userSources) {\n this.visitor.visitSource(source);\n }\n }\n}\n\nexport default StripInlineTransform;\n"],"mappings":";;;;;;;;AA8BA,IAAM,qBAAN,cAAiC,WAAW;;;;CAI1C,AAAU,YAAY,MAAkB;AACtC,MAAI,gBAAgB,QAAQ,KAAK,YAAY;GAC3C,MAAM,WAAY,KAAK,WAA+B,QACnD,cAA6B,UAAU,kBAAkB,gBAAgB,OAC3E;AACD,QAAK,aAAa,SAAS,SAAS,IAAI,WAAW;;;;;;;AAQzD,IAAM,uBAAN,cAAmC,UAAU;CAC3C,AAAQ,UAAU,IAAI,oBAAoB;;;;;CAM1C,WAAW,SAAuB;EAIhC,MAAM,cAHW,KAAmB,QAAQ,QAGhB,QAAQ,YACjC,OAAO,eAAe,aAAa,QAAQ,OAAO,eAAe,aAAa,cAC5E,CAAC,OAAO,eAAe,mBAAqC,CAChE;AAED,OAAK,MAAM,UAAU,YACnB,MAAK,QAAQ,YAAY,OAAO;;;AAKtC,2BAAe"}
|