// File: /workspace/github_cpp_makefile_star2_O2/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 0x17c3c
movq %rax, %r14
leaq 0x11bf6(%rip), %rsi     # 0x2ab28
leaq 0x11b8f(%rip), %rdx     # 0x2aac8
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x4200
testq %rax, %rax
je 0x19001
movq %rax, %rbx
callq 0x189d8
testb %al, %al
je 0x19001
leaq 0x20(%rbx), %r15
leaq -0x88(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x4290
movq 0x122ff(%rip), %r14     # 0x2b278
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x4290
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x14422
movl %eax, %r14d
leaq -0x48(%rbp), %rdi
callq 0x40e0
testb %r14b, %r14b
je 0x19065
movl 0x10(%rbx), %r14d
callq 0x154a8
callq 0x154a8
movq %rax, %r15
cmpl $0x7, (%rax)
jne 0x1900d
xorl %edi, %edi
movl %r14d, %esi
callq 0x13f5c
testb %al, %al
je 0x190bd
pushq $0x30
popq %rdi
callq 0x41f0
movq %rax, %r14
movq 0x12298(%rip), %rcx     # 0x2b278
movl 0x10(%r15), %r8d
incl %r8d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x7a02
jmp 0x19047
movq %r14, %rdi
callq 0x18a16
movq %rax, %r14
callq 0x154d4
cmpl $0x2, (%rax)
je 0x18ff6
jmp 0x19053
pushq $0x1
popq %rdi
movl %r14d, %esi
callq 0x13f5c
testb %al, %al
je 0x190e4
pushq $0x30
popq %rdi
callq 0x41f0
movq %rax, %r14
movq 0x12246(%rip), %rcx     # 0x2b278
movl 0x10(%r15), %r8d
incl %r8d
pushq $0x1
popq %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x7a02
leaq -0x88(%rbp), %rdi
callq 0x40e0
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x38
popq %rdi
callq 0x4110
movq %rax, %r14
movl 0x8(%rbx), %r12d
leaq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x4290
movl 0x8(%rbx), %edi
decl %edi
movb $0x1, %r15b
movl %edi, %esi
callq 0x15504
leaq -0x68(%rbp), %rdx
movq %r14, %rdi
movl %r12d, %esi
movq %rax, %rcx
xorl %r8d, %r8d
callq 0x1aad4
xorl %r15d, %r15d
leaq 0x115ca(%rip), %rsi     # 0x2a678
leaq -0x13b39(%rip), %rdx    # 0x557c
movq %r14, %rdi
callq 0x4310
pushq $0x38
popq %rdi
callq 0x4110
movq %rax, %r12
movl 0x8(%rbx), %r13d
movl 0x10(%r15), %ebx
leal -0x1(%r13), %edi
movl %ebx, %esi
callq 0x15504
leaq 0x3d36(%rip), %rcx      # 0x1ce18
jmp 0x19109
pushq $0x38
popq %rdi
callq 0x4110
movq %rax, %r12
movl 0x8(%rbx), %r13d
movl 0x10(%r15), %ebx
leal -0x1(%r13), %edi
movl %ebx, %esi
callq 0x15504
leaq 0x3d21(%rip), %rcx      # 0x1ce2a
leaq 0x11500(%rip), %rdx     # 0x2a610
addq $0x10, %rdx
movq %rdx, (%r12)
andw $0x0, 0x8(%r12)
movq %rax, 0x10(%r12)
movq %rcx, 0x18(%r12)
andq $0x0, 0x20(%r12)
incl %ebx
movl %r13d, 0x28(%r12)
movl %ebx, 0x2c(%r12)
movl %r14d, 0x30(%r12)
leaq 0x114f1(%rip), %rsi     # 0x2a638
movq 0x11e8a(%rip), %rdx     # 0x2afd8
movq %r12, %rdi
callq 0x4310
jmp 0x19158
movq %rax, %rbx
movq %r12, %rdi
jmp 0x19188
jmp 0x19162
movq %rax, %rbx
movq %r14, %rdi
callq 0x41d0
jmp 0x191a4
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x40e0
testb %r15b, %r15b
jne 0x19185
jmp 0x191a4
movq %rax, %rbx
movq %r14, %rdi
callq 0x4180
jmp 0x191a4
jmp 0x191a1
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x40e0
jmp 0x191a4
jmp 0x191a1
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x40e0
movq %rbx, %rdi
callq 0x4340