// File: /workspace/github_cpp_makefile_star2_O1/AshOlogn[P]ash-language-interpreter/src/parser.cpp
// Function: evalPostfixMemberAccess()
AbstractExpressionNode* evalPostfixMemberAccess() {
  
  AbstractExpressionNode* head = evalLiteralGroup();
  VariableNode* varNode = dynamic_cast<VariableNode*>(head);

  if(varNode && isPostfixStructure()) {

		string variableName(varNode->variable);

    //make sure variable is declared
    if(!symbolTable->isDeclared(variableName)) {
      throw StaticVariableScopeError(varNode->startLine, varNode->variable, getCodeLineBlock(varNode->startLine-1, varNode->startLine-1), false);   
    }

    //get variable type
    ParseDataType varType = varNode->evalType;

    Token* firstPlus = consume(); //consume first + or -
    Token* secondPlus = consume(); //consume second + or -

    if(secondPlus->type == ADD) {
      //make sure type is correct
      if(!typecheckUnaryExpression(POSTFIX_INC_OP, varType)) {
        throw StaticTypeError(varNode->startLine, secondPlus->line+1, getCodeLineBlock(varNode->startLine-1, secondPlus->line), "postfix increment", varType);
      }
      return new UnaryOperatorNode(POSTFIX_INC_OP, varNode, symbolTable, secondPlus->line+1);

    } else {
      //make sure type is correct
      if(!typecheckUnaryExpression(POSTFIX_DEC_OP, varType)) {
        throw StaticTypeError(varNode->startLine, secondPlus->line+1, getCodeLineBlock(varNode->startLine-1, secondPlus->line), "postfix decrement", varType);
      }
      return new UnaryOperatorNode(POSTFIX_DEC_OP, varNode, symbolTable, secondPlus->line+1); 
    }
  }

  while(peek()->type == LEFT_BRACKET) {
    head = handleMemberAccess(head);
  }

  return head;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
callq 0x1a4dc
movq %rax, %r14
leaq 0x101df(%rip), %rsi     # 0x2bb28
leaq 0x10178(%rip), %rdx     # 0x2bac8
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x4230
testq %rax, %rax
je 0x1ba3c
movq %rax, %rbx
callq 0x1b3ae
testb %al, %al
je 0x1ba3c
leaq -0x78(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %r15
movq %r15, %rdi
callq 0x8ac2
movq 0x108f4(%rip), %r14     # 0x2c290
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x8ac2
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x16646
movl %eax, %r14d
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x1b9d5
callq 0x41e0
testb %r14b, %r14b
je 0x1baac
movl 0x10(%rbx), %r14d
callq 0x1789c
callq 0x1789c
movq %rax, %r12
cmpl $0x7, (%rax)
jne 0x1ba48
xorl %edi, %edi
movl %r14d, %esi
callq 0x16118
testb %al, %al
je 0x1bb16
movl $0x30, %edi
callq 0x4210
movq %rax, %r14
movq 0x10876(%rip), %rcx     # 0x2c290
movl 0x10(%r12), %r8d
incl %r8d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x8cbe
jmp 0x1ba89
movq %r14, %rdi
callq 0x1b3f0
movq %rax, %r14
callq 0x178eb
cmpl $0x2, (%rax)
je 0x1ba31
jmp 0x1ba9a
movl $0x1, %edi
movl %r14d, %esi
callq 0x16118
testb %al, %al
je 0x1bb41
movl $0x30, %edi
callq 0x4210
movq %rax, %r14
movq 0x1081f(%rip), %rcx     # 0x2c290
movl 0x10(%r12), %r8d
incl %r8d
movq %rax, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x8cbe
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x1ba9a
callq 0x41e0
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x38, %edi
callq 0x4110
movq %rax, %r14
movl 0x8(%rbx), %r15d
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0x8ac2
movl 0x8(%rbx), %edi
decl %edi
movb $0x1, %r12b
movl %edi, %esi
callq 0x17961
leaq -0x48(%rbp), %rdx
movq %r14, %rdi
movl %r15d, %esi
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x1d65a
xorl %r12d, %r12d
leaq 0xfb71(%rip), %rsi      # 0x2b678
leaq -0x15f28(%rip), %rdx    # 0x5be6
movq %r14, %rdi
callq 0x4350
movl $0x38, %edi
callq 0x4110
movq %rax, %r15
movl 0x8(%rbx), %eax
movl 0x10(%r12), %ebx
movq %rax, %r12
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x17961
leaq 0x3319(%rip), %rcx      # 0x1ee58
jmp 0x1bb6a
movl $0x38, %edi
callq 0x4110
movq %rax, %r15
movl 0x8(%rbx), %eax
movl 0x10(%r12), %ebx
movq %rax, %r12
leal -0x1(%rax), %edi
movl %ebx, %esi
callq 0x17961
leaq 0x3300(%rip), %rcx      # 0x1ee6a
incl %ebx
leaq 0xfa9d(%rip), %rdx      # 0x2b610
addq $0x10, %rdx
movq %rdx, (%r15)
movw $0x0, 0x8(%r15)
movq %rax, 0x10(%r15)
movq %rcx, 0x18(%r15)
movq $0x0, 0x20(%r15)
movl %r12d, 0x28(%r15)
movl %ebx, 0x2c(%r15)
movl %r14d, 0x30(%r15)
leaq 0xfa94(%rip), %rsi      # 0x2b638
movq 0x1042d(%rip), %rdx     # 0x2bfd8
movq %r15, %rdi
callq 0x4350
jmp 0x1bbb5
movq %rax, %rbx
movq %r15, %rdi
jmp 0x1bbec
jmp 0x1bbbf
movq %rax, %rbx
movq %r14, %rdi
jmp 0x1bc01
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1bbe4
callq 0x41e0
jmp 0x1bbe4
movq %rax, %rbx
movb $0x1, %r12b
testb %r12b, %r12b
je 0x1bc0d
movq %r14, %rdi
callq 0x4190
jmp 0x1bc0d
jmp 0x1bc0a
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x1bc0d
callq 0x41e0
jmp 0x1bc0d
jmp 0x1bc0a
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x1bc1e
callq 0x41e0
movq %rbx, %rdi
callq 0x4380