added type Attrs = FxHashMap<SmolStr, Value>

This commit is contained in:
Moritz Gmeiner 2024-09-03 16:53:46 +02:00
commit 943528a0db
4 changed files with 14 additions and 9 deletions

View file

@ -1,12 +1,12 @@
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::value::Attrs;
use crate::{LoxClass, LoxReference};
pub type EvalResult<T> = Result<T, RuntimeError>;
@ -206,7 +206,7 @@ impl Eval for Expr {
None => None,
};
let mut methods: FxHashMap<String, Value> = FxHashMap::default();
let mut methods = Attrs::default();
// this is the scope "this" will get injected in
env.enter_scope()?;
@ -215,7 +215,7 @@ impl Eval for Expr {
let method = method_expr.eval(env)?;
if let Value::Function(ref fun) = method {
let name = fun.name().to_owned();
let name = fun.name().into();
methods.insert(name, method);
}
}