remove possibility of using same transpiler twice
This commit is contained in:
parent
09dd19508d
commit
9c54dee454
|
@ -176,9 +176,8 @@ where
|
||||||
|
|
||||||
tracing::info!("Transpiling the source code.");
|
tracing::info!("Transpiling the source code.");
|
||||||
|
|
||||||
let mut transpiler = Transpiler::new(main_namespace_name, pack_format);
|
let datapack =
|
||||||
transpiler.transpile(&programs, handler)?;
|
Transpiler::new(main_namespace_name, pack_format).transpile(&programs, handler)?;
|
||||||
let datapack = transpiler.into_datapack();
|
|
||||||
|
|
||||||
if handler.has_received() {
|
if handler.has_received() {
|
||||||
return Err(Error::other(
|
return Err(Error::other(
|
||||||
|
|
|
@ -69,22 +69,16 @@ impl Transpiler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes the transpiler and returns the resulting datapack.
|
/// Transpiles the given programs and returns the resulting datapack.
|
||||||
#[must_use]
|
|
||||||
pub fn into_datapack(self) -> Datapack {
|
|
||||||
self.datapack
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transpiles the given programs.
|
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
/// - [`TranspileError::MissingFunctionDeclaration`] If a called function is missing
|
/// - [`TranspileError::MissingFunctionDeclaration`] If a called function is missing
|
||||||
#[tracing::instrument(level = "trace", skip_all)]
|
#[tracing::instrument(level = "trace", skip_all)]
|
||||||
pub fn transpile(
|
pub fn transpile(
|
||||||
&mut self,
|
mut self,
|
||||||
programs: &[ProgramFile],
|
programs: &[ProgramFile],
|
||||||
handler: &impl Handler<base::Error>,
|
handler: &impl Handler<base::Error>,
|
||||||
) -> Result<(), TranspileError> {
|
) -> Result<Datapack, TranspileError> {
|
||||||
tracing::trace!("Transpiling program declarations");
|
tracing::trace!("Transpiling program declarations");
|
||||||
for program in programs {
|
for program in programs {
|
||||||
let program_identifier = program
|
let program_identifier = program
|
||||||
|
@ -145,7 +139,7 @@ impl Transpiler {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(self.datapack)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transpiles the given program.
|
/// Transpiles the given program.
|
||||||
|
|
Loading…
Reference in New Issue