Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_annotation_decl.cpp
blob280c085a50ff0ee6d78ee1b750607344edb15550
1 #include "ast_annotation_decl.h"
2 #include "ast_annotation_member.h"
3 #include "utl_indenter.h"
4 #include "utl_identifier.h"
5 #include "ast_constant.h"
7 AST_Decl::NodeType const AST_Annotation_Decl::NT =
8 AST_Decl::NT_annotation_decl;
10 AST_Annotation_Decl::AST_Annotation_Decl (UTL_ScopedName *name)
11 : AST_Decl (NT, name),
12 AST_Type (NT, name),
13 AST_ConcreteType (NT, name),
14 UTL_Scope (NT),
15 AST_Structure (name, false, false)
17 if (!ACE_OS::strcmp(name->last_component ()->get_string (), "@annotation"))
19 idl_global->err ()-> misc_error(
20 "An Annotation can not be named \"annotation\"");
24 AST_Annotation_Decl::~AST_Annotation_Decl ()
28 void AST_Annotation_Decl::dump (ACE_OSTREAM_TYPE &o)
30 this->dump_i (o, "@annotation ");
31 AST_Decl::dump (o);
32 this->dump_i (o, " {\n");
33 UTL_Scope::dump (o);
34 idl_global->indent ()->skip_to (o);
35 this->dump_i (o, "}");
38 void AST_Annotation_Decl::destroy ()
40 AST_Decl::destroy ();
43 void
44 AST_Annotation_Decl::escape_name (Identifier *name)
46 FE_Utils::original_local_name (name); // Annotations can't clash with C++ keywords
47 char *old_name = name->get_string ();
48 char *new_name = new char [ACE_OS::strlen (old_name) + 2]; // '@' and '\0'
49 if (new_name)
51 new_name[0] = '@';
52 new_name[1] = '\0';
53 ACE_OS::strcat (new_name, old_name);
54 name->replace_string (new_name);
55 delete [] new_name;
59 void
60 AST_Annotation_Decl::escape_name (UTL_ScopedName *name)
62 escape_name (name->last_component ());
65 bool
66 AST_Annotation_Decl::annotatable () const
68 return false;
71 AST_Annotation_Member *
72 AST_Annotation_Decl::fe_add_annotation_member (
73 AST_Annotation_Member *annotation_member)
75 AST_Decl *d = fe_add_decl (annotation_member);
76 if (d)
78 AST_Type *ft = annotation_member->field_type ();
79 UTL_ScopedName *mru = ft->last_referenced_as ();
80 if (mru)
82 add_to_referenced (ft, false, mru->first_component ());
86 AST_Annotation_Decl *s = dynamic_cast<AST_Annotation_Decl*> (this);
87 if (s)
89 s->fields ().enqueue_tail (annotation_member);
92 return dynamic_cast<AST_Annotation_Member*> (d);
95 AST_Constant *
96 AST_Annotation_Decl::fe_add_constant (AST_Constant *t)
98 return dynamic_cast<AST_Constant*> (fe_add_decl (t));
102 AST_Annotation_Decl::ast_accept (ast_visitor *visitor)
104 ACE_UNUSED_ARG (visitor);
105 return 0;
108 bool
109 AST_Annotation_Decl::ami_visit ()
111 return false;