MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecodeBits

Function DecodeBits

src/util/asmap.cpp:21–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19constexpr uint32_t INVALID = 0xFFFFFFFF;
20
21uint32_t DecodeBits(std::vector<bool>::const_iterator& bitpos, const std::vector<bool>::const_iterator& endpos, uint8_t minval, const std::vector<uint8_t> &bit_sizes)
22{
23 uint32_t val = minval;
24 bool bit;
25 for (std::vector<uint8_t>::const_iterator bit_sizes_it = bit_sizes.begin();
26 bit_sizes_it != bit_sizes.end(); ++bit_sizes_it) {
27 if (bit_sizes_it + 1 != bit_sizes.end()) {
28 if (bitpos == endpos) break;
29 bit = *bitpos;
30 bitpos++;
31 } else {
32 bit = 0;
33 }
34 if (bit) {
35 val += (1 << *bit_sizes_it);
36 } else {
37 for (int b = 0; b < *bit_sizes_it; b++) {
38 if (bitpos == endpos) return INVALID; // Reached EOF in mantissa
39 bit = *bitpos;
40 bitpos++;
41 val += bit << (*bit_sizes_it - 1 - b);
42 }
43 return val;
44 }
45 }
46 return INVALID; // Reached EOF in exponent
47}
48
49enum class Instruction : uint32_t
50{

Callers 4

DecodeTypeFunction · 0.85
DecodeASNFunction · 0.85
DecodeMatchFunction · 0.85
DecodeJumpFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected