1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

updated func and tonlib

This commit is contained in:
ton 2020-02-15 20:03:17 +04:00
parent 493ae2410c
commit a73d202ba2
50 changed files with 1340 additions and 271 deletions

View file

@ -14,7 +14,7 @@
You should have received a copy of the GNU Lesser General Public License
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2017-2019 Telegram Systems LLP
Copyright 2017-2020 Telegram Systems LLP
*/
#pragma once
@ -348,6 +348,10 @@ class Stack : public td::CntObject {
void pop_many(int count) {
stack.resize(stack.size() - count);
}
void pop_many(int count, int offs) {
std::move(stack.cend() - offs, stack.cend(), stack.end() - (count + offs));
pop_many(count);
}
void drop_bottom(int count) {
std::move(stack.cbegin() + count, stack.cend(), stack.begin());
pop_many(count);

View file

@ -379,6 +379,15 @@ int exec_blkdrop(VmState* st, unsigned args) {
return 0;
}
int exec_blkdrop2(VmState* st, unsigned args) {
int x = ((args >> 4) & 15), y = (args & 15);
Stack& stack = st->get_stack();
VM_LOG(st) << "execute BLKDROP2 " << x << ',' << y;
stack.check_underflow(x + y);
stack.pop_many(x, y);
return 0;
}
int exec_blkpush(VmState* st, unsigned args) {
int x = ((args >> 4) & 15), y = (args & 15);
Stack& stack = st->get_stack();
@ -570,7 +579,8 @@ void register_stack_ops(OpcodeTable& cp0) {
.insert(OpcodeInstr::mksimple(0x68, 8, "DEPTH", exec_depth))
.insert(OpcodeInstr::mksimple(0x69, 8, "CHKDEPTH", exec_chkdepth))
.insert(OpcodeInstr::mksimple(0x6a, 8, "ONLYTOPX", exec_onlytop_x))
.insert(OpcodeInstr::mksimple(0x6b, 8, "ONLYX", exec_only_x));
.insert(OpcodeInstr::mksimple(0x6b, 8, "ONLYX", exec_only_x))
.insert(OpcodeInstr::mkfixedrange(0x6c10, 0x6d00, 16, 8, instr::dump_2c("BLKDROP2 ", ","), exec_blkdrop2));
}
} // namespace vm

View file

@ -811,26 +811,24 @@ bool store_grams(CellBuilder& cb, td::RefInt256 value) {
}
int exec_reserve_raw(VmState* st, int mode) {
VM_LOG(st) << "execute RESERVERAW" << (mode & 1 ? "X" : "");
VM_LOG(st) << "execute RAWRESERVE" << (mode & 1 ? "X" : "");
Stack& stack = st->get_stack();
stack.check_underflow(2);
int f = stack.pop_smallint_range(3);
td::RefInt256 x;
Ref<CellSlice> csr;
stack.check_underflow(2 + (mode & 1));
int f = stack.pop_smallint_range(15);
Ref<Cell> y;
if (mode & 1) {
csr = stack.pop_cellslice();
} else {
x = stack.pop_int_finite();
if (td::sgn(x) < 0) {
throw VmError{Excno::range_chk, "amount of nanograms must be non-negative"};
}
y = stack.pop_maybe_cell();
}
auto x = stack.pop_int_finite();
if (td::sgn(x) < 0) {
throw VmError{Excno::range_chk, "amount of nanograms must be non-negative"};
}
CellBuilder cb;
if (!(cb.store_ref_bool(get_actions(st)) // out_list$_ {n:#} prev:^(OutList n)
&& cb.store_long_bool(0x36e6b809, 32) // action_reserve_currency#36e6b809
&& cb.store_long_bool(f, 8) // mode:(## 8)
&& (mode & 1 ? cb.append_cellslice_bool(std::move(csr))
: (store_grams(cb, std::move(x)) && cb.store_bool_bool(false))))) {
&& store_grams(cb, std::move(x)) //
&& cb.store_maybe_ref(std::move(y)))) {
throw VmError{Excno::cell_ov, "cannot serialize raw reserved currency amount into an output action cell"};
}
return install_output_action(st, cb.finalize());
@ -886,8 +884,8 @@ int exec_change_lib(VmState* st) {
void register_ton_message_ops(OpcodeTable& cp0) {
using namespace std::placeholders;
cp0.insert(OpcodeInstr::mksimple(0xfb00, 16, "SENDRAWMSG", exec_send_raw_message))
.insert(OpcodeInstr::mksimple(0xfb02, 16, "RESERVERAW", std::bind(exec_reserve_raw, _1, 0)))
.insert(OpcodeInstr::mksimple(0xfb03, 16, "RESERVERAWX", std::bind(exec_reserve_raw, _1, 1)))
.insert(OpcodeInstr::mksimple(0xfb02, 16, "RAWRESERVE", std::bind(exec_reserve_raw, _1, 0)))
.insert(OpcodeInstr::mksimple(0xfb03, 16, "RAWRESERVEX", std::bind(exec_reserve_raw, _1, 1)))
.insert(OpcodeInstr::mksimple(0xfb04, 16, "SETCODE", exec_set_code))
.insert(OpcodeInstr::mksimple(0xfb06, 16, "SETLIBCODE", exec_set_lib_code))
.insert(OpcodeInstr::mksimple(0xfb07, 16, "CHANGELIB", exec_change_lib));