ROSE  0.11.98.0
Public Member Functions | List of all members
Rose::EditDistance::LinearEditDistance::Analysis< NodeType > Class Template Reference

Description

template<typename NodeType = Node>
class Rose::EditDistance::LinearEditDistance::Analysis< NodeType >

Edit distance analysis.

Analyzes two ASTs to determine the edit distance between them using the following algorithm:

Definition at line 104 of file LinearEditDistance.h.

#include <midend/programAnalysis/EditDistance/LinearEditDistance.h>

Public Member Functions

 Analysis ()
 Constructs an analysis object with no associated trees. More...
 
size_t cost () const
 Edit distance. More...
 
double relativeCost () const
 Relative edit distance. More...
 
AnalysissetTree1 (SgNode *ast, SgFile *file=NULL, size_t minDepth=0, size_t maxDepth=size_t(-1))
 Associate an AST with this analysis. More...
 
AnalysissetTree2 (SgNode *ast, SgFile *file=NULL, size_t minDepth=0, size_t maxDepth=size_t(-1))
 Associate an AST with this analysis. More...
 
Analysiscompute (SgNode *source, SgNode *target, SgFile *sourceFile=NULL, SgFile *targetFile=NULL)
 Compute edit distance. More...
 
Analysiscompute (SgNode *target, SgFile *targetFile=NULL)
 Compute edit distance. More...
 
Analysiscompute ()
 Compute edit distance. More...
 

Constructor & Destructor Documentation

template<typename NodeType = Node>
Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::Analysis ( )
inline

Constructs an analysis object with no associated trees.

Definition at line 110 of file LinearEditDistance.h.

Member Function Documentation

template<typename NodeType = Node>
Analysis& Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::setTree1 ( SgNode ast,
SgFile file = NULL,
size_t  minDepth = 0,
size_t  maxDepth = size_t(-1) 
)
inline

Associate an AST with this analysis.

The setTree1 sets the source AST and setTree2 sets the target AST. It does so by forgetting any previous source or target list nodes, traversing the specified tree to select new source or target nodes, creating a list of NodeType nodes, and storing the list in this analysis.

During traversal, AST nodes whose tree depth is between minDepth and maxDepth, inclusive are added to the list. However, if a file is specified then the node must also belong to the specified file.

Definition at line 122 of file LinearEditDistance.h.

Referenced by Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute().

template<typename NodeType = Node>
Analysis& Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::setTree2 ( SgNode ast,
SgFile file = NULL,
size_t  minDepth = 0,
size_t  maxDepth = size_t(-1) 
)
inline

Associate an AST with this analysis.

The setTree1 sets the source AST and setTree2 sets the target AST. It does so by forgetting any previous source or target list nodes, traversing the specified tree to select new source or target nodes, creating a list of NodeType nodes, and storing the list in this analysis.

During traversal, AST nodes whose tree depth is between minDepth and maxDepth, inclusive are added to the list. However, if a file is specified then the node must also belong to the specified file.

Definition at line 125 of file LinearEditDistance.h.

Referenced by Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute().

template<typename NodeType = Node>
Analysis& Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute ( SgNode source,
SgNode target,
SgFile sourceFile = NULL,
SgFile targetFile = NULL 
)
inline

Compute edit distance.

The no-argument version computes edit distance over the source and target ASTs that have been previously added to this analysis object. The other versions call setTree2 and/or setTree1 before doing the computation.

Returns this analysis object so that a query method can be chained:

size_t distance = LinearEditDistance::Analysis<>::compute(ast1,ast2).cost();

Definition at line 142 of file LinearEditDistance.h.

References Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute(), and Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::setTree1().

template<typename NodeType = Node>
Analysis& Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute ( SgNode target,
SgFile targetFile = NULL 
)
inline

Compute edit distance.

The no-argument version computes edit distance over the source and target ASTs that have been previously added to this analysis object. The other versions call setTree2 and/or setTree1 before doing the computation.

Returns this analysis object so that a query method can be chained:

size_t distance = LinearEditDistance::Analysis<>::compute(ast1,ast2).cost();

Definition at line 146 of file LinearEditDistance.h.

References Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute(), and Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::setTree2().

template<typename NodeType = Node>
Analysis& Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute ( )
inline

Compute edit distance.

The no-argument version computes edit distance over the source and target ASTs that have been previously added to this analysis object. The other versions call setTree2 and/or setTree1 before doing the computation.

Returns this analysis object so that a query method can be chained:

size_t distance = LinearEditDistance::Analysis<>::compute(ast1,ast2).cost();

Definition at line 150 of file LinearEditDistance.h.

References Rose::EditDistance::levenshteinDistance().

Referenced by Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::compute().

template<typename NodeType = Node>
size_t Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::cost ( ) const
inline

Edit distance.

Returns the edit distance previously computed. The compute method must be called first, otherwise zero is returned.

Definition at line 160 of file LinearEditDistance.h.

template<typename NodeType = Node>
double Rose::EditDistance::LinearEditDistance::Analysis< NodeType >::relativeCost ( ) const
inline

Relative edit distance.

Returns an edit distance relative to the size of the ASTs. A relative edit distance is the absolute edit distance divided by the size of the larger tree. Only nodes actually selected from the tree (those satisfying the constraints used by setTree1 and setTree2) are counted in the size.

Definition at line 169 of file LinearEditDistance.h.


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