Skip to content

Commit

Permalink
Remove Assembler::assemble_test()
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jun 11, 2024
1 parent 8546c21 commit f9c1d6e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
19 changes: 0 additions & 19 deletions assembly/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,25 +322,6 @@ impl Assembler {
self.assemble_in_context(source, &mut context)
}

/// Compiles the provided source into a [`MastForest`], without consuming the assembler.
///
/// Note that the state of any kernel used upon initialization will be wiped, so this function
/// should not be used to assemble multiple modules successively. Its main purpose is to allow
/// the caller to access the internal procedure cache and/or module graph after a single call to
/// `assemble_test`.
#[cfg(any(test, feature = "testing"))]
#[doc(hidden)]
pub fn assemble_test(&mut self, source: impl Compile) -> Result<MastForest, Report> {
let mut context = AssemblyContext::default();
context.set_warnings_as_errors(self.warnings_as_errors);
let opts = CompileOptions {
warnings_as_errors: context.warnings_as_errors(),
..CompileOptions::default()
};

self.assemble_with_options_in_context_impl(source, opts, &mut context)
}

/// Like [Assembler::compile], but also takes an [AssemblyContext] to configure the assembler.
pub fn assemble_in_context(
self,
Expand Down
4 changes: 2 additions & 2 deletions assembly/src/assembler/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn nested_blocks() {
}
}

let mut assembler = Assembler::with_kernel_from_module(KERNEL)
let assembler = Assembler::with_kernel_from_module(KERNEL)
.unwrap()
.with_library(&DummyLibrary::default())
.unwrap();
Expand Down Expand Up @@ -119,7 +119,7 @@ fn nested_blocks() {
syscall.foo
end"#;

let program = assembler.assemble_test(program).unwrap();
let program = assembler.assemble(program).unwrap();

let exec_bar_node_id = {
// bar procedure
Expand Down
3 changes: 2 additions & 1 deletion assembly/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ impl TestContext {
#[track_caller]
pub fn assemble(&mut self, source: impl Compile) -> Result<Program, Report> {
self.assembler
.assemble_test(source)
.clone()
.assemble(source)
.map(|mast_forest| mast_forest.try_into().unwrap())
}

Expand Down

0 comments on commit f9c1d6e

Please sign in to comment.