]> Repositorios git - scryer-prolog.git/commitdiff
drop_expansions whenever a compilation error occurs
authorMark Thom <[email protected]>
Thu, 17 Jan 2019 02:05:07 +0000 (19:05 -0700)
committerMark Thom <[email protected]>
Thu, 17 Jan 2019 02:05:07 +0000 (19:05 -0700)
src/prolog/compile.rs

index 5c1e0a3ee10c69cdee5aa6e90efd78a1e16e5751..ed12fedc5cbb147371648c8c4b2e5bd0492a428f 100644 (file)
@@ -437,12 +437,11 @@ impl ListingCompiler {
     }
 }
 
-pub
-fn compile_listing<R: Read>(wam: &mut Machine, src: R, mut indices: IndexStore) -> EvalSession
+fn compile_work<R: Read>(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<R: Read>(wam: &mut Machine, src: R, mut indices: IndexStore)
     EvalSession::EntrySuccess
 }
 
+#[inline]
+pub fn compile_listing<R: Read>(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();