1 #ifndef TAO_IDL_UTL_SCOPE_T_CPP
2 #define TAO_IDL_UTL_SCOPE_T_CPP
7 #include "global_extern.h"
11 #include "ast_interface_fwd.h"
13 template<typename DECL
>
15 UTL_Scope::fe_add_full_intf_decl (DECL
*t
)
17 if (t
->redef_clash ())
25 if ((predef
= this->lookup_for_add (t
)) != 0)
27 // Treat fwd declared interfaces specially
28 if (predef
->node_type () == DECL::NT
)
30 DECL
*fwd
= dynamic_cast<DECL
*> (predef
);
36 // Forward declared and not defined yet.
37 if (!fwd
->is_defined ())
39 if (fwd
->defined_in () != this)
41 idl_global
->err ()->error3 (UTL_Error::EIDL_SCOPE_CONFLICT
,
49 // OK, not illegal redef of forward declaration. Now check whether.
50 // it has been referenced already.
51 else if (this->referenced (predef
, t
->local_name ()))
53 idl_global
->err ()->error3 (UTL_Error::EIDL_DEF_USE
,
62 else if (!FE_Utils::can_be_redefined (predef
, t
))
64 idl_global
->err ()->error3 (UTL_Error::EIDL_REDEF
,
71 else if (referenced (predef
, t
->local_name ()) && !t
->is_defined ())
73 idl_global
->err ()->error3 (UTL_Error::EIDL_DEF_USE
,
80 else if (t
->has_ancestor (predef
))
82 idl_global
->err ()->redefinition_in_scope (t
, predef
);
89 this->add_to_scope (t
);
91 // We do this for interfaces, valuetypes and components in
92 // a different place than we do for structs and unions,
93 // since fwd declared structs and unions must be defined in
94 // the same translation unit.
95 AST_InterfaceFwd
*fd
= t
->fwd_decl ();
98 fd
->set_as_defined ();
99 fd
->disown_full_definition (); // This scope assumes ownership
102 // Add it to set of locally referenced symbols
103 this->add_to_referenced (t
,
109 template<typename FULL_DECL
>
110 typename
FULL_DECL::FWD_TYPE
*
111 UTL_Scope::fe_add_fwd_intf_decl (typename
FULL_DECL::FWD_TYPE
*t
)
115 // Already defined and cannot be redefined? Or already used?
116 if ((d
= this->lookup_for_add (t
)) != 0)
118 AST_Decl::NodeType nt
= d
->node_type ();
120 // There used to be another check here ANDed with the one below:
121 // d->defined_in () == this. But lookup_for_add() calls only
122 // lookup_by_name_local(), which does not bump up the scope,
123 // and look_in_prev_mods() for modules. If look_in_prev_mods()
124 // finds something, the scopes will NOT be the same pointer
125 // value, but the result is what we want.
126 if (nt
== FULL_DECL::NT
)
128 FULL_DECL
*itf
= dynamic_cast<FULL_DECL
*> (d
);
134 // If the lookup found the full_definition member of another
135 // interface_fwd, don't reset this full_definition. Otherwise
136 // reset the member and set is_defined_ on i so it itf won't
137 // get destroyed twice.
138 if (itf
->is_defined ())
140 t
->set_full_definition (itf
);
141 t
->set_as_defined ();
145 if (!FE_Utils::can_be_redefined (d
, t
))
147 idl_global
->err ()->error3 (UTL_Error::EIDL_REDEF
,
154 // No need to call referenced() for forward declared interafces,
155 // they can be redeclared after referencing.
157 if (t
->has_ancestor (d
))
159 idl_global
->err ()->redefinition_in_scope (t
, d
);
165 this->add_to_scope (t
);
167 // Add it to set of locally referenced symbols
168 this->add_to_referenced (t
,
175 #endif // TAO_IDL_UTL_SCOPE_T_CPP