Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Data Structures | Macros | Typedefs | Functions
chunk.h File Reference

Go to the source code of this file.

Data Structures

struct  chunk_cond_set_struct
struct  chunk_cond_struct

Macros

#define CHUNK_COND_HASH_TABLE_SIZE   1024
#define LOG_2_CHUNK_COND_HASH_TABLE_SIZE   10

Typedefs

typedef struct agent_struct agent
typedef char Bool
typedef struct chunk_cond_struct chunk_cond
typedef struct
chunk_cond_set_struct 
chunk_cond_set
typedef struct condition_struct condition
typedef struct instantiation_struct instantiation
typedef union symbol_union Symbol

Functions

void add_results_for_id (agent *thisAgent, Symbol *id)
Bool add_to_chunk_cond_set (agent *thisAgent, chunk_cond_set *set, chunk_cond *new_cc)
void chunk_instantiation (agent *thisAgent, instantiation *inst, bool variablize, instantiation **custom_inst_list)
void init_chunker (agent *thisAgent)
chunk_condmake_chunk_cond_for_condition (agent *thisAgent, condition *cond)
void variablize_condition_list (agent *thisAgent, condition *cond)
void variablize_nots_and_insert_into_conditions (agent *thisAgent, not_struct *nots, condition *conds)
void variablize_symbol (agent *thisAgent, Symbol **sym)

Macro Definition Documentation

#define CHUNK_COND_HASH_TABLE_SIZE   1024

Definition at line 25 of file chunk.h.

Referenced by init_chunk_cond_set().

#define LOG_2_CHUNK_COND_HASH_TABLE_SIZE   10

Definition at line 26 of file chunk.h.

Referenced by make_chunk_cond_for_condition().

Typedef Documentation

typedef struct agent_struct agent

Definition at line 51 of file chunk.h.

typedef char Bool

Definition at line 18 of file chunk.h.

typedef struct chunk_cond_struct chunk_cond
typedef struct condition_struct condition

Definition at line 19 of file chunk.h.

Definition at line 20 of file chunk.h.

typedef union symbol_union Symbol

Definition at line 21 of file chunk.h.

Function Documentation

void add_results_for_id ( agent thisAgent,
Symbol id 
)

Definition at line 123 of file chunk.cpp.

References add_pref_to_results(), add_results_if_needed(), preference_struct::all_of_slot_next, slot_struct::all_preferences, agent_struct::extra_result_prefs_from_instantiation, wme_struct::id, preference_struct::id, symbol_union::id, identifier_struct::input_wmes, preference_struct::inst_next, wme_struct::next, slot_struct::next, NIL, agent_struct::results_tc_number, identifier_struct::slots, wme_struct::value, and slot_struct::wmes.

Referenced by add_results_if_needed().

{
slot *s;
preference *pref;
wme *w;
id->id.tc_num = thisAgent->results_tc_number;
/* --- scan through all preferences and wmes for all slots for this id --- */
for (w=id->id.input_wmes; w!=NIL; w=w->next)
add_results_if_needed (thisAgent, w->value);
for (s=id->id.slots; s!=NIL; s=s->next) {
for (pref=s->all_preferences; pref!=NIL; pref=pref->all_of_slot_next)
add_pref_to_results(thisAgent, pref);
for (w=s->wmes; w!=NIL; w=w->next)
add_results_if_needed (thisAgent, w->value);
} /* end of for slots loop */
/* --- now scan through extra prefs and look for any with this id --- */
for (pref=thisAgent->extra_result_prefs_from_instantiation; pref!=NIL;
pref=pref->inst_next) {
if (pref->id==id) add_pref_to_results(thisAgent, pref);
}
}
Bool add_to_chunk_cond_set ( agent thisAgent,
chunk_cond_set set,
chunk_cond new_cc 
)

Definition at line 364 of file chunk.cpp.

References agent_struct::chunk_cond_pool, chunk_cond_struct::compressed_hash_value, chunk_cond_struct::cond, conditions_are_equal(), FALSE, chunk_cond_struct::hash_value, insert_at_head_of_dll, chunk_cond_struct::next_in_bucket, NIL, and TRUE.

Referenced by backtrace_through_instantiation().

