// File: /workspace/github_c_makefile_star2_O2/coyove[P]chann/./lib/unqlite/unqlite.c
// Function: jx9CompileJsonObject
JX9_PRIVATE sxi32 jx9CompileJsonObject(jx9_gen_state *pGen, sxi32 iCompileFlag)
{
	SyToken *pKey, *pCur;
	sxi32 nPair = 0;
	sxi32 rc;

	pGen->pIn++; /* Jump the open querly braces '{'*/
	pGen->pEnd--;
	SXUNUSED(iCompileFlag); /* cc warning */
	for(;;){
		/* Jump leading commas */
		while( pGen->pIn < pGen->pEnd && (pGen->pIn->nType & JX9_TK_COMMA) ){
			pGen->pIn++;
		}
		pCur = pGen->pIn;
		if( SXRET_OK != jx9GetNextExpr(pGen->pIn, pGen->pEnd, &pGen->pIn) ){
			/* No more entry to process */
			break;
		}
		/* Compile the key */
		pKey = pCur;
		while( pCur < pGen->pIn ){
			if( pCur->nType & JX9_TK_COLON /*':'*/  ){
				break;
			}
			pCur++;
		}
		rc = SXERR_EMPTY;
		if( pCur < pGen->pIn ){
			if( &pCur[1] >= pGen->pIn ){
				/* Missing value */
				rc = jx9GenCompileError(&(*pGen), E_ERROR, pCur->nLine, "JSON Object: Missing entry value");
				if( rc == SXERR_ABORT ){
					return SXERR_ABORT;
				}
				return SXRET_OK;
			}
			/* Compile the expression holding the key */
			rc = GenStateCompileJSONEntry(&(*pGen), pKey, pCur,
				EXPR_FLAG_RDONLY_LOAD                /* Do not create the variable if inexistant */, 
				GenStateJSONObjectKeyNodeValidator   /* Node validator callback */
				);
			if( rc == SXERR_ABORT ){
				return SXERR_ABORT;
			}
			pCur++; /* Jump the double colon ':'  */
		}else if( pKey == pCur ){
			/* Key is omitted, emit an error */
			jx9GenCompileError(&(*pGen),E_ERROR, pCur->nLine, "JSON Object: Missing entry key");
			pCur++; /* Jump the double colon ':'  */
		}else{
			/* Reset back the cursor and point to the entry value */
			pCur = pKey;
		}
		/* Compile indice value */
		rc = GenStateCompileJSONEntry(&(*pGen), pCur, pGen->pIn, EXPR_FLAG_RDONLY_LOAD/*Do not create the variable if inexistant*/,0);
		if( rc == SXERR_ABORT ){
			return SXERR_ABORT;
		}
		nPair++;
	}
	/* Emit the load map instruction */
	jx9VmEmitInstr(pGen->pVm, JX9_OP_LOAD_MAP, nPair * 2, 1, 0, 0);
	/* Node successfully compiled */
	return SXRET_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x158(%rdi), %r15
movq 0x158(%rdi), %rax
movq 0x160(%rdi), %rsi
addq $0x20, %rax
movq %rax, 0x158(%rdi)
addq $-0x20, %rsi
movq %rsi, 0x160(%rdi)
xorl %r13d, %r13d
addq $0x20, %rax
leaq -0x20(%rax), %r12
cmpq %rsi, %r12
jae 0x43fe8
testb $0x2, -0xe(%rax)
je 0x43fe8
movq %rax, (%r15)
jmp 0x43fd0
movq %r12, %rdi
movq %r15, %rdx
callq 0x42f48
testl %eax, %eax
jne 0x440a1
movl %r13d, -0x2c(%rbp)
movq (%r15), %rax
xorl %ecx, %ecx
movq %r12, %rbx
cmpq %rax, %rbx
jae 0x44043
leaq 0x20(%rbx), %r13
addq $-0x20, %rcx
testb $0x10, 0x12(%rbx)
movq %r13, %rbx
je 0x44007
cmpq %rax, %r13
jae 0x440bf
leaq -0x20(%r13), %rdx
movq %r14, %rdi
movq %r12, %rsi
leaq 0x638(%rip), %rcx       # 0x4466f
callq 0x4462d
cmpl $-0xa, %eax
jne 0x44069
jmp 0x4409c
movq %r12, %r13
testq %rcx, %rcx
jne 0x44069
movl 0x14(%rbx), %edx
movq %r14, %rdi
pushq $0x1
popq %rsi
leaq 0x21d8b(%rip), %rcx     # 0x65de6
xorl %eax, %eax
callq 0x3eed6
addq $0x20, %rbx
movq %rbx, %r13
movq 0x158(%r14), %rdx
movq %r14, %rdi
movq %r13, %rsi
xorl %ecx, %ecx
callq 0x4462d
cmpl $-0xa, %eax
je 0x4409c
movl -0x2c(%rbp), %r13d
incl %r13d
movq 0x158(%r14), %rax
movq 0x160(%r14), %rsi
jmp 0x43fd0
pushq $-0xa
popq %rbx
jmp 0x440df
movq (%r14), %rdi
addl %r13d, %r13d
xorl %ebx, %ebx
pushq $0x6
popq %rsi
pushq $0x1
popq %rcx
movl %r13d, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x3ee6f
jmp 0x440df
movl -0xc(%r13), %edx
leaq 0x21cfb(%rip), %rcx     # 0x65dc5
xorl %ebx, %ebx
pushq $0x1
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x3eed6
cmpl $-0xa, %eax
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq