// File: /workspace/github_cpp_makefile_star2_O3/kram[P]kram/./src/vm/value.cpp
// Function: Value::print[abi:cxx11](bool)
std::string Value::print(bool print_type) {
	std::stringstream res;

	if (print_type) {
		std::string i = "UNKNOWN";
		switch (this->type) {
			case Type::NUL: i = "NUL"; break;
			case Type::STRING: i = "STRING"; break;
			case Type::NUMBER: i = "NUMBER"; break;
			case Type::BOOL: i = "BOOL"; break;
			case Type::REFERENCE: i = "REFERENCE"; break;
			case Type::FUNCTION: i = "FUNCTION"; break;
			case Type::CLASS: i = "CLASS"; break;
			case Type::NAME: i = "NAME"; break;
		}

		res << i << "<";
	}

	switch (this->type) {
		case Type::NUL:
			res << "NULL";
			break;

		case Type::STRING:
			res << *this->data.strval;
			break;

		case Type::NUMBER:
			res << std::setprecision (std::numeric_limits<double>::digits10 + 1);
			res << this->data.number;
			break;

		case Type::BOOL:
			if (this->getBool()) {
				res << "true";
			} else {
				res << "false";
			}
			break;

		// We can probably prettify these even further, eg print what a REFERENCE is actually pointing to.
		// But that is for another time.
		case Type::REFERENCE: res << "REFERENCE"; break;
		case Type::FUNCTION: res << "FUNCTION"; break;
		case Type::CLASS: res << "CLASS"; break;
		case Type::NAME: res << "NAME"; break;
	}

	if (print_type) {
		res << ">";
	}

	return res.str();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
callq 0x3190
testl %ebp, %ebp
je 0xd140
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x501a(%rip), %rsi      # 0x120e5
leaq 0x501a(%rip), %rdx      # 0x120ec
movq %rsp, %rdi
callq 0x47d2
movl 0x8(%r14), %eax
cmpq $0x8, %rax
jae 0xd10b
leaq 0x5c89(%rip), %rdx      # 0x12d74
movslq (%rdx,%rax,4), %rcx
addq %rdx, %rcx
leaq 0x5c9f(%rip), %rdx      # 0x12d98
movq (%rdx,%rax,8), %r8
movq %rsp, %rdi
movq 0x8(%rdi), %rdx
xorl %esi, %esi
callq 0x3320
leaq 0x30(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x32a0
leaq 0x522a(%rip), %rsi      # 0x1234f
movl $0x1, %edx
movq %rax, %rdi
callq 0x32a0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xd140
callq 0x3230
movl 0x8(%r14), %eax
cmpq $0x7, %rax
ja 0xd214
leaq 0x5bff(%rip), %rcx      # 0x12d54
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x4, %edx
leaq 0x5e03(%rip), %rsi      # 0x12f6d
jmp 0xd20a
movl $0x9, %edx
leaq 0x5de8(%rip), %rsi      # 0x12f63
jmp 0xd20a
leaq 0x30(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movq $0x10, 0x38(%rsp,%rax)
movsd (%r14), %xmm0
callq 0x3350
jmp 0xd214
xorpd %xmm0, %xmm0
xorl %edx, %edx
ucomisd (%r14), %xmm0
setne %dl
leaq 0x30(%rsp), %rdi
leaq 0x5144(%rip), %rax      # 0x122ff
leaq 0x5142(%rip), %rsi      # 0x12304
cmovneq %rax, %rsi
xorq $0x5, %rdx
jmp 0xd20f
movl $0x4, %edx
leaq 0x606f(%rip), %rsi      # 0x13247
jmp 0xd20a
leaq 0x30(%rsp), %rdi
movq (%r14), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x32a0
jmp 0xd214
movl $0x8, %edx
leaq 0x4f30(%rip), %rsi      # 0x1212c
jmp 0xd20a
movl $0x5, %edx
leaq 0x4f1c(%rip), %rsi      # 0x12126
leaq 0x30(%rsp), %rdi
callq 0x32a0
testb %bpl, %bpl
je 0xd22f
leaq 0x30(%rsp), %rdi
leaq 0x5122(%rip), %rsi      # 0x12347
movl $0x1, %edx
callq 0x32a0
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x3340
movq 0xdd75(%rip), %rsi      # 0x1afb8
leaq 0x20(%rsp), %rdi
callq 0x31b0
leaq 0xa0(%rsp), %rdi
callq 0x30c0
movq %rbx, %rax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0xd280
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xd283
callq 0x3230
jmp 0xd283
movq %rax, %rbx
movq 0xdd2e(%rip), %rsi      # 0x1afb8
leaq 0x20(%rsp), %rdi
callq 0x31b0
leaq 0xa0(%rsp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x33c0
nop