Typedefs | |
typedef void(* | p_term_print_func )(void *data, const char *format,...) |
Functions | |
p_term * | p_term_expand_dcg (p_context *context, p_term *term) |
Expands the DCG rule in term to a full clause definition for context. | |
p_term * | p_term_sort (p_context *context, p_term *list, int flags) |
Sorts list according to the term precedes relationship. | |
p_term * | p_term_create_functor (p_context *context, p_term *name, int arg_count) |
Creates a functor term within ontext with the specified name and arg_count. Returns the new functor. | |
int | p_term_bind_functor_arg (p_term *term, int index, p_term *value) |
Binds the argument at index within the specified functor term to value. | |
p_term * | p_term_create_functor_with_args (p_context *context, p_term *name, p_term **args, int arg_count) |
Creates a functor term within ontext with the specified name and the arg_count members of args as arguments. Returns the new functor. | |
p_term * | p_term_create_list (p_context *context, p_term *head, p_term *tail) |
Creates a list term from head and tail within context. Returns the new list. | |
void | p_term_set_tail (p_term *list, p_term *tail) |
Sets the tail of list to tail. | |
p_term * | p_term_create_atom (p_context *context, const char *name) |
Creates an atom within context with the specified name. | |
p_term * | p_term_create_atom_n (p_context *context, const char *name, size_t len) |
Creates an atom within context with the len bytes at name as its atom name. | |
p_term * | p_term_create_string (p_context *context, const char *str) |
Creates a string within context with the specified str value. | |
p_term * | p_term_create_string_n (p_context *context, const char *str, size_t len) |
Creates a string within context with the len bytes from the specified str buffer. | |
p_term * | p_term_create_variable (p_context *context) |
Creates an unbound variable within context. | |
p_term * | p_term_create_named_variable (p_context *context, const char *name) |
Creates an unbound variable within context and associates it with name. | |
p_term * | p_term_create_member_variable (p_context *context, p_term *object, p_term *name, int auto_create) |
Creates an unbound member variable within context that refers to the member name within object. | |
p_term * | p_term_create_integer (p_context *context, int value) |
Creates an integer within context with the specified value. | |
p_term * | p_term_create_real (p_context *context, double value) |
Creates a real within context with the specified value. | |
p_term * | p_term_nil_atom (p_context *context) |
Returns the special "nil" atom that represents the empty list within context. | |
p_term * | p_term_prototype_atom (p_context *context) |
Returns the special "prototype" atom within context that names the prototype for an object. | |
p_term * | p_term_class_name_atom (p_context *context) |
Returns the special "className" atom within context that names the class of an object. | |
p_term * | p_term_deref (const p_term *term) |
Dereferences term to resolve bound variables. | |
p_term * | p_term_deref_member (p_context *context, p_term *term) |
Dereferences term to resolve bound variables within context. | |
p_term * | p_term_deref_own_member (p_context *context, p_term *term) |
Dereferences term to resolve bound variables within context. | |
int | p_term_type (const p_term *term) |
Returns the type of term after dereferencing it. | |
int | p_term_arg_count (const p_term *term) |
Returns the number of arguments for a functor or predicate term, or zero if term is not a functor or predicate. | |
const char * | p_term_name (const p_term *term) |
Returns the name of the functor, predicate, atom, or variable contained in term, or null if term does not have a name. | |
size_t | p_term_name_length (const p_term *term) |
Returns the length of the name of the functor, predicate, atom, or variable contained in term, or zero if term does not have a name. | |
size_t | p_term_name_length_utf8 (const p_term *term) |
Returns the UTF-8 length of the name of the functor, predicate, atom, or variable contained in term, or zero if term does not have a name. | |
p_term * | p_term_functor (const p_term *term) |
Returns the atom name of the functor or predicate term, or null if term is not a functor or predicate. | |
p_term * | p_term_arg (const p_term *term, int index) |
Returns the argument at position index within the functor term, or null if term is not a functor or index is out of range. | |
int | p_term_integer_value (const p_term *term) |
Returns the 32-bit signed integer value within term, or zero if term is not an integer term. | |
double | p_term_real_value (const p_term *term) |
Returns the double-precision floating point value within term, or zero if term is not a real term. | |
p_term * | p_term_head (const p_term *term) |
Returns the head of the specified list term, or null if term is not a list term. | |
p_term * | p_term_tail (const p_term *term) |
Returns the tail of the specified list term, or null if term is not a list term. | |
p_term * | p_term_object (const p_term *term) |
Returns the object term associated with a member variable reference term, or null if term is not a member variable reference. | |
p_term * | p_term_create_object (p_context *context, p_term *prototype) |
Creates an object term within context with the specified class prototype. | |
p_term * | p_term_create_class_object (p_context *context, p_term *class_name, p_term *prototype) |
Creates a class object term within context for the class called name with the specified base class prototype. | |
int | p_term_add_property (p_context *context, p_term *term, p_term *name, p_term *value) |
Adds name and value as a property to term within context. | |
p_term * | p_term_property (p_context *context, const p_term *term, const p_term *name) |
Returns the value associated with the property name on term within context, or null if name is not present. | |
p_term * | p_term_own_property (p_context *context, const p_term *term, const p_term *name) |
Returns the value associated with the property name on term within context, or null if name is not present. | |
int | p_term_set_own_property (p_context *context, p_term *term, p_term *name, p_term *value) |
Sets the value associated with the property name on term within context. | |
int | p_term_is_instance_object (p_context *context, const p_term *term) |
Returns non-zero if term is an object within context and term is not a class object, zero otherwise. | |
int | p_term_is_class_object (p_context *context, const p_term *term) |
Returns non-zero if term is a class object within context, zero otherwise. | |
int | p_term_inherits (p_context *context, const p_term *term1, const p_term *term2) |
Returns non-zero if term1 inherits from term2 within context, zero otherwise. | |
int | p_term_is_instance_of (p_context *context, const p_term *term1, const p_term *term2) |
Returns non-zero if term1 is an instance of term2, zero otherwise. | |
p_term * | p_term_create_predicate (p_context *context, p_term *name, int arg_count) |
Creates a new predicate instance within context with the specified name and arg_count arguments. | |
p_term * | p_term_create_dynamic_clause (p_context *context, p_term *head, p_term *body) |
Creates a new clause within context with the specified head and body. | |
void | p_term_add_clause_first (p_context *context, p_term *predicate, p_term *clause) |
Adds clause to predicate within context at the front of the predicate's clause list. | |
void | p_term_add_clause_last (p_context *context, p_term *predicate, p_term *clause) |
Adds clause to predicate within context at the end of the predicate's clause list. | |
void | p_term_clauses_begin (const p_term *predicate, const p_term *head, p_term_clause_iter *iter) |
Starts an iteration over the clauses of predicate, using iter as the iteration control information. | |
p_term * | p_term_clauses_next (p_term_clause_iter *iter) |
Returns the next clause for the iteration control block iter. | |
int | p_term_clauses_has_more (const p_term_clause_iter *iter) |
Returns non-zero if iter has more clauses yet to be iterated. | |
p_term * | p_term_create_database (p_context *context) |
Returns a new database term within context. | |
void | p_term_database_add_predicate (p_term *database, p_term *predicate) |
Adds predicate to database. | |
p_term * | p_term_database_lookup_predicate (p_term *database, p_term *name, int arity) |
Returns the predicate in database that is associated with name and arity. | |
p_term * | p_term_create_member_name (p_context *context, p_term *class_name, p_term *name) |
Returns an atom which is the concatenation of class_name, :: , and name. The atom is created within context. | |
int | p_term_bind_variable (p_context *context, p_term *var, p_term *value, int flags) |
Binds the variable var to value. | |
int | p_term_unify (p_context *context, p_term *term1, p_term *term2, int flags) |
Unifies term1 with term2 within context. | |
void | p_term_stdio_print_func (void *data, const char *format,...) |
Prints formatted output according to format to the stdio FILE stream data. | |
void | p_term_print (p_context *context, const p_term *term, p_term_print_func print_func, void *print_data) |
Prints term within context to the output stream defined by print_func and print_data. | |
void | p_term_print_unquoted (p_context *context, const p_term *term, p_term_print_func print_func, void *print_data) |
Prints term within context to the output stream defined by print_func and print_data. | |
void | p_term_print_with_vars (p_context *context, const p_term *term, p_term_print_func print_func, void *print_data, const p_term *vars) |
Prints term within context to the output stream defined by print_func and print_data. | |
int | p_term_precedes (p_context *context, const p_term *term1, const p_term *term2) |
Returns -1, 0, or 1 depending upon whether term1 is less than, equal to, or greater than term2 using the "precedes" relationship. The terms are compared within context. | |
int | p_term_is_ground (const p_term *term) |
Returns non-zero if term is a ground term without any unbound variables; zero otherwise. | |
p_term * | p_term_clone (p_context *context, p_term *term) |
Clones term within context to create a new term that has freshly renamed versions of the variables within term. | |
p_term * | p_term_unify_clause (p_context *context, p_term *term, p_term *clause) |
Unifies term with the renamed head of clause. | |
int | p_term_strcmp (const p_term *str1, const p_term *str2) |
Compares str1 and str2 and returns a comparison code. | |
p_term * | p_term_concat_string (p_context *context, p_term *str1, p_term *str2) |
Concatenates str1 and str2 to create a new string. | |
p_term * | p_term_witness (p_context *context, p_term *term, p_term **subgoal) |
Returns a list of the free variables in term, where each free variable occurs only once in the list. |
This module provides functions for creating Plang terms and operating on them. Terms may have a number of special forms, described by their p_term_type(): functors, lists, atoms, strings, variables, integers, reals, objects, and predicates.
This module is concerned with creating and managing terms from native C applications and builtin predicates. See Language Syntax - Terms for information on how to create terms in the Plang language.
The p_term_print_func function pointer type is used by p_term_print() to output printf-style formatted data to an output stream.
void p_term_add_clause_first | ( | p_context * | context, | |
p_term * | predicate, | |||
p_term * | clause | |||
) |
Adds clause to predicate within context at the front of the predicate's clause list.
The predicate is assumed to be of type P_TERM_PREDICATE and already dereferenced.
The clause is assumed to be of type P_TERM_CLAUSE to have the same number of arguments as predicate.
void p_term_add_clause_last | ( | p_context * | context, | |
p_term * | predicate, | |||
p_term * | clause | |||
) |
Adds clause to predicate within context at the end of the predicate's clause list.
The predicate is assumed to be of type P_TERM_PREDICATE and already dereferenced.
The clause is assumed to be of type P_TERM_CLAUSE to have the same number of arguments as predicate.
int p_term_add_property | ( | p_context * | context, | |
p_term * | term, | |||
p_term * | name, | |||
p_term * | value | |||
) |
Adds name and value as a property to term within context.
Returns non-zero if the property was added, or zero if the parameters are invalid. The term must be an object, and name must be an atom other than "prototype" or "className".
This function does not check if name is already a property on the term, so it should only be used to add new properties.
p_term* p_term_arg | ( | const p_term * | term, | |
int | index | |||
) |
Returns the argument at position index within the functor term, or null if term is not a functor or index is out of range.
The term is automatically dereferenced.
int p_term_arg_count | ( | const p_term * | term | ) |
Returns the number of arguments for a functor or predicate term, or zero if term is not a functor or predicate.
The term is automatically dereferenced.
int p_term_bind_functor_arg | ( | p_term * | term, | |
int | index, | |||
p_term * | value | |||
) |
Binds the argument at index within the specified functor term to value.
Returns non-zero if the bind was successful, or zero if term is not a functor, index is out of range, value is invalid, or the argument has already been bound.
int p_term_bind_variable | ( | p_context * | context, | |
p_term * | var, | |||
p_term * | value, | |||
int | flags | |||
) |
Binds the variable var to value.
Returns non-zero if the bind was successful, or zero if var is already bound, if var is not a variable, or if creating the binding would introduce a circularity into value.
If flags does not contain P_BIND_NO_OCCURS_CHECK, then the bind will fail if var occurs within value as performing the binding will create a circularity.
If flags does not contain P_BIND_NO_RECORD, then the binding will be recorded in context for back-tracking purposes.
p_term* p_term_class_name_atom | ( | p_context * | context | ) |
Returns the special "className" atom within context that names the class of an object.
Returns the atom with the name "className". This function is equivalent to calling p_term_create_atom() with "className" as the argument, but is more efficient.
void p_term_clauses_begin | ( | const p_term * | predicate, | |
const p_term * | head, | |||
p_term_clause_iter * | iter | |||
) |
Starts an iteration over the clauses of predicate, using iter as the iteration control information.
If head is not null and the predicate is indexed, then iterate over the best list of clauses that match head according to the index.
Use p_term_clauses_next() to iterate through the returned list.
int p_term_clauses_has_more | ( | const p_term_clause_iter * | iter | ) |
Returns non-zero if iter has more clauses yet to be iterated.
p_term* p_term_clauses_next | ( | p_term_clause_iter * | iter | ) |
Returns the next clause for the iteration control block iter.
p_term* p_term_clone | ( | p_context * | context, | |
p_term * | term | |||
) |
Clones term within context to create a new term that has freshly renamed versions of the variables within term.
p_term* p_term_concat_string | ( | p_context * | context, | |
p_term * | str1, | |||
p_term * | str2 | |||
) |
Concatenates str1 and str2 to create a new string.
Returns the concatenated string, or null if str1 or str2 is not a string.
p_term* p_term_create_atom | ( | p_context * | context, | |
const char * | name | |||
) |
Creates an atom within context with the specified name.
Returns the atom term. The same term will be returned every time this function is called for the same name on context. This allows atoms to be quickly compared for equality by comparing their pointers. By comparison, p_term_create_string() creates a new term every time it is called.
Atoms and strings are not unifiable as they are different types of terms. Atoms typically represent identifiers in the program, whereas strings represent human-readable data for the program.
The name should be encoded in the UTF-8 character set. Use p_term_create_atom_n() for names with embedded NUL's.
p_term* p_term_create_atom_n | ( | p_context * | context, | |
const char * | name, | |||
size_t | len | |||
) |
Creates an atom within context with the len bytes at name as its atom name.
Returns the atom term. The same term will be returned every time this function is called for the same name on context. This allows atoms to be quickly compared for equality by comparing their pointers. By comparison, p_term_create_string() creates a new term every time it is called.
Atoms and strings are not unifiable as they are different types of terms. Atoms typically represent identifiers in the program, whereas strings represent human-readable data for the program.
The name should be encoded in the UTF-8 character.
p_term* p_term_create_class_object | ( | p_context * | context, | |
p_term * | class_name, | |||
p_term * | prototype | |||
) |
Creates a class object term within context for the class called name with the specified base class prototype.
Returns the class object term. The class_name must be an atom, and the prototype must be an object or null.
p_term* p_term_create_database | ( | p_context * | context | ) |
Returns a new database term within context.
p_term* p_term_create_dynamic_clause | ( | p_context * | context, | |
p_term * | head, | |||
p_term * | body | |||
) |
Creates a new clause within context with the specified head and body.
p_term* p_term_create_functor | ( | p_context * | context, | |
p_term * | name, | |||
int | arg_count | |||
) |
Creates a functor term within ontext with the specified name and arg_count. Returns the new functor.
The arguments will be initially unbound. This function should be followed to calls to lc_term_bind_functor_arg() to bind the arguments to specific terms.
p_term* p_term_create_functor_with_args | ( | p_context * | context, | |
p_term * | name, | |||
p_term ** | args, | |||
int | arg_count | |||
) |
Creates a functor term within ontext with the specified name and the arg_count members of args as arguments. Returns the new functor.
p_term* p_term_create_integer | ( | p_context * | context, | |
int | value | |||
) |
Creates an integer within context with the specified value.
Returns the integer term.
p_term* p_term_create_list | ( | p_context * | context, | |
p_term * | head, | |||
p_term * | tail | |||
) |
Creates a list term from head and tail within context. Returns the new list.
p_term* p_term_create_member_name | ( | p_context * | context, | |
p_term * | class_name, | |||
p_term * | name | |||
) |
Returns an atom which is the concatenation of class_name, ::
, and name. The atom is created within context.
This function is typically used to create the name of a member predicate within a class.
p_term* p_term_create_member_variable | ( | p_context * | context, | |
p_term * | object, | |||
p_term * | name, | |||
int | auto_create | |||
) |
Creates an unbound member variable within context that refers to the member name within object.
Returns the member variable term. The name must be an atom.
If auto_create is non-zero, then the member name will be added to the object during unification if it doesn't exist. If auto_create is zero, then unification will fail if the member name does not exist.
p_term* p_term_create_named_variable | ( | p_context * | context, | |
const char * | name | |||
) |
Creates an unbound variable within context and associates it with name.
Returns the variable term. The name is for primarily for debugging purposes.
p_term* p_term_create_object | ( | p_context * | context, | |
p_term * | prototype | |||
) |
Creates an object term within context with the specified class prototype.
Returns the object term. The prototype must be an object.
p_term* p_term_create_predicate | ( | p_context * | context, | |
p_term * | name, | |||
int | arg_count | |||
) |
Creates a new predicate instance within context with the specified name and arg_count arguments.
The predicate will initially have no clauses. Use p_term_add_clause_first() and p_term_add_clause_last() to add clauses to the predicate.
p_term* p_term_create_real | ( | p_context * | context, | |
double | value | |||
) |
Creates a real within context with the specified value.
Returns the real term.
p_term* p_term_create_string | ( | p_context * | context, | |
const char * | str | |||
) |
Creates a string within context with the specified str value.
Returns the string term. Unlike p_term_create_atom(), a new term is returned every time this function is called.
Atoms and strings are not unifiable as they are different types of terms. Atoms typically represent identifiers in the program, whereas strings represent human-readable data for the program.
The str should be encoded in the UTF-8 character set. Use p_term_create_string_n() for strings with embedded NUL characters.
p_term* p_term_create_string_n | ( | p_context * | context, | |
const char * | str, | |||
size_t | len | |||
) |
Creates a string within context with the len bytes from the specified str buffer.
Returns the string term. Unlike p_term_create_atom(), a new term is returned every time this function is called.
Atoms and strings are not unifiable as they are different types of terms. Atoms typically represent identifiers in the program, whereas strings represent human-readable data for the program.
The str should be encoded in the UTF-8 character set.
p_term* p_term_create_variable | ( | p_context * | context | ) |
Creates an unbound variable within context.
Returns the variable term.
void p_term_database_add_predicate | ( | p_term * | database, | |
p_term * | predicate | |||
) |
Adds predicate to database.
p_term* p_term_database_lookup_predicate | ( | p_term * | database, | |
p_term * | name, | |||
int | arity | |||
) |
Returns the predicate in database that is associated with name and arity.
Returns null if the predicate is not present in the local database.
p_term* p_term_deref | ( | const p_term * | term | ) |
Dereferences term to resolve bound variables.
Returns the dereferenced version of term, or null if term is null. The result may be a variable if it is unbound.
Dereferencing is needed when terms of type P_TERM_VARIABLE or P_TERM_MEMBER_VARIABLE are bound to other terms during unification. Normally dereferencing is performed automatically by term query functions such as p_term_type(), p_term_arg_count(), p_term_name(), etc.
p_term* p_term_deref_member | ( | p_context * | context, | |
p_term * | term | |||
) |
Dereferences term to resolve bound variables within context.
Returns the dereferenced version of term, or null if term is null. The result may be a variable if it is unbound.
This function differs from p_term_deref() in that it will attempt to resolve P_TERM_MEMBER_VARIABLE references, recording their bindings in the trail of context for back-tracking.
p_term* p_term_deref_own_member | ( | p_context * | context, | |
p_term * | term | |||
) |
Dereferences term to resolve bound variables within context.
Returns the dereferenced version of term, or null if term is null. The result may be a variable if it is unbound.
This function differs from p_term_deref_member() in that it will only resolve member references on the object itself, not on class prototypes. This is typically used in the implementation of variable assignment predicates such as (:=)/2 where the class prototype should be read-only with respect to an assignment to an object property.
p_term* p_term_expand_dcg | ( | p_context * | context, | |
p_term * | term | |||
) |
p_term* p_term_functor | ( | const p_term * | term | ) |
Returns the atom name of the functor or predicate term, or null if term is not a functor or predicate.
The term is automatically dereferenced.
p_term* p_term_head | ( | const p_term * | term | ) |
Returns the head of the specified list term, or null if term is not a list term.
The term is automatically dereferenced.
int p_term_inherits | ( | p_context * | context, | |
const p_term * | term1, | |||
const p_term * | term2 | |||
) |
Returns non-zero if term1 inherits from term2 within context, zero otherwise.
The terms are automatically dereferenced.
int p_term_integer_value | ( | const p_term * | term | ) |
Returns the 32-bit signed integer value within term, or zero if term is not an integer term.
The term is automatically dereferenced.
int p_term_is_class_object | ( | p_context * | context, | |
const p_term * | term | |||
) |
Returns non-zero if term is a class object within context, zero otherwise.
The term is automatically dereferenced.
int p_term_is_ground | ( | const p_term * | term | ) |
int p_term_is_instance_object | ( | p_context * | context, | |
const p_term * | term | |||
) |
Returns non-zero if term is an object within context and term is not a class object, zero otherwise.
The term is automatically dereferenced.
int p_term_is_instance_of | ( | p_context * | context, | |
const p_term * | term1, | |||
const p_term * | term2 | |||
) |
Returns non-zero if term1 is an instance of term2, zero otherwise.
The terms are automatically dereferenced. The term1 must be an instance object, and term2 must be a class object.
const char* p_term_name | ( | const p_term * | term | ) |
Returns the name of the functor, predicate, atom, or variable contained in term, or null if term does not have a name.
The term is automatically dereferenced.
size_t p_term_name_length | ( | const p_term * | term | ) |
Returns the length of the name of the functor, predicate, atom, or variable contained in term, or zero if term does not have a name.
The term is automatically dereferenced. The returned length is in bytes. Use p_term_name_length_utf8() to get the length in logical characters.
size_t p_term_name_length_utf8 | ( | const p_term * | term | ) |
Returns the UTF-8 length of the name of the functor, predicate, atom, or variable contained in term, or zero if term does not have a name.
The term is automatically dereferenced. The returned length is in logcial UTF-8 characters. Use p_term_name_length() to get the length in bytes.
p_term* p_term_nil_atom | ( | p_context * | context | ) |
Returns the special "nil" atom that represents the empty list within context.
Returns the atom with the name "[]". This function is equivalent to calling p_term_create_atom() with "[]" as the argument, but is more efficient.
p_term* p_term_object | ( | const p_term * | term | ) |
Returns the object term associated with a member variable reference term, or null if term is not a member variable reference.
The term is automatically dereferenced. The p_term_name() function can be used to retrive the name of the member variable.
p_term* p_term_own_property | ( | p_context * | context, | |
const p_term * | term, | |||
const p_term * | name | |||
) |
Returns the value associated with the property name on term within context, or null if name is not present.
This function does not search prototype objects for name.
int p_term_precedes | ( | p_context * | context, | |
const p_term * | term1, | |||
const p_term * | term2 | |||
) |
Returns -1, 0, or 1 depending upon whether term1 is less than, equal to, or greater than term2 using the "precedes" relationship. The terms are compared within context.
Variables precede all floating-point reals, which precede all integers, which precede all strings, which precede all atoms, which precede all functors (including lists), which precede all objects, which precede all predicates.
Variables, objects, and pedicates are compared by pointer. Reals, integers, strings, and atoms are compared by value. Functors order on arity, then name, and then the arguments from left-to-right. Lists are assumed to have arity 2 and "." as their functor name.
void p_term_print | ( | p_context * | context, | |
const p_term * | term, | |||
p_term_print_func | print_func, | |||
void * | print_data | |||
) |
Prints term within context to the output stream defined by print_func and print_data.
This function is intended for debugging purposes. It may refuse to print some parts of term if the recursion depth is too high.
void p_term_print_unquoted | ( | p_context * | context, | |
const p_term * | term, | |||
p_term_print_func | print_func, | |||
void * | print_data | |||
) |
Prints term within context to the output stream defined by print_func and print_data.
If term is an atom or string, then it will be printed without quoting. Otherwise, the behavior is the same as p_term_print().
This function is intended for debugging purposes. It may refuse to print some parts of term if the recursion depth is too high.
void p_term_print_with_vars | ( | p_context * | context, | |
const p_term * | term, | |||
p_term_print_func | print_func, | |||
void * | print_data, | |||
const p_term * | vars | |||
) |
Prints term within context to the output stream defined by print_func and print_data.
The vars parameters should be a list of Name = Var terms. Whenever Var is encountered in term as an unbound variable, it will be printed as Name. All other unbound variables are printed as "_N".
p_term* p_term_property | ( | p_context * | context, | |
const p_term * | term, | |||
const p_term * | name | |||
) |
Returns the value associated with the property name on term within context, or null if name is not present.
If the property name is not present on term, then the prototype object of term will be consulted for the property.
p_term* p_term_prototype_atom | ( | p_context * | context | ) |
Returns the special "prototype" atom within context that names the prototype for an object.
Returns the atom with the name "prototype". This function is equivalent to calling p_term_create_atom() with "prototype" as the argument, but is more efficient.
double p_term_real_value | ( | const p_term * | term | ) |
Returns the double-precision floating point value within term, or zero if term is not a real term.
The term is automatically dereferenced.
int p_term_set_own_property | ( | p_context * | context, | |
p_term * | term, | |||
p_term * | name, | |||
p_term * | value | |||
) |
Sets the value associated with the property name on term within context.
This function does not search prototype objects for name. If name does not exist, then p_term_add_property() will be used to add a new property.
Returns non-zero if the property was added, or zero if the parameters are invalid. The term must be an object, and name must be an atom other than "prototype" or "className".
This function should be used with care because the change to the property name is not back-trackable.
void p_term_set_tail | ( | p_term * | list, | |
p_term * | tail | |||
) |
Sets the tail of list to tail.
This function is intended for use by parsers that build lists incrementally from the top down, where the tail of list had previously been set to null.
p_term* p_term_sort | ( | p_context * | context, | |
p_term * | list, | |||
int | flags | |||
) |
Sorts list according to the term precedes relationship.
Returns the sorted version of the list, or null if some part of list is not a valid list. If list ends in a variable tail, then the list will be sorted and the returned list will end in nil.
The flags indicate how to compare keys within the list. The supported flags are P_SORT_ASCENDING, P_SORT_DESCENDING, P_SORT_KEYED, P_SORT_REVERSE_KEYED, and P_SORT_UNIQUE.
The sorting algorithm used is merge sort, which will preserve the original ordering of elements that have identical keys.
void p_term_stdio_print_func | ( | void * | data, | |
const char * | format, | |||
... | ||||
) |
Prints formatted output according to format to the stdio FILE stream data.
int p_term_strcmp | ( | const p_term * | str1, | |
const p_term * | str2 | |||
) |
Compares str1 and str2 and returns a comparison code.
The str1 and str2 terms are assumed to be either atoms or strings. The result is undefined if this assumption does not hold.
This comparison function is safe on strings that have embedded NUL characters as it uses memcmp() internally.
p_term* p_term_tail | ( | const p_term * | term | ) |
Returns the tail of the specified list term, or null if term is not a list term.
The term is automatically dereferenced.
int p_term_type | ( | const p_term * | term | ) |
Returns the type of term after dereferencing it.
Returns one of P_TERM_FUNCTOR, P_TERM_VARIABLE, etc, or P_TERM_INVALID if term is null.
int p_term_unify | ( | p_context * | context, | |
p_term * | term1, | |||
p_term * | term2, | |||
int | flags | |||
) |
Unifies term1 with term2 within context.
Returns non-zero if the unify was successful, or zero on failure. The flags control how variables are bound.
p_term* p_term_unify_clause | ( | p_context * | context, | |
p_term * | term, | |||
p_term * | clause | |||
) |
Unifies term with the renamed head of clause.
If the unification succeeds, then this function returns the renamed body of clause. Returns null if the unification fails.
The return value will be the atom true
if clause does not have a body and clause unifies with term.
The name of the functor in the head of clause is ignored when unifying against term, which makes this function suitable for matching against member predicates that have qualified names.
p_term* p_term_witness | ( | p_context * | context, | |
p_term * | term, | |||
p_term ** | subgoal | |||
) |