47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
use crate::vm::function::DvmFunction;
|
|
use crate::vm::virtual_method::DmVirtualMethod;
|
|
use std::rc::Rc;
|
|
|
|
#[derive(Debug, Eq)]
|
|
pub struct DvmInterface {
|
|
fqn: String,
|
|
static_functions: Vec<Rc<DvmFunction>>,
|
|
virtual_methods: Vec<DmVirtualMethod>,
|
|
}
|
|
|
|
impl PartialEq for DvmInterface {
|
|
fn eq(&self, other: &Self) -> bool {
|
|
self.fqn == other.fqn
|
|
}
|
|
}
|
|
|
|
impl DvmInterface {
|
|
pub fn new(fqn: &str) -> Self {
|
|
DvmInterface {
|
|
fqn: fqn.to_string(),
|
|
static_functions: Vec::new(),
|
|
virtual_methods: Vec::new(),
|
|
}
|
|
}
|
|
|
|
pub fn fqn(&self) -> &str {
|
|
self.fqn.as_str()
|
|
}
|
|
|
|
pub fn add_function(&mut self, dm_fn: DvmFunction) {
|
|
self.static_functions.push(Rc::new(dm_fn));
|
|
}
|
|
|
|
pub fn functions(&self) -> &Vec<Rc<DvmFunction>> {
|
|
&self.static_functions
|
|
}
|
|
|
|
pub fn add_method(&mut self, dm_virtual_method: DmVirtualMethod) {
|
|
self.virtual_methods.push(dm_virtual_method);
|
|
}
|
|
|
|
pub fn virtual_methods(&self) -> &Vec<DmVirtualMethod> {
|
|
&self.virtual_methods
|
|
}
|
|
}
|