// File: /workspace/github_cpp_makefile_star2_O2/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 0x6ab8
cmpl $0x2, %eax
jne 0x66ac
movq 0xd98f(%rip), %rbx      # 0x13fd0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x20f0
leaq 0x867f(%rip), %rsi      # 0xecda
movq %rbx, %rdi
callq 0x21d0
movslq %ebp, %rcx
imulq $0xa8, %rcx, %rcx
leaq 0xada24(%rip), %rdx     # 0xb4098
leaq (%rdx,%rcx), %rsi
addq $0x88, %rsi
movq %rax, %rdi
callq 0x21c0
leaq 0x865c(%rip), %rsi      # 0xecea
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
andq $0x0, 0x30(%rax)
movslq %ebp, %rax
imulq $0xa8, %rax, %r12
leaq 0xad9be(%rip), %r13     # 0xb4098
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 0xa71fa(%rip), %ecx     # 0xad8fc
movl %ecx, 0x2c(%rsp)
movl 0xa4(%rax), %eax
movl %eax, 0x30(%rsp)
cmpl $0x1, 0xa71e1(%rip)     # 0xad8f8
jne 0x6728
movl $0x1, 0x50(%rsp)
andl $0x0, 0xa71d4(%rip)     # 0xad8fc
movq 0xa7179(%rip), %r15     # 0xad8a8
movq 0xd89a(%rip), %r12      # 0x13fd0
leaq 0x823a(%rip), %r13      # 0xe977
cmpq 0xa716c(%rip), %r15     # 0xad8b0
je 0x678b
leaq 0x30(%r15), %rdi
movq %r14, %rsi
callq 0x5f9f
testb %al, %al
jne 0x676f
movq %r12, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
addq $0x60, %r15
jmp 0x673d
cmpl $0x1, %ebx
je 0x677a
testl %ebx, %ebx
je 0x677e
jmp 0x678b
addq $0x18, %r15
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0xa692
leaq 0x8(%rsp), %rdi
callq 0xa6be
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x67a8
jmp 0x67a8
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xa6be
movq %rbx, %rdi
callq 0x2330