You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
853 B

10 years ago
#pragma once
#include <evmjit/JIT.h>
10 years ago
namespace dev
{
namespace eth
{
/// Converts EVM JIT representation of 256-bit integer to eth type dev::u256.
inline u256 jit2eth(evmjit::i256 _i)
10 years ago
{
u256 u = _i.words[3];
10 years ago
u <<= 64;
u |= _i.words[2];
10 years ago
u <<= 64;
u |= _i.words[1];
10 years ago
u <<= 64;
u |= _i.words[0];
10 years ago
return u;
}
/// Converts eth type dev::u256 to EVM JIT representation of 256-bit integer.
inline evmjit::i256 eth2jit(u256 _u)
10 years ago
{
evmjit::i256 i;
i.words[0] = static_cast<uint64_t>(_u);
10 years ago
_u >>= 64;
i.words[1] = static_cast<uint64_t>(_u);
10 years ago
_u >>= 64;
i.words[2] = static_cast<uint64_t>(_u);
10 years ago
_u >>= 64;
i.words[3] = static_cast<uint64_t>(_u);
10 years ago
return i;
}
/// Converts eth type dev::h256 to EVM JIT representation of 256-bit hash value.
inline evmjit::h256 eth2jit(h256 _u)
{
/// Just directly copies memory
return *(evmjit::h256*)&_u;
}
10 years ago
}
}