From a0354816cf84c6c9b4e788891d9801f8610fe437 Mon Sep 17 00:00:00 2001 From: Rerumu Date: Sat, 25 Jun 2022 16:32:46 -0400 Subject: [PATCH] Reorder function debug names --- codegen/luajit/src/translator.rs | 9 ++++----- codegen/luau/src/translator.rs | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/codegen/luajit/src/translator.rs b/codegen/luajit/src/translator.rs index f69067b..7c5045d 100644 --- a/codegen/luajit/src/translator.rs +++ b/codegen/luajit/src/translator.rs @@ -249,13 +249,12 @@ fn write_localize_used(func_list: &[FuncData], w: &mut dyn Write) -> Result Result<()> { - write!(w, "FUNC_LIST")?; + write!(w, "FUNC_LIST[{index}] =")?; - if let Some(name) = wasm.name_section().get(&index) { - write!(w, "--[[ {name} ]]")?; + match wasm.name_section().get(&index) { + Some(name) => write!(w, "--[[ {name} ]]"), + None => Ok(()), } - - write!(w, "[{index}] =") } fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> { diff --git a/codegen/luau/src/translator.rs b/codegen/luau/src/translator.rs index 02ed275..066d303 100644 --- a/codegen/luau/src/translator.rs +++ b/codegen/luau/src/translator.rs @@ -245,13 +245,12 @@ fn write_localize_used(func_list: &[FuncData], w: &mut dyn Write) -> Result Result<()> { - write!(w, "FUNC_LIST")?; + write!(w, "FUNC_LIST[{index}] =")?; - if let Some(name) = wasm.name_section().get(&index) { - write!(w, "--[[ {name} ]]")?; + match wasm.name_section().get(&index) { + Some(name) => write!(w, "--[[ {name} ]]"), + None => Ok(()), } - - write!(w, "[{index}] =") } fn write_func_list(wasm: &Module, func_list: &[FuncData], w: &mut dyn Write) -> Result<()> {