Refactor analyzer to return impurity
The `Analyzer` is now responsible for determining the purity of `Define` bindings. Previously, this responsibility was left to the caller. Added a new example `design-flaw.myc` to test this change. Updated `soa_series.myc` due to the purity change.
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
(do
|
||||||
|
(do
|
||||||
|
(def x "hh")
|
||||||
|
)
|
||||||
|
(print x)
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
;; Output: 228
|
;; Output: 26.7
|
||||||
;; Benchmark: 1.4us
|
;; Benchmark: 1.4us
|
||||||
;; Benchmark-Repeat: 1406
|
;; Benchmark-Repeat: 1406
|
||||||
(do
|
(do
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ impl<'a> Analyzer<'a> {
|
|||||||
captured_by,
|
captured_by,
|
||||||
} => {
|
} => {
|
||||||
let val_m = self.visit(value.clone());
|
let val_m = self.visit(value.clone());
|
||||||
let p = val_m.ty.purity;
|
|
||||||
(
|
(
|
||||||
BoundKind::Define {
|
BoundKind::Define {
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
@@ -125,7 +124,7 @@ impl<'a> Analyzer<'a> {
|
|||||||
value: Rc::new(val_m),
|
value: Rc::new(val_m),
|
||||||
captured_by: captured_by.clone(),
|
captured_by: captured_by.clone(),
|
||||||
},
|
},
|
||||||
p,
|
Purity::Impure,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ impl UsageInfo {
|
|||||||
self.collect(v);
|
self.collect(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BoundKind::Define { value, .. } => {
|
BoundKind::Define { addr, value, .. } => {
|
||||||
|
self.assigned.insert(*addr);
|
||||||
self.collect(value);
|
self.collect(value);
|
||||||
}
|
}
|
||||||
BoundKind::Expansion { bound_expanded, .. } => {
|
BoundKind::Expansion { bound_expanded, .. } => {
|
||||||
|
|||||||
Reference in New Issue
Block a user