]> Repositorios git - scryer-prolog.git/commitdiff
remove DynamicIs
authorMark Thom <[email protected]>
Sat, 17 Mar 2018 21:01:31 +0000 (15:01 -0600)
committerMark Thom <[email protected]>
Sat, 17 Mar 2018 21:01:31 +0000 (15:01 -0600)
src/prolog/ast.rs
src/prolog/io.rs
src/prolog/machine/machine_state.rs
src/prolog/machine/machine_state_impl.rs
src/prolog/macros.rs

index 80456e2bd86366bbfb097a8e547e0f4fb8e25632..c09f118987589cc50c16fe0659e97be9f637ba75 100644 (file)
@@ -1236,7 +1236,6 @@ pub enum ControlInstruction {
     CallClause(ClauseType, usize, usize, bool), // name, arity, perm_vars after threshold, last call.
     CheckCpExecute,
     Deallocate,
-    DynamicIs,    
     GetCleanerCall,
     Goto(usize, usize, bool),  // p, arity, last call.
     IsClause(bool, RegType, ArithmeticTerm), // last call, register of var, term.
@@ -1248,7 +1247,6 @@ impl ControlInstruction {
     pub fn is_jump_instr(&self) -> bool {
         match self {
             &ControlInstruction::CallClause(..)  => true,
-            &ControlInstruction::DynamicIs => true,
             &ControlInstruction::GetCleanerCall => true,
             &ControlInstruction::Goto(..) => true,
             &ControlInstruction::IsClause(..) => true,
index 3b4824c4fcf5f35dcc8b0a8f420d4686431ec8c5..8652983af50e96db79bee655d995adce637569ef 100644 (file)
@@ -127,8 +127,6 @@ impl fmt::Display for ControlInstruction {
                 write!(f, "is_call {}, {}", r, at),
             &ControlInstruction::IsClause(true, r, ref at) =>
                 write!(f, "is_execute {}, {}", r, at),
-            &ControlInstruction::DynamicIs =>
-                write!(f, "call_is"),
             &ControlInstruction::JmpBy(arity, offset, pvs, false) =>
                 write!(f, "jmp_by_call {}/{}, {}", offset, arity, pvs),
             &ControlInstruction::JmpBy(arity, offset, pvs, true) =>
index dbc34905530bed43e74fbe1ec14ef2165b725656..7fed09af144599adcf62661309cdd8ed4c0c8e5a 100644 (file)
@@ -523,7 +523,16 @@ pub(crate) trait CallPolicy: Any {
                 machine_st.goto_ptr(CodePtr::DirEntry(294, clause_name!("builtin")), 3, lco);
                 Ok(())
             },
-            _ => panic!("(is)/2 or an inlined command: should have been superseded by previous clause.")
+            &ClauseType::Is => {
+                let a = machine_st[temp_v!(1)].clone();
+                let result = machine_st.arith_eval_by_metacall(temp_v!(2))?;
+
+                machine_st.unify(a, Addr::Con(Constant::Number(result)));
+                machine_st.p += 1;
+
+                Ok(())
+            },
+            _ => panic!("inlined command: should have been superseded by previous clause.")
         }
     }
 }
index 1d72446e0551c9015d13b98a0034a2c502b314cc..ba003d030054eab2118350c0673f09bda579df5a 100644 (file)
@@ -304,7 +304,7 @@ impl MachineState {
         Rc::new(BigInt::from_signed_bytes_le(&f(&u_n1, &u_n2).to_bytes_le()))
     }
 
-    fn arith_eval_by_metacall(&self, r: RegType) -> Result<Number, Vec<HeapCellValue>>
+    pub(super) fn arith_eval_by_metacall(&self, r: RegType) -> Result<Number, Vec<HeapCellValue>>
     {
         let instantiation_err = functor!("instantiation_error", 1, [heap_atom!("(is)/2")]);
         let a = self[r].clone();
@@ -1873,13 +1873,6 @@ impl MachineState {
 
                 self.p += 1;
             },
-            &ControlInstruction::DynamicIs => {
-                let a = self[temp_v!(1)].clone();
-                let result = try_or_fail!(self, self.arith_eval_by_metacall(temp_v!(2)));
-
-                self.unify(a, Addr::Con(Constant::Number(result)));
-                self.p += 1;
-            },
             &ControlInstruction::GetCleanerCall => {
                 let dest = self[temp_v!(1)].clone();
 
index 4c3a581617963a55b0e10cc00e3f748de1efbede..baa27346e5ba33359bf079628fb16a932fa538f2 100644 (file)
@@ -498,7 +498,7 @@ macro_rules! display {
 
 macro_rules! dynamic_is {
     () => (
-        Line::Control(ControlInstruction::DynamicIs)
+        Line::Control(ControlInstruction::CallClause(ClauseType::Is, 2, 0, false))
     )
 }