NumberInput Class Reference

#include <Metric.h>

Inheritance diagram for NumberInput:

Inheritance graph
[legend]
Collaboration diagram for NumberInput:

Collaboration graph
[legend]

Detailed Description

Definition at line 168 of file Metric.h.


Public Member Functions

 NumberInput ()
 NumberInput (const std::string &defASTStr)
virtual ~NumberInput ()
virtual MetricResult operator() (const tree< AstNode > &, const MapClasses *classes=0, const MapVariables *vars=0, const MapFunctions *func=0, const MapAssignments *assigns=0, const MapVarEquivalent *equiv=0)

Data Fields

Ast defAST

Constructor & Destructor Documentation

NumberInput::NumberInput (  )  [inline]

Definition at line 173 of file Metric.h.

00173 {}

NumberInput::NumberInput ( const std::string &  defASTStr  )  [inline]

Definition at line 174 of file Metric.h.

References defAST.

00174                                             {
00175         defAST = Ast(defASTStr);
00176     }

virtual NumberInput::~NumberInput (  )  [inline, virtual]

Definition at line 177 of file Metric.h.

00177 {}


Member Function Documentation

MetricResult NumberInput::operator() ( const tree< AstNode > &  tr,
const MapClasses classes = 0,
const MapVariables vars = 0,
const MapFunctions func = 0,
const MapAssignments assigns = 0,
const MapVarEquivalent equiv = 0 
) [virtual]

Implements Metric.

Definition at line 199 of file Metric.cpp.

References tree< T, tree_node_allocator >::begin(), tree< T, tree_node_allocator >::begin_leaf(), defAST, tree< T, tree_node_allocator >::end_leaf(), Ast::getTreeConstPtr(), MetricResult::main, tree< T, tree_node_allocator >::number_of_children(), and tree< T, tree_node_allocator >::parent().

00201 {
00202     MetricResult  result;   
00203     unsigned num=0;
00204     // Get the pointer on the tree with input entry defintion
00205     list<string> scanned;
00206     string temp,fullvarname;
00207     const tree<AstNode>*  def = defAST.getTreeConstPtr();
00208     // Go through all variables
00209     for(MapVariables::const_iterator iter=vars->begin(); iter!=vars->end();++iter)
00210     {
00211         for (AstVarBaseList::const_iterator jter=iter->second.begin();jter!=iter->second.end();++jter)
00212         {
00213             temp = jter->name;
00214             fullvarname = jter->name;
00215             if (jter->index.length() > 0) {
00216                  fullvarname += ('[' + jter->index + ']');
00217             }
00218             for (tree<AstNode>::leaf_iterator lter=def->begin_leaf();lter!=def->end_leaf();++lter)
00219             {
00220                 if (lter->getValue() == temp) {
00221                     if (find(scanned.begin(), scanned.end(), fullvarname) == scanned.end()) {
00222                         // Am I looking for an array somewhere?
00223                         tree<AstNode>::iterator tter=tr.parent(tr.begin(jter->position));
00224                         if (tr.number_of_children(tter) > 1)
00225                             num++;                          
00226                         scanned.push_back(fullvarname);
00227                     }                       
00228                 }
00229             }
00230         }
00231     }
00232     result.main = num;
00233     return result;
00234 }

Here is the call graph for this function:


Field Documentation

Ast NumberInput::defAST

Definition at line 171 of file Metric.h.

Referenced by NumberInput(), and operator()().


The documentation for this class was generated from the following files:
Generated on Wed Feb 27 20:32:01 2008 for php.ast.svn.src. by  doxygen 1.5.3