summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-07-11 16:25:14 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-07-11 16:25:14 +0000
commitabad303e6389f67a86e325900b85dc86bad188c1 (patch)
tree23e3be716cc5e3cb34db6d9d66a1e221c0fbf17f
parent25db436df7db46c612ce25aaa1ef20d24e05faa7 (diff)
downloadATCD-abad303e6389f67a86e325900b85dc86bad188c1.tar.gz
#if defined _FOO__CI_ guard around object constructor from Stub,
replaced nested type name with full name in _unchecked_narrow, and added member, iterator, and functions to AST_Module to deal with lookups of declarations from a previous opening.
-rw-r--r--TAO/TAO_IDL/ast/ast_module.cpp70
-rw-r--r--TAO/TAO_IDL/be/be_generator.cpp73
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp4
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp3
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp4
-rw-r--r--TAO/TAO_IDL/include/ast_module.h12
-rw-r--r--TAO/TAO_IDL/util/utl_scope.cpp24
7 files changed, 141 insertions, 49 deletions
diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp
index f518f628010..36dbc4ac08f 100644
--- a/TAO/TAO_IDL/ast/ast_module.cpp
+++ b/TAO/TAO_IDL/ast/ast_module.cpp
@@ -748,9 +748,79 @@ AST_Module::add_CORBA_members (void)
# endif /* IDL_HAS_VALUETYPE */
}
+void
+AST_Module::add_to_previous (AST_Module *m)
+{
+ // Here, we depend on the scope iterator in
+ // be_generator::create_module (which calls this function)
+ // to return items in the order they were declared or included.
+ // That means that the last module returned that matches the name
+ // of this one will have all the decls from all previous
+ // reopenings in its previous_ member.
+ this->previous_ = m->previous_;
+
+ UTL_ScopeActiveIterator *i =
+ new UTL_ScopeActiveIterator (DeclAsScope (m),
+ UTL_Scope::IK_decls);
+
+ AST_Decl *d = 0;
+
+ while (!i->is_done ())
+ {
+ d = i->item ();
+
+ // Add all the previous opening's decls (except
+ // for the predefined types) to the 'previous' list
+ // of this one.
+ if (d->node_type () != AST_Decl::NT_pre_defined)
+ {
+ this->previous_.insert (d);
+ }
+
+ i->next ();
+ }
+
+ delete i;
+}
+
+AST_Decl *
+AST_Module::look_in_previous (Identifier *e)
+{
+ AST_Decl *d = 0;
+ ACE_Unbounded_Set_Iterator<AST_Decl *> iter (this->previous_);
+
+ while (!iter.done ())
+ {
+ d = *iter;
+
+ if (e->case_compare (d->local_name ()))
+ {
+ return d;
+ }
+
+ iter++;
+ }
+
+ return 0;
+}
+
/*
* Narrowing methods
*/
IMPL_NARROW_METHODS2(AST_Module, AST_Decl, UTL_Scope)
IMPL_NARROW_FROM_DECL(AST_Module)
IMPL_NARROW_FROM_SCOPE(AST_Module)
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+template class ACE_Node<AST_Decl *>;
+template class ACE_Unbounded_Set<AST_Decl *>;
+template class ACE_Unbounded_Set_Iterator<AST_Decl *>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+#pragma instantiate ACE_Node<AST_Decl *>
+#pragma instantiate ACE_Unbounded_Set<AST_Decl *>
+#pragma instantiate ACE_Unbounded_Set_Iterator<AST_Decl *>
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp
index eb828868fcc..6eadddf6cac 100644
--- a/TAO/TAO_IDL/be/be_generator.cpp
+++ b/TAO/TAO_IDL/be/be_generator.cpp
@@ -125,6 +125,7 @@ be_generator::create_module (UTL_Scope *s,
UTL_StrList *p)
{
AST_Decl *d = 0;
+ AST_Module *m = 0;
UTL_ScopeActiveIterator *iter =
new UTL_ScopeActiveIterator (s,
UTL_Scope::IK_decls);
@@ -146,46 +147,11 @@ be_generator::create_module (UTL_Scope *s,
// supposed to create.
if (d->local_name ()->compare (n->last_component ()))
{
- // If the node in our scope and the one being created
- // are either both #included or both not #included, just
- // return the node from the scope and continue adding
- // members to it as they're parsed.
- if (d->imported () == idl_global->imported ())
- {
- delete iter;
- delete retval;
- return AST_Module::narrow_from_decl (d);
- }
- else
- {
- // The node in our scope is #included (note that
- // because of the above case there will be only
- // one), but the one being created is not. We add
- // the #included module's members to the new node
- // and return it.
- UTL_ScopeActiveIterator *i =
- new UTL_ScopeActiveIterator (DeclAsScope (d),
- UTL_Scope::IK_decls);
-
- AST_Decl *dd = 0;
-
- while (!i->is_done ())
- {
- dd = i->item ();
-
- // Add all the included module's members (except
- // for the predefined types) to the scope of the
- // one we're creating.
- if (dd->node_type () != AST_Decl::NT_pre_defined)
- {
- retval->add_to_scope (dd);
- }
-
- i->next ();
- }
-
- delete i;
- }
+ m = AST_Module::narrow_from_decl (d);
+
+ // Get m's previous_ member, plus all it's decls,
+ // into the new modules's previous_ member.
+ retval->add_to_previous (m);
}
}
@@ -194,6 +160,33 @@ be_generator::create_module (UTL_Scope *s,
delete iter;
+ // If this scope is itself a module, and has been previously
+ // opened, the previous opening may contain a previous opening
+ // of the module we're creating.
+ d = ScopeAsDecl (s);
+ AST_Decl::NodeType nt = d->node_type ();
+
+ if (nt == AST_Decl::NT_module || nt == AST_Decl::NT_root)
+ {
+ m = AST_Module::narrow_from_decl (d);
+
+ // AST_Module::previous_ is a set, so it contains each
+ // entry only once, but previous_ will contain the decls
+ // from all previous openings. See comment in
+ // AST_Module::add_to_previous() body.
+ d = m->look_in_previous (n->last_component ());
+
+ if (d != 0)
+ {
+ if (d->node_type () == AST_Decl::NT_module)
+ {
+ m = AST_Module::narrow_from_decl (d);
+
+ retval->add_to_previous (m);
+ }
+ }
+ }
+
// If we are opening module CORBA, we must add the predefined
// types TypeCode, TCKind and maybe ValueBase.
if (!ACE_OS::strcmp (retval->local_name ()->get_string (), "CORBA"))
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp
index 730caa383ee..e6b033913b3 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp
@@ -68,13 +68,15 @@ be_visitor_interface_ci::visit_interface (be_interface *node)
// Generate the constructor from stub and servant.
if (! node->is_local ())
{
+ os->gen_ifdef_macro (node->flat_name (), "");
*os << "ACE_INLINE" << be_nl;
*os << node->name () << "::" << node->local_name () <<
" (TAO_Stub *objref, TAO_ServantBase *_tao_servant, "
<< "CORBA::Boolean _tao_collocated) // constructor" << be_nl;
*os << " : CORBA_Object (objref, _tao_servant, _tao_collocated)"
<< be_nl;
- *os << "{}" << be_nl << be_nl;
+ *os << "{}" << be_nl;
+ os->gen_endif ();
}
// generate the ifdefined macro for the _var type
diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp
index 9e0e3f1ca82..a0802da2c3c 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp
@@ -155,8 +155,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node)
// The default proxy will either be returned else be transformed to
// a smart one!
*os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl
- << "ACE_NEW_RETURN (default_proxy, "
- << bt->nested_type_name (this->ctx_->scope ())
+ << "ACE_NEW_RETURN (default_proxy, ::" << bt->name ()
<< " (stub), " << bt->nested_type_name (this->ctx_->scope ())
<< "::_nil ());"<< be_uidt_nl
<< "#if (TAO_HAS_SMART_PROXIES == 1)" << be_idt_nl
diff --git a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp
index 18f061fd46e..9dab904787e 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface_fwd/interface_fwd_ci.cpp
@@ -54,13 +54,15 @@ be_visitor_interface_fwd_ci::visit_interface_fwd (be_interface_fwd *node)
if (! node->is_local ())
{
+ os->gen_ifdef_macro (node->flat_name (), "");
*os << "ACE_INLINE" << be_nl;
*os << node->name () << "::" << node->local_name () <<
" (TAO_Stub *objref, TAO_ServantBase *_tao_servant, "
<< "CORBA::Boolean _tao_collocated) // constructor" << be_nl;
*os << " : CORBA_Object (objref, _tao_servant, _tao_collocated)"
<< be_nl;
- *os << "{}" << be_nl << be_nl;
+ *os << "{}" << be_nl;
+ os->gen_endif ();
}
// Generate the constructor from stub and servant.
diff --git a/TAO/TAO_IDL/include/ast_module.h b/TAO/TAO_IDL/include/ast_module.h
index d7147cb52c1..2f02ed48c5b 100644
--- a/TAO/TAO_IDL/include/ast_module.h
+++ b/TAO/TAO_IDL/include/ast_module.h
@@ -113,6 +113,15 @@ public:
// TypeCode, TCKind and ValueBase to its scope.
void add_CORBA_members (void);
+ // Add decls from previous opening of this module to the
+ // 'previous' set of this module, along with the argument's
+ // own 'previous' set.
+ void add_to_previous (AST_Module *m);
+
+ // Called by lookup_by_name_local, to check for declaration
+ // in a previous opening of this module.
+ AST_Decl *look_in_previous (Identifier *e);
+
private:
friend void fe_populate(AST_Module *m);
friend int tao_yyparse();
@@ -134,6 +143,9 @@ private:
virtual AST_Native *fe_add_native (AST_Native *n);
idl_bool pd_has_nested_valuetype;
+
+ ACE_Unbounded_Set<AST_Decl *> previous_;
+ // Container for declaration from previous openings of this module.
};
#endif // _AST_MODULE_AST_MODULE_HH
diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp
index 65f69b39449..7a9b7247b71 100644
--- a/TAO/TAO_IDL/util/utl_scope.cpp
+++ b/TAO/TAO_IDL/util/utl_scope.cpp
@@ -872,9 +872,11 @@ UTL_Scope::lookup_by_name_local (Identifier *e,
return d;
}
else
- // This is an instance of a reopened modules that matches the
- // input indentifier, but the rest of the scoped name didn't
- // match.
+ // If the index has been incremented, it means the identifier
+ // matched on a previous call to this function, but after
+ // returning, the rest of the scoped name didn't match. So we
+ // see if there's another matching identifier to the 'head' of
+ // the scoped name we're working with.
{
index--;
i->next ();
@@ -887,8 +889,20 @@ UTL_Scope::lookup_by_name_local (Identifier *e,
delete i;
- // OK, not found, return NULL
- return NULL;
+ // OK, not found, check if this scope is a module, and if so,
+ // look in previous openings, if any.
+ d = ScopeAsDecl (this);
+
+ if (d->node_type () == AST_Decl::NT_module)
+ {
+ AST_Module *m = AST_Module::narrow_from_decl (d);
+
+ return m->look_in_previous (e);
+ }
+ else
+ {
+ return 0;
+ }
}
/*