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

Function getTransitiveDeps

src/jsifier.mjs:131–152  ·  view source on GitHub ↗
(symbol)

Source from the content-addressed store, hash-verified

129}
130
131function getTransitiveDeps(symbol) {
132 // TODO(sbc): Use some kind of cache to avoid quadratic behaviour here.
133 const transitiveDeps = new Set();
134 const seen = new Set();
135 const toVisit = [symbol];
136 while (toVisit.length) {
137 const sym = toVisit.pop();
138 if (!seen.has(sym)) {
139 let directDeps = LibraryManager.library[sym + '__deps'] ?? [];
140 directDeps = directDeps.filter((d) => typeof d === 'string');
141 for (const dep of directDeps) {
142 if (!transitiveDeps.has(dep)) {
143 debugLog(`adding dependency ${symbol} -> ${dep}`);
144 }
145 transitiveDeps.add(dep);
146 toVisit.push(dep);
147 }
148 seen.add(sym);
149 }
150 }
151 return Array.from(transitiveDeps);
152}
153
154function shouldPreprocess(fileName) {
155 var content = readFile(fileName).trim();

Callers 1

addFromLibraryFunction · 0.85

Calls 6

debugLogFunction · 0.90
hasMethod · 0.80
popMethod · 0.45
addMethod · 0.45
pushMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected