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

Configure Feed

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

remove currently unused fields

author
Giacomo Cavalieri
committer
Louis Pilfold
date (Jul 14, 2026, 12:57 PM +0100) commit 394527e4 parent 9b99d017 change-id sosrzwmo
+66 -188
+66 -188
erlang-generation/src/lib.rs
··· 41 41 /// Represents an open function that has yet to be closed. 42 42 /// A function definition is started with `ErlangBuilder::start_function` and 43 43 /// _must_ be closed using `ErlangBuilder::end_function`. 44 - pub struct Function { 45 - clauses: erlang_term_format::List, 46 - statements: erlang_term_format::List, 47 - } 44 + pub struct Function {} 48 45 49 46 #[must_use] 50 47 /// Represents an open function call that has yet to be closed. 51 - pub struct Call { 52 - arguments: erlang_term_format::List, 53 - } 48 + pub struct Call {} 54 49 55 50 #[must_use] 56 51 /// Represents an open case expression that has yet to be closed. 57 - pub struct Case { 58 - branches: erlang_term_format::List, 59 - } 52 + pub struct Case {} 60 53 61 54 #[must_use] 62 55 /// Represents an open case clause pattern that has yet to be generated. 63 - pub struct ClausePattern { 64 - pattern: erlang_term_format::List, 65 - guards: erlang_term_format::List, 66 - body: erlang_term_format::List, 67 - } 56 + pub struct ClausePattern {} 68 57 69 58 #[must_use] 70 59 /// Represents a set of clause guards that has yet to be closed. 71 - pub struct ClauseGuards { 72 - guards: erlang_term_format::List, 73 - body: erlang_term_format::List, 74 - } 60 + pub struct ClauseGuards {} 75 61 76 62 #[must_use] 77 63 /// Represents an open clause body that has yet to be closed. 78 - pub struct ClauseBody { 79 - body: erlang_term_format::List, 80 - } 64 + pub struct ClauseBody {} 81 65 82 66 #[must_use] 83 67 /// Represents an open tuple that has yet to be closed. 84 - pub struct Tuple { 85 - items: erlang_term_format::List, 86 - } 68 + pub struct Tuple {} 87 69 88 70 #[must_use] 89 71 /// Represents an open map that has yet to be closed. 90 - pub struct Map { 91 - items: erlang_term_format::List, 92 - } 72 + pub struct Map {} 93 73 94 74 #[must_use] 95 75 /// Represents an open bit array that has yet to be closed. 96 - pub struct BitArray { 97 - segments: erlang_term_format::List, 98 - } 76 + pub struct BitArray {} 99 77 100 78 #[must_use] 101 79 /// Represents an open bit array pattern that has yet to be closed. 102 - pub struct BitArrayPattern { 103 - segments: erlang_term_format::List, 104 - } 80 + pub struct BitArrayPattern {} 105 81 106 82 #[must_use] 107 83 /// Represents an open tuple type that has yet to be closed. 108 - pub struct TupleType { 109 - items: erlang_term_format::List, 110 - } 84 + pub struct TupleType {} 111 85 112 86 #[must_use] 113 87 /// Represents an open tuple pattern that has yet to be closed. 114 - pub struct TuplePattern { 115 - items: erlang_term_format::List, 116 - } 88 + pub struct TuplePattern {} 117 89 118 90 #[must_use] 119 91 /// Represents an open doc/moduledoc attribute. 120 - pub struct DocAttribute { 121 - items: erlang_term_format::List, 122 - } 92 + pub struct DocAttribute {} 123 93 124 94 #[must_use] 125 95 /// Represents an open record attribute. 126 - pub struct RecordAttribute { 127 - fields: erlang_term_format::List, 128 - } 96 + pub struct RecordAttribute {} 129 97 130 98 #[must_use] 131 99 /// Represents an open function type annotation that has yet to be closed after 132 100 /// generating the arguments types and the return type. 133 - pub struct FunctionType { 134 - types: erlang_term_format::List, 135 - } 101 + pub struct FunctionType {} 136 102 137 103 #[must_use] 138 104 /// Represents an open named type that has yet to be closed after generating 139 105 /// the types it takes as an argument (if any). 140 - pub struct NamedType { 141 - types: erlang_term_format::List, 142 - } 106 + pub struct NamedType {} 143 107 144 108 #[must_use] 145 109 /// Represents an open alternative type that has yet to be closed after 146 110 /// generating all of its alternatives. 147 - pub struct UnionType { 148 - alternatives: erlang_term_format::List, 149 - } 111 + pub struct UnionType {} 150 112 151 113 #[must_use] 152 114 /// Represents an open function type annotation that has yet to be closed after 153 115 /// generating the arguments types and the return type. 154 - pub struct FunctionSpec { 155 - representations: erlang_term_format::List, 156 - } 116 + pub struct FunctionSpec {} 157 117 158 118 #[must_use] 159 119 /// Represents an open block that has yet to be closed after generating the 160 120 /// statements that go inside it. 161 - pub struct Block { 162 - statements: erlang_term_format::List, 163 - } 121 + pub struct Block {} 164 122 165 123 #[must_use] 166 124 /// Represents an open list of arguments' types in a function type annotation 167 125 /// that has yet to be closed. 168 - pub struct FunctionTypeArguments { 169 - types: erlang_term_format::List, 170 - arguments: erlang_term_format::List, 171 - } 126 + pub struct FunctionTypeArguments {} 172 127 173 128 /// All the possible specifiers that can be used in a bit array segment. 174 129 pub enum BitArraySegmentSpecifier { ··· 1802 1757 self.code.push_str("-doc("); 1803 1758 self.position 1804 1759 .push(ErlangSourceBuilderPosition::DocAttribute); 1805 - DocAttribute { 1806 - items: ErlangSourceBuilder::dummy_list(), 1807 - } 1760 + DocAttribute {} 1808 1761 } 1809 1762 1810 1763 fn start_moduledoc_attribute(&mut self) -> DocAttribute { ··· 1812 1765 self.code.push_str("-moduledoc("); 1813 1766 self.position 1814 1767 .push(ErlangSourceBuilderPosition::DocAttribute); 1815 - DocAttribute { 1816 - items: ErlangSourceBuilder::dummy_list(), 1817 - } 1768 + DocAttribute {} 1818 1769 } 1819 1770 1820 - fn end_doc_attribute(&mut self, attribute: DocAttribute) { 1771 + fn end_doc_attribute(&mut self, _attribute: DocAttribute) { 1821 1772 self.close_currently_open_item(); 1822 - attribute.items.consume(); 1823 1773 } 1824 1774 1825 1775 fn compile_attribute<'a>(&mut self, arguments: impl IntoIterator<Item = &'a str>) { ··· 1858 1808 self.position 1859 1809 .push(ErlangSourceBuilderPosition::RecordAttribute { first: true }); 1860 1810 1861 - RecordAttribute { 1862 - fields: ErlangSourceBuilder::dummy_list(), 1863 - } 1811 + RecordAttribute {} 1864 1812 } 1865 1813 1866 - fn end_record_attribute(&mut self, record: RecordAttribute) { 1814 + fn end_record_attribute(&mut self, _record: RecordAttribute) { 1867 1815 self.close_currently_open_item(); 1868 - record.fields.consume(); 1869 1816 } 1870 1817 1871 1818 fn record_field(&mut self) { ··· 1882 1829 self.code.push_str(&quote_atom_name(name)); 1883 1830 self.position 1884 1831 .push(ErlangSourceBuilderPosition::FunctionSpec); 1885 - FunctionSpec { 1886 - representations: ErlangSourceBuilder::dummy_list(), 1887 - } 1832 + FunctionSpec {} 1888 1833 } 1889 1834 1890 - fn end_function_spec(&mut self, function_spec: FunctionSpec) { 1835 + fn end_function_spec(&mut self, _function_spec: FunctionSpec) { 1891 1836 self.close_currently_open_item(); 1892 - function_spec.representations.consume(); 1893 1837 } 1894 1838 1895 1839 fn type_spec<Name: AsRef<str>>( ··· 1938 1882 needs_wrapping, 1939 1883 }); 1940 1884 1941 - FunctionTypeArguments { 1942 - types: ErlangSourceBuilder::dummy_list(), 1943 - arguments: ErlangSourceBuilder::dummy_list(), 1944 - } 1885 + FunctionTypeArguments {} 1945 1886 } 1946 1887 1947 1888 fn end_function_type_arguments( 1948 1889 &mut self, 1949 - function_type: FunctionTypeArguments, 1890 + _function_type: FunctionTypeArguments, 1950 1891 ) -> FunctionType { 1951 1892 self.close_currently_open_item(); 1952 - function_type.arguments.consume(); 1953 - FunctionType { 1954 - types: function_type.types, 1955 - } 1893 + 1894 + FunctionType {} 1956 1895 } 1957 1896 1958 - fn end_function_type(&mut self, function_type: FunctionType) { 1897 + fn end_function_type(&mut self, _function_type: FunctionType) { 1959 1898 self.close_currently_open_item(); 1960 - function_type.types.consume(); 1961 1899 } 1962 1900 1963 1901 fn start_named_type(&mut self, name: &str) -> NamedType { ··· 1967 1905 self.code.push_str(&quote_atom_name(name)); 1968 1906 self.code.push('('); 1969 1907 1970 - NamedType { 1971 - types: ErlangSourceBuilder::dummy_list(), 1972 - } 1908 + NamedType {} 1973 1909 } 1974 1910 1975 1911 fn start_remote_named_type(&mut self, module: ErlangModuleName, name: &str) -> NamedType { ··· 1981 1917 self.code.push_str(&quote_atom_name(name)); 1982 1918 self.code.push('('); 1983 1919 1984 - NamedType { 1985 - types: ErlangSourceBuilder::dummy_list(), 1986 - } 1920 + NamedType {} 1987 1921 } 1988 1922 1989 - fn end_named_type(&mut self, named_type: NamedType) { 1923 + fn end_named_type(&mut self, _named_type: NamedType) { 1990 1924 self.close_currently_open_item(); 1991 - named_type.types.consume(); 1992 1925 } 1993 1926 1994 1927 fn start_tuple_type(&mut self) -> TupleType { ··· 1997 1930 .push(ErlangSourceBuilderPosition::TupleType { first: true }); 1998 1931 self.code.push('{'); 1999 1932 2000 - TupleType { 2001 - items: ErlangSourceBuilder::dummy_list(), 2002 - } 1933 + TupleType {} 2003 1934 } 2004 1935 2005 - fn end_tuple_type(&mut self, tuple: TupleType) { 1936 + fn end_tuple_type(&mut self, _tuple: TupleType) { 2006 1937 self.close_currently_open_item(); 2007 - tuple.items.consume(); 2008 1938 } 2009 1939 2010 1940 fn start_union_type(&mut self) -> UnionType { ··· 2012 1942 self.position 2013 1943 .push(ErlangSourceBuilderPosition::UnionType { first: true }); 2014 1944 2015 - UnionType { 2016 - alternatives: ErlangSourceBuilder::dummy_list(), 2017 - } 1945 + UnionType {} 2018 1946 } 2019 1947 2020 - fn end_union_type(&mut self, union_type: UnionType) { 1948 + fn end_union_type(&mut self, _union_type: UnionType) { 2021 1949 self.close_currently_open_item(); 2022 - union_type.alternatives.consume(); 2023 1950 } 2024 1951 2025 1952 fn type_variable(&mut self, name: &str) { ··· 2057 1984 self.position 2058 1985 .push(ErlangSourceBuilderPosition::FunctionStatement { first: true }); 2059 1986 2060 - Function { 2061 - clauses: ErlangSourceBuilder::dummy_list(), 2062 - statements: ErlangSourceBuilder::dummy_list(), 2063 - } 1987 + Function {} 2064 1988 } 2065 1989 2066 1990 fn start_anonymous_function<Name: AsRef<str>>( ··· 2085 2009 self.position 2086 2010 .push(ErlangSourceBuilderPosition::AnonymousFunctionStatement { first: true }); 2087 2011 2088 - Function { 2089 - clauses: ErlangSourceBuilder::dummy_list(), 2090 - statements: ErlangSourceBuilder::dummy_list(), 2091 - } 2012 + Function {} 2092 2013 } 2093 2014 2094 - fn end_function(&mut self, function: Function) { 2015 + fn end_function(&mut self, _function: Function) { 2095 2016 self.close_currently_open_item(); 2096 - function.clauses.consume(); 2097 - function.statements.consume(); 2098 2017 } 2099 2018 2100 2019 fn start_block(&mut self) -> Block { ··· 2104 2023 self.position 2105 2024 .push(ErlangSourceBuilderPosition::Block { first: true }); 2106 2025 2107 - Block { 2108 - statements: ErlangSourceBuilder::dummy_list(), 2109 - } 2026 + Block {} 2110 2027 } 2111 2028 2112 - fn end_block(&mut self, block: Block) { 2029 + fn end_block(&mut self, _block: Block) { 2113 2030 self.close_currently_open_item(); 2114 - block.statements.consume(); 2115 2031 } 2116 2032 2117 2033 fn start_remote_call(&mut self, module: ErlangModuleName, function: &str) -> Call { ··· 2138 2054 expected: ExpectedCallItem::Arguments { first: true }, 2139 2055 called_item_needs_wrapping: false, 2140 2056 }); 2141 - Call { 2142 - arguments: ErlangSourceBuilder::dummy_list(), 2143 - } 2057 + Call {} 2144 2058 } 2145 2059 2146 2060 fn start_call(&mut self) -> Call { ··· 2164 2078 expected: ExpectedCallItem::FunctionToBeCalled, 2165 2079 called_item_needs_wrapping: false, 2166 2080 }); 2167 - Call { 2168 - arguments: ErlangSourceBuilder::dummy_list(), 2169 - } 2081 + Call {} 2170 2082 } 2171 2083 2172 - fn end_call(&mut self, call: Call) { 2084 + fn end_call(&mut self, _call: Call) { 2173 2085 self.close_currently_open_item(); 2174 - call.arguments.consume(); 2175 2086 } 2176 2087 2177 2088 fn start_tuple(&mut self) -> Tuple { ··· 2180 2091 self.position 2181 2092 .push(ErlangSourceBuilderPosition::Tuple { first: true }); 2182 2093 2183 - Tuple { 2184 - items: ErlangSourceBuilder::dummy_list(), 2185 - } 2094 + Tuple {} 2186 2095 } 2187 2096 2188 - fn end_tuple(&mut self, tuple: Tuple) { 2097 + fn end_tuple(&mut self, _tuple: Tuple) { 2189 2098 self.close_currently_open_item(); 2190 - tuple.items.consume(); 2191 2099 } 2192 2100 2193 2101 fn start_map(&mut self) -> Map { ··· 2196 2104 self.indentation += INDENT; 2197 2105 self.position 2198 2106 .push(ErlangSourceBuilderPosition::Map { first: true }); 2199 - Map { 2200 - items: ErlangSourceBuilder::dummy_list(), 2201 - } 2107 + Map {} 2202 2108 } 2203 2109 2204 - fn end_map(&mut self, map: Map) { 2110 + fn end_map(&mut self, _map: Map) { 2205 2111 self.close_currently_open_item(); 2206 - map.items.consume(); 2207 2112 } 2208 2113 2209 2114 fn map_field(&mut self) { ··· 2222 2127 first: true, 2223 2128 }); 2224 2129 2225 - BitArray { 2226 - segments: ErlangSourceBuilder::dummy_list(), 2227 - } 2130 + BitArray {} 2228 2131 } 2229 2132 2230 - fn end_bit_array(&mut self, bit_array: BitArray) { 2133 + fn end_bit_array(&mut self, _bit_array: BitArray) { 2231 2134 self.close_currently_open_item(); 2232 - bit_array.segments.consume(); 2233 2135 } 2234 2136 2235 2137 fn bit_array_segment(&mut self) { ··· 2322 2224 expected: ExpectedCaseItem::Subject, 2323 2225 }); 2324 2226 2325 - Case { 2326 - branches: ErlangSourceBuilder::dummy_list(), 2327 - } 2227 + Case {} 2328 2228 } 2329 2229 2330 - fn end_case(&mut self, case: Case) { 2230 + fn end_case(&mut self, _case: Case) { 2331 2231 self.close_currently_open_item(); 2332 - case.branches.consume(); 2333 2232 } 2334 2233 2335 2234 fn start_case_clause(&mut self) -> ClausePattern { ··· 2337 2236 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2338 2237 expected: ExpectedCaseClauseItem::Pattern, 2339 2238 }); 2340 - ClausePattern { 2341 - pattern: ErlangSourceBuilder::dummy_list(), 2342 - guards: ErlangSourceBuilder::dummy_list(), 2343 - body: ErlangSourceBuilder::dummy_list(), 2344 - } 2239 + ClausePattern {} 2345 2240 } 2346 2241 2347 - fn end_clause_pattern(&mut self, clause_pattern: ClausePattern) -> ClauseGuards { 2242 + fn end_clause_pattern(&mut self, _clause_pattern: ClausePattern) -> ClauseGuards { 2348 2243 self.close_currently_open_item(); 2349 2244 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2350 2245 expected: ExpectedCaseClauseItem::Guards { first: true }, 2351 2246 }); 2352 - clause_pattern.pattern.consume(); 2353 - ClauseGuards { 2354 - guards: clause_pattern.guards, 2355 - body: clause_pattern.body, 2356 - } 2247 + 2248 + ClauseGuards {} 2357 2249 } 2358 2250 2359 - fn end_clause_guards(&mut self, clause_guards: ClauseGuards) -> ClauseBody { 2251 + fn end_clause_guards(&mut self, _clause_guards: ClauseGuards) -> ClauseBody { 2360 2252 self.close_currently_open_item(); 2361 2253 self.indentation += INDENT; 2362 2254 self.position.push(ErlangSourceBuilderPosition::CaseClause { 2363 2255 expected: ExpectedCaseClauseItem::Body { first: true }, 2364 2256 }); 2365 2257 2366 - clause_guards.guards.consume(); 2367 - ClauseBody { 2368 - body: clause_guards.body, 2369 - } 2258 + ClauseBody {} 2370 2259 } 2371 2260 2372 - fn end_clause_body(&mut self, clause_body: ClauseBody) { 2261 + fn end_clause_body(&mut self, _clause_body: ClauseBody) { 2373 2262 self.close_currently_open_item(); 2374 - clause_body.body.consume(); 2375 2263 } 2376 2264 2377 2265 fn variable(&mut self, name: &str) { ··· 2480 2368 self.code.push('{'); 2481 2369 self.position 2482 2370 .push(ErlangSourceBuilderPosition::TuplePattern { first: true }); 2483 - TuplePattern { 2484 - items: ErlangSourceBuilder::dummy_list(), 2485 - } 2371 + TuplePattern {} 2486 2372 } 2487 2373 2488 - fn end_tuple_pattern(&mut self, tuple: TuplePattern) { 2374 + fn end_tuple_pattern(&mut self, _tuple: TuplePattern) { 2489 2375 self.close_currently_open_item(); 2490 - tuple.items.consume(); 2491 2376 } 2492 2377 2493 2378 fn start_bit_array_pattern(&mut self) -> BitArrayPattern { ··· 2498 2383 first: true, 2499 2384 }); 2500 2385 2501 - BitArrayPattern { 2502 - segments: ErlangSourceBuilder::dummy_list(), 2503 - } 2386 + BitArrayPattern {} 2504 2387 } 2505 2388 2506 - fn end_bit_array_pattern(&mut self, bit_array: BitArrayPattern) { 2389 + fn end_bit_array_pattern(&mut self, _bit_array: BitArrayPattern) { 2507 2390 self.close_currently_open_item(); 2508 - bit_array.segments.consume(); 2509 2391 } 2510 2392 2511 2393 fn cons_list_pattern(&mut self) { ··· 2581 2463 const INDENT: usize = 4; 2582 2464 2583 2465 impl ErlangSourceBuilder { 2584 - fn dummy_list() -> erlang_term_format::List { 2585 - erlang_term_format::List::new(0) 2586 - } 2587 - 2588 2466 /// This has to be called before generating any new top level form: those 2589 2467 /// are specs like `-spec`, `-type`, `-opaque`, doc attributes like 2590 2468 /// `-doc` and `-moduledoc`, and function definitions.