mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-07 19:14:37 +01:00
Fixed ram evaluation to include more edge-cases (#665)
This commit is contained in:
@ -270,13 +270,13 @@ function parseOnlyCalculateDeps(code: string, currentModule: string): ParseDepsR
|
||||
|
||||
// References get added pessimistically. They are added for thisModule.name, name, and for
|
||||
// any aliases.
|
||||
function addRef(key: string, name: string): void {
|
||||
function addRef(key: string, name: string, module = currentModule): void {
|
||||
const s = dependencyMap[key] || (dependencyMap[key] = new Set());
|
||||
const external = internalToExternal[name];
|
||||
if (external !== undefined) {
|
||||
s.add(external);
|
||||
}
|
||||
s.add(currentModule + "." + name);
|
||||
s.add(module + "." + name);
|
||||
s.add(name); // For builtins like hack.
|
||||
}
|
||||
|
||||
@ -366,10 +366,19 @@ function parseOnlyCalculateDeps(code: string, currentModule: string): ParseDepsR
|
||||
walkDeeper(node.declaration, st);
|
||||
return;
|
||||
}
|
||||
const specifiers = node.specifiers;
|
||||
|
||||
for (const specifier of specifiers) {
|
||||
addRef(st.key, specifier.local.name);
|
||||
for (const specifier of node.specifiers) {
|
||||
const exportedDepName = currentModule + "." + specifier.exported.name;
|
||||
|
||||
if (node.source !== null) {
|
||||
// if this is true, we are re-exporting something
|
||||
addRef(exportedDepName, specifier.local.name, node.source.value);
|
||||
additionalModules.push(node.source.value);
|
||||
} else if (specifier.exported.name !== specifier.local.name) {
|
||||
// this makes sure we are not refering to ourselves
|
||||
// if this is not true, we don't need to add anything
|
||||
addRef(exportedDepName, specifier.local.name);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user