Make environment generic and adapt closures
Added unit test
This commit is contained in:
Regular → Executable
+3
-2
@@ -2,6 +2,7 @@ use core::fmt;
|
||||
use std::fmt::Display;
|
||||
use std::ops::{Add, Div, Mul, Not, Rem, Sub};
|
||||
|
||||
use crate::backend::environment::Environment;
|
||||
use crate::common::lox_result::{runtime_error, LoxResult};
|
||||
use crate::{
|
||||
backend::environment::EnvironmentStack,
|
||||
@@ -312,7 +313,7 @@ pub struct LoxFunction {
|
||||
pub parameters: Vec<(String, String)>,
|
||||
pub return_type: Option<String>,
|
||||
pub body: AstNode<Stmt>,
|
||||
pub closure: Option<EnvironmentStack>,
|
||||
pub closure: Option<EnvironmentStack<BaseValue>>,
|
||||
pub guard: Option<Box<Expr>>,
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ impl LoxFunction {
|
||||
pub fn new(
|
||||
parameters: Vec<(String, String)>,
|
||||
body: AstNode<Stmt>,
|
||||
closure: Option<EnvironmentStack>,
|
||||
closure: Option<EnvironmentStack<BaseValue>>,
|
||||
guard: Option<Box<Expr>>,
|
||||
) -> Self {
|
||||
LoxFunction {
|
||||
|
||||
Reference in New Issue
Block a user