// File: /workspace/github_cpp_makefile_star2_O1/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 0x8367
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x11d24(%rip), %rbx     # 0x19fd0
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 0xc995(%rip), %rsi      # 0x14c7a
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2280
movslq %ebp, %rax
imulq $0xa8, %rax, %rax
leaq 0xb1dc5(%rip), %rcx     # 0xba0c8
movq 0x88(%rcx,%rax), %rsi
movq 0x90(%rcx,%rax), %rdx
movq %rbx, %rdi
callq 0x2280
movq %rax, %rbx
leaq 0xc965(%rip), %rsi      # 0x14c8a
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 0xb1d2f(%rip), %r13     # 0xba0c8
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 0xab56b(%rip), %ecx     # 0xb392c
movl %ecx, 0x2c(%rsp)
movl 0xa4(%rax), %eax
movl %eax, 0x30(%rsp)
cmpl $0x1, 0xab552(%rip)     # 0xb3928
jne 0x83ea
movl $0x1, 0x50(%rsp)
movl $0x0, 0xab542(%rip)     # 0xb392c
movq 0xab4e7(%rip), %r15     # 0xb38d8
cmpq 0xab4e8(%rip), %r15     # 0xb38e0
je 0x84a5
movq 0x11bcb(%rip), %r12     # 0x19fd0
leaq 0xc50b(%rip), %r13      # 0x14917
movq 0x38(%r15), %rdx
cmpq 0x8(%r14), %rdx
jne 0x842b
testq %rdx, %rdx
je 0x8472
movq (%r14), %rsi
movq 0x30(%r15), %rdi
callq 0x2240
testl %eax, %eax
je 0x8472
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 0xab472(%rip), %r15     # 0xb38e0
jne 0x840c
jmp 0x84a5
cmpl $0x1, 0x4(%rsp)
je 0x8494
cmpl $0x0, 0x4(%rsp)
jne 0x84a5
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xf83e
cmpl $0x1, 0x4(%rsp)
jne 0x84a5
addq $0x18, %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xf83e
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x84bc
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x84d3
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 0x84e6
jmp 0x84e6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xf868
movq %rbx, %rdi
callq 0x23a0