Merge pull request #2303 from jwillemsen/jwi-803
[ACE_TAO.git] / TAO / TAO_IDL / include / ast_interface.h
blob1cc3c60b556c4f47560152e0d681a77aa06afa18
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_INTERFACE_AST_INTERFACE_HH
66 #define _AST_INTERFACE_AST_INTERFACE_HH
68 // NOTE: add (AST_EnumValue *) is defined here because enums can
69 // be defined manifest locally; the constants defined in these
70 // enums are inserted in the enclosing scope.
72 #include "ast_type.h"
73 #include "utl_scope.h"
75 class TAO_IDL_FE_Export AST_Interface : public virtual AST_Type,
76 public virtual UTL_Scope
78 public:
79 AST_Interface (UTL_ScopedName *n,
80 AST_Type **ih,
81 long nih,
82 AST_Interface **ih_flat,
83 long nih_flat,
84 bool local,
85 bool abstract);
87 virtual ~AST_Interface ();
89 // This serves for interfaces, value types, components, and eventtypes.
90 static void fwd_redefinition_helper (AST_Interface *&i,
91 UTL_Scope *s);
93 // Overridden for valuetypes, components, and eventtypes.
94 virtual void redefine (AST_Interface *from);
96 AST_Type **inherits () const;
98 long n_inherits () const;
100 AST_Interface **inherits_flat () const;
102 long n_inherits_flat () const;
104 ACE_Unbounded_Queue<AST_Type *> &get_insert_queue ();
105 ACE_Unbounded_Queue<AST_Type *> &get_del_queue ();
107 AST_Operation *be_add_operation (AST_Operation *);
109 void be_replace_operation (AST_Decl *old_op,
110 AST_Decl *new_op);
112 // Is this interface defined? This predicate returns FALSE when an
113 // interface was forward declared but not defined yet, and TRUE in
114 // all other cases.
115 bool is_defined ();
117 // Check if we have redefined any of our parents' operations or attributes,
118 // and check if there is such a clash among the parents
119 bool redef_clash ();
121 // Accessors for the member.
122 bool home_equiv () const;
123 void home_equiv (bool val);
125 // Accessors for the member.
126 AST_InterfaceFwd *fwd_decl () const;
127 void fwd_decl (AST_InterfaceFwd *node);
129 // Look through inherited interfaces.
130 virtual AST_Decl *look_in_inherited (UTL_ScopedName *e,
131 bool full_def_only);
133 AST_Decl *look_in_inherited_local (Identifier *e,
134 bool full_def_only = false);
136 /// Do we have both abstract and concrete parents?
137 int has_mixed_parentage ();
139 /// Compute whether or not we have both abstract and concrete parents,
140 /// and make a list of the abstract parents, if any.
141 void analyze_parentage ();
143 // Recursively called on valuetype to check for legal use as
144 // a primary key. Overridden for valuetype, struct, sequence,
145 // union, array, typedef, and interface.
146 virtual bool legal_for_primary_key () const;
148 virtual AST_Decl *special_lookup (UTL_ScopedName *e,
149 bool full_def_only,
150 AST_Decl *&final_parent_decl);
152 /// Accessors for the members.
153 AST_Interface *ami_handler () const;
154 void ami_handler (AST_Interface *handler);
155 AST_Interface *ami4ccm_uses () const;
156 void ami4ccm_uses (AST_Interface *implied);
158 // Cleanup function.
159 virtual void destroy ();
161 // AST Dumping.
162 virtual void dump (ACE_OSTREAM_TYPE &o);
164 // Visiting.
165 virtual int ast_accept (ast_visitor *visitor);
167 static AST_Decl::NodeType const NT;
168 typedef AST_InterfaceFwd FWD_TYPE;
170 virtual bool annotatable () const;
172 protected:
173 // Data.
175 // Immediate ancestors.
176 AST_Type **pd_inherits;
177 long pd_n_inherits;
179 // All ancestors.
180 AST_Interface **pd_inherits_flat;
181 long pd_n_inherits_flat;
183 // Queue data structure needed for breadth-first traversal of
184 // inheritance tree.
185 ACE_Unbounded_Queue<AST_Type *> insert_queue;
187 // For a special case of a deeply nested inheritance graph and one specific
188 // way of inheritance in which a node that was already visited,
189 // but is not present in
190 // the queue, gets inserted at the tail. This situation arises when a node
191 // multiply inherits from two or more interfaces in which the first parent is
192 // higher up in the tree than the second parent. In addition, if the second
193 // parent turns out to be a child of the first .
195 // Queue of dequeued nodes to be searched for the above case.
196 ACE_Unbounded_Queue<AST_Type *> del_queue;
198 // Are we the equivalent interface of a home?
199 bool home_equiv_;
201 // The forward declaration we may have been created from.
202 AST_InterfaceFwd *fwd_decl_;
204 // Must keep these base interface placeholders in a separate
205 // container, so they can be destroyed. Iterating over
206 // pd_inherits won't work because the real interfaces will
207 // probably already be destroyed and the pointers will be
208 // garbage.
209 ACE_Unbounded_Queue<AST_Type *> param_holders_;
211 /// Do we have both abstract and concrete parents?
212 int has_mixed_parentage_;
214 /// Store here for quick retrieval without an AST lookup.
215 AST_Interface *ami_handler_;
216 AST_Interface *ami4ccm_uses_;
218 public:
219 // Scope Management Protocol.
221 virtual AST_Constant *fe_add_constant (AST_Constant *c);
223 virtual AST_Exception *fe_add_exception (AST_Exception *e);
225 virtual AST_Attribute *fe_add_attribute (AST_Attribute *a);
227 virtual AST_Operation *fe_add_operation (AST_Operation *o);
229 virtual AST_Union *fe_add_union (AST_Union *u);
231 virtual AST_Structure *fe_add_structure (AST_Structure *s);
233 virtual AST_UnionFwd *fe_add_union_fwd (AST_UnionFwd *u);
235 virtual AST_StructureFwd *fe_add_structure_fwd (AST_StructureFwd *s);
237 virtual AST_Enum *fe_add_enum (AST_Enum *e);
239 virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v);
241 virtual AST_Typedef *fe_add_typedef (AST_Typedef *t);
243 virtual AST_Native *fe_add_native (AST_Native *n);
245 protected:
246 // Lookup based on the local name, override of UTL_Scope definition.
247 // This version checks for redefinitions of attributes or operations.
248 AST_Decl *lookup_for_add (AST_Decl *d);
250 void redef_clash_populate_r (AST_Type *t);
251 // Populate the insert queue with our parents, and, if we are a
252 // valuetype, with our supported interface and our parents'
253 // supported interfaces.
255 int insert_non_dup (AST_Type *t,
256 bool abstract_paths_only = false);
257 // Do non-duplicating insert of bi, by searching both the
258 // insert queue and the delete queue.
261 #endif // _AST_INTERFACE_AST_INTERFACE_HH