Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Enumerations | Functions
osupport.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include "osupport.h"
#include "symtab.h"
#include "wmem.h"
#include "gdatastructs.h"
#include "agent.h"
#include "kernel.h"
#include "production.h"
#include "instantiations.h"
#include "rhsfun.h"
#include "print.h"
#include "reorder.h"
#include "rete.h"
#include "xml.h"

Go to the source code of this file.

Enumerations

enum  yes_no_maybe

Functions

void add_tc_through_lhs_and_rhs (agent *thisAgent, condition *lhs, action *rhs, tc_number tc, list **id_list, list **var_list)
void add_to_os_tc (agent *thisAgent, Symbol *id, Bool isa_state)
void add_to_os_tc_if_id (agent *thisAgent, Symbol *sym, Bool flag)
void add_to_os_tc_if_needed (agent *thisAgent, Symbol *sym)
void begin_os_tc (agent *thisAgent, preference *rhs_prefs_or_nil)
void calculate_compile_time_o_support (agent *thisAgent, condition *lhs, action *rhs)
void calculate_support_for_instantiation_preferences (agent *thisAgent, instantiation *inst)
Bool condition_list_has_id_test_for_sym (condition *conds, Symbol *sym)
void dougs_calculate_support_for_instantiation_preferences (agent *thisAgent, instantiation *inst)
Symbolfind_compile_time_match_goal (agent *thisAgent, condition *lhs, list *known_goals)
listfind_known_goals (agent *thisAgent, condition *lhs)
Symbolfind_thing_off_goal (agent *thisAgent, condition *lhs, Symbol *goal, Symbol *attr)
Bool id_or_value_of_condition_list_is_in_os_tc (agent *thisAgent, condition *conds, Symbol *sym_excluded_from_value, Symbol *match_state_to_exclude_test_of_the_operator_off_of)
Bool is_state_id (agent *thisAgent, Symbol *sym, Symbol *match_state)
Bool match_state_tests_non_operator_slot (agent *thisAgent, condition *conds, Symbol *match_state)
Bool test_has_id_in_os_tc (agent *thisAgent, test t, Symbol *excluded_sym)
yes_no_maybe test_is_for_symbol (test t, Symbol *sym)

Enumeration Type Documentation

Enumerator:
YES 
NO 
MAYBE 

Definition at line 574 of file osupport.cpp.

{ YES, NO, MAYBE } ;

Function Documentation

void add_tc_through_lhs_and_rhs ( agent thisAgent,
condition lhs,
action rhs,
tc_number  tc,
list **  id_list,
list **  var_list 
)

Definition at line 815 of file osupport.cpp.

References action_is_in_tc(), add_action_to_tc(), add_cond_to_tc(), action_struct::already_in_tc, condition_struct::already_in_tc, cond_is_in_tc(), FALSE, action_struct::next, condition_struct::next, NIL, and TRUE.

Referenced by calculate_compile_time_o_support().

{
action *a;
Bool anything_changed;
for (c=lhs; c!=NIL; c=c->next) c->already_in_tc = FALSE;
for (a=rhs; a!=NIL; a=a->next) a->already_in_tc = FALSE;
/* --- keep trying to add new stuff to the tc --- */
while (TRUE) {
anything_changed = FALSE;
for (c=lhs; c!=NIL; c=c->next)
if (! c->already_in_tc)
if (cond_is_in_tc (thisAgent, c, tc)) {
add_cond_to_tc (thisAgent, c, tc, id_list, var_list);
anything_changed = TRUE;
}
for (a=rhs; a!=NIL; a=a->next)
if (! a->already_in_tc)
if (action_is_in_tc (a, tc)) {
add_action_to_tc (thisAgent, a, tc, id_list, var_list);
anything_changed = TRUE;
}
if (! anything_changed) break;
}
}
void add_to_os_tc ( agent thisAgent,
Symbol id,
Bool  isa_state 
)

Definition at line 84 of file osupport.cpp.

