1 #include "ast_annotation_appl.h"
2 #include "ast_annotation_member.h"
4 AST_Annotation_Appl::Param::Param ()
11 AST_Annotation_Appl::Param::~Param ()
26 AST_Annotation_Appl::delete_params (AST_Annotation_Appl::Params
* params
)
30 Params::ITERATOR
iter (*params
);
42 AST_Decl::NodeType
const AST_Annotation_Appl::NT
= AST_Decl::NT_annotation_appl
;
44 AST_Annotation_Appl::AST_Annotation_Appl (
45 UTL_ScopedName
*name
, AST_Annotation_Appl::Params
*params
)
46 : AST_Decl (NT
, name
),
48 AST_ConcreteType (NT
, name
),
50 AST_Structure (name
, false, false),
51 AST_Annotation_Decl (name
),
52 original_name_ (name
->get_string_copy ()),
54 annotation_decl_ (nullptr)
58 AST_Annotation_Appl::~AST_Annotation_Appl ()
60 delete [] original_name_
;
61 delete_params (params_
);
62 AST_Structure::destroy ();
65 void AST_Annotation_Appl::dump (ACE_OSTREAM_TYPE
&o
)
67 dump_i (o
, original_name_
);
71 Params::ITERATOR
iter (*params_
);
92 int AST_Annotation_Appl::ast_accept (ast_visitor
*)
97 void AST_Annotation_Appl::destroy ()
101 const char *AST_Annotation_Appl::original_name () const
103 return original_name_
;
107 AST_Annotation_Appl::apply_from (AST_Annotation_Decl
*decl
)
109 // Apply Each Member From the Annotation Declaration
110 for (UTL_ScopeActiveIterator
si (
112 UTL_Scope::IK_decls
);
116 AST_Annotation_Member
*member
=
117 dynamic_cast<AST_Annotation_Member
*> (si
.item ());
120 AST_Annotation_Member
*new_member
= fe_add_annotation_member (
121 new AST_Annotation_Member (member
->name (), member
));
124 * Check to see if we have a parameter that matches this. If not,
125 * make sure that the member has a default value.
127 Param
*param
= find_param (member
->local_name ()->get_string ());
130 new_member
->value (new AST_Expression (param
->expr
, member
->expr_type()));
131 if (new_member
->invalid_value ())
133 idl_global
->err ()->invalid_annotation_param_type (
134 this, member
, param
->expr
);
139 else if (!new_member
->value ())
141 idl_global
->err ()->annotation_param_missing_error (
148 // Make sure all the parameters were used
151 for (Param::Iterator
it (*params_
);
152 !it
.done (); it
.advance ())
154 Param
**param
= nullptr;
156 if ((*param
) && !(*param
)->used
)
158 idl_global
->err ()->invalid_annotation_param_error (
159 this, decl
, (*param
)->id
);
165 annotation_decl_
= decl
;
170 AST_Annotation_Appl::Params
*
171 AST_Annotation_Appl::params ()
176 AST_Annotation_Decl
*
177 AST_Annotation_Appl::annotation_decl ()
179 return annotation_decl_
;
182 AST_Annotation_Appl::Param
*
183 AST_Annotation_Appl::find_param (const char *name
)
187 // Check for single nameless parameter
188 if (params_
->size () == 1)
190 Param
*top
= nullptr;
192 if (top
&& !top
->id
&& top
->expr
)
194 // Don't reuse it if used
195 return top
->used
? nullptr : top
;
198 for (Param::Iterator
it (*params_
);
199 !it
.done (); it
.advance ())
201 Param
**param
= nullptr;
203 if ((*param
) && (*param
)->id
&& !ACE_OS::strcmp ((*param
)->id
->get_string (), name
))