// File: CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeStructDeclare()
Declare* Parser::ConsumeStructDeclare() {
    Token* sid = CloneToken(tokenizer->Previous());
    // struct type id
    if (!generator->descriptor->FindStructContextVariableById(sid->text)) {
      RuntimeError("undefined struct [" + sid->text + "] in current scope");
    }

    Expect(TOKEN_ID);
    Token* id = CloneToken(token);
    StructValue* sv;

    // struct only allow null to default value
    if (Accept(TOKEN_ASSIGN)) {
      Expect(TOKEN_DATA_TYPE);
      sv = new StructValue(sid, CloneToken(token));
      if (token.text != ReservedWordMap[RESERVED_NULL]) {
        RuntimeError("struct only allow null to default value");
      }
    } else {
      sv = new StructValue(sid, nullptr);
    }

    generator->descriptor->AddDataTypesOnce(TYPE_STRUCT);
    RightValue* rv = new RightValue(sv);
    Declare* declare = new Declare(TYPE_STRUCT, id, sid, rv);
    return declare;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq (%rax), %rdi
callq 0xae520
movq -0xf0(%rbp), %rdi
movq %rax, %rsi
callq 0xa81f0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rsi
addq $0x8, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x991c0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0xbd0d0
movq %rax, -0xd8(%rbp)
jmp 0xaa122
movq -0xd8(%rbp), %rax
cmpq $0x0, %rax
setne %al
xorb $-0x1, %al
movb %al, -0xf1(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x992c0
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0xaa150
jmp 0xaa1fd
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0x554e7(%rip), %rsi     # 0xff646
leaq -0x80(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0xa6e30
movq -0x100(%rbp), %rsi
leaq 0x554dc(%rip), %rdx     # 0xff659
leaq -0x60(%rbp), %rdi
callq 0xa10c0
jmp 0xaa188
movq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0x60(%rbp), %rsi
callq 0xa82a0
jmp 0xaa19e
leaq -0x60(%rbp), %rdi
callq 0x992c0
leaq -0x80(%rbp), %rdi
callq 0x992c0
jmp 0xaa1fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x992c0
jmp 0xaa4de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa1ef
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 0xaa4de
movq -0xf0(%rbp), %rdi
movl $0x4, %esi
callq 0xa83a0
movq -0xf0(%rbp), %rdi
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq -0xf0(%rbp), %rdi
movq %rax, -0x88(%rbp)
movl $0x3d, %esi
callq 0xa75f0
testb $0x1, %al
jne 0xaa242
jmp 0xaa3b5
movq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0xa83a0
movl $0x10, %edi
callq 0x99480
movq -0xf0(%rbp), %rdi
movq %rax, -0x118(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
movq %rdi, %rsi
addq $0x10, %rsi
callq 0xa81f0
movq %rax, -0x108(%rbp)
jmp 0xaa288
movq -0x108(%rbp), %rdx
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdi
callq 0xb3470
jmp 0xaa2a4
movq -0xf0(%rbp), %rax
movq -0x118(%rbp), %rcx
movq %rcx, -0x90(%rbp)
addq $0x10, %rax
addq $0x8, %rax
movq %rax, -0x120(%rbp)
movl $0xc, -0x94(%rbp)
leaq 0x86767(%rip), %rdi     # 0x130a40
leaq -0x94(%rbp), %rsi
callq 0xa48c0
movq -0x120(%rbp), %rdi
movq %rax, %rsi
callq 0xab370
testb $0x1, %al
jne 0xaa2fd
jmp 0xaa3b3
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x99850
movq -0x128(%rbp), %rdx
leaq 0x5534e(%rip), %rsi     # 0xff66c
leaq -0xb8(%rbp), %rdi
callq 0x99640
jmp 0xaa32c
movq -0xf0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq -0xb8(%rbp), %rsi
callq 0xa82a0
jmp 0xaa345
leaq -0xb8(%rbp), %rdi
callq 0x992c0
leaq -0xb9(%rbp), %rdi
callq 0x994f0
jmp 0xaa3b3
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
jmp 0xaa4de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xaa3a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x992c0
leaq -0xb9(%rbp), %rdi
callq 0x994f0
jmp 0xaa4de
jmp 0xaa408
movl $0x10, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x130(%rbp)
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xb3470
jmp 0xaa3db
movq -0x130(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0xaa408
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
jmp 0xaa4de
movq -0xf0(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rdi
movl $0xa, %esi
callq 0xbd440
movl $0x58, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x138(%rbp)
movq -0x90(%rbp), %rsi
xorl %edx, %edx
callq 0xb3380
jmp 0xaa448
movq -0x138(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x20, %edi
callq 0x99480
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x140(%rbp)
movq -0x88(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0xc8(%rbp), %r8
movl $0xa, %esi
xorl %r9d, %r9d
callq 0xb3580
jmp 0xaa48e
movq -0x140(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x99440
jmp 0xaa4de
movq -0x140(%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 (%rax,%rax)