summaryrefslogtreecommitdiff
path: root/trunk/TAO/TAO_IDL/be/be_visitor_decl.cpp
blob: 379d71a67c8931a8adeb6cc982cb6ab592e028de (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
//
// $Id$
//

// ============================================================================
//
// = LIBRARY
//    TAO IDL
//
// = FILENAME
//    be_visitor_decl.cpp
//
// = DESCRIPTION
//    Visitor for the base be_decl node. This serves to maintain the current
//    state (context) of code generation for the derived visitor.
//
// = AUTHOR
//    Aniruddha Gokhale
//
// ============================================================================

#include "be_visitor_decl.h"
#include "be_visitor_sequence.h"
#include "be_visitor_context.h"
#include "be_typedef.h"
#include "be_type.h"
#include "ace/Log_Msg.h"

ACE_RCSID (be, 
           be_visitor_decl, 
           "$Id$")

// Root visitor for client header
be_visitor_decl::be_visitor_decl (be_visitor_context *ctx)
  : ctx_ (ctx)
{
}

be_visitor_decl::~be_visitor_decl (void)
{
}

be_visitor_context *
be_visitor_decl::ctx (void)
{
  return this->ctx_;
}

int
be_visitor_decl::gen_anonymous_base_type (be_type *bt,
                                          TAO_CodeGen::CG_STATE cg_state)
{
  be_typedef *tdef = be_typedef::narrow_from_decl (bt);

  if (!tdef)
    {
      be_visitor_context ctx (*this->ctx_);
      ctx.state (cg_state);

      // In case our container was typedef'd.
      ctx.tdef (0);

      int status = 0;

      switch (cg_state)
      {
        case TAO_CodeGen::TAO_ROOT_CH:
          {
            be_visitor_sequence_ch visitor (&ctx);
            status = bt->accept (&visitor);
            break;
          }
        case TAO_CodeGen::TAO_ROOT_CI:
          {
            break;
          }
        case TAO_CodeGen::TAO_ROOT_CS:
          {
            be_visitor_sequence_cs visitor (&ctx);
            status = bt->accept (&visitor);
            break;
          }
        case TAO_CodeGen::TAO_ROOT_CDR_OP_CS:
          {
            be_visitor_sequence_cdr_op_cs visitor (&ctx);
            status = bt->accept (&visitor);
            break;
          }
        default:
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_decl::"
                             "gen_anonymous_base_type - "
                             "bad context state\n"),
                            -1);
      }

      if (status == -1)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             "(%N:%l) be_visitor_decl::"
                             "gen_anonymous_base_type - "
                             "anonymous base type codegen failed\n"),
                            -1);
        }
    }

  return 0;
}