Ejemplo n.º 1
0
    bytes unpadLeft(bytes _b)
    {
        unsigned int i = 0;
        if (_b.size() == 0)
            return _b;

        while (i < _b.size() && _b[i] == byte(0))
            i++;

        if (i != 0)
            _b.erase(_b.begin(), _b.begin() + i);
        return _b;
    }
Ejemplo n.º 2
0
string eth::disassemble(bytes const& _mem)
{
	stringstream ret;
	uint numerics = 0;
	for (auto it = _mem.begin(); it != _mem.end(); ++it)
	{
		byte n = *it;
		auto iit = c_instructionInfo.find((Instruction)n);
		if (numerics || iit == c_instructionInfo.end() || (byte)iit->first != n)	// not an instruction or expecting an argument...
		{
			if (numerics)
				numerics--;
			ret << "0x" << hex << (int)n << " ";
		}
		else
		{
			auto const& ii = iit->second;
			ret << ii.name << " ";
			numerics = ii.additional;
		}
	}
	return ret.str();
}
Ejemplo n.º 3
0
 bytes padded(bytes _b, unsigned _l)
 {
     while (_b.size() < _l)
         _b.insert(_b.begin(), 0);
     return asBytes(asString(_b).substr(_b.size() - max(_l, _l)));
 }
Ejemplo n.º 4
0
 bool operator==(const bytes& rhs) const {
   return std::equal(begin(), end(), rhs.begin());
 }
Ejemplo n.º 5
0
 bytes(const bytes& o) {
   std::copy(o.begin(), o.end(), data);
 }