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_Array nodes denote array type and field modifiers.
66 // AST_Array nodes have a list of dimensions (a UTL_ExprList)
67 // a count of the number of dimensions and a base type (a
68 // subtype of AST_ConcreteType. This means that we cannot have
69 // arrays of AST_Interfaces???
71 #include "ast_array.h"
72 #include "ast_expression.h"
73 #include "ast_param_holder.h"
74 #include "ast_visitor.h"
76 #include "utl_exprlist.h"
77 #include "utl_identifier.h"
78 #include "ace/Log_Msg.h"
79 #include "ace/OS_Memory.h"
81 AST_Decl::NodeType
const
82 AST_Array::NT
= AST_Decl::NT_array
;
84 AST_Array::AST_Array (UTL_ScopedName
*n
,
91 AST_Decl (AST_Decl::NT_array
,
94 AST_Type (AST_Decl::NT_array
,
96 AST_ConcreteType (AST_Decl::NT_array
,
100 owns_base_type_ (false)
102 this->pd_dims
= this->compute_dims (ds
,
106 AST_Array::~AST_Array (void)
110 // Private operations.
112 // Compute how many dimensions there are and collect their expressions
115 AST_Array::compute_dims (UTL_ExprList
*ds
,
123 AST_Expression
**result
= 0;
124 ACE_NEW_RETURN (result
,
125 AST_Expression
*[nds
],
128 UTL_ExprlistActiveIterator
iter (ds
);
130 for (ACE_CDR::ULong i
= 0;
131 !iter
.is_done () && i
< nds
;
134 AST_Expression
*orig
= iter
.item ();
135 AST_Param_Holder
*ph
= orig
->param_holder ();
137 AST_Expression::ExprType ex_type
=
138 (ph
== 0 ? orig
->ev ()->et
: ph
->info ()->const_type_
);
140 AST_Expression
*copy
= 0;
141 ACE_NEW_RETURN (copy
,
142 AST_Expression (orig
,
152 // Redefinition of inherited virtual operations.
154 // Dump this AST_Array node to the ostream o.
156 AST_Array::dump (ACE_OSTREAM_TYPE
&o
)
158 pd_base_type
->dump (o
);
160 this->dump_i (o
, " ");
162 this->local_name ()->dump (o
);
164 for (ACE_CDR::ULong i
= 0; i
< this->pd_n_dims
; i
++)
166 this->dump_i (o
, "[");
168 pd_dims
[i
]->dump (o
);
170 this->dump_i (o
, "]");
175 AST_Array::ast_accept (ast_visitor
*visitor
)
177 return visitor
->visit_array (this);
180 // Compute the size type of the node in question.
182 AST_Array::compute_size_type (void)
184 AST_Type
*type
= this->base_type ();
188 ACE_ERROR_RETURN ((LM_ERROR
,
189 "(%N:%l) be_array::compute_size_type - "
194 // Our size type is the same as our type.
195 this->size_type (type
->size_type ());
197 this->has_constructor (type
->has_constructor ());
204 AST_Array::n_dims (void)
206 return this->pd_n_dims
;
210 AST_Array::dims (void)
212 return this->pd_dims
;
216 AST_Array::base_type (void) const
218 return this->pd_base_type
;
222 AST_Array::set_base_type (AST_Type
*nbt
)
224 this->pd_base_type
= nbt
;
225 this->is_local_
= nbt
->is_local ();
226 AST_Decl::NodeType bnt
= nbt
->node_type ();
228 if (bnt
== AST_Decl::NT_sequence
229 || bnt
== AST_Decl::NT_param_holder
)
231 this->owns_base_type_
= true;
236 AST_Array::legal_for_primary_key (void) const
238 return this->base_type ()->legal_for_primary_key ();
242 AST_Array::destroy (void)
244 if (this->owns_base_type_
)
246 this->pd_base_type
->destroy ();
247 delete this->pd_base_type
;
248 this->pd_base_type
= 0;
251 for (ACE_CDR::ULong i
= 0; i
< this->pd_n_dims
; ++i
)
253 this->pd_dims
[i
]->destroy ();
254 delete this->pd_dims
[i
];
255 this->pd_dims
[i
] = 0;
258 delete [] this->pd_dims
;
262 this->AST_ConcreteType::destroy ();
266 AST_Array::set_dims (AST_Expression
**ds
,
270 this->pd_n_dims
= nds
;
273 IMPL_NARROW_FROM_DECL(AST_Array
)
275 AST_Annotation_Appls
&
276 AST_Array::base_type_annotations ()
278 return base_type_annotations_
;
282 AST_Array::base_type_annotations (const AST_Annotation_Appls
&annotations
)
284 base_type_annotations_
= annotations
;