1 // Copyright 2017-2019 VMware, Inc.
2 // SPDX-License-Identifier: BSD-2-Clause
3 //
4 // The BSD-2 license (the License) set forth below applies to all parts of the
5 // Cascade project.  You may not use this file except in compliance with the
6 // License.
7 //
8 // BSD-2 License
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright notice, this
14 // list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright notice,
17 // this list of conditions and the following disclaimer in the documentation
18 // and/or other materials provided with the distribution.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND
21 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef CASCADE_SRC_VERILOG_AST_VISITORS_EDITOR_H
32 #define CASCADE_SRC_VERILOG_AST_VISITORS_EDITOR_H
33 
34 #include "verilog/ast/ast_fwd.h"
35 
36 namespace cascade {
37 
38 // An intrusive visitor. The default implementation of this class performs a
39 // recursive descent over the AST and provides write access to the nodes that
40 // it encounters.
41 
42 struct Editor {
43   virtual ~Editor() = default;
44 
45   virtual void edit(ArgAssign* aa);
46   virtual void edit(Attributes* a);
47   virtual void edit(AttrSpec* as);
48   virtual void edit(CaseGenerateItem* cgi);
49   virtual void edit(CaseItem* ci);
50   virtual void edit(Event* e);
51   virtual void edit(BinaryExpression* be);
52   virtual void edit(ConditionalExpression* ce);
53   virtual void edit(FeofExpression* fe);
54   virtual void edit(FopenExpression* fe);
55   virtual void edit(Concatenation* c);
56   virtual void edit(Identifier* i);
57   virtual void edit(MultipleConcatenation* mc);
58   virtual void edit(Number* n);
59   virtual void edit(String* s);
60   virtual void edit(RangeExpression* re);
61   virtual void edit(UnaryExpression* ue);
62   virtual void edit(GenerateBlock* gb);
63   virtual void edit(Id* i);
64   virtual void edit(IfGenerateClause* igc);
65   virtual void edit(ModuleDeclaration* md);
66   virtual void edit(AlwaysConstruct* ac);
67   virtual void edit(IfGenerateConstruct* igc);
68   virtual void edit(CaseGenerateConstruct* cgc);
69   virtual void edit(LoopGenerateConstruct* lgc);
70   virtual void edit(InitialConstruct* ic);
71   virtual void edit(ContinuousAssign* ca);
72   virtual void edit(GenvarDeclaration* gd);
73   virtual void edit(LocalparamDeclaration* ld);
74   virtual void edit(NetDeclaration* nd);
75   virtual void edit(ParameterDeclaration* pd);
76   virtual void edit(RegDeclaration* rd);
77   virtual void edit(GenerateRegion* gr);
78   virtual void edit(ModuleInstantiation* mi);
79   virtual void edit(PortDeclaration* pd);
80   virtual void edit(BlockingAssign* ba);
81   virtual void edit(NonblockingAssign* na);
82   virtual void edit(CaseStatement* cs);
83   virtual void edit(ConditionalStatement* cs);
84   virtual void edit(ForStatement* fs);
85   virtual void edit(RepeatStatement* rs);
86   virtual void edit(ParBlock* pb);
87   virtual void edit(SeqBlock* sb);
88   virtual void edit(TimingControlStatement* rcs);
89   virtual void edit(DebugStatement* ds);
90   virtual void edit(FflushStatement* fs);
91   virtual void edit(FinishStatement* fs);
92   virtual void edit(FseekStatement* fs);
93   virtual void edit(GetStatement* gs);
94   virtual void edit(PutStatement* ps);
95   virtual void edit(RestartStatement* rs);
96   virtual void edit(RetargetStatement* rs);
97   virtual void edit(SaveStatement* ss);
98   virtual void edit(WhileStatement* ws);
99   virtual void edit(EventControl* ec);
100   virtual void edit(VariableAssign* va);
101 };
102 
103 } // namespace cascade
104 
105 #endif
106 
107