mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
automatically heapify captured variables
This commit is contained in:
parent
9d447d9266
commit
8e847847a6
5 changed files with 136 additions and 40 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue