Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
dc578d1
Add default rustfmt config
matthiasbeyer Mar 10, 2023
77d74f6
Run cargo-fmt
matthiasbeyer Mar 10, 2023
c97f558
Run clippy-fix: Mark variables as unused
matthiasbeyer Mar 10, 2023
d80876d
Run clippy-fix: Remove "mut" keyword where unnecessary
matthiasbeyer Mar 10, 2023
37a989e
Run clippy-fix: Remove unused imports
matthiasbeyer Mar 10, 2023
98cab60
Fix clippy: Remove needless borrow
matthiasbeyer Mar 10, 2023
28a837f
Fix clippy: Type with len() fn should also have is_empty()
matthiasbeyer Mar 10, 2023
415ddc4
Fix clippy: use to_string() instead of format!() macro
matthiasbeyer Mar 10, 2023
c00f062
Fix clippy: Use is_empty() instead of len() == 0
matthiasbeyer Mar 10, 2023
c43085f
Fix clippy: Remove needless borrow
matthiasbeyer Mar 10, 2023
180e7db
Fix clippy: Replace format!() with to_string() call
matthiasbeyer Mar 10, 2023
8de1deb
Fix clippy: Mask unused variable
matthiasbeyer Mar 10, 2023
1bb82f0
Fix clippy: Mask unused variable
matthiasbeyer Mar 10, 2023
5acbdbc
Fix clippy: Use is_empty() instead of len() > 0
matthiasbeyer Mar 10, 2023
775e025
Fix clippy: Remove unnecessary keyword "return"
matthiasbeyer Mar 10, 2023
ac8960f
Fix clippy: Remove unnecessary borrow
matthiasbeyer Mar 10, 2023
8ff143b
Fix clippy: Remove unnecessary clone()
matthiasbeyer Mar 10, 2023
d2998e0
Fix clippy: Elide lifetimes
matthiasbeyer Mar 10, 2023
1e1d359
Fix clippy: Replace into_iter() with iter()
matthiasbeyer Mar 10, 2023
9630ce3
Fix clippy: Remove unnecessary clone()
matthiasbeyer Mar 10, 2023
3ff7f42
Fix clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
21472c9
Fix: Do not use ? operator when we can easily map()
matthiasbeyer Mar 10, 2023
0fb0f52
Clippy: Allow result_unit_err lint for now
matthiasbeyer Mar 10, 2023
5706371
Clippy: Allow type_complexity lint for now
matthiasbeyer Mar 10, 2023
9398920
Fix clippy: Remove unnecessary borrow
matthiasbeyer Mar 10, 2023
830f22d
Fix clippy: Don't pass unit to function
matthiasbeyer Mar 10, 2023
efdd42c
Fix clippy: Use try_for_each instead of collecting to Result
matthiasbeyer Mar 10, 2023
0553ddb
Fix clippy: Don't compare to Ok(()), is is_ok()
matthiasbeyer Mar 10, 2023
99609ae
Fix clippy: Don't use else-if when logical OR is possible
matthiasbeyer Mar 10, 2023
05fa58d
Fix clippy: don't negate is_ok() result, use is_err()
matthiasbeyer Mar 10, 2023
2c47232
Fix clippy: Remove unnecessary clone()
matthiasbeyer Mar 10, 2023
b415853
Fix clippy: Remove unnecessary keyword "return"
matthiasbeyer Mar 10, 2023
fddc74f
Fix clippy: Replace .iter().next() with .first()
matthiasbeyer Mar 10, 2023
3e1ce9c
Fix clippy: Simplify constructor
matthiasbeyer Mar 10, 2023
4c02daf
Fix clippy: Use field initialization from variable directly
matthiasbeyer Mar 10, 2023
50f6357
Fix clippy: Remove unnecessary dereference
matthiasbeyer Mar 10, 2023
92bba89
Fix clippy: Remove unnecessary closures
matthiasbeyer Mar 10, 2023
eb6473c
Clippy: Allow never_loop in two instances
matthiasbeyer Mar 10, 2023
962d110
Fix clippy: Replace format!() with .to_string()
matthiasbeyer Mar 10, 2023
8739f44
Fix clippy: Replace format!() with .to_string()
matthiasbeyer Mar 10, 2023
055dbe3
Fix clippy: Replace len() > 0 with is_empty()
matthiasbeyer Mar 10, 2023
7677153
Fix clippy: Remove unnecessary borrow
matthiasbeyer Mar 10, 2023
1afb7f3
Fix clippy: Remove unused variable
matthiasbeyer Mar 10, 2023
9e447ba
Fix clippy: Replace format!() with .to_string()
matthiasbeyer Mar 10, 2023
77e339d
Fix clippy: Replace matching with .is_some()
matthiasbeyer Mar 10, 2023
3d68fdd
Fix clippy: Remove unused variable
matthiasbeyer Mar 10, 2023
f09b7f1
Fix clippy: Remove unused function param
matthiasbeyer Mar 10, 2023
ff2f408
Fix clippy: Remove unused function param
matthiasbeyer Mar 10, 2023
62029da
Fix clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
efeec63
Fix clippy: mask unused function parameter
matthiasbeyer Mar 10, 2023
273f0fc
Fix clippy: mask unused function parameter
matthiasbeyer Mar 10, 2023
d64fc63
Fix clippy: Remove unnecessary reference
matthiasbeyer Mar 10, 2023
4ff0fd7
Fix clippy: Replace map with if-let
matthiasbeyer Mar 10, 2023
e5e1bb8
Fix clippy: Use any() instead of iter()...is_some()
matthiasbeyer Mar 10, 2023
54a5c3e
Fix clippy: Collapse if
matthiasbeyer Mar 10, 2023
20e4db1
Fix clippy: Remove unnecessary binding
matthiasbeyer Mar 10, 2023
c81a5f5
Fix clippy: Remove param that's only used in recursion
matthiasbeyer Mar 10, 2023
c58e0e5
Fix clippy: Replace map with if-let
matthiasbeyer Mar 10, 2023
c304a2e
Fix clippy: Replace len() == 0 with is_empty()
matthiasbeyer Mar 10, 2023
69b2e54
Fix clippy: Replace map with if-let
matthiasbeyer Mar 10, 2023
e234691
Fix clippy: Replace len() > 0 with ! is_empty()
matthiasbeyer Mar 10, 2023
564742e
Fix clippy: Replace manual matches!() with macro
matthiasbeyer Mar 10, 2023
79fcbad
Fix clippy: Replace constructor without params with Default impl
matthiasbeyer Mar 10, 2023
68bb4d1
Fix clippy: Remove unnecessary clone()
matthiasbeyer Mar 10, 2023
32b8653
Fix clippy: Replace format!() with to_string()
matthiasbeyer Mar 10, 2023
36cab35
Fix clippy: Remove unreachable patterns
matthiasbeyer Mar 10, 2023
d1272d6
Fix clippy: Remove feature gate that has been stabelized
matthiasbeyer Mar 10, 2023
2e2ec7c
Fix clippy: Remove unnecessary clone() calls
matthiasbeyer Mar 10, 2023
1026b30
Fix clippy: Remove lifetimes taht are infered
matthiasbeyer Mar 10, 2023
f942661
Fix clippy: Remove fn param that is only used in recursion
matthiasbeyer Mar 10, 2023
4b64825
Fix clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
ebe3a84
Fix clippy: Replace format!() with to_string()
matthiasbeyer Mar 10, 2023
37ff79d
Fix clippy: Remove unnecesary binding
matthiasbeyer Mar 10, 2023
11e4626
Fix clippy: Remove unnecesary binding
matthiasbeyer Mar 10, 2023
7586ddf
Fix clippy: Replace find().is_{some,none}() with any()
matthiasbeyer Mar 10, 2023
c5e1192
Fix clippy: Replace len() == 0 with is_empty()
matthiasbeyer Mar 10, 2023
fdb78a5
Fix clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
c4f710c
Fix clippy: Remove unnecessary reference
matthiasbeyer Mar 10, 2023
a7b6444
Fix clippy: Replace format!() with to_string()
matthiasbeyer Mar 10, 2023
374b239
Fix clippy: Remove unnecessary call to Result::ok()
matthiasbeyer Mar 10, 2023
57dd433
Fix clippy: Replace into_iter() with iter()
matthiasbeyer Mar 10, 2023
539ab56
Fix clippy: Replace len() > 0 with ! is_empty()
matthiasbeyer Mar 10, 2023
f2f8206
Fix clippy: Remove unnecessary clone()
matthiasbeyer Mar 10, 2023
430e975
Fix clippy: Replace len() == 0 with is_empty()
matthiasbeyer Mar 10, 2023
682f1e2
Fix clippy: Replace into_iter() with iter()
matthiasbeyer Mar 10, 2023
722649c
Fix clippy: Remove unused function param
matthiasbeyer Mar 10, 2023
2084bcb
Fix clippy: Replace find().is_some() with .any()
matthiasbeyer Mar 10, 2023
84c1774
Fix clippy: Remove unused fn Scope::with()
matthiasbeyer Mar 10, 2023
ed5d48f
Fix clippy: Remove unused fn Scope::without_basin()
matthiasbeyer Mar 10, 2023
60ef0e9
Fix clippy: Remove unused fn Infer::iter_effects()
matthiasbeyer Mar 10, 2023
05ca379
Fix clippy: Remove unused member Datas::alias_lut
matthiasbeyer Mar 10, 2023
b1c0fea
Fix: Allow dead code here
matthiasbeyer Mar 10, 2023
626281d
Fix clippy: Remove unreachable pattern
matthiasbeyer Mar 10, 2023
47d248d
Fix clippy: Remove unreachable pattern
matthiasbeyer Mar 10, 2023
8a0fd25
Fix clippy: Remove unreachable pattern
matthiasbeyer Mar 10, 2023
92f6e2f
Fix clippy: Remove feature gate that has been stabelized
matthiasbeyer Mar 10, 2023
91bf3ef
Fix clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
770a1f4
Fix clippy: Use unwrap_or_default()
matthiasbeyer Mar 10, 2023
7bad21b
Fix Clippy: Remove unnecessary closure
matthiasbeyer Mar 10, 2023
4014c39
Fix clippy: Remove unnecessary clone
matthiasbeyer Mar 10, 2023
2ca9618
Fix clippy: Replace or_else() with or()
matthiasbeyer Mar 10, 2023
6e28f6f
Fix clippy: Replace format!() with to_string()
matthiasbeyer Mar 10, 2023
85317ee
Fix clippy: Replace manual matches!() with macro
matthiasbeyer Mar 10, 2023
03514df
Fix clippy: Rename Ident::as_ref()
matthiasbeyer Mar 10, 2023
b89ca84
Clippy: Allow type_complexity lint for now
matthiasbeyer Mar 10, 2023
09daafb
Allow dead code for now
matthiasbeyer Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 177 additions & 104 deletions analysis/src/class.rs

