use crate::value::Value;
use indexmap::IndexMap;
use std::collections::HashSet;
#[derive(Debug, Clone)]
pub struct Frame {
pub locals: IndexMap<String, Value>,
pub last_value: Value,
pub is_function_frame: bool,
pub is_isolated_scope: bool,
pub forgotten: HashSet<String>,
}
impl Frame {
pub fn new() -> Self {
Self {
locals: IndexMap::new(),
last_value: Value::Null,
is_function_frame: false,
is_isolated_scope: false,
forgotten: HashSet::new(),
}
}
pub fn function_frame() -> Self {
Self {
locals: IndexMap::new(),
last_value: Value::Null,
is_function_frame: true,
is_isolated_scope: true,
forgotten: HashSet::new(),
}
}
pub fn isolated_scope() -> Self {
Self {
locals: IndexMap::new(),
last_value: Value::Null,
is_function_frame: false,
is_isolated_scope: true,
forgotten: HashSet::new(),
}
}
}
impl Default for Frame {
fn default() -> Self {
Self::new()
}
}