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 #include "fe_declarator.h"
67 #include "ast_array.h"
68 #include "ast_param_holder.h"
71 #include "global_extern.h"
72 #include "nr_extern.h"
74 #include "ace/config-all.h"
76 FE_Declarator::FE_Declarator (UTL_ScopedName
*n
,
79 : pd_complex_part (cp
),
85 // Compose the type of the complex declarator (if any) with the base
86 // type supplied in ct.
88 FE_Declarator::compose (AST_Decl
*d
)
90 AST_Type
*ct
= dynamic_cast<AST_Type
*> (d
);
94 idl_global
->err ()->not_a_type (d
);
97 else if (ct
->node_type () == AST_Decl::NT_param_holder
)
99 AST_Param_Holder
*ph
=
100 dynamic_cast<AST_Param_Holder
*> (ct
);
102 // Every other template parameter kind is legal.
103 if (ph
->info ()->type_
== AST_Decl::NT_const
)
105 idl_global
->err ()->not_a_type (d
);
110 AST_Decl::NodeType nt
= d
->node_type ();
112 if (nt
== AST_Decl::NT_struct_fwd
113 || nt
== AST_Decl::NT_union_fwd
114 || nt
== AST_Decl::NT_struct
115 || nt
== AST_Decl::NT_union
)
117 if (! ct
->is_defined ())
119 idl_global
->err ()->error1 (UTL_Error::EIDL_ILLEGAL_ADD
,
128 // All uses of forward declared types must
129 // not have a different prefix from the place of declaration.
130 if (!ct
->is_defined ())
132 const char *original_prefix
= d
->prefix ();
135 // Maybe the prefix hasn't been applied yet.
136 while (ACE_OS::strcmp (original_prefix
, "") == 0)
138 scope
= ScopeAsDecl (scope
->defined_in ());
140 // Are we at global scope?
146 original_prefix
= scope
->prefix ();
149 // Skip if the pointers are the same.
150 if (d
->prefix () != original_prefix
)
152 d
->prefix (const_cast<char *> (original_prefix
));
155 // (JP) This could give a bogus error, since typeprefix can
156 // appear any time after the corresponding declaration.
157 // The right way to do this is with a separate traversal
158 // after the entire AST is built.
160 char *current_prefix = 0;
161 idl_global->pragma_prefixes ().top (current_prefix);
163 if (current_prefix != 0
164 && ACE_OS::strcmp (current_prefix, d->prefix ()) != 0)
166 idl_global->err ()->error1 (UTL_Error::EIDL_PREFIX_CONFLICT,
174 if (this->pd_decl_type
== FD_simple
|| this->pd_complex_part
== 0)
179 if (this->pd_complex_part
->node_type () == AST_Decl::NT_array
)
181 arr
= dynamic_cast<AST_Array
*> (this->pd_complex_part
);
183 // The base type of an array isn't set until after the array
184 // has been created, so the check below gets done at this point.
185 arr
->set_base_type (ct
);
186 AST_Decl::NodeType nt
= ct
->unaliased_type ()->node_type ();
188 if (nt
== AST_Decl::NT_string
|| nt
== AST_Decl::NT_wstring
)
190 idl_global
->string_member_seen_
= true;
196 // We shouldn't get here.
201 FE_Declarator::destroy (void)
205 this->pd_name
->destroy ();
206 delete this->pd_name
;
214 FE_Declarator::complex_part (void)
216 return this->pd_complex_part
;
220 FE_Declarator::name (void)
222 return this->pd_name
;
225 FE_Declarator::DeclaratorType
226 FE_Declarator::decl_type (void)
228 return this->pd_decl_type
;