References add_to_os_tc_if_needed(), preference_struct::all_of_slot_next, slot_struct::all_preferences, preference_struct::attr, slot_struct::attr, wme_struct::id, preference_struct::id, symbol_union::id, identifier_struct::input_wmes, preference_struct::inst_next, wme_struct::next, slot_struct::next, NIL, agent_struct::o_support_tc, agent_struct::operator_symbol, preference_is_binary(), preference_struct::referent, agent_struct::rhs_prefs_from_instantiation, identifier_struct::slots, identifier_struct::tc_num, preference_struct::type, wme_struct::value, preference_struct::value, and slot_struct::wmes.

Referenced by add_to_os_tc_if_needed().

{
slot *s;
preference *pref;
wme *w;
/* --- if id is already in the TC, exit; else mark it as in the TC --- */
if (id->id.tc_num==thisAgent->o_support_tc) return;
id->id.tc_num = thisAgent->o_support_tc;
/* --- scan through all preferences and wmes for all slots for this id --- */
for (w=id->id.input_wmes; w!=NIL; w=w->next)
add_to_os_tc_if_needed (thisAgent, w->value);
for (s=id->id.slots; s!=NIL; s=s->next) {
if ((!isa_state) || (s->attr != thisAgent->operator_symbol)) {
for (pref=s->all_preferences; pref!=NIL; pref=pref->all_of_slot_next) {
add_to_os_tc_if_needed (thisAgent, pref->value);
add_to_os_tc_if_needed (thisAgent, pref->referent);
}
for (w=s->wmes; w!=NIL; w=w->next)
add_to_os_tc_if_needed (thisAgent, w->value);
}
} /* end of for slots loop */
/* --- now scan through RHS prefs and look for any with this id --- */
for (pref=thisAgent->rhs_prefs_from_instantiation; pref!=NIL; pref=pref->inst_next) {
if (pref->id==id) {
if ((!isa_state) || (pref->attr != thisAgent->operator_symbol)) {
add_to_os_tc_if_needed (thisAgent, pref->value);
add_to_os_tc_if_needed (thisAgent, pref->referent);
}
}
}
/* We don't need to worry about goal/impasse wmes here, since o-support tc's
never start there and there's never a pointer to a goal or impasse from
something else. */
}
void add_to_os_tc_if_id ( agent thisAgent,
Symbol sym,
Bool  flag 
)
inline

Definition at line 72 of file osupport.cpp.

References common, and IDENTIFIER_SYMBOL_TYPE.

{
if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \
add_to_os_tc (thisAgent, sym,flag);
}
void add_to_os_tc_if_needed ( agent thisAgent,
Symbol sym 
)
inline

Definition at line 63 of file osupport.cpp.

References add_to_os_tc(), common, FALSE, and IDENTIFIER_SYMBOL_TYPE.

Referenced by add_to_os_tc().

{
if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)
add_to_os_tc (thisAgent, sym,FALSE);
}
void begin_os_tc ( agent thisAgent,
preference rhs_prefs_or_nil 
)

Definition at line 122 of file osupport.cpp.

References get_new_tc_number(), agent_struct::o_support_tc, and agent_struct::rhs_prefs_from_instantiation.

{
thisAgent->o_support_tc = get_new_tc_number(thisAgent);
thisAgent->rhs_prefs_from_instantiation = rhs_prefs_or_nil;
}
void calculate_compile_time_o_support ( agent thisAgent,
condition lhs,
action rhs 
)

Definition at line 854 of file osupport.cpp.

References ACCEPTABLE_PREFERENCE_TYPE, action_is_in_tc(), add_bound_variables_in_test(), add_symbol_to_tc(), add_tc_through_lhs_and_rhs(), action_struct::attr, three_field_tests_struct::attr_test, condition_list_has_id_test_for_sym(), condition_struct::data, FALSE, find_compile_time_match_goal(), find_known_goals(), find_thing_off_goal(), cons_struct::first, free_list(), get_new_tc_number(), I_SUPPORT, action_struct::id, three_field_tests_struct::id_test, MAKE_ACTION, match_state_tests_non_operator_slot(), MAYBE, action_struct::next, condition_struct::next, NIL, NO, O_SUPPORT, agent_struct::operator_symbol, POSITIVE_CONDITION, action_struct::preference_type, REQUIRE_PREFERENCE_TYPE, cons_struct::rest, rhs_value_is_symbol(), rhs_value_to_symbol(), agent_struct::soar_verbose_flag, action_struct::support, test_is_for_symbol(), condition_struct::condition_main_data_union::tests, TRUE, action_struct::type, condition_struct::type, UNKNOWN_SUPPORT, action_struct::value, three_field_tests_struct::value_test, VARIABLE_SYMBOL_TYPE, xml_generate_verbose(), and YES.

