fn gen_init_param(global_size: u64, global_ref_indexs: &[i32]) -> Chunk {
    let mut code = vec![0; INIT_PARAM_SIZE as usize];
    code[GLOBAL_SIZE_OFFSET as usize..][..8].copy_from_slice(&global_size.to_le_bytes());
    let mut ref_map = vec![0; (global_size as usize / 8 + 7) / 8];
    for index in global_ref_indexs {
        let index = *index as usize;
        ref_map[index / 8] |= 1 << (index % 8);
    }
    Chunk {
        name: INIT_PARAM.to_owned(),
        code,
        links: vec![
            ChunkLink {
                pos: GLOBAL_SECTION_OFFSET as usize,
                to: ChunkLinkTarget::Symbol(GLOBAL_SECTION.to_owned()),
            },
            ChunkLink {
                pos: GLOBAL_MAP_OFFSET as usize,
                to: ChunkLinkTarget::Data(ref_map),
            },
            ChunkLink {
                pos: STR_PROTOTYPE_OFFSET as usize,
                to: ChunkLinkTarget::Symbol(STR_PROTOTYPE.to_owned()),
            },
        ],
        extra: ChunkExtra::Data { writable: true },
    }
}
// Generate configuration data for standard library initialization
Generate configuration data for standard library initialization
Generate configuration data for standard library initialization
fn gen_init_param(global_size: u64, global_ref_indexs: &[i32]) -> Chunk {
    let mut code = vec![0; INIT_PARAM_SIZE as usize];
    code[GLOBAL_SIZE_OFFSET as usize..][..8].copy_from_slice(&global_size.to_le_bytes());
    let mut ref_map = vec![0; (global_size as usize / 8 + 7) / 8];
    for index in global_ref_indexs {
        let index = *index as usize;
        ref_map[index / 8] |= 1 << (index % 8);
    }
    Chunk {
        name: INIT_PARAM.to_owned(),
        code,
        links: vec![
            ChunkLink {
                pos: GLOBAL_SECTION_OFFSET as usize,
                to: ChunkLinkTarget::Symbol(GLOBAL_SECTION.to_owned()),
            },
            ChunkLink {
                pos: GLOBAL_MAP_OFFSET as usize,
                to: ChunkLinkTarget::Data(ref_map),
            },
            ChunkLink {
                pos: STR_PROTOTYPE_OFFSET as usize,
                to: ChunkLinkTarget::Symbol(STR_PROTOTYPE.to_owned()),
            },
        ],
        extra: ChunkExtra::Data { writable: true },
    }
}
fn gen_init_param ( global_size : u64 , global_ref_indexs : & [ i32 ] ) -> Chunk { let mut code = vec ! [ 0 INIT_PARAM_SIZE as usize ] ; code [ GLOBAL_SIZE_OFFSET as usize .. ] [ .. 8 ] . copy_from_slice ( & global_size . to_le_bytes ( ) ) ; let mut ref_map = vec ! [ 0 ( global_size as usize 8 7 ) 8 ] ; for index in global_ref_indexs { let index = * index as usize ; ref_map [ index / 8 ] |= 1 << ( index % 8 ) ; } Chunk { name : INIT_PARAM . to_owned ( ) , code , links : vec ! [ ChunkLink { pos GLOBAL_SECTION_OFFSET as usize to ChunkLinkTarget Symbol ( GLOBAL_SECTION to_owned ( ) ) } ChunkLink { pos GLOBAL_MAP_OFFSET as usize to ChunkLinkTarget Data ( ref_map ) } ChunkLink { pos STR_PROTOTYPE_OFFSET as usize to ChunkLinkTarget Symbol ( STR_PROTOTYPE to_owned ( ) ) } ] , extra : ChunkExtra :: Data { writable : true } , } }
Generate configuration data for standard library initialization
Generate configuration data for standard library initialization
global_size
u64
global_ref_indexs
&[i32]