From 160d74b263c6a0cfce65f916299337289e95e87f Mon Sep 17 00:00:00 2001 From: FirowMD Date: Wed, 1 Jan 2025 22:11:15 +0300 Subject: [PATCH] Minor decompiler changes --- bytesto4t/src-tauri/src/lib.rs | 12 ++++++++---- bytesto4t/src/lib/ViewDecompiler.svelte | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bytesto4t/src-tauri/src/lib.rs b/bytesto4t/src-tauri/src/lib.rs index 2f5b8ab..42b3f64 100644 --- a/bytesto4t/src-tauri/src/lib.rs +++ b/bytesto4t/src-tauri/src/lib.rs @@ -210,8 +210,10 @@ fn get_decompiled_info(app_data: State) -> Result { return Err("Function index out of bounds".to_string()); } let function = &functions[index]; - Ok(format!("{}", decompile_function(&bytecode, &function) - .display(&bytecode, &hlbc_decompiler::fmt::FormatOptions::new(2)))) + decompile_function(&bytecode, &function) + .map_err(|e| format!("Decompilation failed: {}", e)) + .map(|decompiled| format!("{}", decompiled + .display(&bytecode, &hlbc_decompiler::fmt::FormatOptions::new(2)))) } "class" => { let types = &bytecode.types; @@ -221,8 +223,10 @@ fn get_decompiled_info(app_data: State) -> Result { let type_obj = &types[index]; match type_obj { Type::Obj(obj) => { - Ok(format!("{}", decompile_class(&bytecode, obj) - .display(&bytecode, &hlbc_decompiler::fmt::FormatOptions::new(2)))) + decompile_class(&bytecode, obj) + .map_err(|e| format!("Decompilation failed: {}", e)) + .map(|decompiled| format!("{}", decompiled + .display(&bytecode, &hlbc_decompiler::fmt::FormatOptions::new(2)))) } _ => Err("Type is not an object".to_string()), } diff --git a/bytesto4t/src/lib/ViewDecompiler.svelte b/bytesto4t/src/lib/ViewDecompiler.svelte index 8e236f5..8affe9f 100644 --- a/bytesto4t/src/lib/ViewDecompiler.svelte +++ b/bytesto4t/src/lib/ViewDecompiler.svelte @@ -49,7 +49,7 @@ {decompilerTitle} {#if functionName !== ""} -

+

{functionName}

{/if}