From 090f04c7e1d392aac3a9e0da771d0898df696da1 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Wed, 16 Jan 2019 19:05:07 -0700 Subject: [PATCH] drop_expansions whenever a compilation error occurs --- src/prolog/compile.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/prolog/compile.rs b/src/prolog/compile.rs index 5c1e0a3e..ed12fedc 100644 --- a/src/prolog/compile.rs +++ b/src/prolog/compile.rs @@ -437,12 +437,11 @@ impl ListingCompiler { } } -pub -fn compile_listing(wam: &mut Machine, src: R, mut indices: IndexStore) -> EvalSession +fn compile_work(compiler: &mut ListingCompiler, wam: &mut Machine, src: R, + mut indices: IndexStore) + -> EvalSession { - let mut compiler = ListingCompiler::new(&wam.code_repo); - let mut results = try_eval_session!(compiler.gather_items(wam, src, &mut indices) - .map_err(|e| compiler.drop_expansions(wam, e))); + let mut results = try_eval_session!(compiler.gather_items(wam, src, &mut indices)); let module_code = try_eval_session!(compiler.generate_code(results.worker_results, wam, &mut indices.code_dir)); @@ -465,6 +464,17 @@ fn compile_listing(wam: &mut Machine, src: R, mut indices: IndexStore) EvalSession::EntrySuccess } +#[inline] +pub fn compile_listing(wam: &mut Machine, src: R, indices: IndexStore) -> EvalSession +{ + let mut compiler = ListingCompiler::new(&wam.code_repo); + + match compile_work(&mut compiler, wam, src, indices) { + EvalSession::Error(e) => EvalSession::Error(compiler.drop_expansions(wam, e)), + result => result + } +} + fn setup_indices(wam: &mut Machine, indices: &mut IndexStore) -> Result<(), SessionError> { if let Some(builtins) = wam.indices.take_module(clause_name!("builtins")) { let flags = wam.machine_flags(); -- 2.54.0