{
chunk_cond *old;
for (old=set->table[new_cc->compressed_hash_value]; old!=NIL;
old=old->next_in_bucket)
if (old->hash_value==new_cc->hash_value)
if (conditions_are_equal (old->cond, new_cc->cond))
break;
if (old) {
/* --- the new condition was already in the set; so don't add it --- */
free_with_pool (&thisAgent->chunk_cond_pool, new_cc);
return FALSE;
}
/* --- add new_cc to the table --- */
insert_at_head_of_dll (set->all, new_cc, next, prev);
next_in_bucket, prev_in_bucket);
return TRUE;
}
void chunk_instantiation ( agent thisAgent,
instantiation inst,
bool  variablize,
instantiation **  custom_inst_list 
)

Definition at line 973 of file chunk.cpp.

References explain_chunk_struct::actions, add_goal_or_impasse_tests(), add_production_to_rete(), explain_chunk_struct::all_grounds, identifier_struct::allow_bottom_up_chunks, explain_chunk_struct::backtrace, agent_struct::backtrace_number, backtrace_through_instantiation(), instantiation_struct::bottom_of_instantiated_conditions, build_chunk_conds_for_grounds_and_add_negateds(), agent_struct::chunk_cond_pool, chunk_instantiation(), CHUNK_PRODUCTION_TYPE, agent_struct::chunks_this_d_cycle, explain_chunk_struct::conds, copy_and_variablize_result_list(), copy_condition_list(), agent_struct::current_phase, deallocate_action_list(), deallocate_condition_list(), DUPLICATE_PRODUCTION, excise_production(), explain_add_temp_to_chunk_list(), EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE, EXPLAIN_SYSPARAM, FALSE, fill_in_new_instantiation_stuff(), free_list(), instantiation_struct::GDS_evaluated_already, generate_chunk_name_sym_constant(), generate_new_sym_constant(), get_new_tc_number(), get_nots_for_instantiated_conditions(), get_printer_output_column(), get_results_for_instantiation(), agent_struct::grounds, agent_struct::grounds_tc, identifier_struct::higher_goal, preference_struct::id, symbol_union::id, instantiation_struct::in_ms, preference_struct::inst, preference_struct::inst_next, chunk_cond_struct::instantiated_cond, agent_struct::instantiation_pool, agent_struct::instantiations_with_nots, agent_struct::justification_count, JUSTIFICATION_PRODUCTION_TYPE, identifier_struct::level, agent_struct::locals, agent_struct::locals_tc, make_clones_of_results(), make_production(), instantiation_struct::match_goal, instantiation_struct::match_goal_level, agent_struct::max_chunks_reached, MAX_CHUNKS_SYSPARAM, explain_chunk_struct::name, sym_constant_struct::name, chunk_cond_struct::next, instantiation_struct::next, explain_chunk_struct::next_chunk, preference_struct::next_result, NIL, instantiation_struct::nots, agent_struct::positive_potentials, agent_struct::potentials_tc, instantiation_struct::preferences_generated, print(), print_action_list(), print_condition_list(), print_preference(), print_production(), print_string(), PRINT_WARNINGS_SYSPARAM, print_with_symbols(), instantiation_struct::prod, REFRACTED_INST_DID_NOT_MATCH, REFRACTED_INST_MATCHED, instantiation_struct::reliable, reorder_instantiated_conditions(), reset_backtrace_list(), reset_variable_generator(), symbol_union::sc, should_variablize(), smem_valid_production(), agent_struct::stop_soar, symbol_remove_ref(), agent_struct::sysparams, agent_struct::system_halted, TIMERS_ENABLED, instantiation_struct::top_of_instantiated_conditions, TRACE_BACKTRACING_SYSPARAM, TRACE_CHUNK_NAMES_SYSPARAM, TRACE_CHUNKS_SYSPARAM, trace_grounded_potentials(), TRACE_JUSTIFICATION_NAMES_SYSPARAM, TRACE_JUSTIFICATIONS_SYSPARAM, trace_locals(), trace_ungrounded_potentials(), TRUE, agent_struct::variablization_tc, variablize_condition_list(), variablize_nots_and_insert_into_conditions(), chunk_cond_struct::variablized_cond, xml_att_val(), xml_begin_tag(), xml_end_tag(), and xml_generate_warning().

Referenced by _epmem_process_buffered_wme_list(), _smem_process_buffered_wme_list(), chunk_instantiation(), and create_instantiation().

