// File: /workspace/github_cpp_makefile_star2_O3/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: ExprToken::_evaluate()
void ExprToken::_evaluate() {
  // Evaluate the postfix expression
  std::stack<std::shared_ptr<Token>> operands;
  for (auto token : _postfix) {
    auto op = std::dynamic_pointer_cast<OperatorToken>(token);
    if (std::dynamic_pointer_cast<LiteralToken>(token) ||
        std::dynamic_pointer_cast<GlobalVarToken>(token)) {
      operands.push(token);
    } else if (std::dynamic_pointer_cast<ParamToken>(token) ||
               std::dynamic_pointer_cast<LocalVarToken>(token) ||
               std::dynamic_pointer_cast<FunctionCallToken>(token)) {
      // We don't know parameter or local variable values at
      // compile time, nor do we know the output of functions,
      // so this expression can't be constant.
      _const = false;
      return;
    } else if (nullptr != op) {
      std::shared_ptr<Token> rhs = operands.top();
      operands.pop();
      std::shared_ptr<Token> lhs;
      if (op->isBinary()) {
        lhs = operands.top();
        operands.pop();
      } else {
        lhs = nullptr;
      }
      uint16_t result;
      // If using assignment, dereferencing, or address-of, this
      // expression is not considered constant.
      if (("=" == op->str() && op->isBinary()) ||
          (("&" == op->str() || "*" == op->str()) && op->isUnary())) {
        _const = false;
        return;
      } else if ("[" == op->str() && op->isBinary()) {
        auto global = std::dynamic_pointer_cast<GlobalVarToken>(lhs);
        if (nullptr == global) {
          _const = false;
          return;
        }
        if (!global->isArray()) {
          _const = false;
          return;
        } else if (global->arraySize() <= rhs->val()) {
          _warn("Array index out of bounds in expression.", _lineNum);
          _const = false;
          return;
        }
        result = global->arrayVal(rhs->val());
      } else {
        result = op->operate(lhs ? lhs->val() : 0, rhs->val());
      }
      operands.push(std::shared_ptr<Token>(new LiteralToken(result)));
    } else {
      _const = false;
      return;
    }
  }
  _value = operands.top()->val();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x2f76a
movq 0x10(%rbx), %rbp
movq %rbx, (%rsp)
movq 0x18(%rbx), %rax
movq %rax, 0x88(%rsp)
cmpq %rax, %rbp
je 0x14f75
leaq 0x3140f(%rip), %rsi     # 0x45d18
leaq 0xe8(%rsp), %r14
movq (%rbp), %r12
movq %r12, 0x28(%rsp)
movq 0x8(%rbp), %rax
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x14942
movq 0x32669(%rip), %rcx     # 0x46f98
cmpb $0x0, (%rcx)
je 0x14939
incl 0x8(%rax)
jmp 0x14942
lock
incl 0x8(%rax)
movq 0x28(%rsp), %r12
testq %r12, %r12
je 0x149e5
movq %r12, %rdi
leaq 0x31a93(%rip), %rdx     # 0x463e8
xorl %ecx, %ecx
callq 0x7330
movq %rax, %r15
testq %rax, %rax
je 0x14984
movq 0x30(%rsp), %r13
testq %r13, %r13
je 0x14984
movq 0x32623(%rip), %rax     # 0x46f98
cmpb $0x0, (%rax)
je 0x14a56
incl 0x8(%r13)
jmp 0x14987
xorl %r13d, %r13d
movq %r14, %rbx
movq %r12, %rdi
leaq 0x31384(%rip), %r14     # 0x45d18
movq %r14, %rsi
leaq 0x31a1a(%rip), %rdx     # 0x463b8
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
jne 0x149c7
movq %r12, %rdi
movq %r14, %rsi
leaq 0x314c1(%rip), %rdx     # 0x45e78
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
je 0x14abd
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movq %rbx, %r14
je 0x149fe
movq 0x325bd(%rip), %rax     # 0x46f98
cmpb $0x0, (%rax)
je 0x149f5
incl 0x8(%rdi)
jmp 0x149f9
xorl %r13d, %r13d
movq (%rsp), %rax
movb $0x0, 0xc(%rax)
xorl %r15d, %r15d
jmp 0x14a13
lock
incl 0x8(%rdi)
callq 0x8036
movb $0x1, %r15b
leaq 0x90(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x3045a
testq %r13, %r13
je 0x14a20
movq %r13, %rdi
callq 0x8036
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x14a2f
callq 0x8036
testb %r15b, %r15b
je 0x14fa9
addq $0x10, %rbp
cmpq 0x88(%rsp), %rbp
leaq 0x312cd(%rip), %rsi     # 0x45d18
jne 0x14911
jmp 0x14f75
lock
incl 0x8(%r13)
movq 0x28(%rsp), %r12
testq %r12, %r12
jne 0x14987
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x14a8f
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x10(%rax), %rcx
movq %rcx, 0x58(%rsp)
movq -0x8(%rax), %rbx
testq %rbx, %rbx
je 0x14b40
movq 0x324ec(%rip), %rax     # 0x46f98
cmpb $0x0, (%rax)
je 0x14b3c
incl 0x8(%rbx)
jmp 0x14b40
movq %r12, %rdi
movq %r14, %rsi
leaq 0x312fe(%rip), %rdx     # 0x45dc8
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
jne 0x14b0c
movq %r12, %rdi
movq %r14, %rsi
leaq 0x317e5(%rip), %rdx     # 0x462c8
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
jne 0x14b0c
movq %r12, %rdi
movq %r14, %rsi
leaq 0x3191c(%rip), %rdx     # 0x46418
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
je 0x14e63
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
movq %rbx, %r14
je 0x149e8
movq 0x32474(%rip), %rax     # 0x46f98
cmpb $0x0, (%rax)
je 0x14b2e
incl 0x8(%rdi)
jmp 0x14b32
lock
incl 0x8(%rdi)
callq 0x8036
jmp 0x149e8
lock
incl 0x8(%rbx)
leaq 0x90(%rsp), %rdi
callq 0x300fc
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
cmpb $0x1, 0x30(%r15)
jne 0x14ba8
movq 0xc0(%rsp), %rsi
cmpq 0xc8(%rsp), %rsi
jne 0x14b82
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
movq -0x10(%rsi), %rax
movq %rax, 0x40(%rsp)
addq $-0x8, %rsi
leaq 0x48(%rsp), %rdi
callq 0x21fd2
leaq 0x90(%rsp), %rdi
callq 0x300fc
jmp 0x14bad
movaps %xmm0, 0x40(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xbd58
movq %r12, %rdi
leaq 0x20a19(%rip), %rsi     # 0x355f2
callq 0x70c0
testl %eax, %eax
jne 0x14bf0
movb $0x1, %r12b
cmpb $0x0, 0x30(%r15)
jne 0x14cb3
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0xbd58
movq %r12, %rdi
leaq 0x209ca(%rip), %rsi     # 0x355e6
callq 0x70c0
testl %eax, %eax
je 0x14c60
leaq 0xf8(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xbd58
movq %r14, %rdi
leaq 0x20984(%rip), %rsi     # 0x355d6
callq 0x70c0
testl %eax, %eax
je 0x14c6a
xorl %r12d, %r12d
jmp 0x14c72
movb 0x30(%r15), %r12b
xorb $0x1, %r12b
jmp 0x14c97
movb 0x30(%r15), %r12b
xorb $0x1, %r12b
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x14c97
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x14cb3
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14ccf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %r12b, %r12b
je 0x14ce4
movq (%rsp), %rax
movb $0x0, 0xc(%rax)
xorl %r15d, %r15d
jmp 0x14e3e
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xbd58
movq %r12, %rdi
leaq 0x208e4(%rip), %rsi     # 0x355f4
callq 0x70c0
testl %eax, %eax
je 0x14d3b
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14db5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x14db5
movb 0x30(%r15), %r12b
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14d5b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %r12b, %r12b
je 0x14db5
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
leaq 0x30fa9(%rip), %rsi     # 0x45d18
je 0x14cd4
leaq 0x310fc(%rip), %rdx     # 0x45e78
xorl %ecx, %ecx
callq 0x7330
testq %rax, %rax
je 0x14cd4
movq %rax, %r12
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x14e78
movq 0x321f4(%rip), %rax     # 0x46f98
cmpb $0x0, (%rax)
je 0x14e74
incl 0x8(%rdi)
jmp 0x14e78
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x14dc9
movq (%rdi), %rax
callq *(%rax)
movl %eax, %r12d
jmp 0x14dcc
xorl %r12d, %r12d
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
movzwl %r12w, %esi
movzwl %ax, %edx
movq %r15, %rdi
callq 0xe43a
movl %eax, %r12d
movl $0x10, %edi
callq 0x72b0
movl $0xffffffff, 0x8(%rax)  # imm = 0xFFFFFFFF
leaq 0x315b0(%rip), %rcx     # 0x463b0
movq %rcx, (%rax)
movw %r12w, 0xc(%rax)
movq %rax, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x2f51a
leaq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2fd5e
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x14e3b
callq 0x8036
movb $0x1, %r15b
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x14e4d
callq 0x8036
testq %rbx, %rbx
je 0x14a13
movq %rbx, %rdi
callq 0x8036
jmp 0x14a13
testq %r15, %r15
movq %rbx, %r14
jne 0x14a69
jmp 0x149e8
lock
incl 0x8(%rdi)
cmpb $0x0, 0x68(%r12)
je 0x14f5a
movq %rdi, 0x38(%rsp)
movq 0x98(%r12), %rax
movq %rax, 0x80(%rsp)
movq 0xa0(%r12), %r15
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
subl 0x80(%rsp), %r15d
shrl %r15d
cmpw %r15w, %ax
jae 0x14f05
movq 0x58(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
movzwl %ax, %esi
movq 0x98(%r12), %rax
movq 0xa0(%r12), %rdx
subq %rax, %rdx
sarq %rdx
cmpq %rsi, %rdx
jbe 0x14fc8
movzwl (%rax,%rsi,2), %r12d
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x14de8
callq 0x8036
jmp 0x14de8
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
leaq 0x20a6a(%rip), %rsi     # 0x35988
leaq 0x20a8b(%rip), %rdx     # 0x359b0
callq 0xbdee
movq (%rsp), %rax
movl 0x8(%rax), %esi
movq %r15, %rdi
callq 0x34217
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14f55
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x38(%rsp), %rdi
movq (%rsp), %rax
movb $0x0, 0xc(%rax)
testq %rdi, %rdi
je 0x14cdc
callq 0x8036
jmp 0x14cdc
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x14f98
movq 0xd8(%rsp), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x10(%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
movq (%rsp), %rcx
movw %ax, 0xe(%rcx)
leaq 0x90(%rsp), %rdi
callq 0x21e32
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21070(%rip), %rdi     # 0x3603f
xorl %eax, %eax
callq 0x7430
jmp 0x14ffb
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x14ffe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x14ffe
jmp 0x14ffb
movq %rax, %r14
cmpq $0x0, 0x38(%rsp)
je 0x1506c
movq 0x38(%rsp), %rdi
jmp 0x1501a
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1506c
callq 0x8036
jmp 0x1506c
jmp 0x15069
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x15047
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x15047
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1506c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x1506c
jmp 0x15069
jmp 0x15069
movq %rax, %r14
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x1507b
callq 0x8036
testq %rbx, %rbx
je 0x15092
movq %rbx, %rdi
callq 0x8036
jmp 0x15092
movq %rax, %r14
jmp 0x150ae
movq %rax, %r14
testq %r13, %r13
je 0x1509f
movq %r13, %rdi
callq 0x8036
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x150ae
callq 0x8036
leaq 0x90(%rsp), %rdi
callq 0x21e32
movq %r14, %rdi
callq 0x74f0
nop