1 #include "ast_component.h"
2 #include "ast_attribute.h"
3 #include "ast_provides.h"
5 #include "ast_publishes.h"
7 #include "ast_consumes.h"
8 #include "ast_mirror_port.h"
9 #include "ast_visitor.h"
10 #include "utl_identifier.h"
11 #include "utl_indenter.h"
13 #include "global_extern.h"
14 #include "fe_extern.h"
16 AST_Decl::NodeType
const
17 AST_Component::NT
= AST_Decl::NT_component
;
19 AST_Component::AST_Component (UTL_ScopedName
*n
,
20 AST_Component
*base_component
,
23 AST_Interface
**supports_flat
,
27 AST_Decl (AST_Decl::NT_component
,
29 AST_Type (AST_Decl::NT_component
,
31 UTL_Scope (AST_Decl::NT_component
),
39 pd_base_component (base_component
)
41 FE_Utils::tmpl_mod_ref_check (this, base_component
);
43 if (!this->imported ())
45 idl_global
->component_seen_
= true;
49 AST_Component::~AST_Component (void)
54 AST_Component::redefine (AST_Interface
*from
)
56 AST_Component
*c
= dynamic_cast<AST_Component
*> (from
);
60 idl_global
->err ()->redef_error (from
->local_name ()->get_string (),
61 this->local_name ()->get_string ());
65 // Copy over all the base class members.
66 this->AST_Interface::redefine (from
);
68 this->pd_base_component
= c
->pd_base_component
;
72 AST_Component::look_in_inherited (UTL_ScopedName
*e
,
77 if (this->pd_base_component
!= 0)
80 this->pd_base_component
->lookup_by_name_r (
88 // Look through supported interface list.
90 AST_Component::look_in_supported (UTL_ScopedName
*e
,
97 // Can't look in an interface which was not yet defined.
98 if (!this->is_defined ())
100 idl_global
->err ()->fwd_decl_lookup (this, e
);
104 // OK, loop through supported interfaces.
106 for (nis
= this->n_supports (), is
= this->supports ();
110 if ((*is
)->node_type () == AST_Decl::NT_param_holder
)
116 dynamic_cast<AST_Interface
*> (*is
);
118 d
= (i
)->lookup_by_name_r (e
, full_def_only
);
130 AST_Component::base_component (void) const
132 return this->pd_base_component
;
136 AST_Component::supports (void) const
138 return this->inherits ();
142 AST_Component::n_supports (void) const
144 return this->n_inherits ();
148 AST_Component::special_lookup (UTL_ScopedName
*e
,
150 AST_Decl
*&/*final_parent_decl*/)
152 AST_Decl
*d
= this->look_in_inherited (e
, full_def_only
);
156 d
= this->look_in_supported (e
, full_def_only
);
163 AST_Component::destroy (void)
165 this->AST_Interface::destroy ();
169 AST_Component::dump (ACE_OSTREAM_TYPE
&o
)
171 this->dump_i (o
, "component ");
173 this->local_name ()->dump (o
);
175 this->dump_i (o
, " ");
177 if (this->pd_base_component
!= 0)
179 this->dump_i (o
, ": ");
180 this->pd_base_component
->local_name ()->dump (o
);
183 if (this->pd_n_inherits
> 0)
185 this->dump_i (o
, "supports ");
187 for (long i
= 0; i
< this->pd_n_inherits
; ++i
)
189 this->pd_inherits
[i
]->local_name ()->dump (o
);
191 if (i
< this->pd_n_inherits
- 1)
193 this->dump_i (o
, ", ");
198 this->dump_i (o
, " {\n");
201 idl_global
->indent ()->skip_to (o
);
203 this->dump_i (o
, "}");
207 AST_Component::ast_accept (ast_visitor
*visitor
)
209 return visitor
->visit_component (this);
213 AST_Component::fe_add_provides (AST_Provides
*p
)
215 return dynamic_cast<AST_Provides
*> (this->fe_add_ref_decl (p
));
219 AST_Component::fe_add_uses (AST_Uses
*u
)
221 return dynamic_cast<AST_Uses
*> (this->fe_add_ref_decl (u
));
225 AST_Component::fe_add_publishes (AST_Publishes
*p
)
227 return dynamic_cast<AST_Publishes
*> (this->fe_add_ref_decl (p
));
231 AST_Component::fe_add_emits (AST_Emits
*e
)
233 return dynamic_cast<AST_Emits
*> (this->fe_add_ref_decl (e
));
237 AST_Component::fe_add_consumes (AST_Consumes
*c
)
239 return dynamic_cast<AST_Consumes
*> (this->fe_add_ref_decl (c
));
243 AST_Component::fe_add_extended_port (AST_Extended_Port
*p
)
245 return dynamic_cast<AST_Extended_Port
*> (this->fe_add_ref_decl (p
));
249 AST_Component::fe_add_mirror_port (AST_Mirror_Port
*p
)
251 return dynamic_cast<AST_Mirror_Port
*> (this->fe_add_ref_decl (p
));
255 AST_Component::be_add_uses (AST_Uses
*i
,
259 this->add_to_scope (i
,
262 // Add it to set of locally referenced symbols.
263 this->add_to_referenced (i
,
271 IMPL_NARROW_FROM_DECL (AST_Component
)
272 IMPL_NARROW_FROM_SCOPE (AST_Component
)