| 2279 | } |
| 2280 | |
| 2281 | GcCode* parseCode(Thread* t, Stream& s, GcSingleton* pool) |
| 2282 | { |
| 2283 | PROTECT(t, pool); |
| 2284 | |
| 2285 | unsigned maxStack = s.read2(); |
| 2286 | unsigned maxLocals = s.read2(); |
| 2287 | unsigned length = s.read4(); |
| 2288 | |
| 2289 | if (DebugClassReader) { |
| 2290 | fprintf(stderr, |
| 2291 | " code: maxStack %d maxLocals %d length %d\n", |
| 2292 | maxStack, |
| 2293 | maxLocals, |
| 2294 | length); |
| 2295 | } |
| 2296 | |
| 2297 | GcCode* code = makeCode(t, pool, 0, 0, 0, 0, 0, maxStack, maxLocals, length); |
| 2298 | s.read(code->body().begin(), length); |
| 2299 | PROTECT(t, code); |
| 2300 | |
| 2301 | if (DebugClassReader) { |
| 2302 | disassembleCode(" ", code->body().begin(), length); |
| 2303 | } |
| 2304 | |
| 2305 | unsigned ehtLength = s.read2(); |
| 2306 | if (ehtLength) { |
| 2307 | GcExceptionHandlerTable* eht = makeExceptionHandlerTable(t, ehtLength); |
| 2308 | for (unsigned i = 0; i < ehtLength; ++i) { |
| 2309 | unsigned start = s.read2(); |
| 2310 | unsigned end = s.read2(); |
| 2311 | unsigned ip = s.read2(); |
| 2312 | unsigned catchType = s.read2(); |
| 2313 | eht->body()[i] = exceptionHandler(start, end, ip, catchType); |
| 2314 | } |
| 2315 | |
| 2316 | code->setExceptionHandlerTable(t, eht); |
| 2317 | } |
| 2318 | |
| 2319 | unsigned attributeCount = s.read2(); |
| 2320 | for (unsigned j = 0; j < attributeCount; ++j) { |
| 2321 | GcByteArray* name |
| 2322 | = cast<GcByteArray>(t, singletonObject(t, pool, s.read2() - 1)); |
| 2323 | unsigned length = s.read4(); |
| 2324 | |
| 2325 | if (vm::strcmp(reinterpret_cast<const int8_t*>("LineNumberTable"), |
| 2326 | name->body().begin()) == 0) { |
| 2327 | unsigned lntLength = s.read2(); |
| 2328 | GcLineNumberTable* lnt = makeLineNumberTable(t, lntLength); |
| 2329 | for (unsigned i = 0; i < lntLength; ++i) { |
| 2330 | unsigned ip = s.read2(); |
| 2331 | unsigned line = s.read2(); |
| 2332 | lnt->body()[i] = lineNumber(ip, line); |
| 2333 | } |
| 2334 | |
| 2335 | code->setLineNumberTable(t, lnt); |
| 2336 | } else { |
| 2337 | s.skip(length); |
| 2338 | } |
no test coverage detected