Copying Terms¶
These predicates allow copying terms.
They can deal with sharing terms or structure, handling constraints, and infinite terms.
Define:¶
Functions:¶
1. CELL * Yap_ArenaLimit(Term arena):
1. CELL * Yap_ArenaPt(Term arena):
1. UInt Yap_ArenaSz(Term arena):
1. static int copy_complex_term(CELL pt0_, CELL pt0_end_, bool share, bool copy_att_vars, CELL ptf_, Term bindp, Ystack_t *stt USES_REGS): : THis is the key function to copy term, parameters are:
found infinite loop. p0 is the original sub-term = ...,p0,.... ptd0 is the dereferenced version of d0
pt0- pointer to start input - 1
pt0_end- pointer to end input -1
share- share duplicate code, instead of performing multiple copies
copy_att_vars- copy attributes on variables
ptf- poiter to destination
bindp- list of bindings introduce to break cycles in the original term. If *bindp == TermFoundVar rewrite any loops as a singleconstant.
stt->hlow return:
bool
The routine works by marking compund terms the first time they are visited. If the term is a listm it marks the head of the list, otherwise it marks the functor. The mderef routines then do marker-aware dereferencing.
1. Term Yap_MkArena(CELL ptr, CELL max):
1. bool Yap_ArenaExpand(size_t sz, CELL *arenap, bool first_try):
1. static Int allocate_arena(USES_REGS1):
1. static Int arena_size(USES_REGS1):
1. void Yap_AllocateDefaultArena(size_t gsizeW, int wid, void *cs):
1. static bool visitor_error_handler(yap_error_number err, Ystack_t stt, size_t min_grow, Term arenap):
1. Term CopyTermToArena(Term t, bool share, bool copy_att_vars, yap_error_number errp, Term arenap, Term *bindp USES_REGS):
1. Term Yap_CopyTerm(Term inp):
1. Term Yap_CopyTermNoShare(Term inp):
1. static Int copy_term(USES_REGS1):
1. static Int duplicate_term(USES_REGS1):
1. static Int rational_term_to_forest(USES_REGS1): : "rational_term_to_forest(? TI,- TF, -Extras, ?More" )
@class rational_term_to_forest_4
Copy the term, but loops within the term are broken up and added to a list of loopy assignments
The term TF is a forest representation (without cycles and repeated terms) for the Prolog term TI. The term TF is the main term. The difference list SubTerms-MoreSubterms stores terms of the form V=T, where V is a new variable occuring in TF, and T is a copy of a sub-term from TI.
1. Term Yap_TermAsForest(Term t1):