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

updated vm (breaking compatibility)

- updated vm
- new actor scheduler
- updated tonlib
- updated DNS smartcontract
This commit is contained in:
ton 2020-02-28 14:28:47 +04:00
parent 9e4816e7f6
commit e27fb1e09c
100 changed files with 3692 additions and 1299 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
#include <vector>
@ -169,6 +169,8 @@ class PropagateConstSpan {
size_t size_{0};
};
struct Normalize {};
template <class Tr = BigIntInfo>
class AnyIntView {
public:
@ -308,6 +310,10 @@ class BigIntG {
explicit BigIntG(word_t x) : n(1) {
digits[0] = x;
}
BigIntG(Normalize, word_t x) : n(1) {
digits[0] = x;
normalize_bool();
}
BigIntG(const BigIntG& x) : n(x.n) {
std::memcpy(digits, x.digits, n * sizeof(word_t));
///std::cout << "(BiCC " << (const void*)&x << "->" << (void*)this << ")";
@ -2515,6 +2521,11 @@ extern template class AnyIntView<BigIntInfo>;
extern template class BigIntG<257, BigIntInfo>;
typedef BigIntG<257, BigIntInfo> BigInt256;
template <int n = 257>
BigIntG<n, BigIntInfo> make_bigint(long long x) {
return BigIntG<n, BigIntInfo>{Normalize(), x};
}
namespace literals {
extern BigInt256 operator""_i256(const char* str, std::size_t str_len);

View file

@ -38,6 +38,11 @@ RefInt256 operator+(RefInt256 x, long long y) {
return x;
}
RefInt256 operator+(RefInt256 x, const BigInt256& y) {
(x.write() += y).normalize();
return x;
}
RefInt256 operator-(RefInt256 x, RefInt256 y) {
(x.write() -= *y).normalize();
return x;
@ -48,6 +53,11 @@ RefInt256 operator-(RefInt256 x, long long y) {
return x;
}
RefInt256 operator-(RefInt256 x, const BigInt256& y) {
(x.write() -= y).normalize();
return x;
}
RefInt256 operator-(RefInt256 x) {
x.write().negate().normalize();
return x;
@ -69,6 +79,12 @@ RefInt256 operator*(RefInt256 x, long long y) {
return x;
}
RefInt256 operator*(RefInt256 x, const BigInt256& y) {
RefInt256 z{true, 0};
z.write().add_mul(*x, y).normalize();
return z;
}
RefInt256 operator/(RefInt256 x, RefInt256 y) {
RefInt256 quot{true};
x.write().mod_div(*y, quot.write());
@ -142,6 +158,11 @@ RefInt256& operator+=(RefInt256& x, long long y) {
return x;
}
RefInt256& operator+=(RefInt256& x, const BigInt256& y) {
(x.write() += y).normalize();
return x;
}
RefInt256& operator-=(RefInt256& x, RefInt256 y) {
(x.write() -= *y).normalize();
return x;
@ -152,6 +173,11 @@ RefInt256& operator-=(RefInt256& x, long long y) {
return x;
}
RefInt256& operator-=(RefInt256& x, const BigInt256& y) {
(x.write() -= y).normalize();
return x;
}
RefInt256& operator*=(RefInt256& x, RefInt256 y) {
RefInt256 z{true, 0};
z.write().add_mul(*x, *y).normalize();
@ -163,6 +189,12 @@ RefInt256& operator*=(RefInt256& x, long long y) {
return x;
}
RefInt256& operator*=(RefInt256& x, const BigInt256& y) {
RefInt256 z{true, 0};
z.write().add_mul(*x, y).normalize();
return x = z;
}
RefInt256& operator/=(RefInt256& x, RefInt256 y) {
RefInt256 quot{true};
x.write().mod_div(*y, quot.write());
@ -214,9 +246,13 @@ int sgn(RefInt256 x) {
}
RefInt256 make_refint(long long x) {
auto xx = td::RefInt256{true, x};
xx.unique_write().normalize();
return xx;
return td::RefInt256{true, td::Normalize(), x};
}
RefInt256 zero_refint() {
// static RefInt256 Zero = td::RefInt256{true, 0};
// return Zero;
return td::RefInt256{true, 0};
}
RefInt256 bits_to_refint(td::ConstBitPtr bits, int n, bool sgnd) {

View file

@ -33,10 +33,13 @@ typedef Ref<CntInt256> RefInt256;
extern RefInt256 operator+(RefInt256 x, RefInt256 y);
extern RefInt256 operator+(RefInt256 x, long long y);
extern RefInt256 operator+(RefInt256 x, const BigInt256& y);
extern RefInt256 operator-(RefInt256 x, RefInt256 y);
extern RefInt256 operator-(RefInt256 x, long long y);
extern RefInt256 operator-(RefInt256 x, const BigInt256& y);
extern RefInt256 operator*(RefInt256 x, RefInt256 y);
extern RefInt256 operator*(RefInt256 x, long long y);
extern RefInt256 operator*(RefInt256 x, const BigInt256& y);
extern RefInt256 operator/(RefInt256 x, RefInt256 y);
extern RefInt256 operator%(RefInt256 x, RefInt256 y);
extern RefInt256 div(RefInt256 x, RefInt256 y, int round_mode = -1);
@ -53,10 +56,13 @@ extern RefInt256 rshift(RefInt256 x, int y, int round_mode = -1);
extern RefInt256& operator+=(RefInt256& x, RefInt256 y);
extern RefInt256& operator+=(RefInt256& x, long long y);
extern RefInt256& operator+=(RefInt256& x, const BigInt256& y);
extern RefInt256& operator-=(RefInt256& x, RefInt256 y);
extern RefInt256& operator-=(RefInt256& x, long long y);
extern RefInt256& operator-=(RefInt256& x, const BigInt256& y);
extern RefInt256& operator*=(RefInt256& x, RefInt256 y);
extern RefInt256& operator*=(RefInt256& x, long long y);
extern RefInt256& operator*=(RefInt256& x, const BigInt256& y);
extern RefInt256& operator/=(RefInt256& x, RefInt256 y);
extern RefInt256& operator%=(RefInt256& x, RefInt256 y);
@ -100,7 +106,14 @@ extern int cmp(RefInt256 x, RefInt256 y);
extern int cmp(RefInt256 x, long long y);
extern int sgn(RefInt256 x);
template <typename... Args>
RefInt256 make_refint(Args&&... args) {
return td::RefInt256{true, std::forward<Args>(args)...};
}
extern RefInt256 make_refint(long long x);
extern RefInt256 zero_refint();
extern RefInt256 bits_to_refint(td::ConstBitPtr bits, int n, bool sgnd = false);
extern std::string dec_string(RefInt256 x);