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

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

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

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

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

		Expression *value = parseExpression(LOWEST);

		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 $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x60, %edi
callq 0x52a0
movq %rax, %rdi
movq %rdi, -0x40(%rbp)
movq %rdi, %rax
movq %rax, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x23ca0
jmp 0x2017d
movq -0x48(%rbp), %rsi
movq -0x38(%rbp), %rax
movq %rax, -0x18(%rbp)
addq $0x30, %rsi
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
callq 0x22d00
movq -0x48(%rbp), %rdi
leaq 0x4595b(%rip), %rsi     # 0x65b00
callq 0x21d00
testb $0x1, %al
jne 0x201f2
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x201c6
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20321
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x60, %esi
callq 0x52b0
jmp 0x2032b
movq -0x48(%rbp), %rdi
leaq 0x45923(%rip), %rsi     # 0x65b20
callq 0x21d00
testb $0x1, %al
jne 0x2022b
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x2021e
movq -0x58(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20321
movq -0x48(%rbp), %rdi
leaq 0x45a2a(%rip), %rsi     # 0x65c60
callq 0x21d00
testb $0x1, %al
jne 0x20264
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x20257
movq -0x60(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20321
jmp 0x20266
movq -0x48(%rbp), %rdi
addq $0x70, %rdi
leaq 0x45a0b(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x20280
jmp 0x202e3
movq -0x48(%rbp), %rdi
callq 0x1f390
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x21d60
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
leaq -0x30(%rbp), %rsi
callq 0x23c30
movq -0x48(%rbp), %rdi
addq $0x70, %rdi
leaq 0x459c8(%rip), %rsi     # 0x65c80
callq 0x22d80
testb $0x1, %al
jne 0x202c3
jmp 0x202e1
movq -0x48(%rbp), %rdi
leaq 0x458f2(%rip), %rsi     # 0x65bc0
callq 0x21d00
testb $0x1, %al
jne 0x202e1
movq $0x0, -0x8(%rbp)
jmp 0x20321
jmp 0x20266
movq -0x48(%rbp), %rdi
leaq 0x45992(%rip), %rsi     # 0x65c80
callq 0x21d00
testb $0x1, %al
jne 0x20319
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x2030f
movq -0x68(%rbp), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
movq $0x0, -0x8(%rbp)
jmp 0x20321
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x5490
nopw %cs:(%rax,%rax)