test/tools/yulInterpreter/EVMInstructionInterpreter.cpp
/// Reads 32 bytes from @a _data at position @a _offset bytes while
/// interpreting @a _data to be padded with an infinite number of zero
/// bytes beyond its end.
Reads 32 bytes from @a _data at position @a _offset bytes while
interpreting @a _data to be padded with an infinite number of zero
bytes beyond its end.
Reads 32 bytes from @a _data at position @a _offset bytes while interpreting @a _data to be padded with an infinite number of zero bytes beyond its end .
u256 readZeroExtended(bytes const& _data, u256 const& _offset)
{
	if (_offset >= _data.size())
		return 0;
	else if (_offset + 32 <= _data.size())
		return *reinterpret_cast<h256 const*>(_data.data() + static_cast<size_t>(_offset));
	else
	{
		size_t off = static_cast<size_t>(_offset);
		u256 val;
		for (size_t i = 0; i < 32; ++i)
		{
			val <<= 8;
			if (off + i < _data.size())
				val += _data[off + i];
		}
		return val;
	}
}
u256 readZeroExtended ( bytes const & _data , u256 const & _offset ) { if ( _offset >= _data . size ( ) ) return 0 ; else if ( _offset + 32 <= _data . size ( ) ) return * reinterpret_cast < h256 const * > ( _data . data ( ) + static_cast < size_t > ( _offset ) ) ; else { size_t off = static_cast < size_t > ( _offset ) ; u256 val ; for ( size_t i = 0 ; i < 32 ; ++ i ) { val <<= 8 ; if ( off + i < _data . size ( ) ) val += _data [ off + i ] ; } return val ; } }
Reads 32 bytes from @a _data at position @a _offset bytes while
interpreting @a _data to be padded with an infinite number of zero
bytes beyond its end.
Reads 32 bytes from @a _data at position @a _offset bytes while interpreting @a _data to be padded with an infinite number of zero bytes beyond its end .