tr_code_xsb_i.h File Reference


Defines

#define opatom   Atom(NodePtr)
#define opsucc   ((byte *)(Child(NodePtr)))
#define opfail   ((byte *)(Sibl(NodePtr)))
#define FIRST_HASH_NODE   -1
#define NO_MORE_IN_HASH   -2
#define HASH_IS_FREE   -3
#define HASH_IS_NOT_FREE   -4
#define hash_nonvar_subterm(Subterm, pBTHT, BucketNum)
#define find_next_nonempty_bucket(pBTHT, pTable, BucketNum)
#define next_lpcreg
#define proceed_lpcreg
#define non_ftag_lpcreg   lpcreg = opsucc
#define MAX_TRIE_REGS   500
#define restore_regs_and_vars(tbreg, offset)
#define save_trie_registers(tbreg)
#define restore_trie_registers(temp)
#define unify_with_trie_numcon
#define unify_with_trie_str
#define unify_with_trie_list
#define unify_with_trie_val
#define unify_with_trie_attv

Variables

Cellreg_array
CPtr reg_arrayptr
int reg_array_size = DEFAULT_ARRAYSIZ
CPtr var_regs [MAX_TRIE_REGS]
int num_vars_in_var_regs = -1
BTNptr NodePtr
BTNptr Last_Nod_Sav
int delay_it

Define Documentation

#define find_next_nonempty_bucket pBTHT,
pTable,
BucketNum   ) 
 

Value:

{       \
   long TableSize = BTHT_NumBuckets(pBTHT);                     \
                                                                \
   while (TRUE) {                                               \
     BucketNum++;                                               \
     if (BucketNum >= TableSize) {                              \
       BucketNum = NO_MORE_IN_HASH;                             \
       break;                                                   \
     }                                                          \
     else if ( IsNonNULL(*(pTable + BucketNum)) )               \
       break;                                                   \
   }                                                            \
 }

#define FIRST_HASH_NODE   -1
 

#define HASH_IS_FREE   -3
 

#define HASH_IS_NOT_FREE   -4
 

#define hash_nonvar_subterm Subterm,
pBTHT,
BucketNum   ) 
 

Value:

{       \
                                                                \
   Cell symbol = 0;     /* eliminate compiler warning */        \
                                                                \
   switch (cell_tag(Subterm)) {                                 \
   case XSB_STRING:                                            \
   case XSB_INT:                                               \
   case XSB_FLOAT:                                              \
     symbol = EncodeTrieConstant(Subterm);                      \
     break;                                                     \
   case XSB_LIST:                                               \
     symbol = EncodeTrieList(Subterm);                          \
     break;                                                     \
   case XSB_STRUCT:                                             \
     symbol = EncodeTrieFunctor(Subterm);                       \
     break;                                                     \
   default:                                                     \
     fprintf(stderr,"Bad tag :Type %ld ",cell_tag(Subterm));    \
     xsb_exit("In instruction hash_handle");                    \
     break;                                                     \
   }                                                            \
   BucketNum = TrieHash(symbol,BTHT_GetHashSeed(pBTHT));        \
 }

#define MAX_TRIE_REGS   500
 

#define next_lpcreg
 

Value:

{                               \
   if ( IsLeafNode(NodePtr) )                   \
     proceed_lpcreg                             \
   else                                         \
     non_ftag_lpcreg;                           \
 }

#define NO_MORE_IN_HASH   -2
 

#define non_ftag_lpcreg   lpcreg = opsucc
 

#define opatom   Atom(NodePtr)
 

#define opfail   ((byte *)(Sibl(NodePtr)))
 

#define opsucc   ((byte *)(Child(NodePtr)))
 

#define proceed_lpcreg
 

Value:

#define restore_regs_and_vars tbreg,
offset   ) 
 

Value:

#define restore_trie_registers temp   ) 
 

Value:

{                       \
    int i;                                              \
    CPtr treg = temp;                                   \
                                                        \
    reg_arrayptr = reg_array - 1;                       \
    i = cell(treg);                                     \
    i = int_val(i);                                     \
    while (i > 0) {                                     \
      reg_arrayptr++;                                   \
      *reg_arrayptr = *(++treg);                        \
      i--;                                              \
    }                                                   \
    i = *(++treg);                                      \
    num_vars_in_var_regs = int_val(i);                  \
    for (i = 0; i <= num_vars_in_var_regs; i++) {       \
      var_regs[i] = (CPtr)*(++treg);                    \
    }                                                   \
}

save_trie_registers tbreg   ) 
 

Value:

{                               \
  CPtr temp_arrayptr;                                           \
  int reg_count = 0, i;                                         \
                                                                \
  i = num_vars_in_var_regs;                                     \
  while (i >= 0) {                                              \
    *(--tbreg) = (Cell)var_regs[i];                             \
    i--;                                                        \
  }                                                             \
  *(--tbreg) = makeint(num_vars_in_var_regs);                   \
  temp_arrayptr = reg_arrayptr;                                 \
  while (temp_arrayptr >= reg_array) {                          \
    /* INV: temp_array_ptr + reg_count == reg_arrayptr */       \
    *(--tbreg) = *temp_arrayptr;                                \
    reg_count++;                                                \
    temp_arrayptr--;                                            \
  }                                                             \
  (*--tbreg) = makeint(reg_count);                              \
}

#define unify_with_trie_attv
 

Value:

{                                               \
  XSB_Deref(*reg_arrayptr);                                             \
  num_vars_in_var_regs = (int)int_val(opatom) &0xffff;                  \
  if (isref(*reg_arrayptr)) {                                           \
    bind_ref((CPtr) *reg_arrayptr, makeattv(hreg));                     \
  }                                                                     \
  else if (isattv(*reg_arrayptr)) {                                     \
    add_interrupt(CTXTc cell(((CPtr)dec_addr(*reg_arrayptr) + 1)),makeattv(hreg));   \
    bind_ref((CPtr)dec_addr(*reg_arrayptr), makeattv(hreg));    \
  }                                                                     \
  else {                                                                \
    attv_dbgmsg(">>>> add_interrupt in unify_with_trie_attv\n");        \
    add_interrupt(CTXTc makeattv(hreg), *reg_arrayptr);                 \
  }                                                                     \
  var_regs[num_vars_in_var_regs] = (CPtr) makeattv(hreg);               \
  new_heap_free(hreg);                                                  \
  *reg_arrayptr = (Cell) hreg;                                          \
  new_heap_free(hreg);                                                  \
}

#define unify_with_trie_list
 

#define unify_with_trie_numcon
 

Value:

{                                       \
  XSB_Deref(*reg_arrayptr);                                             \
  if (isref(*reg_arrayptr)) {                                           \
    bind_ref((CPtr)*reg_arrayptr, opatom);                               \
  }                                                                     \
  else if (isattv(*reg_arrayptr)) {                                     \
    attv_dbgmsg(">>>> add_interrupt in unify_with_trie_numcon\n");      \
    add_interrupt(CTXTc cell(((CPtr)dec_addr(*reg_arrayptr) + 1)), opatom);\
    bind_int_tagged((CPtr)dec_addr(*reg_arrayptr), opatom);                     \
  }                                                                     \
  else {                                                                \
    if (*reg_arrayptr != opatom) {                                      \
      Fail1;                                                            \
      XSB_Next_Instr();                                                 \
    }                                                                   \
  }                                                                     \
}

#define unify_with_trie_str
 

#define unify_with_trie_val
 

Value:

{                                               \
  Cell cell2deref;                                                      \
  XSB_Deref(*reg_arrayptr);                                             \
  if (isref(*reg_arrayptr)) {                                           \
    cell2deref = (Cell)var_regs[(int)int_val(opatom)];                  \
    XSB_Deref(cell2deref);                                              \
    if (cell2deref != *reg_arrayptr)                                    \
      bind_ref((CPtr) *reg_arrayptr, cell2deref);                       \
  }                                                                     \
  else if (isattv(*reg_arrayptr)) {                                     \
    cell2deref = (Cell) var_regs[(int)int_val(opatom)];                 \
    XSB_Deref(cell2deref);                                              \
    if (*reg_arrayptr != cell2deref) {                                  \
      /* Do not trigger attv interrupt! */                              \
      bind_ref(clref_val(*reg_arrayptr), cell2deref);                   \
    }                                                                   \
    else {                                                              \
      attv_dbgmsg(">>>> keep old attr in unify_with_trie_val\n");       \
    }                                                                   \
  }                                                                     \
  else {                                                                \
    op1 = (Cell)*reg_arrayptr;                                          \
    op2 = (Cell) var_regs[(int)int_val(opatom)];                        \
    if (unify(CTXTc op1,op2) == FALSE) {                                \
      Fail1;                                                            \
      XSB_Next_Instr();                                                 \
    }                                                                   \
  }                                                                     \
  reg_arrayptr--;                                                       \
}


Variable Documentation

int delay_it
 

BTNptr Last_Nod_Sav
 

BTNptr NodePtr
 

int num_vars_in_var_regs = -1
 

Cell* reg_array
 

int reg_array_size = DEFAULT_ARRAYSIZ
 

CPtr reg_arrayptr
 

CPtr var_regs[MAX_TRIE_REGS]
 


Generated on Wed Jul 26 13:26:54 2006 for XSB by  doxygen 1.4.5