Beispiel #1
0
/** @pred  set_value(+ _A_,+ _C_)


    Associate atom  _A_ with constant  _C_.

    The `set_value` and `get_value` built-ins give a fast alternative to
    the internal data-base. This is a simple form of implementing a global
    counter.

    ~~~~~
    read_and_increment_counter(Value) :-
    get_value(counter, Value),
    Value1 is Value+1,
    set_value(counter, Value1).
    ~~~~~
    This predicate is YAP specific.
*/
static Int p_setval(USES_REGS1) { /* '$set_value'(+Atom,+Atomic) */
  Term t1 = Deref(ARG1), t2 = Deref(ARG2);
  if (!IsVarTerm(t1) && IsAtomTerm(t1) &&
      (!IsVarTerm(t2) && (IsAtomTerm(t2) || IsNumTerm(t2)))) {
    Yap_PutValue(AtomOfTerm(t1), t2);
    return (TRUE);
  }
  return (FALSE);
}
Beispiel #2
0
Int use_eam(USES_REGS1) {
  if (EAM)
    EAM = 0;
  else {
    Yap_PutValue(AtomCArith, 0);
    EAM = 1;
  }
  return (TRUE);
}
Beispiel #3
0
static void InitDebug(void) {
  Atom At;
#if DEBUG
  int i;

  for (i = 1; i < 20; ++i)
    GLOBAL_Option[i] = 0;
  if (Yap_output_msg) {
    char ch;

#if _WIN32
    if (!_isatty(_fileno(stdin))) {
      return;
    }
#elif HAVE_ISATTY
    if (!isatty(0)) {
      return;
    }
#endif
    fprintf(stderr, "absmi address:%p\n", FunAdr(Yap_absmi));
    fprintf(stderr, "Set	Trace Options:\n");
    fprintf(stderr, "a getch\t\tb token\t\tc Lookup\td LookupVar\ti Index\n");
    fprintf(stderr, "e SetOp\t\tf compile\tg icode\t\th boot\t\tl log\n");
    fprintf(stderr, "m Machine\t p parser\n");
    while ((ch = putchar(getchar())) != '\n' && ch != '\r') {
      if (ch >= 'a' && ch <= 'z')
        GLOBAL_Option[ch - 'a' + 1] = 1;
      GLOBAL_Option[ch - 'a' + 1] = 1;
    }
    if (GLOBAL_Option['l' - 96]) {
      GLOBAL_logfile = fopen(LOGFILE, "w");
      if (GLOBAL_logfile == NULL) {
        fprintf(stderr, "can not open %s\n", LOGFILE);
        getchar();
        exit(0);
      }
      fprintf(stderr, "logging session to file 'logfile'\n");
#ifdef MAC
      Yap_SetTextFile(LOGFILE);
      lp = my_line;
      curfile = Nill;
#endif
    }
  }
#endif
  /* Set at full leash */
  At = AtomLeash;
  Yap_PutValue(At, MkIntTerm(15));
}
Beispiel #4
0
static Int p_values(USES_REGS1) { /* '$values'(Atom,Old,New) */
  Term t1 = Deref(ARG1), t3 = Deref(ARG3);

  if (IsVarTerm(t1)) {
    Yap_Error(INSTANTIATION_ERROR, t1, "set_value/2");
    return (FALSE);
  }
  if (!IsAtomTerm(t1)) {
    Yap_Error(TYPE_ERROR_ATOM, t1, "set_value/2");
    return (FALSE);
  }
  if (!Yap_unify_constant(ARG2, Yap_GetValue(AtomOfTerm(t1)))) {
    return (FALSE);
  }
  if (!IsVarTerm(t3)) {
    if (IsAtomTerm(t3) || IsNumTerm(t3)) {
      Yap_PutValue(AtomOfTerm(t1), t3);
    } else
      return (FALSE);
  }
  return (TRUE);
}
Beispiel #5
0
static void InitVersion(void) {
  Yap_PutValue(AtomVersionNumber, MkAtomTerm(Yap_LookupAtom(YAP_FULL_VERSION)));
}