remove SCCCutPolicy panic, revise (;)/2 so that comma'ed cuts are handled properly (#361)
This commit is contained in:
@@ -213,18 +213,36 @@ comma_errors(G1, G2, B) :- '$call_with_default_policy'(','(G1, G2, B)).
|
|||||||
|
|
||||||
;(G1, G2) :- '$get_b_value'(B), ;(G1, G2, B).
|
;(G1, G2) :- '$get_b_value'(B), ;(G1, G2, B).
|
||||||
|
|
||||||
|
:- non_counted_backtracking semicolon_compound_selector/3.
|
||||||
|
semicolon_compound_selector(->(G2, G3), G4, B) :-
|
||||||
|
( call(G2) ->
|
||||||
|
call(G3)
|
||||||
|
; '$set_cp'(B),
|
||||||
|
call(G4)
|
||||||
|
).
|
||||||
|
semicolon_compound_selector(','(G2, G3), G4, B) :-
|
||||||
|
( ','(G2, G3, B)
|
||||||
|
; '$set_cp'(B),
|
||||||
|
call(G4)
|
||||||
|
).
|
||||||
|
semicolon_compound_selector(';'(G2, G3), G4, B) :-
|
||||||
|
( ';'(G2, G3, B)
|
||||||
|
; '$set_cp'(B),
|
||||||
|
call(G4)
|
||||||
|
).
|
||||||
|
|
||||||
:- non_counted_backtracking (;)/3.
|
:- non_counted_backtracking (;)/3.
|
||||||
;(G1, G4, B) :- compound(G1),
|
;(G1, G4, B) :-
|
||||||
'$call_with_default_policy'(G1 = ->(G2, G3)),
|
compound(G1),
|
||||||
!,
|
semicolon_compound_selector(G1, G4, B).
|
||||||
( call(G2) -> call(G3)
|
;(G1, G2, B) :-
|
||||||
; '$set_cp'(B),
|
G1 == !, '$set_cp'(B), call(G2).
|
||||||
call(G4)
|
;(G1, G2, B) :-
|
||||||
).
|
G2 == !, call(G1), '$set_cp'(B).
|
||||||
;(G1, G2, B) :- G1 == !, '$set_cp'(B), call(G2).
|
;(G, _, _) :-
|
||||||
;(G1, G2, B) :- G2 == !, call(G1), '$set_cp'(B).
|
call(G).
|
||||||
;(G, _, _) :- call(G).
|
;(_, G, _) :-
|
||||||
;(_, G, _) :- call(G).
|
call(G).
|
||||||
|
|
||||||
G1 -> G2 :- '$get_b_value'(B), '$call_with_default_policy'(->(G1, G2, B)).
|
G1 -> G2 :- '$get_b_value'(B), '$call_with_default_policy'(->(G1, G2, B)).
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ scc_helper(C, G, Bb) :-
|
|||||||
; '$reset_block'(NBb),
|
; '$reset_block'(NBb),
|
||||||
'$fail').
|
'$fail').
|
||||||
scc_helper(_, _, Bb) :-
|
scc_helper(_, _, Bb) :-
|
||||||
'$reset_block'(Bb), '$get_ball'(Ball),
|
'$reset_block'(Bb),
|
||||||
|
'$get_ball'(Ball),
|
||||||
'$call_with_default_policy'(run_cleaners_with_handling),
|
'$call_with_default_policy'(run_cleaners_with_handling),
|
||||||
'$erase_ball',
|
'$erase_ball',
|
||||||
'$call_with_default_policy'(throw(Ball)).
|
'$call_with_default_policy'(throw(Ball)).
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ impl CodeRepo {
|
|||||||
.unwrap_or((Predicate::new(), VecDeque::from(vec![])))
|
.unwrap_or((Predicate::new(), VecDeque::from(vec![])))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_in_situ_result(
|
pub(crate)
|
||||||
|
fn add_in_situ_result(
|
||||||
&mut self,
|
&mut self,
|
||||||
result: &CompiledResult,
|
result: &CompiledResult,
|
||||||
in_situ_code_dir: &mut InSituCodeDir,
|
in_situ_code_dir: &mut InSituCodeDir,
|
||||||
@@ -100,16 +101,19 @@ impl CodeRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn size_of_cached_query(&self) -> usize {
|
pub(super)
|
||||||
|
fn size_of_cached_query(&self) -> usize {
|
||||||
self.cached_query.len()
|
self.cached_query.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn take_in_situ_code(&mut self) -> Code {
|
pub(super)
|
||||||
|
fn take_in_situ_code(&mut self) -> Code {
|
||||||
mem::replace(&mut self.in_situ_code, Code::new())
|
mem::replace(&mut self.in_situ_code, Code::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn lookup_instr<'a>(
|
pub(super)
|
||||||
|
fn lookup_instr<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
last_call: bool,
|
last_call: bool,
|
||||||
p: &CodePtr,
|
p: &CodePtr,
|
||||||
|
|||||||
@@ -2280,7 +2280,8 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => panic!("expected SCCCutPolicy trait object."),
|
None => {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.fail = true;
|
self.fail = true;
|
||||||
|
|||||||
@@ -934,7 +934,7 @@ impl RelationWorker {
|
|||||||
let mut term = *term;
|
let mut term = *term;
|
||||||
|
|
||||||
if let Term::Clause(cell, name, terms, op_spec) = term {
|
if let Term::Clause(cell, name, terms, op_spec) = term {
|
||||||
if name.as_str() == "," {
|
if name.as_str() == "," && terms.len() == 2 {
|
||||||
let term = Term::Clause(cell, name, terms, op_spec);
|
let term = Term::Clause(cell, name, terms, op_spec);
|
||||||
let mut subterms = unfold_by_str(term, ",");
|
let mut subterms = unfold_by_str(term, ",");
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
|
|
||||||
:- module('$toplevel', [repl/1, consult/1, use_module/1, use_module/2]).
|
:- module('$toplevel', ['$repl'/1, consult/1, use_module/1, use_module/2]).
|
||||||
|
|
||||||
:- use_module(library(charsio)).
|
:- use_module(library(charsio)).
|
||||||
:- use_module(library(lists)).
|
:- use_module(library(lists)).
|
||||||
:- use_module(library(si)).
|
:- use_module(library(si)).
|
||||||
|
|
||||||
repl([_|Args]) :-
|
'$repl'([_|Args]) :-
|
||||||
maplist(use_list_of_modules, Args),
|
maplist(use_list_of_modules, Args),
|
||||||
false.
|
false.
|
||||||
repl(_) :- repl.
|
'$repl'(_) :- repl.
|
||||||
|
|
||||||
use_list_of_modules(Mod0) :-
|
use_list_of_modules(Mod0) :-
|
||||||
atom_chars(Mod, Mod0),
|
atom_chars(Mod, Mod0),
|
||||||
|
|||||||
Reference in New Issue
Block a user