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
),
13 AST_ConcreteType (NT
, name
),
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 ");
32 this->dump_i (o
, " {\n");
34 idl_global
->indent ()->skip_to (o
);
35 this->dump_i (o
, "}");
38 void AST_Annotation_Decl::destroy ()
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'
53 ACE_OS::strcat (new_name
, old_name
);
54 name
->replace_string (new_name
);
60 AST_Annotation_Decl::escape_name (UTL_ScopedName
*name
)
62 escape_name (name
->last_component ());
66 AST_Annotation_Decl::annotatable () const
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
);
78 AST_Type
*ft
= annotation_member
->field_type ();
79 UTL_ScopedName
*mru
= ft
->last_referenced_as ();
82 add_to_referenced (ft
, false, mru
->first_component ());
86 AST_Annotation_Decl
*s
= dynamic_cast<AST_Annotation_Decl
*> (this);
89 s
->fields ().enqueue_tail (annotation_member
);
92 return dynamic_cast<AST_Annotation_Member
*> (d
);
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
);
109 AST_Annotation_Decl::ami_visit ()