Otawa  0.10
otawa::ContextualProperty Class Reference

A contextual property is a special property that allows to retrieve a property value by its contextual path (ContextualPath). More...

#include <otawa/prop/ContextualProperty.h>

Inheritance diagram for otawa::ContextualProperty:
otawa::Property

Classes

class  Node
 

Public Member Functions

 ContextualProperty (void)
 Build a contextual property. More...
 
const AbstractIdentifierid (void) const
 Get the identifier code of the property. More...
 
Propertynext (void) const
 Get the next property. More...
 
template<class T >
const T & get (void) const
 
template<class T >
void set (const T &value)
 
virtual void print (elm::io::Output &out) const
 Print the given property, that is, the identifier and its value if any. More...
 

Static Public Member Functions

static bool exists (const PropList &props, const ContextualPath &path, const AbstractIdentifier &id)
 Test if a contextual property exists, that is, the property value is defined at any step of the given contextual path. More...
 
static PropListref (PropList &props, const ContextualPath &path, const AbstractIdentifier &id)
 Obtain a reference on a property value in the given contextual path. More...
 
static const PropListfind (const PropList &props, const ContextualPath &path, const AbstractIdentifier &id)
 Get a contextual property from a property list. More...
 
static PropListmake (PropList &props, const ContextualPath &path)
 Set a contextual property. More...
 
static void print (io::Output &out, const PropList &props)
 Display the contextual information of the given property list. More...
 
static const AbstractIdentifiergetID (elm::CString name)
 Allocate a new identifier matching the given name. More...
 

Protected Member Functions

virtual Propertycopy (void)
 This method is called when a property is copied. More...
 

Private Member Functions

const PropListfindProps (const PropList &props, const ContextualPath &path, const AbstractIdentifier &id) const
 Find the property list matching the best the given path. More...
 
PropListmakeProps (const ContextualPath &path)
 Find or make the property list for the given path. More...
 
PropListrefProps (PropList &props, const ContextualPath &path, const AbstractIdentifier &id)
 
void print (io::Output &out, const Node &node, int indent=0) const
 

Private Attributes

Node root
 

Static Private Attributes

static AbstractIdentifier ID
 Private identifier for contextual properties. More...
 

Detailed Description

A contextual property is a special property that allows to retrieve a property value by its contextual path (ContextualPath).

Contextual path allows to takes into account the context of execution of a block, that is, the chaining of function, calls and loop iteration driving to the block. Notice that the path must be precise while the matching is performed on a blurred contextual tree. This means that some parts of the contextual path may be ignored if an embedding context is found in the contextual property. For example, the path [c1, c2, c3] may match a property whose path is [c1, c3] as it is considered as [c1, *, c2], that is more general that the given path. * means "any component".

Constructor & Destructor Documentation

otawa::ContextualProperty::ContextualProperty ( void  )

Build a contextual property.

Referenced by make(), and ref().

Member Function Documentation

Property * otawa::Property::copy ( void  )
inlineprotectedvirtualinherited

This method is called when a property is copied.

It may be specialized by Property class children.

Returns
Copy of the current property.

Reimplemented in otawa::LockedProperty< T >, and otawa::GenericProperty< T >.

References otawa::Property::_id, and otawa::Property::Property().

Referenced by refProps().

bool otawa::ContextualProperty::exists ( const PropList props,
const ContextualPath path,
const AbstractIdentifier id 
)
static

Test if a contextual property exists, that is, the property value is defined at any step of the given contextual path.

Parameters
propsProperty list to look in.
pathContextual path.
idLooked identifier.

References findProps(), otawa::PropList::getProp(), and ID.

Referenced by otawa::ContextualPath::Ref< T >::exists().

const PropList & otawa::ContextualProperty::find ( const PropList props,
const ContextualPath path,
const AbstractIdentifier id 
)
static

Get a contextual property from a property list.

Parameters
propsProperty list to look in.
pathContextual path.
idIdentifier of the looked property.
Returns
Found property or null.

References findProps(), otawa::PropList::getProp(), and ID.

Referenced by otawa::ContextualPath::get().

const PropList & otawa::ContextualProperty::findProps ( const PropList props,
const ContextualPath path,
const AbstractIdentifier id 
) const
private

Find the property list matching the best the given path.

Parameters
pathPath to match.
stackStack of property list leading to the full context.
Returns
More precise property list matching the path.

References elm::genstruct::Vector< T >::count(), otawa::ContextualPath::count(), elm::genstruct::Vector< T >::push(), root, and otawa::ContextualProperty::Node::step.

Referenced by exists(), and find().

template<class T >
const T & otawa::Property::get ( void  ) const
inlineinherited
const AbstractIdentifier * otawa::Property::getID ( elm::CString  name)
staticinherited

Allocate a new identifier matching the given name.

Note that, if an identifier exists with the same name, its code will be returned ensuring consistency between name and code for identifiers.

Parameters
nameName of the identifier.
Returns
Allocated identifier code.

References otawa::display::find().

const Identifier * otawa::Property::id ( void  ) const
inlineinherited
PropList & otawa::ContextualProperty::make ( PropList props,
const ContextualPath path 
)
static

Set a contextual property.

Parameters
propsProperty list to set in.
pathContextual path of the property.
propProperty to set.

References otawa::PropList::addProp(), ContextualProperty(), otawa::ContextualPath::count(), otawa::PropList::getProp(), ID, and makeProps().

Referenced by otawa::ContextualPath::Ref< T >::add(), refProps(), and otawa::ContextualPath::Ref< T >::remove().

PropList & otawa::ContextualProperty::makeProps ( const ContextualPath path)
private

Find or make the property list for the given path.

Parameters
pathContextual path.
Returns
Property matching the given path.

References elm::inhstruct::Tree::add(), otawa::ContextualPath::count(), root, and otawa::ContextualProperty::Node::step.

Referenced by make().

void otawa::Property::print ( elm::io::Output out) const
virtualinherited

Print the given property, that is, the identifier and its value if any.

Parameters
outOutput to use.

Referenced by otawa::operator<<().

void otawa::ContextualProperty::print ( io::Output out,
const PropList props 
)
static

Display the contextual information of the given property list.

Parameters
outStream to output to.
propsProperty list.

References otawa::PropList::getProp(), ID, print(), and root.

Referenced by print().

void otawa::ContextualProperty::print ( io::Output out,
const Node node,
int  indent = 0 
) const
private
PropList & otawa::ContextualProperty::ref ( PropList props,
const ContextualPath path,
const AbstractIdentifier id 
)
static

Obtain a reference on a property value in the given contextual path.

If the property does not exists, create and return it. If the property exists at an intermediate level, copy it at the top level and return reference to it.

Parameters
propsProperty list to look in.
pathContextual path.
idLooked identifier.

References otawa::PropList::addProp(), ContextualProperty(), otawa::ContextualPath::count(), otawa::PropList::getProp(), ID, and refProps().

Referenced by otawa::ContextualPath::Ref< T >::ref().

template<class T >
void otawa::Property::set ( const T &  value)
inlineinherited

Member Data Documentation

AbstractIdentifier otawa::ContextualProperty::ID
staticprivate

Private identifier for contextual properties.

Referenced by exists(), find(), make(), print(), and ref().

Node otawa::ContextualProperty::root
private

Referenced by findProps(), makeProps(), print(), and refProps().


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