* Load a java constant pool */
| 178 | * Load a java constant pool |
| 179 | */ |
| 180 | void load(util::membuffer &buf) |
| 181 | { |
| 182 | // FIXME: @SANITY this should check for the end of buffer. |
| 183 | uint16_t length = 0; |
| 184 | buf.read_be(length); |
| 185 | length--; |
| 186 | const constant *last_constant = nullptr; |
| 187 | while (length) |
| 188 | { |
| 189 | const constant &cnst = constant(buf); |
| 190 | constants.push_back(cnst); |
| 191 | last_constant = &constants[constants.size() - 1]; |
| 192 | if (last_constant->type == constant_type_t::j_double || |
| 193 | last_constant->type == constant_type_t::j_long) |
| 194 | { |
| 195 | // push in a fake constant to preserve indexing |
| 196 | constants.push_back(constant(0)); |
| 197 | length -= 2; |
| 198 | } |
| 199 | else |
| 200 | { |
| 201 | length--; |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | typedef std::vector<java::constant> container_type; |
| 206 | /** |
| 207 | * Access constants based on jar file index numbers (index of the first element is 1) |