#include <Metric.h>
Definition at line 182 of file Metric.h.
Public Member Functions | |
NumberDiffuseInputs () | |
NumberDiffuseInputs (const std::string &defASTStr) | |
virtual | ~NumberDiffuseInputs () |
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 |
NumberDiffuseInputs::NumberDiffuseInputs | ( | ) | [inline] |
NumberDiffuseInputs::NumberDiffuseInputs | ( | const std::string & | defASTStr | ) | [inline] |
virtual NumberDiffuseInputs::~NumberDiffuseInputs | ( | ) | [inline, virtual] |
MetricResult NumberDiffuseInputs::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] |
Same as NumberInput but counting with the dataflow:
a = $_GET['b'] b = $_GET['b']
=> 2
Implements Metric.
Definition at line 245 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().
00247 { 00248 MetricResult result; 00249 unsigned num=0; 00250 // Get the pointer on the tree with input entry defintion 00251 list<string> scanned; 00252 string temp,fullvarname; 00253 const tree<AstNode>* def = defAST.getTreeConstPtr(); 00254 00255 // Go through all variables 00256 for(MapVariables::const_iterator iter=vars->begin(); iter!=vars->end();++iter) 00257 { 00258 for (AstVarBaseList::const_iterator jter=iter->second.begin();jter!=iter->second.end();++jter) 00259 { 00260 temp = jter->name; 00261 fullvarname = jter->name; 00262 if (jter->index.length() > 0) { 00263 fullvarname += ('[' + jter->index + ']'); 00264 } 00265 for (tree<AstNode>::leaf_iterator lter=def->begin_leaf();lter!=def->end_leaf();++lter) 00266 { 00267 if (lter->getValue() == temp) { 00268 if (find(scanned.begin(), scanned.end(), fullvarname) == scanned.end()) { 00269 // Am I looking for an array somewhere? 00270 tree<AstNode>::iterator tter=tr.parent(tr.begin(jter->position)); 00271 if (tr.number_of_children(tter) > 1) 00272 num++; 00273 scanned.push_back(fullvarname); 00274 } 00275 } 00276 } 00277 } 00278 } 00279 00280 // Then, add the assignments variables recursivle of the scanned listen 00281 // cerr << "Equivalences:" << endl; 00282 for (MapAssignments::const_iterator iter = assigns->begin(); iter != assigns->end(); ++iter) 00283 { 00284 fullvarname = iter->second.name; 00285 if (iter->second.index.length() > 0) { 00286 fullvarname += ('[' + iter->second.index + ']'); 00287 } 00288 00289 string tname = iter->first.name; 00290 if (iter->first.index.length() > 0) { 00291 tname += ('[' + iter->first.index + ']'); 00292 } 00293 if (find(scanned.begin(), scanned.end(), fullvarname) != scanned.end()){ 00294 num++; 00295 } 00296 } 00297 result.main = num; 00298 return result; 00299 }