// File: minirop[P]JDecomqiler/src/ClassFile.cpp
// Function: ClassFile::parseConstant()
bool ClassFile::parseConstant()
{
	bool isDoubleSize = false;
	
	CPinfo info;
	
	stream >> info.tag;
	
	switch(info.tag)
	{
		case CONSTANT_Utf8:
			{
				std::uint16_t length;
				stream >> length;
				char * string = new char[length+1];
				stream.readRawData(string, length);
				string[length] = 0;
				info.UTF8Info.bytes = string;
				toDelete.push_back(string);
			}
			break;
		case CONSTANT_Integer:
			stream >> info.IntegerInfo.bytes;
			break;
		case CONSTANT_Float:
			stream >> info.FloatInfo.bytes;
			break;
		case CONSTANT_Long:
			stream >> info.BigIntInfo.bytes;
			isDoubleSize = true;
			break;
		case CONSTANT_Double:
			stream >> info.DoubleInfo.bytes;
			isDoubleSize = true;
			break;
		case CONSTANT_Class:
			stream >> info.ClassInfo.name_index;
			break;
		case CONSTANT_String:
			stream >> info.StringInfo.string_index;
			break;
		case CONSTANT_Fieldref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_Methodref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_InterfaceMethodref:
			stream >> info.RefInfo.class_index;
			stream >> info.RefInfo.name_and_type_index;
			break;
		case CONSTANT_NameAndType:
			stream >> info.NameAndTypeInfo.name_index;
			stream >> info.NameAndTypeInfo.descriptor_index;
			break;
		case CONSTANT_MethodHandle:
			stream >> info.MethodHandleInfo.reference_kind;
			stream >> info.MethodHandleInfo.reference_index;
			break;
		case CONSTANT_MethodType:
			stream >> info.MethodTypeInfo.descriptor_index;
			break;
		case CONSTANT_InvokeDynamic:
			stream >> info.InvokeDynamicInfo.bootstrap_method_attr_index;
			stream >> info.InvokeDynamicInfo.name_and_type_index;
			break;
		default:
			cerr << "ERROR: unrecognize TAG" << endl;
			exit(1);
	}
	
	constant_pool.push_back(info);
	
	return isDoubleSize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movb $0x0, -0x9(%rbp)
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
callq 0x3af0
movzbl -0x28(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x11, %eax
ja 0x494e
movq -0x40(%rbp), %rax
leaq 0x25974(%rip), %rcx     # 0x2a01c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x3b40
movzwl -0x2a(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movq $-0x1, %rax
cmpq $0x0, %rdi
cmovlq %rax, %rdi
callq 0x3030
movq -0x48(%rbp), %rdi
movq %rax, -0x38(%rbp)
addq $0xa8, %rdi
movq -0x38(%rbp), %rsi
movzwl -0x2a(%rbp), %eax
movl %eax, %edx
callq 0x3910
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rax
movzwl -0x2a(%rbp), %ecx
movb $0x0, (%rax,%rcx)
movq -0x38(%rbp), %rax
movq %rax, -0x18(%rbp)
addq $0x90, %rdi
leaq -0x38(%rbp), %rsi
callq 0x5ac0
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3ba0
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3ba0
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3c10
movb $0x1, -0x9(%rbp)
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3c10
movb $0x1, -0x9(%rbp)
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3af0
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
jmp 0x497a
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
callq 0x3b40
movq -0x48(%rbp), %rdi
addq $0xa8, %rdi
leaq -0x28(%rbp), %rsi
addq $0x8, %rsi
addq $0x2, %rsi
callq 0x3b40
jmp 0x497a
movq 0x3369b(%rip), %rdi     # 0x37ff0
leaq 0x257ae(%rip), %rsi     # 0x2a10a
callq 0x32a0
movq %rax, %rdi
movq 0x33655(%rip), %rsi     # 0x37fc0
callq 0x32d0
movl $0x1, %edi
callq 0x3330
leaq 0x33947(%rip), %rdi     # 0x382c8
leaq -0x28(%rbp), %rsi
callq 0x5b30
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)