// File: CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeEnumDeclare()
Declare* Parser::ConsumeEnumDeclare() {
    Token* eid = CloneToken(tokenizer->Previous());

    // enum type id
    if (!generator->descriptor->FindEnumContextVariableById(eid->text)) {
      RuntimeError("undefined enum [" + eid->text + "] in current scope");
    }

    Expect(TOKEN_ID);
    Token* id = CloneToken(token);
    Expect(TOKEN_ASSIGN);
    Expect(TOKEN_ID);
    Token* ei = CloneToken(token);

    // value must match type
    if (eid->text != ei->text) {
      RuntimeError("enum type [" + eid->text + "] not match value [" + ei->text + "]");
    }

    // enum variable id
    Enum* def = generator->descriptor->FindEnumContextVariableById(ei->text);
    if (!def) {
      RuntimeError("undefined enum [" + ei->text + "] in current scope");
    }

    Expect(TOKEN_CONNECTION);
    Expect(TOKEN_ID);
    if (!generator->descriptor->EnumInlcudeProperty(def, token.text)) {
      RuntimeError("undefined property [" + token.text + "] in enum [" + ei->text + "]");
    }

    Token* ep = CloneToken(token);
    EnumValue* ev = new EnumValue(ei, ep);
    RightValue* rv = new RightValue(ev);
    Declare* declare = new Declare(TYPE_ENUM, id, eid, rv);
    return declare;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x258(%rbp)
movq (%rax), %rdi
callq 0xae520
movq -0x258(%rbp), %rdi
movq %rax, %rsi
callq 0xa81f0
movq %rax, %rcx
movq -0x258(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x250(%rbp)
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0x991c0
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rsi
callq 0xbcf70
movq %rax, -0x240(%rbp)
jmp 0xaa572
movq -0x240(%rbp), %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
movb %al, -0x259(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x992c0
movb -0x259(%rbp), %al
testb $0x1, %al
jne 0xaa5a0
jmp 0xaa64d
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0x550e5(%rip), %rsi     # 0xff694
leaq -0x80(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0xa6e30
movq -0x268(%rbp), %rsi
leaq 0x5508c(%rip), %rdx     # 0xff659
leaq -0x60(%rbp), %rdi
callq 0xa10c0
jmp 0xaa5d8
movq -0x258(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x60(%rbp), %rsi
callq 0xa82a0
jmp 0xaa5ee
leaq -0x60(%rbp), %rdi
callq 0x992c0
leaq -0x80(%rbp), %rdi
callq 0x992c0
jmp 0xaa64d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa63f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x992c0
leaq -0x80(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq -0x258(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0x258(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq -0x258(%rbp), %rdi
movq %rax, -0x88(%rbp)
movl $0x3d, %esi
callq 0xa83a0
movq -0x258(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0x258(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
movq -0x90(%rbp), %rsi
addq $0x8, %rsi
callq 0xab370
testb $0x1, %al
jne 0xaa6d5
jmp 0xaa805
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0x54fc1(%rip), %rsi     # 0xff6a5
leaq -0x110(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0xa6e30
movq -0x270(%rbp), %rsi
leaq 0x54fac(%rip), %rdx     # 0xff6b1
leaq -0xf0(%rbp), %rdi
callq 0xa10c0
jmp 0xaa713
movq -0x90(%rbp), %rdx
addq $0x8, %rdx
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa1070
jmp 0xaa733
leaq 0x56348(%rip), %rdx     # 0x100a82
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xa10c0
jmp 0xaa74f
movq -0x258(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0xb0(%rbp), %rsi
callq 0xa82a0
jmp 0xaa768
leaq -0xb0(%rbp), %rdi
callq 0x992c0
leaq -0xd0(%rbp), %rdi
callq 0x992c0
leaq -0xf0(%rbp), %rdi
callq 0x992c0
leaq -0x110(%rbp), %rdi
callq 0x992c0
jmp 0xaa805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa7f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa7e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa7dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x992c0
leaq -0xd0(%rbp), %rdi
callq 0x992c0
leaq -0xf0(%rbp), %rdi
callq 0x992c0
leaq -0x110(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq -0x258(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x288(%rbp)
movq -0x90(%rbp), %rsi
addq $0x8, %rsi
leaq -0x138(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x991c0
movq -0x288(%rbp), %rdi
movq -0x280(%rbp), %rsi
callq 0xbcf70
movq %rax, -0x278(%rbp)
jmp 0xaa855
leaq -0x138(%rbp), %rdi
callq 0x992c0
movq -0x278(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x118(%rbp)
jne 0xaa945
movq -0x90(%rbp), %rdx
addq $0x8, %rdx
leaq 0x54e05(%rip), %rsi     # 0xff694
leaq -0x178(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0xa6e30
movq -0x290(%rbp), %rsi
leaq 0x54da9(%rip), %rdx     # 0xff659
leaq -0x158(%rbp), %rdi
callq 0xa10c0
jmp 0xaa8be
movq -0x258(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x158(%rbp), %rsi
callq 0xa82a0
jmp 0xaa8d7
leaq -0x158(%rbp), %rdi
callq 0x992c0
leaq -0x178(%rbp), %rdi
callq 0x992c0
jmp 0xaa945
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x992c0
leaq -0x178(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq -0x258(%rbp), %rdi
movl $0x2e, %esi
callq 0xa83a0
movq -0x258(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0x258(%rbp), %rsi
movq 0x8(%rsi), %rax
movq 0x50(%rax), %rax
movq %rax, -0x2b0(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x2a8(%rbp)
addq $0x18, %rsi
leaq -0x198(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x991c0
movq -0x2b0(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
movq -0x2a0(%rbp), %rdx
callq 0xbd020
movb %al, -0x291(%rbp)
jmp 0xaa9c4
movb -0x291(%rbp), %al
xorb $-0x1, %al
movb %al, -0x2b1(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x992c0
movb -0x2b1(%rbp), %al
testb $0x1, %al
jne 0xaa9ed
jmp 0xaab40
movq -0x258(%rbp), %rdx
addq $0x18, %rdx
leaq 0x54cc6(%rip), %rsi     # 0xff6c5
leaq -0x218(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0xa6e30
movq -0x2c0(%rbp), %rsi
leaq 0x54cba(%rip), %rdx     # 0xff6da
leaq -0x1f8(%rbp), %rdi
callq 0xa10c0
jmp 0xaaa2e
movq -0x90(%rbp), %rdx
addq $0x8, %rdx
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0xa1070
jmp 0xaaa4e
leaq 0x5602d(%rip), %rdx     # 0x100a82
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0xa10c0
jmp 0xaaa6a
movq -0x258(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x1b8(%rbp), %rsi
callq 0xa82a0
jmp 0xaaa83
leaq -0x1b8(%rbp), %rdi
callq 0x992c0
leaq -0x1d8(%rbp), %rdi
callq 0x992c0
leaq -0x1f8(%rbp), %rdi
callq 0x992c0
leaq -0x218(%rbp), %rdi
callq 0x992c0
jmp 0xaab40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaab2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaab23
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaab17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x992c0
leaq -0x1d8(%rbp), %rdi
callq 0x992c0
leaq -0x1f8(%rbp), %rdi
callq 0x992c0
leaq -0x218(%rbp), %rdi
callq 0x992c0
jmp 0xaac6b
movq -0x258(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq %rax, -0x220(%rbp)
movl $0x10, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
movq -0x90(%rbp), %rsi
movq -0x220(%rbp), %rdx
callq 0xb34b0
jmp 0xaab86
movq -0x2c8(%rbp), %rax
movq %rax, -0x228(%rbp)
movl $0x58, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d0(%rbp)
movq -0x228(%rbp), %rsi
xorl %edx, %edx
callq 0xb33e0
jmp 0xaabbb
movq -0x2d0(%rbp), %rax
movq %rax, -0x230(%rbp)
movl $0x20, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x230(%rbp), %r8
movl $0x9, %esi
xorl %r9d, %r9d
callq 0xb3580
jmp 0xaac01
movq -0x2d8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x2c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
jmp 0xaac6b
movq -0x2d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
jmp 0xaac6b
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
movq -0x38(%rbp), %rdi
callq 0x99840
nopw %cs:(%rax,%rax)