Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_union / discriminant_ch.cpp
blob945581974539a3e812b21c41254dfd456fac4391
2 //=============================================================================
3 /**
4 * @file discriminant_ch.cpp
6 * Visitor generating code for discriminant of the Union
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "union.h"
14 be_visitor_union_discriminant_ch::be_visitor_union_discriminant_ch (
15 be_visitor_context *ctx)
16 : be_visitor_decl (ctx)
20 be_visitor_union_discriminant_ch::~be_visitor_union_discriminant_ch ()
24 int
25 be_visitor_union_discriminant_ch::visit_enum (be_enum *node)
27 // Get the enclosing union backend.
28 be_union *bu =
29 dynamic_cast<be_union*> (this->ctx_->node ());
30 be_type *bt = nullptr;
32 // Check if we are visiting this node via a visit to a typedef node.
33 if (this->ctx_->alias ())
35 bt = this->ctx_->alias ();
37 else
39 bt = node;
42 TAO_OutStream *os = this->ctx_->stream ();
44 // Not a typedef and bt is defined inside the union.
45 if (bt->node_type () != AST_Decl::NT_typedef
46 && bt->is_child (bu))
48 // Instantiate a visitor context with a copy of our context. This info
49 // will be modified based on what type of node we are visiting.
50 be_visitor_context ctx (*this->ctx_);
51 ctx.node (node);
53 // First generate the enum declaration.
54 be_visitor_enum_ch visitor (&ctx);
56 if (node->accept (&visitor) == -1)
58 ACE_ERROR_RETURN ((LM_ERROR,
59 "(%N:%l) be_visitor_union_discriminant_ch::"
60 "visit_enum - "
61 "codegen failed\n"),
62 -1);
66 TAO_INSERT_COMMENT (os);
68 // The set method.
69 *os << be_nl_2
70 << "void _d (" << bt->nested_type_name (bu) << ");" << be_nl;
71 // The get method.
72 *os << bt->nested_type_name (bu) << " _d () const;";
74 return 0;
77 int
78 be_visitor_union_discriminant_ch::visit_predefined_type (be_predefined_type
79 *node)
81 // get the enclosing union backend.
82 be_union *bu =
83 dynamic_cast<be_union*> (this->ctx_->node ());
84 be_type *bt = nullptr;
86 // Check if we are visiting this node via a visit to a typedef node.
87 if (this->ctx_->alias ())
89 bt = this->ctx_->alias ();
91 else
93 bt = node;
96 TAO_OutStream *os = this->ctx_->stream ();
98 TAO_INSERT_COMMENT (os);
100 // The set method.
101 *os << be_nl_2
102 << "void _d ( " << bt->nested_type_name (bu) << ");" << be_nl;
103 // The get method.
104 *os << bt->nested_type_name (bu) << " _d () const;";
106 return 0;
110 be_visitor_union_discriminant_ch::visit_typedef (be_typedef *node)
112 this->ctx_->alias (node);
114 // The node to be visited in the base primitve type that gets typedefed.
115 be_type *bt = node->primitive_base_type ();
117 if (!bt || (bt->accept (this) == -1))
119 ACE_ERROR_RETURN ((LM_ERROR,
120 "(%N:%l) be_visitor_union_discriminant_ch::"
121 "visit_typedef - "
122 "Bad primitive type\n"),
123 -1);
126 this->ctx_->alias (nullptr);
127 return 0;