{
goal_stack_level grounds_level;
preference *results, *pref;
action *rhs;
production *prod;
instantiation *chunk_inst;
Symbol *prod_name;
byte prod_type;
Bool print_name, print_prod;
byte rete_addition_result;
condition *lhs_top, *lhs_bottom;
not_struct *nots;
chunk_cond *top_cc, *bottom_cc;
bool reliable = true;
bool variablize;
explain_chunk_str temp_explain_chunk;
memset(temp_explain_chunk.name, 0, EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE);
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
soar_process_timer local_timer;
local_timer.set_enabled( &( thisAgent->sysparams[ TIMERS_ENABLED ] ) );
#endif
#endif
/* --- if it only matched an attribute impasse, don't chunk --- */
if (! inst->match_goal)
return;
/* --- if no preference is above the match goal level, exit --- */
for (pref=inst->preferences_generated; pref!=NIL; pref=pref->inst_next)
{
if (pref->id->id.level < inst->match_goal_level)
break;
}
if (! pref)
return;
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.start();
#endif
#endif
results = get_results_for_instantiation (thisAgent, inst);
if (!results) goto chunking_done;
/* set allow_bottom_up_chunks to false for all higher goals to prevent chunking */
{
Symbol *g;
}
grounds_level = inst->match_goal_level - 1;
thisAgent->backtrace_number++;
if (thisAgent->backtrace_number==0)
thisAgent->backtrace_number=1;
thisAgent->grounds_tc++;
if (thisAgent->grounds_tc==0)
thisAgent->grounds_tc=1;
thisAgent->potentials_tc++;
if (thisAgent->potentials_tc==0)
thisAgent->potentials_tc=1;
thisAgent->locals_tc++;
if (thisAgent->locals_tc==0)
thisAgent->locals_tc=1;
thisAgent->grounds = NIL;
thisAgent->positive_potentials = NIL;
thisAgent->locals = NIL;
/* Start a new structure for this potential chunk */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
temp_explain_chunk.conds = NULL;
temp_explain_chunk.actions = NULL;
temp_explain_chunk.backtrace = NULL;
temp_explain_chunk.name[0] = '\0';
temp_explain_chunk.all_grounds = NIL;
temp_explain_chunk.next_chunk = NULL;
}
/* --- backtrace through the instantiation that produced each result --- */
for (pref=results; pref!=NIL; pref=pref->next_result)
{
{
print_string (thisAgent, "\nFor result preference ");
xml_begin_tag(thisAgent, kTagBacktraceResult);
print_preference (thisAgent, pref);
print_string (thisAgent, " ");
}
backtrace_through_instantiation (thisAgent, pref->inst, grounds_level, NULL, &reliable, 0);
{
xml_end_tag(thisAgent, kTagBacktraceResult);
}
}
while (TRUE)
{
trace_locals (thisAgent, grounds_level, &reliable);
if (! trace_ungrounded_potentials (thisAgent, grounds_level, &reliable)) break;
}
free_list (thisAgent, thisAgent->positive_potentials);
/* --- backtracing done; collect the grounds into the chunk --- */
{
tc_number tc_for_grounds;
tc_for_grounds = get_new_tc_number(thisAgent);
build_chunk_conds_for_grounds_and_add_negateds (thisAgent, &top_cc, &bottom_cc, tc_for_grounds, &reliable);
nots = get_nots_for_instantiated_conditions (thisAgent, thisAgent->instantiations_with_nots, tc_for_grounds);
}
variablize = !dont_variablize && reliable && should_variablize(thisAgent, inst);
/* --- check for LTI validity --- */
if ( variablize )
{
if ( top_cc )
{
// need a temporary copy of the actions
thisAgent->variablization_tc = get_new_tc_number(thisAgent);
rhs = copy_and_variablize_result_list (thisAgent, results, true);
if ( !smem_valid_production( top_cc->variablized_cond, rhs ) )
{
variablize = false;
{
print( thisAgent, "\nWarning: LTI validation failed, creating justification instead." );
xml_generate_warning( thisAgent, "LTI validation failed, creating justification instead." );
}
}
// remove temporary copy
deallocate_action_list (thisAgent, rhs);
}
}
/* --- get symbol for name of new chunk or justification --- */
if (variablize)
{
/* kjh (B14) begin */
thisAgent->chunks_this_d_cycle++;
prod_name = generate_chunk_name_sym_constant(thisAgent, inst);
/* kjh (B14) end */
/* old way of generating chunk names ...
prod_name = generate_new_sym_constant ("chunk-",&thisAgent->chunk_count);
thisAgent->chunks_this_d_cycle)++;
*/
prod_type = CHUNK_PRODUCTION_TYPE;
print_name = (thisAgent->sysparams[TRACE_CHUNK_NAMES_SYSPARAM] != 0);
print_prod = (thisAgent->sysparams[TRACE_CHUNKS_SYSPARAM] != 0);
}
else
{
prod_name = generate_new_sym_constant (thisAgent, "justification-", &thisAgent->justification_count);
print_name = (thisAgent->sysparams[TRACE_JUSTIFICATION_NAMES_SYSPARAM] != 0);
print_prod = (thisAgent->sysparams[TRACE_JUSTIFICATIONS_SYSPARAM] != 0);
}
/* AGR 617/634 begin */
if (print_name)
{
if (get_printer_output_column(thisAgent)!=1)
print (thisAgent, "\n");
print_with_symbols (thisAgent, "Building %y", prod_name);
xml_begin_tag(thisAgent, kTagLearning);
xml_begin_tag(thisAgent, kTagProduction);
xml_att_val(thisAgent, kProduction_Name, prod_name);
xml_end_tag(thisAgent, kTagProduction);
xml_end_tag(thisAgent, kTagLearning);
}
/* AGR 617/634 end */
/* --- if there aren't any grounds, exit --- */
if (! top_cc)
{
{
print_string (thisAgent, " Warning: chunk has no grounds, ignoring it.");
xml_generate_warning(thisAgent, "Warning: chunk has no grounds, ignoring it.");
}
symbol_remove_ref(thisAgent, prod_name);
goto chunking_done;
}
/* MVP 6-8-94 */
if (thisAgent->chunks_this_d_cycle > static_cast<uint64_t>(thisAgent->sysparams[MAX_CHUNKS_SYSPARAM]) )
{
{
print (thisAgent, "\nWarning: reached max-chunks! Halting system.");
xml_generate_warning(thisAgent, "Warning: reached max-chunks! Halting system.");
}
thisAgent->max_chunks_reached = TRUE;
symbol_remove_ref(thisAgent, prod_name);
goto chunking_done;
}
lhs_top = top_cc->variablized_cond;
lhs_bottom = bottom_cc->variablized_cond;
if (variablize) {
reset_variable_generator (thisAgent, lhs_top, NIL);
thisAgent->variablization_tc = get_new_tc_number(thisAgent);
variablize_condition_list (thisAgent, lhs_top);
variablize_nots_and_insert_into_conditions (thisAgent, nots, lhs_top);
}
rhs = copy_and_variablize_result_list (thisAgent, results, variablize);
add_goal_or_impasse_tests (thisAgent, top_cc);
prod = make_production (thisAgent, prod_type, prod_name, &lhs_top, &lhs_bottom, &rhs, FALSE);
if (!prod)
{
print (thisAgent, "\nUnable to reorder this chunk:\n ");
print_condition_list (thisAgent, lhs_top, 2, FALSE);
print (thisAgent, "\n -->\n ");
print_action_list (thisAgent, rhs, 3, FALSE);
print (thisAgent, "\n\nThis error is likely caused by the reasons outlined section 4 of the Soar\n");
print (thisAgent, "manual, subsection \"revising the substructure of a previous result\".\n");
print (thisAgent, "\n");
print (thisAgent, "Check that the rules are not revising substructure of a result matched only\n");
print (thisAgent, "through the local state.\n");
{
while (top_cc)
{
cc = top_cc;
top_cc = cc->next;
free_with_pool (&thisAgent->chunk_cond_pool, cc);
}
}
deallocate_action_list (thisAgent, rhs);
symbol_remove_ref(thisAgent, prod_name);
// We cannot proceed, the GDS will crash in decide.cpp:decide_non_context_slot
thisAgent->stop_soar = TRUE;
thisAgent->system_halted = TRUE;
goto chunking_done;
}
{
condition *inst_lhs_top = 0, *inst_lhs_bottom = 0;
reorder_instantiated_conditions (top_cc, &inst_lhs_top, &inst_lhs_bottom);
/* Record the list of grounds in the order they will appear in the chunk. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
temp_explain_chunk.all_grounds = inst_lhs_top; /* Not a copy yet */
allocate_with_pool (thisAgent, &thisAgent->instantiation_pool, &chunk_inst);
chunk_inst->prod = prod;
chunk_inst->top_of_instantiated_conditions = inst_lhs_top;
chunk_inst->bottom_of_instantiated_conditions = inst_lhs_bottom;
chunk_inst->nots = nots;
chunk_inst->GDS_evaluated_already = FALSE; /* REW: 09.15.96 */
chunk_inst->reliable = reliable;
chunk_inst->in_ms = TRUE; /* set TRUE for now, we'll find out later... */
make_clones_of_results (thisAgent, results, chunk_inst);
fill_in_new_instantiation_stuff (thisAgent, chunk_inst, TRUE);
}
/* RBD 4/6/95 Need to copy cond's and actions for the production here,
otherwise some of the variables might get deallocated by the call to
add_production_to_rete() when it throws away chunk variable names. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
condition *new_top = 0;
condition *new_bottom = 0;
copy_condition_list (thisAgent, lhs_top, &new_top, &new_bottom);
temp_explain_chunk.conds = new_top;
temp_explain_chunk.actions = copy_and_variablize_result_list (thisAgent, results, variablize);
}
rete_addition_result = add_production_to_rete (thisAgent, prod, lhs_top, chunk_inst, print_name);
/* If didn't immediately excise the chunk from the rete net
then record the temporary structure in the list of explained chunks. */
if (thisAgent->sysparams[EXPLAIN_SYSPARAM])
{
if ((rete_addition_result != DUPLICATE_PRODUCTION)
&& ((prod_type != JUSTIFICATION_PRODUCTION_TYPE)
|| (rete_addition_result != REFRACTED_INST_DID_NOT_MATCH) ))
{
strncpy(temp_explain_chunk.name,prod_name->sc.name, EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE);
temp_explain_chunk.name[EXPLAIN_CHUNK_STRUCT_NAME_BUFFER_SIZE - 1] = 0;
explain_add_temp_to_chunk_list (thisAgent, &temp_explain_chunk);
}
else
{
/* RBD 4/6/95 if excised the chunk, discard previously-copied stuff */
deallocate_condition_list (thisAgent, temp_explain_chunk.conds);
deallocate_action_list (thisAgent, temp_explain_chunk.actions);
}
}
/* --- deallocate chunks conds and variablized conditions --- */
deallocate_condition_list (thisAgent, lhs_top);
{
while (top_cc)
{
cc = top_cc;
top_cc = cc->next;
free_with_pool (&thisAgent->chunk_cond_pool, cc);
}
}
if (print_prod && (rete_addition_result!=DUPLICATE_PRODUCTION))
{
print_string (thisAgent, "\n");
xml_begin_tag(thisAgent, kTagLearning);
print_production (thisAgent, prod, FALSE);
xml_end_tag(thisAgent, kTagLearning);
}
if (rete_addition_result==DUPLICATE_PRODUCTION)
{
excise_production (thisAgent, prod, FALSE);
}
else if ((prod_type==JUSTIFICATION_PRODUCTION_TYPE)
&& (rete_addition_result==REFRACTED_INST_DID_NOT_MATCH))
{
excise_production (thisAgent, prod, FALSE);
}
if (rete_addition_result!=REFRACTED_INST_MATCHED)
{
/* --- it didn't match, or it was a duplicate production --- */
/* --- tell the firer it didn't match, so it'll only assert the
o-supported preferences --- */
chunk_inst->in_ms = FALSE;
}
/* --- assert the preferences --- */
chunk_inst->next = (*custom_inst_list);
(*custom_inst_list) = chunk_inst;
/* MVP 6-8-94 */
if (!thisAgent->max_chunks_reached)
chunk_instantiation (thisAgent, chunk_inst, dont_variablize, custom_inst_list);
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.stop();
thisAgent->timers_chunking_cpu_time[thisAgent->current_phase].update(local_timer);
#endif
#endif
return;
chunking_done: {}
#ifndef NO_TIMING_STUFF
#ifdef DETAILED_TIMING_STATS
local_timer.stop();
thisAgent->timers_chunking_cpu_time[thisAgent->current_phase].update(local_timer);
#endif
#endif
}
void init_chunker ( agent thisAgent)

