Typedefs | |
typedef p_goal_result(* | p_db_builtin )(p_context *context, p_term **args, p_term **error) |
typedef p_goal_result(* | p_db_arith )(p_context *context, p_arith_value *result, const p_arith_value *values, p_term **args, p_term **error) |
Enumerations | |
enum | p_op_specifier { P_OP_NONE, P_OP_XF, P_OP_YF, P_OP_XFX, P_OP_XFY, P_OP_YFX, P_OP_FX, P_OP_FY } |
enum | p_predicate_flags { P_PREDICATE_NONE = 0x00, P_PREDICATE_COMPILED = 0x01, P_PREDICATE_DYNAMIC = 0x02, P_PREDICATE_BUILTIN = 0x04 } |
Functions | |
p_op_specifier | p_db_operator_info (const p_term *name, int arity, int *priority) |
Retrieves the operator details for the atom name and the specified arity (1 or 2). | |
void | p_db_set_operator_info (p_term *name, p_op_specifier specifier, int priority) |
Sets the operator details for the atom name according to specifier and priority. | |
p_db_builtin | p_db_builtin_predicate (const p_term *name, int arity) |
Returns the builtin predicate function for name and arity, or null if there is no builtin predicate function. | |
void | p_db_set_builtin_predicate (p_term *name, int arity, p_db_builtin builtin) |
Sets the builtin predicate function for name and arity. | |
p_db_arith | p_db_builtin_arith (const p_term *name, int arity) |
Returns the builtin arithmetic function for name and arity, or null if there is no builtin arithmetic function. | |
void | p_db_set_builtin_arith (p_term *name, int arity, p_db_arith builtin) |
Sets the builtin arithmetic function for name and arity. | |
int | p_db_clause_assert_first (p_context *context, p_term *clause) |
Asserts clause as the first clause in a database predicate on context. | |
int | p_db_clause_assert_last (p_context *context, p_term *clause) |
Asserts clause as the last clause in a database predicate on context. | |
int | p_db_clause_retract (p_context *context, p_term *clause) |
Retracts clause from the predicate database on context. | |
int | p_db_clause_abolish (p_context *context, const p_term *name, int arity) |
Abolishes all clauses from the predicate database on context that match name and arity. | |
int | p_db_local_clause_assert_first (p_context *context, p_term *database, p_term *clause) |
Asserts clause as the first clause in a database predicate on context within the specified local database. | |
int | p_db_local_clause_assert_last (p_context *context, p_term *database, p_term *clause) |
Asserts clause as the last clause in a database predicate on context within the specified local database. | |
int | p_db_local_clause_retract (p_context *context, p_term *database, p_term *clause) |
Retracts clause from a local database on context. | |
int | p_db_local_clause_abolish (p_context *context, p_term *database, const p_term *name, int arity) |
Abolishes all clauses from a local database on context that match name and arity. | |
p_predicate_flags | p_db_predicate_flags (p_context *context, const p_term *name, int arity) |
Returns the flags associated with the predicate name / arity in context. | |
void | p_db_set_predicate_flag (p_context *context, p_term *name, int arity, p_predicate_flags flag, int value) |
Sets the flag associated with the predicate name / arity in context to value (0 or 1). |
This module manages the predicate an operator database.
This type defines the function prototype of a builtin arithmetic function.
The arguments are the execution context, a pointer to the result value, a pointer to an array of argument values, a pointer to the raw terms that resulted in the argument values, and a return pointer for error terms.
The return value should be one of P_RESULT_TRUE or P_RESULT_ERROR.
Builtin arithmetic functions must be deterministic; they cannot backtrack.
Definition at line 65 of file database.h.
This type defines the function prototype of a builtin predicate.
The arguments are the execution context, a pointer to the terms that define the predicates arguments, and a return pointer for error terms.
The return value should be one of P_RESULT_FAIL, P_RESULT_TRUE, or P_RESULT_ERROR.
Builtin predicates must be deterministic; they cannot backtrack.
Definition at line 50 of file database.h.
enum p_op_specifier |
This enum defines the specifier for a prefix, infix, or postfix operator.
Definition at line 29 of file database.h.
enum p_predicate_flags |
This enum defines flags that are associated with predicates in the database.
P_PREDICATE_NONE |
No flags are specified for the predicate. |
P_PREDICATE_COMPILED |
The predicate has been compiled into a read-only form that cannot be modified by asserta/1 and friends. |
P_PREDICATE_DYNAMIC |
The predicate is marked as dynamic. Its clauses will not be compiled. This is intended for predicates that are created dynamically in the database at runtime. |
P_PREDICATE_BUILTIN |
The predicate was set by p_db_set_builtin_predicate(), is read-only, and cannot be modified by asserta/1 and friends. |
Definition at line 40 of file database.h.
p_db_arith p_db_builtin_arith | ( | const p_term * | name, | |
int | arity | |||
) |
Returns the builtin arithmetic function for name and arity, or null if there is no builtin arithmetic function.
Definition at line 431 of file database.c.
p_db_builtin p_db_builtin_predicate | ( | const p_term * | name, | |
int | arity | |||
) |
Returns the builtin predicate function for name and arity, or null if there is no builtin predicate function.
Definition at line 344 of file database.c.
int p_db_clause_abolish | ( | p_context * | context, | |
const p_term * | name, | |||
int | arity | |||
) |
Abolishes all clauses from the predicate database on context that match name and arity.
Returns non-zero if the clauses were abolished, or zero if the predicate is compiled or builtin.
Definition at line 699 of file database.c.
int p_db_clause_assert_first | ( | p_context * | context, | |
p_term * | clause | |||
) |
Asserts clause as the first clause in a database predicate on context.
Returns non-zero if the clause was added, or zero if the predicate is builtin or compiled. It is assumed that clause is a freshly renamed term, is well-formed, and the top-level functor is "(:-)/2".
Definition at line 540 of file database.c.
int p_db_clause_assert_last | ( | p_context * | context, | |
p_term * | clause | |||
) |
Asserts clause as the last clause in a database predicate on context.
Returns non-zero if the clause was added, or zero if the predicate is compiled or builtin. It is assumed that clause is a freshly renamed term, is well-formed, and the top-level functor is "(:-)/2".
Definition at line 622 of file database.c.
int p_db_clause_retract | ( | p_context * | context, | |
p_term * | clause | |||
) |
Retracts clause from the predicate database on context.
Returns a positive value if the clause was retracted, zero if the predicate is compiled or builtin, or a negative value if there are no more matching clauses. It is assumed that the top-level functor of clause is "(:-)/2".
Definition at line 640 of file database.c.
int p_db_local_clause_abolish | ( | p_context * | context, | |
p_term * | database, | |||
const p_term * | name, | |||
int | arity | |||
) |
Abolishes all clauses from a local database on context that match name and arity.
Returns non-zero if the clauses were abolished, or zero if database is not a local database.
Definition at line 918 of file database.c.
int p_db_local_clause_assert_first | ( | p_context * | context, | |
p_term * | database, | |||
p_term * | clause | |||
) |
Asserts clause as the first clause in a database predicate on context within the specified local database.
Returns non-zero if the clause was added, or zero if database is not a local database. It is assumed that clause is a freshly renamed term, is well-formed, and the top-level functor is "(:-)/2".
Definition at line 735 of file database.c.
int p_db_local_clause_assert_last | ( | p_context * | context, | |
p_term * | database, | |||
p_term * | clause | |||
) |
Asserts clause as the last clause in a database predicate on context within the specified local database.
Returns non-zero if the clause was added, or zero if database is not a local database. It is assumed that clause is a freshly renamed term, is well-formed, and the top-level functor is "(:-)/2".
Definition at line 794 of file database.c.
int p_db_local_clause_retract | ( | p_context * | context, | |
p_term * | database, | |||
p_term * | clause | |||
) |
Retracts clause from a local database on context.
Returns a positive value if the clause was retracted, zero if database is not a local database, or a negative value if there are no more matching clauses. It is assumed that the top-level functor of clause is "(:-)/2".
Definition at line 853 of file database.c.
p_op_specifier p_db_operator_info | ( | const p_term * | name, | |
int | arity, | |||
int * | priority | |||
) |
Retrieves the operator details for the atom name and the specified arity (1 or 2).
Returns the operator prefix/infix/postfix specifier from the function, and return the operator priority in priority.
Definition at line 250 of file database.c.
p_predicate_flags p_db_predicate_flags | ( | p_context * | context, | |
const p_term * | name, | |||
int | arity | |||
) |
Returns the flags associated with the predicate name / arity in context.
Definition at line 951 of file database.c.
void p_db_set_builtin_arith | ( | p_term * | name, | |
int | arity, | |||
p_db_arith | builtin | |||
) |
Sets the builtin arithmetic function for name and arity.
If builtin is null, then the previous builtin function association is removed.
Definition at line 459 of file database.c.
void p_db_set_builtin_predicate | ( | p_term * | name, | |
int | arity, | |||
p_db_builtin | builtin | |||
) |
Sets the builtin predicate function for name and arity.
If builtin is null, then the previous builtin function association is removed.
Definition at line 372 of file database.c.
void p_db_set_operator_info | ( | p_term * | name, | |
p_op_specifier | specifier, | |||
int | priority | |||
) |
Sets the operator details for the atom name according to specifier and priority.
If priority is zero, then the operator details for specifier will be removed.
Definition at line 283 of file database.c.
void p_db_set_predicate_flag | ( | p_context * | context, | |
p_term * | name, | |||
int | arity, | |||
p_predicate_flags | flag, | |||
int | value | |||
) |
Sets the flag associated with the predicate name / arity in context to value (0 or 1).
Definition at line 976 of file database.c.