// File: AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::Assignment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool Parser::Assignment(string &id){
	int type, size, dType, dSize;
	bool found;
	scopeValue destinationValue;
	bool isGlobal;
	bool indirect;
	int indirect_type;
	
	//Determine destination if this is a valid assignment statement
	if( !Destination(id, dType, dSize, destinationValue, found, isGlobal, indirect, indirect_type) ) return false;
	
	//get assignment expression
	if( CheckToken(T_ASSIGNMENT) ){
		Expression(type, size);

		if(found){
			if(size != dSize && (size > 1) && (dSize <= 1)) ReportError("Bad assignment, size of expression must match destination's size.");
			if( (type != dType) && ( (!isNumber(dType)) || (!isNumber(type)) ) ) ReportError("Bad assignment, type of expression must match destination");
		}
		// Move expression result from register(s) to MM using one of the various addressing modes.
		generator->reg2mm( type, dType, size, dSize, destinationValue.FPoffset, isGlobal, indirect, indirect_type );
		return true;
	}
	else{
		ReportLineError("Bad line. Expected ':=' after destination in assignment statement", false);
		return true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x126b0
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %r8
movq -0x20(%rbp), %rsi
movq %rsp, %rax
leaq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x82(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x81(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x2c(%rbp), %rdx
leaq -0x30(%rbp), %rcx
leaq -0x31(%rbp), %r9
callq 0xf3f0
movb %al, -0x12a(%rbp)
jmp 0xf04d
movb -0x12a(%rbp), %al
testb $0x1, %al
jne 0xf083
jmp 0xf059
movb $0x0, -0x9(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xf3b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xf3ce
movq -0x140(%rbp), %rdi
movl $0x13a, %esi            # imm = 0x13A
callq 0x9300
movb %al, -0x141(%rbp)
jmp 0xf09c
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0xf0ab
jmp 0xf308
movq -0x140(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0xcab0
jmp 0xf0c1
testb $0x1, -0x31(%rbp)
je 0xf287
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0xf18c
cmpl $0x1, -0x28(%rbp)
jle 0xf18c
cmpl $0x1, -0x30(%rbp)
jg 0xf18c
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3430
movq -0x150(%rbp), %rdx
leaq 0x16c98(%rip), %rsi     # 0x25da4
leaq -0xb8(%rbp), %rdi
callq 0x62d0
jmp 0xf11a
movq -0x140(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x9060
jmp 0xf12f
leaq -0xb8(%rbp), %rdi
callq 0x31a0
leaq -0xb9(%rbp), %rdi
callq 0x32e0
jmp 0xf18c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xf17b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x31a0
leaq -0xb9(%rbp), %rdi
callq 0x32e0
jmp 0xf3ce
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0xf285
movq -0x140(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0xf850
movb %al, -0x151(%rbp)
jmp 0xf1b0
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0xf1bc
jmp 0xf1e4
movq -0x140(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0xf850
movb %al, -0x152(%rbp)
jmp 0xf1d4
movb -0x152(%rbp), %al
testb $0x1, %al
jne 0xf285
jmp 0xf1e4
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3430
movq -0x160(%rbp), %rdx
leaq 0x16be1(%rip), %rsi     # 0x25de6
leaq -0xe0(%rbp), %rdi
callq 0x62d0
jmp 0xf213
movq -0x140(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x9060
jmp 0xf228
leaq -0xe0(%rbp), %rdi
callq 0x31a0
leaq -0xe1(%rbp), %rdi
callq 0x32e0
jmp 0xf285
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xf274
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x31a0
leaq -0xe1(%rbp), %rdi
callq 0x32e0
jmp 0xf3ce
jmp 0xf287
movq -0x140(%rbp), %rax
movq 0x98(%rax), %rsi
movl -0x24(%rbp), %edx
movl -0x2c(%rbp), %ecx
movl -0x28(%rbp), %r8d
movl -0x30(%rbp), %r9d
movl -0x3c(%rbp), %edi
movl -0x88(%rbp), %ebx
movzbl -0x81(%rbp), %r10d
movzbl -0x82(%rbp), %r11d
movq %rsp, %rax
movl %ebx, 0x18(%rax)
andl $0x1, %r11d
movl %r11d, 0x10(%rax)
andl $0x1, %r10d
movl %r10d, 0x8(%rax)
movl %edi, (%rax)
movl $0x0, 0x20(%rax)
leaq -0x108(%rbp), %rdi
callq 0x1d2f0
jmp 0xf2e9
leaq -0x108(%rbp), %rdi
callq 0x31a0
movb $0x1, -0x9(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xf3b6
leaq -0x129(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x3430
movq -0x168(%rbp), %rdx
leaq 0x16af7(%rip), %rsi     # 0x25e20
leaq -0x128(%rbp), %rdi
callq 0x62d0
jmp 0xf337
movq -0x140(%rbp), %rdi
leaq -0x128(%rbp), %rsi
xorl %edx, %edx
callq 0x8b50
jmp 0xf34e
leaq -0x128(%rbp), %rdi
callq 0x31a0
leaq -0x129(%rbp), %rdi
callq 0x32e0
movb $0x1, -0x9(%rbp)
movl $0x1, -0x98(%rbp)
jmp 0xf3b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0xf3a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x31a0
leaq -0x129(%rbp), %rdi
callq 0x32e0
jmp 0xf3ce
leaq -0x80(%rbp), %rdi
callq 0x12800
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x12800
movq -0x90(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)