@@ -46,7 +46,10 @@ impl OutputWriter {
4646 }
4747
4848 /// Implements the main logic of the output writer.
49- pub fn run ( & self , meanings : impl Iterator < Item = semantic:: Meaning > ) -> anyhow:: Result < ( ) > {
49+ pub fn run (
50+ & self ,
51+ meanings : impl Iterator < Item = semantic:: CompilerCall > ,
52+ ) -> anyhow:: Result < ( ) > {
5053 let entries = meanings. flat_map ( |value| {
5154 into_entries ( value) . unwrap_or_else ( |error| {
5255 log:: error!(
@@ -127,38 +130,34 @@ impl OutputWriter {
127130 }
128131}
129132
130- pub fn into_entries ( value : semantic:: Meaning ) -> Result < Vec < Entry > , anyhow:: Error > {
131- match value {
132- semantic:: Meaning :: Compiler {
133- compiler,
134- working_dir,
135- passes,
136- } => {
137- let entries = passes
138- . iter ( )
139- . flat_map ( |pass| -> Result < Entry , anyhow:: Error > {
140- match pass {
141- semantic:: CompilerPass :: Preprocess => {
142- Err ( anyhow ! ( "preprocess pass should not show up in results" ) )
143- }
144- semantic:: CompilerPass :: Compile {
145- source,
146- output,
147- flags,
148- } => Ok ( Entry {
149- file : into_abspath ( source. clone ( ) , working_dir. as_path ( ) ) ?,
150- directory : working_dir. clone ( ) ,
151- output : into_abspath_opt ( output. clone ( ) , working_dir. as_path ( ) ) ?,
152- arguments : into_arguments ( & compiler, source, output, flags) ?,
153- } ) ,
154- }
155- } )
156- . collect ( ) ;
133+ pub fn into_entries ( value : semantic:: CompilerCall ) -> Result < Vec < Entry > , anyhow:: Error > {
134+ let semantic:: CompilerCall {
135+ compiler,
136+ working_dir,
137+ passes,
138+ } = value;
139+ let entries = passes
140+ . iter ( )
141+ . flat_map ( |pass| -> Result < Entry , anyhow:: Error > {
142+ match pass {
143+ semantic:: CompilerPass :: Preprocess => {
144+ Err ( anyhow ! ( "preprocess pass should not show up in results" ) )
145+ }
146+ semantic:: CompilerPass :: Compile {
147+ source,
148+ output,
149+ flags,
150+ } => Ok ( Entry {
151+ file : into_abspath ( source. clone ( ) , working_dir. as_path ( ) ) ?,
152+ directory : working_dir. clone ( ) ,
153+ output : into_abspath_opt ( output. clone ( ) , working_dir. as_path ( ) ) ?,
154+ arguments : into_arguments ( & compiler, source, output, flags) ?,
155+ } ) ,
156+ }
157+ } )
158+ . collect ( ) ;
157159
158- Ok ( entries)
159- }
160- _ => Ok ( vec ! [ ] ) ,
161- }
160+ Ok ( entries)
162161}
163162
164163fn into_arguments (
@@ -210,10 +209,7 @@ mod test {
210209 fn test_non_compilations ( ) -> Result < ( ) > {
211210 let empty: Vec < Entry > = vec ! [ ] ;
212211
213- let result: Vec < Entry > = into_entries ( semantic:: Meaning :: Ignored ) ?;
214- assert_eq ! ( empty, result) ;
215-
216- let input = semantic:: Meaning :: Compiler {
212+ let input = semantic:: CompilerCall {
217213 compiler : PathBuf :: from ( "/usr/bin/cc" ) ,
218214 working_dir : PathBuf :: from ( "/home/user" ) ,
219215 passes : vec ! [ ] ,
@@ -226,7 +222,7 @@ mod test {
226222
227223 #[ test]
228224 fn test_single_source_compilation ( ) -> Result < ( ) > {
229- let input = semantic:: Meaning :: Compiler {
225+ let input = semantic:: CompilerCall {
230226 compiler : PathBuf :: from ( "clang" ) ,
231227 working_dir : PathBuf :: from ( "/home/user" ) ,
232228 passes : vec ! [ semantic:: CompilerPass :: Compile {
@@ -252,7 +248,7 @@ mod test {
252248
253249 #[ test]
254250 fn test_multiple_sources_compilation ( ) -> Result < ( ) > {
255- let input = semantic:: Meaning :: Compiler {
251+ let input = semantic:: CompilerCall {
256252 compiler : PathBuf :: from ( "clang" ) ,
257253 working_dir : PathBuf :: from ( "/home/user" ) ,
258254 passes : vec ! [
0 commit comments