LS::evacuate(self)
}
- /*
- #[inline(always)]
- pub(crate) fn load_state(&mut self) -> &mut LoadStatePayload<<LS as LoadState<'a>>::TS> {
- self.payload.as_mut()
- }
- */
-
fn dequeue_terms(&mut self) -> Result<Option<Declaration>, SessionError> {
while !self.payload.term_stream.eof()? {
let load_state = &mut self.payload;
let term = load_state.term_stream.next(&composite_op_dir)?;
- // if is_consistent is false, self.predicates is not empty.
if !term.is_consistent(&load_state.predicates) {
self.compile_and_submit()?;
}
let machine_st = LS::machine_st(&mut self.payload);
let term_addr = machine_st[heap_term_loc];
- /*
- if let Ok(lit) = Literal::try_from(term_addr) {
- return Ok(Term::Literal(Cell::default(), lit));
- } else if machine_st.is_cyclic_term(term_addr) {
- return Err(SessionError::from(CompilationError::CannotParseCyclicTerm));
- }
- */
-
let mut term_stack = vec![];
let mut iter = stackful_post_order_iter(&mut machine_st.heap, term_addr);
; Term = [Item] ->
!,
( atom(Item) ->
- ( Item == user ->
- catch(load(user_input), E, print_exception_with_check(E))
- ;
- submit_query_and_print_results(consult(Item), [])
- )
+ ( Item == user ->
+ catch(load(user_input), E, print_exception_with_check(E))
+ ;
+ submit_query_and_print_results(consult(Item), [])
+ )
; catch(type_error(atom, Item, repl/0),
- E,
- print_exception_with_check(E))
+ E,
+ print_exception_with_check(E))
)
; Term = end_of_file ->
halt
submit_query_and_print_results(Term0, VarList) :-
( functor(Term0, call, _) ->
Term = Term0 % prevent pre-mature expansion of incomplete goal
- % in the first argument, which is done by call/N
+ % in the first argument, which is done by call/N
; expand_goal(Term0, user, Term)
),
setup_call_cleanup(bb_put('$first_answer', true),
needs_bracketing(Value, Op) :-
catch((functor(Value, F, _),
- current_op(EqPrec, EqSpec, Op),
- current_op(FPrec, _, F)),
- _,
- false),
+ current_op(EqPrec, EqSpec, Op),
+ current_op(FPrec, _, F)),
+ _,
+ false),
( EqPrec < FPrec ->
true
; FPrec > 0, F == Value, graphic_token_char(F) ->
write_goal(G, VarList, MaxDepth) :-
( G = (Var = Value) ->
( var(Value) ->
- select((Var = _), VarList, NewVarList)
+ select((Var = _), VarList, NewVarList)
; VarList = NewVarList
),
write(Var),
write(' = '),
( needs_bracketing(Value, (=)) ->
- write('('),
- write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
- write(')')
+ write('('),
+ write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
+ write(')')
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)])
)
; G == [] ->
write_last_goal(G, VarList, MaxDepth) :-
( G = (Var = Value) ->
( var(Value) ->
- select((Var = _), VarList, NewVarList)
+ select((Var = _), VarList, NewVarList)
; VarList = NewVarList
),
write(Var),
write(' = '),
( needs_bracketing(Value, (=)) ->
- write('('),
- write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
- write(')')
+ write('('),
+ write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
+ write(')')
; write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth)]),
- ( trailing_period_is_ambiguous(Value) ->
- write(' ')
- ; true
- )
+ ( trailing_period_is_ambiguous(Value) ->
+ write(' ')
+ ; true
+ )
)
; G == [] ->
write('true')
),
( B0 == B ->
( Goals == [] ->
- write('true.'), nl
+ write('true.'), nl
; loader:thread_goals(Goals, ThreadedGoals, (',')),
- write_eq(ThreadedGoals, NewVarList0, 20),
- write('.'),
- nl
+ write_eq(ThreadedGoals, NewVarList0, 20),
+ write('.'),
+ nl
)
; loader:thread_goals(Goals, ThreadedGoals, (',')),
write_eq(ThreadedGoals, NewVarList0, 20),