ROSE
0.9.6a
|
Action annotation. More...
#include <action.h>
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... | |
exprAnn * | condition () 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... | |
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.
|
inline |
|
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.
|
private |
|
private |
Condition.
The condition to test for activating this substitution.
Definition at line 39 of file action.h.
Referenced by condition().
|
private |
|
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?