diff --git a/libevm/VM.h b/libevm/VM.h index b4a0664ec..c95242dfa 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -38,6 +38,13 @@ namespace eth class VMFactory; +// Convert from a 256-bit integer stack/memory entry into a 160-bit Address hash. +// Currently we just pull out the right (low-order in BE) 160-bits. +inline Address asAddress(u256 _item) +{ + return right160(h256(_item)); +} + inline u256 fromAddress(Address _a) { return (u160)_a; @@ -151,7 +158,7 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con case Instruction::SLOAD: require(1); - runGas = c_sloadGas; + runGas = c_sloadGas; break; // These all operate on memory and therefore potentially expand it: @@ -223,7 +230,7 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con u256 inOff = m_stack[m_stack.size() - 2]; u256 inSize = m_stack[m_stack.size() - 3]; newTempSize = (bigint)inOff + inSize; - runGas = c_createGas; + runGas = c_createGas; break; } case Instruction::EXP: @@ -399,7 +406,7 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con m_stack.pop_back(); break; case Instruction::SDIV: - m_stack[m_stack.size() - 2] = m_stack[m_stack.size() - 2] ? s2u(u2s(m_stack.back()) / u2s(m_stack[m_stack.size() - 2])) : 0; + m_stack[m_stack.size() - 2] = m_stack[m_stack.size() - 2] ? s2u(u2s(m_stack.back()) / u2s(m_stack[m_stack.size() - 2])) : 0; m_stack.pop_back(); break; case Instruction::MOD: @@ -407,7 +414,7 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con m_stack.pop_back(); break; case Instruction::SMOD: - m_stack[m_stack.size() - 2] = m_stack[m_stack.size() - 2] ? s2u(u2s(m_stack.back()) % u2s(m_stack[m_stack.size() - 2])) : 0; + m_stack[m_stack.size() - 2] = m_stack[m_stack.size() - 2] ? s2u(u2s(m_stack.back()) % u2s(m_stack[m_stack.size() - 2])) : 0; m_stack.pop_back(); break; case Instruction::EXP: @@ -430,11 +437,11 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con m_stack.pop_back(); break; case Instruction::SLT: - m_stack[m_stack.size() - 2] = u2s(m_stack.back()) < u2s(m_stack[m_stack.size() - 2]) ? 1 : 0; + m_stack[m_stack.size() - 2] = u2s(m_stack.back()) < u2s(m_stack[m_stack.size() - 2]) ? 1 : 0; m_stack.pop_back(); break; case Instruction::SGT: - m_stack[m_stack.size() - 2] = u2s(m_stack.back()) > u2s(m_stack[m_stack.size() - 2]) ? 1 : 0; + m_stack[m_stack.size() - 2] = u2s(m_stack.back()) > u2s(m_stack[m_stack.size() - 2]) ? 1 : 0; m_stack.pop_back(); break; case Instruction::EQ: diff --git a/libevm/VMFace.h b/libevm/VMFace.h index 6617db1da..f4dd3096e 100644 --- a/libevm/VMFace.h +++ b/libevm/VMFace.h @@ -34,21 +34,6 @@ struct BadJumpDestination: virtual VMException {}; struct OutOfGas: virtual VMException {}; struct StackTooSmall: virtual public VMException {}; -// Convert from a 256-bit integer stack/memory entry into a 160-bit Address hash. -// Currently we just pull out the right (low-order in BE) 160-bits. -inline Address asAddress(u256 _item) -{ - return right160(h256(_item)); -} - -inline u256 fromAddress(Address _a) -{ - return (u160)_a; - // h256 ret; - // memcpy(&ret, &_a, sizeof(_a)); - // return ret; -} - /** */ class VMFace