// File: Heptagon196[P]Gos/GosASTCompiler.cpp
// Function: Gos::AST::Preprocess::CompileAST(Gos::Compiler::VMCompiler&)
Compile(Preprocess) {
    START();
    // using
    if (branch & 8) {
        usings.push_back(nodes[0]->token.str);
        return 0;
    }
    // class def
    int start = 0;
    if (branch & 2) {
        SUB(start++);
    }
    std::string className = nodes[start++]->token.str;
    compilingClassName = className;
    compilingClassVars.clear();
    compilingClassVarTypes.clear();
    std::vector<std::string> inherits;
    if (branch & 4) {
        GosAST* idList = nodes[start++];
        for (GosAST* ast : idList->nodes) {
            inherits.push_back(ast->token.str);
        }
    }
    vm.WriteCommandAttributes("GosInstance", {});
    vm.WriteCommandDefClass(className, inherits);
    for (int i = 0; i < usings.size(); i++) {
        std::string& name = usings[i];
        compilingClassVars.push_back(name);
        compilingClassVarTypes.push_back(name);
        vm.WriteCommandNamespace(name);
        pc--;
        code.currentScope->varID.erase(name);
        code.currentScope->varType.erase(name);
    }
    auto& mgr = ReflMgr::Instance();
    for (const std::string& cls : inherits) {
        mgr.IterateField(TypeID::getRaw(cls), std::function([&](const FieldInfo& field) {
            std::string varName = field.name;
            std::string typeName = (std::string)field.varType.getName();
            compilingClassVars.push_back(varName);
            compilingClassVarTypes.push_back(typeName);
            vm.WriteCommandDefVar(typeName, varName);
            pc--;
            code.currentScope->varID.erase(varName);
            code.currentScope->varType.erase(typeName);
        }));
    }
    for (int i = start; i < nodes.size(); i++) {
        SUB(i);
    }
    return 0;
}

