ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
actionAnn Class Reference

Action annotation. More...

#include <action.h>

Inheritance diagram for actionAnn:
Collaboration diagram for actionAnn:

Public Types

enum  ActionKind {
  Inline,
  Replace
}
 

Public Member Functions

 actionAnn (exprAnn *condition, int line)
 Create a new "inline" action annotation. More...
 
 actionAnn (exprAnn *condition, stmtNode *replacement, int line)
 Create a new "replace" action annotation. More...
 
exprAnncondition () const
 Return the condition. More...
 
virtual void lookup (procedureAnn *procedure, Annotations *annotations)
 Lookup variables. More...
 
void test (callsiteEntry *callsite, procLocation *where, propertyAnalyzer *property_analyzer)
 Test the condition. More...
 
bool is_applicable (callsiteEntry *callsite)
 Is applicable. More...
 
stmtNode * generate_replacement (callsiteEntry *callsite, propertyAnalyzer *analyzer, Linker &linker, Annotations *annotations)
 Generate replacement code. More...
 
- Public Member Functions inherited from Ann
 Ann (int line)
 
int line () const
 

Private Attributes

ActionKind _kind
 Kind of action. More...
 
exprAnn_condition
 Condition. More...
 
stmtNode * _replacement
 Replacement statement. More...
 
candidate_map _candidates
 Candidates. More...
 

Detailed Description

Action annotation.

Definition at line 19 of file action.h.

Member Enumeration Documentation

Enumerator
Inline 
Replace 

Definition at line 23 of file action.h.

Constructor & Destructor Documentation

actionAnn::actionAnn ( exprAnn condition,
int  line 
)

Create a new "inline" action annotation.

actionAnn::actionAnn ( exprAnn condition,
stmtNode *  replacement,
int  line 
)

Create a new "replace" action annotation.

Used by the parser, this constructor creates a new subsitution with the given condition and substitute code.

Member Function Documentation

exprAnn* actionAnn::condition ( ) const
inline

Return the condition.

Definition at line 79 of file action.h.

References _condition.

virtual void actionAnn::lookup ( procedureAnn procedure,
Annotations annotations 
)
virtual

Lookup variables.

After parsing, this method is called by procedureAnn::postprocess() method to lookup the variables in both the condition and the substitution.

void actionAnn::test ( callsiteEntry *  callsite,
procLocation *  where,
propertyAnalyzer *  property_analyzer 
)

Test the condition.

For the given calling context, it evaluates the condition and stores the results in the _candidates map.

bool actionAnn::is_applicable ( callsiteEntry *  callsite)

Is applicable.

Return true if the action is applicable at the given call site

stmtNode* actionAnn::generate_replacement ( callsiteEntry *  callsite,
propertyAnalyzer *  analyzer,
Linker &  linker,
Annotations annotations 
)

Generate replacement code.

For inlining and replacement actions, generate the code that will replace the given procedure call.

Member Data Documentation

ActionKind actionAnn::_kind
private

Kind of action.

Currently, there are only two kinds: inline (inline the body of the library routine) and replace (replace the call to the library routine with some other code).

Definition at line 33 of file action.h.

exprAnn* actionAnn::_condition
private

Condition.

The condition to test for activating this substitution.

Definition at line 39 of file action.h.

Referenced by condition().

stmtNode* actionAnn::_replacement
private

Replacement statement.

This is a C code statement that provides the template for the substitution. We replace elements of the statement with information and variable names from the actual call site.

Definition at line 47 of file action.h.

candidate_map actionAnn::_candidates
private

Candidates.

A substitution candidate is a particular callsite in the text of the program (a stmtNode). For each callsite, we record the possible contexts that reach it, and the truth value of the condition in that context. We need this information for two reasons. First, we can only modify the code when the transformation applies in all the contexts (or we need to do something else, like clone the code). Second, we need to record the different contexts so that we can get the variable bindings during substitution. TBD: What if the condition is true is all contexts, but the bindings are different?

Definition at line 61 of file action.h.


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