// File: /workspace/github_c_makefile_star2_O2/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 0x422c0
movzwl 0x30(%r13), %eax
testw $0x600c, %ax            # imm = 0x600C
je 0x422c0
movl 0x28(%r13), %eax
cmpl $0x5, %eax
je 0x4231b
cmpl $0x4, %eax
jne 0x42331
movq (%r14), %rdi
leaq 0x24823(%rip), %rsi     # 0x66abf
pushq $0x4
popq %rdx
movq %rdi, -0x30(%rbp)
callq 0x32436
testl %eax, %eax
je 0x42354
leaq 0x1f9b7(%rip), %rsi     # 0x61c6e
pushq $0x4
popq %rdx
movq -0x30(%rbp), %rdi
jmp 0x42328
leaq 0x23a0d(%rip), %rcx     # 0x65cd4
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0x3eed6
cmpl $-0xa, %eax
jne 0x422f2
pushq $-0xa
popq %r15
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x158(%rbx), %rax
movq 0x160(%rbx), %rcx
xorl %r15d, %r15d
cmpq %rcx, %rax
jae 0x422e0
testb $0x4, 0x12(%rax)
jne 0x422e0
addq $0x20, %rax
movq %rax, 0x158(%rbx)
jmp 0x42300
movq (%r14), %rdi
leaq 0x1f94e(%rip), %rsi     # 0x61c73
pushq $0x5
popq %rdx
callq 0x32436
testl %eax, %eax
je 0x42354
leaq 0x40(%r13), %rax
movq %rax, 0x158(%rbx)
cmpq %r12, %rax
jae 0x42348
testb $0x40, 0x52(%r13)
jne 0x42373
leaq 0x239d3(%rip), %rcx     # 0x65d22
jmp 0x422c7
leaq 0x23996(%rip), %rcx     # 0x65cf1
pushq $0x1
popq %rsi
movq %rbx, %rdi
movl %r15d, %edx
movq %r14, %r8
xorl %eax, %eax
callq 0x3eed6
jmp 0x422d7
addq $0x60, %r13
movq %r13, 0x158(%rbx)
movq (%rbx), %rdi
pushq $0x28
popq %rsi
callq 0x279f7
testq %rax, %rax
je 0x4245f
movq %rax, %r12
movq (%rbx), %rax
movabsq $0x1800000000, %rcx     # imm = 0x1800000000
movq %rcx, 0x14(%r12)
andl $0x0, 0x10(%r12)
andl $0x0, 0x1c(%r12)
movq %rax, (%r12)
andq $0x0, 0x8(%r12)
andq $0x0, 0x20(%r12)
movq 0xf0(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq %r12, 0xf0(%rax)
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4012f
movl %eax, %r13d
movq (%rbx), %rdi
xorl %edx, %edx
cmpl $-0x3, %eax
setne %dl
pushq $0x1
popq %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3ee6f
movq (%rbx), %rdi
leaq 0xc8(%rdi), %rax
movq -0x30(%rbp), %rcx
testq %rcx, %rcx
cmovneq %rcx, %rax
movq %rax, 0xf0(%rdi)
cmpl $-0xa, %r13d
je 0x422dc
movq %rdi, 0x20(%r12)
leaq 0xb75(%rip), %rdx       # 0x42fa9
movq %r14, %rsi
movq %r12, %rcx
callq 0x292bb
testl %eax, %eax
je 0x422e0
movq %r12, %rdi
callq 0x31feb
movq (%rbx), %rdi
movq %r12, %rsi
callq 0x27bf8
jmp 0x422e0
movq %rbx, %rdi
callq 0x426d9
jmp 0x422dc