// File: /workspace/github_c_makefile_star2_O1/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 0x19b256(%rip), %rax    # 0x1a8dd0
movq (%rax), %rsi
movq %rsp, %r12
movq %r12, %rdi
callq 0xe0431
movq $0x0, 0x10(%r12)
movq (%r14), %r12
leaq 0x19c12d(%rip), %rax    # 0x1a9cc8
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 0xdbf5
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0xdbf5
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0xdbf5
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0xdcfd
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0xdc25
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r12, %rsi
callq 0xf3f85
movq %rax, %r13
leaq 0x19c0ae(%rip), %rdi    # 0x1a9cc8
movq %r12, %rsi
movq %rax, %rdx
callq 0x12128c
movabsq $-0x503db0e6e1c2e704, %r12 # imm = 0xAFC24F191E3D18FC
movq %r13, %rdi
movq %r14, %rsi
callq 0x10aa35
movq %rax, %rdi
callq 0xc8e31
movq %rsp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0xe0676
movq %rax, %r13
cmpq $0x0, 0x10(%rax)
jne 0xdc69
movq %r13, %rdi
movl $0x2e, %esi
callq 0x115381
xorl %eax, %eax
callq 0x114bbb
movq %rsp, %rdi
xorl %esi, %esi
movq %r12, %rdx
movq %rax, %rcx
callq 0xe0676
movq %rax, %r12
cmpb $0x2f, (%r15)
jne 0xdc96
movq %r12, %rdi
movq %r15, %rsi
callq 0x11454b
jmp 0xdcae
movq 0x8(%r13), %rdx
leaq 0x12a3d7(%rip), %rsi    # 0x138078
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x114736
movq 0x8(%r12), %rdi
callq 0xc90fb
movq 0x8(%r12), %rdx
testb %al, %al
je 0xdcd0
movq %rdx, %rdi
callq 0xc92d1
movq %rax, (%rbx)
xorl %ebx, %ebx
jmp 0xdce4
leaq 0x12a3b1(%rip), %rsi    # 0x138088
movq %r14, %rdi
xorl %eax, %eax
callq 0xddb2
movq %rax, %rbx
movq %rsp, %rdi
callq 0xe0b30
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %r13d, %r13d
jmp 0xdbf9