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

Function simplify_test

Core/SoarKernel/src/reorder.cpp:283–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283saved_test* simplify_test(agent* thisAgent, test* t, saved_test* old_sts)
284{
285 test New, subtest;
286 saved_test* saved;
287 Symbol* var, *sym;
288 cons* c, *prev_c, *next_c;
289 complex_test* ct;
290
291 if (test_is_blank_test(*t))
292 {
293 sym = generate_new_variable(thisAgent, "dummy-");
294 *t = make_equality_test_without_adding_reference(sym);
295 return old_sts;
296 }
297
298 if (test_is_blank_or_equality_test(*t))
299 {
300 return old_sts;
301 }
302
303 ct = complex_test_from_test(*t);
304
305 switch (ct->type)
306 {
307
308 case CONJUNCTIVE_TEST:
309 /* --- look at subtests for an equality test --- */
310 sym = NIL;
311 for (c = ct->data.conjunct_list; c != NIL; c = c->rest)
312 {
313 subtest = static_cast<char*>(c->first);
314 if (test_is_blank_or_equality_test(subtest))
315 {
316 sym = referent_of_equality_test(subtest);
317 }
318 }
319 /* --- if no equality test was found, generate a variable for it --- */
320 if (!sym)
321 {
322 sym = generate_new_variable(thisAgent, "dummy-");
323 New = make_equality_test_without_adding_reference(sym);
324 allocate_cons(thisAgent, &c);
325 c->first = New;
326 c->rest = ct->data.conjunct_list;
327 ct->data.conjunct_list = c;
328 }
329 /* --- scan through, create saved_test for subtests except equality --- */
330 prev_c = NIL;
331 c = ct->data.conjunct_list;
332 while (c)
333 {
334 next_c = c->rest;
335 subtest = static_cast<char*>(c->first);
336 if (! test_is_blank_or_equality_test(subtest))
337 {
338 /* --- create saved_test, splice this cons out of conjunct_list --- */
339 allocate_with_pool(thisAgent, &thisAgent->saved_test_pool, &saved);
340 saved->next = old_sts;

Callers 1

reorder.cppFile · 0.85

Calls 10

test_is_blank_testFunction · 0.85
generate_new_variableFunction · 0.85
complex_test_from_testFunction · 0.85
allocate_consFunction · 0.85
allocate_with_poolFunction · 0.85
symbol_add_refFunction · 0.85
free_consFunction · 0.85

Tested by

no test coverage detected