1 #include <portability.h>
36 #include "soar_TraceNames.h"
40 using namespace soar_TraceNames;
80 for (ch=s; *ch!=0; ch++) {
100 #define PRINT_BUFSIZE 5000
106 va_start (args, format);
107 vsprintf (buf, format, args);
118 while ((*format !=
'%') && (*format != 0)) *(ch++) = *(format++);
119 if (*format == 0)
break;
121 if (*(format+1)==
'y') {
140 va_start (args, format);
148 va_start (args, format);
158 while (n) { *(ch++)=
' '; n--; }
192 char first_and_last_char,
char *dest) {
197 *ch++ = first_and_last_char;
199 if ((*s==first_and_last_char)||(*s==
'\\')) *ch++ =
'\\';
202 *ch++ = first_and_last_char;
210 switch(sym->common.symbol_type) {
212 return kTypeVariable ;
227 Bool rereadable,
char *dest,
size_t dest_size) {
228 Bool possible_id, possible_var, possible_sc, possible_ic, possible_fc;
230 Bool has_angle_bracket;
232 switch(sym->common.symbol_type) {
234 if (!dest)
return sym->
var.
name;
235 strncpy (dest, sym->
var.
name, dest_size);
236 dest[dest_size - 1] = 0;
252 dest[dest_size - 1] = 0;
260 SNPRINTF (dest, dest_size,
"%ld", static_cast<long int>(sym->
ic.
value));
261 dest[dest_size - 1] = 0;
269 SNPRINTF (dest, dest_size,
"%#.16g", sym->
fc.
value);
270 dest[dest_size - 1] = 0;
272 char *start_of_exponent;
273 char *end_of_mantissa;
274 start_of_exponent = dest;
275 while ((*start_of_exponent != 0) && (*start_of_exponent !=
'e'))
277 end_of_mantissa = start_of_exponent - 1;
278 while (*end_of_mantissa ==
'0') end_of_mantissa--;
280 while (*start_of_exponent) *end_of_mantissa++ = *start_of_exponent++;
281 *end_of_mantissa = 0;
287 if (!dest)
return sym->
sc.
name;
288 strncpy (dest, sym->
sc.
name, dest_size);
300 has_angle_bracket = sym->
sc.
name[0] ==
'<' ||
303 if ((!possible_sc) || possible_var || possible_ic || possible_fc ||
310 if (!dest)
return sym->
sc.
name;
311 strncpy (dest, sym->
sc.
name, dest_size);
317 strncpy(msg,
"Internal Soar Error: symbol_to_string called on bad symbol\n",
BUFFER_MSG_SIZE);
335 strncpy (dest,
"[BLANK TEST]", dest_size);
336 dest[dest_size - 1] = 0;
353 strncpy (ch,
"<> ", dest_size - (ch - dest));
354 ch[dest_size - (ch - dest) - 1] = 0;
360 strncpy (ch,
"< ", dest_size - (ch - dest));
361 ch[dest_size - (ch - dest) - 1] = 0;
366 strncpy (ch,
"> ", dest_size - (ch - dest));
367 ch[dest_size - (ch - dest) - 1] = 0;
372 strncpy (ch,
"<= ", dest_size - (ch - dest));
373 ch[dest_size - (ch - dest) - 1] = 0;
378 strncpy (ch,
">= ", dest_size - (ch - dest));
379 ch[dest_size - (ch - dest) - 1] = 0;
384 strncpy (ch,
"<=> ", dest_size - (ch - dest));
385 ch[dest_size - (ch - dest) - 1] = 0;
390 strncpy (ch,
"<< ", dest_size - (ch - dest));
391 ch[dest_size - (ch - dest) - 1] = 0;
398 strncpy (ch,
">>", dest_size - (ch - dest));
399 ch[dest_size - (ch - dest) - 1] = 0;
402 strncpy (ch,
"{ ", dest_size - (ch - dest));
403 ch[dest_size - (ch - dest) - 1] = 0;
410 strncpy (ch,
"}", dest_size - (ch - dest));
411 ch[dest_size - (ch - dest) - 1] = 0;
414 strncpy (dest,
"[GOAL ID TEST]", dest_size - (ch - dest));
415 ch[dest_size - (ch - dest) - 1] = 0;
418 strncpy (dest,
"[IMPASSE ID TEST]", dest_size - (ch - dest));
419 ch[dest_size - (ch - dest) - 1] = 0;
433 strncpy (msg,
"Internal error: rhs_value_to_string called on reteloc.\n",
BUFFER_MSG_SIZE);
451 strncpy (ch,
"(", dest_size);
452 ch[dest_size - 1] = 0;
456 strncpy (ch,
"+", dest_size - (ch - dest));
457 ch[dest_size - (ch - dest) - 1] = 0;
459 strncpy (ch,
"-", dest_size - (ch - dest));
460 ch[dest_size - (ch - dest) - 1] = 0;
467 strncpy (ch,
" ", dest_size - (ch - dest));
468 ch[dest_size - (ch - dest) - 1] = 0;
475 strncpy (ch,
")", dest_size - (ch - dest));
476 ch[dest_size - (ch - dest) - 1] = 0;
504 #define PRINT_CONDITION_LIST_TEMP_SIZE 10000
506 int indent,
Bool internal) {
507 dl_list *conds_not_yet_printed, *tail_of_conds_not_yet_printed;
511 Bool removed_goal_test, removed_impasse_test;
517 conds_not_yet_printed =
NIL;
518 tail_of_conds_not_yet_printed =
NIL;
520 for (c=conds; c!=
NIL; c=c->
next)
522 allocate_with_pool (thisAgent, &thisAgent->
dl_cons_pool, &dc);
524 if (conds_not_yet_printed)
526 tail_of_conds_not_yet_printed->
next = dc;
530 conds_not_yet_printed = dc;
532 dc->
prev = tail_of_conds_not_yet_printed;
533 tail_of_conds_not_yet_printed = dc;
535 tail_of_conds_not_yet_printed->
next =
NIL;
539 while (conds_not_yet_printed)
541 if (did_one_line_already)
543 print (thisAgent,
"\n");
548 did_one_line_already =
TRUE;
551 dc = conds_not_yet_printed;
558 xml_begin_tag(thisAgent, kTagConjunctive_Negation_Condition);
560 xml_end_tag(thisAgent, kTagConjunctive_Negation_Condition);
566 removed_goal_test = removed_impasse_test =
FALSE;
569 &removed_impasse_test);
573 conds_for_this_id = dc;
589 if (removed_goal_test)
592 xml_att_val(thisAgent, kConditionTest, kConditionTestState);
596 if (removed_impasse_test)
599 xml_att_val(thisAgent, kConditionTest, kConditionTestImpasse);
608 while (conds_for_this_id)
610 dc = conds_for_this_id;
611 conds_for_this_id = conds_for_this_id->
next;
679 #define PRINT_ACTION_LIST_TEMP_SIZE 10000
681 int indent,
Bool internal) {
682 Bool did_one_line_already;
683 dl_list *actions_not_yet_printed, *tail_of_actions_not_yet_printed;
688 if (!actions)
return;
690 did_one_line_already =
FALSE;
693 actions_not_yet_printed =
NIL;
694 tail_of_actions_not_yet_printed =
NIL;
695 for (a=actions; a!=
NIL; a=a->
next) {
696 allocate_with_pool (thisAgent, &thisAgent->
dl_cons_pool, &dc);
698 if (actions_not_yet_printed) tail_of_actions_not_yet_printed->
next = dc;
699 else actions_not_yet_printed = dc;
700 dc->
prev = tail_of_actions_not_yet_printed;
701 tail_of_actions_not_yet_printed = dc;
703 tail_of_actions_not_yet_printed->
next =
NIL;
706 while (actions_not_yet_printed) {
707 if (did_one_line_already) {
708 print (thisAgent,
"\n");
711 did_one_line_already =
TRUE;
713 dc = actions_not_yet_printed;
727 actions_for_this_id = dc;
742 while (actions_for_this_id) {
743 dc = actions_for_this_id;
744 actions_for_this_id = actions_for_this_id->
next;
808 print (thisAgent,
" %s\n", temp);
809 xml_att_val(thisAgent, kProductionDocumentation, temp);
819 xml_att_val(thisAgent, kProductionType, kProductionTypeDefault);
825 xml_att_val(thisAgent, kProductionType, kProductionTypeChunk);
828 print_string (thisAgent,
" :justification ;# not reloadable\n");
829 xml_att_val(thisAgent, kProductionType, kProductionTypeJustification);
833 xml_att_val(thisAgent, kProductionType, kProductionTypeTemplate);
840 xml_att_val(thisAgent, kProductionDeclaredSupport, kProductionDeclaredOSupport);
846 xml_att_val(thisAgent, kProductionDeclaredSupport, kProductionDeclaredISupport);
856 &top, &bottom,
NIL,&rhs);
897 old_next = cond->
next;
898 old_prev = cond->
prev;
902 cond->
next = old_next;
903 cond->
prev = old_prev;
934 "print.c: Error: bad type passed to preference_type_indicator\n",
BUFFER_MSG_SIZE);
946 print (thisAgent,
"%c", pref_type);
952 print (thisAgent,
"\n");
983 print (thisAgent,
"=>WM: ");
994 print (thisAgent,
"<=WM: ");
1015 print (thisAgent,
"\n");
1025 print (thisAgent,
"\n");
1049 if (action == PRINTING) {
1051 }
else if (action == FIRING) {
1054 }
else if (action == RETRACTING) {
1063 print (thisAgent,
"[dummy production]");
1064 xml_att_val(thisAgent, kProduction_Name,
"[dummy_production]");
1068 print (thisAgent,
"\n");
1071 if (action == PRINTING) {
1073 }
else if (action == FIRING) {
1076 }
else if (action == RETRACTING) {
1078 xml_end_tag(thisAgent, kTagProduction_Retracting);
1096 #ifdef DO_TOP_LEVEL_REF_CTS
1097 print (thisAgent,
" ");
1101 print (thisAgent,
" ");
1116 if (action == PRINTING) {
1118 }
else if (action == FIRING) {
1121 }
else if (action == RETRACTING) {
1123 xml_end_tag(thisAgent, kTagProduction_Retracting);
1133 while (cond != NULL) {
1135 print (thisAgent,
"\n ");
1137 print (thisAgent,
"\n");
1147 print (thisAgent, s);
1154 xml_att_val(thisAgent, kPhase_Status, kPhaseStatus_End);
1159 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Input);
1162 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Pref);
1165 xml_att_val(thisAgent, kPhase_Name, kPhaseName_WM);
1168 xml_att_val(thisAgent, kPhase_FiringType, kPhaseFiringType_PE);
1171 xml_att_val(thisAgent, kPhase_FiringType, kPhaseFiringType_IE);
1176 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Decision);
1179 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Output);
1182 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Propose);
1185 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Apply);
1188 xml_att_val(thisAgent, kPhase_Name, kPhaseName_Unknown);
1203 (!strcmp(filterComponent->
sc.
name,
"*")))
1206 return(filterComponent == wmeComponent);
1224 if ( ((isAdd && wf->
adds) || ((!isAdd) && wf->
removes)) &&