// File: menhits[P]phplus/src/ResolveLiteral.cpp
// Function: resolveLiteral(std::shared_ptr<TokenData>)
Action resolveLiteral(Token token)
{
	if (token->getType()==TokenData::STRING_LITERAL)
	{
		return resolveStringLiteral(token);
	}
	
	if (token->getType()!=TokenData::LITERAL)
	{
		throw PhplusError(FUNC+" called on token that is not a literal", INTERNAL_ERROR, token);
	}
	
	string in=token->getText();
	
	if (in.empty())
		return nullptr;
	
	//bool floatingPoint=false;
	
	Type type=Unknown;
	
	if (in.empty())
	{
		error.log("tried to make literal with empty string", INTERNAL_ERROR, token);
	}
	
	if ((in[0]>='0' && in[0]<='9') || in[0]=='.')
	{
		type=Int;
		
		for (auto i=in.begin(); i!=in.end(); ++i)
		{
			if (*i=='.' || *i=='_')
			{
				type=Dub;
				break;
			}
		}
		
		if (in.back()=='d' || in.back()=='f')
		{
			type=Dub;
			in.pop_back();
		}
		else if (in.back()=='i')
		{
			type=Int;
			in.pop_back();
		}
		else if (in.back()=='b')
		{
			type=Bool;
			in.pop_back();
		}
	}
	
	if (type==Int)
	{
		return resolveIntLiteral(token, type);
	}
	else if (type==Dub) //floating point
	{
		return resolveDubLiteral(token);
	}
	else
	{
		throw PhplusError("tried to make literal with invalid type of " + type->getString(), INTERNAL_ERROR, token);
	}
}

// Assembly:
subq $0x228, %rsp            # imm = 0x228
movq %rsi, 0x78(%rsp)
movq %rdi, %rax
movq 0x78(%rsp), %rdi
movq %rax, 0x80(%rsp)
movq %rax, %rcx
movq %rcx, 0x88(%rsp)
movq %rax, 0x220(%rsp)
movq %rdi, 0x218(%rsp)
callq 0x1bb70
movq %rax, %rdi
callq 0x1bee0
cmpl $0x4, %eax
jne 0x9ae6c
movq 0x78(%rsp), %rsi
leaq 0x208(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x1bc90
movq 0x80(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0x9aa40
jmp 0x9ae34
leaq 0x208(%rsp), %rdi
callq 0xfc00
jmp 0x9b5dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x208(%rsp), %rdi
callq 0xfc00
jmp 0x9b5ec
movq 0x78(%rsp), %rdi
callq 0x1bb70
movq %rax, %rdi
callq 0x1bee0
cmpl $0x3, %eax
je 0x9afd2
movb $0x1, 0x19f(%rsp)
movl $0x38, %edi
callq 0xb1f0
movq %rax, 0x60(%rsp)
leaq 0x1b7(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xb690
movq 0x68(%rsp), %rdx
leaq 0x3ab6b(%rip), %rsi     # 0xd5a27
leaq 0x1b8(%rsp), %rdi
callq 0xb4c0
jmp 0x9aecb
leaq 0x3ab64(%rip), %rdx     # 0xd5a36
leaq 0x1d8(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0xfa60
jmp 0x9aee9
movq 0x78(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x1bc90
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rcx
leaq 0x1d8(%rsp), %rsi
movl $0x3, %edx
callq 0x35600
jmp 0x9af1e
movq 0x60(%rsp), %rdi
movb $0x0, 0x19f(%rsp)
leaq 0x7a696(%rip), %rsi     # 0x1155c8
leaq -0x808c9(%rip), %rdx    # 0x1a670
callq 0xb640
jmp 0x9b5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9afaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9af9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x1a0(%rsp), %rdi
callq 0xfc00
leaq 0x1d8(%rsp), %rdi
callq 0xb6e8
leaq 0x1b8(%rsp), %rdi
callq 0xb6e8
leaq 0x1b7(%rsp), %rdi
callq 0xb3f0
testb $0x1, 0x19f(%rsp)
jne 0x9afc3
jmp 0x9afcd
movq 0x60(%rsp), %rdi
callq 0xb2d0
jmp 0x9b5ec
movq 0x78(%rsp), %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x178(%rsp), %rdi
callq 0x1bb80
leaq 0x178(%rsp), %rdi
callq 0xb610
testb $0x1, %al
jne 0x9afff
jmp 0x9b020
movq 0x80(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1bcd0
movl $0x1, 0x174(%rsp)
jmp 0x9b5cf
leaq 0x160(%rsp), %rdi
leaq 0x7d469(%rip), %rsi     # 0x118498
callq 0x1a920
leaq 0x178(%rsp), %rdi
callq 0xb610
testb $0x1, %al
jne 0x9b04a
jmp 0x9b12d
leaq 0x13f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xb690
movq 0x50(%rsp), %rdx
leaq 0x3a9f5(%rip), %rsi     # 0xd5a5d
leaq 0x140(%rsp), %rdi
callq 0xb4c0
jmp 0x9b077
movq 0x78(%rsp), %rsi
leaq 0x128(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x1bc90
movq 0x48(%rsp), %rcx
leaq 0x7d329(%rip), %rdi     # 0x1183c3
leaq 0x140(%rsp), %rsi
movl $0x3, %edx
callq 0x34c70
jmp 0x9b0ae
leaq 0x128(%rsp), %rdi
callq 0xfc00
leaq 0x140(%rsp), %rdi
callq 0xb6e8
leaq 0x13f(%rsp), %rdi
callq 0xb3f0
jmp 0x9b12d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9b11b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xfc00
leaq 0x140(%rsp), %rdi
callq 0xb6e8
leaq 0x13f(%rsp), %rdi
callq 0xb3f0
jmp 0x9b5b3
xorl %eax, %eax
movl %eax, %esi
leaq 0x178(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x40(%rsp)
jmp 0x9b145
movq 0x40(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x9b177
xorl %eax, %eax
movl %eax, %esi
leaq 0x178(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x38(%rsp)
jmp 0x9b16a
movq 0x38(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jle 0x9b1a0
xorl %eax, %eax
movl %eax, %esi
leaq 0x178(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x30(%rsp)
jmp 0x9b18f
movq 0x30(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x9b327
leaq 0x160(%rsp), %rdi
leaq 0x7d339(%rip), %rsi     # 0x1184e8
callq 0x1a4e0
leaq 0x178(%rsp), %rdi
callq 0xb320
movq %rax, 0x120(%rsp)
leaq 0x178(%rsp), %rdi
callq 0xb230
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x9b600
testb $0x1, %al
jne 0x9b1f9
jmp 0x9b266
leaq 0x120(%rsp), %rdi
callq 0x9b640
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x9b223
leaq 0x120(%rsp), %rdi
callq 0x9b640
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x9b252
leaq 0x160(%rsp), %rdi
leaq 0x7d2c6(%rip), %rsi     # 0x1184f8
callq 0x1a4e0
jmp 0x9b266
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9b5b3
jmp 0x9b254
leaq 0x120(%rsp), %rdi
callq 0x9b650
jmp 0x9b1c9
leaq 0x178(%rsp), %rdi
callq 0xb2c0
movsbl (%rax), %eax
cmpl $0x64, %eax
je 0x9b290
leaq 0x178(%rsp), %rdi
callq 0xb2c0
movsbl (%rax), %eax
cmpl $0x66, %eax
jne 0x9b2b3
leaq 0x160(%rsp), %rdi
leaq 0x7d259(%rip), %rsi     # 0x1184f8
callq 0x1a4e0
leaq 0x178(%rsp), %rdi
callq 0xb440
jmp 0x9b325
leaq 0x178(%rsp), %rdi
callq 0xb2c0
movsbl (%rax), %eax
cmpl $0x69, %eax
jne 0x9b2eb
leaq 0x160(%rsp), %rdi
leaq 0x7d211(%rip), %rsi     # 0x1184e8
callq 0x1a4e0
leaq 0x178(%rsp), %rdi
callq 0xb440
jmp 0x9b323
leaq 0x178(%rsp), %rdi
callq 0xb2c0
movsbl (%rax), %eax
cmpl $0x62, %eax
jne 0x9b321
leaq 0x160(%rsp), %rdi
leaq 0x7d1b9(%rip), %rsi     # 0x1184c8
callq 0x1a4e0
leaq 0x178(%rsp), %rdi
callq 0xb440
jmp 0x9b323
jmp 0x9b325
jmp 0x9b327
leaq 0x160(%rsp), %rdi
leaq 0x7d1b2(%rip), %rsi     # 0x1184e8
callq 0x9b670
testb $0x1, %al
jne 0x9b344
jmp 0x9b3eb
movq 0x78(%rsp), %rsi
leaq 0x108(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x1bc90
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0x160(%rsp), %rsi
callq 0x1a920
movq 0x80(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
callq 0x99dc0
jmp 0x9b38e
leaq 0xf8(%rsp), %rdi
callq 0x1a950
leaq 0x108(%rsp), %rdi
callq 0xfc00
movl $0x1, 0x174(%rsp)
jmp 0x9b5a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x1a950
leaq 0x108(%rsp), %rdi
callq 0xfc00
jmp 0x9b5b3
leaq 0x160(%rsp), %rdi
leaq 0x7d0fe(%rip), %rsi     # 0x1184f8
callq 0x9b670
testb $0x1, %al
jne 0x9b405
jmp 0x9b473
movq 0x78(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x1bc90
movq 0x80(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x9a360
jmp 0x9b430
leaq 0xe8(%rsp), %rdi
callq 0xfc00
movl $0x1, 0x174(%rsp)
jmp 0x9b5a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0xfc00
jmp 0x9b5b3
movb $0x1, 0x97(%rsp)
movl $0x38, %edi
callq 0xb1f0
movq %rax, 0x10(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x1a660
movq %rax, %rsi
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq 0xa8(%rsp), %rdi
callq *%rax
jmp 0x9b4ad
leaq 0x3a5d1(%rip), %rsi     # 0xd5a85
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x1bcf0
jmp 0x9b4cb
movq 0x78(%rsp), %rsi
leaq 0x98(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x1bc90
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rcx
leaq 0xc8(%rsp), %rsi
movl $0x3, %edx
callq 0x35600
jmp 0x9b500
movq 0x10(%rsp), %rdi
movb $0x0, 0x97(%rsp)
leaq 0x7a0b4(%rip), %rsi     # 0x1155c8
leaq -0x80eab(%rip), %rdx    # 0x1a670
callq 0xb640
jmp 0x9b5f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9b58c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
jmp 0x9b57f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x200(%rsp)
movl %eax, 0x1fc(%rsp)
leaq 0x98(%rsp), %rdi
callq 0xfc00
leaq 0xc8(%rsp), %rdi
callq 0xb6e8
leaq 0xa8(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0x97(%rsp)
jne 0x9b598
jmp 0x9b5a2
movq 0x10(%rsp), %rdi
callq 0xb2d0
jmp 0x9b5b3
leaq 0x160(%rsp), %rdi
callq 0x1a950
jmp 0x9b5cf
leaq 0x160(%rsp), %rdi
callq 0x1a950
leaq 0x178(%rsp), %rdi
callq 0xb6e8
jmp 0x9b5ec
leaq 0x178(%rsp), %rdi
callq 0xb6e8
movq 0x88(%rsp), %rax
addq $0x228, %rsp            # imm = 0x228
retq
movq 0x200(%rsp), %rdi
callq 0xb680
nopl (%rax)