// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileConstant
static sxi32 jx9CompileConstant(jx9_gen_state *pGen)
{
	SySet *pConsCode, *pInstrContainer;
	sxu32 nLine = pGen->pIn->nLine;
	SyString *pName;
	sxi32 rc;
	pGen->pIn++; /* Jump the 'const' keyword */
	if( pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & (JX9_TK_SSTR|JX9_TK_DSTR|JX9_TK_ID|JX9_TK_KEYWORD)) == 0 ){
		/* Invalid constant name */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Invalid constant name");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	/* Peek constant name */
	pName = &pGen->pIn->sData;
	/* Make sure the constant name isn't reserved */
	if( GenStateIsReservedID(pName) ){
		/* Reserved constant */
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Cannot redeclare a reserved constant '%z'", pName);
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	pGen->pIn++;
	if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & JX9_TK_EQUAL /* '=' */) == 0 ){
		/* Invalid statement*/
		rc = jx9GenCompileError(pGen, E_ERROR, nLine, "const: Expected '=' after constant name");
		if( rc == SXERR_ABORT ){
			/* Error count limit reached, abort immediately */
			return SXERR_ABORT;
		}
		goto Synchronize;
	}
	pGen->pIn++; /*Jump the equal sign */
	/* Allocate a new constant value container */
	pConsCode = (SySet *)SyMemBackendPoolAlloc(&pGen->pVm->sAllocator, sizeof(SySet));
	if( pConsCode == 0 ){
		return GenStateOutOfMem(pGen);
	}
	SySetInit(pConsCode, &pGen->pVm->sAllocator, sizeof(VmInstr));
	/* Swap bytecode container */
	pInstrContainer = jx9VmGetByteCodeContainer(pGen->pVm);
	jx9VmSetByteCodeContainer(pGen->pVm, pConsCode);
	/* Compile constant value */
	rc = jx9CompileExpr(&(*pGen), 0, 0);
	/* Emit the done instruction */
	jx9VmEmitInstr(pGen->pVm, JX9_OP_DONE, (rc != SXERR_EMPTY ? 1 : 0), 0, 0, 0);
	jx9VmSetByteCodeContainer(pGen->pVm, pInstrContainer); 
	if( rc == SXERR_ABORT ){
		/* Don't worry about freeing memory, everything will be released shortly */
		return SXERR_ABORT;
	}
	SySetSetUserData(pConsCode, pGen->pVm);
	/* Register the constant */
	rc = jx9VmRegisterConstant(pGen->pVm, pName, jx9VmExpandConstantValue, pConsCode);
	if( rc != SXRET_OK ){
		SySetRelease(pConsCode);
		SyMemBackendPoolFree(&pGen->pVm->sAllocator, pConsCode);
	}
	return SXRET_OK;
Synchronize:
	/* Synchronize with the next-semi-colon and avoid compiling this erroneous statement */
	while(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & JX9_TK_SEMI) == 0 ){
		pGen->pIn++;
	}
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x158(%rdi), %r13
movq 0x160(%rdi), %r12
movl 0x14(%r13), %r15d
leaq 0x20(%r13), %r14
movq %r14, 0x158(%rdi)
cmpq %r12, %r14
jae 0x4cd8c
movzwl 0x30(%r13), %eax
testl $0x600c, %eax           # imm = 0x600C
je 0x4cd8c
movl 0x28(%r13), %eax
cmpl $0x5, %eax
je 0x4cdf2
cmpl $0x4, %eax
jne 0x4ce0a
movq (%r14), %rdi
leaq 0x2bd70(%rip), %rsi     # 0x78ad4
movq %rdi, -0x30(%rbp)
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
je 0x4ce2d
leaq 0x26ef6(%rip), %rsi     # 0x73c77
movq -0x30(%rbp), %rdi
movl $0x4, %edx
jmp 0x4ce01
leaq 0x2af56(%rip), %rcx     # 0x77ce9
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x49434
movl %eax, %ecx
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %ecx
je 0x4cde3
movq 0x158(%rbx), %rdx
movq 0x160(%rbx), %rcx
xorl %eax, %eax
cmpq %rcx, %rdx
jae 0x4cde3
addq $0x20, %rdx
testb $0x4, -0xe(%rdx)
jne 0x4cde3
movq %rdx, 0x158(%rbx)
leaq 0x20(%rdx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rdx
jb 0x4cdca
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
leaq 0x26e80(%rip), %rsi     # 0x73c7c
movl $0x5, %edx
callq 0x3a837
testl %eax, %eax
je 0x4ce2d
leaq 0x40(%r13), %rax
movq %rax, 0x158(%rbx)
cmpq %r12, %rax
jae 0x4ce21
testb $0x40, 0x52(%r13)
jne 0x4ce4e
leaq 0x2af0f(%rip), %rcx     # 0x77d37
jmp 0x4cd93
leaq 0x2aed2(%rip), %rcx     # 0x77d06
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
movq %r14, %r8
xorl %eax, %eax
callq 0x49434
jmp 0x4cda5
addq $0x60, %r13
movq %r13, 0x158(%rbx)
movq (%rbx), %rdi
movl $0x28, %esi
callq 0x2e951
testq %rax, %rax
je 0x4cf2d
movq %rax, %r15
movq (%rbx), %rax
movabsq $0x1800000000, %rcx     # imm = 0x1800000000
movq %rcx, 0x14(%r15)
xorl %ecx, %ecx
movl %ecx, 0x10(%r15)
movl %ecx, 0x1c(%r15)
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
movq %rcx, 0x20(%r15)
movq 0xf0(%rax), %r13
movq %r15, 0xf0(%rax)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a7a9
movl %eax, %r12d
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $-0x3, %eax
setne %dl
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x493c1
movq (%rbx), %rdi
leaq 0xc8(%rdi), %rax
testq %r13, %r13
cmovneq %r13, %rax
movq %rax, 0xf0(%rdi)
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpl $-0xa, %r12d
je 0x4cde3
movq %rdi, 0x20(%r15)
leaq 0xda0(%rip), %rdx       # 0x4dca4
movq %r14, %rsi
movq %r15, %rcx
callq 0x3055b
testl %eax, %eax
je 0x4cf26
movq %r15, %rdi
callq 0x3a2bc
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x2eb38
xorl %eax, %eax
jmp 0x4cde3
leaq 0x2a81a(%rip), %rcx     # 0x7774e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x49434
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
jmp 0x4cde3