cl-structures::Interned: Change to_ref() from assoc. function to member function
(it's so much nicer)
This commit is contained in:
@@ -86,7 +86,7 @@ impl ConValue {
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn TupleStruct(name: Sym, values: Box<[ConValue]>) -> Self {
|
||||
Self::TupleStruct(Box::new((Sym::to_ref(&name), values)))
|
||||
Self::TupleStruct(Box::new((name.to_ref(), values)))
|
||||
}
|
||||
#[allow(non_snake_case)]
|
||||
pub fn Struct(name: Sym, values: HashMap<Sym, ConValue>) -> Self {
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Callable for Function {
|
||||
return Err(Error::ArgNumber { want: bind.len(), got: args.len() });
|
||||
}
|
||||
if self.is_constructor {
|
||||
return Ok(ConValue::TupleStruct(Box::new((Sym::to_ref(name), args.into()))));
|
||||
return Ok(ConValue::TupleStruct(Box::new((name.to_ref(), args.into()))));
|
||||
}
|
||||
let Some(body) = body else {
|
||||
return Err(Error::NotDefined(*name));
|
||||
|
||||
@@ -89,7 +89,7 @@ impl Interpret for Module {
|
||||
// TODO: Keep modules around somehow, rather than putting them on the stack
|
||||
fn interpret(&self, env: &mut Environment) -> IResult<ConValue> {
|
||||
let Self { name, kind } = self;
|
||||
env.push_frame(Interned::to_ref(name), Default::default());
|
||||
env.push_frame(name.to_ref(), Default::default());
|
||||
let out = match kind {
|
||||
Some(file) => file.interpret(env),
|
||||
None => {
|
||||
@@ -154,7 +154,7 @@ impl Interpret for Enum {
|
||||
fn interpret(&self, env: &mut Environment) -> IResult<ConValue> {
|
||||
let Self { name, variants: kind } = self;
|
||||
if let Some(variants) = kind {
|
||||
env.push_frame(Sym::to_ref(name), Default::default());
|
||||
env.push_frame(name.to_ref(), Default::default());
|
||||
for (idx, Variant { name, kind }) in variants.iter().enumerate() {
|
||||
match kind {
|
||||
VariantKind::Plain => env.insert(*name, Some(ConValue::Int(idx as _))),
|
||||
@@ -223,7 +223,7 @@ impl Interpret for UseTree {
|
||||
let Ok(ConValue::Module(m)) = env.get(*name) else {
|
||||
Err(Error::TypeError)?
|
||||
};
|
||||
env.push_frame(Interned::to_ref(name), *m);
|
||||
env.push_frame(name.to_ref(), *m);
|
||||
let out = get_bindings(tree, env, bindings);
|
||||
env.pop_frame();
|
||||
return out;
|
||||
|
||||
Reference in New Issue
Block a user