// File: /workspace/github_cpp_makefile_star2_O3/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 0x1a4cb
movq %rax, %r14
leaq 0x10219(%rip), %rsi     # 0x2bb28
leaq 0x101b2(%rip), %rdx     # 0x2bac8
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x4230
testq %rax, %rax
je 0x1ba02
movq %rax, %rbx
callq 0x1b374
testb %al, %al
je 0x1ba02
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 0x897a
movq 0x1092e(%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 0x897a
leaq -0x68(%rbp), %rsi
movq %r14, %rdi
callq 0x16598
movl %eax, %r14d
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x1b99b
callq 0x41e0
testb %r14b, %r14b
je 0x1ba72
movl 0x10(%rbx), %r14d
callq 0x177cc
callq 0x177cc
movq %rax, %r12
cmpl $0x7, (%rax)
jne 0x1ba0e
xorl %edi, %edi
movl %r14d, %esi
callq 0x16090
testb %al, %al
je 0x1badc
movl $0x30, %edi
callq 0x4210
movq %rax, %r14
movq 0x108b0(%rip), %rcx     # 0x2c290
movl 0x10(%r12), %r8d
incl %r8d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x8b7a
jmp 0x1ba4f
movq %r14, %rdi
callq 0x1b3b6
movq %rax, %r14
callq 0x1781b
cmpl $0x2, (%rax)
je 0x1b9f7
jmp 0x1ba60
movl $0x1, %edi
movl %r14d, %esi
callq 0x16090
testb %al, %al
je 0x1bb07
movl $0x30, %edi
callq 0x4210
movq %rax, %r14
movq 0x10859(%rip), %rcx     # 0x2c290
movl 0x10(%r12), %r8d
incl %r8d
movq %rax, %rdi
movl $0x1, %esi
movq %rbx, %rdx
callq 0x8b7a
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x1ba60
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 0x897a
movl 0x8(%rbx), %edi
decl %edi
movb $0x1, %r12b
movl %edi, %esi
callq 0x17891
leaq -0x48(%rbp), %rdx
movq %r14, %rdi
movl %r15d, %esi
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x1d60a
xorl %r12d, %r12d
leaq 0xfbab(%rip), %rsi      # 0x2b678
leaq -0x15f1a(%rip), %rdx    # 0x5bba
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 0x17891
leaq 0x3333(%rip), %rcx      # 0x1ee38
jmp 0x1bb30
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 0x17891
leaq 0x331a(%rip), %rcx      # 0x1ee4a
incl %ebx
leaq 0xfad7(%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 0xface(%rip), %rsi      # 0x2b638
movq 0x10467(%rip), %rdx     # 0x2bfd8
movq %r15, %rdi
callq 0x4350
jmp 0x1bb7b
movq %rax, %rbx
movq %r15, %rdi
jmp 0x1bbaf
jmp 0x1bb85
movq %rax, %rbx
movq %r14, %rdi
jmp 0x1bbc4
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1bba2
callq 0x41e0
testb %r12b, %r12b
jne 0x1bbac
jmp 0x1bbd0
movq %rax, %rbx
movq %r14, %rdi
callq 0x4190
jmp 0x1bbd0
jmp 0x1bbcd
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x1bbd0
callq 0x41e0
jmp 0x1bbd0
jmp 0x1bbcd
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r13, %rdi
je 0x1bbe1
callq 0x41e0
movq %rbx, %rdi
callq 0x4380