MCPcopy Create free account
hub / github.com/ReadyTalk/avian / parseJavaClass

Function parseJavaClass

src/tools/type-generator/main.cpp:617–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617void parseJavaClass(Module& module, ClassParser& clparser, Stream* s)
618{
619 uint32_t magic = s->read4();
620 assert(magic == 0xCAFEBABE);
621 (void)magic;
622 s->read2(); // minor version
623 s->read2(); // major version
624
625 unsigned poolCount = s->read2() - 1;
626 std::vector<uintptr_t> pool(poolCount, -1);
627 for (unsigned i = 0; i < poolCount; ++i) {
628 unsigned c = s->read1();
629
630 switch (c) {
631 case CONSTANT_Integer:
632 case CONSTANT_Float:
633 pool[i] = s->read4();
634 break;
635
636 case CONSTANT_Long:
637 case CONSTANT_Double:
638 pool[i++] = s->read4();
639 pool[i] = s->read4();
640 break;
641
642 case CONSTANT_Utf8: {
643 unsigned length = s->read2();
644 uint8_t* p = static_cast<uint8_t*>(malloc(length + 1));
645 s->read(p, length);
646 p[length] = 0;
647 pool[i] = reinterpret_cast<uintptr_t>(p);
648 } break;
649
650 case CONSTANT_Class:
651 case CONSTANT_String:
652 pool[i] = s->read2();
653 break;
654
655 case CONSTANT_NameAndType:
656 pool[i] = s->read4();
657 break;
658
659 case CONSTANT_Fieldref:
660 case CONSTANT_Methodref:
661 case CONSTANT_InterfaceMethodref:
662 pool[i] = s->read4();
663 break;
664
665 default:
666 abort();
667 }
668 }
669
670 s->read2(); // flags
671 s->read2(); // name
672
673 unsigned superIndex = s->read2();
674 if (superIndex) {

Callers 1

parseTypeFunction · 0.85

Calls 14

FieldSpecClass · 0.85
setSuperMethod · 0.80
fieldTypeFunction · 0.70
MethodClass · 0.70
readMethod · 0.65
skipMethod · 0.65
addMethod · 0.65
abortFunction · 0.50
read4Method · 0.45
read2Method · 0.45
read1Method · 0.45
insertMethod · 0.45

Tested by

no test coverage detected