Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / include / ast_interface.h
blob2be8cee24f346149f1778cece04285c045f392b4
1 // This may look like C, but it's really -*- C++ -*-
2 /*
4 COPYRIGHT
6 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
7 States of America. All Rights Reserved.
9 This product is protected by copyright and distributed under the following
10 license restricting its use.
12 The Interface Definition Language Compiler Front End (CFE) is made
13 available for your use provided that you include this license and copyright
14 notice on all media and documentation and the software program in which
15 this product is incorporated in whole or part. You may copy and extend
16 functionality (but may not remove functionality) of the Interface
17 Definition Language CFE without charge, but you are not authorized to
18 license or distribute it to anyone else except as part of a product or
19 program developed by you or with the express written consent of Sun
20 Microsystems, Inc. ("Sun").
22 The names of Sun Microsystems, Inc. and any of its subsidiaries or
23 affiliates may not be used in advertising or publicity pertaining to
24 distribution of Interface Definition Language CFE as permitted herein.
26 This license is effective until terminated by Sun for failure to comply
27 with this license. Upon termination, you shall destroy or return all code
28 and documentation for the Interface Definition Language CFE.
30 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
31 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
33 DEALING, USAGE OR TRADE PRACTICE.
35 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
36 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
37 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
39 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
40 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
41 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
43 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
44 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
45 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47 Use, duplication, or disclosure by the government is subject to
48 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
49 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
50 52.227-19.
52 Sun, Sun Microsystems and the Sun logo are trademarks or registered
53 trademarks of Sun Microsystems, Inc.
55 SunSoft, Inc.
56 2550 Garcia Avenue
57 Mountain View, California 94043
59 NOTE:
61 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
62 trademarks or registered trademarks of Sun Microsystems, Inc.
66 #ifndef _AST_INTERFACE_AST_INTERFACE_HH
67 #define _AST_INTERFACE_AST_INTERFACE_HH
69 // NOTE: add (AST_EnumValue *) is defined here because enums can
70 // be defined manifest locally; the constants defined in these
71 // enums are inserted in the enclosing scope.
73 #include "ast_type.h"
74 #include "utl_scope.h"
76 class TAO_IDL_FE_Export AST_Interface : public virtual AST_Type,
77 public virtual UTL_Scope
79 public:
80 AST_Interface (UTL_ScopedName *n,
81 AST_Type **ih,
82 long nih,
83 AST_Interface **ih_flat,
84 long nih_flat,
85 bool local,
86 bool abstract);
88 virtual ~AST_Interface (void);
90 // This serves for interfaces, value types, components, and eventtypes.
91 static void fwd_redefinition_helper (AST_Interface *&i,
92 UTL_Scope *s);
94 // Overridden for valuetypes, components, and eventtypes.
95 virtual void redefine (AST_Interface *from);
97 AST_Type **inherits (void) const;
99 long n_inherits (void) const;
101 AST_Interface **inherits_flat (void) const;
103 long n_inherits_flat (void) const;
105 ACE_Unbounded_Queue<AST_Type *> &get_insert_queue (void);
106 ACE_Unbounded_Queue<AST_Type *> &get_del_queue (void);
108 AST_Operation *be_add_operation (AST_Operation *);
110 void be_replace_operation (AST_Decl *old_op,
111 AST_Decl *new_op);
113 // Is this interface defined? This predicate returns FALSE when an
114 // interface was forward declared but not defined yet, and TRUE in
115 // all other cases.
116 bool is_defined (void);
118 // Check if we have redefined any of our parents' operations or attributes,
119 // and check if there is such a clash among the parents
120 bool redef_clash (void);
122 // Accessors for the member.
123 bool home_equiv (void) const;
124 void home_equiv (bool val);
126 // Accessors for the member.
127 AST_InterfaceFwd *fwd_decl (void) const;
128 void fwd_decl (AST_InterfaceFwd *node);
130 // Look through inherited interfaces.
131 virtual AST_Decl *look_in_inherited (UTL_ScopedName *e,
132 bool full_def_only);
134 AST_Decl *look_in_inherited_local (Identifier *e,
135 bool full_def_only = false);
137 /// Do we have both abstract and concrete parents?
138 int has_mixed_parentage (void);
140 /// Compute whether or not we have both abstract and concrete parents,
141 /// and make a list of the abstract parents, if any.
142 void analyze_parentage (void);
144 // Recursively called on valuetype to check for legal use as
145 // a primary key. Overridden for valuetype, struct, sequence,
146 // union, array, typedef, and interface.
147 virtual bool legal_for_primary_key (void) const;
149 virtual AST_Decl *special_lookup (UTL_ScopedName *e,
150 bool full_def_only,
151 AST_Decl *&final_parent_decl);
153 /// Accessors for the members.
154 AST_Interface *ami_handler (void) const;
155 void ami_handler (AST_Interface *handler);
156 AST_Interface *ami4ccm_uses (void) const;
157 void ami4ccm_uses (AST_Interface *implied);
159 // Cleanup function.
160 virtual void destroy (void);
162 // Narrowing.
164 DEF_NARROW_FROM_DECL(AST_Interface);
165 DEF_NARROW_FROM_SCOPE(AST_Interface);
167 // AST Dumping.
168 virtual void dump (ACE_OSTREAM_TYPE &o);
170 // Visiting.
171 virtual int ast_accept (ast_visitor *visitor);
173 static AST_Decl::NodeType const NT;
174 typedef AST_InterfaceFwd FWD_TYPE;
176 virtual bool annotatable () const;
178 protected:
179 // Data.
181 // Immediate ancestors.
182 AST_Type **pd_inherits;
183 long pd_n_inherits;
185 // All ancestors.
186 AST_Interface **pd_inherits_flat;
187 long pd_n_inherits_flat;
189 // Queue data structure needed for breadth-first traversal of
190 // inheritance tree.
191 ACE_Unbounded_Queue<AST_Type *> insert_queue;
193 // For a special case of a deeply nested inheritance graph and one specific
194 // way of inheritance in which a node that was already visited,
195 // but is not present in
196 // the queue, gets inserted at the tail. This situation arises when a node
197 // multiply inherits from two or more interfaces in which the first parent is
198 // higher up in the tree than the second parent. In addition, if the second
199 // parent turns out to be a child of the first .
201 // Queue of dequeued nodes to be searched for the above case.
202 ACE_Unbounded_Queue<AST_Type *> del_queue;
204 // Are we the equivalent interface of a home?
205 bool home_equiv_;
207 // The forward declaration we may have been created from.
208 AST_InterfaceFwd *fwd_decl_;
210 // Must keep these base interface placeholders in a separate
211 // container, so they can be destroyed. Iterating over
212 // pd_inherits won't work because the real interfaces will
213 // probably already be destroyed and the pointers will be
214 // garbage.
215 ACE_Unbounded_Queue<AST_Type *> param_holders_;
217 /// Do we have both abstract and concrete parents?
218 int has_mixed_parentage_;
220 /// Store here for quick retrieval without an AST lookup.
221 AST_Interface *ami_handler_;
222 AST_Interface *ami4ccm_uses_;
224 public:
225 // Scope Management Protocol.
227 virtual AST_Constant *fe_add_constant (AST_Constant *c);
229 virtual AST_Exception *fe_add_exception (AST_Exception *e);
231 virtual AST_Attribute *fe_add_attribute (AST_Attribute *a);
233 virtual AST_Operation *fe_add_operation (AST_Operation *o);
235 virtual AST_Union *fe_add_union (AST_Union *u);
237 virtual AST_Structure *fe_add_structure (AST_Structure *s);
239 virtual AST_UnionFwd *fe_add_union_fwd (AST_UnionFwd *u);
241 virtual AST_StructureFwd *fe_add_structure_fwd (AST_StructureFwd *s);
243 virtual AST_Enum *fe_add_enum (AST_Enum *e);
245 virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v);
247 virtual AST_Typedef *fe_add_typedef (AST_Typedef *t);
249 virtual AST_Native *fe_add_native (AST_Native *n);
251 protected:
252 // Lookup based on the local name, override of UTL_Scope definition.
253 // This version checks for redefinitions of attributes or operations.
254 AST_Decl *lookup_for_add (AST_Decl *d);
256 void redef_clash_populate_r (AST_Type *t);
257 // Populate the insert queue with our parents, and, if we are a
258 // valuetype, with our supported interface and our parents'
259 // supported interfaces.
261 int insert_non_dup (AST_Type *t,
262 bool abstract_paths_only = false);
263 // Do non-duplicating insert of bi, by searching both the
264 // insert queue and the delete queue.
267 #endif // _AST_INTERFACE_AST_INTERFACE_HH