2 //=============================================================================
4 * @file constant_cs.cpp
6 * Visitor for code generation of Constant code in the client stubs file.
8 * @author Aniruddha Gokhale
10 //=============================================================================
14 be_visitor_constant_cs::be_visitor_constant_cs (be_visitor_context
*ctx
)
15 : be_visitor_decl (ctx
)
19 be_visitor_constant_cs::~be_visitor_constant_cs ()
23 // visit the Constant_cs node and its scope
25 be_visitor_constant_cs::visit_constant (be_constant
*node
)
27 if (node
->cli_stub_gen ()
29 || !node
->is_nested ())
34 AST_Decl::NodeType snt
= node
->defined_in ()->scope_node_type ();
35 bool in_class
= (snt
!= AST_Decl::NT_root
36 && snt
!= AST_Decl::NT_module
);
37 if (be_global
->gen_inline_constants () && !in_class
)
39 // No storage is required in the source file for these
43 AST_Expression::ExprType etype
= node
->et ();
44 bool const forbidden_in_class
= (in_class
45 && (etype
== AST_Expression::EV_string
46 || etype
== AST_Expression::EV_wstring
47 || etype
== AST_Expression::EV_float
48 || etype
== AST_Expression::EV_double
49 || etype
== AST_Expression::EV_longdouble
));
51 TAO_OutStream
*os
= this->ctx_
->stream ();
53 TAO_INSERT_COMMENT (os
);
58 if (node
->et () == AST_Expression::EV_enum
)
60 *os
<< node
->enum_full_name ();
64 *os
<< exprtype_to_cpp_corba_type (node
->et ());
67 *os
<< " " << node
->name ();
68 if (!be_global
->gen_inline_constants () || forbidden_in_class
)
70 // For those constants not defined in the outermost scope,
71 // or in a module, they get assigned to their values in the source file.
72 *os
<< " = " << node
->constant_value ();
76 node
->cli_stub_gen (true);