summaryrefslogtreecommitdiff
path: root/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp
blob: 169fb57ace31939204caa5a87d20baecb3738f6d (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// file      : Test/CIDL/Compiler/GeneratorImpl.hpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#ifndef TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP
#define TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP

#include <iostream>

#include "CCF/CodeGenerationKit/IndentationIDL.hpp"
#include "CCF/CodeGenerationKit/IndentationImplanter.hpp"

#include "CCF/CIDL/SemanticGraph.hpp"
#include "CCF/CIDL/Traversal.hpp"

#include "../../IDL3/Compiler/GeneratorImpl.hpp"

namespace CIDL
{
  using namespace CCF::CIDL;

  using std::cout;
  using std::endl;

  class GeneratorImpl : public IDL3::GeneratorImpl
  {
  protected:
    // Layer 1
    //

    // Layer 2
    //

    // Layer 3
    //

    //--

    struct Composition : Traversal::Composition
    {
      virtual void
      pre (Type& c)
      {
        //@@ TODO kind
        cout << "composition " << "session" << " ";
      }

      virtual void
      name (Type& i)
      {
        cout << i.name ();
      }

      virtual void
      names_pre (Type&)
      {
        cout << "{";
      }

      virtual void
      names_post (Type&)
      {
        cout << "}";
      }

      virtual void
      post (Type&)
      {
        cout << ";";
      }
    };


    struct HomeExecutor : Traversal::HomeExecutor
    {
      virtual void
      pre (Type&)
      {
        cout << "home executor ";
      }

      virtual void
      name (Type& he)
      {
        cout << he.name () << "{";
      }

      virtual void
      implements_pre (Type&)
      {
        cout << "implements ";
      }

      virtual void
      implements_post (Type&)
      {
        cout << ";";
      }

      virtual void
      manages_pre (Type&)
      {
        cout << "manages ";
      }

      virtual void
      manages_post (Type&)
      {
        cout << ";";
      }

      virtual void
      post (Type& he)
      {
        cout << "};";
      }
    };


    // Layer 4
    //

    //--

    // Layer 5
    //

    //--

    struct SimpleName : Traversal::Nameable
    {
      virtual void
      traverse (Type& n)
      {
        cout << n.name ();
      }
    };

  public:

    GeneratorImpl ()
    {
      // Layer 1
      //

      // Layer 2
      //

      // Layer 3
      //

      //--

      defines.node_traverser (composition);

      // Layer 4
      //

      composition.edge_traverser (composition_defines);

      //--

      composition_defines.node_traverser (home_executor);

      // Layer 5
      //
      home_executor.edge_traverser (home_executor_implements);
      home_executor.edge_traverser (home_executor_manages);

      //--

      home_executor_implements.node_traverser (type_name);
      home_executor_manages.node_traverser (simple_name);

      // Layer 6
      //

    }

  protected:
    // Layer 1
    //

    // Layer 2
    //

    // Layer 3
    //

    //--

    Composition composition;

    // Layer 4
    //

    Traversal::Defines composition_defines;

    //--

    HomeExecutor home_executor;

    // Layer 5
    //
    Traversal::Implements home_executor_implements;
    Traversal::Manages home_executor_manages;

    //--

    SimpleName simple_name;

    // Layer 6
    //

  public:
    void
    generate (CCF::CIDL::SemanticGraph::TranslationUnit& tu)
    {
      // Plug automatic IDL indenter.
      //
      Indentation::Implanter<Indentation::IDL> guard (cout);

      unit.traverse (tu);
    }
  };
}

#endif  // TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP