// File: pranavmodx[P]modlang/src/parser.cpp
// Function: Parser::parseMaxHeapLiteral()
Expression *Parser::parseMaxHeapLiteral()
{
	MaxHeapLiteral *exp = new MaxHeapLiteral();
	exp->token = curToken;

	if (!expectPeek(LT))
	{
		delete exp;
		return nullptr;
	}

	if (peekToken.type != INTEGER && peekToken.type != STRING) {
		delete exp;
		peekTypeError();
		return nullptr;
	}

	nextToken();

	exp->type = curToken.type;

	if (!expectPeek(GT))
	{
		delete exp;
		return nullptr;
	}

	if (!expectPeek(LBRACE))
	{
		delete exp;
		return nullptr;
	}

	while (peekToken.type != RBRACE)
	{
		nextToken();

		Expression *value = parseExpression(LOWEST);

		if (value->getTokenType() != exp->type) {
			curTypeError(exp->type);
			return nullptr;
		}

		exp->elements.push_back(value);

		if (peekToken.type != RBRACE && !expectPeek(COMMA))
			return nullptr;
	}

	if (!expectPeek(RBRACE))
	{
		delete exp;
		return nullptr;
	}

	return exp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movl $0x80, %edi
callq 0x52a0
movq %rax, %rdi
movq %rdi, -0x90(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
movaps %xmm0, 0x70(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x23df0
jmp 0x207a5
movq -0x98(%rbp), %rsi
movq -0x88(%rbp), %rax
movq %rax, -0x18(%rbp)
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x22d00
movq -0x98(%rbp), %rdi
leaq 0x4532a(%rip), %rsi     # 0x65b00
callq 0x21d00
testb $0x1, %al
jne 0x2082c
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x207fd
movq -0xa0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x80, %esi
callq 0x52b0
jmp 0x20ac4
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x451a2(%rip), %rsi     # 0x659e0
callq 0x22d80
testb $0x1, %al
jne 0x20849
jmp 0x2089d
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x451a5(%rip), %rsi     # 0x65a00
callq 0x22d80
testb $0x1, %al
jne 0x20866
jmp 0x2089d
movq -0x18(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x20884
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq -0x98(%rbp), %rdi
callq 0x222c0
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
movq -0x98(%rbp), %rdi
callq 0x1f390
movq -0x98(%rbp), %rsi
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
callq 0x5050
movq -0x98(%rbp), %rdi
leaq 0x45251(%rip), %rsi     # 0x65b20
callq 0x21d00
testb $0x1, %al
jne 0x20903
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x208f6
movq -0xb0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
movq -0x98(%rbp), %rdi
leaq 0x4534f(%rip), %rsi     # 0x65c60
callq 0x21d00
testb $0x1, %al
jne 0x20945
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
je 0x20938
movq -0xb8(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
jmp 0x20947
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x45327(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x20967
jmp 0x20a70
movq -0x98(%rbp), %rdi
callq 0x1f390
movq -0x98(%rbp), %rdi
xorl %esi, %esi
callq 0x21d60
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movq (%rsi), %rax
leaq -0x50(%rbp), %rdi
callq *0x30(%rax)
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
leaq -0x50(%rbp), %rdi
callq 0x22d80
movb %al, -0xb9(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5518
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0x209bf
jmp 0x20a1c
movq -0x18(%rbp), %rsi
addq $0x48, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x5130
movq -0x98(%rbp), %rdi
movq -0xc8(%rbp), %rsi
callq 0x22370
jmp 0x209ec
leaq -0x70(%rbp), %rdi
callq 0x5518
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5518
jmp 0x20ac4
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
leaq -0x30(%rbp), %rsi
callq 0x23c30
movq -0x98(%rbp), %rdi
addq $0x70, %rdi
leaq 0x45241(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x20a4a
jmp 0x20a6b
movq -0x98(%rbp), %rdi
leaq 0x45168(%rip), %rsi     # 0x65bc0
callq 0x21d00
testb $0x1, %al
jne 0x20a6b
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
jmp 0x20947
movq -0x98(%rbp), %rdi
leaq 0x45202(%rip), %rsi     # 0x65c80
callq 0x21d00
testb $0x1, %al
jne 0x20aaf
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x20aa5
movq -0xd0(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20ab7
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x5490
nopl (%rax)