Referenced by make_production().

{
list *known_goals;
cons *c;
Symbol *match_state, *match_operator;
yes_no_maybe lhs_oa_support, lhs_oc_support, lhs_om_support;
action *a;
condition *cond;
Bool operator_found, possible_operator_found;
/* --- initialize: mark all rhs actions as "unknown" --- */
for (a=rhs; a!=NIL; a=a->next)
/* --- if "operator" doesn't appear in any LHS attribute slot, and there
are no RHS +/! makes for "operator", then nothing gets support --- */
operator_found = FALSE;
possible_operator_found = FALSE;
for (cond=lhs; cond!=NIL; cond=cond->next) {
if (cond->type != POSITIVE_CONDITION) continue;
if (ynm==YES) { operator_found = possible_operator_found = TRUE; break; }
if (ynm==MAYBE) possible_operator_found = TRUE;
}
if (! operator_found) {
for (a=rhs; a!=NIL; a=a->next) {
if (a->type != MAKE_ACTION) continue;
if (rhs_value_is_symbol(a->attr)) { /* RBD 3/29/95 general RHS attr's */
Symbol *attr;
if (attr==thisAgent->operator_symbol)
{ operator_found = possible_operator_found = TRUE; break; }
if (attr->common.symbol_type==VARIABLE_SYMBOL_TYPE)
possible_operator_found = TRUE;
} else {
possible_operator_found = TRUE; /* for funcall, must play it safe */
}
}
}
if (! possible_operator_found) {
for (a=rhs; a!=NIL; a=a->next) {
}
return;
}
/* --- find known goals; RHS augmentations of goals get no support --- */
known_goals = find_known_goals (thisAgent, lhs);
/* SBH: In NNPSCM, the only RHS-goal augmentations that can't get support are
preferences for the "operator" slot. */
for (c=known_goals; c!=NIL; c=c->rest) {
for (a=rhs; a!=NIL; a=a->next) {
if (a->type != MAKE_ACTION) continue;
if (rhs_value_is_symbol(a->attr) && /* RBD 3/29/95 */
}
}
/* --- find match goal, state, and operator --- */
match_state = find_compile_time_match_goal (thisAgent, lhs, known_goals);
free_list (thisAgent, known_goals);
if (!match_state) return;
match_operator = find_thing_off_goal (thisAgent, lhs, match_state, thisAgent->operator_symbol);
/* --- If when checking (above) for "operator" appearing anywhere, we
found a possible operator but not a definite operator, now go back and
see if the possible operator was actually the match goal or match state;
if so, it's not a possible operator. (Note: by "possible operator" I
mean something appearing in the *attribute* field that might get bound
to the symbol "operator".) --- */
if (possible_operator_found && !operator_found) {
possible_operator_found = FALSE;
for (cond=lhs; cond!=NIL; cond=cond->next) {
if (cond->type != POSITIVE_CONDITION) continue;
if ((ynm!=NO) &&
(test_is_for_symbol (cond->data.tests.attr_test, match_state)!=YES))
{ possible_operator_found = TRUE; break; }
}
if (! possible_operator_found) {
for (a=rhs; a!=NIL; a=a->next) {
if (a->type != MAKE_ACTION) continue;
/* we're looking for "operator" augs of goals only, and match_state
couldn't get bound to a goal */
if (rhs_value_to_symbol(a->id) == match_state) continue;
if (rhs_value_is_symbol(a->attr)) { /* RBD 3/29/95 */
Symbol *attr;
if ((attr->common.symbol_type==VARIABLE_SYMBOL_TYPE) &&
(attr != match_state))
{ possible_operator_found = TRUE; break; }
} else { /* RBD 3/29/95 */
possible_operator_found = TRUE; break;
}
}
}
if (! possible_operator_found) {
for (a=rhs; a!=NIL; a=a->next)
return;
}
}
/* --- calculate LHS support predicates --- */
lhs_oa_support = MAYBE;
if (match_operator) {
/* SBH 7/1/94 #2 */
if ((condition_list_has_id_test_for_sym (lhs, match_operator)) &&
(match_state_tests_non_operator_slot(thisAgent, lhs,match_state))) {
/* end SBH 7/1/94 #2 */
lhs_oa_support = YES;
}
}
lhs_oc_support = MAYBE;
lhs_om_support = MAYBE;
/* SBH 7/1/94 #2 */
/* For NNPSCM, must test that there is a test of a non-operator slot off
of the match_state. */
if (match_state_tests_non_operator_slot(thisAgent, lhs,match_state))
{
/* end SBH 7/1/94 #2 */
lhs_oc_support = YES;
for (cond=lhs; cond!=NIL; cond=cond->next) {
if (cond->type != POSITIVE_CONDITION) continue;
if (test_is_for_symbol (cond->data.tests.id_test, match_state) != YES) continue;
!= YES)
continue;
lhs_om_support = YES;
break;
}
}
if (lhs_oa_support == YES) { /* --- look for RHS o-a support --- */
/* --- do TC(match_state) --- */
tc = get_new_tc_number(thisAgent);
add_symbol_to_tc (thisAgent, match_state, tc, NIL, NIL);
add_tc_through_lhs_and_rhs (thisAgent, lhs, rhs, tc, NIL, NIL);
/* --- any action with id in the TC gets support --- */
for (a=rhs; a!=NIL; a=a->next) {
if (action_is_in_tc (a, tc)) {
/* SBH 7/1/94 Avoid resetting of support that was previously set to I_SUPPORT. */
/* gap 10/6/94 If the action has an attribue of operator, then you
don't know if it should get o-support until run time because of
the vagaries of knowing when this is matching a context object
or not. */
} else {
}
}
/* end SBH 7/1/94 */
}
}
if (lhs_oc_support == YES) { /* --- look for RHS o-c support --- */
/* --- do TC(rhs operators) --- */
tc = get_new_tc_number(thisAgent);
for (a=rhs; a!=NIL; a=a->next) {
if (a->type != MAKE_ACTION) continue;
if (
(rhs_value_to_symbol(a->id)==match_state) &&
}
}
}
add_tc_through_lhs_and_rhs (thisAgent, lhs, rhs, tc, NIL, NIL);
/* --- any action with id in the TC gets support --- */
for (a=rhs; a!=NIL; a=a->next) {
if (action_is_in_tc (a, tc)) {
/* SBH 6/7/94:
Make sure the action is not already marked as "I_SUPPORT". This
avoids giving o-support in the case where the operator
points back to the goal, thus adding the goal to the TC,
thus adding the operator proposal itself to the TC; thus
giving o-support to an operator proposal.
*/
/* End SBH 6/7/94 */
/* REW: begin 09.15.96 */
/* in operand, operator proposals are now only i-supported.*/
if (thisAgent->soar_verbose_flag == TRUE) {
printf("\n operator creation: setting a->support to I_SUPPORT");
xml_generate_verbose(thisAgent, "operator creation: setting a->support to I_SUPPORT");
}
/* REW: end 09.15.96 */
}
}
}
if (lhs_om_support == YES) { /* --- look for RHS o-m support --- */
/* --- do TC(lhs operators) --- */
tc = get_new_tc_number(thisAgent);
for (cond=lhs; cond!=NIL; cond=cond->next) {
if (cond->type != POSITIVE_CONDITION) continue;
if (test_is_for_symbol (cond->data.tests.id_test, match_state) == YES) {
if (test_is_for_symbol (cond->data.tests.attr_test, thisAgent->operator_symbol) == YES) {
}
}
}
add_tc_through_lhs_and_rhs (thisAgent, lhs, rhs, tc, NIL, NIL);
/* --- any action with id in the TC gets support --- */
for (a=rhs; a!=NIL; a=a->next) {
if (action_is_in_tc (a, tc)) {
/* SBH 7/1/94 Avoid resetting of support that was previously set to I_SUPPORT. */
/* end SBH 7/1/94 */
}
}
}
}
void calculate_support_for_instantiation_preferences ( agent thisAgent,
instantiation inst 
)

