// File: AndrewAlbert[P]Compiler-Theory/SourceCode/scope.cpp
// Function: scope::printScope()
void scope::printScope(){
	int i;
	cout << "\n" << endl;
	for(i = 0; i < 20; i++)
		cout << "|-";
	cout << "|" << endl;

	// Show the local symbol table entries
	cout << "\nSCOPE: " << name << "\n\nLocal Symbol Table:" << endl;
	map<string, scopeValue>::iterator it;
	for(it = localTable.begin(); it != localTable.end(); it++){
		cout << "id: " << it->first;
		
		// Display the symbol's type identifier
		cout << "\ttype: ";
		switch(it->second.type){
			case TYPE_INTEGER:
				cout << "Integer";
				break;
			case TYPE_FLOAT:
				cout << "Float";
				break;
			case TYPE_CHAR:
				cout << "Char";
				break;
			case TYPE_STRING:
				cout << "String";
				break;
			case TYPE_BOOL:
				cout << "Bool";
				break;
			case TYPE_PROCEDURE:
				cout << "Procedure";
				break;
			default:
				cout << "Unknown";
				break;
		}
		
		// Display frame pointer offset for variables in the scope
		if (it->second.type != TYPE_PROCEDURE) cout << "\n\tFP offset: " << it->second.FPoffset;
		
		// Display all parameter types for procedure entries ex: Integer[5] In/Out
		if(it->second.type == TYPE_PROCEDURE){
			cout << "\n\tparameters:\n\t";
			vector<scopeValue> Vec = it->second.arguments;		
			vector<scopeValue>::size_type vec_it;
			for(vec_it = 0; vec_it != Vec.size(); vec_it++){
				if(vec_it != 0) cout << ", ";
				//cout << Vec[vec_it].type << "\t";
				switch(Vec[vec_it].type){
					case TYPE_INTEGER:
						cout << "Integer";
						break;
					case TYPE_FLOAT:
						cout << "Float";
						break;
					case TYPE_CHAR:
						cout << "Char";
						break;
					case TYPE_STRING:
						cout << "String";
						break;
					case TYPE_BOOL:
						cout << "Bool";
						break;
					case TYPE_PROCEDURE:
						cout << "Procedure";
						break;
					default:
						cout << "Unknown";
						break;
				}
				if(Vec[vec_it].size > 0) cout << "[" << Vec[vec_it].size << "]";
				switch(Vec[vec_it].paramType){
					case TYPE_PARAM_IN:
						cout << " In";
						break;
					case TYPE_PARAM_OUT:
						cout << " Out";
						break;
					case TYPE_PARAM_INOUT:
						cout << " In/Out";
						break;
					default:
						cout << " ?";
						break;
				}
			}
		cout << "\n" << endl;
		}
		else cout << "\n\tsize: " << it->second.size << "\n" << endl;
	}

	for(i = 0; i < 20; i++)
		cout << "|-";
	cout << "|" << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x1d422(%rip), %rdi     # 0x32fd0
leaq 0x1135d(%rip), %rsi     # 0x26f12
callq 0x3270
movq %rax, %rdi
movq 0x1d3f4(%rip), %rsi     # 0x32fb8
callq 0x32c0
movl $0x0, -0xc(%rbp)
cmpl $0x14, -0xc(%rbp)
jge 0x15bf4
movq 0x1d3f3(%rip), %rdi     # 0x32fd0
leaq 0x11020(%rip), %rsi     # 0x26c04
callq 0x3270
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x15bd0
movq 0x1d3d5(%rip), %rdi     # 0x32fd0
leaq 0x114fa(%rip), %rsi     # 0x270fc
callq 0x3270
movq %rax, %rdi
movq 0x1d3a7(%rip), %rsi     # 0x32fb8
callq 0x32c0
movq 0x1d3b3(%rip), %rdi     # 0x32fd0
leaq 0x10fe3(%rip), %rsi     # 0x26c07
callq 0x3270
movq -0x68(%rbp), %rsi
movq %rax, %rdi
addq $0x60, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x10fcd(%rip), %rsi     # 0x26c10
callq 0x3270
movq %rax, %rdi
movq 0x1d366(%rip), %rsi     # 0x32fb8
callq 0x32c0
leaq -0x18(%rbp), %rdi
callq 0x161e0
movq -0x68(%rbp), %rdi
addq $0x30, %rdi
callq 0x16640
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x68(%rbp), %rdi
addq $0x30, %rdi
callq 0x16260
movq %rax, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x16230
testb $0x1, %al
jne 0x15ca0
jmp 0x1613a
movq 0x1d329(%rip), %rdi     # 0x32fd0
movq %rdi, -0x80(%rbp)
leaq 0x10f74(%rip), %rsi     # 0x26c26
callq 0x3270
movq %rax, -0x88(%rbp)
leaq -0x18(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x163d0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x3260
movq -0x80(%rbp), %rdi
leaq 0x10f46(%rip), %rsi     # 0x26c2b
callq 0x3270
movq -0x78(%rbp), %rdi
callq 0x163d0
movl 0x20(%rax), %eax
addl $0xfffffef6, %eax       # imm = 0xFFFFFEF6
movl %eax, %ecx
movq %rcx, -0x70(%rbp)
subl $0x14, %eax
ja 0x15d9c
movq -0x70(%rbp), %rax
leaq 0x10e47(%rip), %rcx     # 0x26b5c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x1d2ab(%rip), %rdi     # 0x32fd0
leaq 0x10f07(%rip), %rsi     # 0x26c33
callq 0x3270
jmp 0x15daf
movq 0x1d296(%rip), %rdi     # 0x32fd0
leaq 0x10efa(%rip), %rsi     # 0x26c3b
callq 0x3270
jmp 0x15daf
movq 0x1d281(%rip), %rdi     # 0x32fd0
leaq 0x10eeb(%rip), %rsi     # 0x26c41
callq 0x3270
jmp 0x15daf
movq 0x1d26c(%rip), %rdi     # 0x32fd0
leaq 0x10edb(%rip), %rsi     # 0x26c46
callq 0x3270
jmp 0x15daf
movq 0x1d257(%rip), %rdi     # 0x32fd0
leaq 0x10ecd(%rip), %rsi     # 0x26c4d
callq 0x3270
jmp 0x15daf
movq 0x1d242(%rip), %rdi     # 0x32fd0
leaq 0x10ebd(%rip), %rsi     # 0x26c52
callq 0x3270
jmp 0x15daf
movq 0x1d22d(%rip), %rdi     # 0x32fd0
leaq 0x10eb2(%rip), %rsi     # 0x26c5c
callq 0x3270
leaq -0x18(%rbp), %rdi
callq 0x163d0
cmpl $0x11e, 0x20(%rax)      # imm = 0x11E
je 0x15df3
movq 0x1d208(%rip), %rdi     # 0x32fd0
leaq 0x10e95(%rip), %rsi     # 0x26c64
callq 0x3270
movq %rax, -0x90(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x163d0
movq -0x90(%rbp), %rdi
movl 0x64(%rax), %esi
callq 0x3410
leaq -0x18(%rbp), %rdi
callq 0x163d0
cmpl $0x11e, 0x20(%rax)      # imm = 0x11E
jne 0x160d4
movq 0x1d1c0(%rip), %rdi     # 0x32fd0
leaq 0x10e5b(%rip), %rsi     # 0x26c72
callq 0x3270
leaq -0x18(%rbp), %rdi
callq 0x163d0
movq %rax, %rsi
addq $0x20, %rsi
addq $0x8, %rsi
leaq -0x40(%rbp), %rdi
callq 0x133d0
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x134c0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
je 0x16098
cmpq $0x0, -0x48(%rbp)
je 0x15ea0
movq 0x1d15a(%rip), %rdi     # 0x32fd0
leaq 0x10e05(%rip), %rsi     # 0x26c82
callq 0x3270
jmp 0x15e84
jmp 0x15ea0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x12930
jmp 0x16190
movq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16670
movl (%rax), %eax
addl $0xfffffef6, %eax       # imm = 0xFFFFFEF6
movl %eax, %ecx
movq %rcx, -0xa0(%rbp)
subl $0x14, %eax
ja 0x15f6a
movq -0xa0(%rbp), %rax
leaq 0x10cdc(%rip), %rcx     # 0x26bb0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x1d0ec(%rip), %rdi     # 0x32fd0
leaq 0x10d48(%rip), %rsi     # 0x26c33
callq 0x3270
jmp 0x15ef2
jmp 0x15f81
movq 0x1d0d2(%rip), %rdi     # 0x32fd0
leaq 0x10d36(%rip), %rsi     # 0x26c3b
callq 0x3270
jmp 0x15f0c
jmp 0x15f81
movq 0x1d0bb(%rip), %rdi     # 0x32fd0
leaq 0x10d25(%rip), %rsi     # 0x26c41
callq 0x3270
jmp 0x15f23
jmp 0x15f81
movq 0x1d0a4(%rip), %rdi     # 0x32fd0
leaq 0x10d13(%rip), %rsi     # 0x26c46
callq 0x3270
jmp 0x15f3a
jmp 0x15f81
movq 0x1d08d(%rip), %rdi     # 0x32fd0
leaq 0x10d03(%rip), %rsi     # 0x26c4d
callq 0x3270
jmp 0x15f51
jmp 0x15f81
movq 0x1d076(%rip), %rdi     # 0x32fd0
leaq 0x10cf1(%rip), %rsi     # 0x26c52
callq 0x3270
jmp 0x15f68
jmp 0x15f81
movq 0x1d05f(%rip), %rdi     # 0x32fd0
leaq 0x10ce4(%rip), %rsi     # 0x26c5c
callq 0x3270
jmp 0x15f7f
jmp 0x15f81
movq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16670
cmpl $0x0, 0x4(%rax)
jle 0x15fec
movq 0x1d035(%rip), %rdi     # 0x32fd0
leaq 0x112c1(%rip), %rsi     # 0x27263
callq 0x3270
movq %rax, -0xa8(%rbp)
jmp 0x15fb0
movq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16670
movq -0xa8(%rbp), %rdi
movl 0x4(%rax), %esi
callq 0x3410
movq %rax, -0xb0(%rbp)
jmp 0x15fd5
movq -0xb0(%rbp), %rdi
leaq 0xf34b(%rip), %rsi      # 0x2532e
callq 0x3270
jmp 0x15fea
jmp 0x15fec
movq -0x48(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16670
movl 0x40(%rax), %eax
movl %eax, -0xb4(%rbp)
subl $0x11f, %eax            # imm = 0x11F
je 0x16029
jmp 0x1600b
movl -0xb4(%rbp), %eax
subl $0x120, %eax            # imm = 0x120
je 0x16040
jmp 0x1601a
movl -0xb4(%rbp), %eax
subl $0x121, %eax            # imm = 0x121
je 0x16057
jmp 0x1606e
movq 0x1cfa0(%rip), %rdi     # 0x32fd0
leaq 0x10c4e(%rip), %rsi     # 0x26c85
callq 0x3270
jmp 0x1603e
jmp 0x16085
movq 0x1cf89(%rip), %rdi     # 0x32fd0
leaq 0x10c3b(%rip), %rsi     # 0x26c89
callq 0x3270
jmp 0x16055
jmp 0x16085
movq 0x1cf72(%rip), %rdi     # 0x32fd0
leaq 0x10c29(%rip), %rsi     # 0x26c8e
callq 0x3270
jmp 0x1606c
jmp 0x16085
movq 0x1cf5b(%rip), %rdi     # 0x32fd0
leaq 0x10c1a(%rip), %rsi     # 0x26c96
callq 0x3270
jmp 0x16083
jmp 0x16085
jmp 0x16087
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x15e41
movq 0x1cf31(%rip), %rdi     # 0x32fd0
leaq 0x10e6c(%rip), %rsi     # 0x26f12
callq 0x3270
movq %rax, -0xc0(%rbp)
jmp 0x160b4
movq -0xc0(%rbp), %rdi
movq 0x1cef6(%rip), %rsi     # 0x32fb8
callq 0x32c0
jmp 0x160c9
leaq -0x40(%rbp), %rdi
callq 0x12930
jmp 0x16124
movq 0x1cef5(%rip), %rdi     # 0x32fd0
leaq 0x10bb7(%rip), %rsi     # 0x26c99
callq 0x3270
movq %rax, -0xc8(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x163d0
movq -0xc8(%rbp), %rdi
movl 0x24(%rax), %esi
callq 0x3410
movq %rax, %rdi
leaq 0x10e02(%rip), %rsi     # 0x26f12
callq 0x3270
movq %rax, %rdi
movq 0x1ce99(%rip), %rsi     # 0x32fb8
callq 0x32c0
jmp 0x16126
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x16690
movq %rax, -0x60(%rbp)
jmp 0x15c79
movl $0x0, -0xc(%rbp)
cmpl $0x14, -0xc(%rbp)
jge 0x16165
movq 0x1ce82(%rip), %rdi     # 0x32fd0
leaq 0x10aaf(%rip), %rsi     # 0x26c04
callq 0x3270
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x16141
movq 0x1ce64(%rip), %rdi     # 0x32fd0
leaq 0x10f89(%rip), %rsi     # 0x270fc
callq 0x3270
movq %rax, %rdi
movq 0x1ce36(%rip), %rsi     # 0x32fb8
callq 0x32c0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3420
nopl (%rax)