// File: /workspace/github_cpp_makefile_star2_O3/zhengwangsun[P]pas2c/semantics.cpp
// Function: enterSub(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void enterSub(int position, int type, string currentTable, int flag)//将新id添加到子符号表，flag标志此id填写到哪里，0是item，1是argument
{
    if (isDefined(position) == 2)//如果在子表中已经定义
    {
        cout<<currentTable<<endl;
        cout<<"double defined("<<tree.node[position].value<<") when enterSub"<<endl;
    }
    else
    {
        Tuple newTuple;
        
        newTuple.name = tree.node[position].value;
        newTuple.type = type;
        newTuple.demension = demension;
        newTuple.declareRow = tree.node[position].row;

        if (isArray == 1)
        {
            newTuple.isArray = 1;
            demension = 0;//目前只用在数组判断了
        }
        
        for(vector<subTableItem>::iterator it = subTable.begin(); it != subTable.end();it++)
        {
            if(it->name == currentTable)//找到当前子表
            {
                if (flag == 0)//0代表填入item
                    it->item.push_back(newTuple);
                if (flag == 1)//1代表填入argument
                    it->argument.push_back(newTuple);
                break;
            }
            else
                cout<<"error!"<<endl;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %ecx, %ebx
movq %rdx, %r14
movl %esi, %r15d
movl %edi, %ebp
callq 0x8b17
cmpl $0x2, %eax
jne 0x8363
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x10d28(%rip), %rbx     # 0x18fd0
movq %rbx, %rdi
callq 0x2280
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq 0xb9c9(%rip), %rsi      # 0x13caa
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2280
movslq %ebp, %rax
imulq $0xa8, %rax, %rax
leaq 0xb0dc9(%rip), %rcx     # 0xb90c8
movq 0x88(%rcx,%rax), %rsi
movq 0x90(%rcx,%rax), %rdx
movq %rbx, %rdi
callq 0x2280
movq %rax, %rbx
leaq 0xb999(%rip), %rsi      # 0x13cba
movl $0xf, %edx
movq %rax, %rdi
callq 0x2280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150
movl %ebx, 0x4(%rsp)
leaq 0x18(%rsp), %rbx
movq %rbx, -0x10(%rbx)
xorl %eax, %eax
movq %rax, -0x8(%rbx)
movb $0x0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movq %rax, 0x30(%rbx)
movslq %ebp, %rax
imulq $0xa8, %rax, %r12
leaq 0xb0d33(%rip), %r13     # 0xb90c8
leaq (%r12,%r13), %rsi
addq $0x88, %rsi
leaq 0x8(%rsp), %rdi
callq 0x2110
leaq (%r12,%r13), %rax
addq $0x8, %rax
movl %r15d, 0x28(%rsp)
movl 0xaa56f(%rip), %ecx     # 0xb292c
movl %ecx, 0x2c(%rsp)
movl 0xa4(%rax), %eax
movl %eax, 0x30(%rsp)
cmpl $0x1, 0xaa556(%rip)     # 0xb2928
jne 0x83e6
movl $0x1, 0x50(%rsp)
movl $0x0, 0xaa546(%rip)     # 0xb292c
movq 0xaa4eb(%rip), %r15     # 0xb28d8
cmpq 0xaa4ec(%rip), %r15     # 0xb28e0
je 0x848e
movq 0x10bcf(%rip), %r12     # 0x18fd0
leaq 0xb53f(%rip), %r13      # 0x13947
movq 0x38(%r15), %rdx
cmpq 0x8(%r14), %rdx
jne 0x8427
testq %rdx, %rdx
je 0x846e
movq (%r14), %rsi
movq 0x30(%r15), %rdi
callq 0x2240
testl %eax, %eax
je 0x846e
movl $0x6, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
addq $0x60, %r15
cmpq 0xaa476(%rip), %r15     # 0xb28e0
jne 0x8408
jmp 0x848e
movl 0x4(%rsp), %eax
cmpl $0x1, %eax
je 0x847d
testl %eax, %eax
je 0x8481
jmp 0x848e
addq $0x18, %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xf42c
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x84a5
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x84bc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x84cf
jmp 0x84cf
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xf456
movq %rbx, %rdi
callq 0x23a0