Definition at line 267 of file osupport.cpp.

References wme_struct::acceptable, ACCEPTABLE_PREFERENCE_TYPE, production_struct::action_list, add_to_growable_string(), wme_struct::attr, action_struct::attr, condition_struct::bt, DECLARED_I_SUPPORT, DECLARED_O_SUPPORT, production_struct::declared_support, FALSE, free_growable_string(), get_symbol_from_rete_loc(), wme_struct::id, action_struct::id, symbol_union::id, preference_struct::inst_next, identifier_struct::isa_goal, identifier_struct::level, MAKE_ACTION, make_blank_growable_string(), production_struct::name, action_struct::next, condition_struct::next, NIL, agent_struct::o_support_calculation_type, preference_struct::o_supported, agent_struct::operator_symbol, POSITIVE_CONDITION, action_struct::preference_type, instantiation_struct::preferences_generated, print_with_symbols(), instantiation_struct::prod, instantiation_struct::rete_token, rhs_value_is_reteloc(), rhs_value_is_symbol(), rhs_value_to_reteloc_field_num(), rhs_value_to_reteloc_levels_up(), rhs_value_to_string(), rhs_value_to_symbol(), agent_struct::soar_verbose_flag, symbol_to_string(), text_of_growable_string(), instantiation_struct::top_of_instantiated_conditions, TRUE, action_struct::type, condition_struct::type, UNDECLARED_SUPPORT, wme_struct::value, bt_info_struct::wme_, xml_generate_verbose(), and xml_generate_warning().

