Extend frame a bit
This commit is contained in:
10
src/frame.rs
10
src/frame.rs
@@ -4,7 +4,7 @@ use stack::Stack;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
pub stack: Stack,
|
pub stack: Stack,
|
||||||
locals: Vec<i32>,
|
pub locals: Vec<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Frame {
|
impl Frame {
|
||||||
@@ -18,6 +18,14 @@ impl Frame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
self.locals.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.locals.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get(&self, offset: usize) -> Result<i32> {
|
pub fn get(&self, offset: usize) -> Result<i32> {
|
||||||
if offset >= self.locals.len() {
|
if offset >= self.locals.len() {
|
||||||
return Err("Local variable out of range");
|
return Err("Local variable out of range");
|
||||||
|
|||||||
Reference in New Issue
Block a user