Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_root.cpp
blob220b85babc3965d7122b89d00576eaf8fed6df03
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 // AST_Root nodes represent the roots of ASTs.
66 // AST_Root is a subclass of AST_Module, and is defined to allow BEs
67 // to subclass it to associate their own information with an entire
68 // AST.
70 #include "ast_root.h"
71 #include "ast_sequence.h"
72 #include "ast_string.h"
73 #include "ast_array.h"
74 #include "ast_visitor.h"
75 #include "utl_identifier.h"
76 #include "ace/OS_NS_string.h"
77 #include "ace/OS_Memory.h"
79 AST_Decl::NodeType const
80 AST_Root::NT = AST_Decl::NT_root;
82 AST_Root::AST_Root (UTL_ScopedName *n)
83 : COMMON_Base (),
84 AST_Decl (AST_Decl::NT_root,
85 n),
86 UTL_Scope (AST_Decl::NT_root),
87 AST_Module (n)
91 AST_Root::~AST_Root (void)
95 // Overrides the one in UTL_Scope - this one doesn't
96 // count the predefined types.
97 unsigned long
98 AST_Root::nmembers (void)
100 unsigned long retval = 0;
102 for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
103 !si.is_done ();
104 si.next ())
106 if (si.item ()->node_type () == AST_Decl::NT_pre_defined)
108 continue;
111 ++retval;
114 return retval;
117 // Add this AST_Sequence to the locally defined types in this scope.
118 AST_Sequence *
119 AST_Root::fe_add_sequence (AST_Sequence *t)
121 if (t == 0)
123 return 0;
126 this->add_to_local_types (t);
127 return t;
130 // Add this AST_String to the locally defined types in this scope.
131 AST_String *
132 AST_Root::fe_add_string (AST_String *t)
134 if (t == 0)
136 return 0;
139 this->add_to_local_types (t);
140 return t;
143 // Add this AST_Array to the locally defined types in this scope.
144 AST_Array *
145 AST_Root::fe_add_array (AST_Array *t)
147 if (t == 0)
149 return 0;
152 this->add_to_local_types (t);
153 return t;
156 // Redefinition of inherited virtual operations.
158 // Dump this AST_Root node to the ostream o.
159 void
160 AST_Root::dump (ACE_OSTREAM_TYPE &o)
162 UTL_Scope::dump (o);
166 AST_Root::ast_accept (ast_visitor *visitor)
168 return visitor->visit_root (this);
171 void
172 AST_Root::destroy (void)
174 long i = 0;
175 AST_Decl *d = 0;
177 // Just destroy and delete everything but the CORBA
178 // module, and the 'void' keyword, in case we are
179 // processing multiple IDL files.
180 // Final cleanup will be done in fini().
181 long end = this->pd_decls_used;
183 for (i = 2; i < end; ++i)
185 d = this->pd_decls[i];
187 d->destroy ();
188 delete d;
189 d = 0;
190 --this->pd_decls_used;
193 // Same goes for the references and the name
194 // references, leave the first 2.
196 // This array of pointers holds references, no need
197 // for destruction. The array itself will be cleaned
198 // up when AST_Root::fini() calls UTL_Scope::destroy ().
199 for (i = 2; i < this->pd_referenced_used; ++i)
201 this->pd_referenced[i] = 0;
204 this->pd_referenced_used = 2;
206 for (i = 2; i < this->pd_name_referenced_used; ++i)
208 Identifier *id = this->pd_name_referenced[i];
209 id->destroy ();
210 delete id;
211 id = 0;
214 this->pd_name_referenced_used = 2;
217 void
218 AST_Root::fini (void)
220 this->UTL_Scope::destroy ();
221 this->AST_Decl::destroy ();
224 IMPL_NARROW_FROM_DECL(AST_Root)
225 IMPL_NARROW_FROM_SCOPE(AST_Root)