RELEASE_AND_RETURN & fix indirect checking

This commit is contained in:
pfg
2024-12-13 19:48:08 -08:00
parent d1dd1b9e13
commit a655ad26e5
2 changed files with 8 additions and 7 deletions

View File

@@ -77,16 +77,18 @@ pub const ModuleInfo = struct {
/// find any exports marked as 'local' that are actually 'indirect' and fix them
pub fn fixupIndirectExports(self: *ModuleInfo) !void {
var local_name_to_module_name = std.AutoArrayHashMap(StringID, StringID).init(self.strings.allocator);
var local_name_to_module_name = std.AutoArrayHashMap(StringID, *ImportInfo).init(self.strings.allocator);
defer local_name_to_module_name.deinit();
for (self.imports.items) |*ip| {
try local_name_to_module_name.put(ip.local_name, ip.module_name);
try local_name_to_module_name.put(ip.local_name, ip);
}
for (self.exports.items) |*xp| {
if (xp.* == .local) {
if (local_name_to_module_name.get(xp.local.local_name)) |im| {
xp.* = .{ .indirect = .{ .export_name = xp.local.export_name, .import_name = xp.local.local_name, .module_name = im } };
if (local_name_to_module_name.get(xp.local.local_name)) |ip| {
if (ip.kind == .single) {
xp.* = .{ .indirect = .{ .export_name = xp.local.export_name, .import_name = ip.import_name, .module_name = ip.module_name } };
}
}
}
}

View File

@@ -218,12 +218,11 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj
dumpRecordInfo(moduleRecord);
zig_log_cstr("\n \x1b[91m</Actual Record Info>\x1b(B\x1b[m", "");
scope.release();
if (compare) {
return fallbackParse(globalObject, moduleKey, sourceCode, promise, moduleRecord);
RELEASE_AND_RETURN(scope, fallbackParse(globalObject, moduleKey, sourceCode, promise, moduleRecord));
} else {
promise->fulfillWithNonPromise(globalObject, moduleRecord);
return JSValue::encode(promise);
RELEASE_AND_RETURN(scope, JSValue::encode(promise));
}
}
static EncodedJSValue fallbackParse(JSGlobalObject* globalObject, const Identifier& moduleKey, const SourceCode& sourceCode, JSInternalPromise* promise, JSModuleRecord* resultValue)