YAPStringTerm::YAPStringTerm(char *s) { // build string BACKUP_H(); CACHE_REGS Term ts = MkStringTerm(s); mk(ts); RECOVER_H(); }
YAPListTerm::YAPListTerm(YAPTerm ts[], arity_t n) { CACHE_REGS BACKUP_H(); if (n == 0) t = TermNil; while (HR + n * 2 > ASP - 1024) { RECOVER_H(); if (!Yap_dogc(0, NULL PASS_REGS)) { t = TermNil; } BACKUP_H(); } t = AbsPair(HR); for (arity_t i = 0; i < n; i++) { HR[2 * i] = ts[i].gt(); HR[2 * i + 1] = AbsPair(HR + (2 * i + 2)); } }
YAPApplTerm::YAPApplTerm(const std::string f, YAPTerm a1) { BACKUP_H(); arity_t arity = 1; Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); Term o = Yap_MkNewApplTerm(ff, arity); Term *tt = RepAppl(o) + 1; tt[0] = a1.term(); mk(o); RECOVER_H(); }
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) { BACKUP_H(); arity_t arity = ArityOfFunctor(f.f); Term o = Yap_MkNewApplTerm(f.f, arity); Term *tt = RepAppl(o) + 1; for (arity_t i = 0; i < arity; i++) tt[i] = ts[i].term(); mk(o); RECOVER_H(); }
YAPApplTerm::YAPApplTerm(const char *f, std::vector<YAPTerm> ts) : YAPTerm() { BACKUP_H(); arity_t arity = ts.size(); std::vector<Term> tt(arity); for (arity_t i = 0; i < arity; i++) tt[i] = ts[i].term(); Functor ff = Yap_MkFunctor(Yap_LookupAtom(f), arity); t = Yap_MkApplTerm(ff, arity, &tt[0]); RECOVER_H(); }
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() { BACKUP_H(); arity_t arity = ArityOfFunctor(f.f); Term *tt = new Term[arity]; for (arity_t i = 0; i < arity; i++) tt[i] = ts[i].term(); mk(Yap_MkApplTerm(f.f, arity, tt)); delete[] tt; RECOVER_H(); }
YAPApplTerm::YAPApplTerm(const std::string f, std::vector<YAPTerm> ts) { BACKUP_H(); arity_t arity = ts.size(); Functor ff = Yap_MkFunctor(Yap_LookupAtom(f.c_str()), arity); Term o = Yap_MkNewApplTerm(ff, arity); Term *tt = RepAppl(o) + 1; for (arity_t i = 0; i < arity; i++) tt[i] = ts[i].term(); mk(o); RECOVER_H(); }
YAPStringTerm::YAPStringTerm(char *s) { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.val.c = s; inp.type = YAP_STRING_CHARS; out.type = YAP_STRING_STRING; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk ( out.val.t ); else t = 0L; RECOVER_H(); }
YAPAtomTerm::YAPAtomTerm(wchar_t *s): YAPTerm() { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.val.w = s; inp.type = YAP_STRING_WCHARS; out.type = YAP_STRING_ATOM; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk ( MkAtomTerm(out.val.a) ); else t = 0L; RECOVER_H(); }
YAPAtomTerm::YAPAtomTerm(char *s, size_t len) { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.val.c = s; inp.type = YAP_STRING_CHARS; out.type = YAP_STRING_ATOM|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.sz = len; out.max = len; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk ( MkAtomTerm(out.val.a) ); else t = 0L; RECOVER_H(); }
YAPAtomTerm::YAPAtomTerm(char s[]) { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.enc = LOCAL_encoding; inp.val.c = s; inp.type = YAP_STRING_CHARS; out.type = YAP_STRING_ATOM; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk(MkAtomTerm(out.val.a)); else t = 0L; RECOVER_H(); }
YAPStringTerm::YAPStringTerm(wchar_t *s, size_t len) : YAPTerm() { // build string BACKUP_H(); CACHE_REGS seq_tv_t inp, out; inp.val.w = s; inp.type = YAP_STRING_WCHARS; out.type = YAP_STRING_STRING|YAP_STRING_NCHARS|YAP_STRING_TRUNC; out.sz = len; out.max = len; if (Yap_CVT_Text(&inp, &out PASS_REGS)) mk ( out.val.t ); else t = 0L; RECOVER_H(); }
YAPPairTerm::YAPPairTerm() : YAPTerm() { BACKUP_H(); t = Yap_MkNewPairTerm( ); RECOVER_H(); }
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() { CACHE_REGS BACKUP_H(); mk ( MkPairTerm( th.term(), tl.term() ) ); RECOVER_H(); }
YAPTerm YAPApplTerm::getArg(int arg) { BACKUP_H(); YAPTerm to = YAPTerm( ArgOfTerm(arg, gt() ) ); RECOVER_H(); return to; }
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() { BACKUP_H(); UInt arity = ArityOfFunctor(f.f); mk ( Yap_MkNewApplTerm( f.f, arity) ); RECOVER_H(); }
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() { BACKUP_H(); UInt arity = ArityOfFunctor(f.f); mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) ); RECOVER_H(); }
YAPPairTerm::YAPPairTerm() { BACKUP_H(); mk(TermNil); RECOVER_H(); }