// File: menhits[P]phplus/src/ErrorHandler.cpp
// Function: ErrorHandler::log(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ErrorPriority, std::shared_ptr<TokenData>)
void ErrorHandler::log(string msg, ErrorPriority priority, Token token)
{
	if (priority==SOURCE_ERROR || priority==INTERNAL_ERROR || priority==RUNTIME_ERROR)
		errorHasBeenLogged=true;
	
	// gcc style
	//if (token)
	//	cout << token->getFile() << ":" << token->getLine() << ":" << token->getCharPos() << ": ";
	
	//cout << priorityToStr(priority) << ": " << msg << endl;
	
	// Phplus style
	
	cout << priorityToStr(priority);
	
	if (token)
	{
		cout << " di '" << token->getFile()->getFilename() << "' pada baris ke " << token->getLine() << ":" << endl;
		cout << indentString(msg, "    ") << endl;
		
		string line=token->getFile()->getLine(token->getLine());
		
		int wspace=0;
		for (; wspace<int(line.size()) && (line[wspace]==' ' || line[wspace]=='\t' || line[wspace]=='\n'); wspace++) {}
		
		string arrows="";
		for (int i=0; i<token->getCharPos()-1-wspace; i++)
			arrows+=" ";
		for (int i=0; i<int(token->getText().size()); i++)
			arrows+="^";
		
		cout << indentString(""+line.substr(wspace, string::npos)+"\n"+arrows, "    ") << endl;
	}
	else
	{
		cout << ": " << msg << endl;
	}
}

// Assembly:
subq $0x2e8, %rsp            # imm = 0x2E8
movq %rsi, 0xb8(%rsp)
movq %rcx, 0xc0(%rsp)
movq %rdi, 0x2e0(%rsp)
movq %rsi, 0x2d8(%rsp)
movl %edx, 0x2d4(%rsp)
movq %rcx, 0x2c8(%rsp)
movq 0x2e0(%rsp), %rax
movq %rax, 0xc8(%rsp)
cmpl $0x0, 0x2d4(%rsp)
je 0x34cd4
cmpl $0x3, 0x2d4(%rsp)
je 0x34cd4
cmpl $0x4, 0x2d4(%rsp)
jne 0x34cdf
movq 0xc8(%rsp), %rax
movb $0x1, (%rax)
movl 0x2d4(%rsp), %esi
leaq 0x2a8(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x34a30
movq 0xb0(%rsp), %rsi
movq 0xe32a6(%rip), %rdi     # 0x117fb0
callq 0xb340
jmp 0x34d11
leaq 0x2a8(%rsp), %rdi
callq 0xb6e8
movq 0xc0(%rsp), %rdi
callq 0x1c050
testb $0x1, %al
jne 0x34d34
jmp 0x35561
movq 0xe3275(%rip), %rdi     # 0x117fb0
leaq 0x9d443(%rip), %rsi     # 0xd2185
callq 0xb380
movq 0xc0(%rsp), %rdi
movq %rax, 0xa0(%rsp)
callq 0x1bb70
movq %rax, %rsi
leaq 0x268(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x35750
movq 0xa8(%rsp), %rdi
callq 0x35780
movq %rax, %rsi
leaq 0x278(%rsp), %rdi
callq 0x35790
jmp 0x34d93
movq 0xa0(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0xb340
movq %rax, 0x98(%rsp)
jmp 0x34db2
movq 0x98(%rsp), %rdi
leaq 0x9d3ca(%rip), %rsi     # 0xd218b
callq 0xb380
movq %rax, 0x90(%rsp)
jmp 0x34dd0
movq 0xc0(%rsp), %rdi
callq 0x1bb70
movq %rax, %rdi
callq 0x357c0
movl %eax, 0x8c(%rsp)
jmp 0x34dee
movl 0x8c(%rsp), %esi
movq 0x90(%rsp), %rdi
callq 0xb670
movq %rax, 0x80(%rsp)
jmp 0x34e0c
movq 0x80(%rsp), %rdi
leaq 0xa05f3(%rip), %rsi     # 0xd540e
callq 0xb380
movq %rax, 0x78(%rsp)
jmp 0x34e27
movq 0x78(%rsp), %rdi
movq 0xe314d(%rip), %rsi     # 0x117f80
callq 0xb3c0
jmp 0x34e3a
leaq 0x278(%rsp), %rdi
callq 0xb6e8
leaq 0x268(%rsp), %rdi
callq 0x357d0
leaq 0x227(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0xb690
movq 0x70(%rsp), %rdx
leaq 0x9cbf7(%rip), %rsi     # 0xd1a69
leaq 0x228(%rsp), %rdi
callq 0xb4c0
jmp 0x34e81
movq 0xb8(%rsp), %rsi
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rdx
movl $0x1, %ecx
callq 0xa8440
jmp 0x34ea5
movq 0xe3104(%rip), %rdi     # 0x117fb0
leaq 0x248(%rsp), %rsi
callq 0xb340
movq %rax, 0x68(%rsp)
jmp 0x34ec0
movq 0x68(%rsp), %rdi
movq 0xe30b4(%rip), %rsi     # 0x117f80
callq 0xb3c0
jmp 0x34ed3
leaq 0x248(%rsp), %rdi
callq 0xb6e8
leaq 0x228(%rsp), %rdi
callq 0xb6e8
leaq 0x227(%rsp), %rdi
callq 0xb3f0
movq 0xc0(%rsp), %rdi
callq 0x1bb70
movq %rax, %rsi
leaq 0x1f0(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x35750
movq 0x50(%rsp), %rdi
callq 0x35780
movq 0xc0(%rsp), %rdi
movq %rax, 0x58(%rsp)
callq 0x1bb70
movq %rax, %rdi
callq 0x357c0
movl %eax, 0x64(%rsp)
jmp 0x34f46
movl 0x64(%rsp), %edx
movq 0x58(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0x9ba50
jmp 0x34f5e
leaq 0x1f0(%rsp), %rdi
callq 0x357d0
movl $0x0, 0x1ec(%rsp)
movl 0x1ec(%rsp), %eax
movl %eax, 0x48(%rsp)
leaq 0x200(%rsp), %rdi
callq 0xb2a0
movl 0x48(%rsp), %ecx
movl %eax, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0x4f(%rsp)
jge 0x35036
movslq 0x1ec(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x40(%rsp)
jmp 0x34fbe
movq 0x40(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, 0x3f(%rsp)
je 0x3502e
movslq 0x1ec(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x30(%rsp)
jmp 0x34fed
movq 0x30(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, 0x3f(%rsp)
je 0x3502e
movslq 0x1ec(%rsp), %rsi
leaq 0x200(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x28(%rsp)
jmp 0x3501c
movq 0x28(%rsp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
sete %al
movb %al, 0x3f(%rsp)
movb 0x3f(%rsp), %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x35043
jmp 0x35175
jmp 0x35045
movl 0x1ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1ec(%rsp)
jmp 0x34f76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0xb6e8
jmp 0x3559b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x350b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x278(%rsp), %rdi
callq 0xb6e8
leaq 0x268(%rsp), %rdi
callq 0x357d0
jmp 0x3559b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35124
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35117
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x248(%rsp), %rdi
callq 0xb6e8
leaq 0x228(%rsp), %rdi
callq 0xb6e8
leaq 0x227(%rsp), %rdi
callq 0xb3f0
jmp 0x3559b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0x357d0
jmp 0x3559b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35552
leaq 0x1c7(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xb690
movq 0x20(%rsp), %rdx
leaq 0x9c88c(%rip), %rsi     # 0xd1a1f
leaq 0x1c8(%rsp), %rdi
callq 0xb4c0
jmp 0x351a2
leaq 0x1c7(%rsp), %rdi
callq 0xb3f0
movl $0x0, 0x1c0(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x1c0(%rsp), %eax
movl %eax, 0x18(%rsp)
callq 0x1bb70
movq %rax, %rdi
callq 0x357e0
movl %eax, 0x1c(%rsp)
jmp 0x351e0
movl 0x18(%rsp), %eax
movl 0x1c(%rsp), %ecx
subl $0x1, %ecx
subl 0x1ec(%rsp), %ecx
cmpl %ecx, %eax
jge 0x35260
leaq 0x9c86f(%rip), %rsi     # 0xd1a6c
leaq 0x1c8(%rsp), %rdi
callq 0xb360
jmp 0x3520c
jmp 0x3520e
movl 0x1c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c0(%rsp)
jmp 0x351ba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x1c7(%rsp), %rdi
callq 0xb3f0
jmp 0x35552
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35545
movl $0x0, 0x1bc(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x1bc(%rsp), %eax
movl %eax, 0x14(%rsp)
callq 0x1bb70
movq %rax, %rsi
leaq 0x198(%rsp), %rdi
callq 0x1bb80
jmp 0x35295
leaq 0x198(%rsp), %rdi
callq 0xb2a0
movl %eax, 0x10(%rsp)
leaq 0x198(%rsp), %rdi
callq 0xb6e8
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %eax
cmpl %ecx, %eax
jge 0x352ea
leaq 0x9ced6(%rip), %rsi     # 0xd219c
leaq 0x1c8(%rsp), %rdi
callq 0xb360
jmp 0x352d5
jmp 0x352d7
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0x3526b
movslq 0x1ec(%rsp), %rdx
leaq 0xf8(%rsp), %rdi
leaq 0x200(%rsp), %rsi
movq $-0x1, %rcx
callq 0xb3a0
jmp 0x35310
leaq 0x9c708(%rip), %rsi     # 0xd1a1f
leaq 0x118(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x1bcf0
jmp 0x3532e
leaq 0x9cbc3(%rip), %rdx     # 0xd1ef8
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0xfa60
jmp 0x3534c
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
leaq 0x1c8(%rsp), %rdx
callq 0x2e070
jmp 0x3536b
leaq 0xd7(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xb690
movq 0x8(%rsp), %rdx
leaq 0x9c6e0(%rip), %rsi     # 0xd1a69
leaq 0xd8(%rsp), %rdi
callq 0xb4c0
jmp 0x35398
leaq 0x178(%rsp), %rdi
leaq 0x158(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
movl $0x1, %ecx
callq 0xa8440
jmp 0x353bc
movq 0xe2bed(%rip), %rdi     # 0x117fb0
leaq 0x178(%rsp), %rsi
callq 0xb340
movq %rax, (%rsp)
jmp 0x353d6
movq (%rsp), %rdi
movq 0xe2b9f(%rip), %rsi     # 0x117f80
callq 0xb3c0
jmp 0x353e8
leaq 0x178(%rsp), %rdi
callq 0xb6e8
leaq 0xd8(%rsp), %rdi
callq 0xb6e8
leaq 0xd7(%rsp), %rdi
callq 0xb3f0
leaq 0x158(%rsp), %rdi
callq 0xb6e8
leaq 0x138(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
leaq 0x200(%rsp), %rdi
callq 0xb6e8
jmp 0x35593
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35538
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x3552b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x3551e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x35504
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
jmp 0x354f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2a0(%rsp)
movl %eax, 0x29c(%rsp)
leaq 0x178(%rsp), %rdi
callq 0xb6e8
leaq 0xd8(%rsp), %rdi
callq 0xb6e8
leaq 0xd7(%rsp), %rdi
callq 0xb3f0
leaq 0x158(%rsp), %rdi
callq 0xb6e8
leaq 0x138(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
leaq 0x200(%rsp), %rdi
callq 0xb6e8
jmp 0x3559b
movq 0xe2a48(%rip), %rdi     # 0x117fb0
leaq 0xa1f65(%rip), %rsi     # 0xd74d4
callq 0xb380
movq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0xb340
movq %rax, %rdi
movq 0xe29f2(%rip), %rsi     # 0x117f80
callq 0xb3c0
addq $0x2e8, %rsp            # imm = 0x2E8
retq
movq 0x2a0(%rsp), %rdi
callq 0xb680
nopl (%rax,%rax)