// File: ryuichiueda[P]GlueLang/src/Job.cc
// Function: Job::parse()
bool Job::parse(void)
{
	m_feeder->getPos(&m_start_line, &m_start_char);

	// scanning of file name 
	// If `file <filename> =` is found, 
	// the DefFile object is pushed as the first element of m_nodes.
	// This node is also given to the last command line.
	if(add(new DefFile(m_feeder,m_env,&m_scopes))){
		m_outfile = (DefFile *)m_nodes[0];	
		m_nodes.pop_back();
	}else if(add(new DefStr(m_feeder,m_env,&m_scopes))){
		m_outstr = (DefStr *)m_nodes[0];	
		m_nodes.pop_back();
	}

	setJobId(m_env->publishJobId());
	int comnum = 0;
	while(1){
		if(add(new Pipeline(m_feeder,m_env,&m_scopes)))
			comnum++;
		else
			break;

		m_feeder->getPos(&m_end_line, &m_end_char);
		m_feeder->blank();

		size_t num = m_nodes.size();
		Pipeline *back1 = (Pipeline *)m_nodes.back();
		Pipeline *back2 = num >= 2 ? (Pipeline *)m_nodes[num-2] : NULL;

		back1->m_is_then = back2 != NULL and back2->m_has_then;

		if(m_feeder->str(">>")){
			back1->m_has_and = true;
			if(back2 != NULL and back2->m_has_then){
				m_feeder->getPos(&m_end_line, &m_end_char);
				m_error_msg = "Invalid connection (>> is connected after ?>)";
				m_exit_status = 6;
				throw this;
			}
		}else if(m_feeder->str("?>")){
			back1->m_has_then = true;
		}else if(m_feeder->str("!>")){
			if(back2 != NULL and back2->m_has_then)
				back2->m_has_or = true;
			else
				back1->m_has_or = true;
		}else{
			m_feeder->setPos(m_end_line, m_end_char);
			break;
		}
	}

	if(comnum < 1){
		m_feeder->setPos(m_start_line,m_start_char);
		return false;
	}

	// whether background proc or not
	if(m_feeder->str("&")){
		m_is_background = true;
		if(! m_feeder->variable(&m_job_name)){
			m_error_msg = "no job name";
			m_exit_status = 2;
			throw this;
		}

		DataJob *d = new DataJob();
		d->setData(&m_job_name);

		try{
			m_env->setData(0,&m_job_name,d);
		}catch(Environment *e){
			m_error_msg = e->m_error_msg;	
			m_exit_status = 2;
			throw this;
		}
	}

	if(add(new Where(m_feeder,m_env,&m_scopes))){
		m_where = (Where *)m_nodes.back();
		m_nodes.pop_back();

	}
	if(m_outstr != NULL)	m_outstr->setJobId(m_job_id);
	if(m_outfile != NULL)	m_outfile->setJobId(m_job_id);
	if(m_where != NULL)	m_where->setJobId(m_job_id);

	m_feeder->getPos(&m_end_line, &m_end_char);
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdx
movq %rdx, -0xf8(%rbp)
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x30, %rsi
addq $0x34, %rdx
callq 0x17610
movl $0x90, %edi
callq 0x6420
movq -0xf8(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf0(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0x9c80
jmp 0x18ddf
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0xb860
testb $0x1, %al
jne 0x18df8
jmp 0x18e4d
movq -0xf8(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x14640
movq -0xf8(%rbp), %rdi
movq (%rax), %rax
movq %rax, 0xc0(%rdi)
addq $0x18, %rdi
callq 0x19b70
jmp 0x18eeb
movq -0xf0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x90, %esi
callq 0x6430
jmp 0x1971e
movl $0xb0, %edi
callq 0x6420
movq -0xf8(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x100(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0xadf0
jmp 0x18e7e
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0xb860
testb $0x1, %al
jne 0x18e97
jmp 0x18ee9
movq -0xf8(%rbp), %rdi
addq $0x18, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x14640
movq -0xf8(%rbp), %rdi
movq (%rax), %rax
movq %rax, 0xc8(%rdi)
addq $0x18, %rdi
callq 0x19b70
jmp 0x18ee9
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0xb0, %esi
callq 0x6430
jmp 0x1971e
jmp 0x18eeb
movq -0xf8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xf3c0
movq -0xf8(%rbp), %rdi
movl %eax, %esi
movq (%rdi), %rax
callq *0x30(%rax)
movl $0x0, -0x20(%rbp)
movl $0xa8, %edi
callq 0x6420
movq -0xf8(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x108(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0x19ed0
jmp 0x18f42
movq -0x108(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0xb860
testb $0x1, %al
jne 0x18f5b
jmp 0x18f88
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x18f8d
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0xa8, %esi
callq 0x6430
jmp 0x1971e
jmp 0x19352
movq -0xf8(%rbp), %rdx
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x3c, %rdx
callq 0x17610
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x164a0
movq -0xf8(%rbp), %rdi
addq $0x18, %rdi
callq 0xd900
movq -0xf8(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x18, %rdi
callq 0x19ba0
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x2, -0x28(%rbp)
jb 0x1900e
movq -0xf8(%rbp), %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
subq $0x2, %rsi
callq 0x14640
movq (%rax), %rax
movq %rax, -0x110(%rbp)
jmp 0x19019
xorl %eax, %eax
movq %rax, -0x110(%rbp)
jmp 0x19019
movq -0x110(%rbp), %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x38(%rbp)
movb %al, -0x111(%rbp)
je 0x19043
movq -0x38(%rbp), %rax
movb 0x86(%rax), %al
movb %al, -0x111(%rbp)
movq -0xf8(%rbp), %rax
movb -0x111(%rbp), %dl
movq -0x30(%rbp), %rcx
andb $0x1, %dl
movb %dl, 0x88(%rcx)
movq 0x8(%rax), %rax
movq %rax, -0x128(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x6710
movq -0x120(%rbp), %rdx
leaq 0x45d8(%rip), %rsi      # 0x1d65e
leaq -0x58(%rbp), %rdi
callq 0x7940
jmp 0x19091
movq -0x128(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x17750
movb %al, -0x129(%rbp)
jmp 0x190a9
leaq -0x58(%rbp), %rdi
callq 0x6280
leaq -0x59(%rbp), %rdi
callq 0x6480
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0x190ca
jmp 0x19191
movq -0x30(%rbp), %rax
movb $0x1, 0x85(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x1918c
movq -0x38(%rbp), %rax
testb $0x1, 0x86(%rax)
je 0x1918c
movq -0xf8(%rbp), %rdx
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x3c, %rdx
callq 0x17610
movq -0xf8(%rbp), %rdi
addq $0x60, %rdi
leaq 0x4543(%rip), %rsi      # 0x1d661
callq 0x6580
movq -0xf8(%rbp), %rax
movl $0x6, 0x80(%rax)
movl $0x8, %edi
callq 0x6200
movq %rax, %rdi
movq -0xf8(%rbp), %rax
movq %rax, (%rdi)
leaq 0xf946(%rip), %rsi      # 0x28a98
xorl %eax, %eax
movl %eax, %edx
callq 0x66d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1917e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6280
leaq -0x59(%rbp), %rdi
callq 0x6480
jmp 0x1971e
jmp 0x1934d
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x140(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x6710
movq -0x138(%rbp), %rdx
leaq 0x44cb(%rip), %rsi      # 0x1d68f
leaq -0x80(%rbp), %rdi
callq 0x7940
jmp 0x191cf
movq -0x140(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x17750
movb %al, -0x141(%rbp)
jmp 0x191e7
leaq -0x80(%rbp), %rdi
callq 0x6280
leaq -0x81(%rbp), %rdi
callq 0x6480
movb -0x141(%rbp), %al
testb $0x1, %al
jne 0x19208
jmp 0x1924c
movq -0x30(%rbp), %rax
movb $0x1, 0x86(%rax)
jmp 0x1934b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x1923b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x6280
leaq -0x81(%rbp), %rdi
callq 0x6480
jmp 0x1971e
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x158(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x6710
movq -0x150(%rbp), %rdx
leaq 0x4413(%rip), %rsi      # 0x1d692
leaq -0xa8(%rbp), %rdi
callq 0x7940
jmp 0x1928d
movq -0x158(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x17750
movb %al, -0x159(%rbp)
jmp 0x192a8
leaq -0xa8(%rbp), %rdi
callq 0x6280
leaq -0xa9(%rbp), %rdi
callq 0x6480
movb -0x159(%rbp), %al
testb $0x1, %al
jne 0x192cc
jmp 0x19331
cmpq $0x0, -0x38(%rbp)
je 0x19324
movq -0x38(%rbp), %rax
testb $0x1, 0x86(%rax)
je 0x19324
movq -0x38(%rbp), %rax
movb $0x1, 0x87(%rax)
jmp 0x1932f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x19313
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x6280
leaq -0xa9(%rbp), %rdi
callq 0x6480
jmp 0x1971e
movq -0x30(%rbp), %rax
movb $0x1, 0x87(%rax)
jmp 0x19349
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rdi
movl 0x38(%rax), %esi
movl 0x3c(%rax), %edx
callq 0x16c90
jmp 0x19352
jmp 0x1934b
jmp 0x1934d
jmp 0x18f11
cmpl $0x1, -0x20(%rbp)
jge 0x19377
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rdi
movl 0x30(%rax), %esi
movl 0x34(%rax), %edx
callq 0x16c90
movb $0x0, -0x1(%rbp)
jmp 0x19710
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x170(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x6710
movq -0x168(%rbp), %rdx
leaq 0x42eb(%rip), %rsi      # 0x1d695
leaq -0xd0(%rbp), %rdi
callq 0x7940
jmp 0x193b8
movq -0x170(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x17750
movb %al, -0x171(%rbp)
jmp 0x193d3
leaq -0xd0(%rbp), %rdi
callq 0x6280
leaq -0xd1(%rbp), %rdi
callq 0x6480
movb -0x171(%rbp), %al
testb $0x1, %al
jne 0x193fa
jmp 0x195e1
movq -0xf8(%rbp), %rsi
movb $0x1, 0xb8(%rsi)
movq 0x8(%rsi), %rdi
addq $0x98, %rsi
callq 0x16a90
testb $0x1, %al
jne 0x194a6
movq -0xf8(%rbp), %rdi
addq $0x60, %rdi
leaq 0x4265(%rip), %rsi      # 0x1d697
callq 0x6580
movq -0xf8(%rbp), %rax
movl $0x2, 0x80(%rax)
movl $0x8, %edi
callq 0x6200
movq %rax, %rdi
movq -0xf8(%rbp), %rax
movq %rax, (%rdi)
leaq 0xf632(%rip), %rsi      # 0x28a98
xorl %eax, %eax
movl %eax, %edx
callq 0x66d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x19495
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x6280
leaq -0xd1(%rbp), %rdi
callq 0x6480
jmp 0x1971e
movl $0x50, %edi
callq 0x6420
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x180(%rbp)
callq 0x9650
jmp 0x194c4
movq -0xf8(%rbp), %rsi
movq -0x180(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rdi
addq $0x98, %rsi
movq %rsi, -0x188(%rbp)
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0xf8(%rbp), %rax
movq -0x188(%rbp), %rdx
movq 0x10(%rax), %rdi
movq -0xe0(%rbp), %rcx
xorl %esi, %esi
callq 0xf250
jmp 0x19519
jmp 0x195df
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x50, %esi
callq 0x6430
jmp 0x1971e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x1971e
movq -0x18(%rbp), %rdi
callq 0x6180
movq -0xf8(%rbp), %rdi
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rsi
addq $0xa0, %rsi
addq $0x60, %rdi
callq 0x6070
jmp 0x1958c
movq -0xf8(%rbp), %rax
movl $0x2, 0x80(%rax)
movl $0x8, %edi
callq 0x6200
movq %rax, %rdi
movq -0xf8(%rbp), %rax
movq %rax, (%rdi)
leaq 0xf4dd(%rip), %rsi      # 0x28a98
xorl %eax, %eax
movl %eax, %edx
callq 0x66d0
jmp 0x19727
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
callq 0x6690
jmp 0x1971e
jmp 0x195e1
movl $0x90, %edi
callq 0x6420
movq -0xf8(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x190(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0x1b800
jmp 0x19612
movq -0x190(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0xb860
testb $0x1, %al
jne 0x1962b
jmp 0x19679
movq -0xf8(%rbp), %rdi
addq $0x18, %rdi
callq 0x19ba0
movq -0xf8(%rbp), %rdi
movq (%rax), %rax
movq %rax, 0x88(%rdi)
addq $0x18, %rdi
callq 0x19b70
jmp 0x19679
movq -0x190(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x90, %esi
callq 0x6430
jmp 0x1971e
movq -0xf8(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x196a1
movq -0xf8(%rbp), %rax
movq 0xc8(%rax), %rdi
movl 0x40(%rax), %esi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0xf8(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
je 0x196c9
movq -0xf8(%rbp), %rax
movq 0xc0(%rax), %rdi
movl 0x40(%rax), %esi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0xf8(%rbp), %rax
cmpq $0x0, 0x88(%rax)
je 0x196f1
movq -0xf8(%rbp), %rax
movq 0x88(%rax), %rdi
movl 0x40(%rax), %esi
movq (%rdi), %rax
callq *0x30(%rax)
movq -0xf8(%rbp), %rdx
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x3c, %rdx
callq 0x17610
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x6700
nopw (%rax,%rax)