// File: pranavmodx[P]modlang/src/parser.cpp
// Function: Parser::parseFunctionParameters()
std::vector<Identifier *> Parser::parseFunctionParameters()
{
	std::vector<Identifier *> parameters;

	if (peekToken.type == RPAREN)
	{ // no parameters
		nextToken();
		return parameters;
	}

	nextToken(); // pass "," or "("

	Identifier *ident = new Identifier();
	ident->token = curToken;
	ident->value = curToken.literal;
	parameters.push_back(ident);

	while (peekToken.type == COMMA)
	{
		nextToken();
		nextToken();
		Identifier *ident = new Identifier();
		ident->token = curToken;
		ident->value = curToken.literal;
		parameters.push_back(ident);
	}

	if (!expectPeek(RPAREN))
		return std::vector<Identifier *>();

	return parameters;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x60(%rbp)
movq %rdi, %rax
movq %rax, -0x58(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x23830
movq -0x50(%rbp), %rdi
addq $0x70, %rdi
leaq 0x43522(%rip), %rsi     # 0x65c40
callq 0x16920
testb $0x1, %al
jne 0x22729
jmp 0x2275e
movq -0x50(%rbp), %rdi
callq 0x1f390
jmp 0x22734
movq -0x60(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x23850
movl $0x1, -0x38(%rbp)
jmp 0x228f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x22908
movq -0x50(%rbp), %rdi
callq 0x1f390
jmp 0x22769
movl $0x68, %edi
callq 0x52a0
movq %rax, -0x68(%rbp)
jmp 0x22779
movq -0x68(%rbp), %rdi
callq 0x23880
jmp 0x22784
movq -0x50(%rbp), %rsi
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
addq $0x30, %rsi
movq -0x40(%rbp), %rdi
addq $0x8, %rdi
callq 0x22d00
jmp 0x227a3
movq -0x50(%rbp), %rsi
addq $0x50, %rsi
movq -0x40(%rbp), %rdi
addq $0x48, %rdi
callq 0x5050
jmp 0x227ba
leaq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x238f0
jmp 0x227c9
jmp 0x227cb
movq -0x50(%rbp), %rdi
addq $0x70, %rdi
leaq 0x433e6(%rip), %rsi     # 0x65bc0
callq 0x16920
testb $0x1, %al
jne 0x227e8
jmp 0x2289e
movq -0x50(%rbp), %rdi
callq 0x1f390
jmp 0x227f3
movq -0x50(%rbp), %rdi
callq 0x1f390
jmp 0x227fe
movl $0x68, %edi
callq 0x52a0
movq %rax, -0x70(%rbp)
jmp 0x2280e
movq -0x70(%rbp), %rdi
callq 0x23880
jmp 0x22819
movq -0x50(%rbp), %rsi
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
addq $0x30, %rsi
movq -0x48(%rbp), %rdi
addq $0x8, %rdi
callq 0x22d00
jmp 0x22838
movq -0x50(%rbp), %rsi
addq $0x50, %rsi
movq -0x48(%rbp), %rdi
addq $0x48, %rdi
callq 0x5050
jmp 0x2284f
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x238f0
jmp 0x2285e
jmp 0x227cb
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x68, %esi
callq 0x52b0
jmp 0x22908
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
movl $0x68, %esi
callq 0x52b0
jmp 0x22908
movq -0x50(%rbp), %rdi
leaq 0x43397(%rip), %rsi     # 0x65c40
callq 0x21d00
movb %al, -0x71(%rbp)
jmp 0x228b3
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x228de
jmp 0x228bc
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x5170
movq -0x60(%rbp), %rdi
callq 0x23830
movl $0x1, -0x38(%rbp)
jmp 0x228f2
movq -0x60(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x23850
movl $0x1, -0x38(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1e440
movq -0x58(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x1e440
movq -0x30(%rbp), %rdi
callq 0x5490
nopw (%rax,%rax)