// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
movq 0x133b6(%rip), %r14     # 0x21fd8
leaq 0xbfe1(%rip), %rsi      # 0x1ac0a
movl $0x1, %edx
movq %r14, %rdi
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movl $0x14, %ebp
leaq 0xbc77(%rip), %rbx      # 0x1a8e0
movl $0x2, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2230
decl %ebp
jne 0xec69
leaq 0xc170(%rip), %rsi      # 0x1adf4
movl $0x1, %edx
movq %r14, %rdi
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0xbc24(%rip), %rsi      # 0x1a8e3
movl $0x8, %edx
movq %r14, %rdi
callq 0x2230
movq %r15, %r12
movq 0x60(%r15), %rsi
movq 0x68(%r15), %rdx
movq %r14, %rdi
callq 0x2230
movq %rax, %rbx
leaq 0xbc03(%rip), %rsi      # 0x1a8ec
movl $0x15, %edx
movq %rax, %rdi
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq 0x48(%r15), %r15
addq $0x38, %r12
movq %r12, 0x20(%rsp)
cmpq %r12, %r15
je 0xf09f
leaq 0x8(%rsp), %rbp
leaq 0xbc33(%rip), %r12      # 0x1a972
leaq 0xbb5e(%rip), %r13      # 0x1a8a4
movl $0x4, %edx
movq %r14, %rdi
leaq 0xbbad(%rip), %rsi      # 0x1a902
callq 0x2230
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
movq %r14, %rdi
callq 0x2230
movl $0x7, %edx
movq %r14, %rdi
leaq 0xbb8e(%rip), %rsi      # 0x1a907
callq 0x2230
movl 0x40(%r15), %eax
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xedae
leaq 0xbafc(%rip), %rdx      # 0x1a890
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x7, %edx
movq %r14, %rdi
leaq 0xbb63(%rip), %rsi      # 0x1a90f
jmp 0xee19
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xedc6
movl $0x9, %edx
movq %r14, %rdi
leaq 0xbb6a(%rip), %rsi      # 0x1a92e
jmp 0xee19
movl $0x7, %edx
movq %r14, %rdi
leaq 0xbb63(%rip), %rsi      # 0x1a938
jmp 0xee19
movl $0x4, %edx
movq %r14, %rdi
leaq 0xbb37(%rip), %rsi      # 0x1a91d
jmp 0xee19
movl $0x4, %edx
movq %r14, %rdi
leaq 0xbb32(%rip), %rsi      # 0x1a929
jmp 0xee19
movl $0x6, %edx
movq %r14, %rdi
leaq 0xbb1a(%rip), %rsi      # 0x1a922
jmp 0xee19
movl $0x5, %edx
movq %r14, %rdi
leaq 0xbafe(%rip), %rsi      # 0x1a917
callq 0x2230
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
je 0xee59
movl $0xd, %edx
movq %r14, %rdi
leaq 0xbb09(%rip), %rsi      # 0x1a940
callq 0x2230
movl 0x84(%r15), %esi
movq %r14, %rdi
callq 0x2320
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
jne 0xf02b
movl $0xf, %edx
movq %r14, %rdi
leaq 0xbae6(%rip), %rsi      # 0x1a94e
callq 0x2230
leaq 0x48(%r15), %rsi
movq %rbp, %rdi
callq 0xdfee
movq 0x8(%rsp), %rax
cmpq %rax, 0x10(%rsp)
je 0xefe1
xorl %ebx, %ebx
xorl %ebp, %ebp
testq %rbp, %rbp
je 0xeeae
movl $0x2, %edx
movq %r14, %rdi
leaq 0xbabd(%rip), %rsi      # 0x1a95e
callq 0x2230
movq 0x8(%rsp), %rax
addq %rbx, %rax
movl (%rax), %eax
movl $0x7, %edx
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xeedf
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
leaq 0xba40(%rip), %rsi      # 0x1a90f
jmpq *%rax
movl $0x5, %edx
leaq 0xba3a(%rip), %rsi      # 0x1a917
jmp 0xef25
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xeef4
movl $0x9, %edx
leaq 0xba3c(%rip), %rsi      # 0x1a92e
jmp 0xef25
leaq 0xba3d(%rip), %rsi      # 0x1a938
jmp 0xef25
movl $0x4, %edx
leaq 0xba14(%rip), %rsi      # 0x1a91d
jmp 0xef25
movl $0x4, %edx
leaq 0xba12(%rip), %rsi      # 0x1a929
jmp 0xef25
movl $0x6, %edx
leaq 0xb9fd(%rip), %rsi      # 0x1a922
movq %r14, %rdi
callq 0x2230
movq 0x8(%rsp), %rax
cmpl $0x0, 0x4(%rax,%rbx)
jle 0xef77
movl $0x1, %edx
movq %r14, %rdi
leaq 0xc013(%rip), %rsi      # 0x1af5b
callq 0x2230
movq 0x8(%rsp), %rax
movl 0x4(%rax,%rbx), %esi
movq %r14, %rdi
callq 0x2320
movl $0x1, %edx
movq %rax, %rdi
leaq 0xa159(%rip), %rsi      # 0x190c6
callq 0x2230
movq 0x8(%rsp), %rax
movl 0x40(%rax,%rbx), %eax
movl $0xfffffee1, %ecx       # imm = 0xFFFFFEE1
addl %ecx, %eax
movl $0x2, %edx
movq %r12, %rsi
cmpl $0x2, %eax
ja 0xefaa
movl %eax, %eax
leaq 0xb920(%rip), %rcx      # 0x1a8b8
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0xb922(%rip), %rcx      # 0x1a8c8
movq (%rcx,%rax,8), %rdx
movq %r14, %rdi
callq 0x2230
incq %rbp
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x71c71c71c71c71c7, %rdx # imm = 0x8E38E38E38E38E39
imulq %rdx, %rcx
addq $0x48, %rbx
cmpq %rcx, %rbp
jne 0xee8d
movl $0x1, %edx
movq %r14, %rdi
leaq 0xbc1a(%rip), %rsi      # 0x1ac0a
callq 0x2230
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
callq 0xdda4
jmp 0xf089
movl $0x8, %edx
movq %r14, %rdi
leaq 0xb93b(%rip), %rsi      # 0x1a975
callq 0x2230
movl 0x44(%r15), %esi
movq %r14, %rdi
callq 0x2320
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0xbbad(%rip), %rsi      # 0x1ac0a
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r15, %rdi
callq 0x2150
movq %rax, %r15
cmpq 0x20(%rsp), %rax
jne 0xed46
movl $0x14, %ebp
movq 0x12f2d(%rip), %rbx     # 0x21fd8
leaq 0xb82e(%rip), %r14      # 0x1a8e0
movl $0x2, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
decl %ebp
jne 0xf0b2
leaq 0xbd27(%rip), %rsi      # 0x1adf4
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2230
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf112
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xdda4
movq %rbx, %rdi
callq 0x2330
nop