2 //=============================================================================
4 * @file be_visitor_context.cpp
6 * Maintains the context information for visitors
8 * @author Aniruddha Gokhale
10 //=============================================================================
12 #include "be_visitor_context.h"
13 #include "be_extern.h"
14 #include "be_helper.h"
16 be_visitor_context::be_visitor_context (void)
17 : ast_visitor_context (),
18 state_ (TAO_CodeGen::TAO_INITIAL
),
19 sub_state_ (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN
),
32 be_visitor_context::be_visitor_context (const be_visitor_context
&ctx
)
33 : ast_visitor_context (ctx
),
35 sub_state_ (ctx
.sub_state_
),
42 exception_ (ctx
.exception_
),
44 interface_ (ctx
.interface_
),
45 port_prefix_ (ctx
.port_prefix_
)
50 be_visitor_context::operator= (const be_visitor_context
&ctx
)
52 this->state_
= ctx
.state_
;
53 this->sub_state_
= ctx
.sub_state_
;
55 this->scope_
= ctx
.scope_
;
56 this->node_
= ctx
.node_
;
57 this->alias_
= ctx
.alias_
;
58 this->tdef_
= ctx
.tdef_
;
59 this->attr_
= ctx
.attr_
;
60 this->exception_
= ctx
.exception_
;
61 this->comma_
= ctx
.comma_
;
62 this->interface_
= ctx
.interface_
;
63 this->template_args_
= ctx
.template_args_
;
64 this->template_params_
= ctx
.template_params_
;
65 this->port_prefix_
= ctx
.port_prefix_
;
70 be_visitor_context::~be_visitor_context (void)
72 // We do not own anything.
78 be_visitor_context::reset (void)
80 this->state_
= TAO_CodeGen::TAO_INITIAL
;
81 this->sub_state_
= TAO_CodeGen::TAO_SUB_STATE_UNKNOWN
;
91 this->template_args_
= 0;
92 this->template_params_
= 0;
93 this->port_prefix_
= "";
97 be_visitor_context::stream (TAO_OutStream
*os
)
103 be_visitor_context::stream (void)
105 static TAO_OutStream null_stream
;
106 return os_
? os_
: &null_stream
;
110 be_visitor_context::scope (be_scope
*s
)
116 be_visitor_context::scope (void)
122 be_visitor_context::node (be_decl
*n
)
128 be_visitor_context::node (void)
134 be_visitor_context::state (TAO_CodeGen::CG_STATE st
)
139 TAO_CodeGen::CG_STATE
140 be_visitor_context::state (void)
146 be_visitor_context::sub_state (TAO_CodeGen::CG_SUB_STATE st
)
148 this->sub_state_
= st
;
151 TAO_CodeGen::CG_SUB_STATE
152 be_visitor_context::sub_state (void)
154 return this->sub_state_
;
158 be_visitor_context::tdef (be_typedef
*node
)
164 be_visitor_context::tdef (void)
170 be_visitor_context::alias (be_typedef
*node
)
176 be_visitor_context::alias (void)
182 be_visitor_context::attribute (be_attribute
*node
)
188 be_visitor_context::attribute (void)
194 be_visitor_context::exception (bool ib
)
196 this->exception_
= ib
;
200 be_visitor_context::exception (void)
202 return this->exception_
;
206 be_visitor_context::comma (bool ib
)
212 be_visitor_context::comma (void)
218 be_visitor_context::interface (be_interface
*interface
)
220 this->interface_
= interface
;
224 be_visitor_context::interface (void) const
226 return this->interface_
;
230 be_visitor_context::port_prefix (void)
232 return this->port_prefix_
;
236 be_visitor_context::export_macro (void) const
238 switch (this->state_
)
240 // If -GA is used, but the anyop macro hasn't been set,
241 // default to the stub macro.
242 case TAO_CodeGen::TAO_ROOT_ANY_OP_CH
:
243 return (be_global
->gen_anyop_files ()
244 ? this->non_null_export_macro ()
245 : be_global
->stub_export_macro ());
246 case TAO_CodeGen::TAO_ARRAY_CH
:
247 case TAO_CodeGen::TAO_INTERFACE_CH
:
248 case TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH
:
249 case TAO_CodeGen::TAO_ROOT_CH
:
250 return be_global
->stub_export_macro ();
251 case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH
:
252 case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH
:
253 case TAO_CodeGen::TAO_ROOT_SH
:
254 return be_global
->skel_export_macro ();
261 be_visitor_context::non_null_export_macro (void) const
263 const char *anyop_export
= be_global
->anyop_export_macro ();
265 return (ACE_OS::strcmp (anyop_export
, "") == 0
266 ? be_global
->stub_export_macro ()