deimos-lang/dvm-lib/src/vm/function.rs

35 lines
689 B
Rust

use crate::instruction::Instruction;
use std::rc::Rc;
pub struct Function {
name: Rc<str>,
instructions: Vec<Instruction>,
register_count: usize,
}
impl Function {
pub fn new(name: &str, instructions: Vec<Instruction>, register_count: usize) -> Self {
Self {
name: name.into(),
instructions,
register_count,
}
}
pub fn name(&self) -> &str {
&self.name
}
pub fn name_owned(&self) -> Rc<str> {
self.name.clone()
}
pub fn instructions(&self) -> &Vec<Instruction> {
&self.instructions
}
pub fn register_count(&self) -> usize {
self.register_count
}
}