automatically heapify captured variables

This commit is contained in:
Moritz Gmeiner 2024-09-01 23:15:36 +02:00
commit 8e847847a6
5 changed files with 136 additions and 40 deletions

View file

@ -3,16 +3,16 @@ use std::rc::Rc;
use rlox2_frontend::parser::Stmt;
use crate::value::HeapedValue;
use crate::environment::{ClosureScope, HeapedValue};
use super::environment::{Environment, Scope};
use super::environment::Environment;
use super::interpret::EvalResult;
use super::{Runtime, Value};
#[derive(Debug, Clone)]
pub struct LoxFunction {
name: Box<str>,
closure: Scope,
closure: ClosureScope,
param_names: Vec<Box<str>>,
body: Box<Stmt>,
}
@ -20,7 +20,7 @@ pub struct LoxFunction {
impl LoxFunction {
pub fn new(
name: impl Into<Box<str>>,
closure: Scope,
closure: ClosureScope,
param_names: Vec<Box<str>>,
body: Stmt,
) -> Rc<Self> {
@ -39,7 +39,7 @@ impl LoxFunction {
&self.name
}
pub fn closure(&self) -> &Scope {
pub fn closure(&self) -> &ClosureScope {
&self.closure
}