TAO_IDL: Fix Memory Leaks Caused By Annotations
[ACE_TAO.git] / TAO / TAO_IDL / include / ast_array.h
blob2eb72f84859bfc900418f01aa428ba6bec73ee5d
1 // This may look like C, but it's really -*- C++ -*-
2 /*
4 COPYRIGHT
6 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
7 States of America. All Rights Reserved.
9 This product is protected by copyright and distributed under the following
10 license restricting its use.
12 The Interface Definition Language Compiler Front End (CFE) is made
13 available for your use provided that you include this license and copyright
14 notice on all media and documentation and the software program in which
15 this product is incorporated in whole or part. You may copy and extend
16 functionality (but may not remove functionality) of the Interface
17 Definition Language CFE without charge, but you are not authorized to
18 license or distribute it to anyone else except as part of a product or
19 program developed by you or with the express written consent of Sun
20 Microsystems, Inc. ("Sun").
22 The names of Sun Microsystems, Inc. and any of its subsidiaries or
23 affiliates may not be used in advertising or publicity pertaining to
24 distribution of Interface Definition Language CFE as permitted herein.
26 This license is effective until terminated by Sun for failure to comply
27 with this license. Upon termination, you shall destroy or return all code
28 and documentation for the Interface Definition Language CFE.
30 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
31 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
33 DEALING, USAGE OR TRADE PRACTICE.
35 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
36 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
37 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
39 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
40 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
41 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
43 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
44 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
45 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47 Use, duplication, or disclosure by the government is subject to
48 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
49 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
50 52.227-19.
52 Sun, Sun Microsystems and the Sun logo are trademarks or registered
53 trademarks of Sun Microsystems, Inc.
55 SunSoft, Inc.
56 2550 Garcia Avenue
57 Mountain View, California 94043
59 NOTE:
61 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
62 trademarks or registered trademarks of Sun Microsystems, Inc.
66 #ifndef _AST_ARRAY_AST_ARRAY_HH
67 #define _AST_ARRAY_AST_ARRAY_HH
69 #include "ace/CDR_Base.h"
71 #include "ast_concrete_type.h"
73 class UTL_ExprList;
74 class AST_Expression;
75 class AST_Type;
76 class ast_visitor;
78 // Representation of array declaration:
79 // An array is a combination of a list of dimensions and a base type.
81 class TAO_IDL_FE_Export AST_Array : public virtual AST_ConcreteType
83 public:
84 AST_Array (UTL_ScopedName *n,
85 ACE_CDR::ULong ndims,
86 UTL_ExprList *dims,
87 bool local,
88 bool abstract);
90 virtual ~AST_Array (void);
92 // Data Accessors.
94 ACE_CDR::ULong n_dims (void);
96 AST_Expression **dims (void);
97 void set_dims (AST_Expression **,
98 ACE_CDR::ULong);
100 AST_Type *base_type (void) const;
101 void set_base_type (AST_Type *nbt);
103 // Recursively called on valuetype to check for legal use as
104 // a primary key. Overridden for valuetype, struct, sequence,
105 // union, array, typedef, and interface.
106 virtual bool legal_for_primary_key (void) const;
108 // Cleanup.
109 virtual void destroy (void);
111 // Narrowing.
113 DEF_NARROW_FROM_DECL(AST_Array);
115 // AST Dumping.
116 virtual void dump (ACE_OSTREAM_TYPE &o);
118 // Visiting.
119 virtual int ast_accept (ast_visitor *visitor);
121 static AST_Decl::NodeType const NT;
124 * Get and Set Annotations on the base type
126 ///{
127 AST_Annotation_Appls &base_type_annotations ();
128 void base_type_annotations (const AST_Annotation_Appls &annotations);
129 ///}
131 protected:
132 virtual int compute_size_type (void);
133 // Compute the size type if it is unknown.
135 private:
136 // Data.
138 ACE_CDR::ULong pd_n_dims;
139 // How many dimensions?
141 AST_Expression **pd_dims;
142 // Their expressions.
144 AST_Type *pd_base_type;
145 // Base type of array.
147 bool owns_base_type_;
148 // If our base type is anonymous array or sequence, we're
149 // responsible for destroying it.
151 // Compute how many dimensions.
152 AST_Expression **compute_dims (UTL_ExprList *dims,
153 ACE_CDR::ULong ndims);
156 * Annotations on the base type
158 AST_Annotation_Appls base_type_annotations_;
161 #endif // _AST_ARRAY_AST_ARRAY_HH