Esempio n. 1
0
/*-------------------------------------------------------------------------*
 * PL_FD_NEQ_2                                                             *
 *                                                                         *
 *-------------------------------------------------------------------------*/
Bool
Pl_Fd_Neq_2(WamWord le_word, WamWord re_word)
{
  int mask;
  WamWord l_word, r_word;
  PlLong c;


#ifdef DEBUG
  cur_op = (pl_full_ac) ? "#\\=#" : "#\\=";
#endif

  if (!Pl_Load_Left_Right(FALSE, le_word, re_word, &mask, &c, &l_word, &r_word))
    return FALSE;

  switch (mask)
    {
    case MASK_EMPTY:
      if (c == 0)
	return FALSE;
      goto term_load;

    case MASK_LEFT:
      if (c > 0)
	{
	  Pl_Fd_Prolog_To_Fd_Var(l_word, TRUE);
	  goto term_load;
	}

      PRIM_CSTR_2(pl_x_neq_c, l_word, Tag_INT(-c));
      goto term_load;

    case MASK_RIGHT:
      if (c < 0)
	{
	  Pl_Fd_Prolog_To_Fd_Var(r_word, TRUE);
	  goto term_load;
	}

      PRIM_CSTR_2(pl_x_neq_c, r_word, Tag_INT(c));
      goto term_load;
    }

  if (c > 0)
    {
      PRIM_CSTR_3(pl_x_plus_c_neq_y, l_word, Tag_INT(c), r_word);
      goto term_load;
    }

  if (c < 0)
    {
      PRIM_CSTR_3(pl_x_plus_c_neq_y, r_word, Tag_INT(-c), l_word);
      goto term_load;
    }


  PRIM_CSTR_2(pl_x_neq_y, l_word, r_word);
term_load:
  return Pl_Term_Math_Loading(l_word, r_word);
}
Esempio n. 2
0
/*-------------------------------------------------------------------------*
 * SET_LTE                                                                 *
 *                                                                         *
 *-------------------------------------------------------------------------*/
static Bool
Set_Lte(WamWord *exp, int result, WamWord *load_word)
{
  WamWord le_word, re_word;
  int mask;
  WamWord l_word, r_word;
  PlLong c;

  le_word = exp[1];
  re_word = exp[2];

  if (result == 0)		/* L <= R is false */
    return Pl_Fd_Lt_2(re_word, le_word);

  if (result == 1)		/* L <= R is true */
    return Pl_Fd_Lte_2(le_word, re_word);

  *load_word = Tag_REF(Pl_Fd_New_Bool_Variable());

#ifdef DEBUG
  cur_op = (pl_full_ac) ? "truth#=<#" : "truth#=<";
#endif

  if (!Pl_Load_Left_Right(FALSE, le_word, re_word, &mask, &c, &l_word, &r_word)
      || !Pl_Term_Math_Loading(l_word, r_word))
    return FALSE;

  switch (mask)
    {
    case MASK_EMPTY:
      return Pl_Get_Integer(c <= 0, *load_word);

    case MASK_LEFT:
      if (c > 0)
	return Pl_Get_Integer(0, *load_word);

      PRIM_CSTR_3(pl_truth_x_lte_c, l_word, Tag_INT(-c), *load_word);
      return TRUE;

    case MASK_RIGHT:
      if (c <= 0)
	return Pl_Get_Integer(1, *load_word);

      PRIM_CSTR_3(pl_truth_x_gte_c, r_word, Tag_INT(c), *load_word);
      return TRUE;
    }

  if (c > 0)
    {
      PRIM_CSTR_4(pl_truth_x_plus_c_lte_y, l_word, Tag_INT(c), r_word,
		  *load_word);
      return TRUE;
    }

  if (c < 0)
    {
      PRIM_CSTR_4(pl_truth_x_plus_c_gte_y, r_word, Tag_INT(-c), l_word,
		  *load_word);
      return TRUE;
    }


  PRIM_CSTR_3(pl_truth_x_lte_y, l_word, r_word, *load_word);
  return TRUE;
}