// File: /workspace/github_cpp_makefile_star2_O2/CoinXu[P]reviser-compiler/src/parser.cpp
// Function: reviser::compiler::Parser::ConsumeStruct(reviser::ast::Struct*)
Struct* Parser::ConsumeStruct(Struct* parent) {
    Expect(TOKEN_STRUCT);
    Expect(TOKEN_ID);

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

    Struct* s = new Struct(CloneToken(token));

    Expect(TOKEN_LEFT_BRACE);

    generator->descriptor->PushContextVariable(s);
    generator->descriptor->PushNewContext();

    while (!Accept(TOKEN_RIGHT_BRACE)) {
      if (LookAtType(TOKEN_STRUCT)) {
        s->AddStruct(ConsumeStruct(s));
      } else if (LookAtType(TOKEN_ENUM)) {
        s->AddEnum(ConsumeEnum(s));
      } else {
        StructProperty* p = ConsumeStructProperty();
        if (generator->descriptor->StructIncludeProperty(s, p->declare->id->text)) {
          RuntimeError("duplicate declare property named [" + p->declare->id->text + "]");
        }
        if (generator->descriptor->FindCurrentContextVariableById(p->declare->id->text)) {
          RuntimeError("duplicate declare named [" + p->declare->id->text + "]");
        }
        s->AddProperty(p);
      }
    }

    generator->descriptor->PopBackContext();
    return s;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x2
popq %rsi
callq 0x3b58a
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x3b58a
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r12
leaq 0x18(%rbx), %r14
leaq -0x70(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x35470
movq %r12, %rdi
movq %r13, %rsi
callq 0x41216
testq %rax, %rax
je 0x3b0db
leaq -0x70(%rbp), %rdi
callq 0x35180
leaq 0x1c6d5(%rip), %rsi     # 0x57543
leaq -0x50(%rbp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0x3aa1e
leaq 0x1db8e(%rip), %rdx     # 0x58a12
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x38f1f
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3b4e8
leaq -0x90(%rbp), %rdi
callq 0x35180
leaq -0x50(%rbp), %rdi
callq 0x35180
leaq 0x10(%rbx), %r15
movl $0xa0, %edi
callq 0x35330
movq %rax, %r14
movq %r15, %rsi
callq 0x3b480
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x3f594
pushq $0x7b
popq %rsi
movq %rbx, %rdi
callq 0x3b58a
movq 0x8(%rbx), %rax
movq 0x50(%rax), %rdi
movq %r14, %rsi
callq 0x410b6
movq 0x8(%rbx), %rax
movq 0x50(%rax), %rdi
callq 0x40fe8
pushq $0x7d
popq %r12
leaq -0xd0(%rbp), %r15
movq %r14, -0x30(%rbp)
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3ada2
testb %al, %al
jne 0x3b0b9
movq %rbx, %rdi
callq 0x3b704
movq %rbx, %rdi
cmpl $0x2, %eax
jne 0x3af4e
movq %r14, %rsi
callq 0x3ae02
movq %r14, %rdi
movq %rax, %rsi
callq 0x3f6b2
jmp 0x3af16
callq 0x3b704
movq %rbx, %rdi
cmpl $0x3, %eax
jne 0x3af70
movq %r14, %rsi
callq 0x3b1b8
movq %r14, %rdi
movq %rax, %rsi
callq 0x3f706
jmp 0x3af16
callq 0x3b74c
movq %rax, %r12
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r13
movq 0x48(%r12), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x35470
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x41440
movl %eax, %r13d
movq %r15, %rdi
callq 0x35180
testb %r13b, %r13b
leaq -0x50(%rbp), %r15
leaq -0x110(%rbp), %r14
je 0x3b010
movq 0x48(%r12), %rax
movq 0x8(%rax), %rdx
addq $0x8, %rdx
movq %r15, %rdi
leaq 0x1c588(%rip), %rsi     # 0x5755d
callq 0x3aa1e
leaq -0x130(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
leaq 0x1da24(%rip), %rdx     # 0x58a12
callq 0x38f1f
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3b4e8
movq %r13, %rdi
callq 0x35180
movq %r15, %rdi
callq 0x35180
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r13
movq 0x48(%r12), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
movq %r14, %rdi
callq 0x35470
movq %r13, %rdi
movq %r14, %rsi
callq 0x41216
movq %rax, %r13
movq %r14, %rdi
callq 0x35180
testq %r13, %r13
movq -0x30(%rbp), %r14
leaq -0xf0(%rbp), %r13
je 0x3b09e
movq 0x48(%r12), %rax
movq 0x8(%rax), %rdx
addq $0x8, %rdx
movq %r15, %rdi
leaq 0x1c4d9(%rip), %rsi     # 0x57543
callq 0x3aa1e
movq %r13, %rdi
movq %r15, %rsi
leaq 0x1d996(%rip), %rdx     # 0x58a12
callq 0x38f1f
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x3b4e8
movq %r13, %rdi
callq 0x35180
movq %r15, %rdi
callq 0x35180
movq %r14, %rdi
movq %r12, %rsi
callq 0x3f65e
leaq -0xd0(%rbp), %r15
pushq $0x7d
popq %r12
jmp 0x3af16
movq 0x8(%rbx), %rax
movq 0x50(%rax), %rdi
callq 0x41040
movq %r14, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0x3b12f
movq 0x8(%rbx), %rax
movq 0x50(%rax), %r12
leaq -0xb0(%rbp), %rdi
movq %r14, %rsi
callq 0x35470
leaq -0xb0(%rbp), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x41440
movl %eax, %r15d
leaq -0xb0(%rbp), %rdi
callq 0x35180
leaq -0x70(%rbp), %rdi
callq 0x35180
testb %r15b, %r15b
jne 0x3ae67
jmp 0x3aeb9
leaq -0x70(%rbp), %rdi
jmp 0x3aeb4
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x35180
jmp 0x3b15a
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x3b185
jmp 0x3b18c
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
jmp 0x3b1ab
movq %rax, %rbx
movq %r14, %rdi
callq 0x35310
jmp 0x3b1b0
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0x3b185
jmp 0x3b18c
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x35180
jmp 0x3b18f
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
jmp 0x3b1ab
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
jmp 0x3b1ab
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x35180
movq %rbx, %rdi
callq 0x355f0