1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00

visit constants in default folder

This commit is contained in:
dark64 2021-04-27 13:34:16 +02:00
parent 231204d7a2
commit 9ec3ac3cf7
3 changed files with 10 additions and 17 deletions

View file

@ -71,21 +71,6 @@ impl<'ast, T: Field> Folder<'ast, T> for ConstantInliner<'ast, T> {
}
}
fn fold_module(&mut self, m: TypedModule<'ast, T>) -> TypedModule<'ast, T> {
TypedModule {
constants: m
.constants
.into_iter()
.map(|(key, tc)| (key, self.fold_constant_symbol(tc)))
.collect(),
functions: m
.functions
.into_iter()
.map(|(key, fun)| (key, self.fold_function_symbol(fun)))
.collect(),
}
}
fn fold_constant_symbol(
&mut self,
s: TypedConstantSymbol<'ast, T>,

View file

@ -204,12 +204,16 @@ pub fn fold_module<'ast, T: Field, F: Folder<'ast, T>>(
m: TypedModule<'ast, T>,
) -> TypedModule<'ast, T> {
TypedModule {
constants: m
.constants
.into_iter()
.map(|(key, tc)| (key, f.fold_constant_symbol(tc)))
.collect(),
functions: m
.functions
.into_iter()
.map(|(key, fun)| (key, f.fold_function_symbol(fun)))
.collect(),
..m
}
}

View file

@ -842,12 +842,16 @@ pub fn fold_module<'ast, T: Field, F: ResultFolder<'ast, T>>(
m: TypedModule<'ast, T>,
) -> Result<TypedModule<'ast, T>, F::Error> {
Ok(TypedModule {
constants: m
.constants
.into_iter()
.map(|(key, tc)| f.fold_constant_symbol(tc).map(|tc| (key, tc)))
.collect::<Result<_, _>>()?,
functions: m
.functions
.into_iter()
.map(|(key, fun)| f.fold_function_symbol(fun).map(|f| (key, f)))
.collect::<Result<_, _>>()?,
..m
})
}