decompiler  1.0.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ActionDatabase Class Reference

Database of root Action objects that can be used to transform a function. More...

#include <action.hh>

Public Member Functions

 ActionDatabase (void)
 Constructor.
 
 ~ActionDatabase (void)
 Destructor.
 
void registerUniversal (Action *act)
 Register the universal root Action. More...
 
ActiongetCurrent (void) const
 Get the current root Action.
 
const string & getCurrentName (void) const
 Get the name of the current root Action.
 
const ActionGroupListgetGroup (const string &grp) const
 Get a specific grouplist by name.
 
ActionsetCurrent (const string &actname)
 Set the current root Action. More...
 
ActiontoggleAction (const string &grp, const string &basegrp, bool val)
 Toggle a group of Actions with a root Action. More...
 
void setGroup (const string &grp, const char **argv)
 Establish a new root Action. More...
 
void cloneGroup (const string &oldname, const string &newname)
 Clone a root Action. More...
 
bool addToGroup (const string &grp, const string &basegroup)
 Add a group to a root Action. More...
 
bool removeFromGroup (const string &grp, const string &basegroup)
 Remove a group from a root Action. More...
 

Private Member Functions

void registerAction (const string &nm, Action *act)
 Register a root Action. More...
 
ActiongetAction (const string &nm) const
 Look up a root Action by name. More...
 
ActionderiveAction (const string &baseaction, const string &grp)
 Derive a root Action. More...
 

Private Attributes

Actioncurrentact
 This is the current root Action.
 
string currentactname
 The name associated with the current root Action.
 
map< string, ActionGroupListgroupmap
 Map from root Action name to the grouplist it uses.
 
map< string, Action * > actionmap
 Map from name to root Action.
 

Static Private Attributes

static const char universalname [] = "universal"
 The name of the universal root Action.
 

Detailed Description

Database of root Action objects that can be used to transform a function.

This is a container for Action objects. It also manages root Action objects, which encapsulate a complete transformation system that can be applied to functions. Root Action objects are derived from a single universal Action object that has every possible sub-action within it. A root Action has its own name and is derived from the universal via a grouplist, which lists a particular subset of Action and Rule groups to use for the root. A new root Action is created by providing a new grouplist via setGroup() or modifying an existing grouplist. This class is intended to be instantiated as a singleton and keeps track of the current root Action, which is the one that will be actively applied to functions.

Member Function Documentation

◆ addToGroup()

bool ActionDatabase::addToGroup ( const string &  grp,
const string &  basegroup 
)

Add a group to a root Action.

Add a group to the grouplist for a particular root Action. Do not use to redefine a root Action that has already been instantiated.

Parameters
grpis the name of the root Action
basegroupis the group to add
Returns
true for a new addition, false is the group was already present

References groupmap, and ActionGroupList::list.

Referenced by toggleAction().

◆ cloneGroup()

void ActionDatabase::cloneGroup ( const string &  oldname,
const string &  newname 
)

Clone a root Action.

Copy an existing root Action by copying its grouplist, giving it a new name. This is suitable for a copy then modify strategy to create a new root Action. Do not use to redefine a root Action that has already been instantiated

Parameters
oldnameis the name of an existing root Action
newnameis the name of the copy

References getGroup(), and groupmap.

Referenced by OptionSetAction::apply().

◆ deriveAction()

Action * ActionDatabase::deriveAction ( const string &  baseaction,
const string &  grp 
)
private

Derive a root Action.

Internal method to build the Action object corresponding to a root Action The new Action object is created by selectively cloning components from an existing object based on a grouplist.

Parameters
baseactionis the name of the model Action object to derive from
grpis the name of the grouplist steering the clone

References actionmap, Action::clone(), getAction(), getGroup(), and registerAction().

Referenced by setCurrent().

◆ getAction()

Action * ActionDatabase::getAction ( const string &  nm) const
private

Look up a root Action by name.

Parameters
nmis the name of the root Action

References actionmap.

Referenced by deriveAction(), and toggleAction().

◆ registerAction()

void ActionDatabase::registerAction ( const string &  nm,
Action act 
)
private

Register a root Action.

Internal method for associated a root Action name with its Action object. The database takes over memory management of the object.

Parameters
nmis the name to register as
actis the Action object

References actionmap.

Referenced by deriveAction(), registerUniversal(), and toggleAction().

◆ registerUniversal()

void ActionDatabase::registerUniversal ( Action act)

Register the universal root Action.

This provides the database with the single Action from which all other root Actions are derived. The Action has a reserved name "universal"

Parameters
actis the universal Action

References registerAction(), and universalname.

Referenced by universal_action().

◆ removeFromGroup()

bool ActionDatabase::removeFromGroup ( const string &  grp,
const string &  basegrp 
)

Remove a group from a root Action.

The group is removed from the grouplist of a root Action. Do not use to redefine a root Action that has already been instantiated.

Parameters
grpis the name of the root Action
basegrpis the group to remove
Returns
true if the group existed and was removed

References groupmap, and ActionGroupList::list.

Referenced by toggleAction().

◆ setCurrent()

Action * ActionDatabase::setCurrent ( const string &  actname)

Set the current root Action.

The Action is specified by name. A grouplist must already exist for this name. If the Action doesn't already exist, it will be derived from the universal action via this grouplist.

Parameters
actnameis the name of the root Action

References currentact, currentactname, deriveAction(), and universalname.

Referenced by OptionSetAction::apply(), OptionCurrentAction::apply(), Architecture::buildAction(), SetAction::rawAction(), and Funcdata::stageJumpTable().

◆ setGroup()

void ActionDatabase::setGroup ( const string &  grp,
const char **  argv 
)

Establish a new root Action.

(Re)set the grouplist for a particular root Action. Do not use this routine to redefine an existing root Action.

Parameters
grpis the name of the root Action
argvis a list of static char pointers, which must end with a NULL pointer, or a zero length string.

References groupmap, and ActionGroupList::list.

Referenced by build_defaultactions().

◆ toggleAction()

Action * ActionDatabase::toggleAction ( const string &  grp,
const string &  basegrp,
bool  val 
)

Toggle a group of Actions with a root Action.

A particular group is either added or removed from the grouplist defining a particular root Action. The root Action is then (re)derived from the universal

Parameters
grpis the name of the root Action
basegrpis name of group (within the grouplist) to toggle
valis true if the group should be added or false if it should be removed
Returns
the modified root Action

References addToGroup(), Action::clone(), currentact, currentactname, getAction(), getGroup(), registerAction(), removeFromGroup(), and universalname.

Referenced by OptionCurrentAction::apply().


The documentation for this class was generated from the following files: