use std::sync::Arc;
use serde::{Deserialize, Serialize};
use crate::{model::Graph, runtime::{instruction::{Instruction, Instructions}, instructions::FN_RETURN, proc::ProcEnv, Error}};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RetIns {
pub expr: Option<Arc<dyn Instruction>>
}
#[typetag::serde(name = "RetIns")]
impl Instruction for RetIns {
fn exec(&self, _env: &mut ProcEnv, _graph: &mut Graph) -> Result<Option<Instructions>, Error> {
let mut instructions = Instructions::default();
if let Some(ins) = &self.expr {
instructions.push(ins.clone());
}
instructions.push(FN_RETURN.clone());
Ok(Some(instructions))
}
}