fn postprocess_setup_imports(&mut self) -> Hopefully<()> {
    // Step 1
    // Write imports onto literal heap as {Mod, Fun, Arity} triplets
    //
    self.imports.reserve(self.raw.imports.len());
    for ri in &self.raw.imports {
      let mod_atom = self.atom_from_loadtime_index(ri.mod_atom_i);
      let fun_atom = self.atom_from_loadtime_index(ri.fun_atom_i);
      let mf_arity = MFArity::new(mod_atom, fun_atom, ri.arity);
      let is_bif = bif::is_bif(&mf_arity);
      //println!("is_bif {} for {}", is_bif, mf_arity);
      let ho_imp = unsafe {
        HOImport::place_into(&mut self.lit_heap, mf_arity, is_bif)?
      };

      self.imports.push(ho_imp);
    }

    // Step 2
    // For each opcode if it has import index arg - overwrite it
    //
    let c_iter = unsafe {
      code::iter::create_mut(&mut self.code)
    };
    for cp in c_iter {
      let curr_opcode = opcode::from_memory_ptr(cp.ptr());
      match curr_opcode {
        gen_op::OPCODE_MAKE_FUN2 => {
          // arg[0] is export
//          self.rewrite_import_index_arg(&cp, 1)
          self.rewrite_lambda_index_arg(cp, 1)
        },
        gen_op::OPCODE_BIF1 |
        gen_op::OPCODE_BIF2 |
        gen_op::OPCODE_CALL_EXT |
        gen_op::OPCODE_CALL_EXT_LAST |
        gen_op::OPCODE_CALL_EXT_ONLY => {
          // arg[1] is export
          self.rewrite_import_index_arg(cp, 2)
        },
        gen_op::OPCODE_GC_BIF1 |
        gen_op::OPCODE_GC_BIF2 |
        gen_op::OPCODE_GC_BIF3 => {
          // arg[2] is export
          self.rewrite_import_index_arg(cp, 3)
        }
        _ => {}
      }
    }
    Ok(())
  }
/// Analyze the code and for certain opcodes overwrite their import index
/// args with direct pointer to import heap.
Analyze the code and for certain opcodes overwrite their import index
args with direct pointer to import heap.
Analyze the code and for certain opcodes overwrite their import index args with direct pointer to import heap .
fn postprocess_setup_imports(&mut self) -> Hopefully<()> {
    // Step 1
    // Write imports onto literal heap as {Mod, Fun, Arity} triplets
    //
    self.imports.reserve(self.raw.imports.len());
    for ri in &self.raw.imports {
      let mod_atom = self.atom_from_loadtime_index(ri.mod_atom_i);
      let fun_atom = self.atom_from_loadtime_index(ri.fun_atom_i);
      let mf_arity = MFArity::new(mod_atom, fun_atom, ri.arity);
      let is_bif = bif::is_bif(&mf_arity);
      //println!("is_bif {} for {}", is_bif, mf_arity);
      let ho_imp = unsafe {
        HOImport::place_into(&mut self.lit_heap, mf_arity, is_bif)?
      };
      self.imports.push(ho_imp);
    }
    // Step 2
    // For each opcode if it has import index arg - overwrite it
    //
    let c_iter = unsafe {
      code::iter::create_mut(&mut self.code)
    };
    for cp in c_iter {
      let curr_opcode = opcode::from_memory_ptr(cp.ptr());
      match curr_opcode {
        gen_op::OPCODE_MAKE_FUN2 => {
          // arg[0] is export
//          self.rewrite_import_index_arg(&cp, 1)
          self.rewrite_lambda_index_arg(cp, 1)
        },
        gen_op::OPCODE_BIF1 |
        gen_op::OPCODE_BIF2 |
        gen_op::OPCODE_CALL_EXT |
        gen_op::OPCODE_CALL_EXT_LAST |
        gen_op::OPCODE_CALL_EXT_ONLY => {
          // arg[1] is export
          self.rewrite_import_index_arg(cp, 2)
        },
        gen_op::OPCODE_GC_BIF1 |
        gen_op::OPCODE_GC_BIF2 |
        gen_op::OPCODE_GC_BIF3 => {
          // arg[2] is export
          self.rewrite_import_index_arg(cp, 3)
        }
        _ => {}
      }
    }
    Ok(())
  }
fn postprocess_setup_imports ( & mut self ) -> Hopefully < ( ) > { // Step 1 // Write imports onto literal heap as {Mod, Fun, Arity} triplets // self . imports . reserve ( self . raw . imports . len ( ) ) ; for ri in & self . raw . imports { let mod_atom = self . atom_from_loadtime_index ( ri . mod_atom_i ) ; let fun_atom = self . atom_from_loadtime_index ( ri . fun_atom_i ) ; let mf_arity = MFArity :: new ( mod_atom , fun_atom , ri . arity ) ; let is_bif = bif :: is_bif ( & mf_arity ) ; //println!("is_bif {} for {}", is_bif, mf_arity); let ho_imp = unsafe { HOImport :: place_into ( & mut self . lit_heap , mf_arity , is_bif ) ? } ; self . imports . push ( ho_imp ) ; } // Step 2 // For each opcode if it has import index arg - overwrite it // let c_iter = unsafe { code :: iter :: create_mut ( & mut self . code ) } ; for cp in c_iter { let curr_opcode = opcode :: from_memory_ptr ( cp . ptr ( ) ) ; match curr_opcode { gen_op :: OPCODE_MAKE_FUN2 => { // arg[0] is export //          self.rewrite_import_index_arg(&cp, 1) self . rewrite_lambda_index_arg ( cp , 1 ) } , gen_op :: OPCODE_BIF1 | gen_op :: OPCODE_BIF2 | gen_op :: OPCODE_CALL_EXT | gen_op :: OPCODE_CALL_EXT_LAST | gen_op :: OPCODE_CALL_EXT_ONLY => { // arg[1] is export self . rewrite_import_index_arg ( cp , 2 ) } , gen_op :: OPCODE_GC_BIF1 | gen_op :: OPCODE_GC_BIF2 | gen_op :: OPCODE_GC_BIF3 => { // arg[2] is export self . rewrite_import_index_arg ( cp , 3 ) } _ => { } } } Ok ( ( ) ) }
Analyze the code and for certain opcodes overwrite their import index
args with direct pointer to import heap.
Analyze the code and for certain opcodes overwrite their import index args with direct pointer to import heap .
&mut self