// File: /workspace/github_cpp_makefile_star2_O1/CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeDeclare()
Declare* Parser::ConsumeDeclare() {
    // data type & data type array
    if (Accept(TOKEN_DATA_TYPE)) {
      const string type = PreviousText();
      if (Accept(TOKEN_LEFT_BRACKET)) {
        return ConsumeDataTypeArrayDeclare(type);
      }
      return ConsumeDataTypeDeclare();
    }

    // struct & struct array
    // enum & enum array
    if (Accept(TOKEN_ID)) {
      // TODO support struct array type
      const Token type_id = tokenizer->Previous();
      const string id = type_id.text;
      DeclareType type = generator->descriptor->FindContextVariableTypeById(id);

      if (Accept(TOKEN_LEFT_BRACKET)) {
        if (type == DECLARE_STRUCT) {
          return ConsumeStructArrayDeclare(type_id);
        }

        if (type == DECLARE_ENUM) {
          return ConsumeEnumArrayDeclare(type_id);
        }

        RuntimeError("unknow array type [" + id + "]");
        return nullptr;
      }

      if (type == DECLARE_STRUCT) {
        return ConsumeStructDeclare();
      }

      if (type == DECLARE_ENUM) {
        return ConsumeEnumDeclare();
      }

      if (type == DECLARE_UNDEFINED) {
        RuntimeError("undefined type [" + id + "]");
        return nullptr;
      }

      RuntimeError("unknow type [" + id + "]");
      return nullptr;
    }

    RuntimeError("unexpected token");
    return nullptr;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rdi, %rbx
xorl %esi, %esi
callq 0x2ca72
testb %al, %al
je 0x2dbd3
movq (%rbx), %rdi
callq 0x30392
leaq -0xf8(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x2a264
movq %rbx, %rdi
movl $0x5b, %esi
callq 0x2ca72
testb %al, %al
je 0x2dd1c
leaq -0x138(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
addq %rsi, %rdx
leaq -0x148(%rbp), %rdi
callq 0x2a264
leaq -0x148(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e044
movq %rax, %rbx
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x2dd27
callq 0x25320
jmp 0x2dd27
movq %rbx, %rdi
movl $0x4, %esi
callq 0x2ca72
testb %al, %al
je 0x2dcd2
movq (%rbx), %rdi
callq 0x30392
movq %rax, %r14
movl (%rax), %eax
leaq -0x100(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0xf0(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
callq 0x2a264
movq 0x38(%r14), %rax
movq %rax, 0x20(%r15)
movups 0x28(%r14), %xmm0
movups %xmm0, 0x10(%r15)
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x10(%r15), %rsi
movq -0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x2a264
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r14
leaq -0x118(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %rdi
callq 0x2a264
leaq -0x128(%rbp), %rsi
movq %r14, %rdi
callq 0x33e46
movl %eax, %r14d
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x2dc96
callq 0x25320
movq %rbx, %rdi
movl $0x5b, %esi
callq 0x2ca72
testb %al, %al
je 0x2dd4d
testl %r14d, %r14d
je 0x2dd77
cmpl $0x1, %r14d
jne 0x2dd8b
leaq -0x108(%rbp), %rsi
movq %rbx, %rdi
callq 0x2e9b0
jmp 0x2de43
leaq -0x158(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x228cf(%rip), %rsi     # 0x505b3
leaq 0x228d8(%rip), %rdx     # 0x505c3
leaq -0x168(%rbp), %r14
movq %r14, %rdi
callq 0x2a2fe
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x2d4fe
movq -0x168(%rbp), %rdi
cmpq %r15, %rdi
je 0x2dd18
callq 0x25320
xorl %ebx, %ebx
jmp 0x2dd38
movq %rbx, %rdi
callq 0x2e202
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r14, %rdi
je 0x2dd38
callq 0x25320
movq %rbx, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
je 0x2de3b
cmpl $0x2, %r14d
je 0x2dde3
cmpl $0x1, %r14d
jne 0x2de4b
movq %rbx, %rdi
callq 0x2ebbc
jmp 0x2de43
leaq -0x108(%rbp), %rsi
movq %rbx, %rdi
callq 0x2eb74
jmp 0x2df5c
leaq 0x227ee(%rip), %rsi     # 0x50580
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2c6b4
leaq 0x23c7c(%rip), %rsi     # 0x51a22
leaq -0x48(%rbp), %rdi
callq 0x25650
leaq -0xb8(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2de9a
movq %rdx, -0xc8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb8(%rbp)
jmp 0x2dea1
leaq 0x227aa(%rip), %rsi     # 0x50594
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2c6b4
leaq 0x23c24(%rip), %rsi     # 0x51a22
leaq -0x48(%rbp), %rdi
callq 0x25650
leaq -0x98(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2ded2
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0x2ded9
movq %rbx, %rdi
callq 0x2ee90
movq %rax, %rbx
jmp 0x2df5e
leaq 0x22753(%rip), %rsi     # 0x505a5
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2c6b4
leaq 0x23bbc(%rip), %rsi     # 0x51a22
leaq -0x48(%rbp), %rdi
callq 0x25650
leaq -0x78(%rbp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2df0a
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x2df11
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0xc8(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2d4fe
movq -0xc8(%rbp), %rdi
jmp 0x2df40
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0xa8(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2d4fe
movq -0xa8(%rbp), %rdi
jmp 0x2df40
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq -0x88(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2d4fe
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
je 0x2df4a
callq 0x25320
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2df5c
callq 0x25320
xorl %ebx, %ebx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x2df6c
callq 0x25320
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
jne 0x2dd33
jmp 0x2dd38
movq %rax, %rbx
movq -0x88(%rbp), %rdi
jmp 0x2dfab
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
jmp 0x2dfab
jmp 0x2dfb7
jmp 0x2dfb7
jmp 0x2e008
jmp 0x2e008
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
cmpq %r14, %rdi
je 0x2dfba
callq 0x25320
jmp 0x2dfba
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x2dfda
jmp 0x2e00b
jmp 0x2e008
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x2e00b
callq 0x25320
jmp 0x2e00b
movq %rax, %rbx
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x2e035
callq 0x25320
jmp 0x2e035
movq %rax, %rbx
movq -0x168(%rbp), %rdi
jmp 0x2e020
movq %rax, %rbx
jmp 0x2e019
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x2e019
callq 0x25320
movq -0x100(%rbp), %rdi
cmpq %r15, %rdi
je 0x2e02a
callq 0x25320
movq %rbx, %rdi
callq 0x255f0
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r14, %rdi
jne 0x2e025
jmp 0x2e02a
nop