Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_array / array.cpp
bloba64f84367e158ae5594592cbfd9bfc87b72888d1
2 //=============================================================================
3 /**
4 * @file array.cpp
6 * Generic visitor for code generation for Arrays
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "array.h"
14 be_visitor_array::be_visitor_array (be_visitor_context *ctx)
15 : be_visitor_decl (ctx)
19 be_visitor_array::~be_visitor_array ()
23 int be_visitor_array::visit_array (be_array *)
25 // Must be overloaded by derived visitors.
26 return -1;
29 int
30 be_visitor_array::visit_enum (be_enum *node)
32 return this->visit_node (node);
35 int
36 be_visitor_array::visit_interface (be_interface *node)
38 return this->emit_common (node);
41 int
42 be_visitor_array::visit_interface_fwd (be_interface_fwd *node)
44 return this->emit_common (node);
47 int
48 be_visitor_array::visit_valuebox (be_valuebox *node)
50 return this->emit_common (node);
53 int
54 be_visitor_array::visit_valuetype (be_valuetype *node)
56 return this->emit_common (node);
59 int
60 be_visitor_array::visit_valuetype_fwd (be_valuetype_fwd *node)
62 return this->emit_common (node);
65 int
66 be_visitor_array::visit_predefined_type (be_predefined_type *node)
68 TAO_OutStream *os = this->ctx_->stream ();
69 AST_PredefinedType::PredefinedType pt = node->pt ();
71 *os << "::";
73 if (pt == AST_PredefinedType::PT_pseudo
74 || pt == AST_PredefinedType::PT_object)
76 *os << node->name () << "_var";
78 else
80 *os << node->name ();
83 return 0;
86 int
87 be_visitor_array::visit_sequence (be_sequence *node)
89 return this->visit_node (node);
92 int
93 be_visitor_array::visit_string (be_string *node)
95 TAO_OutStream *os = this->ctx_->stream ();
97 if (node->width () == (long) sizeof (char))
99 *os << "::TAO::String_Manager";
101 else
103 *os << "::TAO::WString_Manager";
106 return 0;
110 be_visitor_array::visit_structure (be_structure *node)
112 return this->visit_node (node);
116 be_visitor_array::visit_union (be_union *node)
118 return this->visit_node (node);
122 be_visitor_array::visit_typedef (be_typedef *node)
124 TAO_OutStream *os = this->ctx_->stream ();
125 AST_Type *pbt = node->primitive_base_type ();
126 AST_Decl::NodeType nt = pbt->node_type ();
127 AST_PredefinedType::PredefinedType pt = AST_PredefinedType:: PT_void;
128 int result = 0;
130 // We check for these first, because in these cases, we replace the
131 // entire slice type with one of the strings below, instead of using
132 // the node's type name, possibly suffixed with '_var'.
133 if (nt == AST_Decl::NT_string)
135 *os << "::TAO::String_Manager";
137 return 0;
139 else if (nt == AST_Decl::NT_wstring)
141 *os << "::TAO::WString_Manager";
143 return 0;
146 result = this->visit_node (node);
148 if (nt == AST_Decl::NT_pre_defined)
150 AST_PredefinedType *pdt = dynamic_cast<AST_PredefinedType*> (pbt);
151 pt = pdt->pt ();
154 // We must append a "_var" for typedefs of interfaces, CORBA::Objects or
155 // typecodes.
156 if (nt == AST_Decl::NT_interface
157 || nt == AST_Decl::NT_interface_fwd
158 || pt == AST_PredefinedType::PT_pseudo
159 || pt == AST_PredefinedType::PT_object)
161 *os << "_var";
164 return result;
167 // helper
169 be_visitor_array::visit_node (be_type *node)
171 TAO_OutStream *os = this->ctx_->stream ();
172 be_type *bt = nullptr;
174 if (this->ctx_->alias ())
176 bt = this->ctx_->alias ();
178 else
180 bt = node;
183 if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH)
185 *os << bt->nested_type_name (this->ctx_->scope ()->decl ());
187 else
189 *os << bt->name ();
192 return 0;
196 be_visitor_array::emit_common (be_type *node)
198 TAO_OutStream *os = this->ctx_->stream ();
199 be_type *bt = nullptr;
201 if (this->ctx_->alias ())
203 bt = this->ctx_->alias ();
205 else
207 bt = node;
210 if (this->ctx_->state () == TAO_CodeGen::TAO_ARRAY_CH)
212 *os << bt->nested_type_name (this->ctx_->scope ()->decl (), "_var");
214 else
216 *os << bt->name () << "_var";
219 return 0;