YAPTerm

Generic class for Prolog Terms.

The class YAPTerm provides the ability to construct and manipulate Prolog terms. Operations include: 1. constructors that generate terms ranging from other terms to, source text.

  1. term type testing, extraction and construction.

  2. several built-ins for term manipulation, including unification, copying, and variant testing;

The YAPTerm class has several sub-classes, mostly corresponding to diverse types of terms. Also, YAP provides two utility sub-classes: lists and conjunctions.


 a :- b(Z).

YAPTerm is implemented on top of the slot or handle mechanism. This provides protection against stack shifting or garbage collection, but in YAP it requires the programmer to explicitely release the handles. This can be done through [pop_t()][1a30f878eb51ad4dd87bfd4caad6b5defa] or through synch points.

Public Function:

1. Term YAPTerm::gt(): : a handle to stack representation of the term, equivalent to SWI-Prolog's term_t; this is the only dynamic structure in a YAPTerm

convert from YAPTerm to term (same as [term()][1a0d91db4c6bf9396f54371aef858b2c71])

1. Term YAPTerm::pop_t():

get the Prolog term corresponding to the YAPTerm, and try to recover space

1. void YAPTerm::mk(Term t0):

create a new YAPTerm from a term

1. void YAPTerm::put(Term t0):

copy a term to an YAPTerm

1. YAPTerm::YAPTerm(Term tn):

1. YAPTerm::YAPTerm(): : private method to convert from Term (internal YAP representation) toYAPTerm

1. YAPTerm::YAPTerm(void *ptr): : do nothing constructor

pointer to term

1. YAPTerm::YAPTerm(char *s):

parse string s and construct a term.

1. virtual YAPTerm::~YAPTerm():

Term destructor, tries to recover slot

1. YAPTerm::YAPTerm(long int num):

construct a term out of an integer (if you know object type use YAPIntegerTerm)

1. YAPTerm::YAPTerm(double num):

construct a term out of an double (if you know object type use

1. YAPTerm::YAPTerm(std::string &name, std::vector< YAPTerm > ts):

extract the tag of a term, after dereferencing.

1. YAP_tag_t YAPTerm::tag():

1. Term YAPTerm::deepCopy(): : copy the term ( term copy )

1. int YAPTerm::numberVars(int start, bool singletons=false):

number variables in term (see nummbervars/3)

1. Term YAPTerm::term():

convert from YAPTerm to Term (internal YAP representation)

1. YAPTerm YAPTerm::arg(int i):

fetch argument i from the term (i counts from 1)

1. void YAPTerm::bind(Term b):

set a variable in internal representation

1. void YAPTerm::bind(YAPTerm *b):

set a variable

1. Term & YAPTerm::operator: : fetch a sub-term from YAPTerm to Term (internal YAP representation)

1. virtual bool YAPTerm::exactlyEqual(YAPTerm t1):

this term is == to t1

1. virtual bool YAPTerm::unify(YAPTerm t1):

unify this term with t1

1. virtual bool YAPTerm::unifiable(YAPTerm t1):

we can unify t and t1

1. virtual YAP_Term YAPTerm::variant(YAPTerm t1):

t =@= t1, the two terms are equal up to variable renaming

1. virtual intptr_t YAPTerm::hashTerm(size_t sz, size_t depth, bool variant):

compute a number from a ground term

1. virtual bool YAPTerm::isVar(): : type check for unbound

1. virtual bool YAPTerm::isAtom(): : type check for atom

1. virtual bool YAPTerm::isInteger(): : type check for integer

1. virtual bool YAPTerm::isFloat(): : type check for floating-point

1. virtual bool YAPTerm::isString(): : type check for a string " ... "

1. virtual bool YAPTerm::isCompound(): : < structured term or list

1. virtual bool YAPTerm::isAppl(): : is a structured term

1. virtual bool YAPTerm::isPair(): : is a pair term

1. virtual bool YAPTerm::isGround(): : term is ground

1. virtual bool YAPTerm::isList(): : term is a list

1. Term YAPTerm::getArg(arity_t i): : extract the argument i of the term, where i in 1...arity

1. virtual arity_t YAPTerm::arity():

extract the arity of the term; variables have arity 0.

1. virtual const char * YAPTerm::text():

return a string with a textual representation of the term

1. void YAPTerm::reset():

discard all YAPTerms older than this.

1. yhandle_t YAPTerm::handle(): : return a handle to the term

1. bool YAPTerm::initialized(): : whether the term actually refers to a live object

Protected Attributes:

1. yhandle_t YAPTerm::hdl:

Friends:

1. friend class YAPPredicate:

1. friend class YAPPrologPredicate:

1. friend class YAPQuery:

1. friend class YAPModule:

1. friend class YAPModuleProp:

1. friend class YAPApplTerm:

1. friend class YAPListTerm:

1. friend class YAPConjunctiveTerm:

Class: YAPVarTerm

Class: YAPStringTerm

Class: YAPPairTerm

Class: YAPNumberTerm

Class: YAPListTerm

Class: YAPErrorTerm

Class: YAPConjunctiveTerm

Class: YAPAtomTerm

Class: YAPApplTerm