#include "ppl.hh"
#include "pwl.hh"
#include <gmp.h>
#include <SWI-Prolog.h>
#include <cassert>
#include "../exceptions.hh"
#include "../ppl_prolog.icc"
Go to the source code of this file.
Definition at line 383 of file ppl_swiprolog.cc.
typedef atom_t Prolog_atom |
Definition at line 40 of file ppl_swiprolog.cc.
typedef foreign_t Prolog_foreign_return_type |
Definition at line 41 of file ppl_swiprolog.cc.
typedef term_t Prolog_term_ref |
Definition at line 39 of file ppl_swiprolog.cc.
Prolog_term_ref @202::Coefficient_to_integer_term | ( | const PPL::Coefficient & | n | ) | [static] |
Definition at line 372 of file ppl_swiprolog.cc.
References Parma_Polyhedra_Library::assign_r(), Prolog_new_term_ref(), and tmp_mpz_class.
00372 { 00373 PPL::assign_r(tmp_mpz_class, n, PPL::ROUND_NOT_NEEDED); 00374 Prolog_term_ref t = Prolog_new_term_ref(); 00375 PL_unify_mpz(t, tmp_mpz_class.get_mpz_t()); 00376 return t; 00377 }
install_t install | ( | ) |
Definition at line 516 of file ppl_swiprolog.cc.
References ppl_initialize(), and predicates.
00516 { 00517 ppl_initialize(); 00518 PL_register_extensions(predicates); 00519 }
PPL::Coefficient @202::integer_term_to_Coefficient | ( | Prolog_term_ref | t | ) | [static] |
Definition at line 365 of file ppl_swiprolog.cc.
References Prolog_is_integer(), and tmp_mpz_class.
00365 { 00366 assert(Prolog_is_integer(t)); 00367 PL_get_mpz(t, tmp_mpz_class.get_mpz_t()); 00368 return PPL::Coefficient(tmp_mpz_class); 00369 }
void @202::ppl_Prolog_sysdep_deinit | ( | ) | [static] |
void @202::ppl_Prolog_sysdep_init | ( | ) | [static] |
Performs system-dependent initialization.
Definition at line 84 of file ppl_swiprolog.cc.
References Prolog_has_unbounded_integers, Prolog_max_integer, and Prolog_min_integer.
00084 { 00085 Prolog_has_unbounded_integers = true; 00086 Prolog_min_integer = 0; 00087 Prolog_max_integer = 0; 00088 }
Prolog_atom @202::Prolog_atom_from_string | ( | const char * | s | ) | [static] |
Return an atom whose name is given by the null-terminated string s
.
Definition at line 172 of file ppl_swiprolog.cc.
int @202::Prolog_construct_compound | ( | Prolog_term_ref | t, | |
Prolog_atom | f, | |||
Prolog_term_ref | a1, | |||
Prolog_term_ref | a2, | |||
Prolog_term_ref | a3, | |||
Prolog_term_ref | a4 | |||
) | [inline, static] |
Assign to t
a compound term whose principal functor is f
of arity 4 with arguments a1
, a2
, a3
and a4
.
Definition at line 215 of file ppl_swiprolog.cc.
int @202::Prolog_construct_compound | ( | Prolog_term_ref | t, | |
Prolog_atom | f, | |||
Prolog_term_ref | a1, | |||
Prolog_term_ref | a2, | |||
Prolog_term_ref | a3 | |||
) | [inline, static] |
Assign to t
a compound term whose principal functor is f
of arity 3 with arguments a1
, a2
and a3
.
Definition at line 203 of file ppl_swiprolog.cc.
int @202::Prolog_construct_compound | ( | Prolog_term_ref | t, | |
Prolog_atom | f, | |||
Prolog_term_ref | a1, | |||
Prolog_term_ref | a2 | |||
) | [inline, static] |
Assign to t
a compound term whose principal functor is f
of arity 2 with arguments a1
and a2
.
Definition at line 192 of file ppl_swiprolog.cc.
int @202::Prolog_construct_compound | ( | Prolog_term_ref | t, | |
Prolog_atom | f, | |||
Prolog_term_ref | a1 | |||
) | [inline, static] |
Assign to t
a compound term whose principal functor is f
of arity 1 with argument a1
.
Definition at line 181 of file ppl_swiprolog.cc.
int @202::Prolog_construct_cons | ( | Prolog_term_ref | c, | |
Prolog_term_ref | h, | |||
Prolog_term_ref | t | |||
) | [inline, static] |
Assign to c
a Prolog list whose head is h
and tail is t
.
Definition at line 226 of file ppl_swiprolog.cc.
int @202::Prolog_get_address | ( | Prolog_term_ref | t, | |
void ** | vpp | |||
) | [inline, static] |
If t
is the Prolog representation for a memory address, return true and store that address into v
; return false otherwise. The behavior is undefined if t
is not an address.
Definition at line 306 of file ppl_swiprolog.cc.
References Prolog_is_address().
00306 { 00307 assert(Prolog_is_address(t)); 00308 return PL_get_pointer(t, vpp); 00309 }
int @202::Prolog_get_arg | ( | int | i, | |
Prolog_term_ref | t, | |||
Prolog_term_ref | a | |||
) | [inline, static] |
If t
is a Prolog compound term and i
is a positive integer less than or equal to its arity, return true and assign to a
the i-th (principal) argument of t
. The behavior is undefined if t
is not a Prolog compound term.
Definition at line 339 of file ppl_swiprolog.cc.
References Prolog_is_compound().
00339 { 00340 assert(Prolog_is_compound(t)); 00341 return PL_get_arg(i, t, a); 00342 }
int @202::Prolog_get_atom_name | ( | Prolog_term_ref | t, | |
Prolog_atom * | ap | |||
) | [inline, static] |
If t
is a Prolog atom, return true and store its name into name
. The behavior is undefined if t
is not a Prolog atom.
Definition at line 316 of file ppl_swiprolog.cc.
References Prolog_is_atom().
00316 { 00317 assert(Prolog_is_atom(t)); 00318 return PL_get_atom(t, ap); 00319 }
int @202::Prolog_get_compound_name_arity | ( | Prolog_term_ref | t, | |
Prolog_atom * | ap, | |||
int * | ip | |||
) | [inline, static] |
If t
is a Prolog compound term, return true and store its name and arity into name
and arity
, respectively. The behavior is undefined if t
is not a Prolog compound term.
Definition at line 327 of file ppl_swiprolog.cc.
References Prolog_is_compound().
00327 { 00328 assert(Prolog_is_compound(t)); 00329 return PL_get_name_arity(t, ap, ip); 00330 }
int @202::Prolog_get_cons | ( | Prolog_term_ref | c, | |
Prolog_term_ref | h, | |||
Prolog_term_ref | t | |||
) | [inline, static] |
If c
is a Prolog cons (list constructor), assign its head and tail to h
and t
, respectively. The behavior is undefined if c
is not a Prolog cons.
Definition at line 350 of file ppl_swiprolog.cc.
References Prolog_is_cons().
00350 { 00351 assert(Prolog_is_cons(c)); 00352 return PL_get_list(c, h, t); 00353 }
int @202::Prolog_get_long | ( | Prolog_term_ref | t, | |
long * | lp | |||
) | [inline, static] |
Assuming t
is a Prolog integer, return true if its value fits in a long, in which case the value is assigned to v
, return false otherwise. The behavior is undefined if t
is not a Prolog integer.
Definition at line 295 of file ppl_swiprolog.cc.
References Prolog_is_integer().
00295 { 00296 assert(Prolog_is_integer(t)); 00297 return PL_get_long(t, lp); 00298 }
int @202::Prolog_is_address | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is the representation of an address, false otherwise.
Definition at line 268 of file ppl_swiprolog.cc.
int @202::Prolog_is_atom | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is a Prolog atom, false otherwise.
Definition at line 252 of file ppl_swiprolog.cc.
int @202::Prolog_is_compound | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is a Prolog compound term, false otherwise.
Definition at line 276 of file ppl_swiprolog.cc.
int @202::Prolog_is_cons | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is a Prolog list, false otherwise.
Definition at line 284 of file ppl_swiprolog.cc.
int @202::Prolog_is_integer | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is a Prolog integer, false otherwise.
Definition at line 260 of file ppl_swiprolog.cc.
int @202::Prolog_is_variable | ( | Prolog_term_ref | t | ) | [inline, static] |
Return true if t
is a Prolog variable, false otherwise.
Definition at line 244 of file ppl_swiprolog.cc.
Prolog_term_ref @202::Prolog_new_term_ref | ( | ) | [inline, static] |
int @202::Prolog_put_address | ( | Prolog_term_ref | t, | |
void * | p | |||
) | [inline, static] |
Assign to t
a term representing the address contained in p
.
Definition at line 163 of file ppl_swiprolog.cc.
int @202::Prolog_put_atom | ( | Prolog_term_ref | t, | |
Prolog_atom | a | |||
) | [inline, static] |
int @202::Prolog_put_atom_chars | ( | Prolog_term_ref | t, | |
const char * | s | |||
) | [inline, static] |
Assign to t
an atom whose name is given by the null-terminated string s
.
Definition at line 145 of file ppl_swiprolog.cc.
int @202::Prolog_put_long | ( | Prolog_term_ref | t, | |
long | l | |||
) | [inline, static] |
int @202::Prolog_put_term | ( | Prolog_term_ref | t, | |
Prolog_term_ref | u | |||
) | [inline, static] |
Make t
be a reference to the same term referenced by u
, i.e., assign u
to t
.
Definition at line 110 of file ppl_swiprolog.cc.
int @202::Prolog_put_ulong | ( | Prolog_term_ref | t, | |
unsigned long | ul | |||
) | [inline, static] |
Assign to t
a Prolog integer with value ul
.
Definition at line 128 of file ppl_swiprolog.cc.
References Parma_Polyhedra_Library::assign_r(), and tmp_mpz_class.
00128 { 00129 if (ul <= LONG_MAX) 00130 PL_put_integer(t, ul); 00131 else if (ul <= static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) 00132 PL_put_int64(t, static_cast<int64_t>(ul)); 00133 else { 00134 PPL::assign_r(tmp_mpz_class, ul, PPL::ROUND_NOT_NEEDED); 00135 PL_unify_mpz(t, tmp_mpz_class.get_mpz_t()); 00136 } 00137 return 1; 00138 }
void @202::Prolog_raise_exception | ( | Prolog_term_ref | t | ) | [inline, static] |
Raise a Prolog exception with t
as the exception term.
Definition at line 236 of file ppl_swiprolog.cc.
int @202::Prolog_unify | ( | Prolog_term_ref | t, | |
Prolog_term_ref | u | |||
) | [inline, static] |
Unify the terms referenced by t
and u
and return true if the unification is successful; return false otherwise.
Definition at line 360 of file ppl_swiprolog.cc.
install_t uninstall | ( | ) |
Definition at line 522 of file ppl_swiprolog.cc.
References ppl_finalize().
00522 { 00523 ppl_finalize(); 00524 }
PL_extension predicates[] [static] |
const Prolog_foreign_return_type PROLOG_FAILURE = FALSE [static] |
Definition at line 46 of file ppl_swiprolog.cc.
bool Prolog_has_unbounded_integers [static] |
True if and only if the Prolog engine supports unbounded integers.
Definition at line 59 of file ppl_swiprolog.cc.
long Prolog_max_integer [static] |
If Prolog_has_unbounded_integers
is false, holds the maximum integer value representable by a Prolog integer. Holds zero otherwise.
Definition at line 73 of file ppl_swiprolog.cc.
long Prolog_min_integer [static] |
If Prolog_has_unbounded_integers
is false, holds the minimum integer value representable by a Prolog integer. Holds zero otherwise.
Definition at line 66 of file ppl_swiprolog.cc.
const Prolog_foreign_return_type PROLOG_SUCCESS = TRUE [static] |
Definition at line 45 of file ppl_swiprolog.cc.
mpz_class tmp_mpz_class [static] |
Temporary used to communicate big integers between C++ and Prolog.
Definition at line 78 of file ppl_swiprolog.cc.
Referenced by Coefficient_to_integer_term(), integer_term_to_Coefficient(), Prolog_get_long(), and Prolog_put_ulong().