Referenced by fill_in_new_instantiation_stuff().

{
preference *pref;
wme *w;
/* RCHONG: begin 10.11 */
action *act;
Bool o_support,op_elab;
Bool operator_proposal;
char action_attr[50];
int pass;
wme *lowest_goal_wme;
/* RCHONG: end 10.11 */
/* REW: begin 09.15.96 */
if (thisAgent->soar_verbose_flag == TRUE) {
printf("\n in calculate_support_for_instantiation_preferences:");
xml_generate_verbose(thisAgent, "in calculate_support_for_instantiation_preferences:");
}
o_support = FALSE;
op_elab = FALSE;
o_support = TRUE;
o_support = FALSE;
/*
check if the instantiation is proposing an operator. if it
is, then this instantiation is i-supported.
*/
operator_proposal = FALSE;
for (act = inst->prod->action_list; act != NIL ; act = act->next) {
if ((act->type == MAKE_ACTION) &&
if ((strcmp(rhs_value_to_string (thisAgent, act->attr, action_attr, 50),
"operator") == NIL) &&
/* REW: 09.30.96. Bug fix (next line was
operator_proposal == TRUE;) */
operator_proposal = TRUE;
o_support = FALSE;
break;
}
}
}
if (operator_proposal == FALSE) {
/*
an operator wasn't being proposed, so now we need to test if
the operator is being tested on the LHS.
i'll need to make two passes over the wmes that pertain to
this instantiation. the first pass looks for the lowest goal
identifier. the second pass looks for a wme of the form:
(<lowest-goal-id> ^operator ...)
if such a wme is found, then this o-support = TRUE; FALSE otherwise.
this code is essentially identical to that in
p_node_left_addition() in rete.c.
BUGBUG this check only looks at positive conditions. we
haven't really decided what testing the absence of the
operator will do. this code assumes that such a productions
(instantiation) would get i-support.
*/
lowest_goal_wme = NIL;
for (pass = 0; pass != 2; pass++) {
for (c=inst->top_of_instantiated_conditions; c!=NIL; c=c->next) {
w = c->bt.wme_;
if (pass == 0) {
if (w->id->id.isa_goal == TRUE) {
if (lowest_goal_wme == NIL)
lowest_goal_wme = w;
else {
if (w->id->id.level > lowest_goal_wme->id->id.level)
lowest_goal_wme = w;
}
}
}
else {
if ((w->attr == thisAgent->operator_symbol) &&
(w->acceptable == FALSE) &&
(w->id == lowest_goal_wme->id)) {
if (thisAgent->o_support_calculation_type == 3 || thisAgent->o_support_calculation_type == 4) {
/* iff RHS has only operator elaborations
then it's IE_PROD, otherwise PE_PROD, so
look for non-op-elabs in the actions KJC 1/00 */
for (act = inst->prod->action_list;
act != NIL ; act = act->next) {
if (act->type == MAKE_ACTION) {
if ((rhs_value_is_symbol(act->id)) &&
(rhs_value_to_symbol(act->id) == w->value)) {
op_elab = TRUE;
} else if ( thisAgent->o_support_calculation_type == 4
op_elab = TRUE;
} else {
/* this is not an operator elaboration */
o_support = TRUE;
}
}
}
} else {
o_support = TRUE;
break;
}
}
}
}
}
}
}
}
/* KJC 01/00: Warn if operator elabs mixed w/ applications */
if ( (thisAgent->o_support_calculation_type == 3
|| thisAgent->o_support_calculation_type == 4 )
&& (o_support == TRUE)) {
if (op_elab == TRUE ) {
/* warn user about mixed actions */
if ( thisAgent->o_support_calculation_type == 3 ) {
print_with_symbols(thisAgent, "\nWARNING: operator elaborations mixed with operator applications\nget o_support in prod %y", inst->prod->name);
add_to_growable_string(thisAgent, &gs, "WARNING: operator elaborations mixed with operator applications\nget o_support in prod ");
add_to_growable_string(thisAgent, &gs, symbol_to_string(thisAgent, inst->prod->name, true, 0, 0));
free_growable_string(thisAgent, gs);
o_support = TRUE;
} else if ( thisAgent->o_support_calculation_type == 4 ) {
print_with_symbols(thisAgent, "\nWARNING: operator elaborations mixed with operator applications\nget i_support in prod %y", inst->prod->name);
add_to_growable_string(thisAgent, &gs, "WARNING: operator elaborations mixed with operator applications\nget i_support in prod ");
add_to_growable_string(thisAgent, &gs, symbol_to_string(thisAgent, inst->prod->name, true, 0, 0));
free_growable_string(thisAgent, gs);
o_support = FALSE;
}
}
}
/*
assign every preference the correct support
*/
for (pref=inst->preferences_generated; pref!=NIL; pref=pref->inst_next)
pref->o_supported = o_support;
}
Bool condition_list_has_id_test_for_sym ( condition conds,
Symbol sym 
)
void dougs_calculate_support_for_instantiation_preferences ( agent thisAgent,
instantiation inst 
)