Large diffs are not rendered by default.

776 changes: 516 additions & 260 deletions analysis/src/concrete.rs

Large diffs are not rendered by default.

742 changes: 458 additions & 284 deletions analysis/src/context.rs

Large diffs are not rendered by default.

58 changes: 42 additions & 16 deletions analysis/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub struct Datas {
// TODO: Don't use `Result`
name_lut: HashMap<Ident, (Span, Result<DataId, AliasId>, GenScopeId)>,
cons_lut: HashMap<Ident, (Span, DataId)>,
alias_lut: HashMap<Ident, Alias>,
datas: Vec<(Span, Option<Data>, GenScopeId, Ident)>,
aliases: Vec<(Span, Option<Alias>, GenScopeId)>,
pub lang: Lang,
Expand All @@ -49,7 +48,7 @@ impl Datas {
}

pub fn iter_aliases(&self) -> impl Iterator<Item = AliasId> {
(0..self.aliases.len()).map(|i| AliasId(i))
(0..self.aliases.len()).map(AliasId)
}

pub fn data_gen_scope(&self, data: DataId) -> GenScopeId {
Expand Down Expand Up @@ -94,27 +93,41 @@ impl Datas {
}

pub fn get_alias(&self, alias: AliasId) -> Option<&Alias> {
self.aliases[alias.0]
.1
.as_ref()
self.aliases[alias.0].1.as_ref()
}

pub fn get_alias_span(&self, alias: AliasId) -> Span {
self.aliases[alias.0].0
}

pub fn declare_data(&mut self, name: SrcNode<Ident>, gen_scope: GenScopeId, attr: &[SrcNode<ast::Attr>]) -> Result<DataId, Error> {
pub fn declare_data(
&mut self,
name: SrcNode<Ident>,
gen_scope: GenScopeId,
attr: &[SrcNode<ast::Attr>],
) -> Result<DataId, Error> {
let id = DataId(self.datas.len(), *name);
if let Err(old) = self.name_lut.try_insert(*name, (name.span(), Ok(id), gen_scope)) {
Err(Error::DuplicateTypeName(*name, old.entry.get().0, name.span()))
if let Err(old) = self
.name_lut
.try_insert(*name, (name.span(), Ok(id), gen_scope))
{
Err(Error::DuplicateTypeName(
*name,
old.entry.get().0,
name.span(),
))
} else {
if let Some(lang) = attr
.iter()
.find(|a| &**a.name == "lang")
.and_then(|a| a.args.as_ref())
{
if lang.iter().find(|a| &**a.name == "go").is_some() { self.lang.go = Some(id); }
if lang.iter().find(|a| &**a.name == "bool").is_some() { self.lang.r#bool = Some(id); }
if lang.iter().any(|a| &**a.name == "go") {
self.lang.go = Some(id);
}
if lang.iter().any(|a| &**a.name == "bool") {
self.lang.r#bool = Some(id);
}
}

self.datas.push((name.span(), None, gen_scope, *name));
Expand All @@ -125,13 +138,22 @@ impl Datas {
pub fn check_lang_items(&self) -> Vec<Error> {
let mut errors = Vec::new();

if self.lang.go.is_none() { errors.push(Error::MissingLangItem("go")); }
if self.lang.r#bool.is_none() { errors.push(Error::MissingLangItem("bool")); }
if self.lang.go.is_none() {
errors.push(Error::MissingLangItem("go"));
}
if self.lang.r#bool.is_none() {
errors.push(Error::MissingLangItem("bool"));
}

errors
}

pub fn declare_alias(&mut self, name: Ident, span: Span, gen_scope: GenScopeId) -> Result<AliasId, Error> {
pub fn declare_alias(
&mut self,
name: Ident,
span: Span,
gen_scope: GenScopeId,
) -> Result<AliasId, Error> {
let id = AliasId(self.aliases.len());
if let Err(old) = self.name_lut.try_insert(name, (span, Err(id), gen_scope)) {
Err(Error::DuplicateTypeName(name, old.entry.get().0, span))
Expand All @@ -141,15 +163,19 @@ impl Datas {
}
}

pub fn define_data(&mut self, id: DataId, span: Span, data: Data) -> Result<(), Vec<Error>> {
pub fn define_data(&mut self, id: DataId, _span: Span, data: Data) -> Result<(), Vec<Error>> {
let mut errors = Vec::new();
for (cons, _) in &data.cons {
if let Err(old) = self.cons_lut.try_insert(**cons, (cons.span(), id)) {
errors.push(Error::DuplicateConsName(**cons, old.entry.get().0, cons.span()));
errors.push(Error::DuplicateConsName(
**cons,
old.entry.get().0,
cons.span(),
));
}
}
self.datas[id.0].1 = Some(data);
if errors.len() == 0 {
if errors.is_empty() {
Ok(())
} else {
Err(errors)
Expand Down
30 changes: 17 additions & 13 deletions analysis/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ impl<'hir, 'a> dot::Labeller<'a, Node, Edge> for CallGraph<'hir> {

impl<'hir, 'a> dot::GraphWalk<'a, Node, Edge> for CallGraph<'hir> {
fn nodes(&'a self) -> dot::Nodes<'a, Node> {
self.ctx.defs
self.ctx
.defs
.iter()
.filter_map(|(id, def)| if def.attr.iter().find(|a| &**a.name == "util").is_none() {
Some((id, *def.name))
} else {
None
.filter_map(|(id, def)| {
if !def.attr.iter().any(|a| &**a.name == "util") {
Some((id, *def.name))
} else {
None
}
})
.collect()
}
fn edges(&'a self) -> dot::Edges<'a, Edge> {
fn fetch_edge(ctx: &Context, parent: Node, expr: &TyExpr, edges: &mut HashSet<Edge>) {
if let hir::Expr::Global(global) = &**expr {
let def = ctx.defs.get(global.0);
if def.attr.iter().find(|a| &**a.name == "util").is_none() {
edges.insert((
parent,
(global.0, *def.name),
));
if !def.attr.iter().any(|a| &**a.name == "util") {
edges.insert((parent, (global.0, *def.name)));
}
}

Expand All @@ -63,13 +63,17 @@ impl<'hir, 'a> dot::GraphWalk<'a, Node, Edge> for CallGraph<'hir> {

let mut edges = HashSet::new();
for (id, def) in self.ctx.defs.iter() {
if def.attr.iter().find(|a| &**a.name == "util").is_none() {
if !def.attr.iter().any(|a| &**a.name == "util") {
let parent = (id, *def.name);
fetch_edge(self.ctx, parent, def.body.as_ref().unwrap(), &mut edges);
}
}
edges.into_iter().collect()
}
fn source(&self, e: &Edge) -> Node { e.0 }
fn target(&self, e: &Edge) -> Node { e.1 }
fn source(&self, e: &Edge) -> Node {
e.0
}
fn target(&self, e: &Edge) -> Node {
e.1
}
}
9 changes: 3 additions & 6 deletions analysis/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ impl Defs {
if let Err(old) = self.lut.try_insert(name, (span, id)) {
Err(Error::DuplicateDefName(name, old.entry.get().0, span))
} else {
if let Some(lang) = def.attr
if let Some(_lang) = def
.attr
.iter()
.find(|a| &**a.name == "lang")
.and_then(|a| a.args.as_ref())
Expand All @@ -68,11 +69,7 @@ impl Defs {
}

pub fn check_lang_items(&self) -> Vec<Error> {
let mut errors = Vec::new();

// if self.lang.io_unit.is_none() { errors.push(Error::MissingLangItem("io_unit")); }

errors
Vec::new()
}

pub fn define_body(&mut self, id: DefId, expr: TyExpr) {
Expand Down
32 changes: 22 additions & 10 deletions analysis/src/effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ impl Effects {
}

pub fn iter(&self) -> impl Iterator<Item = (EffectDeclId, &EffectDecl)> {
self.effect_decls.iter().enumerate().map(|(i, eff)| (EffectDeclId(i, *eff.name), eff))
self.effect_decls
.iter()
.enumerate()
.map(|(i, eff)| (EffectDeclId(i, *eff.name), eff))
}

// pub fn iter(&self) -> impl Iterator<Item = (EffectDeclId, &EffectDecl)> {
Expand All @@ -65,9 +68,14 @@ impl Effects {
let id = EffectDeclId(self.effect_decls.len(), *eff.name);
let span = eff.name.span();
if let Err(old) = self.lut.try_insert(*eff.name, (span, Ok(id))) {
Err(Error::DuplicateEffectDecl(*eff.name, old.entry.get().0, span))
Err(Error::DuplicateEffectDecl(
*eff.name,
old.entry.get().0,
span,
))
} else {
if let Some(lang) = eff.attr
if let Some(_lang) = eff
.attr
.iter()
.find(|a| &**a.name == "lang")
.and_then(|a| a.args.as_ref())
Expand All @@ -86,27 +94,31 @@ impl Effects {
let id = EffectAliasId(self.effect_aliases.len());
let span = alias.name.span();
if let Err(old) = self.lut.try_insert(*alias.name, (span, Err(id))) {
Err(Error::DuplicateEffectDecl(*alias.name, old.entry.get().0, span))
Err(Error::DuplicateEffectDecl(
*alias.name,
old.entry.get().0,
span,
))
} else {
self.effect_aliases.push(alias);
Ok(id)
}
}

pub fn check_lang_items(&self) -> Vec<Error> {
let mut errors = Vec::new();

// if self.lang.not.is_none() { errors.push(Error::MissingLangItem("not")); }

errors
Vec::new()
}

pub fn define_send_recv(&mut self, id: EffectDeclId, send: TyId, recv: TyId) {
self.effect_decls[id.0].send = Some(send);
self.effect_decls[id.0].recv = Some(recv);
}

pub fn define_alias_effects(&mut self, id: EffectAliasId, effs: Vec<(SrcNode<EffectDeclId>, Vec<TyId>)>) {
pub fn define_alias_effects(
&mut self,
id: EffectAliasId,
effs: Vec<(SrcNode<EffectDeclId>, Vec<TyId>)>,
) {
self.effect_aliases[id.0].effects = Some(effs);
}
}
Loading