From 6647ad9bb212a28783de602ca33602010063c473 Mon Sep 17 00:00:00 2001 From: Mikhael Skvortsov Date: Thu, 9 Feb 2023 11:17:43 +0300 Subject: [PATCH 1/2] disasm: make ifaces visible at crate level --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/disasm/loader.rs | 76 +++++++++++++++++++++++++------------------- src/disasm/mod.rs | 6 ++-- src/lib.rs | 1 + 5 files changed, 49 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index feff1086..1fc4be9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,7 +1325,7 @@ dependencies = [ [[package]] name = "tvm_linker" -version = "0.19.3" +version = "0.19.4" dependencies = [ "assert_cmd", "base64 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index 74b27e8d..80924da6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license-file = 'LICENSE.md' name = 'tvm_linker' readme = 'README.md' repository = 'https://github.com/tonlabs/TVM-linker' -version = '0.19.3' +version = '0.19.4' [[bin]] name = 'tvm_linker' diff --git a/src/disasm/loader.rs b/src/disasm/loader.rs index 42412357..81f4618f 100644 --- a/src/disasm/loader.rs +++ b/src/disasm/loader.rs @@ -1926,29 +1926,35 @@ fn print_dictpushconst(insn: &Instruction, indent: &str) -> String { } pub fn print_code(code: &Code, indent: &str) -> String { + print_code_ex(code, indent, true) +} + +pub fn print_code_ex(code: &Code, indent: &str, full: bool) -> String { let mut disasm = String::new(); for insn in code { disasm += indent; - match insn.name() { - "DICTPUSHCONST" | "PFXDICTSWITCH" => { - // TODO better improve assembler for these two insns - disasm += &print_dictpushconst(insn, indent); - continue - } - "IMPLICIT-JMP" => { - if let Some(InstructionParameter::Code { code, cell }) = insn.params().get(0) { - let hash = cell.as_ref().unwrap().repr_hash().to_hex_string(); - disasm += &format!(".cell {{ ;; #{}\n", hash); - let inner_indent = String::from(" ") + indent; - disasm += &print_code(code, inner_indent.as_str()); - disasm += indent; - disasm += "}\n"; - } else { - unreachable!() + if full { + match insn.name() { + "DICTPUSHCONST" | "PFXDICTSWITCH" => { + // TODO better improve assembler for these two insns + disasm += &print_dictpushconst(insn, indent); + continue + } + "IMPLICIT-JMP" => { + if let Some(InstructionParameter::Code { code, cell }) = insn.params().get(0) { + let hash = cell.as_ref().unwrap().repr_hash().to_hex_string(); + disasm += &format!(".cell {{ ;; #{}\n", hash); + let inner_indent = String::from(" ") + indent; + disasm += &print_code(code, inner_indent.as_str()); + disasm += indent; + disasm += "}\n"; + } else { + unreachable!() + } + continue } - continue + _ => () } - _ => () } disasm += insn.name(); if insn.is_quiet() { @@ -2002,25 +2008,29 @@ pub fn print_code(code: &Code, indent: &str) -> String { disasm += format!("s{}, s{}, s{}", ra, rb, rc).as_str(); } InstructionParameter::Code { code, cell } => { - if let Some(cell) = cell { - disasm += &format!("{{ ;; #{}\n", cell.repr_hash().to_hex_string()); - } else { - disasm += "{\n"; + if full { + if let Some(cell) = cell { + disasm += &format!("{{ ;; #{}\n", cell.repr_hash().to_hex_string()); + } else { + disasm += "{\n"; + } + let inner_indent = String::from(" ") + indent; + disasm += &print_code(code, inner_indent.as_str()); + disasm += indent; + disasm += "}"; + curr_is_block = true; } - let inner_indent = String::from(" ") + indent; - disasm += &print_code(code, inner_indent.as_str()); - disasm += indent; - disasm += "}"; - curr_is_block = true; } InstructionParameter::Cell { cell, collapsed } => { - if *collapsed { - assert!(insn.name() == ";;"); - disasm += ""; - } else { - disasm += &print_cell(cell, indent, false); + if full { + if *collapsed { + assert!(insn.name() == ";;"); + disasm += ""; + } else { + disasm += &print_cell(cell, indent, false); + } + curr_is_block = true; } - curr_is_block = true; } InstructionParameter::CodeDictMarker => { // handled above for DICTPUSHCONST diff --git a/src/disasm/mod.rs b/src/disasm/mod.rs index ed67f099..14307e7d 100644 --- a/src/disasm/mod.rs +++ b/src/disasm/mod.rs @@ -11,9 +11,9 @@ * limitations under the License. */ -pub(crate) mod commands; +pub mod commands; mod handlers; -mod loader; +pub mod loader; #[cfg(test)] mod tests; -mod types; +pub mod types; diff --git a/src/lib.rs b/src/lib.rs index e62b051f..53c5db23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,7 @@ extern crate ton_types; extern crate ton_vm; pub mod abi; +pub mod disasm; pub mod keyman; pub mod parser; pub mod printer; From 3bdc8d3a526002fcd04322397b0228a025b35500 Mon Sep 17 00:00:00 2001 From: tonjen Date: Thu, 9 Feb 2023 08:32:20 +0000 Subject: [PATCH 2/2] Preparing to merge with the master --- Cargo.lock | 70 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1fc4be9f..7c0ead0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,7 +62,7 @@ version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e" dependencies = [ - "bstr 1.1.0", + "bstr 1.2.0", "doc-comment", "predicates", "predicates-core", @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832" dependencies = [ "memchr", "once_cell", @@ -193,9 +193,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" dependencies = [ "jobserver", ] @@ -278,9 +278,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ "crc-catalog", ] @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322296e2f2e5af4270b54df9e85a02ff037e271af20ba3e7fe1575515dc840b8" +checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" dependencies = [ "cc", "cxxbridge-flags", @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "017a1385b05d631e7875b1f151c9f012d37b53491e2a87f65bff5c262b2111d8" +checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" dependencies = [ "cc", "codespan-reporting", @@ -386,15 +386,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c26bbb078acf09bc1ecda02d4223f03bdd28bd4874edcb0379138efc499ce971" +checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" [[package]] name = "cxxbridge-macro" -version = "1.0.88" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357f40d1f06a24b60ae1fe122542c1fb05d28d32acb2aed064e84bc2ad1e252e" +checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" dependencies = [ "proc-macro2", "quote", @@ -630,9 +630,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] @@ -873,9 +873,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -1080,9 +1080,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.91" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -1254,7 +1254,7 @@ version = "1.9.22" source = "git+https://github.com/tonlabs/ton-labs-block.git?tag=1.9.22#bb1f4af6072e52618bdffcfa7614e8ca6ee6b947" dependencies = [ "base64 0.13.1", - "crc 3.0.0", + "crc 3.0.1", "ed25519", "ed25519-dalek", "failure", @@ -1330,7 +1330,7 @@ dependencies = [ "assert_cmd", "base64 0.13.1", "clap", - "crc 3.0.0", + "crc 3.0.1", "ed25519", "ed25519-dalek", "failure", @@ -1420,9 +1420,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1430,9 +1430,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -1445,9 +1445,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1455,9 +1455,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -1468,9 +1468,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "winapi" @@ -1545,9 +1545,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.5+zstd.1.5.2" +version = "2.0.6+zstd.1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc50ffce891ad571e9f9afe5039c4837bede781ac4bb13052ed7ae695518596" +checksum = "68a3f9792c0c3dc6c165840a75f47ae1f4da402c2d006881129579f6597e801b" dependencies = [ "cc", "libc",