From: Mark Thom Date: Sat, 16 Feb 2019 21:40:56 +0000 (-0700) Subject: cleanup accessors, various other things X-Git-Tag: v0.8.110~248 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=d2afd2dd195cf9ea1dc048a9aee75fee56c0cb14;p=scryer-prolog.git cleanup accessors, various other things --- diff --git a/src/prolog/codegen.rs b/src/prolog/codegen.rs index 0f092411..24ad1676 100644 --- a/src/prolog/codegen.rs +++ b/src/prolog/codegen.rs @@ -498,6 +498,21 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator code.push(set_cp!(cell.get().norm())); } + fn compile_get_level_and_unify(&mut self, code: &mut Code, cell: &'a Cell, + var: Rc, term_loc: GenContext) + { + let mut target = Vec::new(); + + self.marker.reset_arg(1); + self.marker.mark_var(var, Level::Shallow, cell, term_loc, &mut target); + + if !target.is_empty() { + code.extend(target.into_iter().map(|query_instr| Line::Query(query_instr))); + } + + code.push(get_level_and_unify!(cell.get().norm())); + } + fn compile_seq(&mut self, iter: ChunkedIterator<'a>, conjunct_info: &ConjunctInfo<'a>, code: &mut Code, is_exposed: bool) -> Result<(), ParserError> @@ -511,21 +526,8 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator }; match *term { - &QueryTerm::GetLevelAndUnify(ref cell, ref var) => { - let mut target = Vec::new(); - - self.marker.reset_arg(1); - self.marker.mark_var(var.clone(), Level::Shallow, cell, - term_loc, &mut target); - - if !target.is_empty() { - for query_instr in target { - code.push(Line::Query(query_instr)); - } - } - - code.push(get_level_and_unify!(cell.get().norm())); - }, + &QueryTerm::GetLevelAndUnify(ref cell, ref var) => + self.compile_get_level_and_unify(code, cell, var.clone(), term_loc), &QueryTerm::UnblockedCut(ref cell) => self.compile_unblocked_cut(code, cell), &QueryTerm::BlockedCut => diff --git a/src/prolog/machine/attributed_variables.rs b/src/prolog/machine/attributed_variables.rs index b8216e2e..770bd36b 100644 --- a/src/prolog/machine/attributed_variables.rs +++ b/src/prolog/machine/attributed_variables.rs @@ -70,7 +70,6 @@ impl MachineState { count } - pub(super) fn verify_attributes(&mut self) { for (h, _) in &self.attr_var_init.bindings {