Skip to content

Commit

Permalink
Fix more unused variable warnings
Browse files Browse the repository at this point in the history
Continues work on #347.
  • Loading branch information
garfieldnate committed Mar 6, 2024
1 parent 906dbd3 commit 52f8bef
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Core/SoarKernel/src/decision_process/run_soar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ extern void determine_highest_active_production_level_in_stack_apply(agent* this

void abort_with_fatal_error(agent* thisAgent, const char* msg)
{
FILE* f;
const char* warning = "Soar cannot recover from this error. \nData is still available for inspection, but may be corrupt.\nYou will have to restart Soar to run an agent.\nIf a log was open, it has been closed for safety.";

Output_Manager::Get_OM().printa(thisAgent, msg);
Expand All @@ -77,6 +76,7 @@ void abort_with_fatal_error(agent* thisAgent, const char* msg)
xml_generate_error(thisAgent, msg);
xml_generate_error(thisAgent, warning);

// FILE* f;
// f = fopen("soar_crash_log.txt", "w");
// fprintf(f, "%s", msg);
// fprintf(f, "%s", warning);
Expand Down
22 changes: 8 additions & 14 deletions Core/SoarKernel/src/explanation_memory/instantiation_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ void instantiation_record::create_identity_paths(const inst_record_list* pInstPa
if (lParentInst && (lParentInst->get_match_level() == match_level))
{
lParentInst->create_identity_paths(path_to_base);
} else {
condition_record* lCond = (*it);
}
}
}
Expand Down Expand Up @@ -465,7 +463,6 @@ void instantiation_record::print_arch_inst_for_explanation_trace(bool isChunk, b
condition_record* lCond;
bool lInNegativeConditions = false;
int lConditionCount = 0;
action* rhs;
production* originalProduction = thisAgent->explanationMemory->get_production(original_productionID);

/* Print header */
Expand Down Expand Up @@ -546,7 +543,6 @@ void instantiation_record::viz_wm_instantiation(visObjectType objectType)

Output_Manager* outputManager = thisAgent->outputManager;
GraphViz_Visualizer* visualizer = thisAgent->visualizationManager;
condition_record* lCond;

if (conditions->empty())
{
Expand Down Expand Up @@ -616,8 +612,6 @@ void instantiation_record::viz_et_instantiation(visObjectType objectType)
int lConditionCount = 0;
action* rhs;
condition* top, *bottom, *currentNegativeCond, *current_cond, *print_cond;
test id_test_without_goal_test = NULL, id_test_without_goal_test2 = NULL;
bool removed_goal_test, removed_impasse_test;
production* originalProduction = thisAgent->explanationMemory->get_production(original_productionID);

if (!originalProduction || !originalProduction->p_node)
Expand Down Expand Up @@ -646,20 +640,20 @@ void instantiation_record::viz_et_instantiation(visObjectType objectType)
}
outputManager->set_print_test_format(true, false);

thisAgent->visualizationManager->viz_object_start(production_name, instantiationID, objectType);
visualizer->viz_object_start(production_name, instantiationID, objectType);

for (condition_record_list::iterator it = conditions->begin(); it != conditions->end(); it++)
{
lCond = (*it);
++lConditionCount;
if (lConditionCount > 1)
{
thisAgent->visualizationManager->viz_endl();
visualizer->viz_endl();
}

if (!lInNegativeConditions && (lCond->type == CONJUNCTIVE_NEGATION_CONDITION))
{
thisAgent->visualizationManager->viz_NCC_start();
visualizer->viz_NCC_start();
lInNegativeConditions = true;
}

Expand All @@ -685,7 +679,7 @@ void instantiation_record::viz_et_instantiation(visObjectType objectType)
if (!currentNegativeCond)
{
current_cond = current_cond->next;
thisAgent->visualizationManager->viz_NCC_end();
visualizer->viz_NCC_end();
lInNegativeConditions = false;
}
} else {
Expand All @@ -698,19 +692,19 @@ void instantiation_record::viz_et_instantiation(visObjectType objectType)
}
if (lInNegativeConditions)
{
thisAgent->visualizationManager->viz_NCC_end();
visualizer->viz_NCC_end();
} else {
thisAgent->visualizationManager->viz_endl();
visualizer->viz_endl();
}
thisAgent->visualizationManager->viz_seperator();
visualizer->viz_seperator();

action_record::viz_action_list(thisAgent, actions, originalProduction, rhs, excised_production);

if (originalProduction && originalProduction->p_node)
{
deallocate_condition_list(thisAgent, top);
}
thisAgent->visualizationManager->viz_object_end(objectType);
visualizer->viz_object_end(objectType);
}
}

