use super::*;
pub(crate) struct AddressCache {
pub read_mode_end: Address,
pub compile_end: Address,
pub else_statement: Address,
pub end_statement: Address,
pub break_statement: Address,
pub begin_statement: Address,
pub loop_statement: Address,
pub noop_operation: Address,
}
impl AddressCache {
pub fn uninitalized() -> Self {
Self {
read_mode_end: Address::default(),
compile_end: Address::default(),
else_statement: Address::default(),
end_statement: Address::default(),
break_statement: Address::default(),
begin_statement: Address::default(),
loop_statement: Address::default(),
noop_operation: Address::default(),
}
}
pub fn initialize<State>(interpreter: &mut Interpreter<State>) {
let mut cache = Self::uninitalized();
cache.read_mode_end = interpreter.get_address("]");
cache.compile_end = interpreter.get_address(";");
cache.else_statement = interpreter.get_address("else");
cache.end_statement = interpreter.get_address("end");
cache.break_statement = interpreter.get_address("break");
cache.begin_statement = interpreter.get_address("begin");
cache.loop_statement = interpreter.get_address("loop");
cache.noop_operation = interpreter.get_address(".");
interpreter.address_cache = cache;
}
}