add fixes, further test cases.
This commit is contained in:
@@ -951,8 +951,9 @@ pub enum ArithmeticInstruction {
|
||||
|
||||
pub enum BuiltInInstruction {
|
||||
CleanUpBlock,
|
||||
CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
|
||||
CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),
|
||||
DefaultTrustMe,
|
||||
DefaultSetCutPoint(RegType),
|
||||
DynamicCompareNumber(CompareNumberQT),
|
||||
EraseBall,
|
||||
Fail,
|
||||
|
||||
@@ -119,7 +119,7 @@ fn get_builtins() -> Code {
|
||||
unify_variable!(temp_v!(1)),
|
||||
unify_variable!(temp_v!(2))],
|
||||
set_cp!(temp_v!(3)),
|
||||
goto_execute!(83, 3),
|
||||
goto_execute!(77, 3),
|
||||
retry_me_else!(4),
|
||||
fact![get_constant!(atom!("!"), temp_v!(1)),
|
||||
get_constant!(atom!("!"), temp_v!(2))],
|
||||
@@ -142,7 +142,7 @@ fn get_builtins() -> Code {
|
||||
put_unsafe_value!(1, 2),
|
||||
put_value!(perm_v!(3), 3)],
|
||||
deallocate!(),
|
||||
goto_execute!(83, 3),
|
||||
goto_execute!(77, 3),
|
||||
retry_me_else!(10),
|
||||
allocate!(2),
|
||||
get_level!(perm_v!(2)),
|
||||
@@ -475,7 +475,7 @@ fn get_builtins() -> Code {
|
||||
query![put_var!(perm_v!(1), 1)],
|
||||
get_ball!(),
|
||||
get_level!(perm_v!(2)),
|
||||
set_cp!(perm_v!(2)),
|
||||
default_set_cp!(perm_v!(2)),
|
||||
goto_call!(342, 0), // goto run_cleaners_with_handling/0, 342.
|
||||
query![put_unsafe_value!(1, 1)],
|
||||
deallocate!(),
|
||||
@@ -494,7 +494,7 @@ fn get_builtins() -> Code {
|
||||
put_var!(temp_v!(4), 2),
|
||||
put_constant!(Level::Shallow, atom!("true"), temp_v!(3))],
|
||||
goto_call!(5, 3), // goto catch/3, 5.
|
||||
set_cp!(perm_v!(1)),
|
||||
default_set_cp!(perm_v!(1)),
|
||||
deallocate!(),
|
||||
goto_execute!(342, 0), // goto run_cleaners_with_handling/0, 342.
|
||||
trust_me!(),
|
||||
@@ -506,7 +506,7 @@ fn get_builtins() -> Code {
|
||||
get_cleaner_call!(),
|
||||
query![put_value!(perm_v!(2), 1)],
|
||||
call_n!(1),
|
||||
set_cp!(perm_v!(1)),
|
||||
default_set_cp!(perm_v!(1)),
|
||||
deallocate!(),
|
||||
goto_execute!(354, 0), // goto run_cleaners_without_handling/0, 354.
|
||||
trust_me!(),
|
||||
|
||||
@@ -205,6 +205,8 @@ impl fmt::Display for BuiltInInstruction {
|
||||
match self {
|
||||
&BuiltInInstruction::CleanUpBlock =>
|
||||
write!(f, "clean_up_block"),
|
||||
&BuiltInInstruction::DefaultSetCutPoint(r) =>
|
||||
write!(f, "default_set_cp {}", r),
|
||||
&BuiltInInstruction::DefaultTrustMe =>
|
||||
write!(f, "default_trust_me"),
|
||||
&BuiltInInstruction::InstallInferenceCounter(r1, r2, r3) =>
|
||||
|
||||
@@ -1218,6 +1218,10 @@ impl MachineState {
|
||||
|
||||
self.compare_numbers(cmp, n1, n2);
|
||||
},
|
||||
&BuiltInInstruction::DefaultSetCutPoint(r) => {
|
||||
let mut default_cut_policy = DefaultCutPolicy {};
|
||||
default_cut_policy.cut(self, r);
|
||||
},
|
||||
&BuiltInInstruction::DefaultTrustMe => {
|
||||
let mut call_policy = DefaultCallPolicy {};
|
||||
try_or_fail!(self, call_policy.trust_me(self));
|
||||
@@ -1472,7 +1476,9 @@ impl MachineState {
|
||||
|
||||
self.p += 1;
|
||||
},
|
||||
&BuiltInInstruction::SetCutPoint(r) => {
|
||||
&BuiltInInstruction::SetCutPoint(r) =>
|
||||
cut_policy.cut(self, r),
|
||||
/*{
|
||||
let addr = self.store(self.deref(self[r].clone()));
|
||||
|
||||
match addr {
|
||||
@@ -1487,7 +1493,7 @@ impl MachineState {
|
||||
},
|
||||
_ => self.fail = true
|
||||
};
|
||||
},
|
||||
},*/
|
||||
&BuiltInInstruction::CleanUpBlock => {
|
||||
let nb = self.store(self.deref(self[temp_v!(1)].clone()));
|
||||
|
||||
|
||||
@@ -657,6 +657,12 @@ macro_rules! inference_level {
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! default_set_cp {
|
||||
($r:expr) => (
|
||||
Line::BuiltIn(BuiltInInstruction::DefaultSetCutPoint($r))
|
||||
)
|
||||
}
|
||||
|
||||
macro_rules! default_trust_me {
|
||||
() => (
|
||||
Line::BuiltIn(BuiltInInstruction::DefaultTrustMe)
|
||||
|
||||
@@ -1387,6 +1387,12 @@ fn test_queries_on_builtins()
|
||||
assert_prolog_success!(&mut wam, "?- [X,Y,Z] =@= [V,W,Z].");
|
||||
assert_prolog_success!(&mut wam, "?- [X,Y,X] =@= [V,W,V].");
|
||||
assert_prolog_success!(&mut wam, "?- g(B) = B, g(A) = A, A =@= B.");
|
||||
|
||||
assert_prolog_success!(&mut wam, "?- call(((G = 2 ; fail), B=3, !)).",
|
||||
[["G = 2", "B = 3"]]);
|
||||
|
||||
assert_prolog_success!(&mut wam, "?- call_with_inference_limit((setup_call_cleanup(S=1,(G=2;fail),display(S+G>B)), B=3, !), 100, R).",
|
||||
[["G = 2", "B = 3", "R = !", "S = 1"]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user