mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
rustfmt with nightly options
also some other minor formatting changes
This commit is contained in:
parent
671f7d5306
commit
f8b59e6034
17 changed files with 91 additions and 291 deletions
|
|
@ -3,16 +3,15 @@ use std::rc::Rc;
|
|||
use rlox2_frontend::parser::{BinaryOp, Expr, Literal, LogicalOp, Stmt, UnaryOp};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use super::environment::Environment;
|
||||
use super::{LoxFunction, Runtime, Value};
|
||||
use crate::error::RuntimeError;
|
||||
use crate::function::LoxExternFunction;
|
||||
use crate::{LoxClass, LoxReference};
|
||||
|
||||
use super::environment::Environment;
|
||||
use super::{LoxFunction, Runtime, Value};
|
||||
|
||||
pub type EvalResult<T> = Result<T, RuntimeError>;
|
||||
|
||||
/*====================================================================================================================*/
|
||||
// =================================================================================================
|
||||
|
||||
pub fn execute(statement: Stmt, runtime: &mut Runtime) -> Result<(), RuntimeError> {
|
||||
let mut env = Environment::new(runtime);
|
||||
|
|
@ -22,7 +21,7 @@ pub fn execute(statement: Stmt, runtime: &mut Runtime) -> Result<(), RuntimeErro
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/*====================================================================================================================*/
|
||||
// =================================================================================================
|
||||
|
||||
trait Eval {
|
||||
fn eval(&self, env: &mut Environment) -> EvalResult<Value>;
|
||||
|
|
@ -214,6 +213,7 @@ impl Eval for Expr {
|
|||
|
||||
for method_expr in method_exprs.iter() {
|
||||
let method = method_expr.eval(env)?;
|
||||
|
||||
if let Value::Function(ref fun) = method {
|
||||
let name = fun.name().to_owned();
|
||||
methods.insert(name, method);
|
||||
|
|
@ -307,7 +307,7 @@ impl Eval for Stmt {
|
|||
}
|
||||
}
|
||||
|
||||
/*====================================================================================================================*/
|
||||
// =================================================================================================
|
||||
|
||||
pub fn call_fun(fun: Rc<LoxFunction>, env: &mut Environment) -> EvalResult<Value> {
|
||||
let args = env.collect_args();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue