Updated src/ConstantPoolTags/PoolParser.cpp to reflect using std::any
This commit is contained in:
parent
5f7f3494a4
commit
38802e1f3a
@ -7,15 +7,15 @@
|
||||
#include <ClassFormat.h>
|
||||
#include <ostream>
|
||||
|
||||
void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
void ConstantPoolTags::ConstantPoolParser(ConstantPoolTags::Tags t, JavaClassFormat &jc)
|
||||
{
|
||||
switch (p.tag)
|
||||
switch (t)
|
||||
{
|
||||
case Tags::Utf8: {
|
||||
// std::cout << "FIXME: Implement Utf8 Constant Pool Tag" << std::endl;
|
||||
ConstantUtf8Info ref = static_cast<ConstantUtf8Info>(p.info);
|
||||
ConstantUtf8Info ref;
|
||||
std::vector<uint8_t> length = Utils::ReadFromStart(Globals::buffer(), 2);
|
||||
ref.tag = p.tag;
|
||||
ref.tag = t;
|
||||
ref.length = Utils::vecToVal<uint16_t>(length);
|
||||
|
||||
unsigned char x = Utils::ReadFromStartIntoVal<unsigned char>(Globals::buffer(), 1);
|
||||
@ -49,9 +49,7 @@ void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
if (i != ref.length.ToHostFormat() - 1)
|
||||
x = Utils::ReadFromStartIntoVal<unsigned char>(Globals::buffer(), 1);
|
||||
}
|
||||
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -69,44 +67,40 @@ void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
exit(EXIT_SUCCESS);
|
||||
case Tags::Class: {
|
||||
// std::cout << "FIXME: Implement Class Constant Pool Tag" << std::endl;
|
||||
ConstantClassInfo ref = static_cast<ConstantClassInfo>(p.info);
|
||||
ConstantClassInfo ref;
|
||||
// std::vector<uint8_t> name_index = Utils::ReadFromStart(Globals::buffer(), 2);
|
||||
ref.tag = p.tag;
|
||||
ref.tag = t;
|
||||
ref.name_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
// exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
case Tags::String: {
|
||||
// std::cout << "FIXME: Implement String Constant Pool Tag" << std::endl;
|
||||
ConstantStringInfo ref = static_cast<ConstantStringInfo>(p.info);
|
||||
ref.tag = p.tag;
|
||||
ConstantStringInfo ref;
|
||||
ref.tag = t;
|
||||
// std::cout << std::dec << Globals::buffer().size() << std::endl;
|
||||
ref.string_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
|
||||
// std::cout << std::dec << ref.string_index.ToHostFormat() << std::endl;
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
|
||||
// std::cout << Globals::buffer().size() << std::endl;
|
||||
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
// exit(EXIT_SUCCESS);
|
||||
break;
|
||||
}
|
||||
case Tags::Fieldref: {
|
||||
// std::cout << "FIXME: Implement Fieldref Constant Pool Tag" << std::endl;
|
||||
ConstantFieldrefInfo ref = static_cast<ConstantFieldrefInfo>(p.info);
|
||||
ref.tag = p.tag;
|
||||
ConstantFieldrefInfo ref;
|
||||
ref.tag = t;
|
||||
ref.class_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
ref.name_and_type_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
// exit(EXIT_SUCCESS);
|
||||
break;
|
||||
@ -115,15 +109,13 @@ void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
{
|
||||
// std::cout << "FIXME: Implement Methodref Constant Pool Tag" << std::endl;
|
||||
// ConstantMethodrefInfo ref = *reinterpret_cast<ConstantMethodrefInfo*>(p->info);
|
||||
ConstantMethodrefInfo ref = static_cast<ConstantMethodrefInfo>(p.info);
|
||||
ConstantMethodrefInfo ref;
|
||||
|
||||
ref.tag = p.tag;
|
||||
ref.tag = t;
|
||||
ref.class_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
ref.name_and_type_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
// exit(EXIT_SUCCESS);
|
||||
break;
|
||||
@ -133,14 +125,13 @@ void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
exit(EXIT_SUCCESS);
|
||||
case Tags::NameAndType: {
|
||||
// std::cout << "FIXME: Implement NameAndType Constant Pool Tag" << std::endl;
|
||||
ConstantNameAndTypeInfo ref = static_cast<ConstantNameAndTypeInfo>(p.info);
|
||||
ConstantNameAndTypeInfo ref;
|
||||
|
||||
ref.tag = p.tag;
|
||||
ref.tag = t;
|
||||
ref.name_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
ref.descriptor_index = Utils::ReadFromStartIntoVal<uint16_t>(Globals::buffer(), 2);
|
||||
|
||||
p.info = static_cast<ConstantPoolInfo>(ref);
|
||||
jc.constant_pool.push_back(p);
|
||||
jc.constant_pool.push_back(ref);
|
||||
|
||||
// exit(EXIT_SUCCESS);
|
||||
break;
|
||||
@ -164,7 +155,7 @@ void ConstantPoolTags::ConstantPoolParser(ConstantPool &p, JavaClassFormat &jc)
|
||||
std::cout << "FIXME: Implement Package Constant Pool Tag" << std::endl;
|
||||
exit(EXIT_SUCCESS);
|
||||
default:
|
||||
std::cerr << "Unknown tag: " << std::hex << (int)p.tag << " @ byte " << std::dec << Globals::buffer().size() << " from end of class file" << std::endl;
|
||||
std::cerr << "Unknown tag: " << std::hex << (int)t << " @ byte " << std::dec << Globals::buffer().size() << " from end of class file" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user