Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Typedefs | Functions
tempmem.h File Reference

Go to the source code of this file.

Typedefs

typedef struct agent_struct agent
typedef char Bool
typedef struct slot_struct slot
typedef union symbol_union Symbol

Functions

slotfind_slot (Symbol *id, Symbol *attr)
slotmake_slot (agent *thisAgent, Symbol *id, Symbol *attr)
void mark_slot_as_changed (agent *thisAgent, slot *s)
void mark_slot_for_possible_removal (agent *thisAgent, slot *s)
void remove_garbage_slots (agent *thisAgent)

Typedef Documentation

typedef struct agent_struct agent

Definition at line 40 of file tempmem.h.

typedef char Bool

Definition at line 37 of file tempmem.h.

typedef struct slot_struct slot

Definition at line 39 of file tempmem.h.

typedef union symbol_union Symbol

Definition at line 38 of file tempmem.h.

Function Documentation

slot* find_slot ( Symbol id,
Symbol attr 
)

Definition at line 55 of file tempmem.cpp.

References slot_struct::attr, symbol_union::id, slot_struct::next, NIL, and identifier_struct::slots.

Referenced by add_values_of_attribute_path(), elaborate_gds(), find_name_of_object(), process_o_rejects_and_deallocate_them(), soar_module::remove_module_wme(), and rl_tabulate_reward_value_for_goal().

{
slot *s;
if (!id) return NIL; /* fixes bug #135 kjh */
for (s=id->id.slots; s!=NIL; s=s->next)
if (s->attr==attr) return s;
return NIL;
}
slot* make_slot ( agent thisAgent,
Symbol id,
Symbol attr 
)

Definition at line 64 of file tempmem.cpp.

References slot_struct::acceptable_preference_changed, slot_struct::acceptable_preference_wmes, slot_struct::all_preferences, slot_struct::attr, slot_struct::changed, FALSE, symbol_union::id, slot_struct::id, slot_struct::impasse_id, slot_struct::impasse_type, insert_at_head_of_dll, slot_struct::isa_context_slot, identifier_struct::isa_goal, slot_struct::marked_for_possible_removal, slot_struct::next, NIL, NONE_IMPASSE_TYPE, NUM_PREFERENCE_TYPES, agent_struct::operator_symbol, slot_struct::preferences, agent_struct::slot_pool, identifier_struct::slots, symbol_add_ref(), TRUE, slot_struct::wma_val_references, and slot_struct::wmes.

Referenced by soar_module::add_module_wme(), add_preference_to_tm(), and create_new_context().

{
slot *s;
int i;
/* JC: Search for a slot first. If it exists
* for the given symbol, then just return it
*/
for (s=id->id.slots; s!=NIL; s=s->next)
{
if (s->attr==attr)
return s;
}
/* JC: need to create a new slot */
allocate_with_pool (thisAgent, &thisAgent->slot_pool, &s);
insert_at_head_of_dll (id->id.slots, s, next, prev);
/* Context slots are goals and operators; operator slots get
* created with a goal (see create_new_context).
*/
if ((id->id.isa_goal) && (attr == thisAgent->operator_symbol))
{
}
else
{
}
s->changed = NIL;
s->id = id;
s->attr = attr;
s->wmes = NIL;
/* JC: This is the same as all_preferences
* except they are indexed by type.
*/
for (i=0; i<NUM_PREFERENCE_TYPES; i++)
s->preferences[i] = NIL;
return s;
}
void mark_slot_as_changed ( agent thisAgent,
slot s 
)

Definition at line 119 of file tempmem.cpp.

References slot_struct::changed, agent_struct::changed_slots, agent_struct::dl_cons_pool, agent_struct::highest_goal_whose_context_changed, symbol_union::id, slot_struct::id, insert_at_head_of_dll, slot_struct::isa_context_slot, dl_cons_struct::item, and identifier_struct::level.

Referenced by add_preference_to_tm(), and remove_preference_from_tm().

{
dl_cons *dc;
if (s->isa_context_slot) {
if (s->id->id.level <
} else {
}
s->changed = reinterpret_cast<dl_cons *>(s); /* just make it nonzero */
} else {
if (! s->changed) {
allocate_with_pool (thisAgent, &thisAgent->dl_cons_pool, &dc);
dc->item = s;
s->changed = dc;
insert_at_head_of_dll (thisAgent->changed_slots, dc, next, prev);
}
}
}
void mark_slot_for_possible_removal ( agent thisAgent,
slot s 
)
void remove_garbage_slots ( agent thisAgent)

Definition at line 163 of file tempmem.cpp.

References slot_struct::all_preferences, slot_struct::attr, slot_struct::changed, agent_struct::changed_slots, agent_struct::dl_cons_pool, FALSE, cons_struct::first, free_cons(), symbol_union::id, slot_struct::id, slot_struct::isa_context_slot, slot_struct::marked_for_possible_removal, NIL, print_with_symbols(), remove_from_dll, cons_struct::rest, agent_struct::slot_pool, identifier_struct::slots, agent_struct::slots_for_possible_removal, symbol_remove_ref(), agent_struct::wma_slot_refs_pool, slot_struct::wma_val_references, and slot_struct::wmes.

Referenced by do_buffered_wm_and_ownership_changes().

{
cons *c;
slot *s;
while (thisAgent->slots_for_possible_removal) {
s = static_cast<slot_struct *>(c->first);
free_cons(thisAgent, c);
if (s->wmes || s->all_preferences) {
/* --- don't deallocate it if it still has any wmes or preferences --- */
continue;
}
/* --- deallocate the slot --- */
#ifdef DEBUG_SLOTS
print_with_symbols (thisAgent, "\nDeallocate slot %y ^%y", s->id, s->attr);
#endif
if (s->changed && (! s->isa_context_slot)) {
remove_from_dll (thisAgent->changed_slots, s->changed, next, prev);
free_with_pool (&thisAgent->dl_cons_pool, s->changed);
}
remove_from_dll (s->id->id.slots, s, next, prev);
symbol_remove_ref (thisAgent, s->id);
symbol_remove_ref (thisAgent, s->attr);
if ( s->wma_val_references != NIL )
{
s->wma_val_references->~wma_sym_reference_map();
free_with_pool( &( thisAgent->wma_slot_refs_pool ), s->wma_val_references );
}
free_with_pool (&thisAgent->slot_pool, s);
}
}