// File: iamlouk[P]asbi/src/parser.cc
// Function: asbi::Parser::parse_map(ast::Node*)
ast::Map* Parser::parse_map(ast::Node* firstkey) {
	std::vector<std::pair<ast::Node*,ast::Node*>> values;
	values.push_back(std::make_pair(firstkey, parse_expr()));
	auto t = tokenizer.next();
	while (t.type == tok::Comma) {
		auto key = parse_expr();
		expect(tok::KeyValue);
		auto value = parse_expr();
		values.push_back(std::make_pair(key, value));
		t = tokenizer.next();
	}
	if (t.type != tok::RightSquareBracket)
		throw utils::parser_error("expected ',' or ')' while parsing map", t);

	return new ast::Map(std::move(values));
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x12710
movq 0x70(%rsp), %rdi
callq 0xe090
movq %rax, 0x78(%rsp)
jmp 0x11992
movq 0x78(%rsp), %rax
movq %rax, 0x108(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x12a80
movq %rdx, 0x60(%rsp)
movq %rax, 0x68(%rsp)
jmp 0x119c0
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq %rcx, 0x110(%rsp)
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x110(%rsp), %rsi
callq 0x12a50
jmp 0x119f1
movq 0x70(%rsp), %rdi
callq 0x9340
movq %rdx, 0x50(%rsp)
movq %rax, 0x58(%rsp)
jmp 0x11a07
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, 0xe8(%rsp)
movq %rax, 0xf0(%rsp)
cmpl $0x1d, 0xe8(%rsp)
jne 0x11b3c
movq 0x70(%rsp), %rdi
callq 0xe090
movq %rax, 0x48(%rsp)
jmp 0x11a40
movq 0x70(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl $0xd, %esi
callq 0xdcd0
jmp 0x11a5e
movq 0x70(%rsp), %rdi
callq 0xe090
movq %rax, 0x40(%rsp)
jmp 0x11a6f
movq 0x40(%rsp), %rax
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x12ac0
movq %rdx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
jmp 0x11a9d
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0xc8(%rsp)
movq %rax, 0xd0(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x12a50
jmp 0x11ace
movq 0x70(%rsp), %rdi
callq 0x9340
movq %rdx, 0x20(%rsp)
movq %rax, 0x28(%rsp)
jmp 0x11ae4
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x11a21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
jmp 0x11c7e
cmpl $0x1c, 0xe8(%rsp)
je 0x11bcd
movl $0x48, %edi
callq 0x6200
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
movups 0xe8(%rsp), %xmm0
movaps %xmm0, 0xa0(%rsp)
movq 0xa0(%rsp), %rdx
movq 0xa8(%rsp), %rcx
leaq 0x26e0c(%rip), %rsi     # 0x38992
callq 0x17350
jmp 0x11b8d
movq 0x18(%rsp), %rdi
leaq 0x3998f(%rip), %rsi     # 0x4b528
leaq 0x100(%rip), %rdx       # 0x11ca0
callq 0x6780
jmp 0x11c98
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
callq 0x6320
jmp 0x11c7e
movl $0x20, %edi
callq 0x6460
movq %rax, 0x10(%rsp)
jmp 0x11bde
movb $0x1, 0x87(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x8(%rsp)
leaq 0x120(%rsp), %rsi
callq 0x12b00
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x12720
jmp 0x11c11
movb $0x0, 0x87(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x12790
leaq 0x120(%rsp), %rdi
callq 0x12790
movq 0x10(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x100(%rsp)
movl %eax, 0xfc(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x12790
testb $0x1, 0x87(%rsp)
jne 0x11c6d
jmp 0x11c7c
movq 0x10(%rsp), %rdi
movl $0x20, %esi
callq 0x6470
jmp 0x11c7e
leaq 0x120(%rsp), %rdi
callq 0x12790
movq 0x100(%rsp), %rdi
callq 0x67a0
nopl (%rax,%rax)