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
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
56 Mountain View, California 94043
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
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
)
84 AST_Decl (AST_Decl::NT_root
,
86 UTL_Scope (AST_Decl::NT_root
),
91 AST_Root::~AST_Root (void)
95 // Overrides the one in UTL_Scope - this one doesn't
96 // count the predefined types.
98 AST_Root::nmembers (void)
100 unsigned long retval
= 0;
102 for (UTL_ScopeActiveIterator
si (this, UTL_Scope::IK_decls
);
106 if (si
.item ()->node_type () == AST_Decl::NT_pre_defined
)
117 // Add this AST_Sequence to the locally defined types in this scope.
119 AST_Root::fe_add_sequence (AST_Sequence
*t
)
126 this->add_to_local_types (t
);
130 // Add this AST_String to the locally defined types in this scope.
132 AST_Root::fe_add_string (AST_String
*t
)
139 this->add_to_local_types (t
);
143 // Add this AST_Array to the locally defined types in this scope.
145 AST_Root::fe_add_array (AST_Array
*t
)
152 this->add_to_local_types (t
);
156 // Redefinition of inherited virtual operations.
158 // Dump this AST_Root node to the ostream o.
160 AST_Root::dump (ACE_OSTREAM_TYPE
&o
)
166 AST_Root::ast_accept (ast_visitor
*visitor
)
168 return visitor
->visit_root (this);
172 AST_Root::destroy (void)
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
];
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
];
214 this->pd_name_referenced_used
= 2;
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
)