1 #include "LiteralPool.h"
2 
CLiteralPool(Framework::CStream * stream)3 CLiteralPool::CLiteralPool(Framework::CStream* stream)
4 : m_stream(stream)
5 {
6 
7 }
8 
AlignPool()9 void CLiteralPool::AlignPool()
10 {
11 	unsigned int alignSize = m_stream->Tell() & 0x0F;
12 	if(alignSize != 0)
13 	{
14 		LITERAL128 tempLit(0, 0);
15 		m_stream->Write(&tempLit, 0x10 - alignSize);
16 	}
17 }
18 
GetLiteralPosition(const LITERAL128 & literal)19 uint64 CLiteralPool::GetLiteralPosition(const LITERAL128& literal)
20 {
21 	auto literalPosIterator = m_literalPositions.find(literal);
22 	if(literalPosIterator == std::end(m_literalPositions))
23 	{
24 		m_stream->Seek(0, Framework::STREAM_SEEK_END);
25 		uint32 literalPos = m_stream->Tell();
26 		m_stream->Write64(literal.lo);
27 		m_stream->Write64(literal.hi);
28 		m_literalPositions.insert(std::make_pair(literal, literalPos));
29 		return literalPos;
30 	}
31 	else
32 	{
33 		return literalPosIterator->second;
34 	}
35 }
36