chore: cargo fmt
This commit is contained in:
@@ -97,7 +97,9 @@ impl Compile for ir::Thunk {
|
|||||||
|
|
||||||
impl Compile for ir::Attrs {
|
impl Compile for ir::Attrs {
|
||||||
fn compile(self, comp: &mut Compiler) {
|
fn compile(self, comp: &mut Compiler) {
|
||||||
comp.push(OpCode::AttrSet { cap: self.stcs.len() + self.dyns.len() });
|
comp.push(OpCode::AttrSet {
|
||||||
|
cap: self.stcs.len() + self.dyns.len(),
|
||||||
|
});
|
||||||
for stc in self.stcs {
|
for stc in self.stcs {
|
||||||
stc.1.compile(comp);
|
stc.1.compile(comp);
|
||||||
if !self.rec {
|
if !self.rec {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
use std::hash::Hash;
|
|
||||||
|
|
||||||
use hashbrown::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
|
|
||||||
use derive_more::Constructor;
|
use derive_more::Constructor;
|
||||||
@@ -25,7 +23,9 @@ impl<'vm> AttrSet<'vm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_capacity(cap: usize) -> Self {
|
pub fn with_capacity(cap: usize) -> Self {
|
||||||
AttrSet { data: HashMap::with_capacity(cap) }
|
AttrSet {
|
||||||
|
data: HashMap::with_capacity(cap),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_attr_force(&mut self, sym: usize, val: Value<'vm>) {
|
pub fn push_attr_force(&mut self, sym: usize, val: Value<'vm>) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
use hashbrown::HashSet;
|
||||||
use std::cell::OnceCell;
|
use std::cell::OnceCell;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use hashbrown::HashSet;
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::rc::Rc;
|
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::ty::internal::{AttrSet, Value};
|
use crate::ty::internal::{AttrSet, Value};
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ impl<'vm> Env<'vm> {
|
|||||||
|
|
||||||
pub fn lookup(&self, symbol: usize) -> Option<Value<'vm>> {
|
pub fn lookup(&self, symbol: usize) -> Option<Value<'vm>> {
|
||||||
if let Some(val) = self.map.get(&symbol).cloned() {
|
if let Some(val) = self.map.get(&symbol).cloned() {
|
||||||
return Some(val)
|
return Some(val);
|
||||||
}
|
}
|
||||||
self.last.as_ref().map(|env| env.lookup(symbol)).flatten()
|
self.last.as_ref().map(|env| env.lookup(symbol)).flatten()
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,6 @@ impl<'vm> Env<'vm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn enter(self, new: impl Iterator<Item = (usize, Value<'vm>)>) -> Self {
|
pub fn enter(self, new: impl Iterator<Item = (usize, Value<'vm>)>) -> Self {
|
||||||
/* let mut map = self.map.clone();
|
|
||||||
for (k, v) in new {
|
|
||||||
map.insert_mut(k, v);
|
|
||||||
} */
|
|
||||||
let map = Rc::new(new.collect());
|
let map = Rc::new(new.collect());
|
||||||
let last = Some(
|
let last = Some(
|
||||||
Env {
|
Env {
|
||||||
@@ -42,22 +38,21 @@ impl<'vm> Env<'vm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn enter_with(self, new: Rc<AttrSet<'vm>>) -> Self {
|
pub fn enter_with(self, new: Rc<AttrSet<'vm>>) -> Self {
|
||||||
/* let mut map = self.map.clone();
|
let map = Rc::new(
|
||||||
for (k, v) in new.as_inner().iter() {
|
new.as_inner()
|
||||||
let v = if let Value::Builtins = v {
|
.iter()
|
||||||
Value::AttrSet(new.clone())
|
.map(|(&k, v)| {
|
||||||
} else {
|
(
|
||||||
v.clone()
|
k,
|
||||||
};
|
if let Value::Builtins = v {
|
||||||
map.insert_mut(k.clone(), v);
|
Value::AttrSet(new.clone())
|
||||||
} */
|
} else {
|
||||||
let map = Rc::new(new.as_inner().iter().map(|(&k, v)| {
|
v.clone()
|
||||||
(k, if let Value::Builtins = v {
|
},
|
||||||
Value::AttrSet(new.clone())
|
)
|
||||||
} else {
|
})
|
||||||
v.clone()
|
.collect(),
|
||||||
})
|
);
|
||||||
}).collect());
|
|
||||||
let last = Some(
|
let last = Some(
|
||||||
Env {
|
Env {
|
||||||
last: self.last.clone(),
|
last: self.last.clone(),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::cell::RefCell;
|
|
||||||
use hashbrown::{HashMap, HashSet};
|
use hashbrown::{HashMap, HashSet};
|
||||||
|
use std::cell::RefCell;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
use crate::builtins::env;
|
use crate::builtins::env;
|
||||||
|
|||||||
Reference in New Issue
Block a user