// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x88(%rsp), %rdi
callq 0x18390
movq 0x10(%rbx), %r12
movq %rbx, 0x8(%rsp)
movq 0x18(%rbx), %r15
leaq 0xf8(%rsp), %r13
leaq 0x20(%rsp), %r14
leaq 0x60(%rsp), %rbp
movq %rbp, %rbx
cmpq %r15, %r12
je 0x109f0
movq %r13, %rdi
movq %r12, %rsi
callq 0x18b56
leaq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x183d8
movq %r14, %rdi
movq %r13, %rsi
callq 0x1845a
cmpq $0x0, 0x20(%rsp)
je 0x105ab
leaq 0x28(%rsp), %rdi
callq 0x7a34
jmp 0x105d4
movq %rbp, %rdi
movq %r13, %rsi
callq 0x18504
movq 0x60(%rsp), %rbp
leaq 0x68(%rsp), %rdi
callq 0x7a34
leaq 0x28(%rsp), %rdi
callq 0x7a34
testq %rbp, %rbp
je 0x10613
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0x25628
leaq 0x18(%rsp), %rdi
callq 0x7a34
leaq 0x100(%rsp), %rdi
callq 0x7a34
addq $0x10, %r12
testb %bpl, %bpl
movq %rbx, %rbp
jne 0x1056b
jmp 0x10a25
movq %r14, %rdi
movq %r13, %rsi
callq 0x18559
cmpq $0x0, 0x20(%rsp)
jne 0x10643
movq %rbx, %rdi
movq %r13, %rsi
callq 0x185ae
cmpq $0x0, 0x60(%rsp)
je 0x1065a
leaq 0x68(%rsp), %rdi
callq 0x7a34
leaq 0x28(%rsp), %rdi
callq 0x7a34
movq 0x8(%rsp), %rax
movb $0x0, 0xc(%rax)
xorl %ebp, %ebp
jmp 0x105e7
leaq 0xd8(%rsp), %rdi
movq %r13, %rsi
callq 0x184af
movq 0xd8(%rsp), %rbp
leaq 0xe0(%rsp), %rdi
callq 0x7a34
leaq 0x68(%rsp), %rdi
callq 0x7a34
leaq 0x28(%rsp), %rdi
callq 0x7a34
testq %rbp, %rbp
jne 0x1064d
cmpq $0x0, 0x10(%rsp)
je 0x1064d
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
jne 0x106c6
movq 0xd0(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x10, %rsi
leaq 0x50(%rsp), %rdi
callq 0x18b56
leaq 0x88(%rsp), %rdi
callq 0x252f8
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x10(%rsp), %rax
cmpb $0x1, 0x30(%rax)
jne 0x1073a
movq 0xb8(%rsp), %rsi
cmpq 0xc0(%rsp), %rsi
movq %rbx, %rbp
jne 0x1071d
movq 0xd0(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x10, %rsi
leaq 0x40(%rsp), %rdi
callq 0x18b6a
leaq 0x88(%rsp), %rdi
callq 0x252f8
jmp 0x10759
movaps %xmm0, 0x20(%rsp)
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x256ce
leaq 0x28(%rsp), %rdi
callq 0x7a34
movq %rbx, %rbp
movq 0x10(%rsp), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x73e0
leaq 0x18e81(%rip), %rdi     # 0x295f2
movq %r14, %rsi
callq 0x97dd
movq 0x10(%rsp), %rsi
testb %al, %al
je 0x10795
cmpb $0x0, 0x30(%rsi)
je 0x10795
movq %r14, %rdi
callq 0x75c8
jmp 0x10822
addq $0x10, %rsi
movq %rbp, %rdi
callq 0x73e0
leaq 0x18e3e(%rip), %rdi     # 0x295e6
movq %rbp, %rsi
callq 0x97dd
testb %al, %al
je 0x107c3
movq 0x10(%rsp), %rax
movb 0x30(%rax), %bpl
xorb $0x1, %bpl
jmp 0x1080d
movq 0x10(%rsp), %rsi
addq $0x10, %rsi
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
callq 0x73e0
leaq 0x18df3(%rip), %rdi     # 0x295d6
movq %rbp, %rsi
callq 0x97dd
testb %al, %al
je 0x107fe
movq 0x10(%rsp), %rax
movb 0x30(%rax), %bpl
xorb $0x1, %bpl
jmp 0x10800
xorl %ebp, %ebp
leaq 0xd8(%rsp), %rdi
callq 0x75c8
movq %rbx, %rdi
callq 0x75c8
movq %r14, %rdi
callq 0x75c8
testb %bpl, %bpl
je 0x10832
movq 0x8(%rsp), %rax
movb $0x0, 0xc(%rax)
xorl %ebp, %ebp
jmp 0x10980
movq 0x10(%rsp), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x73e0
leaq 0x18daa(%rip), %rdi     # 0x295f4
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0x108f3
movq 0x10(%rsp), %rax
movb 0x30(%rax), %bpl
movq %r14, %rdi
callq 0x75c8
cmpb $0x1, %bpl
jne 0x108fb
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x18504
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x109c8
cmpb $0x0, 0x68(%rax)
je 0x109c8
movq 0x98(%rax), %rcx
movq %rcx, 0x80(%rsp)
movq 0xa0(%rax), %rbp
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
subl 0x80(%rsp), %ebp
shrl %ebp
cmpw %bp, %ax
jae 0x10999
movq 0x60(%rsp), %rbp
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
movzwl %ax, %esi
movq %rbp, %rdi
callq 0x18604
movw %ax, 0x4(%rsp)
movb $0x1, %bpl
jmp 0x109d3
movq %r14, %rdi
callq 0x75c8
movq 0x10(%rsp), %rbp
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x10915
movq (%rdi), %rax
callq *(%rax)
movl %eax, 0x4(%rsp)
jmp 0x1091d
movl $0x0, 0x4(%rsp)
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
movzwl 0x4(%rsp), %esi
movzwl %ax, %edx
movq %rbp, %rdi
callq 0xc3ce
movl %eax, %ebp
pushq $0x10
popq %rdi
callq 0x72b0
orl $-0x1, 0x8(%rax)
leaq 0x2da74(%rip), %rcx     # 0x3e3c0
movq %rcx, (%rax)
movw %bp, 0xc(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x247a0
movw %bp, 0x4(%rsp)
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0x24fc4
leaq 0x28(%rsp), %rdi
callq 0x7a34
movb $0x1, %bpl
leaq 0x48(%rsp), %rdi
callq 0x7a34
leaq 0x58(%rsp), %rdi
callq 0x7a34
jmp 0x105e7
movq %r14, %rdi
leaq 0x18fe5(%rip), %rsi     # 0x29988
leaq 0xd8(%rsp), %rdx
callq 0x9502
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x2865b
movq %r14, %rdi
callq 0x75c8
movq 0x8(%rsp), %rax
movb $0x0, 0xc(%rax)
xorl %ebp, %ebp
leaq 0x68(%rsp), %rdi
callq 0x7a34
testb %bpl, %bpl
je 0x1082b
movzwl 0x4(%rsp), %ebp
jmp 0x10939
movq 0xb8(%rsp), %rax
cmpq 0xc0(%rsp), %rax
jne 0x10a13
movq 0xd0(%rsp), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x10(%rax), %rdi
movq (%rdi), %rax
callq *(%rax)
movq 0x8(%rsp), %rcx
movw %ax, 0xe(%rcx)
leaq 0x88(%rsp), %rdi
callq 0x18a04
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x75c8
jmp 0x10a58
jmp 0x10a55
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x10a67
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x7a34
jmp 0x10a95
jmp 0x10a92
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x75c8
jmp 0x10a86
jmp 0x10a92
jmp 0x10a92
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x75c8
jmp 0x10a95
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x7a34
leaq 0x58(%rsp), %rdi
callq 0x7a34
jmp 0x10ab3
movq %rax, %rbx
jmp 0x10aca
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x7a34
leaq 0x100(%rsp), %rdi
callq 0x7a34
leaq 0x88(%rsp), %rdi
callq 0x18a04
movq %rbx, %rdi
callq 0x7510
nop