2 //=============================================================================
6 * Extension of class AST_Decl that provides additional means for C++
9 * @author Copyright 1994-1995 by Sun Microsystems
10 * @author Inc. and Aniruddha Gokhale
12 //=============================================================================
16 #include "be_interface.h"
17 #include "be_interface_fwd.h"
18 #include "be_valuetype.h"
19 #include "be_component.h"
20 #include "be_eventtype.h"
22 #include "be_module.h"
24 #include "be_exception.h"
25 #include "be_structure.h"
28 #include "be_operation.h"
29 #include "be_factory.h"
30 #include "be_finder.h"
31 #include "be_sequence.h"
32 #include "be_visitor.h"
34 #include "ast_structure_fwd.h"
35 #include "ast_typedef.h"
36 #include "ast_string.h"
38 #include "utl_identifier.h"
40 #include "global_extern.h"
41 #include "ace/Log_Msg.h"
42 #include "ace/String_Base.h"
44 be_decl::be_decl (AST_Decl::NodeType type
,
50 cli_stub_gen_ (false),
51 cli_inline_gen_ (false),
53 impl_hdr_gen_ (false),
54 srv_skel_gen_ (false),
55 impl_skel_gen_ (false),
56 srv_inline_gen_ (false),
57 tie_skel_gen_ (false),
58 cli_hdr_any_op_gen_ (false),
59 cli_stub_any_op_gen_ (false),
60 cli_hdr_cdr_op_gen_ (false),
61 cli_stub_cdr_op_gen_ (false),
62 cli_inline_cdr_op_gen_ (false),
63 cli_inline_cdr_decl_gen_ (false),
64 cli_traits_gen_ (false),
65 cli_arg_traits_gen_ (false),
66 srv_arg_traits_gen_ (false),
67 srv_sarg_traits_gen_ (false),
68 cli_pragma_inst_gen_ (false),
69 cli_inarg_tmpl_class_gen_ (false),
70 cli_inarg_pragma_inst_gen_ (false),
71 cli_inoutarg_tmpl_class_gen_ (false),
72 cli_inoutarg_pragma_inst_gen_ (false),
73 cli_outarg_tmpl_class_gen_ (false),
74 cli_outarg_pragma_inst_gen_ (false),
75 cli_retarg_tmpl_class_gen_ (false),
76 cli_retarg_pragma_inst_gen_ (false),
77 srv_tmpl_class_gen_ (false),
78 srv_pragma_inst_gen_ (false),
79 srv_inarg_tmpl_class_gen_ (false),
80 srv_inarg_pragma_inst_gen_ (false),
81 srv_inoutarg_tmpl_class_gen_ (false),
82 srv_inoutarg_pragma_inst_gen_ (false),
83 srv_outarg_tmpl_class_gen_ (false),
84 srv_outarg_pragma_inst_gen_ (false),
85 srv_retarg_tmpl_class_gen_ (false),
86 srv_retarg_pragma_inst_gen_ (false),
87 ccm_pre_proc_gen_ (false),
88 ex_idl_facet_gen_ (false),
89 svnt_hdr_facet_gen_ (false),
90 svnt_src_facet_gen_ (false),
91 exec_hdr_facet_gen_ (false),
92 exec_src_facet_gen_ (false),
93 ami4ccm_ex_idl_gen_ (false)
97 be_decl::~be_decl (void)
102 be_decl::compute_full_name (const char *prefix
,
106 if (prefix
== 0 || suffix
== 0)
111 ACE_CString
prefix_str (prefix
);
112 ACE_CString
suffix_str (suffix
);
113 ACE_CString result_str
;
116 if (this->defined_in () == 0)
121 result_str
= prefix_str
;
124 result_str
+= ACE_CString (this->local_name ()->get_string ());
127 result_str
+= suffix_str
;
132 be_decl
* const parent
=
133 dynamic_cast<be_scope
*> (this->defined_in ())->decl ();
137 ACE_ERROR ((LM_ERROR
,
139 "compute_full_name - "
140 "scope name is nil\n"));
146 result_str
= ACE_CString (parent
->full_name ());
149 if (ACE_OS::strcmp (parent
->full_name (), "") != 0)
151 result_str
+= ACE_CString ("::");
155 result_str
+= prefix_str
;
158 result_str
+= ACE_CString (this->local_name ()->get_string ());
161 result_str
+= suffix_str
;
164 name
= ACE_OS::strdup (result_str
.fast_rep ());
168 be_decl::compute_flat_name (const char *prefix
,
172 if (prefix
== 0 || suffix
== 0)
177 ACE_CString
prefix_str (prefix
);
178 ACE_CString
suffix_str (suffix
);
180 ACE_CString result_str
;
183 if (this->defined_in () == 0)
188 result_str
= prefix_str
;
190 // Local name. Leave out _cxx_ prefix, if any.
193 this->original_local_name ()->get_string ());
196 result_str
+= suffix_str
;
201 be_decl
* const parent
=
202 dynamic_cast<be_scope
*> (this->defined_in ())->decl ();
205 ACE_ERROR ((LM_ERROR
,
207 "compute_flat_name - "
208 "scope name is nil\n"));
214 result_str
= ACE_CString (parent
->flat_name ());
217 if (ACE_OS::strcmp (parent
->flat_name (), "") != 0)
221 result_str
+= prefix_str
;
223 // Local name. Leave out _cxx_ prefix, if any.
226 this->original_local_name ()->get_string ());
229 result_str
+= suffix_str
;
232 name
= ACE_OS::strdup (result_str
.c_str ());
236 be_decl::destroy (void)
241 be_decl::set_local (bool val
)
243 this->is_local_
= val
;
246 // Return the scope created by this node (if one exists, else NULL).
248 be_decl::scope (void)
252 switch (this->node_type ())
254 case AST_Decl::NT_interface_fwd
:
255 // Resolve forward declared interface by looking at full_definition()
256 // field and iterating.
258 dynamic_cast<be_interface
*> (
259 (dynamic_cast<be_interface_fwd
*> (this))->full_definition ()
262 case AST_Decl::NT_interface
:
263 return dynamic_cast<be_interface
*> (d
);
264 case AST_Decl::NT_module
:
265 return dynamic_cast<be_module
*> (d
);
266 case AST_Decl::NT_root
:
267 return dynamic_cast<be_root
*> (d
);
268 case AST_Decl::NT_except
:
269 return dynamic_cast<be_exception
*> (d
);
270 case AST_Decl::NT_union
:
271 return dynamic_cast<be_union
*> (d
);
272 case AST_Decl::NT_struct
:
273 return dynamic_cast<be_structure
*> (d
);
274 case AST_Decl::NT_enum
:
275 return dynamic_cast<be_enum
*> (d
);
276 case AST_Decl::NT_op
:
277 return dynamic_cast<be_operation
*> (d
);
278 case AST_Decl::NT_factory
:
279 return dynamic_cast<be_factory
*> (d
);
280 case AST_Decl::NT_finder
:
281 return dynamic_cast<be_finder
*> (d
);
282 case AST_Decl::NT_sequence
:
283 return dynamic_cast<be_sequence
*> (d
);
284 case AST_Decl::NT_valuetype
:
285 return dynamic_cast<be_valuetype
*> (d
);
286 case AST_Decl::NT_component
:
287 return dynamic_cast<be_component
*> (d
);
288 case AST_Decl::NT_eventtype
:
289 return dynamic_cast<be_eventtype
*> (d
);
290 case AST_Decl::NT_home
:
291 return dynamic_cast<be_home
*> (d
);
297 // Boolean methods to test if code was already generated.
299 be_decl::cli_hdr_gen (void)
301 return this->cli_hdr_gen_
;
305 be_decl::cli_stub_gen (void)
307 return this->cli_stub_gen_
;
311 be_decl::cli_hdr_any_op_gen (void)
313 return this->cli_hdr_any_op_gen_
;
317 be_decl::cli_stub_any_op_gen (void)
319 return this->cli_stub_any_op_gen_
;
323 be_decl::cli_hdr_cdr_op_gen (void)
325 return this->cli_hdr_cdr_op_gen_
;
329 be_decl::cli_stub_cdr_op_gen (void)
331 return this->cli_stub_cdr_op_gen_
;
335 be_decl::cli_inline_cdr_op_gen (void)
337 return this->cli_inline_cdr_op_gen_
;
341 be_decl::cli_inline_cdr_decl_gen (void)
343 return this->cli_inline_cdr_decl_gen_
;
347 be_decl::cli_traits_gen (void)
349 return this->cli_traits_gen_
;
353 be_decl::cli_arg_traits_gen (void)
355 return this->cli_arg_traits_gen_
;
359 be_decl::srv_arg_traits_gen (void)
361 return this->srv_arg_traits_gen_
;
365 be_decl::srv_sarg_traits_gen (void)
367 return this->srv_sarg_traits_gen_
;
371 be_decl::cli_pragma_inst_gen (void)
373 return this->cli_pragma_inst_gen_
;
377 be_decl::cli_inarg_tmpl_class_gen (void)
379 return this->cli_inarg_tmpl_class_gen_
;
383 be_decl::cli_inarg_pragma_inst_gen (void)
385 return this->cli_inarg_pragma_inst_gen_
;
389 be_decl::cli_inoutarg_tmpl_class_gen (void)
391 return this->cli_inoutarg_tmpl_class_gen_
;
395 be_decl::cli_inoutarg_pragma_inst_gen (void)
397 return this->cli_inoutarg_pragma_inst_gen_
;
401 be_decl::cli_outarg_tmpl_class_gen (void)
403 return this->cli_outarg_tmpl_class_gen_
;
407 be_decl::cli_outarg_pragma_inst_gen (void)
409 return this->cli_outarg_pragma_inst_gen_
;
413 be_decl::cli_retarg_tmpl_class_gen (void)
415 return this->cli_retarg_tmpl_class_gen_
;
419 be_decl::cli_retarg_pragma_inst_gen (void)
421 return this->cli_retarg_pragma_inst_gen_
;
425 be_decl::srv_tmpl_class_gen (void)
427 return this->srv_tmpl_class_gen_
;
431 be_decl::srv_pragma_inst_gen (void)
433 return this->srv_pragma_inst_gen_
;
437 be_decl::srv_inarg_tmpl_class_gen (void)
439 return this->srv_inarg_tmpl_class_gen_
;
443 be_decl::srv_inarg_pragma_inst_gen (void)
445 return this->srv_inarg_pragma_inst_gen_
;
449 be_decl::srv_inoutarg_tmpl_class_gen (void)
451 return this->srv_inoutarg_tmpl_class_gen_
;
455 be_decl::srv_inoutarg_pragma_inst_gen (void)
457 return this->srv_inoutarg_pragma_inst_gen_
;
461 be_decl::srv_outarg_tmpl_class_gen (void)
463 return this->srv_outarg_tmpl_class_gen_
;
467 be_decl::srv_outarg_pragma_inst_gen (void)
469 return this->srv_outarg_pragma_inst_gen_
;
473 be_decl::srv_retarg_tmpl_class_gen (void)
475 return this->srv_retarg_tmpl_class_gen_
;
479 be_decl::srv_retarg_pragma_inst_gen (void)
481 return this->cli_retarg_pragma_inst_gen_
;
485 be_decl::cli_inline_gen (void)
487 return this->cli_inline_gen_
;
491 be_decl::srv_hdr_gen (void)
493 return this->srv_hdr_gen_
;
497 be_decl::impl_hdr_gen (void)
499 return this->impl_hdr_gen_
;
503 be_decl::srv_skel_gen (void)
505 return this->srv_skel_gen_
;
509 be_decl::impl_skel_gen (void)
511 return this->impl_skel_gen_
;
515 be_decl::srv_inline_gen (void)
517 return this->srv_inline_gen_
;
521 be_decl::tie_skel_gen (void)
523 return this->tie_skel_gen_
;
527 be_decl::ccm_pre_proc_gen (void)
529 return this->ccm_pre_proc_gen_
;
533 be_decl::ex_idl_facet_gen (void)
535 return this->ex_idl_facet_gen_
;
539 be_decl::svnt_hdr_facet_gen (void)
541 return this->svnt_hdr_facet_gen_
;
545 be_decl::svnt_src_facet_gen (void)
547 return this->svnt_src_facet_gen_
;
551 be_decl::exec_hdr_facet_gen (void)
553 return this->exec_hdr_facet_gen_
;
557 be_decl::exec_src_facet_gen (void)
559 return this->exec_src_facet_gen_
;
563 be_decl::ami4ccm_ex_idl_gen (void)
565 return this->ami4ccm_ex_idl_gen_
;
568 // Set the flag indicating that code generation is done.
570 be_decl::cli_hdr_gen (bool val
)
572 this->cli_hdr_gen_
= val
;
576 be_decl::cli_stub_gen (bool val
)
578 this->cli_stub_gen_
= val
;
582 be_decl::cli_hdr_any_op_gen (bool val
)
584 this->cli_hdr_any_op_gen_
= val
;
588 be_decl::cli_stub_any_op_gen (bool val
)
590 this->cli_stub_any_op_gen_
= val
;
594 be_decl::cli_hdr_cdr_op_gen (bool val
)
596 this->cli_hdr_cdr_op_gen_
= val
;
600 be_decl::cli_stub_cdr_op_gen (bool val
)
602 this->cli_stub_cdr_op_gen_
= val
;
606 be_decl::cli_inline_cdr_op_gen (bool val
)
608 this->cli_inline_cdr_op_gen_
= val
;
612 be_decl::cli_inline_cdr_decl_gen (bool val
)
614 this->cli_inline_cdr_decl_gen_
= val
;
618 be_decl::cli_inline_gen (bool val
)
620 this->cli_inline_gen_
= val
;
624 be_decl::cli_traits_gen (bool val
)
626 this->cli_traits_gen_
= val
;
630 be_decl::cli_arg_traits_gen (bool val
)
632 this->cli_arg_traits_gen_
= val
;
636 be_decl::srv_arg_traits_gen (bool val
)
638 this->srv_arg_traits_gen_
= val
;
642 be_decl::srv_sarg_traits_gen (bool val
)
644 this->srv_sarg_traits_gen_
= val
;
648 be_decl::cli_pragma_inst_gen (bool val
)
650 this->cli_pragma_inst_gen_
= val
;
654 be_decl::cli_inarg_tmpl_class_gen (bool val
)
656 this->cli_inarg_tmpl_class_gen_
= val
;
660 be_decl::cli_inarg_pragma_inst_gen (bool val
)
662 this->cli_inarg_pragma_inst_gen_
= val
;
666 be_decl::cli_inoutarg_tmpl_class_gen (bool val
)
668 this->cli_inoutarg_tmpl_class_gen_
= val
;
672 be_decl::cli_inoutarg_pragma_inst_gen (bool val
)
674 this->cli_inoutarg_pragma_inst_gen_
= val
;
678 be_decl::cli_outarg_tmpl_class_gen (bool val
)
680 this->cli_outarg_tmpl_class_gen_
= val
;
684 be_decl::cli_outarg_pragma_inst_gen (bool val
)
686 this->cli_outarg_pragma_inst_gen_
= val
;
690 be_decl::cli_retarg_tmpl_class_gen (bool val
)
692 this->cli_retarg_tmpl_class_gen_
= val
;
696 be_decl::cli_retarg_pragma_inst_gen (bool val
)
698 this->cli_retarg_pragma_inst_gen_
= val
;
702 be_decl::srv_tmpl_class_gen (bool val
)
704 this->srv_tmpl_class_gen_
= val
;
708 be_decl::srv_pragma_inst_gen (bool val
)
710 this->srv_pragma_inst_gen_
= val
;
714 be_decl::srv_inarg_tmpl_class_gen (bool val
)
716 this->srv_inarg_tmpl_class_gen_
= val
;
720 be_decl::srv_inarg_pragma_inst_gen (bool val
)
722 this->srv_inarg_pragma_inst_gen_
= val
;
726 be_decl::srv_inoutarg_tmpl_class_gen (bool val
)
728 this->srv_inoutarg_tmpl_class_gen_
= val
;
732 be_decl::srv_inoutarg_pragma_inst_gen (bool val
)
734 this->srv_inoutarg_pragma_inst_gen_
= val
;
738 be_decl::srv_outarg_tmpl_class_gen (bool val
)
740 this->srv_outarg_tmpl_class_gen_
= val
;
744 be_decl::srv_outarg_pragma_inst_gen (bool val
)
746 this->srv_outarg_pragma_inst_gen_
= val
;
750 be_decl::srv_retarg_tmpl_class_gen (bool val
)
752 this->srv_retarg_tmpl_class_gen_
= val
;
756 be_decl::srv_retarg_pragma_inst_gen (bool val
)
758 this->srv_retarg_pragma_inst_gen_
= val
;
762 be_decl::srv_hdr_gen (bool val
)
764 this->srv_hdr_gen_
= val
;
768 be_decl::impl_hdr_gen (bool val
)
770 this->impl_hdr_gen_
= val
;
775 be_decl::srv_skel_gen (bool val
)
777 this->srv_skel_gen_
= val
;
781 be_decl::srv_inline_gen (bool val
)
783 this->srv_inline_gen_
= val
;
787 be_decl::tie_skel_gen (bool val
)
789 this->tie_skel_gen_
= val
;
793 be_decl::ccm_pre_proc_gen (bool val
)
795 this->ccm_pre_proc_gen_
= val
;
799 be_decl::ex_idl_facet_gen (bool val
)
801 this->ex_idl_facet_gen_
= val
;
805 be_decl::svnt_hdr_facet_gen (bool val
)
807 this->svnt_hdr_facet_gen_
= val
;
811 be_decl::svnt_src_facet_gen (bool val
)
813 this->svnt_src_facet_gen_
= val
;
817 be_decl::exec_hdr_facet_gen (bool val
)
819 this->exec_hdr_facet_gen_
= val
;
823 be_decl::exec_src_facet_gen (bool val
)
825 this->exec_src_facet_gen_
= val
;
829 be_decl::ami4ccm_ex_idl_gen (bool val
)
831 this->ami4ccm_ex_idl_gen_
= val
;
834 //==========================================
837 be_decl::accept (be_visitor
*visitor
)
839 return visitor
->visit_decl (this);
844 IMPL_NARROW_FROM_DECL (be_decl
)