forked from rose-compiler/rose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
classicObjectOrientedVisitorPatternTraversal.C
48 lines (38 loc) · 1.29 KB
/
classicObjectOrientedVisitorPatternTraversal.C
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
#include "rose.h"
// This file is a place holder for an object-oriented vistor pattern
// implemented over the IR nodes that are traversed within a traversal
// of nodes marked to be traversed (instead of over ALL nodes using
// the memory pools as a mechanism).
class ClassicVisitor : public ROSE_VisitorPattern
{
public:
// Override virtural function defined in base class
void visit(SgGlobal* globalScope)
{
printf ("Found the SgGlobal IR node \n");
}
void visit(SgFunctionDeclaration* functionDeclaration)
{
printf ("Found a SgFunctionDeclaration IR node \n");
}
void visit(SgTypeInt* intType)
{
printf ("Found a SgTypeInt IR node \n");
}
void visit(SgTypeDouble* doubleType)
{
printf ("Found a SgTypeDouble IR node \n");
}
};
int
main ( int argc, char* argv[] )
{
// Initialize and check compatibility. See Rose::initialize
ROSE_INITIALIZE;
SgProject* project = frontend(argc,argv);
ROSE_ASSERT (project != NULL);
// Classic visitor pattern
ClassicVisitor visitor_A;
traverseMemoryPoolVisitorPattern(visitor_A);
return backend(project);
}