looklook 0.7.0

Descriptive signal synthesiser.
// Copyright 2026 Gabriel Bjørnager Jensen.
//
// This file is part of LOOKLOOK.
//
// LOOKLOOK is free software: you can redistribute it and/or modify it under the
// terms of the GNU Affero General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later ver-
// sion.
//
// LOOKLOOK is distributed in the hope that it will be useful, but WITHOUT ANY WAR-
// RANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along
// with LOOKLOOK. If not, see <https://www.gnu.org/licenses/>.

//! The [`Op`] type.

use crate::vm::{Int, Vm};

/// An instructed operation.
#[derive(Copy, Debug)]
#[derive_const(Clone)]
pub struct Op {
	/// The instruction address.
	addr: Int<4>,

	/// The operator.
	f: fn(&mut Vm),
}

impl Op {
	/// Constructs a new operation.
	#[inline]
	#[must_use]
	pub const fn new(addr: Int<4>, f: fn(&mut Vm)) -> Self {
		Self { addr, f }
	}

	/// Executes the operation.
	#[inline]
	pub fn exec(&self, vm: &mut Vm) {
		(self.f)(vm)
	}

	/// Retrieves the instruction address.
	#[inline]
	#[must_use]
	pub const fn addr(&self) -> Int<4> {
		self.addr
	}
}