当前位置: 首页>>代码示例>>C++>>正文


C++ IsVarTerm函数代码示例

本文整理汇总了C++中IsVarTerm函数的典型用法代码示例。如果您正苦于以下问题:C++ IsVarTerm函数的具体用法?C++ IsVarTerm怎么用?C++ IsVarTerm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了IsVarTerm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exists_directory

static Int exists_directory(USES_REGS1) {
  Term tname = Deref(ARG1);
  char *file_name;

  if (IsVarTerm(tname)) {
    Yap_Error(INSTANTIATION_ERROR, tname, "exists_directory/1");
    return FALSE;
  } else if (!IsAtomTerm(tname)) {
    Yap_Error(TYPE_ERROR_ATOM, tname, "exists_directory/1");
    return FALSE;
  } else {
    VFS_t *vfs;
    char *s = Yap_VF(RepAtom(AtomOfTerm(tname))->StrOfAE);
    if (!s) return false;
    if ((vfs = vfs_owner(s))) {
bool rc = true;
      return vfs->isdir(vfs, s);

      UNLOCK(GLOBAL_Stream[sno].streamlock);
      return rc;
    }
#if HAVE_STAT
    struct SYSTEM_STAT ss;

    file_name = Yap_VF(RepAtom(AtomOfTerm(tname))->StrOfAE);
    if (SYSTEM_STAT(file_name, &ss) != 0) {
      /* ignore errors while checking a file */
      return false;
    }
    return (S_ISDIR(ss.st_mode));
#else
    return FALSE;
#endif
  }
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:35,代码来源:files.c

示例2: p_is

/// @memberof is/2
static Int
p_is( USES_REGS1 )
{				/* X is Y	 */
  Term out;
  yap_error_number err;

  Term t = Deref(ARG2);
  if (IsVarTerm(t)) {
    Yap_EvalError(INSTANTIATION_ERROR,t, "X is Y");
    return(FALSE);
  }
  Yap_ClearExs();
  do {
    out = Yap_InnerEval(Deref(ARG2));
    if ((err = Yap_FoundArithError()) == YAP_NO_ERROR)
      break;
    if (err == RESOURCE_ERROR_STACK) {
      LOCAL_Error_TYPE = YAP_NO_ERROR;
      if (!Yap_gcl(LOCAL_Error_Size, 2, ENV, CP)) {
	Yap_EvalError(RESOURCE_ERROR_STACK, ARG2, LOCAL_ErrorMessage);
	return FALSE;
      }
    } else {
      Yap_EvalError(err, ARG2, "X is Exp");
      return FALSE;
    }
  } while (TRUE);
  return Yap_unify_constant(ARG1,out);
}
开发者ID:jpbsantos,项目名称:yapOr-teams,代码行数:30,代码来源:eval.c

示例3: p_freeze_choice_point

static Int p_freeze_choice_point( USES_REGS1 ) {
  if (IsVarTerm(Deref(ARG1))) {
    Int offset = freeze_current_cp();
    return Yap_unify(ARG1, MkIntegerTerm(offset));
  }
  return (FALSE);
}
开发者ID:xicoVale,项目名称:yap-6.3,代码行数:7,代码来源:opt.preds.c

示例4: mark_local

static void
mark_local(void)
{
  CELL   *pt;

  /* Adjusting the local */
  pt = LCL0;
  /* moving the trail is simple */
  while (pt > ASP) {
    CELL reg = *--pt;

    if (!IsVarTerm(reg)) {
      if (IsAtomTerm(reg)
#ifdef TABLING
	  /* assume we cannot have atoms on first page,
	     so this must be an arity
	  */
	  && reg > Yap_page_size
#endif
	  ) {
	MarkAtomEntry(RepAtom(AtomOfTerm(reg)));
      }
    }
  }
}
开发者ID:miar,项目名称:yaptab-linear,代码行数:25,代码来源:agc.c

示例5: mark_global_cell

static CELL *
mark_global_cell(CELL *pt)
{   
  CELL reg = *pt;

  if (IsVarTerm(reg)) {
    /* skip bitmaps */
    switch(reg) {
    case (CELL)FunctorDouble:
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
      return pt + 4;
#else
      return pt + 3;
#endif
    case (CELL)FunctorBigInt:
      {
	Int sz = 3 +
	  (sizeof(MP_INT)+
	   (((MP_INT *)(pt+2))->_mp_alloc*sizeof(mp_limb_t)))/sizeof(CELL);
	return pt + sz;
      }
    case (CELL)FunctorLongInt:
      return pt + 3;
      break;
    }
  } else if (IsAtomTerm(reg)) {
    MarkAtomEntry(RepAtom(AtomOfTerm(reg)));
    return pt+1;
  }
  return pt+1;
}
开发者ID:miar,项目名称:yaptab-linear,代码行数:31,代码来源:agc.c

示例6: file_exists

static Int file_exists(USES_REGS1) {
  Term tname = Deref(ARG1);
  char *file_name;

  if (IsVarTerm(tname)) {
    Yap_Error(INSTANTIATION_ERROR, tname, "access");
    return FALSE;
  } else if (!IsAtomTerm(tname)) {
    Yap_Error(TYPE_ERROR_ATOM, tname, "access");
    return FALSE;
  } else {
#if HAVE_STAT
    struct SYSTEM_STAT ss;

    file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
    if (SYSTEM_STAT(file_name, &ss) != 0) {
      if (errno == ENOENT)
        return false;
      PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, tname, "error %s",
                strerror(errno));
      return false;
    }
    return true;
#else
    return FALSE;
#endif
  }
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:28,代码来源:files.c

示例7: p_compare

/** @pred  compare( _C_, _X_, _Y_) is iso


As a result of comparing  _X_ and  _Y_,  _C_ may take one of
the following values:

+
`=` if  _X_ and  _Y_ are identical;
+
`<` if  _X_ precedes  _Y_ in the defined order;
+
`>` if  _Y_ precedes  _X_ in the defined order;

*/
Int p_compare(USES_REGS1) { /* compare(?Op,?T1,?T2)	 */
  Int r = compare(Deref(ARG2), Deref(ARG3));
  Atom p;
  Term t = Deref(ARG1);
  if (r < 0)
    p = AtomLT;
  else if (r > 0)
    p = AtomGT;
  else
    p = AtomEQ;
  if (!IsVarTerm(t)) {
    if (IsAtomTerm(t)) {
      Atom a = AtomOfTerm(t);
      if (a == p)
        return true;
      if (a != AtomLT && a != AtomGT && a != AtomEq)
        Yap_Error(DOMAIN_ERROR_ORDER, ARG1, NULL);
    } else {
      Yap_Error(TYPE_ERROR_ATOM, ARG1, NULL);
    }
    return false;
  }

  return Yap_unify_constant(ARG1, MkAtomTerm(p));
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:39,代码来源:cmppreds.c

示例8: file_directory_name

static Int file_directory_name(USES_REGS1) { /* file_directory_name(Stream,N) */
  Term t = Deref(ARG1);
  Atom at;
  if (IsVarTerm(t)) {
    Yap_Error(INSTANTIATION_ERROR, t, "file_directory_name/2");
    return false;
  }
  at = AtomOfTerm(t);
  const char *c = RepAtom(at)->StrOfAE;
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with
                       // file_base_name in SWI and GNU
  const char *s;
  char c1[YAP_FILENAME_MAX + 1];
  strncpy(c1, c, YAP_FILENAME_MAX);
  s = dirname(c1);
#else
  char s[YAP_FILENAME_MAX + 1];
  Int i = strlen(c);
  strncpy(s, c, YAP_FILENAME_MAX);
  while (--i) {
    if (Yap_dir_separator((int)c[i]))
      break;
  }
  if (i == 0) {
    s[0] = '.';
    i = 1;
  }
  s[i] = '\0';
#endif
  return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:31,代码来源:files.c

示例9: qq_open

static Int qq_open(USES_REGS1) {
  PRED_LD

  Term t = Deref(ARG1);
  if (!IsVarTerm(t) && IsApplTerm(t) && FunctorOfTerm(t) =
          FunctorDQuasiQuotation) {
    void *ptr;
    char *start;
    size_t l int s;
    Term t0, t1, t2;

    if (IsPointerTerm((t0 = ArgOfTerm(1, t))) &&
        IsPointerTerm((t1 = ArgOfTerm(2, t))) &&
        IsIntegerTerm((t2 = ArgOfTerm(3, t)))) {
      ptr = PointerOfTerm(t0);
      start = PointerOfTerm(t1);
      len = IntegerOfTerm(t2);
      if ((s = Yap_open_buf_read_stream(start, len, ENC_UTF8, MEM_BUF_USER)) <
          0)
        return false;
      return Yap_unify(ARG2, Yap_MkStream(s));
    } else {
      Yap_Error(TYPE_ERROR_READ_CONTEXT, t);
    }

    return FALSE;
  }
}
开发者ID:edmcman,项目名称:yap-6.3,代码行数:28,代码来源:readterm.c

示例10: access_path

static Int access_path(USES_REGS1) {
  Term tname = Deref(ARG1);

  if (IsVarTerm(tname)) {
    Yap_Error(INSTANTIATION_ERROR, tname, "access");
    return false;
  } else if (!IsAtomTerm(tname)) {
    Yap_Error(TYPE_ERROR_ATOM, tname, "access");
    return false;
  } else {
          VFS_t *vfs;
          char *s =  RepAtom(AtomOfTerm(tname))->StrOfAE;
          if (!s) return false;
          if ((vfs = vfs_owner(s))) {
              vfs_stat st;
              bool rc = vfs->stat(vfs, s, &st);
              UNLOCK(GLOBAL_Stream[sno].streamlock);
              return rc;
          }
#if HAVE_STAT
    struct SYSTEM_STAT ss;
    char *file_name;

    file_name = RepAtom(AtomOfTerm(tname))->StrOfAE;
    if (SYSTEM_STAT(file_name, &ss) != 0) {
      /* ignore errors while checking a file */
      return true;
    }
    return true;
#else
    return false;
#endif
  }
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:34,代码来源:files.c

示例11: file_base_name

static Int file_base_name(USES_REGS1) { /* file_base_name(Stream,N) */
  Term t = Deref(ARG1);
  Atom at;
  if (IsVarTerm(t)) {
    Yap_Error(INSTANTIATION_ERROR, t, "file_base_name/2");
    return FALSE;
  }
  at = AtomOfTerm(t);
  const char *c = RepAtom(at)->StrOfAE;
  const char *s;
#if HAVE_BASENAME && 0 // DISABLED: Linux basename is not compatible with
                       // file_base_name in SWI and GNU
  char c1[YAP_FILENAME_MAX + 1];
  strncpy(c1, c, YAP_FILENAME_MAX);
  s = basename(c1);
#else
  Int i = strlen(c);
  while (i && !Yap_dir_separator((int)c[--i]))
    ;
  if (Yap_dir_separator((int)c[i])) {
    i++;
  }
  s = c + i;
#endif
  return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
}
开发者ID:vscosta,项目名称:yap-6.3,代码行数:26,代码来源:files.c

示例12: p_cyclic

static Int
p_cyclic( USES_REGS1 )
{
  Term t = Deref(ARG1);
  if (IsVarTerm(t))
    return(FALSE);
  return rational_tree(t);
}
开发者ID:gokhansolak,项目名称:yap-6.3,代码行数:8,代码来源:unify.c

示例13: p_acyclic

static Int
p_acyclic( USES_REGS1 )
{
  Term t = Deref(ARG1);
  if (IsVarTerm(t))
    return(TRUE);
  return !rational_tree(t);
}
开发者ID:gokhansolak,项目名称:yap-6.3,代码行数:8,代码来源:unify.c

示例14: file_no

static Int file_no(int sno, Term t2 USES_REGS) {
  int f = Yap_GetStreamFd(sno);
  Term rc = MkIntTerm(f);
  if (!IsVarTerm(t2) && !IsIntTerm(t2)) {
    return false;
  }
  return Yap_unify_constant(t2, rc);
}
开发者ID:jnorthrup,项目名称:yap-6.3,代码行数:8,代码来源:streams.c

示例15: stream_flags

static Int stream_flags(USES_REGS1) { /* '$stream_flags'(+N,-Flags) */
  Term trm;
  trm = Deref(ARG1);
  if (IsVarTerm(trm) || !IsIntTerm(trm))
    return (FALSE);
  return (Yap_unify_constant(ARG2,
                             MkIntTerm(GLOBAL_Stream[IntOfTerm(trm)].status)));
}
开发者ID:jnorthrup,项目名称:yap-6.3,代码行数:8,代码来源:streams.c


注:本文中的IsVarTerm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。