1 #include <portability.h>
50 #include "soar_TraceNames.h"
59 using namespace soar_TraceNames;
61 #ifdef USE_MEM_POOL_ALLOCATORS
62 typedef std::list< instantiation*, soar_module::soar_memory_pool_allocator< instantiation* > >
inst_mpool_list;
63 typedef std::list< condition*, soar_module::soar_memory_pool_allocator< condition* > >
cond_mpool_list;
100 if (new_pref->
in_tm) {
163 Symbol *lowest_goal_so_far;
168 lowest_goal_so_far =
NIL;
169 lowest_level_so_far = -1;
174 if (cond->
bt.
level > lowest_level_so_far) {
175 lowest_goal_so_far = id;
176 lowest_level_so_far = cond->
bt.
level;
181 if (lowest_goal_so_far)
214 cons *c, *prev_c, *arg_cons;
251 ( new_id_level > 0 ) )
253 result->
id.
level = new_id_level;
275 new_id_letter = *(sym->
var.
name + 1);
298 nil_arg_found =
FALSE;
300 for (arg_cons=fl->
rest; arg_cons!=
NIL; arg_cons=arg_cons->
rest) {
303 static_cast<char *>(arg_cons->
first),
304 new_id_level, new_id_letter, tok, w);
306 if (prev_c) prev_c->
rest = c;
else arglist = c;
309 if (prev_c) prev_c->
rest =
NIL;
else arglist =
NIL;
313 if (!nil_arg_found) {
316 #ifndef NO_TIMING_STUFF
324 result = (*(rf->
f))(thisAgent, arglist, rf->
user_data);
326 #ifndef NO_TIMING_STUFF // restart the kernel timer
334 for (c=arglist; c!=
NIL; c=c->
rest)
356 if (!
id)
goto abort_execute_action;
358 print_with_symbols (thisAgent,
"Error: RHS makes a preference for %y (not an identifier)\n",
id);
359 goto abort_execute_action;
363 if (!attr)
goto abort_execute_action;
368 first_letter, tok, w);
369 if (!value)
goto abort_execute_action;
373 first_letter, tok, w);
374 if (!referent)
goto abort_execute_action;
380 print_with_symbols (thisAgent,
"\nError: attribute preference other than +/- for %y ^%y -- ignoring it.",
id, attr);
381 goto abort_execute_action;
386 abort_execute_action:
419 Bool need_to_do_support_calculations) {
450 #ifdef DO_TOP_LEVEL_REF_CTS
460 #ifdef DO_TOP_LEVEL_REF_CTS
474 all_of_goal_next, all_of_goal_prev);
484 if (need_to_do_support_calculations)
487 if (need_to_do_support_calculations)
497 Bool difference_found;
503 difference_found =
FALSE;
506 c = saved_flags; saved_flags = c->
rest;
511 if (difference_found) {
560 #define trace_firings_of_inst(thisAgent, inst) \
562 (thisAgent->sysparams[TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM+(inst)->prod->type] || \
563 ((inst)->prod->trace_firings)))
567 return ((inst)->prod &&
569 ((inst)->prod->trace_firings)));
587 Bool need_to_do_support_calculations;
592 #ifdef BUG_139_WORKAROUND
649 print (thisAgent,
"Firing ");
661 *(cell++) = static_cast<symbol_union *>(c->
first);
670 print (thisAgent,
" -->\n");
671 xml_object( thisAgent, kTagActionSideMarker );
676 need_to_do_support_calculations =
FALSE;
712 inst_next, inst_prev);
761 print (thisAgent,
" ");
779 static_cast<soar_call_data>(inst));
827 print_with_symbols(thisAgent,
"*** Waterfall: aborting firing because (%y * *)", sym);
828 print(thisAgent,
" level %d is on or higher (lower int) than change level %d\n", sym->
id.
level, thisAgent->
change_level);
851 #ifdef USE_MEM_POOL_ALLOCATORS
859 inst_list.push_back(inst);
860 inst_mpool_list::iterator next_iter = inst_list.begin();
862 while ( next_iter != inst_list.end() )
868 #ifdef DEBUG_INSTANTIATIONS
888 #ifdef DO_TOP_LEVEL_REF_CTS
913 #ifndef DO_TOP_LEVEL_REF_CTS
929 bool has_active_clones =
false;
934 has_active_clones =
true;
937 if ( has_active_clones )
945 has_active_clones =
true;
948 if ( has_active_clones )
977 cond->
bt.
trace, all_of_goal_next, all_of_goal_prev );
984 next_iter = inst_list.insert( next_iter, cond->
bt.
trace->
inst );
987 cond_stack.push_back( cond );
997 while( !cond_stack.empty() )
1000 cond_stack.pop_back();
1021 inst_mpool_list::reverse_iterator riter = inst_list.rbegin();
1022 while( riter != inst_list.rend() )
1045 Bool retracted_a_preference;
1051 static_cast<soar_call_data>(inst));
1053 retracted_a_preference =
FALSE;
1065 if (!retracted_a_preference) {
1067 print (thisAgent,
"Retracting ");
1071 print (thisAgent,
" -->\n");
1072 xml_object( thisAgent, kTagActionSideMarker );
1076 print (thisAgent,
" ");
1082 retracted_a_preference =
TRUE;
1151 printf(
"\n in assert_new_preferences:");
1156 #ifdef O_REJECTS_FIRST
1166 next_inst = inst->
next;
1172 pref->
next = o_rejects;
1204 next_inst = inst->
next;
1223 #ifndef O_REJECTS_FIRST
1225 pref->
next = o_rejects;
1281 #ifndef O_REJECTS_FIRST
1307 xml_att_val( thisAgent, kPhase_Name, kSubphaseName_FiringProductions );
1310 print (thisAgent,
"\t--- Firing Productions (PE) For State At Depth %d ---\n", thisAgent->
active_level);
1311 xml_att_val( thisAgent, kPhase_FiringType, kPhaseFiringType_PE );
1314 print (thisAgent,
"\t--- Firing Productions (IE) For State At Depth %d ---\n", thisAgent->
active_level);
1315 xml_att_val( thisAgent, kPhase_FiringType, kPhaseFiringType_IE );
1318 std::string levelString;
1320 xml_att_val( thisAgent, kPhase_LevelNum, levelString.c_str());
1340 #ifdef USE_MEM_POOL_ALLOCATORS
1351 print (thisAgent,
"\n--- Inner Elaboration Phase, active level %d", thisAgent->
active_level);
1355 print (thisAgent,
" ---\n");
1366 assertionsExist =
TRUE;
1393 if (assertionsExist) {
1409 print(thisAgent,
" inner elaboration loop doesn't have active goal.\n");
1416 print(thisAgent,
" inner elaboration loop at bottom goal.\n");
1433 print(thisAgent,
" inner elaboration loop finished but not at quiescence.\n");
1440 for ( pref_buffer_list::iterator iter=bufdeallo.begin(); iter!=bufdeallo.end(); ++iter )