]> Repositorios git - scryer-prolog.git/commitdiff
remove $reify_switch
authorMark Thom <[email protected]>
Fri, 5 Apr 2019 15:04:05 +0000 (09:04 -0600)
committerMark Thom <[email protected]>
Fri, 5 Apr 2019 15:04:05 +0000 (09:04 -0600)
Cargo.toml
src/prolog/clause_types.rs
src/prolog/lib/reif.pl
src/prolog/machine/machine_errors.rs
src/prolog/machine/machine_state.rs

index a7d29b114a33a3bd096fab1dd225aa140eae2404..64cc437c16f88a10a5bfe3f94b5d94baef7b5cd0 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.40"
+version = "0.8.41"
 authors = ["Mark Thom <[email protected]>"]
 repository = "https://github.com/mthom/scryer-prolog"
 description = "A modern Prolog implementation written mostly in Rust."
index 1252a77a9c5069b789ecde0485e24b0994048669..30dde5645f3063d98e9185adbe2e1969f8628809 100644 (file)
@@ -129,7 +129,6 @@ ref_thread_local! {
         m.insert(("\\==", 2), ClauseType::BuiltIn(BuiltInClauseType::NotEq));
         m.insert(("partial_string", 2), ClauseType::BuiltIn(BuiltInClauseType::PartialString));
         m.insert(("read", 1), ClauseType::BuiltIn(BuiltInClauseType::Read));
-        m.insert(("$reify_switch", 3), ClauseType::BuiltIn(BuiltInClauseType::ReifySwitch));
         m.insert(("sort", 2), ClauseType::BuiltIn(BuiltInClauseType::Sort));
 
         m
@@ -391,7 +390,6 @@ pub enum BuiltInClauseType {
     NotEq,
     PartialString,
     Read,
-    ReifySwitch,
     Sort,
 }
 
@@ -424,7 +422,6 @@ impl BuiltInClauseType {
             &BuiltInClauseType::NotEq => clause_name!("\\=="),
             &BuiltInClauseType::PartialString => clause_name!("partial_string"),
             &BuiltInClauseType::Read => clause_name!("read"),
-            &BuiltInClauseType::ReifySwitch => clause_name!("$reify_switch"),
             &BuiltInClauseType::Sort => clause_name!("sort"),
         }
     }
@@ -446,7 +443,6 @@ impl BuiltInClauseType {
             &BuiltInClauseType::Nl => 0,
             &BuiltInClauseType::PartialString => 1,
             &BuiltInClauseType::Read => 1,
-            &BuiltInClauseType::ReifySwitch => 3,
             &BuiltInClauseType::Sort => 2,
         }
     }
index bdc43fada232da47afc3c12fec56254a248bc631..d57acaf2c1c3c77bbba46cf7b0f8795c6cb70985 100644 (file)
@@ -4,18 +4,13 @@
 
 :- use_module(library(dif)).
 
-/* in essence, '$reify_switch'(T, Then_0, Else_0) is semantically this,
-    (  T == true -> call(Then_0)
+if_(If_1, Then_0, Else_0) :-
+    call(If_1, T),
+    (  T == true  -> call(Then_0)
     ;  T == false -> call(Else_0)
     ;  nonvar(T) -> throw(error(type_error(boolean, T), _))
     ;  throw(error(instantiation_error, _))
     ).
-    but it does not create choice points.
-*/
-
-if_(If_1, Then_0, Else_0) :-
-    call(If_1, T),
-    '$call_with_default_policy'('$reify_switch'(T, Then_0, Else_0)).
 
 =(X, Y, T) :-
     (  X == Y -> T = true
index 02813de1891d234de93524120839cfca01a4279f..c7afcbbc48cb5216d4bd9f7fb82fa7c582e37c3e 100644 (file)
@@ -169,7 +169,7 @@ impl PermissionError {
 pub enum ValidType {
     Atom,
     Atomic,
-    Boolean,
+//    Boolean,
 //    Byte,
     Callable,
 //    Character,
@@ -190,7 +190,7 @@ impl ValidType {
         match self {
             ValidType::Atom => "atom",
             ValidType::Atomic => "atomic",
-            ValidType::Boolean => "boolean",
+//            ValidType::Boolean => "boolean",
 //            ValidType::Byte => "byte",
             ValidType::Callable => "callable",
 //            ValidType::Character => "character",
index 9ea77bc71db82758e4effe8ee6097a1d97c02dd8..656563c0783b4a3658f212b92d07b080a12bb8b8 100644 (file)
@@ -589,48 +589,6 @@ pub(crate) trait CallPolicy: Any {
 
                 return_from_clause!(machine_st.last_call, machine_st)
             },
-            &BuiltInClauseType::ReifySwitch => {
-                let truth_value = machine_st[temp_v!(1)].clone();
-                let truth_value = machine_st.store(machine_st.deref(truth_value));
-
-                match truth_value {
-                    Addr::Con(Constant::Atom(atom, spec)) =>
-                        match atom.as_str() {
-                            "true"  => {
-                                let t_branch = machine_st[temp_v!(2)].clone();
-
-                                machine_st[temp_v!(1)] = t_branch;
-                                self.call_n(machine_st, 1, indices)
-                            },
-                            "false" => {
-                                let f_branch = machine_st[temp_v!(3)].clone();
-
-                                machine_st[temp_v!(1)] = f_branch;
-                                self.call_n(machine_st, 1, indices)
-                            }
-                            _ => {
-                                let truth_value = Addr::Con(Constant::Atom(atom, spec));
-
-                                let stub = MachineError::functor_stub(clause_name!("if_"), 3);
-                                let err  = MachineError::type_error(ValidType::Boolean, truth_value);
-
-                                Err(machine_st.error_form(err, stub))
-                            }
-                        },
-                    ref addr if addr.is_ref() => {
-                        let stub = MachineError::functor_stub(clause_name!("if_"), 3);
-                        let err = MachineError::instantiation_error();
-
-                        Err(machine_st.error_form(err, stub))
-                    },
-                    addr => {
-                        let stub = MachineError::functor_stub(clause_name!("if_"), 3);
-                        let err = MachineError::type_error(ValidType::Boolean, addr);
-
-                        Err(machine_st.error_form(err, stub))
-                    }
-                }
-            },
             &BuiltInClauseType::CopyTerm => {
                 machine_st.copy_term();
                 return_from_clause!(machine_st.last_call, machine_st)