MCPcopy Create free account
hub / github.com/SoarGroup/Soar / add_values_of_attribute_path

Function add_values_of_attribute_path

Core/SoarKernel/src/trace.cpp:1198–1252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1196---------------------------------------------------------------- */
1197
1198void add_values_of_attribute_path(agent* thisAgent,
1199 Symbol* object,
1200 list* path,
1201 growable_string* result,
1202 bool recursive,
1203 int* count)
1204{
1205 slot* s;
1206 wme* w;
1207 char* ch;
1208 growable_string gs;
1209
1210 if (!path) /* path is NIL, so we've reached the end of the path */
1211 {
1212 add_to_growable_string(thisAgent, result, " ");
1213 if (recursive)
1214 {
1215 gs = object_to_trace_string(thisAgent, object);
1216 add_to_growable_string(thisAgent, result, text_of_growable_string(gs));
1217 free_growable_string(thisAgent, gs);
1218 }
1219 else
1220 {
1221 ch = symbol_to_string(thisAgent, object, true, NULL, 0);
1222 add_to_growable_string(thisAgent, result, ch);
1223 }
1224 (*count)++;
1225 return;
1226 }
1227
1228 /* --- not at end of path yet --- */
1229 /* --- can't follow any more path segments off of a non-identifier --- */
1230 if (object->symbol_type != IDENTIFIER_SYMBOL_TYPE)
1231 {
1232 return;
1233 }
1234
1235 /* --- call this routine recursively on any wme matching the first segment
1236 of the attribute path --- */
1237 for (w = object->id->impasse_wmes; w != NIL; w = w->next)
1238 if (w->attr == path->first)
1239 add_values_of_attribute_path(thisAgent, w->value, path->rest, result, recursive,
1240 count);
1241 for (w = object->id->input_wmes; w != NIL; w = w->next)
1242 if (w->attr == path->first)
1243 add_values_of_attribute_path(thisAgent, w->value, path->rest, result, recursive,
1244 count);
1245 s = find_slot(object, static_cast<symbol_struct*>(path->first));
1246 if (s)
1247 {
1248 for (w = s->wmes; w != NIL; w = w->next)
1249 add_values_of_attribute_path(thisAgent, w->value, path->rest, result, recursive,
1250 count);
1251 }
1252}
1253
1254/* ----------------------------------------------------------------
1255 Adds info for a wme to the given "*result" growable_string. If

Callers 1

Calls 6

add_to_growable_stringFunction · 0.85
object_to_trace_stringFunction · 0.85
text_of_growable_stringFunction · 0.85
free_growable_stringFunction · 0.85
symbol_to_stringFunction · 0.85
find_slotFunction · 0.85

Tested by

no test coverage detected