// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/xoico/src/xoico.xo.c
// Function: xoico_embed_file_open
er_t xoico_embed_file_open( x_source* parent, sc_t file_name, x_source** include_source )
{
    // xoico.x:92:1
    BLM_INIT_LEVEL(0);
    st_s* folder = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,bcore_file_folder_path(x_source_get_file(parent) )));
    if( folder->size == 0 ) st_s_push_char(folder,'.' );
    
    st_s* path = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
    if( file_name[ 0 ] == '/' )
    {
        st_s_copy_sc(path,file_name );
    }
    else
    {
        st_s_copy_fa(path,"#<sc_t>/#<sc_t>", folder->sc, file_name );
    }
    
    if( !bcore_file_exists(path->sc ) )
    {
        BLM_RETURNV(er_t, x_source_parse_error_fa(parent,"Xoico: File '#<sc_t>' not found.", path->sc ))
    }
    
    (*(include_source)) =((x_source*)( bcore_file_open_source(path->sc )));
    BLM_RETURNV(er_t, 0)
}

er_t xoico_parse_sc( xoico* o, const xoico_host* host, sc_t sc )
{
    // xoico.x:118:1
    BLM_INIT_LEVEL(0);
    BLM_RETURNV(er_t, xoico_a_parse(o,host, ((x_source*)BLM_LEVEL_A_PUSH(0,x_source_create_from_sc(sc ))) ))
}

er_t xoico_parse_fa( xoico* o, const xoico_host* host, sc_t format, ... )
{
    // xoico.x:125:1
    BLM_INIT_LEVEL(0);
    va_list args;
    va_start( args, format );
    er_t ret = xoico_a_parse(o,host, ((x_source*)BLM_LEVEL_A_PUSH(0,x_source_create_from_fv(format, args ))) );
    va_end( args );
    BLM_RETURNV(er_t, ret)
}

/**********************************************************************************************************************/
// source: xoico_host.x

//----------------------------------------------------------------------------------------------------------------------
// group: xoico_host

XOILA_DEFINE_SPECT_NASC_BEGIN( x_inst, xoico_host )
"{",
    "bcore_spect_header_s header;",
    "feature aware xoico_host : parse_name_st = xoico_host_parse_name_st_default;",
    "feature aware xoico_host : parse_name_tp = xoico_host_parse_name_tp_default;",
    "feature aware xoico_host : compiler = xoico_host_compiler_default;",
    "feature aware xoico_host : cengine = xoico_host_cengine_default;",
    "feature aware xoico_host : obj_type = xoico_host_obj_type_default;",
    "feature aware xoico_host : create_spect_name = xoico_host_create_spect_name_default;",
    "feature aware xoico_host : transient_map;",
    "feature aware xoico_host : nameof = xoico_host_nameof_default;",
    "feature aware xoico_host : entypeof = xoico_host_entypeof_default;",
"}",
XOILA_DEFINE_SPECT_NASC_END( x_inst, xoico_host )

er_t xoico_host_parse_name_tp_default( const xoico_host* o, x_source* source, tp_t* name )
{
    // xoico_host.x:24:1
    BLM_INIT_LEVEL(0);
    st_s* s = ((st_s*)BLM_LEVEL_T_PUSH(0,st_s,st_s_create()));
    BLM_TRY(xoico_host_a_parse_name_st(o,source, s ))
    if( s->size == 0 ) BLM_RETURNV(er_t, x_source_parse_error_fa(source,"Identifier expected." ))
    tp_t t = xoico_compiler_s_entypeof(xoico_host_a_compiler(o),s->sc );
    if( name ) (*(name)) = t;
    BLM_RETURNV(er_t, 0)
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x18e1e7(%rip), %rax    # 0x19bdd0
movq (%rax), %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0xd6675
movq $0x0, 0x10(%r12)
movq (%r14), %r12
leaq 0x18f0be(%rip), %rax    # 0x19ccc8
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r12, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0xdc60
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0xdc60
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0xdc60
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0xdc69
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0xdc90
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r12, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0x18f043(%rip), %rdi    # 0x19ccc8
movq %r12, %rsi
movq %rax, %rdx
callq 0x115fac
movabsq $-0x503db0e6e1c2e704, %r12 # imm = 0xAFC24F191E3D18FC
movq %r13, %rdi
movq %r14, %rsi
callq 0xffe4a
movq %rax, %rdi
callq 0xbf2b1
movq %rsp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r13
cmpq $0x0, 0x10(%rax)
jne 0xdcd4
movq %r13, %rdi
movl $0x2e, %esi
callq 0x10a448
xorl %eax, %eax
callq 0x109c82
movq %rsp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0xd68a8
movq %rax, %r12
cmpb $0x2f, (%r15)
jne 0xdd01
movq %r12, %rdi
movq %r15, %rsi
callq 0x109612
jmp 0xdd19
movq 0x8(%r13), %rdx
leaq 0x11f36c(%rip), %rsi    # 0x12d078
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x1097fd
movq 0x8(%r12), %rdi
callq 0xbf581
movq 0x8(%r12), %rdx
testb %al, %al
je 0xdd3b
movq %rdx, %rdi
callq 0xbf75a
movq %rax, (%rbx)
xorl %ebx, %ebx
jmp 0xdd4f
leaq 0x11f346(%rip), %rsi    # 0x12d088
movq %r14, %rdi
xorl %eax, %eax
callq 0xde10
movq %rax, %rbx
movq %rsp, %rdi
callq 0xd6d2c
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq