// File: /workspace/github_c_makefile_star2_O1/adamjedlicka[P]blu/src/vm/compiler/compiler.c
// Function: caret
static void caret(bluCompiler* compiler, bool canAssign) {
	if (compiler->classCompiler == NULL) {
		error(compiler, "Cannot use '^' outside of a class.");
	} else if (!compiler->classCompiler->hasSuperclass) {
		// TODO : Every class will have superclass 'Object'
		error(compiler, "Cannot use '^' in a class with no superclass.");
	}

	if (match(compiler, TOKEN_LEFT_PAREN)) {
		namedVariable(compiler, syntheticToken(compiler, "@"), false);

		uint8_t argCount = argumentList(compiler);

		pushSuperclass(compiler);
		emitBytes(compiler, OP_SUPER, argCount);
		emitShort(compiler, makeConstant(compiler, OBJ_VAL(bluCopyString(compiler->vm, "__init", 6))));
		return;
	}

	consume(compiler, TOKEN_IDENTIFIER, "Expect superclass method name.");
	uint8_t name = identifierConstant(compiler, &compiler->parser->previous);

	// Push the receiver.
	namedVariable(compiler, syntheticToken(compiler, "@"), false);

	if (match(compiler, TOKEN_LEFT_PAREN)) {
		uint8_t argCount = argumentList(compiler);

		pushSuperclass(compiler);
		emitBytes(compiler, OP_SUPER, argCount);
		emitShort(compiler, name);
	} else {
		pushSuperclass(compiler);
		emitByte(compiler, OP_GET_SUPER);
		emitShort(compiler, name);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rax
testq %rax, %rax
je 0x4d51
cmpb $0x0, 0x28(%rax)
jne 0x4d68
leaq 0x5787(%rip), %rdx      # 0xa4d6
jmp 0x4d58
leaq 0x575b(%rip), %rdx      # 0xa4b3
movq 0x8(%rbx), %rsi
addq $0x20, %rsi
movq %rbx, %rdi
callq 0x5b1c
movq 0x8(%rbx), %rax
cmpl $0x7, 0x40(%rax)
jne 0x4e25
movq %rbx, %rdi
callq 0x553e
leaq 0x577f(%rip), %rax      # 0xa504
movq %rax, 0x68(%rsp)
movb $0x1, 0x70(%rsp)
movups 0x60(%rsp), %xmm0
movups 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b35
movq %rbx, %rdi
callq 0x5c05
movl %eax, %ebp
cmpq $0x0, 0x18(%rbx)
je 0x4deb
leaq 0x5965(%rip), %rax      # 0xa729
movq %rax, 0x28(%rsp)
movb $0x1, 0x30(%rsp)
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b35
movzbl %bpl, %edx
movq %rbx, %rdi
movl $0x14, %esi
callq 0x5c75
movq (%rbx), %rdi
leaq 0x539a(%rip), %rsi      # 0xa1a0
movl $0x6, %edx
callq 0x8411
movq %rbx, %rdi
movl $0x3, %esi
movq %rax, %rdx
callq 0x5cf9
jmp 0x4f47
leaq 0x56da(%rip), %rdx      # 0xa506
movq %rbx, %rdi
movl $0x19, %esi
callq 0x5d2c
movq (%rbx), %rdi
movq 0x8(%rbx), %rax
movq 0x28(%rax), %rsi
movzbl 0x30(%rax), %edx
callq 0x8411
movq %rbx, %rdi
movl $0x3, %esi
movq %rax, %rdx
callq 0x5cf9
movl %eax, %ebp
leaq 0x569e(%rip), %rax      # 0xa504
movq %rax, 0x48(%rsp)
movb $0x1, 0x50(%rsp)
movups 0x40(%rsp), %xmm0
movups 0x50(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b35
movq 0x8(%rbx), %rax
cmpl $0x7, 0x40(%rax)
jne 0x4ef2
movq %rbx, %rdi
callq 0x553e
movq %rbx, %rdi
callq 0x5c05
movl %eax, %r14d
cmpq $0x0, 0x18(%rbx)
je 0x4edf
leaq 0x5871(%rip), %rax      # 0xa729
movq %rax, 0x28(%rsp)
movb $0x1, 0x30(%rsp)
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b35
movzbl %r14b, %edx
movq %rbx, %rdi
movl $0x14, %esi
callq 0x5c75
jmp 0x4f43
cmpq $0x0, 0x18(%rbx)
je 0x4f27
leaq 0x5829(%rip), %rax      # 0xa729
movq %rax, 0x28(%rsp)
movb $0x1, 0x30(%rsp)
movups 0x20(%rsp), %xmm0
movups 0x30(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5b35
movq 0x8(%rbx), %rax
movq 0x28(%rbx), %rdi
addq $0x28, %rdi
movl 0x54(%rax), %edx
movl 0x58(%rax), %ecx
movl $0xf, %esi
callq 0x4b23
movzbl %bpl, %eax
movzwl %ax, %esi
movq %rbx, %rdi
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x5cb5