diff --git a/crypto/fift/lib/Disasm.fif b/crypto/fift/lib/Disasm.fif index a46eb5b27..42c1e4c63 100644 --- a/crypto/fift/lib/Disasm.fif +++ b/crypto/fift/lib/Disasm.fif @@ -2,8 +2,23 @@ library TVM_Disasm // simple TVM Disassembler "Lists.fif" include +variable @vmlibs dictnew @vmlibs ! +{ 256 u@ dup @vmlibs @ 256 udict@ } : vmlib@ +{ 8 u@+ swap 2 = } : libspecial? + variable 'disasm { 'disasm @ execute } : disasm // disassemble a slice +{ $ type } : .atom { dup first .atom dup count 1 > { space 0 over count 2- { 1+ 2dup [] type .", " } swap times 1+ [] type } { drop } cond } : std-show-op { 0 over count 1- { 1+ 2dup [] type space } swap times drop first .atom } : stk-show-op -{ @dismode @ 2 and { .indent ."// " @curop @ csr. } if } : .curop? + +{ ."// LIB: " swap X. cr ref@ <{" cr +indent disasm -indent .indent ."}>" cr true - } swap ' idictforeach ' dictforeach cond drop + } swap ' idictforeach ' dictforeach cond drop -indent .indent ."}" cr } : show-const-dict-op diff --git a/crypto/fift/words.cpp b/crypto/fift/words.cpp index 8d652afcc..fcf52ea01 100644 --- a/crypto/fift/words.cpp +++ b/crypto/fift/words.cpp @@ -1028,13 +1028,19 @@ void interpret_store_end(vm::Stack& stack, bool special) { stack.push_cell(std::move(cell)); } -void interpret_from_cell(vm::Stack& stack) { +void interpret_from_cell(vm::Stack& stack, bool load_special) { auto cell = stack.pop_cell(); - Ref cs{true, vm::NoVmOrd(), std::move(cell)}; - if (!cs->is_valid()) { - throw IntError{"deserializing a special cell as ordinary"}; + bool is_special; + td::Ref cs = td::make_ref(vm::load_cell_slice_special(cell, is_special)); + if (!load_special) { + if (is_special) { + throw IntError{"deserializing a special cell as ordinary"}; + } + stack.push(cs); + } else { + stack.push(cs); + stack.push_bool(is_special); } - stack.push(cs); } // cs n -- cs' x @@ -3301,7 +3307,8 @@ void init_words_common(Dictionary& d) { d.def_stack_word("hashu ", std::bind(interpret_cell_hash, _1, true)); d.def_stack_word("hashB ", std::bind(interpret_cell_hash, _1, false)); // cellslice manipulation (read from cells) - d.def_stack_word(" + foo4 PROC:<{ UNPAIR SWAP DIV }> + main PROC:<{ 70 PUSHINT DIV }> +}END>c constant code-1 + +// add lib cell to vmlibs + spec PUSHREF +}>c spec PUSHREFSLICE +}>c spec disasmc +