39 lines
822 B
Rust
39 lines
822 B
Rust
use crate::type_info::TypeInfo;
|
|
use dvm_lib::instruction::Location;
|
|
use std::fmt::{Display, Formatter};
|
|
use std::rc::Rc;
|
|
|
|
pub struct IrParameter {
|
|
name: Rc<str>,
|
|
type_info: TypeInfo,
|
|
stack_offset: isize,
|
|
}
|
|
|
|
impl IrParameter {
|
|
pub fn new(name: &str, type_info: TypeInfo, stack_offset: isize) -> Self {
|
|
Self {
|
|
name: name.into(),
|
|
type_info,
|
|
stack_offset,
|
|
}
|
|
}
|
|
|
|
pub fn type_info(&self) -> &TypeInfo {
|
|
&self.type_info
|
|
}
|
|
|
|
pub fn stack_offset(&self) -> isize {
|
|
self.stack_offset
|
|
}
|
|
|
|
pub fn as_location(&self) -> Location {
|
|
Location::StackFrameOffset(self.stack_offset)
|
|
}
|
|
}
|
|
|
|
impl Display for IrParameter {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", self.name)
|
|
}
|
|
}
|