// File: /workspace/github_cpp_makefile_star2_O2/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 0x10a2a(%rip), %r14     # 0x1afd0
leaq 0x863d(%rip), %rsi      # 0x12bea
movq %r14, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2100
pushq $0x14
popq %rbx
leaq 0x82f9(%rip), %r15      # 0x128c0
subl $0x1, %ebx
jb 0xa5d9
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
jmp 0xa5c7
movq 0x109f0(%rip), %r14     # 0x1afd0
leaq 0x87ed(%rip), %rsi      # 0x12dd4
movq %r14, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2100
leaq 0x82c5(%rip), %rsi      # 0x128c3
movq %r14, %rdi
callq 0x21c0
leaq 0x60(%r12), %rsi
movq %rax, %rdi
callq 0x21b0
leaq 0x82b2(%rip), %rsi      # 0x128cc
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x2100
movq 0x48(%r12), %r15
addq $0x38, %r12
movq %r12, 0x18(%rsp)
movq %rsp, %r12
pushq $0x48
popq %r13
leaq 0x830c(%rip), %rbp      # 0x12952
leaq 0x8253(%rip), %rbx      # 0x128a0
cmpq 0x18(%rsp), %r15
je 0xa8bd
movq %r14, %rdi
leaq 0x8280(%rip), %rsi      # 0x128e2
callq 0x21c0
leaq 0x20(%r15), %rsi
movq %rax, %rdi
callq 0x21b0
movq %r14, %rdi
leaq 0x826a(%rip), %rsi      # 0x128e7
callq 0x21c0
movl 0x40(%r15), %eax
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xa6b1
leaq 0x81f4(%rip), %rdx      # 0x1288c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
leaq 0x8249(%rip), %rsi      # 0x128ef
jmpq *%rax
leaq 0x8248(%rip), %rsi      # 0x128f7
jmp 0xa6e3
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xa6c1
leaq 0x824f(%rip), %rsi      # 0x1290e
jmp 0xa6e3
leaq 0x8250(%rip), %rsi      # 0x12918
jmp 0xa6e3
leaq 0x822c(%rip), %rsi      # 0x128fd
jmp 0xa6e3
leaq 0x822f(%rip), %rsi      # 0x12909
jmp 0xa6e3
leaq 0x821f(%rip), %rsi      # 0x12902
movq %r14, %rdi
callq 0x21c0
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
je 0xa721
movq %r14, %rdi
leaq 0x8221(%rip), %rsi      # 0x12920
callq 0x21c0
movl 0x84(%r15), %esi
movq %rax, %rdi
callq 0x2300
cmpl $0x11e, 0x40(%r15)      # imm = 0x11E
jne 0xa87b
movq %r14, %rdi
leaq 0x8203(%rip), %rsi      # 0x1292e
callq 0x21c0
movq %r15, 0x20(%rsp)
leaq 0x48(%r15), %rsi
movq %r12, %rdi
callq 0x9afc
xorl %r12d, %r12d
xorl %r15d, %r15d
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r13
cmpq %rax, %r15
je 0xa852
testq %r15, %r15
je 0xa779
movq %r14, %rdi
leaq 0x81ce(%rip), %rsi      # 0x1293e
callq 0x21c0
movq (%rsp), %rcx
movl (%rcx,%r12), %eax
leal -0x10a(%rax), %ecx
cmpl $0x4, %ecx
ja 0xa7a1
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
leaq 0x8159(%rip), %rsi      # 0x128ef
jmpq *%rax
leaq 0x8158(%rip), %rsi      # 0x128f7
jmp 0xa7d3
cmpl $0x11e, %eax            # imm = 0x11E
jne 0xa7b1
leaq 0x815f(%rip), %rsi      # 0x1290e
jmp 0xa7d3
leaq 0x8160(%rip), %rsi      # 0x12918
jmp 0xa7d3
leaq 0x813c(%rip), %rsi      # 0x128fd
jmp 0xa7d3
leaq 0x813f(%rip), %rsi      # 0x12909
jmp 0xa7d3
leaq 0x812f(%rip), %rsi      # 0x12902
movq %r14, %rdi
callq 0x21c0
movq (%rsp), %rax
cmpl $0x0, 0x4(%rax,%r12)
jle 0xa81a
movq %r14, %rdi
leaq 0x874a(%rip), %rsi      # 0x12f3b
callq 0x21c0
movq (%rsp), %rcx
movl 0x4(%rcx,%r12), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x68b5(%rip), %rsi      # 0x110c6
callq 0x21c0
movq (%rsp), %rax
movl 0x40(%rax,%r12), %eax
movl $0xfffffee1, %ecx       # imm = 0xFFFFFEE1
addl %ecx, %eax
movq %rbp, %rsi
cmpl $0x2, %eax
ja 0xa83e
movl %eax, %eax
leaq 0x807d(%rip), %rcx      # 0x128b4
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq %r14, %rdi
callq 0x21c0
incq %r15
addq $0x48, %r12
jmp 0xa747
movq %r14, %rdi
leaq 0x838e(%rip), %rsi      # 0x12bea
callq 0x21c0
movq %rax, %rdi
callq 0x2100
movq %rsp, %r12
movq %r12, %rdi
callq 0x9850
movq 0x20(%rsp), %r15
jmp 0xa8ad
movq %r14, %rdi
leaq 0x80d0(%rip), %rsi      # 0x12955
callq 0x21c0
movl 0x44(%r15), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
leaq 0x834a(%rip), %rsi      # 0x12bea
callq 0x21c0
movq %rax, %rdi
callq 0x2100
movq %r15, %rdi
callq 0x2140
movq %rax, %r15
jmp 0xa64d
pushq $0x14
popq %rbp
movq 0x10709(%rip), %rbx     # 0x1afd0
leaq 0x7ff2(%rip), %r14      # 0x128c0
subl $0x1, %ebp
jb 0xa8e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
jmp 0xa8ce
movq 0x106e9(%rip), %rdi     # 0x1afd0
leaq 0x84e6(%rip), %rsi      # 0x12dd4
callq 0x21c0
movq %rax, %rdi
callq 0x2100
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa90c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x9850
movq %rbx, %rdi
callq 0x2310
nop