Pair link_sym(Psc psc, Psc mod_psc) { Pair *search_ptr, found_pair; char *name, message[120]; byte arity, global_flag; name = get_name(psc); arity = get_arity(psc); if ( (global_flag = is_globalmod(mod_psc)) ) search_ptr = (Pair *)symbol_table.table + hash(name, arity, symbol_table.size); else search_ptr = (Pair *)&get_data(mod_psc); if ((found_pair = search(arity, name, search_ptr))) { if (pair_psc(found_pair) != psc) { /* * Invalidate the old name!! It is no longer accessible * through the global chain. */ if ( get_type(pair_psc(found_pair)) != T_ORDI ) { sprintf(message, "%s/%d (type %d) was defined in another module!", name, arity, get_type(pair_psc(found_pair))); xsb_warn(message); } pair_psc(found_pair) = psc; } } else { found_pair = make_psc_pair(psc, search_ptr); if (global_flag) symbol_table_increment_and_check_for_overflow; } return found_pair; } /* link_sym */
Pair link_sym(Psc psc, Psc mod_psc) { Pair *search_ptr, found_pair; char *name; byte arity, global_flag, type; SYS_MUTEX_LOCK_NOERROR( MUTEX_SYMBOL ) ; name = get_name(psc); arity = get_arity(psc); if ( (global_flag = is_globalmod(mod_psc)) ) { search_ptr = (Pair *)symbol_table.table + hash(name, arity, symbol_table.size); } else search_ptr = (Pair *)&get_data(mod_psc); if ((found_pair = search(arity, name, search_ptr))) { if (pair_psc(found_pair) != psc) { /* * Invalidate the old name!! It is no longer accessible * through the global chain. */ type = get_type(pair_psc(found_pair)); if ( type != T_ORDI ) { char message[220], modmsg[200]; if (type == T_DYNA || type == T_PRED) { Psc mod_psc; mod_psc = (Psc) get_data(pair_psc(found_pair)); if (mod_psc == 0) snprintf(modmsg,200,"%s","usermod"); else if (isstring(mod_psc)) snprintf(modmsg,200,"usermod from file: %s",string_val(mod_psc)); else snprintf(modmsg,200,"module: %s",get_name(mod_psc)); snprintf(message,220, "%s/%d (type %d) had been defined in %s", name, arity, type, modmsg); } else snprintf(message,220, "%s/%d (type %d) had been defined in another module!", name, arity, type); xsb_warn(message); } pair_psc(found_pair) = psc; } } else { found_pair = make_psc_pair(psc, search_ptr); if (global_flag) symbol_table_increment_and_check_for_overflow; } SYS_MUTEX_UNLOCK_NOERROR( MUTEX_SYMBOL ) ; return found_pair; } /* link_sym */
Pair insert(char *name, byte arity, Psc mod_psc, int *is_new) { Pair *search_ptr, temp; if (is_globalmod(mod_psc)) { search_ptr = (Pair *)(symbol_table.table + hash(name, arity, symbol_table.size)); temp = insert0(name, arity, search_ptr, is_new); if (*is_new) symbol_table_increment_and_check_for_overflow; return temp; } else { search_ptr = (Pair *)&(get_data(mod_psc)); return insert0(name, arity, search_ptr, is_new); } } /* insert */