Actually make MovType work
This commit is contained in:
		
							
								
								
									
										15
									
								
								src/vm.rs
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/vm.rs
									
									
									
									
									
								
							| @@ -40,6 +40,15 @@ pub enum ExitInstruction { | ||||
| } | ||||
|  | ||||
| pub enum MovType { Mov, Add, Xor } | ||||
| impl MovType { | ||||
|     fn merge(&self, old_value: Sample, new_value: Sample) -> Sample { | ||||
|         match self { | ||||
|             MovType::Mov => new_value, | ||||
|             MovType::Add => Sample(old_value.0 + new_value.0), | ||||
|             MovType::Xor => Sample(old_value.0 ^ new_value.0) | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| #[derive(Clone, Copy)] pub enum MovDst { L(RegL), R(RegR), Z(RegZ), Ix } | ||||
| #[derive(Clone, Copy)] pub enum MovSrc { A(RegA), L(RegL), R(RegR), Z(RegZ), Ix, Imm(Sample) } | ||||
| @@ -155,20 +164,20 @@ impl Scope { | ||||
|             } | ||||
|             MovDst::R(RegR(r)) => { | ||||
|                 let r = r as usize; | ||||
|                 self.reg_rs[r] = value; return | ||||
|                 self.reg_rs[r] = ty.merge(self.reg_rs[r], value); return | ||||
|             } | ||||
|             MovDst::Z(RegZ(z)) => { | ||||
|                 let z = z as usize; | ||||
|                 (&mut self.reg_zs[z], &self.loop_zs[z]) | ||||
|             } | ||||
|             MovDst::Ix => { self.ix = value; return } | ||||
|             MovDst::Ix => { self.ix = ty.merge(self.ix, value); return } | ||||
|         }; | ||||
|  | ||||
|         let mut ix = flat_ix + offset; | ||||
|         if loop_.length != 0 { ix %= loop_.length; } | ||||
|         ix += chan.formal().start + loop_.start; | ||||
|  | ||||
|         chan[ix] = value | ||||
|         chan[ix] = ty.merge(chan[ix], value) | ||||
|     } | ||||
|  | ||||
|     fn replace(&mut self, dst: OupDst, value: Channel) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user