2 //=============================================================================
6 * Extension of class AST_Enum that provides additional means for C++
9 * @author Copyright 1994-1995 by Sun Microsystems
10 * @author Inc. and Aniruddha Gokhale
12 //=============================================================================
15 #include "be_visitor.h"
16 #include "be_helper.h"
18 #include "global_extern.h"
20 be_enum::be_enum (UTL_ScopedName
*n
,
25 AST_Decl (AST_Decl::NT_enum
,
27 AST_Type (AST_Decl::NT_enum
,
29 AST_ConcreteType (AST_Decl::NT_enum
,
31 UTL_Scope (AST_Decl::NT_enum
),
35 be_scope (AST_Decl::NT_enum
),
36 be_decl (AST_Decl::NT_enum
,
38 be_type (AST_Decl::NT_enum
,
41 if (!this->imported ())
43 idl_global
->enum_seen_
= true;
44 idl_global
->fixed_size_decl_seen_
= true;
49 be_enum::gen_ostream_operator (TAO_OutStream
*os
,
50 bool /* use_underscore */)
53 << "std::ostream& operator<< (std::ostream &strm, const "
54 << this->name () << " _tao_enumerator)" << be_nl
56 << "switch (_tao_enumerator)" << be_idt_nl
59 // The enum's type name itself is not part of the scope of the
60 // enum values. If the enum is defined at global scope, this will
61 // produce an empty string when streamed to the output file.
62 UTL_ScopedName
*s
= ScopeAsDecl (this->defined_in ())->name ();
64 for (UTL_ScopeActiveIterator
i (this, IK_decls
); !i
.is_done (); i
.next ())
66 Identifier
*id
= i
.item ()->local_name ();
68 *os
<< "case " << s
<< "::" << id
69 << ": return strm << \"" << s
<< "::" << id
73 *os
<< "default: return strm;" << be_uidt_nl
74 << "}" << be_uidt
<< be_uidt_nl
79 be_enum::destroy (void)
81 // Call the destroy methods of our base classes.
82 // No need to call be_scope::destroy(). It has no
83 // allocated members, and AST_Enum::destroy() will
84 // call UTL_Scope::destroy().
85 this->be_type::destroy ();
86 this->be_scope::destroy ();
87 this->AST_Enum::destroy ();
91 be_enum::accept (be_visitor
*visitor
)
93 return visitor
->visit_enum (this);
98 IMPL_NARROW_FROM_DECL (be_enum
)
99 IMPL_NARROW_FROM_SCOPE (be_enum
)