// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq 0x132ca(%rip), %r14     # 0x21fd8
leaq 0xbef5(%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 0xbb8b(%rip), %rbx      # 0x1a8e0
movl $0x2, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2230
decl %ebp
jne 0xed55
leaq 0xc084(%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 0xbb38(%rip), %rsi      # 0x1a8e3
movl $0x8, %edx
movq %r14, %rdi
callq 0x2230
movq 0x60(%r12), %rsi
movq 0x68(%r12), %rdx
movq %r14, %rdi
callq 0x2230
movq %rax, %rbx
leaq 0xbb18(%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(%r12), %r15
addq $0x38, %r12
cmpq %r12, %r15
je 0xf185
leaq 0xbb51(%rip), %rbx      # 0x1a972
leaq 0xba7c(%rip), %r13      # 0x1a8a4
movq %r12, 0x20(%rsp)
movl $0x4, %edx
movq %r14, %rdi
leaq 0xbac6(%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 0xbaa7(%rip), %rsi      # 0x1a907
callq 0x2230
movl 0x40(%r15), %eax
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xee95
leaq 0xba15(%rip), %rdx      # 0x1a890
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0x7, %edx
movq %r14, %rdi
leaq 0xba7c(%rip), %rsi      # 0x1a90f
jmp 0xef00
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xeead
movl $0x9, %edx
movq %r14, %rdi
leaq 0xba83(%rip), %rsi      # 0x1a92e
jmp 0xef00
movl $0x7, %edx
movq %r14, %rdi
leaq 0xba7c(%rip), %rsi      # 0x1a938
jmp 0xef00
movl $0x4, %edx
movq %r14, %rdi
leaq 0xba50(%rip), %rsi      # 0x1a91d
jmp 0xef00
movl $0x4, %edx
movq %r14, %rdi
leaq 0xba4b(%rip), %rsi      # 0x1a929
jmp 0xef00
movl $0x6, %edx
movq %r14, %rdi
leaq 0xba33(%rip), %rsi      # 0x1a922
jmp 0xef00
movl $0x5, %edx
movq %r14, %rdi
leaq 0xba17(%rip), %rsi      # 0x1a917
callq 0x2230
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
je 0xef32
movl $0xd, %edx
movq %r14, %rdi
leaq 0xba22(%rip), %rsi      # 0x1a940
callq 0x2230
movl 0x84(%r15), %esi
movq %r14, %rdi
callq 0x2320
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
jne 0xf112
movl $0xf, %edx
movq %r14, %rdi
leaq 0xb9ff(%rip), %rsi      # 0x1a94e
callq 0x2230
leaq 0x48(%r15), %rsi
leaq 0x8(%rsp), %rdi
callq 0xe0e0
movq 0x10(%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0xf0c6
xorl %ebp, %ebp
xorl %r12d, %r12d
testq %r12, %r12
je 0xef90
movl $0x2, %edx
movq %r14, %rdi
leaq 0xb9d3(%rip), %rsi      # 0x1a95e
callq 0x2230
movq 0x8(%rsp), %rax
movl (%rax,%rbp), %eax
movl $0x7, %edx
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xefc7
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
leaq 0xb958(%rip), %rsi      # 0x1a90f
jmpq *%rax
movl $0x5, %edx
leaq 0xb952(%rip), %rsi      # 0x1a917
jmp 0xf00d
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xefdc
movl $0x9, %edx
leaq 0xb954(%rip), %rsi      # 0x1a92e
jmp 0xf00d
leaq 0xb955(%rip), %rsi      # 0x1a938
jmp 0xf00d
movl $0x4, %edx
leaq 0xb92c(%rip), %rsi      # 0x1a91d
jmp 0xf00d
movl $0x4, %edx
leaq 0xb92a(%rip), %rsi      # 0x1a929
jmp 0xf00d
movl $0x6, %edx
leaq 0xb915(%rip), %rsi      # 0x1a922
movq %r14, %rdi
callq 0x2230
movq 0x8(%rsp), %rax
cmpl $0x0, 0x4(%rax,%rbp)
jle 0xf05a
movl $0x1, %edx
movq %r14, %rdi
leaq 0xbf2b(%rip), %rsi      # 0x1af5b
callq 0x2230
movq 0x8(%rsp), %rax
movl 0x4(%rax,%rbp), %esi
movq %r14, %rdi
callq 0x2320
movl $0x1, %edx
movq %rax, %rdi
leaq 0xa071(%rip), %rsi      # 0x190c6
callq 0x2230
movq 0x8(%rsp), %rax
movl 0x40(%rax,%rbp), %eax
movl $0xfffffee1, %ecx       # imm = 0xFFFFFEE1
addl %ecx, %eax
movl $0x2, %edx
movq %rbx, %rsi
cmpl $0x2, %eax
ja 0xf092
movl %eax, %eax
leaq 0xb838(%rip), %rcx      # 0x1a8b8
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
leaq 0xb83a(%rip), %rcx      # 0x1a8c8
movq (%rcx,%rax,8), %rdx
movq %r14, %rdi
callq 0x2230
incq %r12
movq 0x10(%rsp), %rax
subq 0x8(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x71c71c71c71c71c7, %rcx # imm = 0x8E38E38E38E38E39
imulq %rcx, %rax
addq $0x48, %rbp
cmpq %rax, %r12
jne 0xef77
movl $0x1, %edx
movq %r14, %rdi
leaq 0xbb35(%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), %rdi
callq 0xdea4
movq 0x20(%rsp), %r12
jmp 0xf171
movl $0x8, %edx
movq %r14, %rdi
leaq 0xb854(%rip), %rsi      # 0x1a975
callq 0x2230
movl 0x44(%r15), %esi
movq %r14, %rdi
callq 0x2320
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0xbac6(%rip), %rsi      # 0x1ac0a
callq 0x2230
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
movq %r15, %rdi
callq 0x2150
movq %rax, %r15
cmpq %r12, %rax
jne 0xee2d
movl $0x14, %ebp
movq 0x12e47(%rip), %rbx     # 0x21fd8
leaq 0xb748(%rip), %r14      # 0x1a8e0
movl $0x2, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
decl %ebp
jne 0xf198
leaq 0xbc41(%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 0xf1f8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xdea4
movq %rbx, %rdi
callq 0x2330
nop