Exemplo n.º 1
0
static void init_interpreted(definition_t *f)
{
  f->code.intinfo = checkalloc_TYPE(int_info_t);

  /* By default, make it DYNAMIC.  
     set_property() may change this behavior later. MCL. */

  f->code.intinfo->behavior_on_failure = DYNAMIC;

  /*f->code.intinfo->clause_insertion_cond = create_dynamic_lock();*/
  Init_Cond(f->code.intinfo->clause_insertion_cond);

  /*  MCL added on 26 Nov 98 */
  f->code.intinfo->x2_pending_on_instance = NULL;
  f->code.intinfo->x5_pending_on_instance = NULL;

  f->code.intinfo->first = NULL;
  f->code.intinfo->varcase = NULL;
  f->code.intinfo->lstcase = NULL;
  f->code.intinfo->indexer = new_switch_on_key(2,NULL);
  SetEnterInstr(f,ENTER_INTERPRETED);
}
Exemplo n.º 2
0
/* Initialization upon load_foreign_resource, save, or restore. */
void SPCDECL fd_initialize(Wam wam, int when)
{
  TAGGED *table;
  struct pred_spec *pt;

  (void)when;
  (*SP_foreign_stash()) = fd_malloc(wam, sizeof(struct fd_state));

  fd.batching = 0;
  fd.debugging = 0;
  fd.overflowing = 1;
  fd.resumptions = 0;
  fd.entailments = 0;
  fd.prunings = 0;
  fd.failures = 0;
  fd.constraints = 0;
  fd.current_propagator = NULL;
  fd.free_propagators = NULL;
  fd.functor_dom4    = fd_attribute[FD_ATTR_MIN_OFFSET-2]
    = SetArity(SP_atom_from_string("dom"),4);
  (void)SP_register_atom(fd.functor_dom4);
  fd.functor_in_set2 = SetArity(SP_atom_from_string("in_set"),2);
  (void)SP_register_atom(fd.functor_in_set2);
  fd.functor_dom     = SetArity(SP_atom_from_string("dom"),1);
  (void)SP_register_atom(fd.functor_dom);
  fd.functor_min     = SetArity(SP_atom_from_string("min"),1);
  (void)SP_register_atom(fd.functor_min);
  fd.functor_max     = SetArity(SP_atom_from_string("max"),1);
  (void)SP_register_atom(fd.functor_max);
  fd.functor_minmax  = SetArity(SP_atom_from_string("minmax"),1);
  (void)SP_register_atom(fd.functor_minmax);
  fd.functor_val     = SetArity(SP_atom_from_string("val"),1);
  (void)SP_register_atom(fd.functor_val);
  fd.functor_none     = SetArity(SP_atom_from_string("none"),1);
  (void)SP_register_atom(fd.functor_none);
  fd.functor_call    = SetArity(SP_atom_from_string("call"),1);
  (void)SP_register_atom(fd.functor_call);
  fd.functor_eq      = SetArity(SP_atom_from_string("="),2);
  (void)SP_register_atom(fd.functor_eq);
  fd.functor_t_eq_u      = SetArity(SP_atom_from_string("t=u IND"),2);
  (void)SP_register_atom(fd.functor_t_eq_u);
  fd.functor_lists7  = fd_attribute[FD_ATTR_MIN_OFFSET+3]
    = SetArity(SP_atom_from_string("$fdlists"),7);
  (void)SP_register_atom(fd.functor_lists7);
  fd.functor_leqc  = SetArity(SP_atom_from_string("t=<u+c"),3);
  (void)SP_register_atom(fd.functor_leqc);
  fd.functor_alldiff  = SetArity(SP_atom_from_string("all_distinct"),1);
  (void)SP_register_atom(fd.functor_alldiff);
  fd.functor_colored  = SetArity(SP_atom_from_string("colored"),1);
  (void)SP_register_atom(fd.functor_colored);
  table = fd.linkage_keys+1;
  *table++ = fd.functor_dom;
  *table++ = fd.functor_min;
  *table++ = fd.functor_dom;
  *table++ = fd.functor_max;
  *table++ = fd.functor_dom;
  *table++ = fd.functor_minmax;
  *table++ = fd.functor_dom;
  table = fd.var_options;
  *table++ = SetArity(fd.functor_min,0);
  *table++ = SetArity(fd.functor_max,0);
  *table = SP_atom_from_string("ff");
  (void)SP_register_atom(*table++);
  *table = SP_atom_from_string("ffc");
  (void)SP_register_atom(*table++);
  *table = SP_atom_from_string("anti_first_fail");
  (void)SP_register_atom(*table++);
  *table = SP_atom_from_string("occurrence");
  (void)SP_register_atom(*table++);
  *table = SP_atom_from_string("max_regret");
  (void)SP_register_atom(*table++);
  fd.token_a         = SetArity(SP_atom_from_string("a"),1);
  (void)SP_register_atom(fd.token_a);
  fd.token_d         = SetArity(SP_atom_from_string("d"),1);
  (void)SP_register_atom(fd.token_d);
  fd.token_h         = SetArity(SP_atom_from_string("h"),1);
  (void)SP_register_atom(fd.token_h);
  fd.token_l         = SetArity(SP_atom_from_string("l"),1);
  (void)SP_register_atom(fd.token_l);
  fd.token_t         = SetArity(SP_atom_from_string("t"),1);
  (void)SP_register_atom(fd.token_t);
  fd.fd_module = find_module(SP_atom_from_string("clpfd"),TRUE);
  fd_define_predicates(wam, 1);
  fd.overflow_action1 = SP_predicate("overflow_action", 2, "clpfd");
  fd.dispatch = new_switch_on_key(32,NULL);
  (void)prolog_fd_evaluate_indexical(wam, 0);
  for (pt = pred_table; pt->name != NULL; pt++) {
    TAGGED key = SetArity(SP_atom_from_string(pt->name),pt->arity);
    
    SP_register_atom(key);
    dyn_puthash(&fd.dispatch,key)->value.arities = (SP_uinteger)pt->function;
  }
#if DBG>1
  dvar_validate(wam, );
#endif
}