// File: /workspace/github_c_makefile_star2_O2/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
movabsq $-0x503db0e6e1c2e704, %r12 # imm = 0xAFC24F191E3D18FC
leaq 0x10a6e8(%rip), %rax    # 0x117dd0
movq (%rax), %rsi
movq %rsp, %r13
movq %r13, %rdi
callq 0x717f5
andq $0x0, 0x10(%r13)
movq %r14, %rdi
callq 0x270e4
movq %rax, %rdi
callq 0x60c15
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0x71967
movq %rax, %r13
cmpq $0x0, 0x10(%rax)
jne 0xd730
pushq $0x2e
popq %rsi
movq %r13, %rdi
callq 0x8f0ee
xorl %eax, %eax
callq 0x8eb65
movq %rsp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0x71967
movq %rax, %r12
cmpb $0x2f, (%r15)
jne 0xd75d
movq %r12, %rdi
movq %r15, %rsi
callq 0x8e611
jmp 0xd775
movq 0x8(%r13), %rdx
leaq 0x9c910(%rip), %rsi     # 0xaa078
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x8e7af
movq 0x8(%r12), %rdi
callq 0x60eaa
movq 0x8(%r12), %rdx
testb %al, %al
je 0xd797
movq %rdx, %rdi
callq 0x61037
movq %rax, (%rbx)
xorl %ebx, %ebx
jmp 0xd7ab
leaq 0x9c8ea(%rip), %rsi     # 0xaa088
movq %r14, %rdi
xorl %eax, %eax
callq 0xd7c4
movq %rax, %rbx
movq %rsp, %rdi
callq 0x71b64
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq