Exemplo n.º 1
0
intptr_t YAPTerm::numberVars(intptr_t i0, bool skip_singletons) {
  BACKUP_MACHINE_REGS();

  intptr_t i = Yap_NumberVars(gt(), i0, skip_singletons);

  RECOVER_MACHINE_REGS();
  return i;
}
Exemplo n.º 2
0
Term YAPListTerm::dup() {
  yhandle_t tn;
  BACKUP_MACHINE_REGS();

  tn = Yap_CopyTerm(gt());

  RECOVER_MACHINE_REGS();
  return tn;
}
Exemplo n.º 3
0
Term YAPTerm::deepCopy() {
  yhandle_t tn;
  BACKUP_MACHINE_REGS();

  tn = Yap_CopyTerm(gt());

  RECOVER_MACHINE_REGS();
  return (tn);
}
Exemplo n.º 4
0
Term &YAPTerm::operator[](arity_t i) {
  BACKUP_MACHINE_REGS();
  Term t0 = gt();
  Term *tf = nullptr;
  if (IsApplTerm(t0)) {
    // Functor f = FunctorOfTerm(t0);
    // if (IsExtensionFunctor(f))
    //  return 0;
    tf = RepAppl(t0) + (i + 1);
  } else if (IsPairTerm(t0)) {
    if (i == 0)
      tf = RepPair(t0);
    else if (i == 1)
      tf = RepPair(t0) + 1;
    RECOVER_MACHINE_REGS();
  } else {
    throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "");
  }
  RECOVER_MACHINE_REGS();
  return *tf;
}
Exemplo n.º 5
0
Term &YAPTerm::operator[](arity_t i) {
  BACKUP_MACHINE_REGS();
  Term t0 = gt();
  Term tf = 0;
  if (IsApplTerm(t0)) {
    // Functor f = FunctorOfTerm(t0);
    // if (IsExtensionFunctor(f))
    //  return 0;
    tf = RepAppl(t0)[(i + 1)];
  } else if (IsPairTerm(t0)) {
    if (i == 0)
      tf = HeadOfTerm(t0);
    else if (i == 1)
      tf = TailOfTerm(t0);
    RECOVER_MACHINE_REGS();
    tf = RepPair(tf)[i];
  }
  RECOVER_MACHINE_REGS();
    Yap_Error(TYPE_ERROR_COMPOUND, tf, "");
    throw YAPError();
}
Exemplo n.º 6
0
Term &YAPListTerm::operator[](arity_t i) {
  BACKUP_MACHINE_REGS();
  Term t0 = gt();
  Term tf = 0;
  while (IsPairTerm(t0)) {
    if (i == 0) {
      tf = HeadOfTerm(t0);
      break;
    } else {
      t0 = TailOfTerm(t0);
      i--;
    }
  }
  RECOVER_MACHINE_REGS();
  return RepPair(tf)[i];
}
Exemplo n.º 7
0
Term YAPTerm::getArg(arity_t i) {
  BACKUP_MACHINE_REGS();
  Term tf = 0;
  Term t0 = gt();

  if (IsApplTerm(t0)) {
    if (i > ArityOfFunctor(FunctorOfTerm(t0)))
      throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
    tf = (ArgOfTerm(i, t0));
  } else if (IsPairTerm(t0)) {
    if (i == 1)
      tf = (HeadOfTerm(t0));
    else if (i == 2)
      tf = (TailOfTerm(t0));
    else
      throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()");
  } else {
    throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()");
  }
  RECOVER_MACHINE_REGS();
  return tf;
}