00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CBZ_SET_CONTAINER_WALKER_H
00038 #define CBZ_SET_CONTAINER_WALKER_H
00039
00040
00041
00042 class set_container_walker : public Walker
00043 {
00044
00045 public:
00046
00047 static void fixup(Node * n);
00048
00049 private:
00050
00051 stmt_list _stack;
00052
00053 procNode * _current_proc;
00054
00055 stmtNode * nearest();
00056 switchNode * nearest_switch();
00057 loopNode * nearest_loop();
00058
00059 set_container_walker()
00060 : Walker(Both, Subtree),
00061 _stack()
00062 {}
00063
00064 public:
00065
00066 virtual void at_node(Node * the_node, Order ord)
00067 { }
00068
00069
00070
00071 virtual void at_switch(switchNode * the_switch, Order ord)
00072 {
00073 if (ord == Preorder) {
00074 _stack.push_front(the_switch);
00075 the_switch->cases().clear();
00076 }
00077 else _stack.pop_front();
00078 }
00079
00080 virtual void at_loop(loopNode * the_loop, Order ord)
00081 {
00082 if (ord == Preorder) _stack.push_front(the_loop);
00083 else _stack.pop_front();
00084 }
00085
00086
00087
00088 virtual void at_case(caseNode * the_case, Order ord);
00089
00090 virtual void at_continue(continueNode * the_continue, Order ord);
00091
00092 virtual void at_break(breakNode * the_break, Order ord);
00093
00094
00095
00096 void at_proc(procNode * the_proc, Order ord)
00097 {
00098 if (ord == Preorder)
00099 _current_proc = the_proc;
00100 else
00101 _current_proc = (procNode *)0;
00102 }
00103
00104 void at_return(returnNode * the_return, Order ord)
00105 {
00106 if (ord == Preorder)
00107 the_return->proc(_current_proc);
00108 }
00109 };
00110
00111
00112
00113 #endif // CBZ_SET_CONTAINER_WALKER_H