Definition at line 490 of file osupport.cpp.

References ACCEPTABLE_PREFERENCE_TYPE, wme_struct::attr, preference_struct::attr, condition_struct::bt, FALSE, get_new_tc_number(), wme_struct::id, preference_struct::id, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, preference_struct::inst_next, instantiation_struct::match_goal, condition_struct::next, NIL, agent_struct::o_support_tc, preference_struct::o_supported, agent_struct::operator_symbol, POSITIVE_CONDITION, preference_is_binary(), instantiation_struct::preferences_generated, preference_struct::referent, REQUIRE_PREFERENCE_TYPE, identifier_struct::tc_num, instantiation_struct::top_of_instantiated_conditions, TRUE, preference_struct::type, condition_struct::type, preference_struct::value, and bt_info_struct::wme_.

Referenced by fill_in_new_instantiation_stuff().

{
Symbol *match_state;
Bool rule_2_or_3, anything_added;
preference *rhs, *pref;
wme *w;
condition *lhs, *c;
rhs = inst->preferences_generated;
match_state = inst->match_goal;
/* --- First, check whether rule 2 or 3 applies. --- */
rule_2_or_3 = FALSE;
for (c=lhs; c!=NIL; c=c->next) {
if (c->type!=POSITIVE_CONDITION) continue;
w = c->bt.wme_;
if ((w->id==match_state)&&(w->attr==thisAgent->operator_symbol)) {
rule_2_or_3 = TRUE;
break;
}
}
/* --- Initialize all pref's according to rules 2 and 3 --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next)
pref->o_supported = rule_2_or_3;
/* --- If they didn't apply, check rule 4 --- */
if (! rule_2_or_3) {
thisAgent->o_support_tc = get_new_tc_number(thisAgent);
/* BUGBUG With Doug's scheme, o_support_tc no longer needs to be a
global variable -- it could simply be local to this procedure */
anything_added = FALSE;
/* --- look for RHS operators, add 'em (starting points) to the TC --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next) {
if ((pref->id==match_state) &&
(pref->attr==thisAgent->operator_symbol) &&
(pref->value->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)) {
pref->value->id.tc_num = thisAgent->o_support_tc;
anything_added = TRUE;
}
}
/* --- Keep adding stuff to the TC until nothing changes anymore --- */
while (anything_added) {
anything_added = FALSE;
for (pref=rhs; pref!=NIL; pref=pref->inst_next) {
if (pref->id->id.tc_num != thisAgent->o_support_tc) continue;
if (pref->o_supported) continue; /* already added this thing */
pref->o_supported = TRUE;
anything_added = TRUE;
if (pref->value->common.symbol_type==IDENTIFIER_SYMBOL_TYPE)
pref->value->id.tc_num = thisAgent->o_support_tc;
if ((preference_is_binary(pref->type)) &&
(pref->referent->common.symbol_type==IDENTIFIER_SYMBOL_TYPE))
pref->referent->id.tc_num = thisAgent->o_support_tc;
}
}
}
/* --- Finally, use rule 1, which overrides all the other rules. --- */
for (pref=rhs; pref!=NIL; pref=pref->inst_next)
if ((pref->id==match_state) &&
(pref->attr==thisAgent->operator_symbol))
pref->o_supported = FALSE;
}
Symbol* find_compile_time_match_goal ( agent thisAgent,
condition lhs,
list known_goals 
)

