get rid of inference_limit_exceeded(B) as an error term (#2023)
This commit is contained in:
@@ -601,6 +601,8 @@ enum SystemClauseType {
|
|||||||
Name = "$keysort_with_constant_var_ordering"
|
Name = "$keysort_with_constant_var_ordering"
|
||||||
)))]
|
)))]
|
||||||
KeySortWithConstantVarOrdering,
|
KeySortWithConstantVarOrdering,
|
||||||
|
#[strum_discriminants(strum(props(Arity = "0", Name = "$inference_limit_exceeded")))]
|
||||||
|
InferenceLimitExceeded,
|
||||||
REPL(REPLCodePtr),
|
REPL(REPLCodePtr),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1727,6 +1729,7 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::CallUnattributedVar |
|
&Instruction::CallUnattributedVar |
|
||||||
&Instruction::CallGetDBRefs |
|
&Instruction::CallGetDBRefs |
|
||||||
&Instruction::CallKeySortWithConstantVarOrdering |
|
&Instruction::CallKeySortWithConstantVarOrdering |
|
||||||
|
&Instruction::CallInferenceLimitExceeded |
|
||||||
&Instruction::CallFetchGlobalVar |
|
&Instruction::CallFetchGlobalVar |
|
||||||
&Instruction::CallFirstStream |
|
&Instruction::CallFirstStream |
|
||||||
&Instruction::CallFlushOutput |
|
&Instruction::CallFlushOutput |
|
||||||
@@ -1960,6 +1963,7 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::ExecuteUnattributedVar |
|
&Instruction::ExecuteUnattributedVar |
|
||||||
&Instruction::ExecuteGetDBRefs |
|
&Instruction::ExecuteGetDBRefs |
|
||||||
&Instruction::ExecuteKeySortWithConstantVarOrdering |
|
&Instruction::ExecuteKeySortWithConstantVarOrdering |
|
||||||
|
&Instruction::ExecuteInferenceLimitExceeded |
|
||||||
&Instruction::ExecuteFetchGlobalVar |
|
&Instruction::ExecuteFetchGlobalVar |
|
||||||
&Instruction::ExecuteFirstStream |
|
&Instruction::ExecuteFirstStream |
|
||||||
&Instruction::ExecuteFlushOutput |
|
&Instruction::ExecuteFlushOutput |
|
||||||
|
|||||||
@@ -214,27 +214,6 @@ run_cleaners_without_handling(Cp) :-
|
|||||||
|
|
||||||
% call_with_inference_limit
|
% call_with_inference_limit
|
||||||
|
|
||||||
:- non_counted_backtracking end_block/4.
|
|
||||||
|
|
||||||
end_block(_, Bb, NBb, _L) :-
|
|
||||||
'$clean_up_block'(NBb),
|
|
||||||
'$reset_block'(Bb).
|
|
||||||
end_block(B, _Bb, NBb, L) :-
|
|
||||||
'$install_inference_counter'(B, L, _),
|
|
||||||
'$reset_block'(NBb),
|
|
||||||
'$fail'.
|
|
||||||
|
|
||||||
:- non_counted_backtracking handle_ile/3.
|
|
||||||
|
|
||||||
handle_ile(B, inference_limit_exceeded(B), R) :-
|
|
||||||
!,
|
|
||||||
R = inference_limit_exceeded,
|
|
||||||
'$pop_ball_stack'.
|
|
||||||
handle_ile(B, _, _) :-
|
|
||||||
'$remove_call_policy_check'(B),
|
|
||||||
'$pop_from_ball_stack',
|
|
||||||
'$unwind_stack'.
|
|
||||||
|
|
||||||
:- meta_predicate(call_with_inference_limit(0, ?, ?)).
|
:- meta_predicate(call_with_inference_limit(0, ?, ?)).
|
||||||
|
|
||||||
:- non_counted_backtracking call_with_inference_limit/3.
|
:- non_counted_backtracking call_with_inference_limit/3.
|
||||||
@@ -257,8 +236,6 @@ call_with_inference_limit(G, L, R) :-
|
|||||||
call_with_inference_limit(G, L, R, Bb, B),
|
call_with_inference_limit(G, L, R, Bb, B),
|
||||||
'$remove_call_policy_check'(B).
|
'$remove_call_policy_check'(B).
|
||||||
|
|
||||||
install_inference_counter(B, L, Count0) :-
|
|
||||||
'$install_inference_counter'(B, L, Count0).
|
|
||||||
|
|
||||||
:- meta_predicate(call_with_inference_limit(0,?,?,?,?)).
|
:- meta_predicate(call_with_inference_limit(0,?,?,?,?)).
|
||||||
|
|
||||||
@@ -266,23 +243,34 @@ install_inference_counter(B, L, Count0) :-
|
|||||||
|
|
||||||
call_with_inference_limit(G, L, R, Bb, B) :-
|
call_with_inference_limit(G, L, R, Bb, B) :-
|
||||||
'$install_new_block'(NBb),
|
'$install_new_block'(NBb),
|
||||||
'$install_inference_counter'(B, L, Count0),
|
'$install_inference_counter'(NBb, L, Count0),
|
||||||
'$call_with_inference_counting'(call(G)),
|
'$call_with_inference_counting'(call(G)),
|
||||||
'$inference_level'(R, B),
|
'$inference_level'(R, B),
|
||||||
'$remove_inference_counter'(B, Count1),
|
'$remove_inference_counter'(NBb, Count1),
|
||||||
Diff is L - (Count1 - Count0),
|
Diff is L - (Count1 - Count0),
|
||||||
end_block(B, Bb, NBb, Diff).
|
( '$clean_up_block'(NBb),
|
||||||
|
'$reset_block'(Bb)
|
||||||
|
; '$install_inference_counter'(NBb, Diff, _),
|
||||||
|
'$reset_block'(NBb),
|
||||||
|
'$fail'
|
||||||
|
).
|
||||||
call_with_inference_limit(_, _, R, Bb, B) :-
|
call_with_inference_limit(_, _, R, Bb, B) :-
|
||||||
|
( '$inference_limit_exceeded' ->
|
||||||
|
R = inference_limit_exceeded
|
||||||
|
; true
|
||||||
|
),
|
||||||
|
'$get_current_block'(NBb),
|
||||||
|
'$remove_inference_counter'(NBb, _),
|
||||||
'$reset_block'(Bb),
|
'$reset_block'(Bb),
|
||||||
'$remove_inference_counter'(B, _),
|
'$remove_call_policy_check'(B),
|
||||||
( '$get_ball'(Ball),
|
( '$get_ball'(_),
|
||||||
'$push_ball_stack',
|
'$push_ball_stack',
|
||||||
'$get_cp'(Cp),
|
'$get_cp'(Cp),
|
||||||
'$set_cp_by_default'(Cp)
|
'$set_cp_by_default'(Cp),
|
||||||
; '$remove_call_policy_check'(B),
|
'$pop_from_ball_stack',
|
||||||
'$fail'
|
'$unwind_stack'
|
||||||
),
|
; nonvar(R)
|
||||||
handle_ile(B, Ball, R).
|
).
|
||||||
|
|
||||||
%% partial_string(String, L, L0)
|
%% partial_string(String, L, L0)
|
||||||
%
|
%
|
||||||
|
|||||||
@@ -34,6 +34,15 @@ macro_rules! try_or_throw {
|
|||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! increment_call_count {
|
||||||
|
($s:expr) => {{
|
||||||
|
if !($s.increment_call_count_fn)(&mut $s) {
|
||||||
|
$s.backtrack();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! try_or_throw_gen {
|
macro_rules! try_or_throw_gen {
|
||||||
($s:expr, $e:expr) => {{
|
($s:expr, $e:expr) => {{
|
||||||
match $e {
|
match $e {
|
||||||
@@ -1096,12 +1105,7 @@ impl Machine {
|
|||||||
self.trust_me();
|
self.trust_me();
|
||||||
}
|
}
|
||||||
|
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1174,12 +1178,7 @@ impl Machine {
|
|||||||
self.trust_me();
|
self.trust_me();
|
||||||
}
|
}
|
||||||
|
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1205,19 +1204,11 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
&Instruction::RetryMeElse(offset) => {
|
&Instruction::RetryMeElse(offset) => {
|
||||||
self.retry_me_else(offset);
|
self.retry_me_else(offset);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
&Instruction::TrustMe(_) => {
|
&Instruction::TrustMe(_) => {
|
||||||
self.trust_me();
|
self.trust_me();
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
&Instruction::NeckCut => {
|
&Instruction::NeckCut => {
|
||||||
self.machine_st.neck_cut();
|
self.machine_st.neck_cut();
|
||||||
@@ -1521,11 +1512,7 @@ impl Machine {
|
|||||||
if self.machine_st.is_cyclic_term(addr) {
|
if self.machine_st.is_cyclic_term(addr) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1535,11 +1522,7 @@ impl Machine {
|
|||||||
if self.machine_st.is_cyclic_term(addr) {
|
if self.machine_st.is_cyclic_term(addr) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1549,11 +1532,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1563,11 +1542,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1577,11 +1552,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1591,11 +1562,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1605,11 +1572,7 @@ impl Machine {
|
|||||||
|
|
||||||
if let Some(Ordering::Greater) = compare_term_test!(self.machine_st, a1, a2)
|
if let Some(Ordering::Greater) = compare_term_test!(self.machine_st, a1, a2)
|
||||||
{
|
{
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
} else {
|
} else {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
@@ -1621,11 +1584,7 @@ impl Machine {
|
|||||||
|
|
||||||
if let Some(Ordering::Greater) = compare_term_test!(self.machine_st, a1, a2)
|
if let Some(Ordering::Greater) = compare_term_test!(self.machine_st, a1, a2)
|
||||||
{
|
{
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
} else {
|
} else {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
@@ -1636,11 +1595,7 @@ impl Machine {
|
|||||||
let a2 = self.machine_st.registers[2];
|
let a2 = self.machine_st.registers[2];
|
||||||
|
|
||||||
if let Some(Ordering::Less) = compare_term_test!(self.machine_st, a1, a2) {
|
if let Some(Ordering::Less) = compare_term_test!(self.machine_st, a1, a2) {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
} else {
|
} else {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
@@ -1651,11 +1606,7 @@ impl Machine {
|
|||||||
let a2 = self.machine_st.registers[2];
|
let a2 = self.machine_st.registers[2];
|
||||||
|
|
||||||
if let Some(Ordering::Less) = compare_term_test!(self.machine_st, a1, a2) {
|
if let Some(Ordering::Less) = compare_term_test!(self.machine_st, a1, a2) {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
} else {
|
} else {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
@@ -1667,11 +1618,7 @@ impl Machine {
|
|||||||
|
|
||||||
match compare_term_test!(self.machine_st, a1, a2) {
|
match compare_term_test!(self.machine_st, a1, a2) {
|
||||||
Some(Ordering::Greater | Ordering::Equal) => {
|
Some(Ordering::Greater | Ordering::Equal) => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -1685,11 +1632,7 @@ impl Machine {
|
|||||||
|
|
||||||
match compare_term_test!(self.machine_st, a1, a2) {
|
match compare_term_test!(self.machine_st, a1, a2) {
|
||||||
Some(Ordering::Greater | Ordering::Equal) => {
|
Some(Ordering::Greater | Ordering::Equal) => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -1703,11 +1646,7 @@ impl Machine {
|
|||||||
|
|
||||||
match compare_term_test!(self.machine_st, a1, a2) {
|
match compare_term_test!(self.machine_st, a1, a2) {
|
||||||
Some(Ordering::Less | Ordering::Equal) => {
|
Some(Ordering::Less | Ordering::Equal) => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -1721,11 +1660,7 @@ impl Machine {
|
|||||||
|
|
||||||
match compare_term_test!(self.machine_st, a1, a2) {
|
match compare_term_test!(self.machine_st, a1, a2) {
|
||||||
Some(Ordering::Less | Ordering::Equal) => {
|
Some(Ordering::Less | Ordering::Equal) => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -1739,11 +1674,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1753,11 +1684,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1768,11 +1695,7 @@ impl Machine {
|
|||||||
if self.machine_st.eq_test(a1, a2) {
|
if self.machine_st.eq_test(a1, a2) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1783,11 +1706,7 @@ impl Machine {
|
|||||||
if self.machine_st.eq_test(a1, a2) {
|
if self.machine_st.eq_test(a1, a2) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1795,11 +1714,7 @@ impl Machine {
|
|||||||
if self.machine_st.ground_test() {
|
if self.machine_st.ground_test() {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1807,11 +1722,7 @@ impl Machine {
|
|||||||
if self.machine_st.ground_test() {
|
if self.machine_st.ground_test() {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1821,11 +1732,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1835,11 +1742,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1850,11 +1753,7 @@ impl Machine {
|
|||||||
if let Some(Ordering::Equal) = compare_term_test!(self.machine_st, a1, a2) {
|
if let Some(Ordering::Equal) = compare_term_test!(self.machine_st, a1, a2) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1865,11 +1764,7 @@ impl Machine {
|
|||||||
if let Some(Ordering::Equal) = compare_term_test!(self.machine_st, a1, a2) {
|
if let Some(Ordering::Equal) = compare_term_test!(self.machine_st, a1, a2) {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1879,11 +1774,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1893,11 +1784,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1910,11 +1797,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1927,11 +1810,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1944,11 +1823,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1961,11 +1836,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1975,11 +1846,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1989,11 +1856,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2003,11 +1866,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2017,11 +1876,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2039,10 +1894,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Instruction::ExecuteN(arity) => {
|
&Instruction::ExecuteN(arity) => {
|
||||||
@@ -2059,10 +1911,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Instruction::DefaultCallN(arity) => {
|
&Instruction::DefaultCallN(arity) => {
|
||||||
@@ -2101,11 +1950,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Less | Ordering::Equal => {
|
Ordering::Less | Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2119,11 +1964,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Less | Ordering::Equal => {
|
Ordering::Less | Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2137,11 +1978,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Equal => {
|
Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2155,11 +1992,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Equal => {
|
Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2176,11 +2009,7 @@ impl Machine {
|
|||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2194,11 +2023,7 @@ impl Machine {
|
|||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2209,11 +2034,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Greater | Ordering::Equal => {
|
Ordering::Greater | Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2227,11 +2048,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Greater | Ordering::Equal => {
|
Ordering::Greater | Ordering::Equal => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2245,11 +2062,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2263,11 +2076,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2281,11 +2090,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Less => {
|
Ordering::Less => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p += 1;
|
self.machine_st.p += 1;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2299,11 +2104,7 @@ impl Machine {
|
|||||||
|
|
||||||
match n1.cmp(&n2) {
|
match n1.cmp(&n2) {
|
||||||
Ordering::Less => {
|
Ordering::Less => {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
|
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -2878,10 +2679,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Instruction::ExecuteNamed(arity, name, ref idx) => {
|
&Instruction::ExecuteNamed(arity, name, ref idx) => {
|
||||||
@@ -2892,10 +2690,7 @@ impl Machine {
|
|||||||
if self.machine_st.fail {
|
if self.machine_st.fail {
|
||||||
self.machine_st.backtrack();
|
self.machine_st.backtrack();
|
||||||
} else {
|
} else {
|
||||||
try_or_throw!(
|
increment_call_count!(self.machine_st);
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(&mut self.machine_st)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&Instruction::DefaultCallNamed(arity, name, ref idx) => {
|
&Instruction::DefaultCallNamed(arity, name, ref idx) => {
|
||||||
@@ -3224,26 +3019,14 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
&IndexedChoiceInstruction::Retry(l) => {
|
&IndexedChoiceInstruction::Retry(l) => {
|
||||||
self.retry(l);
|
self.retry(l);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
&IndexedChoiceInstruction::DefaultRetry(l) => {
|
&IndexedChoiceInstruction::DefaultRetry(l) => {
|
||||||
self.retry(l);
|
self.retry(l);
|
||||||
}
|
}
|
||||||
&IndexedChoiceInstruction::Trust(l) => {
|
&IndexedChoiceInstruction::Trust(l) => {
|
||||||
self.trust(l);
|
self.trust(l);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
&IndexedChoiceInstruction::DefaultTrust(l) => {
|
&IndexedChoiceInstruction::DefaultTrust(l) => {
|
||||||
self.trust(l);
|
self.trust(l);
|
||||||
@@ -3318,38 +3101,16 @@ impl Machine {
|
|||||||
// this is true iff ii + 1 < len.
|
// this is true iff ii + 1 < len.
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
self.retry(offset);
|
self.retry(offset);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self
|
|
||||||
.machine_st
|
|
||||||
.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.trust(offset);
|
self.trust(offset);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self
|
|
||||||
.machine_st
|
|
||||||
.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.trust(offset);
|
self.trust(offset);
|
||||||
|
increment_call_count!(self.machine_st);
|
||||||
try_or_throw!(
|
|
||||||
self.machine_st,
|
|
||||||
(self.machine_st.increment_call_count_fn)(
|
|
||||||
&mut self.machine_st
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5484,6 +5245,14 @@ impl Machine {
|
|||||||
self.get_db_refs();
|
self.get_db_refs();
|
||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
}
|
}
|
||||||
|
&Instruction::CallInferenceLimitExceeded => {
|
||||||
|
self.inference_limit_exceeded();
|
||||||
|
step_or_fail!(self, self.machine_st.p += 1);
|
||||||
|
}
|
||||||
|
&Instruction::ExecuteInferenceLimitExceeded => {
|
||||||
|
self.inference_limit_exceeded();
|
||||||
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ pub struct MachineState {
|
|||||||
pub(crate) unify_fn: fn(&mut MachineState),
|
pub(crate) unify_fn: fn(&mut MachineState),
|
||||||
pub(crate) bind_fn: fn(&mut MachineState, Ref, HeapCellValue),
|
pub(crate) bind_fn: fn(&mut MachineState, Ref, HeapCellValue),
|
||||||
pub(crate) run_cleaners_fn: fn(&mut Machine) -> bool,
|
pub(crate) run_cleaners_fn: fn(&mut Machine) -> bool,
|
||||||
pub(crate) increment_call_count_fn: fn(&mut MachineState) -> CallResult,
|
pub(crate) increment_call_count_fn: fn(&mut MachineState) -> bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for MachineState {
|
impl fmt::Debug for MachineState {
|
||||||
@@ -412,22 +412,24 @@ impl MachineState {
|
|||||||
self.fail = false;
|
self.fail = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn increment_call_count(&mut self) -> CallResult {
|
pub(crate) fn increment_call_count(&mut self) -> bool {
|
||||||
if self.cwil.inference_limit_exceeded || self.ball.stub.len() > 0 {
|
if self.cwil.inference_limit_exceeded || self.ball.stub.len() > 0 {
|
||||||
return Ok(());
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(&(ref limit, bp)) = self.cwil.limits.last() {
|
if let Some(&(ref limit, block)) = self.cwil.limits.last() {
|
||||||
if self.cwil.count == *limit {
|
if self.cwil.count == *limit {
|
||||||
self.cwil.inference_limit_exceeded = true;
|
self.cwil.inference_limit_exceeded = true;
|
||||||
|
self.block = block;
|
||||||
|
self.unwind_stack();
|
||||||
|
|
||||||
return Err(functor!(atom!("inference_limit_exceeded"), [fixnum(bp)]));
|
return false;
|
||||||
} else {
|
} else {
|
||||||
self.cwil.count += 1;
|
self.cwil.count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -945,7 +947,7 @@ impl MachineState {
|
|||||||
pub(crate) struct CWIL {
|
pub(crate) struct CWIL {
|
||||||
count: Integer,
|
count: Integer,
|
||||||
limits: Vec<(Integer, usize)>,
|
limits: Vec<(Integer, usize)>,
|
||||||
inference_limit_exceeded: bool,
|
pub(crate) inference_limit_exceeded: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CWIL {
|
impl CWIL {
|
||||||
@@ -957,22 +959,22 @@ impl CWIL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn add_limit(&mut self, limit: usize, b: usize) -> &Integer {
|
pub(crate) fn add_limit(&mut self, limit: usize, block: usize) -> &Integer {
|
||||||
let mut limit = Integer::from(limit);
|
let mut limit = Integer::from(limit);
|
||||||
limit += &self.count;
|
limit += &self.count;
|
||||||
|
|
||||||
match self.limits.last() {
|
match self.limits.last() {
|
||||||
Some((ref inner_limit, _)) if *inner_limit <= limit => {}
|
Some((ref inner_limit, _)) if *inner_limit <= limit => {}
|
||||||
_ => self.limits.push((limit, b)),
|
_ => self.limits.push((limit, block)),
|
||||||
};
|
};
|
||||||
|
|
||||||
&self.count
|
&self.count
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn remove_limit(&mut self, b: usize) -> &Integer {
|
pub(crate) fn remove_limit(&mut self, block: usize) -> &Integer {
|
||||||
if let Some((_, bp)) = self.limits.last() {
|
if let Some((_, bl)) = self.limits.last() {
|
||||||
if bp == &b {
|
if bl == &block {
|
||||||
self.limits.pop();
|
self.limits.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl MachineState {
|
|||||||
unify_fn: MachineState::unify,
|
unify_fn: MachineState::unify,
|
||||||
bind_fn: MachineState::bind,
|
bind_fn: MachineState::bind,
|
||||||
run_cleaners_fn: |_| false,
|
run_cleaners_fn: |_| false,
|
||||||
increment_call_count_fn: |_| Ok(()),
|
increment_call_count_fn: |_| true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5695,7 +5695,7 @@ impl Machine {
|
|||||||
|
|
||||||
if bp == self.machine_st.b && self.machine_st.cwil.is_empty() {
|
if bp == self.machine_st.b && self.machine_st.cwil.is_empty() {
|
||||||
self.machine_st.cwil.reset();
|
self.machine_st.cwil.reset();
|
||||||
self.machine_st.increment_call_count_fn = |_| Ok(());
|
self.machine_st.increment_call_count_fn = |_| true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5704,11 +5704,10 @@ impl Machine {
|
|||||||
let a1 = self.deref_register(1);
|
let a1 = self.deref_register(1);
|
||||||
let a2 = self.deref_register(2);
|
let a2 = self.deref_register(2);
|
||||||
|
|
||||||
let bp = cell_as_fixnum!(a1).get_num() as usize;
|
let block = cell_as_fixnum!(a1).get_num() as usize;
|
||||||
|
let count = self.machine_st.cwil.remove_limit(block).clone();
|
||||||
let count = self.machine_st.cwil.remove_limit(bp).clone();
|
|
||||||
|
|
||||||
let result = count.clone().try_into();
|
let result = count.clone().try_into();
|
||||||
|
|
||||||
if let Ok(value) = result{
|
if let Ok(value) = result{
|
||||||
self.machine_st.unify_fixnum(Fixnum::build_with(value), a2);
|
self.machine_st.unify_fixnum(Fixnum::build_with(value), a2);
|
||||||
} else {
|
} else {
|
||||||
@@ -5875,6 +5874,11 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub(crate) fn inference_limit_exceeded(&mut self) {
|
||||||
|
self.machine_st.fail = !self.machine_st.cwil.inference_limit_exceeded;
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn clean_up_block(&mut self) {
|
pub(crate) fn clean_up_block(&mut self) {
|
||||||
let nb = self.deref_register(1);
|
let nb = self.deref_register(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user