]> Repositorios git - scryer-prolog.git/commitdiff
tighten =.. code
authorMark Thom <[email protected]>
Sat, 27 Jan 2018 22:54:05 +0000 (15:54 -0700)
committerMark Thom <[email protected]>
Sat, 27 Jan 2018 22:54:05 +0000 (15:54 -0700)
src/prolog/ast.rs
src/prolog/builtins.rs
src/prolog/io.rs
src/prolog/machine/machine_state.rs
src/prolog/macros.rs

index bc1d4804304393cf6a784605e7df94f2d9bb86eb..0bed72e0c18c1ec98ed4a38c43283e5eb87e67f1 100644 (file)
@@ -782,7 +782,8 @@ pub enum BuiltInInstruction {
     CompareNumber(CompareNumberQT, ArithmeticTerm, ArithmeticTerm),    
     EraseBall,
     Fail,
-    GetArg,
+    GetArgCall,
+    GetArgExecute,
     GetBall,
     GetCurrentBlock,
     GetCutPoint(RegType),
index 33309da22279f79463f8d512e356e352116de995..672e43ffb569a692f56d6eda2e56187f968f6ea7 100644 (file)
@@ -195,7 +195,7 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          functor_execute!(), // functor/3, 146.
          is_integer!(temp_v!(1)), // integer/1, 147.
          proceed!(),
-         get_arg!(), // get_arg/3, 149.
+         get_arg_execute!(), // get_arg/3, 149.
          try_me_else!(10), // arg/3, 150.
          allocate!(4),
          fact![get_var_in_fact!(perm_v!(1), 1),
@@ -358,7 +358,7 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          neck_cut!(),
          query![put_value!(temp_v!(6), 2),
                 put_value!(temp_v!(5), 3)],
-         arg_execute!(),
+         get_arg_execute!(),
          trust_me!(),
          allocate!(5),
          fact![get_list!(Level::Shallow, temp_v!(1)),
@@ -370,7 +370,7 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          query![put_value!(perm_v!(5), 1),
                 put_value!(perm_v!(3), 2),
                 put_value!(temp_v!(5), 3)],
-         arg_call!(),                     
+         get_arg_call!(),                     
          add!(ArithmeticTerm::Reg(perm_v!(5)),
               ArithmeticTerm::Number(rc_integer!(1)),
               1),
index 4c84bfbe5d93225e07ae4a95e26b74e91e1f2491..185eb3f76487b3d457a3737d64cfe084ad46f5d0 100644 (file)
@@ -124,9 +124,9 @@ impl fmt::Display for ControlInstruction {
             &ControlInstruction::ExecuteN(arity) =>
                 write!(f, "execute_N {}", arity),
             &ControlInstruction::FunctorCall =>
-                write!(f, "call_functor"),
+                write!(f, "functor_call"),
             &ControlInstruction::FunctorExecute =>
-                write!(f, "execute_functor"),
+                write!(f, "functor_execute"),
             &ControlInstruction::Deallocate =>
                 write!(f, "deallocate"),
             &ControlInstruction::Execute(ref name, arity) =>
@@ -179,8 +179,10 @@ impl fmt::Display for BuiltInInstruction {
                 write!(f, "erase_ball"),
             &BuiltInInstruction::Fail =>
                 write!(f, "false"),
-            &BuiltInInstruction::GetArg =>
-                write!(f, "get_arg X1, X2, X3"),
+            &BuiltInInstruction::GetArgCall =>
+                write!(f, "get_arg_call X1, X2, X3"),
+            &BuiltInInstruction::GetArgExecute =>
+                write!(f, "get_arg_execute X1, X2, X3"),
             &BuiltInInstruction::GetBall =>
                 write!(f, "get_ball X1"),
             &BuiltInInstruction::GetCurrentBlock =>
@@ -471,8 +473,6 @@ pub fn compile<'a, 'b: 'a>(wam: &'a mut Machine, tl: &'b TopLevelPacket) -> Eval
                 return EvalSession::from(e);
             };
 
-            print_code(&code);
-            
             if !code.is_empty() {
                 if let Some(name) = tl.name() {
                     wam.add_user_code(name, tl.arity(), code)
index 8fadde4a0a15cda8c27421d9c27dfe7d72fc56fc..bc0b6a8944e5f22cea2533db5dfee1742f74d9f9 100644 (file)
@@ -1325,7 +1325,13 @@ impl MachineState {
                 self.unify(a, Addr::Con(Constant::Number(result)));
                 self.p += 1;
             },
-            &BuiltInInstruction::GetArg =>
+            &BuiltInInstruction::GetArgCall =>
+                try_or_fail!(self, {                    
+                    let val = self.try_get_arg();
+                    self.p += 1;
+                    val
+                }),
+            &BuiltInInstruction::GetArgExecute =>
                 try_or_fail!(self, {
                     let val = self.try_get_arg();
                     self.p = self.cp;
index 564996d8d230e8cedbbd1c57d6ec34a7bad850e6..8219e59fdc4ddb8d1cd497395a50e6da8185cd9a 100644 (file)
@@ -358,18 +358,6 @@ macro_rules! functor_execute {
     )
 }
 
-macro_rules! arg_execute {
-    () => (
-        Line::Control(ControlInstruction::ArgExecute)
-    )
-}
-
-macro_rules! arg_call {
-    () => (
-        Line::Control(ControlInstruction::ArgCall)
-    )
-}
-
 macro_rules! unify_value {
     ($r:expr) => (
         FactInstruction::UnifyValue($r)
@@ -412,9 +400,15 @@ macro_rules! add {
     )
 }
 
-macro_rules! get_arg {
+macro_rules! get_arg_call {
+    () => (
+        Line::BuiltIn(BuiltInInstruction::GetArgCall)
+    )
+}
+
+macro_rules! get_arg_execute {
     () => (
-        Line::BuiltIn(BuiltInInstruction::GetArg)
+        Line::BuiltIn(BuiltInInstruction::GetArgExecute)
     )
 }