// File: zhengwangsun[P]pas2c/semantics.cpp
// Function: identifier_list(int, int, int)
void identifier_list(int type, int k, int useFlag)
{
	TreeNode tNode= tree.node[k];
	TreeNode childNode;
    if(lookahead(k) == 101)//101是id
    {
        int id_position = tree.node[k].child[0];//将id节点在树中的下标值赋给id_position
        if (useFlag == 1)
        {
            //判断放入主符号表还是子符号表
            if(currentTable == "main")
                enterMain(id_position, type);
            else
                enterSub(id_position, type, currentTable, 0);//是子程序内定义的标识符，0代表放入item
        	
        	childNode=tree.node[tNode.child[0]];
            if(isArray==1) //修改 array
            {
                code[currentLine].insert(3, " ");
                code[currentLine++].insert(4, childNode.value.c_str());
                
                identifier_list1(type, tree.node[k].child[1], 1);
                isArray=0;
            }
            else
            {
                code[currentLine].append(childNode.value);
                identifier_list1(type, tree.node[k].child[1], 1);
            }
        }
        else if (useFlag == 2)//parameter
        {
            enterSub(id_position, type, currentTable, 1);//是子程序参数标识符

			childNode=tree.node[tNode.child[0]];
			code[currentLine].append(childNode.value);
            
            identifier_list1(type, tree.node[k].child[1], 2);
        }
        else if (useFlag == 3)
        { 
            if(isDefined(id_position) != 0)
			{
			//查看是否声明，张英哲改动
                int idType = checkIdType(id_position);
            	addReadType(idType);
            	childNode=tree.node[tNode.child[0]];
				code[currentLine].append(childNode.value);
				code[currentLine++].append(");\n ");
                identifier_list1(-1, tree.node[k].child[1], 3);
                
        	}
			else
                cout<<"the id is not defined where identifier_list"<<endl;
        }
    }
    else
        cout<<"identifier_list error!"<<endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movslq -0x8(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb9402(%rip), %rax     # 0xc6138
leaq 0x8(%rax,%rcx), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x14920
leaq -0x160(%rbp), %rdi
callq 0x149d0
movl -0x8(%rbp), %edi
callq 0xca50
movl %eax, -0x1b8(%rbp)
jmp 0xcd63
movl -0x1b8(%rbp), %eax
cmpl $0x65, %eax
jne 0xd1b8
movslq -0x8(%rbp), %rcx
leaq 0xb93bb(%rip), %rax     # 0xc6138
addq $0x8, %rax
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x170(%rbp)
cmpl $0x1, -0xc(%rbp)
jne 0xcf8d
leaq 0xb2bd3(%rip), %rdi     # 0xbf978
leaq 0x1170e(%rip), %rsi     # 0x1e4ba
callq 0xc770
movb %al, -0x1b9(%rbp)
jmp 0xcdb9
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0xcdc5
jmp 0xcdf1
movl -0x170(%rbp), %edi
movl -0x4(%rbp), %esi
callq 0xd230
jmp 0xcdd5
jmp 0xce68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
jmp 0xd20c
movl -0x170(%rbp), %eax
movl %eax, -0x1c4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x1c0(%rbp)
leaq 0xb2b6b(%rip), %rsi     # 0xbf978
leaq -0x190(%rbp), %rdi
callq 0x30e0
jmp 0xce1b
movl -0x1c0(%rbp), %esi
movl -0x1c4(%rbp), %edi
leaq -0x190(%rbp), %rdx
xorl %ecx, %ecx
callq 0xd340
jmp 0xce37
leaq -0x190(%rbp), %rdi
callq 0x34c8
jmp 0xce68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x34c8
jmp 0xd20c
movslq -0xb4(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb92bb(%rip), %rax     # 0xc6138
leaq 0x8(%rax,%rcx), %rsi
leaq -0x160(%rbp), %rdi
callq 0x14a10
jmp 0xce90
cmpl $0x1, 0xb2b01(%rip)     # 0xbf998
jne 0xcf3e
movslq 0xb377c(%rip), %rax     # 0xc0620
shlq $0x5, %rax
leaq 0xb2af1(%rip), %rdi     # 0xbf9a0
addq %rax, %rdi
leaq 0x11642(%rip), %rdx     # 0x1e4fb
movl $0x3, %esi
callq 0x3070
jmp 0xcec5
movslq 0xb3754(%rip), %rcx     # 0xc0620
movl %ecx, %eax
incl %eax
movl %eax, 0xb374a(%rip)     # 0xc0620
shlq $0x5, %rcx
leaq 0xb2abf(%rip), %rax     # 0xbf9a0
addq %rcx, %rax
movq %rax, -0x1d0(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x30d0
movq -0x1d0(%rbp), %rdi
movq %rax, %rdx
movl $0x4, %esi
callq 0x3070
jmp 0xcf0d
movl -0x4(%rbp), %edi
movslq -0x8(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb9216(%rip), %rax     # 0xc6138
movl 0x10(%rax,%rcx), %esi
movl $0x1, %edx
callq 0xd5a0
jmp 0xcf32
movl $0x0, 0xb2a5c(%rip)     # 0xbf998
jmp 0xcf88
movslq 0xb36db(%rip), %rax     # 0xc0620
shlq $0x5, %rax
leaq 0xb2a50(%rip), %rdi     # 0xbf9a0
addq %rax, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x34a0
jmp 0xcf61
movl -0x4(%rbp), %edi
movslq -0x8(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb91c2(%rip), %rax     # 0xc6138
movl 0x10(%rax,%rcx), %esi
movl $0x1, %edx
callq 0xd5a0
jmp 0xcf86
jmp 0xcf88
jmp 0xd1b6
cmpl $0x2, -0xc(%rbp)
jne 0xd084
movl -0x170(%rbp), %eax
movl %eax, -0x1d8(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x1d4(%rbp)
leaq 0xb29c5(%rip), %rsi     # 0xbf978
leaq -0x1b0(%rbp), %rdi
callq 0x30e0
jmp 0xcfc1
movl -0x1d4(%rbp), %esi
movl -0x1d8(%rbp), %edi
leaq -0x1b0(%rbp), %rdx
movl $0x1, %ecx
callq 0xd340
jmp 0xcfe0
leaq -0x1b0(%rbp), %rdi
callq 0x34c8
movslq -0xb4(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb9137(%rip), %rax     # 0xc6138
leaq 0x8(%rax,%rcx), %rsi
leaq -0x160(%rbp), %rdi
callq 0x14a10
jmp 0xd014
movslq 0xb3605(%rip), %rax     # 0xc0620
shlq $0x5, %rax
leaq 0xb297a(%rip), %rdi     # 0xbf9a0
addq %rax, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x34a0
jmp 0xd037
movl -0x4(%rbp), %edi
movslq -0x8(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb90ec(%rip), %rax     # 0xc6138
movl 0x10(%rax,%rcx), %esi
movl $0x2, %edx
callq 0xd5a0
jmp 0xd05c
jmp 0xd1b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x168(%rbp)
movl %eax, -0x16c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x34c8
jmp 0xd20c
cmpl $0x3, -0xc(%rbp)
jne 0xd1b2
movl -0x170(%rbp), %edi
callq 0xda80
movl %eax, -0x1dc(%rbp)
jmp 0xd0a1
movl -0x1dc(%rbp), %eax
cmpl $0x0, %eax
je 0xd17d
movl -0x170(%rbp), %edi
callq 0xe0d0
movl %eax, -0x1e0(%rbp)
jmp 0xd0c3
movl -0x1e0(%rbp), %eax
movl %eax, -0x1b4(%rbp)
movl -0x1b4(%rbp), %edi
callq 0xe5c0
jmp 0xd0dc
movslq -0xb4(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb9047(%rip), %rax     # 0xc6138
leaq 0x8(%rax,%rcx), %rsi
leaq -0x160(%rbp), %rdi
callq 0x14a10
jmp 0xd104
movslq 0xb3515(%rip), %rax     # 0xc0620
shlq $0x5, %rax
leaq 0xb288a(%rip), %rdi     # 0xbf9a0
addq %rax, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x34a0
jmp 0xd127
movslq 0xb34f2(%rip), %rax     # 0xc0620
movl %eax, %ecx
incl %ecx
movl %ecx, 0xb34e8(%rip)     # 0xc0620
shlq $0x5, %rax
leaq 0xb285d(%rip), %rdi     # 0xbf9a0
addq %rax, %rdi
leaq 0x113ab(%rip), %rsi     # 0x1e4f8
callq 0x3490
jmp 0xd154
movslq -0x8(%rbp), %rax
imulq $0xa8, %rax, %rcx
leaq 0xb8fd2(%rip), %rax     # 0xc6138
movl 0x10(%rax,%rcx), %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x3, %edx
callq 0xd5a0
jmp 0xd17b
jmp 0xd1b0
movq 0x18e44(%rip), %rdi     # 0x25fc8
leaq 0x11372(%rip), %rsi     # 0x1e4fd
callq 0x3280
movq %rax, -0x1e8(%rbp)
jmp 0xd199
movq -0x1e8(%rbp), %rdi
movq 0x18e09(%rip), %rsi     # 0x25fb0
callq 0x32b0
jmp 0xd1ae
jmp 0xd1b0
jmp 0xd1b2
jmp 0xd1b4
jmp 0xd1b6
jmp 0xd1eb
movq 0x18e09(%rip), %rdi     # 0x25fc8
leaq 0x11363(%rip), %rsi     # 0x1e529
callq 0x3280
movq %rax, -0x1f0(%rbp)
jmp 0xd1d4
movq -0x1f0(%rbp), %rdi
movq 0x18dce(%rip), %rsi     # 0x25fb0
callq 0x32b0
jmp 0xd1e9
jmp 0xd1eb
leaq -0x160(%rbp), %rdi
callq 0x14a90
leaq -0xb8(%rbp), %rdi
callq 0x14a90
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x160(%rbp), %rdi
callq 0x14a90
leaq -0xb8(%rbp), %rdi
callq 0x14a90
movq -0x168(%rbp), %rdi
callq 0x3450