44 lines
960 B
Rust
44 lines
960 B
Rust
use crate::vm::instruction::Instruction;
|
|
use crate::vm::source_code_location::SourceCodeLocation;
|
|
|
|
#[derive(Debug)]
|
|
pub struct DvmFunction {
|
|
fqn: String,
|
|
instructions: Vec<Instruction>,
|
|
source_code_location: SourceCodeLocation,
|
|
}
|
|
|
|
impl DvmFunction {
|
|
pub fn new(
|
|
fqn: &str,
|
|
instructions: &[Instruction],
|
|
source_code_location: SourceCodeLocation,
|
|
) -> Self {
|
|
DvmFunction {
|
|
fqn: fqn.to_string(),
|
|
instructions: Vec::from(instructions),
|
|
source_code_location,
|
|
}
|
|
}
|
|
|
|
pub fn fqn(&self) -> &str {
|
|
self.fqn.as_str()
|
|
}
|
|
|
|
pub fn instructions(&self) -> &Vec<Instruction> {
|
|
&self.instructions
|
|
}
|
|
|
|
pub fn source_code_location(&self) -> &SourceCodeLocation {
|
|
&self.source_code_location
|
|
}
|
|
}
|
|
|
|
impl PartialEq for DvmFunction {
|
|
fn eq(&self, other: &Self) -> bool {
|
|
self.fqn == other.fqn
|
|
}
|
|
}
|
|
|
|
impl Eq for DvmFunction {}
|