[PPL-devel] [GIT] ppl/ppl(termination): Code for Polyhedron_all_affine_ranking_functions_PR and similar

Patricia Hill p.m.hill at leeds.ac.uk
Mon Mar 8 17:24:58 CET 2010


Module: ppl/ppl
Branch: termination
Commit: ea4a32cfd39ad59de60ca105540feef96207cd09
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=ea4a32cfd39ad59de60ca105540feef96207cd09

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Mon Mar  8 16:22:46 2010 +0000

Code for Polyhedron_all_affine_ranking_functions_PR and similar
revised - but is buggy. m4 version needs fixing.

---

 .../ppl_interface_generator_prolog_cc_code.m4      |   34 ++++++++++++-------
 .../ppl_interface_generator_prolog_hh_code.m4      |    8 ++--
 2 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
index 0fd0510..8792308 100644
--- a/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
+++ b/interfaces/Prolog/ppl_interface_generator_prolog_cc_code.m4
@@ -1231,12 +1231,12 @@ m4_define(`ppl_ at CLASS@_bounded_ at AFFIMAGE@_code',
 m4_define(`ppl_ at CLASS@_termination_test_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
   ppl_ at CLASS@_termination_test_ at TERMINATION_ID@
-  (Prolog_term_ref t_ph) {
+  (Prolog_term_ref t_pset) {
   static const char* where = "ppl_ at CLASS@_termination_test_ at TERMINATION_ID@/1";
   try {
-    @CPP_CLASS@* ph = term_to_handle<@CPP_CLASS@ >(t_ph, where);
+    @CPP_CLASS@* pset = term_to_handle<@CPP_CLASS@ >(t_pset, where);
     PPL_CHECK(ph);
-    if (Parma_Polyhedra_Library::termination_test_ at TERMINATION_ID@(*ph))
+    if (Parma_Polyhedra_Library::termination_test_ at TERMINATION_ID@(*pset))
         return PROLOG_SUCCESS;
   }
   CATCH_ALL;
@@ -1247,14 +1247,14 @@ m4_define(`ppl_ at CLASS@_termination_test_ at TERMINATION_ID@_code',
 m4_define(`ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
   ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@
-  (Prolog_term_ref t_x,
+  (Prolog_term_ref t_pset,
    Prolog_term_ref t_g) {
   static const char* where = "ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@/2";
   try {
-    @CPP_CLASS@* x = term_to_handle<@CPP_CLASS@ >(t_x, where);
+    @CPP_CLASS@* pset = term_to_handle<@CPP_CLASS@ >(t_pset, where);
     Generator gg(point());
-    PPL_CHECK(x);
-    if (Parma_Polyhedra_Library::one_affine_ranking_function_ at TERMINATION_ID@(*x, gg)
+    PPL_CHECK(pset);
+    if (Parma_Polyhedra_Library::one_affine_ranking_function_ at TERMINATION_ID@(*pset, gg)
         && Prolog_unify(t_g, generator_term(gg)))
         return PROLOG_SUCCESS;
   }
@@ -1266,16 +1266,24 @@ m4_define(`ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@_code',
 m4_define(`ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
   ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@
-  (Prolog_term_ref t_x,
+  (Prolog_term_ref t_pset,
    Prolog_term_ref t_ph) {
   static const char* where =
       "ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@/2";
   try {
-    @CPP_CLASS@* x = term_to_handle<@CPP_CLASS@ >(t_x, where);
-    C_Polyhedron* ph = term_to_handle<C_Polyhedron >(t_ph, where);
-    PPL_CHECK(x);
-    Parma_Polyhedra_Library::all_affine_ranking_functions_ at TERMINATION_ID@(*x,
-                                                                           *ph);
+    @CPP_CLASS@* pset = term_to_handle<@CPP_CLASS@ >(t_pset, where);
+    C_Polyhedron ph();
+    PPL_CHECK(pset);
+    Parma_Polyhedra_Library
+      ::all_affine_ranking_functions_ at TERMINATION_ID@(*pset, *ph);
+      Prolog_term_ref tmp = Prolog_new_term_ref();
+      Prolog_put_address(tmp, ph);
+      if (Prolog_unify(t_ph, tmp)) {
+                                    PPL_REGISTER(ph);
+                                    return PROLOG_SUCCESS;
+                                    }
+     else
+      delete ph;
     return PROLOG_SUCCESS;
   }
   CATCH_ALL;
diff --git a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4 b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
index 1c38748..16f3d03 100644
--- a/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
+++ b/interfaces/Prolog/ppl_interface_generator_prolog_hh_code.m4
@@ -513,20 +513,20 @@ m4_define(`ppl_ at CLASS@_ at MEMBYTES@_code',
 
 m4_define(`ppl_ at CLASS@_termination_test_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
-  ppl_ at CLASS@_termination_test_ at TERMINATION_ID@(Prolog_term_ref t_x);
+  ppl_ at CLASS@_termination_test_ at TERMINATION_ID@(Prolog_term_ref t_pset);
 
 ')
 
 m4_define(`ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
-  ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@(Prolog_term_ref t_x,
+  ppl_ at CLASS@_one_affine_ranking_function_ at TERMINATION_ID@(Prolog_term_ref t_pset,
                                              Prolog_term_ref t_g);
 
 ')
 
 m4_define(`ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@_code',
   `extern "C" Prolog_foreign_return_type
-  ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@(Prolog_term_ref t_x,
-                                              Prolog_term_ref t_g);
+  ppl_ at CLASS@_all_affine_ranking_functions_ at TERMINATION_ID@(Prolog_term_ref t_pset,
+                                              Prolog_term_ref t_ph);
 
 ')




More information about the PPL-devel mailing list