Definition at line 654 of file osupport.cpp.

References three_field_tests_struct::attr_test, collect_root_variables(), condition_struct::data, FALSE, cons_struct::first, free_cons(), free_list(), get_new_tc_number(), three_field_tests_struct::id_test, member_of_list(), condition_struct::next, NIL, agent_struct::nil_symbol, POSITIVE_CONDITION, push(), cons_struct::rest, agent_struct::superstate_symbol, test_is_for_symbol(), condition_struct::condition_main_data_union::tests, condition_struct::type, three_field_tests_struct::value_test, and YES.

Referenced by calculate_compile_time_o_support().

{
list *roots;
list *root_goals;
int num_root_goals;
cons *c, *prev_c, *next_c;
Symbol *result;
condition *cond;
/* --- find root variables --- */
tc = get_new_tc_number(thisAgent);
roots = collect_root_variables (thisAgent, lhs, tc, FALSE);
/* --- intersect roots with known_goals, producing root_goals --- */
root_goals = NIL;
num_root_goals = 0;
for (c=roots; c!=NIL; c=c->rest)
if (member_of_list (c->first, known_goals)) {
push (thisAgent, c->first, root_goals);
num_root_goals++;
}
free_list (thisAgent, roots);
/* --- if more than one goal, remove any with "^object nil" --- */
if (num_root_goals > 1) {
for (cond=lhs; cond!=NIL; cond=cond->next) {
if ((cond->type==POSITIVE_CONDITION) &&
prev_c = NIL;
for (c=root_goals; c!=NIL; c=next_c) {
next_c = c->rest;
if (test_is_for_symbol (cond->data.tests.id_test, static_cast<symbol_union *>(c->first))==YES) {
/* --- remove c from the root_goals list --- */
if (prev_c) prev_c->rest = next_c; else root_goals = next_c;
free_cons (thisAgent, c);
num_root_goals--;
if (num_root_goals==1) break; /* be sure not to remove them all */
} else {
prev_c = c;
}
} /* end of for (c) loop */
if (num_root_goals==1) break; /* be sure not to remove them all */
}
} /* end of for (cond) loop */
}
/* --- if there's only one root goal, that's it! --- */
if (num_root_goals==1)
result = static_cast<symbol_union *>(root_goals->first);
else
result = NIL;
/* --- clean up and return result --- */
free_list (thisAgent, root_goals);
return result;
}
list* find_known_goals ( agent thisAgent,
condition lhs 
)
Symbol* find_thing_off_goal ( agent thisAgent,
condition lhs,
Symbol goal,
Symbol attr 
)
Bool id_or_value_of_condition_list_is_in_os_tc ( agent thisAgent,
condition conds,
Symbol sym_excluded_from_value,
Symbol match_state_to_exclude_test_of_the_operator_off_of 
)