Definition at line 1371 of file chunk.cpp.

References agent_struct::chunk_cond_pool, init_chunk_cond_set(), init_memory_pool(), and agent_struct::negated_set.

Referenced by init_soar_agent().

{
init_memory_pool (thisAgent, &thisAgent->chunk_cond_pool, sizeof(chunk_cond), "chunk condition");
}
chunk_cond* make_chunk_cond_for_condition ( agent thisAgent,
condition cond 
)

Definition at line 346 of file chunk.cpp.

References agent_struct::chunk_cond_pool, chunk_cond_struct::compressed_hash_value, chunk_cond_struct::cond, hash_condition(), chunk_cond_struct::hash_value, LOG_2_CHUNK_COND_HASH_TABLE_SIZE, masks_for_n_low_order_bits, and uint32_t().

Referenced by backtrace_through_instantiation().

{
uint32_t remainder, hv;
allocate_with_pool (thisAgent, &thisAgent->chunk_cond_pool, &cc);
cc->cond = cond;
cc->hash_value = hash_condition (thisAgent, cond);
remainder = cc->hash_value;
hv = 0;
while (remainder) {
hv ^= (remainder &
remainder = remainder >> LOG_2_CHUNK_COND_HASH_TABLE_SIZE;
}
return cc;
}
void variablize_condition_list ( agent thisAgent,
condition cond 
)

Definition at line 238 of file chunk.cpp.

{
for (; cond!=NIL; cond=cond->next) {
switch (cond->type) {
variablize_test (thisAgent, &(cond->data.tests.id_test));
variablize_test (thisAgent, &(cond->data.tests.attr_test));
variablize_test (thisAgent, &(cond->data.tests.value_test));
break;
variablize_condition_list (thisAgent, cond->data.ncc.top);
break;
}
}
}
void variablize_nots_and_insert_into_conditions ( agent thisAgent,
not_struct nots,
condition conds 
)

Definition at line 576 of file chunk.cpp.

{
Symbol *var1, *var2;
test t;
Bool added_it;
for (n=nots; n!=NIL; n=n->next) {
var1 = n->s1->id.variablization;
var2 = n->s2->id.variablization;
/* --- find where var1 is bound, and add "<> var2" to that test --- */
allocate_with_pool (thisAgent, &thisAgent->complex_test_pool, &ct);
ct->data.referent = var2;
added_it = FALSE;
for (c=conds; c!=NIL; c=c->next) {
if (c->type != POSITIVE_CONDITION) continue;
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.id_test), t);
added_it = TRUE;
break;
}
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.attr_test), t);
added_it = TRUE;
break;
}
var1)) {
add_new_test_to_test (thisAgent, &(c->data.tests.value_test), t);
added_it = TRUE;
break;
}
}
if (!added_it) {
char msg[BUFFER_MSG_SIZE];
strncpy (msg,"chunk.c: Internal error: couldn't add Not test to chunk\n", BUFFER_MSG_SIZE);
msg[BUFFER_MSG_SIZE - 1] = 0; /* ensure null termination */
abort_with_fatal_error(thisAgent, msg);
}
} /* end of for n=nots */
}
void variablize_symbol ( agent thisAgent,
Symbol **  sym 
)

Definition at line 179 of file chunk.cpp.

{
char prefix[2];
Symbol *var;
if ((*sym)->common.symbol_type!=IDENTIFIER_SYMBOL_TYPE) return; // only variablize identifiers
if ((*sym)->id.smem_lti != NIL) // don't variablize lti (long term identifiers)
{
(*sym)->id.tc_num = thisAgent->variablization_tc;
(*sym)->id.variablization = (*sym);
return;
}
if ((*sym)->id.tc_num == thisAgent->variablization_tc) {
/* --- it's already been variablized, so use the existing variable --- */
var = (*sym)->id.variablization;
symbol_remove_ref (thisAgent, *sym);
*sym = var;
return;
}
/* --- need to create a new variable --- */
(*sym)->id.tc_num = thisAgent->variablization_tc;
prefix[0] = static_cast<char>(tolower((*sym)->id.name_letter));
prefix[1] = 0;
var = generate_new_variable (thisAgent, prefix);
(*sym)->id.variablization = var;
symbol_remove_ref (thisAgent, *sym);
*sym = var;
}