// File: CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeEnum(reviser::ast::Struct*)
Enum* Parser::ConsumeEnum(Struct* parent) {
    Expect(TOKEN_ENUM);
    Expect(TOKEN_ID);

    if (generator->descriptor->FindCurrentContextVariableById(token.text)
      || (parent && generator->descriptor->StructIncludeProperty(parent, token.text))) {
      RuntimeError("duplicate declare named [" + token.text + "]");
    }

    Token* id = CloneToken(token);
    Enum* e = new Enum(id);
    generator->descriptor->PushContextVariable(e);

    Expect(TOKEN_LEFT_BRACE);

    // no property enum
    if (Accept(TOKEN_RIGHT_BRACE)) {
      return e;
    }

    do {
      EnumProperty* property = ConsumeEnumProperty();
      if (generator->descriptor->EnumInlcudeProperty(e, property->id->text)) {
        RuntimeError("duplicate declare enum property named [" + property->id->text + "]");
        break;
      }
      e->properties.push_back(property);
    } while (Accept(TOKEN_COMMA));

    Expect(TOKEN_RIGHT_BRACE);
    return e;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x148(%rbp)
movl $0x3, %esi
callq 0xa83a0
movq -0x148(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0x148(%rbp), %rsi
movq 0x8(%rsi), %rax
movq 0x50(%rax), %rax
movq %rax, -0x140(%rbp)
addq $0x18, %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x991c0
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movb $0x0, -0x69(%rbp)
callq 0xbcde0
movq %rax, -0x130(%rbp)
jmp 0xa7d93
movq -0x130(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0x149(%rbp)
jne 0xa7e24
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x14a(%rbp)
je 0xa7e18
movq -0x148(%rbp), %rsi
movq 0x8(%rsi), %rax
movq 0x50(%rax), %rax
movq %rax, -0x160(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x158(%rbp)
addq $0x18, %rsi
leaq -0x68(%rbp), %rdi
callq 0x991c0
jmp 0xa7de7
movq -0x158(%rbp), %rsi
movq -0x160(%rbp), %rdi
movb $0x1, -0x69(%rbp)
leaq -0x68(%rbp), %rdx
callq 0xbd180
movb %al, -0x161(%rbp)
jmp 0xa7e0a
movb -0x161(%rbp), %al
movb %al, -0x14a(%rbp)
jmp 0xa7e18
movb -0x14a(%rbp), %al
movb %al, -0x149(%rbp)
movb -0x149(%rbp), %al
movb %al, -0x162(%rbp)
testb $0x1, -0x69(%rbp)
jne 0xa7e38
jmp 0xa7e41
leaq -0x68(%rbp), %rdi
callq 0x992c0
leaq -0x38(%rbp), %rdi
callq 0x992c0
movb -0x162(%rbp), %al
testb $0x1, %al
jne 0xa7e59
jmp 0xa7f3f
movq -0x148(%rbp), %rdx
addq $0x18, %rdx
leaq 0x57688(%rip), %rsi     # 0xff4f3
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0xa6e30
movq -0x170(%rbp), %rsi
leaq 0x58bf6(%rip), %rdx     # 0x100a82
leaq -0x90(%rbp), %rdi
callq 0xa10c0
jmp 0xa7e9a
movq -0x148(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x90(%rbp), %rsi
callq 0xa82a0
jmp 0xa7eb3
leaq -0x90(%rbp), %rdi
callq 0x992c0
leaq -0xb0(%rbp), %rdi
callq 0x992c0
jmp 0xa7f3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa7efa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x69(%rbp)
jne 0xa7eef
jmp 0xa7ef8
leaq -0x68(%rbp), %rdi
callq 0x992c0
jmp 0xa7efa
leaq -0x38(%rbp), %rdi
callq 0x992c0
jmp 0xa81bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa7f2e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x992c0
leaq -0xb0(%rbp), %rdi
callq 0x992c0
jmp 0xa81bc
movq -0x148(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq %rax, -0xb8(%rbp)
movl $0x50, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
movq -0xb8(%rbp), %rsi
callq 0xb3d10
jmp 0xa7f7e
movq -0x148(%rbp), %rax
movq -0x178(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movq 0x8(%rax), %rax
movq 0x50(%rax), %rdi
movq -0xc0(%rbp), %rsi
callq 0xbcb50
movq -0x148(%rbp), %rdi
movl $0x7b, %esi
callq 0xa83a0
movq -0x148(%rbp), %rdi
movl $0x7d, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa7fcf
jmp 0xa7ffc
movq -0xc0(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xa81af
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x99440
jmp 0xa81bc
jmp 0xa7ffe
movq -0x148(%rbp), %rdi
callq 0xaac80
movq %rax, %rcx
movq -0x148(%rbp), %rax
movq %rcx, -0xc8(%rbp)
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0x198(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0xc8(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x8, %rsi
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x991c0
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
movq -0x188(%rbp), %rdx
callq 0xbd020
movb %al, -0x179(%rbp)
jmp 0xa807c
leaq -0xe8(%rbp), %rdi
callq 0x992c0
movb -0x179(%rbp), %al
testb $0x1, %al
jne 0xa8097
jmp 0xa8163
movq -0xc8(%rbp), %rax
movq 0x30(%rax), %rdx
addq $0x8, %rdx
leaq 0x5765b(%rip), %rsi     # 0xff708
leaq -0x128(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0xa6e30
movq -0x1a0(%rbp), %rsi
leaq 0x589b4(%rip), %rdx     # 0x100a82
leaq -0x108(%rbp), %rdi
callq 0xa10c0
jmp 0xa80dc
movq -0x148(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x108(%rbp), %rsi
callq 0xa82a0
jmp 0xa80f5
leaq -0x108(%rbp), %rdi
callq 0x992c0
leaq -0x128(%rbp), %rdi
callq 0x992c0
jmp 0xa8193
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x992c0
jmp 0xa81bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xa8155
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x992c0
leaq -0x128(%rbp), %rdi
callq 0x992c0
jmp 0xa81bc
movq -0xc0(%rbp), %rdi
addq $0x38, %rdi
leaq -0xc8(%rbp), %rsi
callq 0xab3a0
movq -0x148(%rbp), %rdi
movl $0x2c, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xa7ffe
movq -0x148(%rbp), %rdi
movl $0x7d, %esi
callq 0xa83a0
movq -0xc0(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x99840
nopw %cs:(%rax,%rax)