// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileLiteral
JX9_PRIVATE sxi32 jx9CompileLiteral(jx9_gen_state *pGen,sxi32 iCompileFlag)
{
	SyToken *pToken = pGen->pIn;
	jx9_value *pObj;
	SyString *pStr;	
	sxu32 nIdx;
	/* Extract token value */
	pStr = &pToken->sData;
	/* Deal with the reserved literals [i.e: null, false, true, ...] first */
	if( pStr->nByte == sizeof("NULL") - 1 ){
		if( SyStrnicmp(pStr->zString, "null", sizeof("NULL")-1) == 0 ){
			/* NULL constant are always indexed at 0 */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, 0, 0, 0);
			return SXRET_OK;
		}else if( SyStrnicmp(pStr->zString, "true", sizeof("TRUE")-1) == 0 ){
			/* TRUE constant are always indexed at 1 */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, 1, 0, 0);
			return SXRET_OK;
		}
	}else if (pStr->nByte == sizeof("FALSE") - 1 &&
		SyStrnicmp(pStr->zString, "false", sizeof("FALSE")-1) == 0 ){
			/* FALSE constant are always indexed at 2 */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, 2, 0, 0);
			return SXRET_OK;
	}else if(pStr->nByte == sizeof("__LINE__") - 1 &&
		SyMemcmp(pStr->zString, "__LINE__", sizeof("__LINE__")-1) == 0 ){
			/* TICKET 1433-004: __LINE__ constant must be resolved at compile time, not run time */
			pObj = jx9VmReserveConstObj(pGen->pVm, &nIdx);
			if( pObj == 0 ){
				SXUNUSED(iCompileFlag); /* cc warning */
				return GenStateOutOfMem(pGen);
			}
			jx9MemObjInitFromInt(pGen->pVm, pObj, pToken->nLine);
			/* Emit the load constant instruction */
			jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, nIdx, 0, 0);
			return SXRET_OK;
	}else if( pStr->nByte == sizeof("__FUNCTION__") - 1 &&
		SyMemcmp(pStr->zString, "__FUNCTION__", sizeof("__FUNCTION__")-1) == 0 ){
			GenBlock *pBlock = pGen->pCurrent;
			/* TICKET 1433-004: __FUNCTION__/__METHOD__ constants must be resolved at compile time, not run time */
			while( pBlock && (pBlock->iFlags & GEN_BLOCK_FUNC) == 0 ){
				/* Point to the upper block */
				pBlock = pBlock->pParent;
			}
			if( pBlock == 0 ){
				/* Called in the global scope, load NULL */
				jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, 0, 0, 0);
			}else{
				/* Extract the target function/method */
				jx9_vm_func *pFunc = (jx9_vm_func *)pBlock->pUserData;
				pObj = jx9VmReserveConstObj(pGen->pVm, &nIdx);
				if( pObj == 0 ){
					return GenStateOutOfMem(pGen);
				}
				jx9MemObjInitFromString(pGen->pVm, pObj, &pFunc->sName);
				/* Emit the load constant instruction */
				jx9VmEmitInstr(pGen->pVm, JX9_OP_LOADC, 0, nIdx, 0, 0);
			}
			return SXRET_OK;
	}
	/* Query literal table */
	if( SXRET_OK != GenStateFindLiteral(&(*pGen), &pToken->sData, &nIdx) ){
		jx9_value *pObj;
		/* Unknown literal, install it in the literal table */
		pObj = jx9VmReserveConstObj(pGen->pVm, &nIdx);
		if( pObj == 0 ){
			return GenStateOutOfMem(pGen);
		}
		jx9MemObjInitFromString(pGen->pVm, pObj, &pToken->sData);
		GenStateInstallLiteral(&(*pGen), pObj, nIdx);
	}
	/* Emit the load constant instruction */
	jx9VmEmitInstr(pGen->pVm,JX9_OP_LOADC,1,nIdx, 0, 0);
	/* Node successfully compiled */
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x158(%rdi), %r14
movl 0x8(%r14), %r15d
leal -0x4(%r15), %eax
cmpl $0x8, %eax
ja 0x4f325
leaq 0x25573(%rip), %rcx     # 0x747dc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq (%r14), %r15
leaq 0x29858(%rip), %rsi     # 0x78ad4
movq %r15, %rdi
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
je 0x4f44d
leaq 0x249df(%rip), %rsi     # 0x73c77
movq %r15, %rdi
movl $0x4, %edx
callq 0x3a837
testl %eax, %eax
jne 0x4f325
movq (%rbx), %rdi
xorl %ebx, %ebx
movl $0x4, %esi
xorl %edx, %edx
movl $0x1, %ecx
jmp 0x4f3aa
movq (%r14), %rdi
leaq 0x249b3(%rip), %rsi     # 0x73c7c
movl $0x5, %edx
callq 0x3a837
testl %eax, %eax
je 0x4f460
cmpl $0xc, %r15d
je 0x4f309
cmpl $0x8, %r15d
jne 0x4f325
movq (%r14), %rdi
leaq 0x28b8c(%rip), %rsi     # 0x77e7d
movl $0x8, %edx
callq 0x34ebe
testl %eax, %eax
je 0x4f3d6
cmpl $0xc, %r15d
jne 0x4f325
movq (%r14), %rdi
leaq 0x28b73(%rip), %rsi     # 0x77e86
movl $0xc, %edx
callq 0x34ebe
testl %eax, %eax
je 0x4f3ba
leaq -0x1c(%rbp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x50201
testl %eax, %eax
je 0x4f398
movq (%rbx), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x49175
movq %rax, %r15
testq %rax, %rax
je 0x4f374
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x45a64
movl 0x28(%r15), %edx
testl %edx, %edx
je 0x4f38f
movl -0x1c(%rbp), %ecx
leaq 0x8(%rbx), %rdi
movq 0x20(%r15), %rsi
callq 0x4542b
jmp 0x4f38f
leaq 0x283d3(%rip), %rcx     # 0x7774e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x49434
testq %r15, %r15
je 0x4f4fb
movq (%rbx), %rdi
movl -0x1c(%rbp), %ecx
xorl %ebx, %ebx
movl $0x4, %esi
movl $0x1, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x493c1
jmp 0x4f500
movq 0xc8(%rbx), %rax
testq %rax, %rax
je 0x4f431
testb $0x8, 0x14(%rax)
jne 0x4f476
movq 0x8(%rax), %rax
jmp 0x4f3c1
movq (%rbx), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x49175
testq %rax, %rax
je 0x4f4ba
movq (%rbx), %rcx
movl 0x14(%r14), %edx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x20(%rax)
movq %rcx, 0x10(%rax)
movq %rcx, 0x18(%rax)
movl $0x0, 0x30(%rax)
movq %rdx, (%rax)
movl $0x2, 0x8(%rax)
movq (%rbx), %rdi
movl -0x1c(%rbp), %ecx
xorl %ebx, %ebx
movl $0x4, %esi
xorl %edx, %edx
jmp 0x4f3aa
movq (%rbx), %rdi
movl $0x4, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x493c1
jmp 0x4f4f7
movq (%rbx), %rdi
xorl %ebx, %ebx
movl $0x4, %esi
xorl %edx, %edx
xorl %ecx, %ecx
jmp 0x4f3aa
movq (%rbx), %rdi
xorl %ebx, %ebx
movl $0x4, %esi
xorl %edx, %edx
movl $0x2, %ecx
jmp 0x4f3aa
movq 0x40(%rax), %r15
movq (%rbx), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x49175
movq %rax, %r14
testq %rax, %rax
je 0x4f4d7
movq (%rbx), %rdi
addq $0x50, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x45a64
movq (%rbx), %rdi
movl -0x1c(%rbp), %ecx
movl $0x4, %esi
xorl %edx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x493c1
jmp 0x4f4f2
leaq 0x2828d(%rip), %rcx     # 0x7774e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x49434
jmp 0x4f4fb
leaq 0x28270(%rip), %rcx     # 0x7774e
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x49434
testq %r14, %r14
je 0x4f4fb
xorl %ebx, %ebx
jmp 0x4f500
movl $0xfffffff6, %ebx       # imm = 0xFFFFFFF6
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq