1 #include <portability.h>
65 if (num_bits < 16) h = (h & 0xFFFF) ^ (h >> 16);
66 if (num_bits < 8) h = (h & 0xFF) ^ (h >> 8);
80 h = ((h << 8) | (h >> 24)) ^ (*s);
97 return compress (static_cast<uint32_t>(name_number) ^ (static_cast<uint32_t>(name_letter) << 24), num_bits);
105 return compress (static_cast<uint32_t>(value), num_bits);
109 return compress (static_cast<uint32_t>(value), num_bits);
199 for ( ; sym!=
NIL; sym = sym->common.next_in_hash_table) {
200 if (!strcmp(sym->
var.
name,name))
return sym;
212 for ( ; sym!=
NIL; sym = sym->common.next_in_hash_table) {
226 for ( ; sym!=
NIL; sym = sym->common.next_in_hash_table) {
227 if (!strcmp(sym->
sc.
name,name))
return sym;
239 for ( ; sym!=
NIL; sym = sym->common.next_in_hash_table) {
240 if (value==sym->
ic.
value)
return sym;
252 for ( ; sym!=
NIL; sym = sym->common.next_in_hash_table) {
253 if (value==sym->
fc.
value)
return sym;
265 allocate_with_pool (thisAgent, &thisAgent->
variable_pool, &sym);
267 sym->common.reference_count = 1;
274 #ifdef DEBUG_SYMBOL_REFCOUNTS
277 OutputDebugString(
":+ \n");
278 #endif // DEBUG_SYMBOL_REFCOUNTS
286 if (isalpha(name_letter)) {
287 if (islower(name_letter)) name_letter =
static_cast<char>(toupper(name_letter));
293 sym->common.reference_count = 1;
298 if ( name_number ==
NIL )
300 name_number = thisAgent->
id_counter[name_letter-
'A']++;
304 uint64_t *current_number = &( thisAgent->
id_counter[ name_letter -
'A' ] );
305 if ( name_number >= (*current_number) )
307 (*current_number) = ( name_number + 1 );
358 #ifdef DEBUG_SYMBOL_REFCOUNTS
361 OutputDebugString(
":+ \n");
362 #endif // DEBUG_SYMBOL_REFCOUNTS
375 sym->common.reference_count = 1;
377 sym->common.epmem_hash = 0;
378 sym->common.epmem_valid = 0;
379 sym->common.smem_hash = 0;
380 sym->common.smem_valid = 0;
384 #ifdef DEBUG_SYMBOL_REFCOUNTS
387 OutputDebugString(
":+ \n");
388 #endif // DEBUG_SYMBOL_REFCOUNTS
402 sym->common.reference_count = 1;
404 sym->common.epmem_hash = 0;
405 sym->common.epmem_valid = 0;
406 sym->common.smem_hash = 0;
407 sym->common.smem_valid = 0;
410 #ifdef DEBUG_SYMBOL_REFCOUNTS
413 OutputDebugString(
":+ \n");
414 #endif // DEBUG_SYMBOL_REFCOUNTS
428 sym->common.reference_count = 1;
430 sym->common.epmem_hash = 0;
431 sym->common.epmem_valid = 0;
432 sym->common.smem_hash = 0;
433 sym->common.smem_valid = 0;
436 #ifdef DEBUG_SYMBOL_REFCOUNTS
439 OutputDebugString(
":+ \n");
440 #endif // DEBUG_SYMBOL_REFCOUNTS
457 switch (sym->common.symbol_type) {
482 strncpy (msg,
"Internal error: called deallocate_symbol on non-symbol.\n",
BUFFER_MSG_SIZE);
517 FILE* f =
reinterpret_cast<FILE*
>(userdata);
520 if ( sym->common.reference_count > 0 ) {
525 "\t@%c%llu --> %llu\n",
528 static_cast<long long unsigned>(sym->common.reference_count));
533 "\t%c%llu --> %llu\n",
536 static_cast<long long unsigned>(sym->common.reference_count));
540 print (thisAgent, msg);
544 fprintf(f,
"%s", msg) ;
548 print (thisAgent,
"\tERROR: HASHTABLE ITEM IS NOT AN IDENTIFIER!\n");
562 print (thisAgent,
"Internal warning: wanted to reset identifier generator numbers, but\n");
563 print (thisAgent,
"there are still some identifiers allocated. (Probably a memory leak.)\n");
564 print (thisAgent,
"(Leaving identifier numbers alone.)\n");
565 xml_generate_warning(thisAgent,
"Internal warning: wanted to reset identifier generator numbers, but\nthere are still some identifiers allocated. (Probably a memory leak.)\n(Leaving identifier numbers alone.)");
572 FILE *ids = fopen(
"leaked-ids.txt",
"w") ;
585 for (i=0; i<26; i++) thisAgent->
id_counter[i]=1;
628 print_string (thisAgent,
"\n--- Symbolic Constants: ---\n");
630 print_string (thisAgent,
"\n--- Integer Constants: ---\n");
632 print_string (thisAgent,
"\n--- Floating-Point Constants: ---\n");
641 #define GENERATE_NEW_SYM_CONSTANT_BUFFER_SIZE 2000