示例#1
0
文件: yapi.cpp 项目: vscosta/yap-6.3
YAPStringTerm::YAPStringTerm(char *s) { // build string
  BACKUP_H();

  CACHE_REGS
  Term ts = MkStringTerm(s);
  mk(ts);
  RECOVER_H();
}
示例#2
0
文件: yapi.cpp 项目: vscosta/yap-6.3
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));
  }
}
示例#3
0
文件: yapi.cpp 项目: vscosta/yap-6.3
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();
}
示例#4
0
文件: yapi.cpp 项目: vscosta/yap-6.3
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();
}
示例#5
0
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();
}
示例#6
0
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();
}
示例#7
0
文件: yapi.cpp 项目: vscosta/yap-6.3
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();
}
示例#8
0
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();
}
示例#9
0
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();
}
示例#10
0
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();
}
示例#11
0
文件: yapi.cpp 项目: vscosta/yap-6.3
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();
}
示例#12
0
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();
}
示例#13
0
YAPPairTerm::YAPPairTerm() : YAPTerm() {
  BACKUP_H();
  t = Yap_MkNewPairTerm( );
  RECOVER_H();
}
示例#14
0
YAPPairTerm::YAPPairTerm(YAPTerm th, YAPTerm tl) : YAPTerm() {
  CACHE_REGS
    BACKUP_H();
  mk ( MkPairTerm( th.term(), tl.term() ) );
  RECOVER_H();
}
示例#15
0
YAPTerm  YAPApplTerm::getArg(int arg) {
  BACKUP_H();
  YAPTerm to = YAPTerm( ArgOfTerm(arg, gt() ) );
  RECOVER_H();
  return to;
}
示例#16
0
YAPApplTerm::YAPApplTerm(YAPFunctor f) : YAPTerm() {
  BACKUP_H();
  UInt arity = ArityOfFunctor(f.f);
  mk ( Yap_MkNewApplTerm( f.f, arity) );
  RECOVER_H();
}
示例#17
0
YAPApplTerm::YAPApplTerm(YAPFunctor f, YAPTerm ts[]) : YAPTerm() {
  BACKUP_H();
  UInt arity = ArityOfFunctor(f.f);
  mk ( Yap_MkApplTerm( f.f, arity, (Term *)ts) );
  RECOVER_H();
}
示例#18
0
文件: yapi.cpp 项目: vscosta/yap-6.3
YAPPairTerm::YAPPairTerm() {
  BACKUP_H();
  mk(TermNil);
  RECOVER_H();
}