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 <ast_interface.h>
66 #include <ast_module.h>
67 #include <ast_array.h>
68 #include <ast_field.h>
69 #include <ast_structure.h>
70 #include <ast_sequence.h>
71 #include <ast_string.h>
72 #include <ast_typedef.h>
73 #include <ast_visitor.h>
74 #include <global_extern.h>
75 #include <nr_extern.h>
76 #include <utl_identifier.h>
77 #include <utl_string.h>
78 #include <utl_scope.h>
80 #include <ast_annotation_appl.h>
81 #include <utl_indenter.h>
83 // FUZZ: disable check_for_streams_include
84 #include <ace/streams.h>
85 #include <ace/OS_NS_stdio.h>
87 COMMON_Base::COMMON_Base (bool local
,
90 is_abstract_ (abstract
)
94 COMMON_Base::~COMMON_Base ()
99 COMMON_Base::destroy ()
104 COMMON_Base::is_local ()
106 return this->is_local_
;
110 COMMON_Base::is_local (bool val
)
112 this->is_local_
= val
;
116 COMMON_Base::is_abstract () const
118 return this->is_abstract_
;
122 COMMON_Base::is_abstract (bool val
)
124 this->is_abstract_
= val
;
127 AST_Decl::AST_Decl (NodeType nt
,
133 contains_wstring_ (-1),
134 annotation_appls_ (0),
135 builtin_ (idl_global
->in_eval_
),
136 pd_imported (idl_global
->imported ()),
137 pd_in_main_file (idl_global
->in_main_file ()),
138 pd_defined_in (idl_global
->scopes ().depth () > 0
139 ? idl_global
->scopes ().top ()
142 pd_line (idl_global
->lineno ()),
144 pd_local_name (n
? n
->last_component ()->copy () : 0),
145 pd_original_local_name (0),
149 anonymous_ (anonymous
),
151 last_referenced_as_ (0),
153 in_tmpl_mod_not_aliased_ (idl_global
->in_tmpl_mod_no_alias ())
155 // If this is the root node, the filename won't have been set yet.
156 UTL_String
*fn
= idl_global
->filename ();
157 this->pd_file_name
= (fn
? fn
->get_string () : "");
159 this->compute_full_name (n
);
162 idl_global
->pragma_prefixes ().top (prefix
);
163 this->prefix_
= ACE::strnew (prefix
? prefix
: "");
167 // The function body creates its own copy.
168 this->original_local_name (n
->last_component ());
171 this->compute_repoID ();
175 UTL_ScopedName
*name
,
180 contains_wstring_ (-1),
181 annotation_appls_ (0),
182 builtin_ (idl_global
->in_eval_
),
183 pd_imported (idl_global
->imported ()),
184 pd_in_main_file (idl_global
->in_main_file ()),
185 pd_defined_in (idl_global
->scopes ().depth () > 0
186 ? idl_global
->scopes ().top ()
188 pd_node_type (other
->node_type ()),
189 pd_line (idl_global
->lineno ()),
191 pd_local_name (name
? name
->last_component ()->copy () : 0),
192 pd_original_local_name (0),
196 anonymous_ (other
->anonymous ()),
198 last_referenced_as_ (0),
200 in_tmpl_mod_not_aliased_ (idl_global
->in_tmpl_mod_no_alias ())
202 // If this is the root node, the filename won't have been set yet.
203 UTL_String
*fn
= idl_global
->filename ();
204 this->pd_file_name
= (fn
? fn
->get_string () : "");
206 this->compute_full_name (name
);
209 idl_global
->pragma_prefixes ().top (prefix
);
210 this->prefix_
= ACE::strnew (prefix
? prefix
: "");
214 // The function body creates its own copy.
215 this->original_local_name (name
->last_component ());
218 this->compute_repoID ();
221 AST_Decl::~AST_Decl ()
228 // These are not set for the root node.
231 this->pd_name
->destroy ();
232 delete this->pd_name
;
236 if (this->pd_local_name
)
238 this->pd_local_name
->destroy ();
239 delete this->pd_local_name
;
240 this->pd_local_name
= 0;
243 if (this->pd_original_local_name
)
245 this->pd_original_local_name
->destroy ();
246 delete this->pd_original_local_name
;
247 this->pd_original_local_name
= 0;
250 if (this->last_referenced_as_
)
252 this->last_referenced_as_
->destroy ();
253 delete this->last_referenced_as_
;
254 this->last_referenced_as_
= 0;
257 delete [] this->full_name_
;
258 this->full_name_
= 0;
260 delete [] this->repoID_
;
263 delete [] this->prefix_
;
266 delete [] this->version_
;
269 delete [] this->flat_name_
;
270 this->flat_name_
= 0;
272 delete annotation_appls_
;
273 annotation_appls_
= 0;
277 AST_Decl::adjust_found (
279 bool /*full_def_only*/)
281 return this; // Defaults to no adjustment
287 return false; // Not a fwd declared type (by default)
290 // Private operations.
292 // Compute our private UTL_ScopedName member.
294 AST_Decl::compute_full_name (UTL_ScopedName
*n
)
296 // This should happen only when we are a non-void predefined type,
297 // in which case our scoped name has already been created by the
298 // AST_PredefinedType constructor.
305 if (!this->defined_in ())
307 this->pd_name
= (UTL_IdList
*) n
->copy ();
311 // Initialize this name to 0.
314 // OK, not global. So copy name of containing scope, then
315 // smash last cdr of copy with new component
316 UTL_ScopedName
*cn
= 0;
317 AST_Decl
*d
= ScopeAsDecl (this->defined_in ());
323 this->pd_name
= (UTL_IdList
*) cn
->copy ();
327 if (this->pd_local_name
)
331 UTL_ScopedName
*conc_name
= 0;
333 UTL_ScopedName (this->pd_local_name
->copy (), 0));
334 this->pd_name
->nconc (conc_name
);
338 ACE_NEW (this->pd_name
,
339 UTL_ScopedName (this->pd_local_name
->copy (), 0));
345 AST_Decl::set_prefix_with_typeprefix_r (const char *value
,
346 UTL_Scope
*appeared_in
)
348 if (this->typeid_set_
)
353 if (this->prefix_scope_
)
355 AST_Decl
*decl
= ScopeAsDecl (this->prefix_scope_
);
356 bool const overridden
=
357 decl
->has_ancestor (ScopeAsDecl (appeared_in
));
364 delete [] this->repoID_
;
366 this->prefix (value
);
367 this->prefix_scope_
= appeared_in
;
369 UTL_Scope
*s
= DeclAsScope (this);
372 for (UTL_ScopeActiveIterator
i (s
, UTL_Scope::IK_decls
);
376 AST_Decl
*tmp
= i
.item ();
377 UTL_Scope
*s_tmp
= DeclAsScope (tmp
);
380 tmp
->set_prefix_with_typeprefix_r (value
, appeared_in
);
385 // This will recursively catch all previous openings of a module.
386 if (this->node_type () == AST_Decl::NT_module
)
388 AST_Module
*m
= dynamic_cast<AST_Module
*> (this);
389 while (!!(m
= m
->previous_opening ()))
391 for (UTL_ScopeActiveIterator
si (m
, UTL_Scope::IK_decls
);
395 AST_Decl
*d
= si
.item ();
396 if (d
->node_type () != AST_Decl::NT_pre_defined
)
398 d
->set_prefix_with_typeprefix_r (value
, appeared_in
);
404 this->compute_repoID ();
407 // Protected operations.
409 // Compute stringified fully scoped name.
411 AST_Decl::compute_full_name ()
413 if (!this->full_name_
)
420 for (UTL_IdListActiveIterator
i (this->name ());
426 namelen
+= 2; // for "::"
430 first
= second
= false;
433 // Print the identifier.
434 name
= i
.item ()->get_string ();
435 namelen
+= ACE_OS::strlen (name
);
438 if (ACE_OS::strcmp (name
, ""))
440 // Does not start with a "".
450 ACE_NEW (this->full_name_
, char [namelen
+ 1]);
451 this->full_name_
[0] = '\0';
455 for (UTL_IdListActiveIterator
j (this->name ());
461 ACE_OS::strcat (this->full_name_
, "::");
465 first
= second
= false;
468 // Print the identifier.
469 name
= j
.item ()->get_string ();
470 ACE_OS::strcat (this->full_name_
, name
);
473 if (ACE_OS::strcmp (name
, ""))
475 // Does not start with a "".
487 // Compute stringified repository ID.
489 AST_Decl::compute_repoID ()
496 size_t namelen
= 4; // for the prefix "IDL:"
500 const char *prefix
= (this->prefix_
? this->prefix_
: "");
501 UTL_Scope
*scope
= this->defined_in ();
502 const char *parent_prefix
= 0;
504 // If our prefix is empty, we check to see if an ancestor has one.
505 while (scope
&& !ACE_OS::strcmp (prefix
, ""))
507 AST_Decl
*parent
= ScopeAsDecl (scope
);
508 if (parent
->node_type () == AST_Decl::NT_root
509 && parent
->imported ())
514 parent_prefix
= parent
->prefix ();
515 prefix
= (parent_prefix
? parent_prefix
: "");
516 scope
= parent
->defined_in ();
519 // in the first loop compute the total length
520 namelen
+= ACE_OS::strlen (prefix
) + 1;
522 const char *version
= this->version_
;
523 scope
= this->defined_in ();
525 // If our version is has not bee set, we use the parent's, if any.
526 while (!version
&& scope
)
528 AST_Decl
*parent
= ScopeAsDecl (scope
);
529 version
= parent
->version_
;
530 scope
= parent
->defined_in ();
535 // Version member string + ':'
536 namelen
+= ACE_OS::strlen (version
) + 1;
544 for (UTL_IdListActiveIterator
i (this->name ());
550 namelen
+= 1; // for "/"
554 first
= second
= false;
557 // Print the identifier.
558 name
= i
.item ()->get_string ();
559 size_t item_len
= ACE_OS::strlen (name
);
561 if (ACE_OS::strstr (name
, "_cxx_") == name
)
563 namelen
+= (item_len
- ACE_OS::strlen ("_cxx_"));
572 if (ACE_OS::strcmp (name
, ""))
574 // Does not start with a "".
584 ACE_NEW (this->repoID_
, char [namelen
+ 1]);
585 ACE_OS::sprintf (this->repoID_
, "IDL:");
587 if (ACE_OS::strcmp (prefix
, ""))
589 ACE_OS::strcat (this->repoID_
, prefix
);
590 ACE_OS::strcat (this->repoID_
, "/");
596 for (UTL_IdListActiveIterator
j (this->name ());
602 ACE_OS::strcat (this->repoID_
, "/");
606 first
= second
= false;
609 // Print the identifier.
610 name
= j
.item ()->get_string ();
612 if (ACE_OS::strstr (name
, "_cxx_") == name
)
614 ACE_OS::strcat (this->repoID_
,
615 name
+ ACE_OS::strlen ("_cxx_"));
619 ACE_OS::strcat (this->repoID_
, name
);
624 if (ACE_OS::strcmp (name
, ""))
626 // Does not start with a "".
638 ACE_OS::strcat (this->repoID_
, ":");
639 ACE_OS::strcat (this->repoID_
, version
);
643 ACE_OS::strcat (this->repoID_
, ":1.0");
647 // Public operations.
650 AST_Decl::flat_name ()
652 if (!this->flat_name_
)
654 this->compute_flat_name ();
657 return this->flat_name_
;
660 // Compute stringified flattened fully scoped name.
662 AST_Decl::compute_flat_name ()
664 if (this->flat_name_
== 0)
671 // In the first loop, compute the total length.
672 for (UTL_IdListActiveIterator
i (this->name ());
678 namelen
+= 1; // for "_"
682 first
= second
= false;
685 // Print the identifier, leaving out
686 // _cxx_ prefix, if any.
687 Identifier
*tmp
= i
.item ()->copy ();
688 FE_Utils::original_local_name (tmp
);
689 item_name
= tmp
->get_string ();
690 namelen
+= ACE_OS::strlen (item_name
);
694 if (ACE_OS::strcmp (item_name
, "") != 0)
696 // Does not start with a "".
710 ACE_NEW (this->flat_name_
, char [namelen
+ 1]);
711 this->flat_name_
[0] = '\0';
715 for (UTL_IdListActiveIterator
j (this->name ());
721 ACE_OS::strcat (this->flat_name_
, "_");
725 first
= second
= false;
728 // Print the identifier, leaving out
729 // _cxx_ prefix, if any.
730 Identifier
*tmp
= j
.item ()->copy ();
731 FE_Utils::original_local_name (tmp
);
732 item_name
= tmp
->get_string ();
733 ACE_OS::strcat (this->flat_name_
, item_name
);
737 if (ACE_OS::strcmp (item_name
, ""))
739 // Does not start with a "".
756 AST_Decl::node_type_to_string (NodeType nt
)
764 case NT_interface_fwd
:
768 case NT_valuetype_fwd
:
817 case NT_component_fwd
:
824 case NT_eventtype_fwd
:
851 // No useful output for these.
857 // Return TRUE if one of my ancestor scopes is "s"
858 // and FALSE otherwise.
860 AST_Decl::has_ancestor (AST_Decl
*s
)
862 AST_Decl
*work
= this;
870 AST_Module
*m
= dynamic_cast<AST_Module
*> (s
);
873 while (!!(m
= m
->previous_opening ()))
875 if (static_cast<AST_Decl
*> (m
) == s
)
882 work
= work
->pd_defined_in
?
883 ScopeAsDecl (work
->pd_defined_in
) :
891 AST_Decl::is_child (AST_Decl
*s
)
893 if (this->defined_in ())
895 AST_Decl
*d
= ScopeAsDecl (this->defined_in ());
901 if (!ACE_OS::strcmp (d
->full_name (), s
->full_name ()))
907 return 0; // Not a child.
911 AST_Decl::is_nested ()
913 AST_Decl
*d
= ScopeAsDecl (this->defined_in ());
915 // If we have an outermost scope and if that scope is not that of the Root,
916 // then we are defined at some nesting level.
917 return (d
&& d
->node_type () != AST_Decl::NT_root
);
920 // Dump this AST_Decl to the ostream o.
922 AST_Decl::dump (ACE_OSTREAM_TYPE
&o
)
924 this->pd_local_name
->dump (o
);
928 AST_Decl::dump_i (ACE_OSTREAM_TYPE
&o
, const char *s
) const
930 // Have to use ACE_CString here to avoid ambiguous overload error, see
931 // SString.h for an the overloaded operator << () methods.
936 AST_Decl::ast_accept (ast_visitor
*visitor
)
938 return visitor
->visit_decl (this);
944 AST_Decl::full_name ()
946 if (!this->full_name_
)
948 this->compute_full_name ();
951 return this->full_name_
;
957 if (this->pd_node_type
== NT_root
)
959 delete [] this->repoID_
;
960 this->repoID_
= ACE::strnew ("");
965 this->compute_repoID ();
968 return this->repoID_
;
972 AST_Decl::repoID (char *value
)
974 delete [] this->repoID_
;
975 this->repoID_
= value
;
981 return this->prefix_
;
985 AST_Decl::prefix (const char *value
)
987 delete [] this->prefix_
;
988 this->prefix_
= ACE::strnew (value
);
996 // Calling the method will compute if necessary.
997 const char *repo_id
= this->repoID ();
999 // All forms of repo id should contain two colons, the
1000 // version coming after the second one.
1001 const char *tail1
= 0;
1002 const char *tail2
= 0;
1006 tail1
= ACE_OS::strchr (repo_id
, ':');
1011 tail2
= ACE_OS::strchr (tail1
+ 1, ':');
1014 if (!this->typeid_set_
&& tail2
)
1016 this->version_
= ACE::strnew (tail2
+ 1);
1020 this->version_
= ACE::strnew ("1.0");
1024 return this->version_
;
1028 AST_Decl::version (char *value
)
1030 // Previous #pragma version or #pragma id make this illegal.
1031 if ((!this->version_
|| !ACE_OS::strcmp (this->version_
, value
))
1032 && !this->typeid_set_
)
1034 delete [] this->version_
;
1035 this->version_
= value
;
1037 // Repo id is now computed eagerly, so a version set must update
1041 ACE_CString
tmp (this->repoID_
);
1042 ACE_CString::size_type
const pos
= tmp
.rfind (':');
1043 if (pos
!= ACE_CString::npos
)
1045 tmp
= tmp
.substr (0, pos
+ 1) + value
;
1046 delete [] this->repoID_
;
1047 this->repoID_
= ACE::strnew (tmp
.fast_rep ());
1053 idl_global
->err ()->version_reset_error ();
1058 AST_Decl::anonymous () const
1060 return this->anonymous_
;
1064 AST_Decl::anonymous (bool val
)
1066 this->anonymous_
= val
;
1070 AST_Decl::typeid_set () const
1072 return this->typeid_set_
;
1076 AST_Decl::typeid_set (bool val
)
1078 this->typeid_set_
= val
;
1082 AST_Decl::set_id_with_typeid (char *value
)
1084 // Can't call 'typeid' twice, even with the same value.
1085 if (this->typeid_set ())
1087 idl_global
->err ()->error1 (UTL_Error::EIDL_TYPEID_RESET
, this);
1090 // Are we a legal type for 'typeid'?
1091 switch (this->pd_node_type
)
1093 case AST_Decl::NT_field
:
1095 AST_Decl::NodeType nt
=
1096 ScopeAsDecl (this->defined_in ())->node_type ();
1098 if ( nt
== AST_Decl::NT_valuetype
1099 || nt
== AST_Decl::NT_eventtype
)
1105 idl_global
->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID
, this);
1110 case AST_Decl::NT_module
:
1111 case AST_Decl::NT_interface
:
1112 case AST_Decl::NT_const
:
1113 case AST_Decl::NT_typedef
:
1114 case AST_Decl::NT_except
:
1115 case AST_Decl::NT_attr
:
1116 case AST_Decl::NT_op
:
1117 case AST_Decl::NT_enum
:
1118 case AST_Decl::NT_factory
:
1119 case AST_Decl::NT_component
:
1120 case AST_Decl::NT_home
:
1121 case AST_Decl::NT_eventtype
:
1125 idl_global
->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID
, this);
1129 delete [] this->repoID_
;
1131 this->repoID (ACE::strnew (value
));
1132 this->typeid_set_
= true;
1136 AST_Decl::set_prefix_with_typeprefix (const char *value
)
1138 // Are we a legal type for 'typeprefix'? This is checked only at
1140 switch (this->pd_node_type
)
1142 case AST_Decl::NT_module
:
1143 case AST_Decl::NT_interface
:
1144 case AST_Decl::NT_valuetype
:
1145 case AST_Decl::NT_eventtype
:
1146 case AST_Decl::NT_struct
:
1147 case AST_Decl::NT_union
:
1148 case AST_Decl::NT_except
:
1152 idl_global
->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEPREFIX
, this);
1156 this->set_prefix_with_typeprefix_r (value
, DeclAsScope (this));
1160 AST_Decl::imported ()
1162 return this->pd_imported
;
1166 AST_Decl::set_imported (bool is_it
)
1168 this->pd_imported
= is_it
;
1172 AST_Decl::in_main_file ()
1174 return this->pd_in_main_file
;
1178 AST_Decl::set_in_main_file (bool is_it
)
1180 this->pd_in_main_file
= is_it
;
1184 AST_Decl::defined_in ()
1186 return this->pd_defined_in
;
1190 AST_Decl::set_defined_in (UTL_Scope
*s
)
1192 this->pd_defined_in
= s
;
1196 AST_Decl::node_type ()
1198 return this->pd_node_type
;
1204 return this->pd_line
;
1208 AST_Decl::set_line (long l
)
1214 AST_Decl::file_name ()
1216 return this->pd_file_name
;
1220 AST_Decl::set_file_name (ACE_CString s
)
1222 this->pd_file_name
= s
;
1228 return this->pd_name
;
1231 // @@ Wherever compute_* are called, we should remember to delete them
1234 // Variation of the <name>. Computes scoped name string, applying
1235 // prefix and suffix to the local name component.
1237 AST_Decl::compute_name (const char *prefix
,
1240 if (!prefix
|| !suffix
)
1245 // Prepare prefix_<local_name>_suffix string.
1247 ACE_CString
suffix_str (suffix
);
1248 ACE_CString
local_str (this->local_name ()->get_string ());
1250 ACE_CString
result_local_str (prefix
);
1251 result_local_str
+= local_str
;
1252 result_local_str
+= suffix_str
;
1254 // Identifier for the resulting local name.
1255 Identifier
*result_local_id
= 0;
1256 ACE_NEW_RETURN (result_local_id
,
1257 Identifier (result_local_str
.c_str ()),
1260 // UTL_Scoped name for the resulting local name.
1261 UTL_ScopedName
*result_local_name
= 0;
1262 ACE_NEW_RETURN (result_local_name
,
1263 UTL_ScopedName (result_local_id
, 0),
1267 UTL_ScopedName
*result_name
= 0;
1268 if (!this->defined_in ())
1270 result_name
= result_local_name
;
1274 // OK, not global. So copy name of containing scope, then
1275 // smash last cdr of copy with new component.
1277 AST_Decl
*d
= ScopeAsDecl (this->defined_in ());
1280 UTL_ScopedName
*cn
= d
->name ();
1283 result_name
= (UTL_ScopedName
*) cn
->copy ();
1286 result_name
->nconc (result_local_name
);
1290 result_name
= result_local_name
;
1300 AST_Decl::set_name (UTL_ScopedName
*n
)
1302 if (this->pd_name
== n
)
1309 this->pd_name
->destroy ();
1310 delete this->pd_name
;
1317 if (this->pd_local_name
)
1319 this->pd_local_name
->destroy ();
1320 delete this->pd_local_name
;
1323 this->pd_local_name
= n
->last_component ()->copy ();
1325 // The name without _cxx_ prefix removed, if there was any.
1326 if (this->pd_original_local_name
)
1328 this->pd_original_local_name
->destroy ();
1329 delete this->pd_original_local_name
;
1332 this->original_local_name (n
->last_component ());
1334 // These will be recomputed on demand.
1335 delete [] this->flat_name_
;
1336 this->flat_name_
= 0;
1338 delete [] this->full_name_
;
1339 this->full_name_
= 0;
1341 delete [] this->repoID_
;
1347 AST_Decl::local_name () const
1349 return this->pd_local_name
;
1353 AST_Decl::local_name (Identifier
*id
)
1355 if (this->pd_local_name
)
1357 this->pd_local_name
->destroy ();
1360 delete this->pd_local_name
;
1361 this->pd_local_name
= id
;
1365 AST_Decl::compute_local_name (const char *prefix
,
1368 if (!prefix
|| !suffix
)
1373 // Init the result with prefix.
1374 ACE_CString
result_str (prefix
);
1377 result_str
+= ACE_CString (this->local_name ()->get_string ());
1380 result_str
+= ACE_CString (suffix
);
1382 // Identifier for the resulting local name.
1383 Identifier
*result_id
= 0;
1384 ACE_NEW_RETURN (result_id
,
1385 Identifier (result_str
.c_str ()),
1391 // If there is _cxx_ in the beginning, we will remove that and keep
1392 // a copy of the original name. TAO IDL's front end adds _cxx_
1393 // prefix to the all the reserved keywords. But when we invoke the
1394 // operation remotely, we should be sending only the name with out
1397 AST_Decl::original_local_name (Identifier
*local_name
)
1399 // Remove _cxx_ if it is present.
1400 if (ACE_OS::strstr (local_name
->get_string (), "_cxx_")
1401 == local_name
->get_string ())
1403 // AACE_CString class is good to do this stuff.
1404 ACE_CString
name_str (local_name
->get_string ());
1407 name_str
= name_str
.substr (ACE_OS::strlen ("_cxx_"));
1409 // Assign to the Identifier variable.
1410 ACE_NEW (this->pd_original_local_name
,
1411 Identifier (name_str
.c_str ()));
1415 this->pd_original_local_name
= local_name
->copy ();
1420 AST_Decl::original_local_name ()
1422 return this->pd_original_local_name
;
1426 AST_Decl::is_defined ()
1428 // AST_Interface, AST_Structure, and AST_Union will
1429 // override this, as will AST_InterfaceFwd, etc.
1434 AST_Decl::last_referenced_as () const
1436 return this->last_referenced_as_
;
1440 AST_Decl::last_referenced_as (UTL_ScopedName
*n
)
1442 if (this->last_referenced_as_
)
1444 this->last_referenced_as_
->destroy ();
1447 delete this->last_referenced_as_
;
1448 this->last_referenced_as_
= n
;
1452 AST_Decl::prefix_scope ()
1454 return this->prefix_scope_
;
1458 AST_Decl::prefix_scope (UTL_Scope
*s
)
1460 this->prefix_scope_
= s
;
1463 // Container types will override this.
1465 AST_Decl::contains_wstring ()
1467 if (this->contains_wstring_
== -1)
1469 switch (this->node_type ())
1471 case AST_Decl::NT_array
:
1473 AST_Array
*a
= dynamic_cast<AST_Array
*> (this);
1474 this->contains_wstring_
= a
->base_type ()->contains_wstring ();
1478 case AST_Decl::NT_except
:
1479 case AST_Decl::NT_struct
:
1480 case AST_Decl::NT_union
:
1482 AST_Structure
*s
= dynamic_cast<AST_Structure
*> (this);
1483 this->contains_wstring_
= s
->contains_wstring ();
1487 case AST_Decl::NT_sequence
:
1489 AST_Sequence
*s
= dynamic_cast<AST_Sequence
*> (this);
1490 this->contains_wstring_
= s
->base_type ()->contains_wstring ();
1494 case AST_Decl::NT_attr
:
1495 case AST_Decl::NT_field
:
1496 case AST_Decl::NT_union_branch
:
1498 AST_Field
*f
= dynamic_cast<AST_Field
*> (this);
1499 this->contains_wstring_
= f
->field_type ()->contains_wstring ();
1503 case AST_Decl::NT_typedef
:
1505 AST_Typedef
*td
= dynamic_cast<AST_Typedef
*> (this);
1506 this->contains_wstring_
=
1507 td
->primitive_base_type ()->contains_wstring ();
1511 case AST_Decl::NT_wstring
:
1512 this->contains_wstring_
= 1;
1516 this->contains_wstring_
= 0;
1521 return this->contains_wstring_
;
1524 // Non-virtual - no need to override this one.
1526 AST_Decl::contains_wstring (int val
)
1528 this->contains_wstring_
= val
;
1532 AST_Decl::masking_checks (AST_Decl
*mod
)
1534 if (!this->pd_local_name
->case_compare (mod
->local_name ()))
1539 AST_Module
*me_mod
= dynamic_cast<AST_Module
*> (this);
1543 AST_Module
*po_mod
= dynamic_cast<AST_Module
*> (mod
);
1546 while (!!(po_mod
= po_mod
->previous_opening ()))
1548 if (po_mod
== me_mod
)
1560 AST_Decl::in_tmpl_mod_not_aliased () const
1562 return this->in_tmpl_mod_not_aliased_
;
1566 AST_Decl::in_tmpl_mod_not_aliased (bool val
)
1568 this->in_tmpl_mod_not_aliased_
= val
;
1571 //Narrowing methods for AST_Decl.
1573 IMPL_NARROW_FROM_DECL(AST_Decl
)
1577 AST_Decl::annotation_appls (const AST_Annotation_Appls
&annotations
)
1581 annotation_appls () = annotations
;
1585 ACE_ERROR ((LM_ERROR
,
1586 ACE_TEXT ("WARNING: %C is annotated but its type can't be annotated!\n"),
1592 AST_Annotation_Appls
&
1593 AST_Decl::annotation_appls ()
1595 if (!annotation_appls_
)
1597 annotation_appls_
= new AST_Annotation_Appls ();
1599 return *annotation_appls_
;
1603 AST_Decl::dump_annotations (ACE_OSTREAM_TYPE
&o
, bool print_inline
)
1605 AST_Annotation_Appls::iterator
1606 i
= annotation_appls ().begin (),
1607 finished
= annotation_appls ().end ();
1608 for (; i
!= finished
; ++i
)
1610 AST_Annotation_Appl
* a
= i
->get ();
1619 idl_global
->indent ()->skip_to (o
);
1625 AST_Decl::dump_with_annotations (ACE_OSTREAM_TYPE
&o
, bool inline_annotations
)
1627 if (annotatable () && auto_dump_annotations())
1629 dump_annotations (o
, inline_annotations
);
1636 operator<< (ACE_OSTREAM_TYPE
&o
, AST_Decl
&d
)
1638 d
.dump_with_annotations (o
, d
.dump_annotations_inline ());
1644 AST_Decl::annotatable () const
1650 AST_Decl::dump_annotations_inline () const
1656 AST_Decl::auto_dump_annotations () const
1662 AST_Decl::builtin () const
1668 AST_Decl::should_be_dumped () const
1670 return !builtin () || idl_global
->dump_builtins_
;
1673 AST_Annotation_Appls
&
1674 AST_Decl::annotations ()
1676 return annotation_appls ();
1680 AST_Decl::ami_visit ()