Skip to content

Commit

Permalink
Merge pull request #845 from tonlabs/disasm-visibility
Browse files Browse the repository at this point in the history
disasm: make ifaces visible at crate level
  • Loading branch information
mskvortsov authored Feb 9, 2023
2 parents 0ff7080 + 3bdc8d3 commit e7f756d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 73 deletions.
72 changes: 36 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
76 changes: 43 additions & 33 deletions src/disasm/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 += "<collapsed>";
} else {
disasm += &print_cell(cell, indent, false);
if full {
if *collapsed {
assert!(insn.name() == ";;");
disasm += "<collapsed>";
} else {
disasm += &print_cell(cell, indent, false);
}
curr_is_block = true;
}
curr_is_block = true;
}
InstructionParameter::CodeDictMarker => {
// handled above for DICTPUSHCONST
Expand Down
6 changes: 3 additions & 3 deletions src/disasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e7f756d

Please sign in to comment.