// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: OperatorToken::operate(unsigned short, unsigned short) const
uint16_t OperatorToken::operate(uint16_t lhs, uint16_t rhs) const {
  if (isUnary()) {
    if ("-" == _op) {
      return -rhs;
    } else if ("*" == _op) {
      throw "Dereferencing not allowed in constant expression.";
    } else if ("&" == _op) {
      throw "Address-of not allowed in constant expression.";
    } else if ("~" == _op) {
      return ~rhs;
    } else if ("!" == _op) {
      return !rhs ? 1 : 0;
    } else if ("+" == _op) {
      return +rhs;
    }
  } else if (isBinary()) {
    if ("+" == _op) {
      return lhs + rhs;
    } else if ("-" == _op) {
      return lhs - rhs;
    } else if ("*" == _op) {
      return lhs * rhs;
    } else if ("/" == _op) {
      if (0 == rhs) {
        _warn("Division by zero in expression.", _lineNum);
        return 0xffff;
      }
      return lhs / rhs;
    } else if ("%" == _op) {
      if (0 == rhs) {
        _warn("Division by zero in expression.", _lineNum);
        return 0xffff;
      }
      return lhs % rhs;
    } else if ("=" == _op) {
      throw "Assignment not allowed in constant expression.";
    } else if ("&" == _op) {
      return lhs & rhs;
    } else if ("|" == _op) {
      return lhs | rhs;
    } else if ("^" == _op) {
      return lhs ^ rhs;
    } else if ("||" == _op) {
      return lhs || rhs ? 1 : 0;
    } else if ("&&" == _op) {
      return lhs && rhs ? 1 : 0;
    } else if ("<" == _op) {
      return lhs < rhs ? 1 : 0;
    } else if ("<=" == _op) {
      return lhs <= rhs ? 1 : 0;
    } else if (">" == _op) {
      return lhs > rhs ? 1 : 0;
    } else if (">=" == _op) {
      return lhs >= rhs ? 1 : 0;
    } else if ("==" == _op) {
      return lhs == rhs ? 1 : 0;
    } else if ("!=" == _op) {
      return lhs != rhs ? 1 : 0;
    } else if ("[" == _op) {
      throw "Array indexing not yet supported.";
    } else if ("<<" == _op) {
      return lhs << rhs;
    } else if (">>" == _op) {
      return lhs >> rhs;
    }
  }
  throw "Invalid operator '" + _op + "' in expression.";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
leaq 0x10(%rdi), %r14
cmpb $0x0, 0x30(%rdi)
je 0xc403
movl %esi, %ebp
movq %rdi, %r15
leaq 0x1d1e2(%rip), %rdi     # 0x295d2
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc41d
addl %ebp, %ebx
jmp 0xc610
leaq 0x1d1ca(%rip), %rdi     # 0x295d4
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc439
negl %ebx
jmp 0xc610
leaq 0x1d1b0(%rip), %rdi     # 0x295d4
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc481
subl %ebx, %ebp
movl %ebp, %ebx
jmp 0xc610
leaq 0x1d196(%rip), %rdi     # 0x295d6
movq %r14, %rsi
callq 0x97dd
testb %al, %al
jne 0xc78a
leaq 0x1d18f(%rip), %rdi     # 0x295e6
movq %r14, %rsi
callq 0x97dd
testb %al, %al
jne 0xc79b
leaq 0x1d170(%rip), %rdi     # 0x295de
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc49c
notl %ebx
jmp 0xc610
leaq 0x1d14e(%rip), %rdi     # 0x295d6
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc4be
imull %ebp, %ebx
jmp 0xc610
leaq 0x1d13d(%rip), %rdi     # 0x295e0
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc4e8
xorl %eax, %eax
testw %bx, %bx
sete %al
movl %eax, %ebx
jmp 0xc610
leaq 0x1d113(%rip), %rdi     # 0x295d8
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc54d
testw %bx, %bx
je 0xc5a1
movl %ebp, %eax
xorl %edx, %edx
divw %bx
movl %eax, %ebx
jmp 0xc610
leaq 0x1d0e3(%rip), %rdi     # 0x295d2
movq %r14, %rsi
callq 0x97dd
testb %al, %al
jne 0xc610
pushq $0x20
popq %rdi
callq 0x7180
movq %rax, %rbx
leaq 0x1d1bd(%rip), %rsi     # 0x296ce
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x9980
movb $0x1, %bpl
leaq 0x1d1b9(%rip), %rdx     # 0x296e1
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x9ad4
xorl %ebp, %ebp
leaq 0x31aea(%rip), %rsi     # 0x3e028
movq 0x32a2b(%rip), %rdx     # 0x3ef70
movq %rbx, %rdi
callq 0x74d0
leaq 0x1d086(%rip), %rdi     # 0x295da
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc573
testw %bx, %bx
je 0xc5de
movl %ebp, %eax
xorl %edx, %edx
divw %bx
movl %edx, %ebx
jmp 0xc610
leaq 0x1d078(%rip), %rdi     # 0x295f2
movq %r14, %rsi
callq 0x97dd
testb %al, %al
jne 0xc7be
leaq 0x1d055(%rip), %rdi     # 0x295e6
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc5c7
andl %ebp, %ebx
jmp 0xc610
leaq 0x1d0b5(%rip), %rsi     # 0x2965d
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x9502
movl 0x8(%r15), %esi
leaq 0x8(%rsp), %rdi
callq 0x2865b
jmp 0xc602
leaq 0x1d015(%rip), %rdi     # 0x295e3
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc61d
orl %ebp, %ebx
jmp 0xc610
leaq 0x1d078(%rip), %rsi     # 0x2965d
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x9502
movl 0x8(%r15), %esi
leaq 0x8(%rsp), %rdi
callq 0x2865b
leaq 0x8(%rsp), %rdi
callq 0x75c8
movw $0xffff, %bx            # imm = 0xFFFF
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cfb8(%rip), %rdi     # 0x295dc
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc634
xorl %ebp, %ebx
jmp 0xc610
leaq 0x1cfa7(%rip), %rdi     # 0x295e2
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc654
xorl %eax, %eax
orw %bp, %bx
setne %al
jmp 0xc4b7
leaq 0x1cf8a(%rip), %rdi     # 0x295e5
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc67a
testw %bp, %bp
setne %al
testw %bx, %bx
setne %cl
andb %al, %cl
movzbl %cl, %ebx
jmp 0xc610
leaq 0x1cf76(%rip), %rdi     # 0x295f7
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc69a
xorl %eax, %eax
cmpw %bx, %bp
setb %al
jmp 0xc4b7
leaq 0x1cf47(%rip), %rdi     # 0x295e8
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc6ba
xorl %eax, %eax
cmpw %bx, %bp
setbe %al
jmp 0xc4b7
leaq 0x1cf39(%rip), %rdi     # 0x295fa
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc6da
xorl %eax, %eax
cmpw %bx, %bp
seta %al
jmp 0xc4b7
leaq 0x1cf0a(%rip), %rdi     # 0x295eb
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc6fa
xorl %eax, %eax
cmpw %bx, %bp
setae %al
jmp 0xc4b7
leaq 0x1ceed(%rip), %rdi     # 0x295ee
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc717
xorl %eax, %eax
cmpw %bx, %bp
jmp 0xc4b4
leaq 0x1ced3(%rip), %rdi     # 0x295f1
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc734
xorl %eax, %eax
cmpw %bx, %bp
jmp 0xc64c
leaq 0x1ceb9(%rip), %rdi     # 0x295f4
movq %r14, %rsi
callq 0x97dd
testb %al, %al
jne 0xc7cf
leaq 0x1cea4(%rip), %rdi     # 0x295f6
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc767
movl %ebx, %ecx
shll %cl, %ebp
jmp 0xc432
leaq 0x1ce8b(%rip), %rdi     # 0x295f9
movq %r14, %rsi
callq 0x97dd
testb %al, %al
je 0xc4ff
movzwl %bp, %eax
movl %ebx, %ecx
shrl %cl, %eax
jmp 0xc4b7
pushq $0x8
popq %rdi
callq 0x7180
leaq 0x1ce63(%rip), %rcx     # 0x295fc
jmp 0xc7aa
pushq $0x8
popq %rdi
callq 0x7180
leaq 0x1ce84(%rip), %rcx     # 0x2962e
movq %rcx, (%rax)
movq 0x327c4(%rip), %rsi     # 0x3ef78
movq %rax, %rdi
xorl %edx, %edx
callq 0x74d0
pushq $0x8
popq %rdi
callq 0x7180
leaq 0x1ceb0(%rip), %rcx     # 0x2967d
jmp 0xc7aa
pushq $0x8
popq %rdi
callq 0x7180
leaq 0x1cece(%rip), %rcx     # 0x296ac
jmp 0xc7aa
jmp 0xc7e4
jmp 0xc7f3
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0xc817
movq %rax, %r14
jmp 0xc817
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bpl, %bpl
jne 0xc80f
jmp 0xc817
movq %rax, %r14
movq %rbx, %rdi
callq 0x7230
movq %r14, %rdi
callq 0x7510
nop