Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/runtime/src/program.rs

24 lines
406 B

use asm::instr::Op;
use asm::data::literal::Addr;
#[derive(Clone, Debug)]
pub struct Program {
ops: Vec<Op>,
}
impl Program {
pub fn new(ops : Vec<Op>) -> Self {
Self {
ops,
}
}
pub fn read(&self, addr: Addr) -> &Op {
if addr.0 >= self.ops.len() as u64 {
&Op::Nop
} else {
&self.ops[addr.0 as usize]
}
}
}