@@ -53,13 +53,18 @@ static bool visit_term(struct Term* t, VISITOR, ARG);
5353//const
5454static void visit_const_value (struct ConstValue * cv , VISITOR , ARG );
5555static void visit_string_const (struct StringConst * s , VISITOR , ARG );
56+ static void visit_enum_value (char * s , VISITOR , ARG );
5657
5758//var
5859// @returns false on error
5960static bool visit_variable (struct Variable * v , VISITOR , ARG );
6061// @returns false on error
6162static bool visit_simple_var (struct SimpleVar * v , VISITOR , ARG );
6263
64+ // enum
65+ static bool visit_enum_decl (struct EnumDecl * ed , VISITOR , ARG );
66+ static bool visit_enum_member (struct EnumMember * em , VISITOR , ARG );
67+
6368bool visit_ast (struct AST * ast , VISITOR , void * arg ) {
6469
6570 for (int i = 0 ; i < ast -> count_namespaces ; i ++ ) {
@@ -78,6 +83,10 @@ bool visit_namespace(struct Namespace* n, VISITOR, void* arg) {
7883 //we do not visit the passthrough include declarations as they
7984 //are just a workaround for now
8085
86+ for (int i = 0 ; i < n -> count_enums ; i ++ ) {
87+ visit_enum_decl (n -> enums [i ], visitor , arg );
88+ }
89+
8190 for (int i = 0 ; i < n -> count_structs ; i ++ ) {
8291 visit_struct_decl (n -> structs [i ], visitor , arg );
8392 }
@@ -91,6 +100,25 @@ bool visit_namespace(struct Namespace* n, VISITOR, void* arg) {
91100 return true;
92101}
93102
103+ static bool visit_enum_decl (struct EnumDecl * ed , VISITOR , ARG ) {
104+
105+ visitor (ed , NODE_ENUM_DECL , arg );
106+
107+ for (int i = 0 ; i < ed -> count_members ; i ++ ) {
108+ if (!visit_enum_member (ed -> members [i ], visitor , arg )) {
109+ return false;
110+ }
111+ }
112+
113+ return true;
114+ }
115+
116+ static bool visit_enum_member (struct EnumMember * em , VISITOR , ARG ) {
117+
118+ visitor (em , NODE_ENUM_MEMBER , arg );
119+ return true;
120+ }
121+
94122void visit_struct_decl (struct StructDecl * s , VISITOR , void * arg ) {
95123
96124 visitor (s , NODE_STRUCTDECL , arg );
@@ -346,6 +374,9 @@ static bool visit_term(struct Term* t, VISITOR, void* arg) {
346374 case TERM_KIND_CONSTVALUE :
347375 visit_const_value (t -> ptr .constvalue_term , visitor , arg );
348376 break ;
377+ case TERM_KIND_ENUM_VALUE :
378+ visit_enum_value (t -> ptr .enum_value_term , visitor , arg );
379+ break ;
349380 default :
350381 fprintf (stderr , "[Visitor][Error] Fatal(2)\n" );
351382 return false;
@@ -365,6 +396,11 @@ static void visit_string_const(struct StringConst* s, VISITOR, void* arg) {
365396 visitor (s , NODE_STRINGCONST , arg );
366397}
367398
399+ static void visit_enum_value (char * s , VISITOR , ARG ) {
400+
401+ visitor (s , NODE_ENUM_VALUE , arg );
402+ }
403+
368404static bool visit_variable (struct Variable * v , VISITOR , void * arg ) {
369405
370406 visitor (v , NODE_VARIABLE , arg );
0 commit comments