| 112 | } |
| 113 | |
| 114 | fn run_impl<'heap>( |
| 115 | pipeline: &mut Pipeline<'heap>, |
| 116 | |
| 117 | runtime: &runtime::Runtime, |
| 118 | client: &Client, |
| 119 | |
| 120 | inputs: &Inputs<'heap, &'heap Heap>, |
| 121 | |
| 122 | interner: hashql_mir::intern::Interner<'heap>, |
| 123 | entry: DefId, |
| 124 | bodies: &mut DefIdSlice<Body<'heap>>, |
| 125 | ) -> Result<(Value<'heap, &'heap Heap>, Vec<Event>), BoxedDiagnostic<'static, SpanId>> { |
| 126 | pipeline.transform(&interner, bodies)?; |
| 127 | let analysis = pipeline.prepare(&interner, bodies)?; |
| 128 | |
| 129 | let interner = interner.into(); |
| 130 | let mut context = CodeGenerationContext::new_in( |
| 131 | &pipeline.env, |
| 132 | &interner, |
| 133 | bodies, |
| 134 | &analysis, |
| 135 | pipeline.heap, |
| 136 | &mut pipeline.scratch, |
| 137 | ); |
| 138 | let mut postgres = PostgresCompiler::new_in(&mut context, &mut pipeline.scratch); |
| 139 | let queries = postgres.compile(); |
| 140 | pipeline.scratch.reset(); |
| 141 | |
| 142 | let diagnostics = mem::take(&mut context.diagnostics); |
| 143 | pipeline.diagnostics.append(&mut diagnostics.boxed()); |
| 144 | |
| 145 | let event_log = AppendEventLog::new(); |
| 146 | let context = CodeExecutionContext::from(context); |
| 147 | let orchestrator = |
| 148 | Orchestrator::new(PostgresClient(client), &queries, &context).with_event_log(&event_log); |
| 149 | |
| 150 | let value = runtime |
| 151 | .block_on(orchestrator.run_in(inputs, entry, [], pipeline.heap)) |
| 152 | .map_err(Diagnostic::generalize) |
| 153 | .map_err(Diagnostic::boxed)?; |
| 154 | |
| 155 | Ok((value, event_log.take())) |
| 156 | } |