MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / VariableDeclaration

Function VariableDeclaration

tools/acorn-optimizer.mjs:250–271  ·  view source on GitHub ↗
(node, _c)

Source from the content-addressed store, hash-verified

248 c(node.body);
249 },
250 VariableDeclaration(node, _c) {
251 let removedHere = 0;
252 node.declarations = node.declarations.filter((node) => {
253 assert(node.type === 'VariableDeclarator');
254 let keep = node.init && hasSideEffects(node.init);
255 walkPattern(
256 node.id,
257 (value) => {
258 keep ||= hasSideEffects(value);
259 },
260 (boundName) => {
261 keep ||= !names.has(boundName);
262 },
263 );
264 if (!keep) removedHere = 1;
265 return keep;
266 });
267 removed += removedHere;
268 if (node.declarations.length === 0) {
269 emptyOut(node);
270 }
271 },
272 ExpressionStatement(node, _c) {
273 if (aggressive && !hasSideEffects(node)) {
274 emptyOut(node);

Callers

nothing calls this directly

Calls 6

hasSideEffectsFunction · 0.85
walkPatternFunction · 0.85
emptyOutFunction · 0.85
hasMethod · 0.80
assertFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected