Actually made "this" work in the interpreter

This commit is contained in:
Emmanuel BENOîT 2023-01-10 09:03:57 +01:00
parent 3e4aea0d78
commit 16151bd326
4 changed files with 27 additions and 89 deletions
src/interpreter

View file

@ -1,4 +1,4 @@
use std::fmt::Display;
use std::{fmt::Display, cell::RefMut};
use itertools::izip;
@ -32,8 +32,17 @@ impl Function {
}
}
pub(super) fn name(&self) -> Option<&Token> {
self.name.as_ref()
pub(super) fn copy_with_child_env(&self) -> Self {
Self {
name: self.name.clone(),
params: self.params.clone(),
body: self.body.clone(),
env: Environment::create_child(&self.env),
}
}
pub(super) fn env(&self) -> RefMut<Environment> {
self.env.borrow_mut()
}
}