summaryrefslogtreecommitdiff
path: root/trunk/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp
blob: 9c699fe20ba5e51e5dd0b8e8400a5e9770d82044 (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
// file      : CCF/IDL3/SemanticAction/Impl/Include.hpp
// author    : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id    : $Id$

#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP
#define CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP

#include <set>
#include <stack>

#include "CCF/CompilerElements/Context.hpp"
#include "CCF/CompilerElements/Diagnostic.hpp"

#include "CCF/IDL2/SemanticGraph/Translation.hpp"
#include "CCF/IDL3/SemanticGraph/Elements.hpp"

#include "CCF/IDL2/SemanticAction/Include.hpp"
#include "CCF/IDL3/SemanticAction/Factory.hpp"

#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp"

namespace CCF
{
  namespace IDL3
  {
    namespace SemanticAction
    {
      namespace Impl
      {
        // Note: overriding IDL2 include to allow inclusion of IDL3 files.
        //
        //
        struct Include : IDL2::SemanticAction::Include, Base
        {
        public:
          Include (Context& c,
                   Diagnostic::Stream& dout,
                   SemanticAction::Factory& action_factory);

          virtual void
          quote (StringLiteralPtr const& sl);

          virtual void
          bracket (StringLiteralPtr const& sl);

          virtual void
          end ();

        private:
          enum Type_
          {
            quote_,
            bracket_
          };

          virtual void
          impl (StringLiteralPtr const& sl, Type_ type);

          bool
          handle_already_included (fs::path const& path,
                                   StringLiteralPtr const& sl);
        private:
          Diagnostic::Stream& dout_;
          SemanticAction::Factory& action_factory_;

          std::stack<SemanticGraph::TranslationRegion*> stack_;
          std::stack<fs::path> abs_path_stack_, rel_path_stack_;

          struct FilePathComparator
          {
            bool operator () (fs::path const& x, fs::path const& y) const
            {
              return x.string () < y.string ();
            }
          };

          std::set<fs::path, FilePathComparator> include_file_set_;
        };
      }
    }
  }
}

#endif  // CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP