// File: pranavmodx[P]modlang/src/evaluator.cpp
// Function: Evaluator::evalIndexExpression(Object*, Object*, Environment*)
Object *Evaluator::evalIndexExpression(Object *left, Object *index, Environment *env)
{
	if (left->type() == STRING_OBJ && index->type() == INTEGER_OBJ)
		return evalStringIndexExpression((String *)left, (Integer *)index);

	else if (left->type() == ARRAY_OBJ && index->type() == INTEGER_OBJ)
		return evalArrayIndexExpression((Array *)left, (Integer *)index);

	else if (left->type() == HASHMAP_OBJ)
		return evalHashMapIndexExpression((HashMap *)left, index);

	else
		return new Error("error: index operator [] not supported for -> " + left->type());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
leaq -0x48(%rbp), %rdi
callq *(%rax)
leaq -0x48(%rbp), %rdi
leaq 0x325c2(%rip), %rsi     # 0x67260
callq 0x16920
movb %al, %cl
movb $0x0, -0x75(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x122(%rbp)
jne 0x34cb8
jmp 0x34ce4
movq -0x20(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x68(%rbp), %rdi
callq *%rax
jmp 0x34cca
movb $0x1, -0x75(%rbp)
leaq -0x68(%rbp), %rdi
leaq 0x32547(%rip), %rsi     # 0x67220
callq 0x16920
movb %al, -0x122(%rbp)
movb -0x122(%rbp), %al
movb %al, -0x131(%rbp)
testb $0x1, -0x75(%rbp)
jne 0x34cf8
jmp 0x34d01
leaq -0x68(%rbp), %rdi
callq 0x5518
leaq -0x48(%rbp), %rdi
callq 0x5518
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x34d16
jmp 0x34d4d
movq -0x130(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x36be0
movq %rax, -0x8(%rbp)
jmp 0x34f78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x5518
jmp 0x34f85
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
leaq -0x98(%rbp), %rdi
callq *(%rax)
leaq -0x98(%rbp), %rdi
leaq 0x32535(%rip), %rsi     # 0x672a0
callq 0x16920
movb %al, %cl
movb $0x0, -0xb9(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x132(%rbp)
jne 0x34d88
jmp 0x34dbd
movq -0x20(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0xb8(%rbp), %rdi
callq *%rax
jmp 0x34d9d
movb $0x1, -0xb9(%rbp)
leaq -0xb8(%rbp), %rdi
leaq 0x3246e(%rip), %rsi     # 0x67220
callq 0x16920
movb %al, -0x132(%rbp)
movb -0x132(%rbp), %al
movb %al, -0x133(%rbp)
testb $0x1, -0xb9(%rbp)
jne 0x34dd4
jmp 0x34de0
leaq -0xb8(%rbp), %rdi
callq 0x5518
leaq -0x98(%rbp), %rdi
callq 0x5518
movb -0x133(%rbp), %al
testb $0x1, %al
jne 0x34df8
jmp 0x34e32
movq -0x130(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x36eb0
movq %rax, -0x8(%rbp)
jmp 0x34f78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5518
jmp 0x34f85
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
leaq -0xe0(%rbp), %rdi
callq *(%rax)
leaq -0xe0(%rbp), %rdi
leaq 0x32470(%rip), %rsi     # 0x672c0
callq 0x16920
movb %al, -0x134(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x5518
movb -0x134(%rbp), %al
testb $0x1, %al
jne 0x34e73
jmp 0x34e90
movq -0x130(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x37080
movq %rax, -0x8(%rbp)
jmp 0x34f78
movl $0x28, %edi
callq 0x52a0
movq %rax, -0x140(%rbp)
movb $0x1, -0x121(%rbp)
movq -0x18(%rbp), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x120(%rbp), %rdi
callq *%rax
jmp 0x34ebd
leaq 0x10eaa(%rip), %rsi     # 0x45d6e
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0x1bde0
jmp 0x34ed9
movq -0x140(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x2b980
jmp 0x34eee
movq -0x140(%rbp), %rax
movb $0x0, -0x121(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5518
leaq -0x120(%rbp), %rdi
callq 0x5518
jmp 0x34f78
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x34f5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x34f4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x5518
leaq -0x120(%rbp), %rdi
callq 0x5518
testb $0x1, -0x121(%rbp)
jne 0x34f65
jmp 0x34f76
movq -0x140(%rbp), %rdi
movl $0x28, %esi
callq 0x52b0
jmp 0x34f85
movq -0x8(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x5490
nop