mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 20:26:41 +00:00
Fix u256 to APInt conversion
This commit is contained in:
parent
e6b4761765
commit
c6cf723c68
1 changed files with 5 additions and 3 deletions
|
|
@ -43,9 +43,11 @@ llvm::ConstantInt* Constant::get(uint64_t _n)
|
|||
|
||||
llvm::ConstantInt* Constant::get(u256 _n)
|
||||
{
|
||||
auto limbs = _n.backend().limbs();
|
||||
auto words = reinterpret_cast<uint64_t*>(limbs);
|
||||
llvm::APInt n(256, 4, words);
|
||||
auto& backend = _n.backend();
|
||||
auto words = reinterpret_cast<uint64_t*>(backend.limbs());
|
||||
auto nWords = backend.limb_bits == 64 ? backend.size() : (backend.size() + 1) / 2;
|
||||
llvm::APInt n(256, nWords, words);
|
||||
assert(n.toString(10, false) == _n.str());
|
||||
return static_cast<llvm::ConstantInt*>(llvm::ConstantInt::get(Type::i256, n));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue