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

	// mainly for shebang
	while(m_feeder->comment());
	// import
	while(add(new Import(m_feeder,m_env,&m_scopes))){
		while(m_feeder->blankLine());
	}

	m_env->initTmpdir();

	while(1){
		// comments -> proc or job -> proc or job -> ...

		while(m_feeder->comment());

		bool res = add(new DefProc(m_feeder,m_env,&m_scopes))
			|| add(new Job(m_feeder,m_env,&m_scopes));

		if(!res)
			break;
	
		while(m_feeder->blankLine());
	}
	m_feeder->getPos(&m_end_line, &m_end_char);

	if(!m_feeder->atEnd()){
		m_error_msg = "Unknown token";
		m_exit_status = 7;
		throw this;
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdx
movq %rdx, -0x30(%rbp)
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x30, %rsi
addq $0x34, %rdx
callq 0x17610
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x17510
testb $0x1, %al
jne 0x1b0ab
jmp 0x1b0ad
jmp 0x1b098
jmp 0x1b0af
movl $0xc8, %edi
callq 0x6420
movq -0x30(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0x18240
jmp 0x1b0da
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xb860
testb $0x1, %al
jne 0x1b0ed
jmp 0x1b125
jmp 0x1b0ef
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x16800
testb $0x1, %al
jne 0x1b102
jmp 0x1b123
jmp 0x1b0ef
movq -0x38(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0xc8, %esi
callq 0x6430
jmp 0x1b2bf
jmp 0x1b0af
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xe210
jmp 0x1b134
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x17510
testb $0x1, %al
jne 0x1b147
jmp 0x1b149
jmp 0x1b134
movl $0xc8, %edi
callq 0x6420
movq -0x30(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
movb $0x0, -0x21(%rbp)
callq 0xa810
jmp 0x1b178
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xb860
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0x41(%rbp)
jne 0x1b1d4
movl $0xd0, %edi
callq 0x6420
movq -0x30(%rbp), %rcx
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movq %rdi, -0x20(%rbp)
movb $0x1, -0x21(%rbp)
movq 0x8(%rcx), %rsi
movq 0x10(%rcx), %rdx
addq $0x48, %rcx
callq 0x18c40
jmp 0x1b1c4
movq -0x50(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xb860
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movb %al, -0x15(%rbp)
testb $0x1, -0x15(%rbp)
jne 0x1b22a
jmp 0x1b246
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
movl $0xc8, %esi
callq 0x6430
jmp 0x1b2bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x1b217
jmp 0x1b225
movq -0x20(%rbp), %rdi
movl $0xd0, %esi
callq 0x6430
jmp 0x1b2bf
jmp 0x1b22c
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x16800
testb $0x1, %al
jne 0x1b23f
jmp 0x1b241
jmp 0x1b22c
jmp 0x1b132
movq -0x30(%rbp), %rdx
movq 0x8(%rdx), %rdi
movq %rdx, %rsi
addq $0x38, %rsi
addq $0x3c, %rdx
callq 0x17610
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x174c0
testb $0x1, %al
jne 0x1b2b5
movq -0x30(%rbp), %rdi
addq $0x60, %rdi
leaq 0x251c(%rip), %rsi      # 0x1d79a
callq 0x6580
movq -0x30(%rbp), %rax
movl $0x7, 0x80(%rax)
movl $0x8, %edi
callq 0x6200
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq %rax, (%rdi)
leaq 0xd9a4(%rip), %rsi      # 0x28c50
xorl %eax, %eax
movl %eax, %edx
callq 0x66d0
movb $0x1, %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
movq -0x10(%rbp), %rdi
callq 0x6700
nopl (%rax,%rax)