// File: CoinXu[P]reviser-compiler/src/compiler/javascript/javascript_struct.cpp
// Function: reviser::javascript::JavaScriptStruct::Generate[abi:cxx11]()
string JavaScriptStruct::Generate() {
    string indent = JavaScriptCommon::Indent(node->level);
    string indent_next = JavaScriptCommon::Indent(node->level + 1);

    vector<string> properties;
    string code = indent + "var " + node->id->text + " = (function() {\n";

    for (vector<Struct::ContentStore>::iterator it = begin(node->contents);
      it != end(node->contents); it++) {
      const string new_line = next(it) == end(node->contents) ? "\n" : "\n\n";

      switch ((*it).type) {
        case DeclareProperty: {
          JavaScriptStructProperty g(node->properties.at((*it).index), this);
          properties.push_back(g.Generate() + new_line);
          break;
        }

        case DeclareStruct: {
          JavaScriptStruct g(node->structs.at((*it).index), this);
          code += g.Generate() + new_line;
          break;
        }

        case DeclareEnum: {
          JavaScriptEnum g(node->enums.at((*it).index), this);
          code += g.Generate() + new_line;
          break;
        }

        default:
          break;
      }
    }

    code += indent_next + "class " + node->id->text + " extends Reviser {\n";
    for (string p: properties) {
      code = code + p;
    }
    code += indent_next + "}\n";
    code += indent_next + "return " + node->id->text + ";\n"; 

    return code + indent + "})();" + "\n\n";
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x3f8(%rbp)
movq %rdi, %rax
movq %rax, -0x3f0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3e8(%rbp)
movq 0x20(%rax), %rax
movl 0x98(%rax), %esi
leaq -0x30(%rbp), %rdi
callq 0xeb9c0
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
movl 0x98(%rax), %esi
incl %esi
leaq -0x50(%rbp), %rdi
callq 0xeb9c0
jmp 0xf4210
leaq -0x78(%rbp), %rdi
callq 0xa0c50
leaq 0xc7f2(%rip), %rdx      # 0x100a12
leaq -0xd8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xaaee0
jmp 0xf4232
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x30(%rax), %rdx
addq $0x8, %rdx
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa1070
jmp 0xf425a
leaq 0xc97c(%rip), %rdx      # 0x100bdd
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xa10c0
jmp 0xf4276
leaq -0xb8(%rbp), %rdi
callq 0x992c0
leaq -0xd8(%rbp), %rdi
callq 0x992c0
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rdi
subq $-0x80, %rdi
callq 0xf6460
movq %rax, -0x400(%rbp)
jmp 0xf42ab
movq -0x400(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rdi
subq $-0x80, %rdi
callq 0xf64d0
movq %rax, -0x408(%rbp)
jmp 0xf42d6
movq -0x408(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xf6490
testb $0x1, %al
jne 0xf4300
jmp 0xf4825
movq -0xe0(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0xf6540
movq %rax, -0x410(%rbp)
jmp 0xf4328
movq -0x3e8(%rbp), %rax
movq -0x410(%rbp), %rcx
movq %rcx, -0x110(%rbp)
movq 0x20(%rax), %rdi
subq $-0x80, %rdi
callq 0xf64d0
movq %rax, -0x418(%rbp)
jmp 0xf4353
movq -0x418(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xf6500
movb %al, %dl
leaq 0xc831(%rip), %rcx      # 0x100bae
leaq 0xc829(%rip), %rax      # 0x100bad
testb %dl, %dl
cmovneq %rcx, %rax
movq %rax, -0x428(%rbp)
leaq -0x121(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x99850
movq -0x428(%rbp), %rsi
movq -0x420(%rbp), %rdx
leaq -0x108(%rbp), %rdi
callq 0x99640
jmp 0xf43c0
leaq -0x121(%rbp), %rdi
callq 0x994f0
leaq -0xe0(%rbp), %rdi
callq 0xf6570
movl (%rax), %eax
movl %eax, -0x42c(%rbp)
testl %eax, %eax
je 0xf4496
jmp 0xf43ea
movl -0x42c(%rbp), %eax
subl $0x1, %eax
je 0xf45be
jmp 0xf43fb
movl -0x42c(%rbp), %eax
subl $0x2, %eax
je 0xf46d8
jmp 0xf47ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4c16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4c04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4457
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x992c0
leaq -0xd8(%rbp), %rdi
callq 0x992c0
jmp 0xf4c04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x121(%rbp), %rdi
callq 0x994f0
jmp 0xf4bf8
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x38, %rax
movq %rax, -0x440(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xf6570
movq -0x440(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0xf6590
movq %rax, -0x438(%rbp)
jmp 0xf44d1
movq -0x3e8(%rbp), %rdx
movq -0x438(%rbp), %rax
movq (%rax), %rsi
leaq -0x150(%rbp), %rdi
callq 0xf6130
jmp 0xf44f0
leaq -0x190(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xf4c30
jmp 0xf4505
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0xa1070
jmp 0xf4521
leaq -0x78(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xecae0
jmp 0xf4533
leaq -0x170(%rbp), %rdi
callq 0x992c0
leaq -0x190(%rbp), %rdi
callq 0x992c0
leaq -0x150(%rbp), %rdi
callq 0xf6190
jmp 0xf47ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf45ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf45a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x992c0
leaq -0x190(%rbp), %rdi
callq 0x992c0
leaq -0x150(%rbp), %rdi
callq 0xf6190
jmp 0xf4814
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x50, %rax
movq %rax, -0x450(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xf6570
movq -0x450(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0xb7530
movq %rax, -0x448(%rbp)
jmp 0xf45f9
movq -0x3e8(%rbp), %rdx
movq -0x448(%rbp), %rax
movq (%rax), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0xf4140
jmp 0xf4618
leaq -0x1f8(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xf41b0
jmp 0xf462d
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0xa1070
jmp 0xf4649
leaq -0x98(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x995d0
jmp 0xf465e
leaq -0x1d8(%rbp), %rdi
callq 0x992c0
leaq -0x1f8(%rbp), %rdi
callq 0x992c0
leaq -0x1b8(%rbp), %rdi
callq 0xf41a0
jmp 0xf47ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf46c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf46bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x992c0
leaq -0x1f8(%rbp), %rdi
callq 0x992c0
leaq -0x1b8(%rbp), %rdi
callq 0xf41a0
jmp 0xf4814
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
addq $0x68, %rax
movq %rax, -0x460(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xf6570
movq -0x460(%rbp), %rdi
movq 0x8(%rax), %rsi
callq 0xb7570
movq %rax, -0x458(%rbp)
jmp 0xf4713
movq -0x3e8(%rbp), %rdx
movq -0x458(%rbp), %rax
movq (%rax), %rsi
leaq -0x220(%rbp), %rdi
callq 0xeb2f0
jmp 0xf4732
leaq -0x260(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0xeb370
jmp 0xf4747
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0xa1070
jmp 0xf4763
leaq -0x98(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x995d0
jmp 0xf4778
leaq -0x240(%rbp), %rdi
callq 0x992c0
leaq -0x260(%rbp), %rdi
callq 0x992c0
leaq -0x220(%rbp), %rdi
callq 0xeb350
jmp 0xf47ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf47de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf47d2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x992c0
leaq -0x260(%rbp), %rdi
callq 0x992c0
leaq -0x220(%rbp), %rdi
callq 0xeb350
jmp 0xf4814
jmp 0xf47ee
leaq -0x108(%rbp), %rdi
callq 0x992c0
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
callq 0xf65d0
movq %rax, -0x268(%rbp)
jmp 0xf42b9
leaq -0x108(%rbp), %rdi
callq 0x992c0
jmp 0xf4bf8
leaq 0xc539(%rip), %rdx      # 0x100d65
leaq -0x2c8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xaaee0
jmp 0xf483e
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x30(%rax), %rdx
addq $0x8, %rdx
leaq -0x2a8(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0xa1070
jmp 0xf4866
leaq 0xc382(%rip), %rdx      # 0x100bef
leaq -0x288(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
callq 0xa10c0
jmp 0xf4882
leaq -0x98(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x995d0
jmp 0xf4897
leaq -0x288(%rbp), %rdi
callq 0x992c0
leaq -0x2a8(%rbp), %rdi
callq 0x992c0
leaq -0x2c8(%rbp), %rdi
callq 0x992c0
leaq -0x78(%rbp), %rax
movq %rax, -0x2d0(%rbp)
movq -0x2d0(%rbp), %rdi
callq 0xa3540
movq %rax, -0x2d8(%rbp)
movq -0x2d0(%rbp), %rdi
callq 0xa33c0
movq %rax, -0x2e0(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0xafc80
testb $0x1, %al
jne 0xf4908
jmp 0xf49eb
leaq -0x2d8(%rbp), %rdi
callq 0xb3150
movq %rax, %rsi
leaq -0x300(%rbp), %rdi
callq 0x991c0
jmp 0xf4925
leaq -0x320(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x300(%rbp), %rdx
callq 0xc25f0
jmp 0xf4941
leaq -0x98(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x99590
leaq -0x320(%rbp), %rdi
callq 0x992c0
leaq -0x300(%rbp), %rdi
callq 0x992c0
leaq -0x2d8(%rbp), %rdi
callq 0xb3130
jmp 0xf48ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf49bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf49b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x992c0
leaq -0x2a8(%rbp), %rdi
callq 0x992c0
leaq -0x2c8(%rbp), %rdi
callq 0x992c0
jmp 0xf4bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x992c0
jmp 0xf4bf8
leaq 0xc211(%rip), %rdx      # 0x100c03
leaq -0x340(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xaaee0
jmp 0xf4a04
leaq -0x98(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x995d0
jmp 0xf4a19
leaq -0x340(%rbp), %rdi
callq 0x992c0
leaq 0xc1da(%rip), %rdx      # 0x100c06
leaq -0x3a0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xaaee0
jmp 0xf4a3e
movq -0x3e8(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x30(%rax), %rdx
addq $0x8, %rdx
leaq -0x380(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0xa1070
jmp 0xf4a66
leaq 0xc089(%rip), %rdx      # 0x100af6
leaq -0x360(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0xa10c0
jmp 0xf4a82
leaq -0x98(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x995d0
jmp 0xf4a97
leaq -0x360(%rbp), %rdi
callq 0x992c0
leaq -0x380(%rbp), %rdi
callq 0x992c0
leaq -0x3a0(%rbp), %rdi
callq 0x992c0
leaq -0x3e0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xc25f0
jmp 0xf4ad4
leaq 0xc133(%rip), %rdx      # 0x100c0e
leaq -0x3c0(%rbp), %rdi
leaq -0x3e0(%rbp), %rsi
callq 0xa10c0
jmp 0xf4af0
movq -0x3f8(%rbp), %rdi
leaq 0xc0af(%rip), %rdx      # 0x100bad
leaq -0x3c0(%rbp), %rsi
callq 0xa10c0
jmp 0xf4b0c
leaq -0x3c0(%rbp), %rdi
callq 0x992c0
leaq -0x3e0(%rbp), %rdi
callq 0x992c0
leaq -0x98(%rbp), %rdi
callq 0x992c0
leaq -0x78(%rbp), %rdi
callq 0xa0c70
leaq -0x50(%rbp), %rdi
callq 0x992c0
leaq -0x30(%rbp), %rdi
callq 0x992c0
movq -0x3f0(%rbp), %rax
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x992c0
jmp 0xf4bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4bb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4bac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x992c0
leaq -0x380(%rbp), %rdi
callq 0x992c0
leaq -0x3a0(%rbp), %rdi
callq 0x992c0
jmp 0xf4bf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xf4bec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x3c0(%rbp), %rdi
callq 0x992c0
leaq -0x3e0(%rbp), %rdi
callq 0x992c0
leaq -0x98(%rbp), %rdi
callq 0x992c0
leaq -0x78(%rbp), %rdi
callq 0xa0c70
leaq -0x50(%rbp), %rdi
callq 0x992c0
leaq -0x30(%rbp), %rdi
callq 0x992c0
movq -0x58(%rbp), %rdi
callq 0x99840
nopl (%rax,%rax)