// Assembly:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, 0x1d8(%rsp)
movq %rsi, 0x1d0(%rsp)
movq 0x1d8(%rsp), %rdi
movq %rdi, 0x70(%rsp)
movl 0x2c(%rdi), %eax
movl %eax, 0x125fdb(%rip)    # 0x3022f8
addq $0x10, %rdi
callq 0x1d1e80
cmpq $0x0, %rax
jne 0x1dc33c
movl $0x0, 0x1e4(%rsp)
jmp 0x1dc9a4
movq 0x70(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1dc385
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1d1e60
movq (%rax), %rsi
addq $0x28, %rsi
addq $0x18, %rsi
leaq 0x125f70(%rip), %rdi    # 0x3022e0
callq 0x1b4f80
movl $0x0, 0x1e4(%rsp)
jmp 0x1dc9a4
movq 0x70(%rsp), %rax
movl $0x0, 0x1cc(%rsp)
movl 0x8(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1dc3d4
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
movl 0x1cc(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1cc(%rsp)
movslq %eax, %rsi
callq 0x1d1e60
movq (%rax), %rdi
movq 0x1d0(%rsp), %rsi
movq (%rdi), %rax
callq *(%rax)
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
movslq 0x1cc(%rsp), %rsi
movl %esi, %eax
incl %eax
movl %eax, 0x1cc(%rsp)
callq 0x1d1e60
movq (%rax), %rsi
addq $0x40, %rsi
leaq 0x1a8(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0x6f070
movq 0x68(%rsp), %rsi
leaq 0x125e76(%rip), %rdi    # 0x302290
callq 0x1187a0
jmp 0x1dc421
leaq 0x125e88(%rip), %rdi    # 0x3022b0
callq 0x1dd1d0
leaq 0x125e94(%rip), %rdi    # 0x3022c8
callq 0x1dd1d0
leaq 0x180(%rsp), %rdi
callq 0x1b4f70
movq 0x70(%rsp), %rax
movl 0x8(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x1dc55c
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
movl 0x1cc(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x1cc(%rsp)
movslq %eax, %rsi
callq 0x1d1e60
movq (%rax), %rax
movq %rax, 0x178(%rsp)
movq 0x178(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x170(%rsp)
movq 0x170(%rsp), %rdi
callq 0x1d1b70
movq %rax, 0x168(%rsp)
movq 0x170(%rsp), %rdi
callq 0x1d1ba0
movq %rax, 0x160(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x1d1bd0
xorb $-0x1, %al
testb $0x1, %al
jne 0x1dc4e4
jmp 0x1dc55a
leaq 0x168(%rsp), %rdi
callq 0x1d1c10
movq (%rax), %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rsi
addq $0x40, %rsi
leaq 0x180(%rsp), %rdi
callq 0x1b4f80
jmp 0x1dc517
jmp 0x1dc519
leaq 0x168(%rsp), %rdi
callq 0x1d1c20
jmp 0x1dc4c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x1dc995
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x1dc988
jmp 0x1dc55c
movq 0x1d0(%rsp), %rax
movq 0xe8(%rax), %rax
movq %rax, 0x58(%rsp)
leaq 0x137(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x13570
movq 0x60(%rsp), %rdx
leaq 0x45aba(%rip), %rsi     # 0x222048
leaq 0x138(%rsp), %rdi
callq 0x165520
jmp 0x1dc59d
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
movq $0x0, 0x120(%rsp)
leaq 0x110(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x1b4f70
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %rdx
leaq 0x138(%rsp), %rsi
callq 0x1b1a30
jmp 0x1dc5df
leaq 0x110(%rsp), %rdi
callq 0x6ed80
leaq 0x138(%rsp), %rdi
callq 0x52f50
leaq 0x137(%rsp), %rdi
callq 0x136a0
movq 0x1d0(%rsp), %rax
movq 0xe8(%rax), %rdi
leaq 0x1a8(%rsp), %rsi
leaq 0x180(%rsp), %rdx
callq 0x1b0670
jmp 0x1dc62c
movl $0x0, 0x10c(%rsp)
movslq 0x10c(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0x125c95(%rip), %rdi    # 0x3022e0
callq 0x6f4b0
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jae 0x1dc78f
movslq 0x10c(%rsp), %rsi
leaq 0x125c70(%rip), %rdi    # 0x3022e0
callq 0x1dd580
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rsi
leaq 0x125c24(%rip), %rdi    # 0x3022b0
callq 0x1b4f80
jmp 0x1dc693
movq 0x100(%rsp), %rsi
leaq 0x125c26(%rip), %rdi    # 0x3022c8
callq 0x1b4f80
jmp 0x1dc6a9
movq 0x1d0(%rsp), %rax
movq 0xe8(%rax), %rdi
movq 0x100(%rsp), %rsi
callq 0x1b0ec0
jmp 0x1dc6c7
movq 0x1d0(%rsp), %rax
movl 0xe0(%rax), %ecx
decl %ecx
movl %ecx, 0xe0(%rax)
movq 0x1d0(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x28, %rdi
movq 0x100(%rsp), %rsi
callq 0x1dd790
jmp 0x1dc6ff
movq 0x1d0(%rsp), %rax
movq 0xd0(%rax), %rdi
addq $0x60, %rdi
movq 0x100(%rsp), %rsi
callq 0x1dd7c0
jmp 0x1dc721
jmp 0x1dc723
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0x1dc637
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
jmp 0x1dc77d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x6ed80
leaq 0x138(%rsp), %rdi
callq 0x52f50
leaq 0x137(%rsp), %rdi
callq 0x136a0
jmp 0x1dc988
callq 0x4a240
movq %rax, 0x40(%rsp)
jmp 0x1dc79b
movq 0x40(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0x180(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x1b54a0
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x1b54d0
movq %rax, 0xe0(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x1b5500
xorb $-0x1, %al
testb $0x1, %al
jne 0x1dc802
jmp 0x1dc8fa
leaq 0xe8(%rsp), %rdi
callq 0x1b5540
movq %rax, 0xd8(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x52f00
movq %rax, 0xa8(%rsp)
movq %rdx, 0xb0(%rsp)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq 0xb8(%rsp), %rdi
callq 0x18fed0
jmp 0x1dc860
movq 0x1d0(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x30(%rsp)
leaq 0x80(%rsp), %rsi
callq 0x1dc9c0
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
movups 0xb8(%rsp), %xmm0
movups 0xc8(%rsp), %xmm1
movq %rsp, %rax
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x4de90
jmp 0x1dc8b5
leaq 0x88(%rsp), %rdi
callq 0x1dd7f0
leaq 0xe8(%rsp), %rdi
callq 0x1b5550
jmp 0x1dc7e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1a0(%rsp)
movl %eax, 0x19c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x1dd7f0
jmp 0x1dc988
movl 0x1cc(%rsp), %eax
movl %eax, 0x7c(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x7c(%rsp), %rax
movq %rax, 0x28(%rsp)
addq $0x10, %rdi
callq 0x1d1e80
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x1dc961
movq 0x70(%rsp), %rdi
addq $0x10, %rdi
movslq 0x7c(%rsp), %rsi
callq 0x1d1e60
movq (%rax), %rdi
movq 0x1d0(%rsp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x1dc952
jmp 0x1dc954
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x1dc905
movl $0x0, 0x1e4(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x6ed80
leaq 0x1a8(%rsp), %rdi
callq 0x52f50
jmp 0x1dc9a4
leaq 0x180(%rsp), %rdi
callq 0x6ed80
leaq 0x1a8(%rsp), %rdi
callq 0x52f50
jmp 0x1dc9b3
movl 0x1e4(%rsp), %eax
addq $0x1e8, %rsp            # imm = 0x1E8
retq
movq 0x1a0(%rsp), %rdi
callq 0x133f0