Definition at line 163 of file osupport.cpp.

References three_field_tests_struct::attr_test, CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, FALSE, three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, condition_struct::next, NIL, agent_struct::operator_symbol, POSITIVE_CONDITION, test_has_id_in_os_tc(), test_includes_equality_test_for_symbol(), condition_struct::condition_main_data_union::tests, ncc_info_struct::top, TRUE, condition_struct::type, and three_field_tests_struct::value_test.

{
/* RBD 8/19/94 Under NNPSCM, when we use this routine to look for "something
off the state", we want to exclude tests of (match_state ^operator _). */
for ( ; conds!=NIL; conds=conds->next) {
switch (conds->type) {
match_state_to_exclude_test_of_the_operator_off_of) &&
thisAgent->operator_symbol))
break;
if (test_has_id_in_os_tc (thisAgent, conds->data.tests.id_test, NIL))
return TRUE;
if (test_has_id_in_os_tc (thisAgent, conds->data.tests.value_test,
sym_excluded_from_value))
return TRUE;
break;
sym_excluded_from_value
, match_state_to_exclude_test_of_the_operator_off_of
))
return TRUE;
break;
}
}
return FALSE;
}
Bool is_state_id ( agent thisAgent,
Symbol sym,
Symbol match_state 
)

Definition at line 207 of file osupport.cpp.

References FALSE, symbol_union::id, identifier_struct::lower_goal, agent_struct::top_goal, and TRUE.

{
Symbol *c;
for(c = thisAgent->top_goal; c != match_state; c = c->id.lower_goal) {
if (sym == c)
return TRUE;
}
if (sym == match_state)
return TRUE;
else
return FALSE;
}
Bool match_state_tests_non_operator_slot ( agent thisAgent,
condition conds,
Symbol match_state 
)
Bool test_has_id_in_os_tc ( agent thisAgent,
test  t,
Symbol excluded_sym 
)
yes_no_maybe test_is_for_symbol ( test  t,
Symbol sym 
)

Definition at line 576 of file osupport.cpp.

References complex_test_from_test(), complex_test_struct::test_info_union::conjunct_list, CONJUNCTIVE_TEST, complex_test_struct::data, complex_test_struct::test_info_union::disjunction_list, DISJUNCTION_TEST, FALSE, cons_struct::first, MAYBE, member_of_list(), NIL, NO, referent_of_equality_test(), cons_struct::rest, test_is_blank_or_equality_test(), test_is_blank_test(), TRUE, complex_test_struct::type, VARIABLE_SYMBOL_TYPE, and YES.

Referenced by calculate_compile_time_o_support(), find_compile_time_match_goal(), find_thing_off_goal(), and match_state_tests_non_operator_slot().

{
cons *c;
Bool maybe_found;
Symbol *referent;
if (test_is_blank_test(t)) return MAYBE;
if (referent==sym) return YES;
if (referent->common.symbol_type==VARIABLE_SYMBOL_TYPE) return MAYBE;
if (sym->common.symbol_type==VARIABLE_SYMBOL_TYPE) return MAYBE;
return NO;
}
switch (ct->type) {
if (sym->common.symbol_type==VARIABLE_SYMBOL_TYPE) return MAYBE;
if (member_of_list (sym, ct->data.disjunction_list)) return MAYBE;
return NO;
maybe_found = FALSE;
for (c=ct->data.conjunct_list; c!=NIL; c=c->rest) {
temp = test_is_for_symbol (static_cast<char *>(c->first), sym);
if (temp==YES) return YES;
if (temp==MAYBE) maybe_found = TRUE;
}
if (maybe_found) return MAYBE;
return NO;
default: /* goal/impasse tests, relational tests other than equality */
return MAYBE;
}
}