Expand Down
1 change: 0 additions & 1 deletion Core/SoarKernel/src/parsing/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,6 @@ void Lexer::addExec()
Lexeme Lexer::get_lexeme_from_string (agent* thisAgent, const char* input)
{
Lexer lexer = Lexer(thisAgent, input);
const char * c;
lexer.current_lexeme.lex_string = "";
lexer.consume_whitespace_and_comments();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ Symbol* rl_build_template_instantiation(agent* thisAgent, instantiation* my_temp
}

production* my_template = my_template_instance->prod;
char first_letter;
double init_value = 0;
condition* cond_top, *cond_bottom;

Expand Down Expand Up @@ -988,7 +987,6 @@ void rl_perform_update(agent* thisAgent, double op_value, bool op_rl, Symbol* go
}

// Change value of rule
Symbol* lSym = rhs_value_to_symbol(prod->action_list->referent);
deallocate_rhs_value(thisAgent, prod->action_list->referent);
prod->action_list->referent = allocate_rhs_value_for_symbol_no_refcount(thisAgent, thisAgent->symbolManager->make_float_constant(new_combined), 0, 0);

Expand Down
11 changes: 3 additions & 8 deletions Core/SoarKernel/src/semantic_memory/smem_activation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ double SMem_Manager::lti_calc_base(uint64_t pLTI_ID, int64_t time_now, uint64_t
// get all history
SQL->history_get->bind_int(1, pLTI_ID);
SQL->history_get->execute();
bool prohibited = false;
//int recent = 0;
int64_t recent_time = 0;

Expand Down Expand Up @@ -296,7 +295,6 @@ double SMem_Manager::lti_activate(uint64_t pLTI_ID, bool add_access, uint64_t nu
double spread = 0;
double modified_spread = 0;
double new_base;
double additional;
bool already_in_spread_table = false;
std::unordered_map<uint64_t, int64_t>* spreaded_to = smem_spreaded_to;
if (settings->spreading->get_value() == on && spreaded_to->find(pLTI_ID) != spreaded_to->end() && (*spreaded_to)[pLTI_ID] != 0)
Expand Down Expand Up @@ -388,7 +386,7 @@ void SMem_Manager::child_spread(uint64_t lti_id, std::map<uint64_t, std::list<st
double total_touches = 0;
std::list<smem_edge_update*>::iterator edge_begin_it = edge_updates->begin();
std::list<smem_edge_update*>::iterator edge_it;
bool prohibited = false;
// bool prohibited = false;
double edge_update_decay = thisAgent->SMem->settings->spreading_edge_update_factor->get_value();//.99;
for (edge_it = edge_begin_it; edge_it != edge_updates->end(); ++edge_it)
{
Expand Down Expand Up @@ -485,7 +483,6 @@ void SMem_Manager::child_spread(uint64_t lti_id, std::map<uint64_t, std::list<st
//After the loop of commits to the table, we then loop over thge original updates map attached to the agent to do the deletions (frees).
std::map<uint64_t,double>::iterator updates_begin = old_edge_weight_map_for_children.begin();
std::map<uint64_t,double>::iterator updates_it;
double update_sum = 0;
soar_module::sqlite_statement* update_edge = SQL->web_update_child_edge;
for (updates_it = updates_begin; updates_it != old_edge_weight_map_for_children.end(); ++updates_it)
{// args are edge weight, parent lti it, child lti id.
Expand Down Expand Up @@ -700,12 +697,10 @@ void SMem_Manager::calc_spread_trajectories()
attach();
soar_module::sqlite_statement* lti_all = SQL->lti_all;
uint64_t lti_id;
int j = 0;
//smem_delete_trajectory_indices();//This is for efficiency.
//It's super inefficient to maintain the database indexing during this batch processing
//It's way better to delete and rebuild. However, for testing and small DBs, it's fine. I'm testing... so... it's commented for now.
// - scijones (Yell at me if you see this.)
double p1 = settings->spreading_continue_probability->get_value();
std::map<uint64_t, std::list<std::pair<uint64_t, double>>*> lti_trajectories;
while (lti_all->execute() == soar_module::row)
{//loop over all ltis.
Expand Down Expand Up @@ -949,7 +944,7 @@ void SMem_Manager::calc_spread(std::set<uint64_t>* current_candidates, bool do_m
{
SQL->act_lti_fake_get->bind_int(1,*recipient_it);
SQL->act_lti_fake_get->execute();
double spread = SQL->act_lti_fake_get->column_double(1);//This is the spread before changes.
// double spread = SQL->act_lti_fake_get->column_double(1);//This is the spread before changes.
double prev_base = SQL->act_lti_fake_get->column_double(0);
SQL->act_lti_fake_get->reinitialize();
SQL->act_lti_fake_delete->bind_int(1, *recipient_it);
Expand Down Expand Up @@ -1047,7 +1042,7 @@ void SMem_Manager::calc_spread(std::set<uint64_t>* current_candidates, bool do_m
{
SQL->act_lti_fake_get->bind_int(1,*candidate);
SQL->act_lti_fake_get->execute();
double spread = SQL->act_lti_fake_get->column_double(1);//This is the spread before changes.
// double spread = SQL->act_lti_fake_get->column_double(1);//This is the spread before changes.
double prev_base = SQL->act_lti_fake_get->column_double(0);
SQL->act_lti_fake_get->reinitialize();
SQL->act_lti_fake_delete->bind_int(1, *candidate);
Expand Down
8 changes: 0 additions & 8 deletions Core/SoarKernel/src/semantic_memory/smem_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ void SMem_Manager::create_store_set(ltm_set* store_set, uint64_t lti_id, uint64_
* scijones Sept 9, 2016.
*/
soar_module::sqlite_statement* expand_q = thisAgent->SMem->SQL->web_expand;
std::string attr_str;
int64_t attr_int;
double attr_double;
std::string val_str;
int64_t val_int;
double val_double;

smem_vis_lti* new_lti;
smem_vis_lti* parent_lti;
Expand Down Expand Up @@ -224,8 +218,6 @@ id_set SMem_Manager::print_LTM(uint64_t pLTI_ID, double lti_act, std::string* re
return_val->append("(");
get_lti_name(pLTI_ID, *return_val);

bool possible_id, possible_ic, possible_fc, possible_sc, possible_var, is_rereadable;

// get direct children: attr_type, attr_hash, value_type, value_hash, value_letter, value_num, value_lti
expand_q->bind_int(1, pLTI_ID);
while (expand_q->execute() == soar_module::row)
Expand Down
2 changes: 1 addition & 1 deletion Core/SoarKernel/src/semantic_memory/smem_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void SMem_Manager::STM_to_LTM(Symbol* pSTI, smem_storage_type store_type, bool u
wme_list* children = get_direct_augs_of_id(pSTI, tc);
wme_list::iterator w;

uint64_t l_val_ID, l_LTM_ID = get_current_LTI_for_iSTI(pSTI, use_lookup, pOverwriteOldLinkToLTM);
uint64_t l_LTM_ID = get_current_LTI_for_iSTI(pSTI, use_lookup, pOverwriteOldLinkToLTM);

// encode this level
{
Expand Down
1 change: 0 additions & 1 deletion Core/SoarKernel/src/soar_representation/instantiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@ void add_deep_copy_prefs_to_inst(agent* thisAgent, preference* pref, instantiati

deep_copy_wme* lNewDC_WME;
goal_stack_level glbDeepCopyWMELevel = 0;
condition* prev_cond = NULL;
preference* lPref;

glbDeepCopyWMELevel = pref->id->id->level;
Expand Down
2 changes: 0 additions & 2 deletions Core/SoarKernel/src/soar_representation/production.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ void add_symbol_to_tc(agent* thisAgent, Symbol* sym, tc_number tc, cons** id_lis

void add_test_to_tc(agent* thisAgent, test t, tc_number tc, cons** id_list, cons** var_list)
{
cons* c;

if (!t) return;
add_symbol_to_tc(thisAgent, t->eq_test->data.referent, tc, id_list, var_list);

Expand Down
14 changes: 7 additions & 7 deletions Core/SoarKernel/src/soar_representation/production_reorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,12 +812,13 @@ cons* collect_root_variables(agent* thisAgent,

for (auto it = new_vars_from_id_slot->begin(); it != new_vars_from_id_slot->end(); it++)
{
chunk_element* lOldMatchedSym = (*it);
found_goal_impasse_test = false;

for (cond = cond_list; cond != NIL; cond = cond->next)
{
if (cond->type != POSITIVE_CONDITION) continue;
if ((cond->data.tests.id_test->eq_test->data.referent == (*it)->variable_sym) &&
if ((cond->data.tests.id_test->eq_test->data.referent == lOldMatchedSym->variable_sym) &&
test_includes_goal_or_impasse_id_test(cond->data.tests.id_test, true, true))
{
found_goal_impasse_test = true;
Expand All @@ -826,21 +827,20 @@ cons* collect_root_variables(agent* thisAgent,
}
if (! found_goal_impasse_test)
{
if (add_ungrounded && isNewUngroundedElement(ungrounded_syms, (*it)->instantiated_sym, (*it)->inst_identity))
if (add_ungrounded && isNewUngroundedElement(ungrounded_syms, lOldMatchedSym->instantiated_sym, lOldMatchedSym->inst_identity))
{
chunk_element* lNewUngroundedSym;
thisAgent->memoryManager->allocate_with_pool(MP_chunk_element, &lNewUngroundedSym);
chunk_element* lOldMatchedSym = (*it);
lNewUngroundedSym->variable_sym = (*it)->variable_sym;
lNewUngroundedSym->instantiated_sym = (*it)->instantiated_sym;
lNewUngroundedSym->inst_identity = (*it)->inst_identity;
lNewUngroundedSym->variable_sym = lOldMatchedSym->variable_sym;
lNewUngroundedSym->instantiated_sym = lOldMatchedSym->instantiated_sym;
lNewUngroundedSym->inst_identity = lOldMatchedSym->inst_identity;
ungrounded_syms->push_back(lNewUngroundedSym);
} else {
// TODO: we should reject the rule entirely, not just print a warning. sp {hello-world (<s> ^results <any>)-->}
if (thisAgent->outputManager->settings[OM_WARNINGS])
{
thisAgent->outputManager->sprinta_sf(thisAgent, errorStr, "\nWarning: On the LHS of production %s, identifier %y is not connected to any goal or impasse.\n",
thisAgent->name_of_production_being_reordered, (*it)->variable_sym);
thisAgent->name_of_production_being_reordered, lOldMatchedSym->variable_sym);
thisAgent->outputManager->printa(thisAgent, errorStr.c_str());
xml_generate_warning(thisAgent, errorStr.c_str());
}
Expand Down
8 changes: 3 additions & 5 deletions Core/SoarKernel/src/soar_representation/rhs_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ get_lti_id_rhs_function_code(agent* thisAgent, cons* args, void* /*user_data*/)
Symbol*
set_lti_id_rhs_function_code(agent* thisAgent, cons* args, void* /*user_data*/)
{
Symbol* sym, *ltiIDSym, *returnSym;
Symbol* sym, *ltiIDSym;

if (!args)
{
Expand Down Expand Up @@ -713,8 +713,6 @@ Symbol* trim_rhs_function_code(agent* thisAgent, cons* args, void* /*user_data*/
*/
Symbol* string_rhs_function_code(agent* thisAgent, cons* args, void* /*user_data*/)
{
char* symbol_to_convert;

if (!args)
{
thisAgent->outputManager->printa_sf(thisAgent, "%eError: 'string' function called with no arguments.\n");
Expand Down Expand Up @@ -1096,7 +1094,7 @@ Symbol* xmltowme_from_xml_internal(agent* thisAgent, ElementXML_Handle element,
Symbol* value = xmltowme_get_value(thisAgent, child, linkMap, links);

// add wme
wme* w = soar_module::add_module_wme(thisAgent, targetId, attribute, value, false);
soar_module::add_module_wme(thisAgent, targetId, attribute, value, false);
const char* link = soarxml_GetAttribute(child, "link-id");
if (link != NULL)
{
Expand Down Expand Up @@ -1128,7 +1126,7 @@ Symbol* xmltowme_from_xml(agent* thisAgent, ElementXML_Handle element, Symbol* t
auto targetIt = linkMap.find(std::string(link.linkTo));
if (targetIt != linkMap.end())
{
wme* w = soar_module::add_module_wme(thisAgent, link.from, link.attribute, targetIt->second, false);
soar_module::add_module_wme(thisAgent, link.from, link.attribute, targetIt->second, false);
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions Core/SoarKernel/src/soar_representation/symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ bool make_string_rereadable(std::string &pStr)
{
bool possible_id, possible_var, possible_sc, possible_ic, possible_fc;
bool is_rereadable;
bool has_angle_bracket;

const char* pCStr = pStr.c_str();
short pLength = pStr.size();

soar::Lexer::determine_possible_symbol_types_for_string(pCStr, pLength,
&possible_id, &possible_var, &possible_sc, &possible_ic, &possible_fc, &is_rereadable);

// has_angle_bracket = pCStr[0] == '<' || pCStr[pLength - 1] == '>';
// bool has_angle_bracket = pCStr[0] == '<' || pCStr[pLength - 1] == '>';

if ((!possible_sc) || possible_var || possible_ic || possible_fc || possible_id || (!is_rereadable))
{
Expand Down
Loading

0 comments on commit 52f8bef

Please sign in to comment.