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 ()),
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_
;
106 IMPL_NARROW_FROM_DECL (AST_Annotation_Appl
)
107 IMPL_NARROW_FROM_SCOPE (AST_Annotation_Appl
)
110 AST_Annotation_Appl::apply_from (AST_Annotation_Decl
*decl
)
112 // Apply Each Member From the Annotation Declaration
113 for (UTL_ScopeActiveIterator
si (
115 UTL_Scope::IK_decls
);
119 AST_Annotation_Member
*member
=
120 dynamic_cast<AST_Annotation_Member
*> (si
.item ());
123 AST_Annotation_Member
*new_member
= fe_add_annotation_member (
124 new AST_Annotation_Member (member
->name (), member
));
127 * Check to see if we have a parameter that matches this. If not,
128 * make sure that the member has a default value.
130 Param
*param
= find_param (member
->local_name ()->get_string ());
133 new_member
->value (new AST_Expression (param
->expr
, member
->expr_type()));
134 if (new_member
->invalid_value ())
136 idl_global
->err ()->invalid_annotation_param_type (
137 this, member
, param
->expr
);
142 else if (!new_member
->value ())
144 idl_global
->err ()->annotation_param_missing_error (
151 // Make sure all the parameters were used
154 for (Param::Iterator
it (*params_
);
155 !it
.done (); it
.advance ())
159 if ((*param
) && !(*param
)->used
)
161 idl_global
->err ()->invalid_annotation_param_error (
162 this, decl
, (*param
)->id
);
168 annotation_decl_
= decl
;
173 AST_Annotation_Appl::Params
*
174 AST_Annotation_Appl::params ()
179 AST_Annotation_Decl
*
180 AST_Annotation_Appl::annotation_decl ()
182 return annotation_decl_
;
185 AST_Annotation_Appl::Param
*
186 AST_Annotation_Appl::find_param (const char *name
)
190 // Check for single nameless parameter
191 if (params_
->size () == 1)
195 if (top
&& !top
->id
&& top
->expr
)
197 // Don't reuse it if used
198 return top
->used
? 0 : top
;
201 for (Param::Iterator
it (*params_
);
202 !it
.done (); it
.advance ())
206 if ((*param
) && (*param
)->id
&& !ACE_OS::strcmp ((*param
)->id
->get_string (), name
))