pub fn spawn(
        vm: &mut VM<'a>,
        host: Shared<Host<'a>>,
        name: String,
        redshift: bool,
        script: &str,
    ) -> Result<Shared<Exa<'a>>, Box<dyn Error>> {
        // TODO: VM check on name uniqueness
        host.borrow_mut().reserve_slot()?;
        let mut insts = parse_text(script).unwrap();
        let data_file = Exa::extract_data(&mut insts, vm.file_counter.clone());
        let labels = Exa::extract_labels(&mut insts);
        let e = Rc::new(RefCell::new(Exa {
            base_name: name.clone(),
            spawn_id: 0,
            name,
            registers: if redshift {
                Registers::new_redshift()
            } else {
                Registers::new()
            },
            pc: 0,
            instructions: insts,
            labels: labels,
            mode: Mode::Global,
            file_pointer: 0,
            file: data_file,
            global_bus: vm.bus.clone(),
            host: host,
            error: None,
            result: CycleResult::new(),
            spawn_counter: Rc::new(AtomicU32::new(1)),
            file_counter: vm.file_counter.clone(),
            sprite: Sprite::empty(),
            ran_test_mrd_this_cycle: false,
            waiting: false,
        }));
        vm.register_exa(e.clone());
        Ok(e)
    }
/// Spawn an Exa in the specified Host, if there is available space.
Spawn an Exa in the specified Host, if there is available space.
Spawn an Exa in the specified Host if there is available space .
pub fn spawn(
        vm: &mut VM<'a>,
        host: Shared<Host<'a>>,
        name: String,
        redshift: bool,
        script: &str,
    ) -> Result<Shared<Exa<'a>>, Box<dyn Error>> {
        // TODO: VM check on name uniqueness
        host.borrow_mut().reserve_slot()?;
        let mut insts = parse_text(script).unwrap();
        let data_file = Exa::extract_data(&mut insts, vm.file_counter.clone());
        let labels = Exa::extract_labels(&mut insts);
        let e = Rc::new(RefCell::new(Exa {
            base_name: name.clone(),
            spawn_id: 0,
            name,
            registers: if redshift {
                Registers::new_redshift()
            } else {
                Registers::new()
            },
            pc: 0,
            instructions: insts,
            labels: labels,
            mode: Mode::Global,
            file_pointer: 0,
            file: data_file,
            global_bus: vm.bus.clone(),
            host: host,
            error: None,
            result: CycleResult::new(),
            spawn_counter: Rc::new(AtomicU32::new(1)),
            file_counter: vm.file_counter.clone(),
            sprite: Sprite::empty(),
            ran_test_mrd_this_cycle: false,
            waiting: false,
        }));
        vm.register_exa(e.clone());
        Ok(e)
    }
pub fn spawn ( vm : & mut VM < ' a > , host : Shared < Host < ' a > > , name : String , redshift : bool , script : & str , ) -> Result < Shared < Exa < ' a > > , Box < dyn Error > > { // TODO: VM check on name uniqueness host . borrow_mut ( ) . reserve_slot ( ) ? ; let mut insts = parse_text ( script ) . unwrap ( ) ; let data_file = Exa :: extract_data ( & mut insts , vm . file_counter . clone ( ) ) ; let labels = Exa :: extract_labels ( & mut insts ) ; let e = Rc :: new ( RefCell :: new ( Exa { base_name : name . clone ( ) , spawn_id : 0 , name , registers : if redshift { Registers :: new_redshift ( ) } else { Registers :: new ( ) } , pc : 0 , instructions : insts , labels : labels , mode : Mode :: Global , file_pointer : 0 , file : data_file , global_bus : vm . bus . clone ( ) , host : host , error : None , result : CycleResult :: new ( ) , spawn_counter : Rc :: new ( AtomicU32 :: new ( 1 ) ) , file_counter : vm . file_counter . clone ( ) , sprite : Sprite :: empty ( ) , ran_test_mrd_this_cycle : false , waiting : false , } ) ) ; vm . register_exa ( e . clone ( ) ) ; Ok ( e ) }
Spawn an Exa in the specified Host, if there is available space.
Spawn an Exa in the specified Host if there is available space .
vm
&mut VM<'a>
host
Shared<Host<'a>>
name
String
redshift
bool
script
&str
vm
&mut VM<'a>
host
Shared<Host<'a>>
name
String
redshift
bool
script
&str