Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_exception.cpp
blob301539d96d8ce98faa58d35f9cb8bbbb8aadf164
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_Exceptions denote IDL exception declarations
66 // AST_Exceptions are a subclass of AST_Decl (they are not types!)
67 // and of UTL_Scope.
69 #include "ast_exception.h"
70 #include "ast_field.h"
71 #include "ast_union.h"
72 #include "ast_enum.h"
73 #include "ast_enum_val.h"
74 #include "ast_typedef.h"
75 #include "ast_visitor.h"
77 #include "utl_err.h"
78 #include "utl_identifier.h"
79 #include "utl_indenter.h"
81 AST_Decl::NodeType const
82 AST_Exception::NT = AST_Decl::NT_except;
84 AST_Exception::AST_Exception (UTL_ScopedName *n,
85 bool local,
86 bool abstract)
87 : COMMON_Base (local,
88 abstract),
89 AST_Decl (AST_Decl::NT_except,
90 n),
91 AST_Type (AST_Decl::NT_except,
92 n),
93 AST_ConcreteType (AST_Decl::NT_except,
94 n),
95 UTL_Scope (AST_Decl::NT_except),
96 AST_Structure (AST_Decl::NT_except,
98 local,
99 abstract)
103 AST_Exception::~AST_Exception (void)
107 // Public operations.
109 // Are we or the parameter node involved in any recursion?
110 bool
111 AST_Exception::in_recursion (ACE_Unbounded_Queue<AST_Type *> &list)
113 bool self_test = (list.size () == 0);
115 // We should calculate this only once. If it has already been
116 // done, just return it.
117 if (self_test && this->in_recursion_ != -1)
119 return (this->in_recursion_ == 1);
122 if (list.size () > 1)
124 if (match_names (this, list))
126 // this happens when we are not recursed ourselves but instead
127 // are part of another recursive type
128 return false;
132 list.enqueue_tail(this);
134 // Proceed if the number of members in our scope is greater than 0.
135 if (this->nmembers () > 0)
137 // Continue until each element is visited.
138 for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ())
140 AST_Field *field = dynamic_cast<AST_Field*> (i.item ());
142 if (field == 0)
143 // This will be an enum value or other legitimate non-field
144 // member - in any case, no recursion.
146 continue;
149 AST_Type *type = field->field_type ();
151 if (type->node_type () == AST_Decl::NT_typedef)
153 AST_Typedef *td = dynamic_cast<AST_Typedef*> (type);
154 type = td->primitive_base_type ();
157 if (type == 0)
159 ACE_ERROR_RETURN ((LM_ERROR,
160 ACE_TEXT ("(%N:%l) AST_Exception::")
161 ACE_TEXT ("in_recursion - ")
162 ACE_TEXT ("bad field type\n")),
166 if (type->in_recursion (list))
168 if (self_test)
169 this->in_recursion_ = 1;
170 idl_global->recursive_type_seen_ = true;
171 return true;
176 // Not in recursion.
177 if (self_test)
178 this->in_recursion_ = 0;
179 return 0; //this->in_recursion_;
182 // Dump this AST_Exception node to the ostream o.
183 void
184 AST_Exception::dump (ACE_OSTREAM_TYPE &o)
186 this->dump_i (o, "exception ");
187 this->local_name ()->dump (o);
188 this->dump_i (o, " {\n");
189 UTL_Scope::dump (o);
190 idl_global->indent ()->skip_to (o);
191 this->dump_i (o, "}");
195 AST_Exception::ast_accept (ast_visitor *visitor)
197 return visitor->visit_exception (this);
200 void
201 AST_Exception::destroy (void)
203 this->AST_Structure::destroy ();
206 IMPL_NARROW_FROM_DECL(AST_Exception)
207 IMPL_NARROW_FROM_SCOPE(AST_Exception)