Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / TAO_IDL / include / ast_structure.h
blob808afb32f83cff6935c60bd59a715f0fd9e91b19
1 /*
3 COPYRIGHT
5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
49 52.227-19.
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
54 SunSoft, Inc.
55 2550 Garcia Avenue
56 Mountain View, California 94043
58 NOTE:
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 #ifndef _AST_STRUCTURE_AST_STRUCTURE_HH
66 #define _AST_STRUCTURE_AST_STRUCTURE_HH
68 // Representation of structure:
70 // NOTE: add (AST_ConcreteType *) is defined here because a structure
71 // can contain locally defined types in addition to fields.
73 // NOTE: add (AST_EnumValue *) is defined here because enums can
74 // be defined manifest locally; the constants defined in these
75 // enums are inserted in the enclosing scope. It is unlikely that
76 // a BE writer will need to overload this function in AST_Structure.
78 #include "ast_concrete_type.h"
79 #include "utl_scope.h"
80 #include "ace/Unbounded_Queue.h"
82 class TAO_IDL_FE_Export AST_Structure
83 : public virtual AST_ConcreteType,
84 public virtual UTL_Scope
86 public:
87 AST_Structure (UTL_ScopedName *n,
88 bool local,
89 bool abstract);
91 AST_Structure (AST_Decl::NodeType nt,
92 UTL_ScopedName *n,
93 bool local,
94 bool abstract);
96 virtual ~AST_Structure ();
98 // This serves for both structs and unions.
99 static void fwd_redefinition_helper (AST_Structure *&i,
100 UTL_Scope *s);
102 // Overridden for unions.
103 virtual void redefine (AST_Structure *from);
105 virtual int member_count ();
106 // Return the count of members.
108 virtual ACE_CDR::ULong nfields () const;
109 // Return the count of actual fields.
111 virtual int field (AST_Field **&result,
112 ACE_CDR::ULong slot) const;
113 // Get an individual field node.
115 virtual bool is_local ();
116 // Overwrite the is_local method.
118 virtual bool in_recursion (ACE_Unbounded_Queue<AST_Type *> &list);
119 // Are we or the node represented by node involved in recursion.
121 virtual int contains_wstring ();
122 // Do we contain a wstring at some nesting level?
124 // Is this struct or union defined? This predicate returns FALSE when a
125 // forward declaration is not defined yet, and TRUE in
126 // all other cases.
127 virtual bool is_defined ();
129 // Recursively called on valuetype to check for legal use as
130 // a primary key. Overridden for valuetype, struct, sequence,
131 // union, array, typedef, and interface.
132 virtual bool legal_for_primary_key () const;
134 // Accessors for the member.
135 AST_StructureFwd *fwd_decl () const;
136 void fwd_decl (AST_StructureFwd *node);
138 // AST Dumping.
139 virtual void dump (ACE_OSTREAM_TYPE &o);
141 // Cleanup function.
142 virtual void destroy ();
144 // Visiting.
145 virtual int ast_accept (ast_visitor *visitor);
147 // Accessor for the member.
148 ACE_Unbounded_Queue<AST_Field *> &fields ();
150 static AST_Decl::NodeType const NT;
152 virtual bool annotatable () const;
154 virtual AST_Field *fe_add_field (AST_Field *f);
156 /// Easy Member Access
157 ///{
158 virtual AST_Decl *operator[] (const size_t index);
159 virtual AST_Decl *operator[] (const char* name);
160 ///}
162 protected:
163 friend int tao_yyparse ();
164 // Scope Management Protocol.
166 virtual AST_Union *fe_add_union (AST_Union *u);
168 virtual AST_Structure *fe_add_structure (AST_Structure *s);
170 virtual AST_Enum *fe_add_enum (AST_Enum *e);
172 virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v);
174 virtual int compute_size_type ();
175 // Compute the size type if it is unknown.
177 ACE_Unbounded_Queue<AST_Field *> fields_;
178 // Container for this struct's field nodes. Excludes nodes included
179 // in member_count, i.e., enum values of an enum declared inside
180 // the struct.
182 private:
183 int compute_member_count ();
184 // Count the number of members.
186 int member_count_;
187 // Number of members.
189 int local_struct_;
190 // We also need to determine whether we contain any local type.
192 AST_StructureFwd *fwd_decl_;
193 // The forward declaration we may have been created from.
196 #endif // _AST_STRUCTURE_AST_STRUCTURE_HH