| 874 | } |
| 875 | |
| 876 | unsigned parsePoolEntry(Thread* t, |
| 877 | Stream& s, |
| 878 | uint32_t* index, |
| 879 | GcSingleton* pool, |
| 880 | unsigned i) |
| 881 | { |
| 882 | PROTECT(t, pool); |
| 883 | |
| 884 | s.setPosition(index[i]); |
| 885 | |
| 886 | switch (s.read1()) { |
| 887 | case CONSTANT_Integer: |
| 888 | case CONSTANT_Float: { |
| 889 | uint32_t v = s.read4(); |
| 890 | singletonValue(t, pool, i) = v; |
| 891 | |
| 892 | if (DebugClassReader) { |
| 893 | fprintf(stderr, " consts[%d] = int/float 0x%x\n", i, v); |
| 894 | } |
| 895 | } |
| 896 | return 1; |
| 897 | |
| 898 | case CONSTANT_Long: |
| 899 | case CONSTANT_Double: { |
| 900 | uint64_t v = s.read8(); |
| 901 | memcpy(&singletonValue(t, pool, i), &v, 8); |
| 902 | |
| 903 | if (DebugClassReader) { |
| 904 | fprintf(stderr, " consts[%d] = long/double <todo>\n", i); |
| 905 | } |
| 906 | } |
| 907 | return 2; |
| 908 | |
| 909 | case CONSTANT_Utf8: { |
| 910 | if (singletonObject(t, pool, i) == 0) { |
| 911 | GcByteArray* value = internByteArray(t, makeByteArray(t, s, s.read2())); |
| 912 | pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); |
| 913 | |
| 914 | if (DebugClassReader) { |
| 915 | fprintf(stderr, " consts[%d] = utf8 %s\n", i, value->body().begin()); |
| 916 | } |
| 917 | } |
| 918 | } |
| 919 | return 1; |
| 920 | |
| 921 | case CONSTANT_Class: { |
| 922 | if (singletonObject(t, pool, i) == 0) { |
| 923 | unsigned si = s.read2() - 1; |
| 924 | parsePoolEntry(t, s, index, pool, si); |
| 925 | |
| 926 | GcReference* value = makeReference( |
| 927 | t, 0, 0, cast<GcByteArray>(t, singletonObject(t, pool, si)), 0); |
| 928 | pool->setBodyElement(t, i, reinterpret_cast<uintptr_t>(value)); |
| 929 | |
| 930 | if (DebugClassReader) { |
| 931 | fprintf(stderr, " consts[%d] = class <todo>\n", i); |
| 932 | } |
| 933 | } |
no test coverage detected