-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintNamesPlugin.cpp
49 lines (40 loc) · 1.44 KB
/
PrintNamesPlugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// An example ROSE plugin: PrintNamesPlugin.cpp
//Mandatory include headers
#include "rose.h"
#include "plugin.h"
// optional headers
#include "RoseAst.h" // using AST Iterator
#include <iostream>
using namespace std;
using namespace Rose;
//Step 1. Derive a plugin action from Rose::PluginAction
class PrintNamesAction : public Rose::PluginAction {
public:
PrintNamesAction() {}
~PrintNamesAction() {}
// This is optional. Need only if your plugin wants to handle options
// Provide command line option processing: arg will be the options passed to this plugin
bool ParseArgs(const std::vector<std::string> &arg)
{
cout<<arg.size()<< " arguments "<<endl;
for (size_t i=0; i< arg.size(); i++)
{
cout<<arg[i]<<endl;
}
return true;
}
// This is mandatory: providing work in your plugin
// Do actual work after ParseArgs();
void process (SgProject* n) {
SgNode* node= n;
RoseAst ast(node);
for(RoseAst::iterator i=ast.begin();i!=ast.end();++i) {
SgFunctionDeclaration* fdecl= isSgFunctionDeclaration(*i);
if (fdecl && (fdecl->get_definingDeclaration()==fdecl))
cout<<fdecl->get_name()<<endl;
}
} // end process()
};
//Step 2: Declare a plugin entry with a unique name
// Register it under a unique action name plus some description
static Rose::PluginRegistry::Add<PrintNamesAction> uniquePluginName1("print-names", "print function names");