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_InterfaceFwd nodes denote forward declarations of IDL interfaces.
66 // AST_InterfaceFwd nodes have a field containing the full declaration
67 // of the interface, which is initialized when that declaration is
70 #include "ast_interface_fwd.h"
71 #include "ast_interface.h"
72 #include "ast_module.h"
73 #include "ast_visitor.h"
74 #include "utl_identifier.h"
76 AST_Decl::NodeType
const
77 AST_InterfaceFwd::NT
= AST_Decl::NT_interface_fwd
;
79 AST_InterfaceFwd::AST_InterfaceFwd (AST_Interface
*dummy
,
81 : COMMON_Base (dummy
->is_local (),
82 dummy
->is_abstract ()),
83 AST_Decl (AST_Decl::NT_interface_fwd
,
85 AST_Type (AST_Decl::NT_interface_fwd
,
90 // Create a dummy placeholder for the forward declared interface. This
91 // interface node is not yet defined (n_inherits < 0), so some operations
93 this->pd_full_definition
= dummy
;
95 if (! dummy
->is_local ())
97 idl_global
->non_local_fwd_iface_seen_
= true;
101 AST_InterfaceFwd::~AST_InterfaceFwd (void)
105 // Private operations.
108 AST_InterfaceFwd::is_local (void)
110 return this->full_definition ()->is_local ();
114 AST_InterfaceFwd::is_valuetype (void)
116 AST_Decl::NodeType nt
= this->full_definition ()->node_type ();
117 return nt
== AST_Decl::NT_valuetype
|| nt
== AST_Decl::NT_eventtype
;
121 AST_InterfaceFwd::is_abstract_valuetype (void)
123 return (this->full_definition ()->is_abstract ()
124 && this->is_valuetype ());
128 AST_InterfaceFwd::full_def_seen (void)
130 UTL_Scope
*s
= this->defined_in ();
131 AST_Interface
*i
= 0;
133 // If a full definition is seen in a previous module opening
134 // or anywhere in the current scope (before or after our
135 // declaration, reture TRUE.
137 if (AST_Decl::NT_module
== s
->scope_node_type ())
139 AST_Module
*m
= dynamic_cast<AST_Module
*> (s
);
141 m
->look_in_prev_mods_local (this->local_name (),
146 i
= dynamic_cast<AST_Interface
*> (d
);
148 if (0 != i
&& i
->is_defined ())
155 for (UTL_ScopeActiveIterator
iter (s
, UTL_Scope::IK_decls
);
159 i
= dynamic_cast<AST_Interface
*> (iter
.item ());
161 if (0 != i
&& this->local_name ()->compare (i
->local_name ()))
163 if (i
->is_defined ())
173 // Redefinition of inherited virtual operations.
175 // Dump this AST_InterfaceFwd node to the ostream o.
177 AST_InterfaceFwd::dump (ACE_OSTREAM_TYPE
&o
)
179 if (this->is_abstract ())
181 this->dump_i (o
, "abstract ");
183 else if (this->is_local ())
185 this->dump_i (o
, "local ");
188 this->dump_i (o
, "interface ");
190 this->local_name ()->dump (o
);
194 AST_InterfaceFwd::ast_accept (ast_visitor
*visitor
)
196 return visitor
->visit_interface_fwd (this);
202 AST_InterfaceFwd::full_definition (void)
204 return this->pd_full_definition
;
208 AST_InterfaceFwd::set_full_definition (AST_Interface
*nfd
)
210 if (pd_full_definition
&& has_ownership_
)
212 pd_full_definition
->destroy ();
213 delete pd_full_definition
;
215 pd_full_definition
= nfd
;
216 has_ownership_
= false;
220 AST_InterfaceFwd::is_defined (void)
222 // Look for the one instance of the fwd decl
223 // that may have a full definition.
224 if (!this->is_defined_
)
226 AST_Module
*m
= dynamic_cast<AST_Module
*> (this->defined_in ());
231 m
->look_in_prev_mods_local (this->local_name ());
235 // We could be looking at a superfluous forward decl
236 // of an interface already defined.
237 AST_Interface
*full
= dynamic_cast<AST_Interface
*> (d
);
243 AST_InterfaceFwd
*fwd
= dynamic_cast<AST_InterfaceFwd
*> (d
);
245 // Since fwd_redefinition_helper() is called
246 // before fe_add_interface(), we can't check
247 // n_inherits() or is_defined(), but added()
248 // is a sufficient way to tell if our full
249 // definition has already gone through the
250 // add_to_scope process.
251 if (0 != fwd
&& fwd
->is_defined ())
259 return this->is_defined_
;
263 AST_InterfaceFwd::set_as_defined ()
269 AST_InterfaceFwd::disown_full_definition ()
271 has_ownership_
= false;
275 AST_InterfaceFwd::destroy (void)
279 set_full_definition (0);
282 this->AST_Type::destroy ();
286 AST_InterfaceFwd::is_fwd (void)
288 return true; // This is a fwd declared type
291 // We don't actually want the forward declaration,
292 // but want to return the full definition member,
293 // whether defined yet or not.
295 AST_InterfaceFwd::adjust_found (
301 AST_Interface
*i
= this->full_definition ();
302 return (full_def_only
&& !i
->is_defined () ? 0 : i
);
308 IMPL_NARROW_FROM_DECL (AST_InterfaceFwd
)