Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

add a `BlockNode` variant to the `ClauseGuard` enum

allowing us to keep track of the blocks one has explicitly used when writing
a clause guard

+33 -5
+11 -2
compiler-core/src/ast.rs
··· 1901 1901 1902 1902 #[derive(Debug, Clone, PartialEq, Eq)] 1903 1903 pub enum ClauseGuard<Type, RecordTag> { 1904 + Block { 1905 + location: SrcSpan, 1906 + value: Box<ClauseGuard<Type, RecordTag>>, 1907 + }, 1908 + 1904 1909 Equals { 1905 1910 location: SrcSpan, 1906 1911 left: Box<Self>, ··· 2094 2099 | ClauseGuard::DivFloat { location, .. } 2095 2100 | ClauseGuard::RemainderInt { location, .. } 2096 2101 | ClauseGuard::LtEqFloat { location, .. } 2097 - | ClauseGuard::ModuleSelect { location, .. } => *location, 2102 + | ClauseGuard::ModuleSelect { location, .. } 2103 + | ClauseGuard::Block { location, .. } => *location, 2098 2104 ClauseGuard::FieldAccess { 2099 2105 label_location, 2100 2106 container, ··· 2140 2146 | ClauseGuard::Not { .. } 2141 2147 | ClauseGuard::TupleIndex { .. } 2142 2148 | ClauseGuard::FieldAccess { .. } 2143 - | ClauseGuard::ModuleSelect { .. } => None, 2149 + | ClauseGuard::ModuleSelect { .. } 2150 + | ClauseGuard::Block { .. } => None, 2144 2151 } 2145 2152 } 2146 2153 } ··· 2153 2160 ClauseGuard::FieldAccess { type_, .. } => type_.clone(), 2154 2161 ClauseGuard::ModuleSelect { type_, .. } => type_.clone(), 2155 2162 ClauseGuard::Constant(constant) => constant.type_(), 2163 + ClauseGuard::Block { value, .. } => value.type_(), 2156 2164 2157 2165 ClauseGuard::AddInt { .. } 2158 2166 | ClauseGuard::SubInt { .. } ··· 2185 2193 match self { 2186 2194 ClauseGuard::Var { name, .. } => im::hashset![name], 2187 2195 2196 + ClauseGuard::Block { value, .. } => value.referenced_variables(), 2188 2197 ClauseGuard::Not { expression, .. } => expression.referenced_variables(), 2189 2198 ClauseGuard::TupleIndex { tuple, .. } => tuple.referenced_variables(), 2190 2199 ClauseGuard::FieldAccess { container, .. } => container.referenced_variables(),
+1
compiler-core/src/ast/visit.rs
··· 1367 1367 v.visit_typed_clause_guard(left); 1368 1368 v.visit_typed_clause_guard(right); 1369 1369 } 1370 + super::ClauseGuard::Block { location: _, value } => v.visit_typed_clause_guard(value), 1370 1371 super::ClauseGuard::Not { 1371 1372 location: _, 1372 1373 expression,
+2
compiler-core/src/call_graph.rs
··· 457 457 self.guard(right); 458 458 } 459 459 460 + ClauseGuard::Block { value, .. } => self.guard(value), 461 + 460 462 ClauseGuard::Not { expression, .. } => self.guard(expression), 461 463 462 464 ClauseGuard::Var { name, .. } => self.referenced(name),
+4 -1
compiler-core/src/erlang.rs
··· 1614 1614 1615 1615 fn bare_clause_guard<'a>(guard: &'a TypedClauseGuard, env: &mut Env<'a>) -> Document<'a> { 1616 1616 match guard { 1617 + ClauseGuard::Block { value, .. } => bare_clause_guard(value, env).surround("(", ")"), 1618 + 1617 1619 ClauseGuard::Not { expression, .. } => docvec!["not ", bare_clause_guard(expression, env)], 1618 1620 1619 1621 ClauseGuard::Or { left, right, .. } => clause_guard(left, env) ··· 1762 1764 | ClauseGuard::Var { .. } 1763 1765 | ClauseGuard::TupleIndex { .. } 1764 1766 | ClauseGuard::FieldAccess { .. } 1765 - | ClauseGuard::ModuleSelect { .. } => bare_clause_guard(guard, env), 1767 + | ClauseGuard::ModuleSelect { .. } 1768 + | ClauseGuard::Block { .. } => bare_clause_guard(guard, env), 1766 1769 } 1767 1770 } 1768 1771
+2
compiler-core/src/format.rs
··· 2514 2514 ClauseGuard::Constant(constant) => self.const_expr(constant), 2515 2515 2516 2516 ClauseGuard::Not { expression, .. } => docvec!["!", self.clause_guard(expression)], 2517 + 2518 + ClauseGuard::Block { value, .. } => wrap_block(self.clause_guard(value)).group(), 2517 2519 } 2518 2520 } 2519 2521
+5 -2
compiler-core/src/javascript/expression.rs
··· 1936 1936 1937 1937 pub(crate) fn guard(&mut self, guard: &'a TypedClauseGuard) -> Document<'a> { 1938 1938 match guard { 1939 + ClauseGuard::Block { value, .. } => self.guard(value).surround("(", ")"), 1940 + 1939 1941 ClauseGuard::Equals { left, right, .. } if is_js_scalar(left.type_()) => { 1940 1942 let left = self.wrapped_guard(left); 1941 1943 let right = self.wrapped_guard(right); ··· 2066 2068 | ClauseGuard::TupleIndex { .. } 2067 2069 | ClauseGuard::Constant(_) 2068 2070 | ClauseGuard::Not { .. } 2069 - | ClauseGuard::FieldAccess { .. } => self.guard(guard), 2071 + | ClauseGuard::FieldAccess { .. } 2072 + | ClauseGuard::Block { .. } => self.guard(guard), 2070 2073 2071 2074 ClauseGuard::Equals { .. } 2072 2075 | ClauseGuard::NotEquals { .. } ··· 2089 2092 | ClauseGuard::RemainderInt { .. } 2090 2093 | ClauseGuard::Or { .. } 2091 2094 | ClauseGuard::And { .. } 2092 - | ClauseGuard::ModuleSelect { .. } => docvec!["(", self.guard(guard,), ")"], 2095 + | ClauseGuard::ModuleSelect { .. } => docvec!["(", self.guard(guard), ")"], 2093 2096 } 2094 2097 } 2095 2098
+8
compiler-core/src/type_/expression.rs
··· 2800 2800 ClauseGuard::Constant(constant) => { 2801 2801 Ok(ClauseGuard::Constant(self.infer_const(&None, constant))) 2802 2802 } 2803 + 2804 + ClauseGuard::Block { value, location } => { 2805 + let value = self.infer_clause_guard(*value)?; 2806 + Ok(ClauseGuard::Block { 2807 + location, 2808 + value: Box::new(value), 2809 + }) 2810 + } 2803 2811 } 2804 2812 } 2805 2813