Skip to content

Commit

Permalink
Assembly: make recompute graph private
Browse files Browse the repository at this point in the history
  • Loading branch information
paracetamolo committed Dec 20, 2024
1 parent 25b3546 commit 93f7063
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion assembly/src/assembler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ impl Assembler {

// Recompute graph with executable module, and start compiling
let ast_module_index = self.module_graph.add_ast_module(program)?;
self.module_graph.recompute()?;

// Find the executable entrypoint Note: it is safe to use `unwrap_ast()` here, since this is
// the module we just added, which is in AST representation.
Expand Down
6 changes: 4 additions & 2 deletions assembly/src/assembler/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ impl ModuleGraph {
/// This function will panic if the number of modules exceeds the maximum representable
/// [ModuleIndex] value, `u16::MAX`.
pub fn add_ast_module(&mut self, module: Box<Module>) -> Result<ModuleIndex, AssemblyError> {
self.add_module(PendingWrappedModule::Ast(module))
let res = self.add_module(PendingWrappedModule::Ast(module))?;
self.recompute()?;
Ok(res)
}

fn add_module(&mut self, module: PendingWrappedModule) -> Result<ModuleIndex, AssemblyError> {
Expand Down Expand Up @@ -340,7 +342,7 @@ impl ModuleGraph {
/// NOTE: This will return `Err` if we detect a validation error, a cycle in the graph, or an
/// operation not supported by the current configuration. Basically, for any reason that would
/// cause the resulting graph to represent an invalid program.
pub fn recompute(&mut self) -> Result<(), AssemblyError> {
fn recompute(&mut self) -> Result<(), AssemblyError> {
// It is acceptable for there to be no changes, but if the graph is empty and no changes
// are being made, we treat that as an error
if self.modules.is_empty() && self.pending.is_empty() {
Expand Down

0 comments on commit 93f7063

Please sign in to comment.