#include "ConstantPoolTags/Tags.h" #include #include #include #include #include #include #include #include #include attribute_info Attributes::AttributesParser(JavaClassFormat& jc) { attribute_info ret; ret.attribute_name_index = Utils::ReadFromStartIntoVal(Globals::buffer()); ret.attribute_length = Utils::ReadFromStartIntoVal(Globals::buffer()); ASSERT(ret.attribute_length.ToHostFormat() > 0); for (int i = 0; i < ret.attribute_length.ToHostFormat(); i++) { ret.info.push_back(Utils::ReadFromStartIntoVal(Globals::buffer(), 1)); } std::reverse(ret.info.begin(), ret.info.end()); int idx = ret.info.data()->ToHostFormat(); ASSERT(VEC_ELEM_TYPE(jc.constant_pool[ret.attribute_name_index.ToHostFormat() - 1]) == TYPE(ConstantPoolTags::ConstantUtf8Info)); std::string str = reinterpret_cast(std::any_cast(jc.constant_pool[ret.attribute_name_index.ToHostFormat() - 1]).bytes); switch ((ClassAttributes)crc32_rec(CRC32, str.c_str())) { case ClassAttributes::SOURCE_FILE: { ASSERT(VEC_ELEM_TYPE(jc.constant_pool[idx - 1]) == TYPE(ConstantPoolTags::ConstantUtf8Info)); std::cout << "Source File: " << std::any_cast(jc.constant_pool[idx - 1]).bytes << std::endl; SOURCE_FILE_Attribute attr; // attr. break; } default: std::cerr << "Unknown attribute: \"" << str << "\"" << std::endl; exit(EXIT_FAILURE); } // switch () return ret; }