// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdx, -0x98(%rbp)
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl -0x4(%rbp), %edi
callq 0xda80
cmpl $0x2, %eax
jne 0xd3f0
movq -0x98(%rbp), %rsi
movq 0x18c4a(%rip), %rdi     # 0x25fc8
callq 0x3260
movq %rax, %rdi
movq 0x18c23(%rip), %rsi     # 0x25fb0
callq 0x32b0
movq 0x18c2f(%rip), %rdi     # 0x25fc8
leaq 0x11918(%rip), %rsi     # 0x1ecb8
callq 0x3280
movq %rax, %rdi
movslq -0x4(%rbp), %rax
leaq 0xb8d85(%rip), %rsi     # 0xc6138
addq $0x8, %rsi
imulq $0xa8, %rax, %rax
addq %rax, %rsi
addq $0x80, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x118f1(%rip), %rsi     # 0x1ecc8
callq 0x3280
movq %rax, %rdi
movq 0x18bca(%rip), %rsi     # 0x25fb0
callq 0x32b0
jmp 0xd586
leaq -0x68(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x14ef0
movq -0xa0(%rbp), %rdi
movslq -0x4(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb8d1f(%rip), %rax     # 0xc6138
leaq 0x88(%rax,%rcx), %rsi
callq 0x3030
jmp 0xd428
movl -0x8(%rbp), %eax
movl %eax, -0x48(%rbp)
movl 0xb2568(%rip), %eax     # 0xbf99c
movl %eax, -0x44(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0xb8cf6(%rip), %rax     # 0xc6138
addq $0x8, %rax
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0xa4(%rax), %eax
movl %eax, -0x40(%rbp)
cmpl $0x1, 0xb2538(%rip)     # 0xbf998
jne 0xd48f
movl $0x1, -0x20(%rbp)
movl $0x0, 0xb2529(%rip)     # 0xbf99c
jmp 0xd48f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x14f90
jmp 0xd58f
leaq 0xb24b2(%rip), %rdi     # 0xbf948
callq 0x14b00
movq %rax, -0x80(%rbp)
leaq 0xb24a2(%rip), %rdi     # 0xbf948
callq 0x14b70
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x14b30
testb $0x1, %al
jne 0xd4cb
jmp 0xd57d
leaq -0x80(%rbp), %rdi
callq 0x14ba0
movq -0x98(%rbp), %rsi
movq %rax, %rdi
addq $0x30, %rdi
callq 0xc840
testb $0x1, %al
jne 0xd4ed
jmp 0xd531
cmpl $0x0, -0x14(%rbp)
jne 0xd50c
leaq -0x80(%rbp), %rdi
callq 0x14ba0
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x14f20
jmp 0xd50a
jmp 0xd50c
cmpl $0x1, -0x14(%rbp)
jne 0xd52f
leaq -0x80(%rbp), %rdi
callq 0x14ba0
movq %rax, %rdi
addq $0x18, %rdi
leaq -0x68(%rbp), %rsi
callq 0x14f20
jmp 0xd52d
jmp 0xd52f
jmp 0xd57d
movq 0x18a90(%rip), %rdi     # 0x25fc8
leaq 0x11372(%rip), %rsi     # 0x1e8b1
callq 0x3280
movq %rax, -0xa8(%rbp)
jmp 0xd54d
movq -0xa8(%rbp), %rdi
movq 0x18a55(%rip), %rsi     # 0x25fb0
callq 0x32b0
jmp 0xd562
jmp 0xd564
jmp 0xd566
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x14bc0
movq %rax, -0x90(%rbp)
jmp 0xd49f
leaq -0x68(%rbp), %rdi
callq 0x14f90
addq $0xb0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3450
nopl (%rax,%rax)