summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/ChangeLog21
-rw-r--r--TAO/TAO_IDL/ast/ast_decl.cpp687
-rw-r--r--TAO/TAO_IDL/ast/ast_generator.cpp97
-rw-r--r--TAO/TAO_IDL/ast/ast_module.cpp305
-rw-r--r--TAO/TAO_IDL/be/be_module.cpp12
-rw-r--r--TAO/TAO_IDL/include/utl_scope.h2
-rw-r--r--TAO/TAO_IDL/util/utl_scope.cpp601
7 files changed, 969 insertions, 756 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index d345034d498..e38051e5d68 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,22 +1,23 @@
+Fri Jun 11 09:50:00 UTC 2010 Simon Massey <simon dot massey at prismtech dot com>
+
+ * TAO_IDL/ast/ast_module.cpp:
+ * TAO_IDL/ast/ast_generator.cpp:
+ * TAO_IDL/ast/ast_decl.cpp:
+ * TAO_IDL/be/be_module.cpp:
+ * TAO_IDL/include/utl_scope.h:
+ * TAO_IDL/util/utl_scope.cpp:
+
+ Previous commit missed some of the file revertions.
+
Fri Jun 11 09:37:00 UTC 2010 Simon Massey <simon dot massey at prismtech dot com>
* NEWS:
* TAO_IDL/ast/ast_structure_fwd.cpp:
- * TAO_IDL/ast/ast_module.cpp:
- * TAO_IDL/ast/ast_generator.cpp:
* TAO_IDL/ast/ast_interface_fwd.cpp:
* TAO_IDL/ast/ast_component_fwd.cpp:
- * TAO_IDL/ast/ast_decl.cpp:
* TAO_IDL/ast/ast_template_module_ref.cpp:
- * TAO_IDL/be/be_module.cpp:
* TAO_IDL/be/be_generator.cpp:
* TAO_IDL/be_include/be_module.h:
- * TAO_IDL/include/ast_module.h:
- * TAO_IDL/include/ast_interface_fwd.h:
- * TAO_IDL/include/ast_component_fwd.h:
- * TAO_IDL/include/ast_decl.h:
- * TAO_IDL/include/ast_template_module_ref.h:
- * TAO_IDL/include/ast_structure_fwd.h:
* TAO_IDL/include/utl_scope.h:
* TAO_IDL/util/utl_scope.cpp:
diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp
index a2cb4ed0ffd..8d9588d811f 100644
--- a/TAO/TAO_IDL/ast/ast_decl.cpp
+++ b/TAO/TAO_IDL/ast/ast_decl.cpp
@@ -157,87 +157,33 @@ AST_Decl::AST_Decl (NodeType nt,
{
// If this is the root node, the filename won't have been set yet.
UTL_String *fn = idl_global->filename ();
- this->pd_file_name = (fn ? fn->get_string () : "");
+ this->pd_file_name = (fn != 0 ? fn->get_string () : "");
this->compute_full_name (n);
char *prefix = 0;
idl_global->pragma_prefixes ().top (prefix);
- this->prefix_ = ACE::strnew (prefix ? prefix : "");
- if (n)
+ if (prefix == 0)
{
- // The function body creates its own copy.
- this->original_local_name (n->last_component ());
- }
-
- this->compute_repoID ();
-}
-
-AST_Decl::~AST_Decl (void)
-{
-}
-
-void
-AST_Decl::destroy (void)
-{
- // These are not set for the root node.
- if (this->pd_name)
- {
- this->pd_name->destroy ();
- delete this->pd_name;
- this->pd_name = 0;
- }
-
- if (this->pd_local_name)
- {
- this->pd_local_name->destroy ();
- delete this->pd_local_name;
- this->pd_local_name = 0;
+ this->prefix_ = ACE::strnew ("");
}
-
- if (this->pd_original_local_name)
+ else
{
- this->pd_original_local_name->destroy ();
- delete this->pd_original_local_name;
- this->pd_original_local_name = 0;
+ this->prefix_ = ACE::strnew (prefix);
}
- if (this->last_referenced_as_)
+ if (n != 0)
{
- this->last_referenced_as_->destroy ();
- delete this->last_referenced_as_;
- this->last_referenced_as_ = 0;
+ // The function body creates its own copy.
+ this->original_local_name (n->last_component ());
}
- delete [] this->full_name_;
- this->full_name_ = 0;
-
- delete [] this->repoID_;
- this->repoID_ = 0;
-
- delete [] this->prefix_;
- this->prefix_ = 0;
-
- delete [] this->version_;
- this->version_ = 0;
-
- delete [] this->flat_name_;
- this->flat_name_ = 0;
-}
-
-AST_Decl *
-AST_Decl::adjust_found (
- bool /*ignore_fwd*/,
- bool /*full_def_only*/)
-{
- return this; // Defaults to no adjustment
+ this->compute_repoID ();
}
-bool
-AST_Decl::is_fwd (void)
+AST_Decl::~AST_Decl (void)
{
- return false; // Not a fwd declared type (by default)
}
// Private operations.
@@ -249,50 +195,54 @@ AST_Decl::compute_full_name (UTL_ScopedName *n)
// This should happen only when we are a non-void predefined type,
// in which case our scoped name has already been created by the
// AST_PredefinedType constructor.
- if (!n)
+ if (n == 0)
{
return;
}
+ UTL_ScopedName *cn = 0;
+ AST_Decl *d = 0;
+
+ // Initialize this name to 0.
+ this->pd_name = 0;
+
// Global scope?
- if (!this->defined_in ())
+ if (this->defined_in () == 0)
{
this->pd_name = (UTL_IdList *) n->copy ();
return;
}
- // Initialize this name to 0.
- this->pd_name = 0;
-
// OK, not global. So copy name of containing scope, then
// smash last cdr of copy with new component
- UTL_ScopedName *cn = 0;
- AST_Decl *d = ScopeAsDecl (this->defined_in ());
- if (d)
+ d = ScopeAsDecl (this->defined_in ());
+
+ if (d != 0)
{
cn = d->name ();
- if (cn)
- {
- this->pd_name = (UTL_IdList *) cn->copy ();
- }
}
- if (this->pd_local_name)
+ if (cn != 0)
{
- if (this->pd_name)
+ this->pd_name = (UTL_IdList *) cn->copy ();
+ }
+
+ if (this->pd_local_name != 0)
+ {
+ if (this->pd_name == 0)
{
- UTL_ScopedName *conc_name = 0;
- ACE_NEW (conc_name,
+ ACE_NEW (this->pd_name,
UTL_ScopedName (this->pd_local_name->copy (),
0));
-
- this->pd_name->nconc (conc_name);
}
else
{
- ACE_NEW (this->pd_name,
+ UTL_ScopedName *conc_name = 0;
+ ACE_NEW (conc_name,
UTL_ScopedName (this->pd_local_name->copy (),
0));
+
+ this->pd_name->nconc (conc_name);
}
}
}
@@ -306,11 +256,13 @@ AST_Decl::set_prefix_with_typeprefix_r (const char *value,
return;
}
- if (this->prefix_scope_)
+ if (this->prefix_scope_ != 0)
{
AST_Decl *decl = ScopeAsDecl (this->prefix_scope_);
+
bool const overridden =
decl->has_ancestor (ScopeAsDecl (appeared_in));
+
if (overridden)
{
return;
@@ -323,19 +275,26 @@ AST_Decl::set_prefix_with_typeprefix_r (const char *value,
this->prefix_scope_ = appeared_in;
UTL_Scope *s = DeclAsScope (this);
- if (s)
+
+ if (s != 0)
{
+ AST_Decl *tmp = 0;
+ UTL_Scope *s_tmp = 0;
+
for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_decls);
!i.is_done ();
i.next ())
{
- AST_Decl *tmp = i.item ();
- UTL_Scope *s_tmp = DeclAsScope (tmp);
- if (s_tmp)
+ tmp = i.item ();
+ s_tmp = DeclAsScope (tmp);
+
+ if (s_tmp == 0)
{
- tmp->set_prefix_with_typeprefix_r (value,
- appeared_in);
+ continue;
}
+
+ tmp->set_prefix_with_typeprefix_r (value,
+ appeared_in);
}
}
@@ -343,18 +302,27 @@ AST_Decl::set_prefix_with_typeprefix_r (const char *value,
if (this->node_type () == AST_Decl::NT_module)
{
AST_Module *m = AST_Module::narrow_from_decl (this);
- while (!!(m = m->previous_opening ()))
+
+ for (ACE_Unbounded_Set_Iterator<AST_Module *> iter (m->prev_mods ());
+ !iter.done ();
+ iter.advance ())
{
- for (UTL_ScopeActiveIterator si (m, UTL_Scope::IK_decls);
+ AST_Module **m = 0;
+ iter.next (m);
+
+ for (UTL_ScopeActiveIterator si (*m, UTL_Scope::IK_decls);
!si.is_done ();
si.next ())
{
AST_Decl *d = si.item ();
- if (d->node_type () != AST_Decl::NT_pre_defined)
+
+ if (d->node_type () == AST_Decl::NT_pre_defined)
{
- d->set_prefix_with_typeprefix_r (value,
- appeared_in);
+ continue;
}
+
+ d->set_prefix_with_typeprefix_r (value,
+ appeared_in);
}
}
}
@@ -368,7 +336,11 @@ AST_Decl::set_prefix_with_typeprefix_r (const char *value,
void
AST_Decl::compute_full_name (void)
{
- if (!this->full_name_)
+ if (this->full_name_ != 0)
+ {
+ return;
+ }
+ else
{
size_t namelen = 0;
long first = true;
@@ -394,7 +366,7 @@ AST_Decl::compute_full_name (void)
if (first)
{
- if (ACE_OS::strcmp (name, ""))
+ if (ACE_OS::strcmp (name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -432,7 +404,7 @@ AST_Decl::compute_full_name (void)
if (first)
{
- if (ACE_OS::strcmp (name, ""))
+ if (ACE_OS::strcmp (name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -450,7 +422,7 @@ AST_Decl::compute_full_name (void)
void
AST_Decl::compute_repoID (void)
{
- if (this->repoID_)
+ if (this->repoID_ != 0)
{
return;
}
@@ -464,9 +436,10 @@ AST_Decl::compute_repoID (void)
const char *parent_prefix = 0;
// If our prefix is empty, we check to see if an ancestor has one.
- while (scope && ACE_OS::strcmp (prefix, ""))
+ while (ACE_OS::strcmp (prefix, "") == 0 && scope != 0)
{
AST_Decl *parent = ScopeAsDecl (scope);
+
if (parent->node_type () == AST_Decl::NT_root
&& parent->imported ())
{
@@ -485,14 +458,14 @@ AST_Decl::compute_repoID (void)
scope = this->defined_in ();
// If our version is has not bee set, we use the parent's, if any.
- while (!version && scope)
+ while (version == 0 && scope != 0)
{
AST_Decl *parent = ScopeAsDecl (scope);
version = parent->version_;
scope = parent->defined_in ();
}
- if (version)
+ if (version != 0)
{
// Version member string + ':'
namelen += ACE_OS::strlen (version) + 1;
@@ -531,7 +504,7 @@ AST_Decl::compute_repoID (void)
if (first)
{
- if (ACE_OS::strcmp (name, ""))
+ if (ACE_OS::strcmp (name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -548,11 +521,15 @@ AST_Decl::compute_repoID (void)
this->repoID_[0] = '\0';
- ACE_OS::sprintf (this->repoID_, "IDL:");
+ ACE_OS::sprintf (this->repoID_,
+ "%s",
+ "IDL:");
- if (ACE_OS::strcmp (prefix, ""))
+ if (ACE_OS::strcmp (prefix, "") != 0)
{
- ACE_OS::strcat (this->repoID_, prefix);
+ ACE_OS::strcat (this->repoID_,
+ prefix);
+
ACE_OS::strcat (this->repoID_, "/");
}
@@ -588,7 +565,7 @@ AST_Decl::compute_repoID (void)
if (first)
{
- if (ACE_OS::strcmp (name, ""))
+ if (ACE_OS::strcmp (name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -600,14 +577,17 @@ AST_Decl::compute_repoID (void)
}
}
- if (version)
+ if (version != 0)
{
- ACE_OS::strcat (this->repoID_, ":");
- ACE_OS::strcat (this->repoID_, version);
+ ACE_OS::strcat (this->repoID_,
+ ":");
+ ACE_OS::strcat (this->repoID_,
+ version);
}
else
{
- ACE_OS::strcat (this->repoID_, ":1.0");
+ ACE_OS::strcat (this->repoID_,
+ ":1.0");
}
}
@@ -628,7 +608,11 @@ AST_Decl::flat_name (void)
void
AST_Decl::compute_flat_name (void)
{
- if (!this->flat_name_)
+ if (this->flat_name_ != 0)
+ {
+ return;
+ }
+ else
{
size_t namelen = 0;
long first = true;
@@ -658,7 +642,7 @@ AST_Decl::compute_flat_name (void)
if (first)
{
- if (ACE_OS::strcmp (item_name, ""))
+ if (ACE_OS::strcmp (item_name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -668,7 +652,7 @@ AST_Decl::compute_flat_name (void)
second = true;
}
}
-
+
tmp->destroy ();
delete tmp;
tmp = 0;
@@ -703,7 +687,7 @@ AST_Decl::compute_flat_name (void)
if (first)
{
- if (ACE_OS::strcmp (item_name, ""))
+ if (ACE_OS::strcmp (item_name, "") != 0)
{
// Does not start with a "".
first = false;
@@ -726,106 +710,78 @@ AST_Decl::node_type_to_string (NodeType nt)
{
switch (nt)
{
- case NT_module:
- return "module";
-
- case NT_interface:
- case NT_interface_fwd:
- return "interface";
-
- case NT_valuetype:
- case NT_valuetype_fwd:
- case NT_valuebox:
- return "valuetype";
-
- case NT_const:
- return "const";
-
- case NT_except:
- return "exception";
-
- case NT_attr:
- return "attribute";
-
- case NT_union:
- case NT_union_fwd:
- return "union";
-
- case NT_struct:
- case NT_struct_fwd:
- return "struct";
-
- case NT_enum:
- return "enum";
-
- case NT_string:
- return "string";
-
- case NT_wstring:
- return "wstring";
-
- case NT_array:
- return "array";
-
- case NT_sequence:
- return "sequence";
-
- case NT_typedef:
- return "typedef";
-
- case NT_pre_defined:
- return "primitive";
-
- case NT_native:
- return "native";
-
- case NT_factory:
- return "factory";
-
- case NT_component:
- case NT_component_fwd:
- return "component";
-
- case NT_home:
- return "home";
-
- case NT_eventtype:
- case NT_eventtype_fwd:
- return "eventtype";
-
- case NT_type:
- return "typename";
-
- case NT_fixed:
- return "fixed";
-
- case NT_porttype:
- return "porttype";
-
- case NT_provides:
- return "provides";
-
- case NT_uses:
- return "uses";
-
- case NT_publishes:
- return "publishes";
-
- case NT_emits:
- return "emits";
-
- case NT_consumes:
- return "consumes";
-
+ case NT_module:
+ return "module";
+ case NT_interface:
+ case NT_interface_fwd:
+ return "interface";
+ case NT_valuetype:
+ case NT_valuetype_fwd:
+ case NT_valuebox:
+ return "valuetype";
+ case NT_const:
+ return "const";
+ case NT_except:
+ return "exception";
+ case NT_attr:
+ return "attribute";
+ case NT_union:
+ case NT_union_fwd:
+ return "union";
+ case NT_struct:
+ case NT_struct_fwd:
+ return "struct";
+ case NT_enum:
+ return "enum";
+ case NT_string:
+ return "string";
+ case NT_wstring:
+ return "wstring";
+ case NT_array:
+ return "array";
+ case NT_sequence:
+ return "sequence";
+ case NT_typedef:
+ return "typedef";
+ case NT_pre_defined:
+ return "primitive";
+ case NT_native:
+ return "native";
+ case NT_factory:
+ return "factory";
+ case NT_component:
+ case NT_component_fwd:
+ return "component";
+ case NT_home:
+ return "home";
+ case NT_eventtype:
+ case NT_eventtype_fwd:
+ return "eventtype";
+ case NT_type:
+ return "typename";
+ case NT_fixed:
+ return "fixed";
+ case NT_porttype:
+ return "porttype";
+ case NT_provides:
+ return "provides";
+ case NT_uses:
+ return "uses";
+ case NT_publishes:
+ return "publishes";
+ case NT_emits:
+ return "emits";
+ case NT_consumes:
+ return "consumes";
// No useful output for these.
- case NT_enum_val:
- case NT_field:
- case NT_union_branch:
- case NT_op:
- case NT_argument:
- case NT_root:
- default:
- return "";
+ case NT_enum_val:
+ case NT_field:
+ case NT_union_branch:
+ case NT_op:
+ case NT_argument:
+ case NT_root:
+ default:
+ return "";
}
}
@@ -834,32 +790,44 @@ AST_Decl::node_type_to_string (NodeType nt)
bool
AST_Decl::has_ancestor (AST_Decl *s)
{
- AST_Decl *work = this;
- do
+ if (this == s)
{
- if (work == s)
- {
- return true;
- }
+ return true;
+ }
+
+ AST_Module *m = AST_Module::narrow_from_decl (s);
- AST_Module *m = AST_Module::narrow_from_decl (s);
- if (m)
+ if (m != 0)
+ {
+ ACE_Unbounded_Set<AST_Module *> &prev = m->prev_mods ();
+
+ for (ACE_Unbounded_Set<AST_Module *>::CONST_ITERATOR i (prev);
+ !i.done ();
+ i.advance ())
{
- while (!!(m = m->previous_opening ()))
+ AST_Module **mm = 0;
+ i.next (mm);
+
+ for (UTL_ScopeActiveIterator si (*mm, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
{
- if (static_cast<AST_Decl *> (m) == work)
+ AST_Decl *d = si.item ();
+
+ if (this == d)
{
return true;
}
}
}
+ }
- work = work->pd_defined_in ?
- ScopeAsDecl (work->pd_defined_in) :
- 0;
- } while (work);
+ if (this->pd_defined_in == 0)
+ {
+ return false;
+ }
- return false;
+ return ScopeAsDecl (this->pd_defined_in)->has_ancestor (s);
}
bool
@@ -868,12 +836,13 @@ AST_Decl::is_child (AST_Decl *s)
if (this->defined_in ())
{
AST_Decl *d = ScopeAsDecl (this->defined_in ());
- if (!d)
+
+ if (d == 0)
{
return 0;
}
- if (!ACE_OS::strcmp (d->full_name (), s->full_name ()))
+ if (ACE_OS::strcmp (d->full_name (), s->full_name ()) == 0)
{
return 1;
}
@@ -889,7 +858,12 @@ AST_Decl::is_nested (void)
// If we have an outermost scope and if that scope is not that of the Root,
// then we are defined at some nesting level.
- return (d && d->node_type () != AST_Decl::NT_root);
+ if (d != 0 && d->node_type () != AST_Decl::NT_root)
+ {
+ return true;
+ }
+
+ return false;
}
// Dump this AST_Decl to the ostream o.
@@ -913,12 +887,60 @@ AST_Decl::ast_accept (ast_visitor *visitor)
return visitor->visit_decl (this);
}
+void
+AST_Decl::destroy (void)
+{
+ // These are not set for the root node.
+ if (this->pd_name != 0)
+ {
+ this->pd_name->destroy ();
+ delete this->pd_name;
+ this->pd_name = 0;
+ }
+
+ if (this->pd_local_name != 0)
+ {
+ this->pd_local_name->destroy ();
+ delete this->pd_local_name;
+ this->pd_local_name = 0;
+ }
+
+ if (this->pd_original_local_name != 0)
+ {
+ this->pd_original_local_name->destroy ();
+ delete this->pd_original_local_name;
+ this->pd_original_local_name = 0;
+ }
+
+ if (this->last_referenced_as_ != 0)
+ {
+ this->last_referenced_as_->destroy ();
+ delete this->last_referenced_as_;
+ this->last_referenced_as_ = 0;
+ }
+
+ delete [] this->full_name_;
+ this->full_name_ = 0;
+
+ delete [] this->repoID_;
+ this->repoID_ = 0;
+
+ delete [] this->prefix_;
+ this->prefix_ = 0;
+
+ delete [] this->version_;
+ this->version_ = 0;
+
+ delete [] this->flat_name_;
+ this->flat_name_ = 0;
+}
+
// Data accessors.
const char *
AST_Decl::full_name (void)
{
- if (!this->full_name_)
+ if (this->full_name_ == 0)
{
this->compute_full_name ();
}
@@ -935,7 +957,7 @@ AST_Decl::repoID (void)
this->repoID_ = ACE::strnew ("");
}
- if (!this->repoID_)
+ if (this->repoID_ == 0)
{
this->compute_repoID ();
}
@@ -946,7 +968,7 @@ AST_Decl::repoID (void)
void
AST_Decl::repoID (char *value)
{
- if (this->repoID_)
+ if (this->repoID_ != 0)
{
delete [] this->repoID_;
}
@@ -970,7 +992,7 @@ AST_Decl::prefix (const char *value)
const char *
AST_Decl::version (void)
{
- if (!this->version_)
+ if (this->version_ == 0)
{
// Calling the method will compute if necessary.
const char *repo_id = this->repoID ();
@@ -980,17 +1002,19 @@ AST_Decl::version (void)
const char *tail1 = 0;
const char *tail2 = 0;
- if (repo_id)
+ if (repo_id != 0)
{
- tail1 = ACE_OS::strchr (repo_id, ':');
+ tail1 = ACE_OS::strchr (repo_id,
+ ':');
}
- if (tail1)
+ if (tail1 != 0)
{
- tail2 = ACE_OS::strchr (tail1 + 1, ':');
+ tail2 = ACE_OS::strchr (tail1 + 1,
+ ':');
}
- if (!this->typeid_set_ && tail2)
+ if (! this->typeid_set_ && tail2 != 0)
{
this->version_ = ACE::strnew (tail2 + 1);
}
@@ -1007,15 +1031,15 @@ void
AST_Decl::version (char *value)
{
// Previous #pragma version or #pragma id make this illegal.
- if ((!this->version_ || !ACE_OS::strcmp (this->version_, value))
- && !this->typeid_set_)
+ if ((this->version_ == 0 || ACE_OS::strcmp (this->version_, value) == 0)
+ && ! this->typeid_set_)
{
delete [] this->version_;
this->version_ = value;
// Repo id is now computed eagerly, so a version set must update
// is as well.
- if (this->repoID_)
+ if (this->repoID_ != 0)
{
ACE_CString tmp (this->repoID_);
ACE_CString::size_type const pos = tmp.rfind (':');
@@ -1070,14 +1094,13 @@ AST_Decl::set_id_with_typeid (char *value)
// Are we a legal type for 'typeid'?
switch (this->pd_node_type)
- {
+ {
case AST_Decl::NT_field:
{
AST_Decl::NodeType nt =
ScopeAsDecl (this->defined_in ())->node_type ();
- if ( nt == AST_Decl::NT_valuetype
- || nt == AST_Decl::NT_eventtype)
+ if (nt == AST_Decl::NT_valuetype || nt == AST_Decl::NT_eventtype)
{
break;
}
@@ -1085,10 +1108,10 @@ AST_Decl::set_id_with_typeid (char *value)
{
idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID,
this);
+
return;
}
}
-
case AST_Decl::NT_module:
case AST_Decl::NT_interface:
case AST_Decl::NT_const:
@@ -1102,12 +1125,12 @@ AST_Decl::set_id_with_typeid (char *value)
case AST_Decl::NT_home:
case AST_Decl::NT_eventtype:
break;
-
default:
idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID,
this);
+
return;
- }
+ }
delete [] this->repoID_;
this->repoID_ = 0;
@@ -1121,7 +1144,7 @@ AST_Decl::set_prefix_with_typeprefix (const char *value)
// Are we a legal type for 'typeprefix'? This is checked only at
// the top level.
switch (this->pd_node_type)
- {
+ {
case AST_Decl::NT_module:
case AST_Decl::NT_interface:
case AST_Decl::NT_valuetype:
@@ -1130,12 +1153,12 @@ AST_Decl::set_prefix_with_typeprefix (const char *value)
case AST_Decl::NT_union:
case AST_Decl::NT_except:
break;
-
default:
idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEPREFIX,
this);
+
return;
- }
+ }
this->set_prefix_with_typeprefix_r (value,
DeclAsScope (this));
@@ -1222,11 +1245,13 @@ UTL_ScopedName *
AST_Decl::compute_name (const char *prefix,
const char *suffix)
{
- if (!prefix || !suffix)
+ if (prefix == 0 || suffix == 0)
{
return 0;
}
+ UTL_ScopedName *result_name = 0;
+
// Prepare prefix_<local_name>_suffix string.
ACE_CString suffix_str (suffix);
@@ -1245,12 +1270,12 @@ AST_Decl::compute_name (const char *prefix,
// UTL_Scoped name for the resulting local name.
UTL_ScopedName *result_local_name = 0;
ACE_NEW_RETURN (result_local_name,
- UTL_ScopedName (result_local_id, 0),
+ UTL_ScopedName (result_local_id,
+ 0),
0);
// Global scope?
- UTL_ScopedName *result_name = 0;
- if (!this->defined_in ())
+ if (this->defined_in () == 0)
{
result_name = result_local_name;
}
@@ -1260,19 +1285,22 @@ AST_Decl::compute_name (const char *prefix,
// smash last cdr of copy with new component.
AST_Decl *d = ScopeAsDecl (this->defined_in ());
- if (d)
+
+ if (d != 0)
{
UTL_ScopedName *cn = d->name ();
- if (cn)
+
+ if (cn != 0)
{
result_name = (UTL_ScopedName *) cn->copy ();
- if (result_name)
+
+ if (result_name == 0)
{
- result_name->nconc (result_local_name);
+ result_name = result_local_name;
}
else
{
- result_name = result_local_name;
+ result_name->nconc (result_local_name);
}
}
}
@@ -1289,16 +1317,17 @@ AST_Decl::set_name (UTL_ScopedName *n)
return;
}
- if (this->pd_name)
+ if (this->pd_name != 0)
{
this->pd_name->destroy ();
delete this->pd_name;
}
this->pd_name = n;
- if (n)
+
+ if (n != 0)
{
- if (this->pd_local_name)
+ if (this->pd_local_name != 0)
{
this->pd_local_name->destroy ();
delete this->pd_local_name;
@@ -1307,7 +1336,7 @@ AST_Decl::set_name (UTL_ScopedName *n)
this->pd_local_name = n->last_component ()->copy ();
// The name without _cxx_ prefix removed, if there was any.
- if (this->pd_original_local_name)
+ if (this->pd_original_local_name != 0)
{
this->pd_original_local_name->destroy ();
delete this->pd_original_local_name;
@@ -1336,7 +1365,7 @@ AST_Decl::local_name (void)
void
AST_Decl::local_name (Identifier *id)
{
- if (this->pd_local_name)
+ if (this->pd_local_name != 0)
{
this->pd_local_name->destroy ();
}
@@ -1349,7 +1378,7 @@ Identifier *
AST_Decl::compute_local_name (const char *prefix,
const char *suffix)
{
- if (!prefix || !suffix)
+ if (prefix == 0 || suffix == 0)
{
return 0;
}
@@ -1381,7 +1410,8 @@ void
AST_Decl::original_local_name (Identifier *local_name)
{
// Remove _cxx_ if it is present.
- if (ACE_OS::strstr (local_name->get_string (), "_cxx_")
+ if (ACE_OS::strstr (local_name->get_string (),
+ "_cxx_")
== local_name->get_string ())
{
// AACE_CString class is good to do this stuff.
@@ -1423,7 +1453,7 @@ AST_Decl::last_referenced_as (void) const
void
AST_Decl::last_referenced_as (UTL_ScopedName *n)
{
- if (this->last_referenced_as_)
+ if (this->last_referenced_as_ != 0)
{
this->last_referenced_as_->destroy ();
}
@@ -1452,57 +1482,51 @@ AST_Decl::contains_wstring (void)
{
switch (this->node_type ())
{
- case AST_Decl::NT_array:
- {
- AST_Array *a = AST_Array::narrow_from_decl (this);
- this->contains_wstring_ =
- a->base_type ()->contains_wstring ();
- break;
- }
-
- case AST_Decl::NT_except:
- case AST_Decl::NT_struct:
- case AST_Decl::NT_union:
- {
- AST_Structure *s = AST_Structure::narrow_from_decl (this);
- this->contains_wstring_ =
- s->contains_wstring ();
- break;
- }
-
- case AST_Decl::NT_sequence:
- {
- AST_Sequence *s = AST_Sequence::narrow_from_decl (this);
- this->contains_wstring_ =
- s->base_type ()->contains_wstring ();
+ case AST_Decl::NT_array:
+ {
+ AST_Array *a = AST_Array::narrow_from_decl (this);
+ this->contains_wstring_ =
+ a->base_type ()->contains_wstring ();
+ break;
+ }
+ case AST_Decl::NT_except:
+ case AST_Decl::NT_struct:
+ case AST_Decl::NT_union:
+ {
+ AST_Structure *s = AST_Structure::narrow_from_decl (this);
+ this->contains_wstring_ =
+ s->contains_wstring ();
+ break;
+ }
+ case AST_Decl::NT_sequence:
+ {
+ AST_Sequence *s = AST_Sequence::narrow_from_decl (this);
+ this->contains_wstring_ =
+ s->base_type ()->contains_wstring ();
+ break;
+ }
+ case AST_Decl::NT_attr:
+ case AST_Decl::NT_field:
+ case AST_Decl::NT_union_branch:
+ {
+ AST_Field *f = AST_Field::narrow_from_decl (this);
+ this->contains_wstring_ =
+ f->field_type ()->contains_wstring ();
+ break;
+ }
+ case AST_Decl::NT_typedef:
+ {
+ AST_Typedef *td = AST_Typedef::narrow_from_decl (this);
+ this->contains_wstring_ =
+ td->primitive_base_type ()->contains_wstring ();
+ break;
+ }
+ case AST_Decl::NT_wstring:
+ this->contains_wstring_ = 1;
break;
- }
-
- case AST_Decl::NT_attr:
- case AST_Decl::NT_field:
- case AST_Decl::NT_union_branch:
- {
- AST_Field *f = AST_Field::narrow_from_decl (this);
- this->contains_wstring_ =
- f->field_type ()->contains_wstring ();
+ default:
+ this->contains_wstring_ = 0;
break;
- }
-
- case AST_Decl::NT_typedef:
- {
- AST_Typedef *td = AST_Typedef::narrow_from_decl (this);
- this->contains_wstring_ =
- td->primitive_base_type ()->contains_wstring ();
- break;
- }
-
- case AST_Decl::NT_wstring:
- this->contains_wstring_ = 1;
- break;
-
- default:
- this->contains_wstring_ = 0;
- break;
}
}
@@ -1525,24 +1549,31 @@ AST_Decl::masking_checks (AST_Decl *mod)
}
AST_Module *me_mod = AST_Module::narrow_from_decl (this);
- if (me_mod)
+ AST_Module *of_mod = AST_Module::narrow_from_decl (mod);
+
+ if (me_mod != 0 && of_mod != 0)
{
- AST_Module *po_mod = AST_Module::narrow_from_decl (mod);
- if (po_mod)
+ for (ACE_Unbounded_Set<AST_Module *>::CONST_ITERATOR i (
+ of_mod->prev_mods ());
+ !i.done ();
+ i.advance ())
{
- while (!!(po_mod = po_mod->previous_opening ()))
+ AST_Module **m = 0;
+ i.next (m);
+
+ if (*m == me_mod)
{
- if (po_mod == me_mod)
- {
- return true;
- }
+ return true;
}
}
}
-
+
return false;
}
//Narrowing methods for AST_Decl.
IMPL_NARROW_FROM_DECL(AST_Decl)
+
+
+
diff --git a/TAO/TAO_IDL/ast/ast_generator.cpp b/TAO/TAO_IDL/ast/ast_generator.cpp
index d490aa13622..4d9d631e449 100644
--- a/TAO/TAO_IDL/ast/ast_generator.cpp
+++ b/TAO/TAO_IDL/ast/ast_generator.cpp
@@ -119,7 +119,8 @@ AST_Generator::create_predefined_type (AST_PredefinedType::PredefinedType t,
{
AST_PredefinedType *retval = 0;
ACE_NEW_RETURN (retval,
- AST_PredefinedType (t, n),
+ AST_PredefinedType (t,
+ n),
0);
return retval;
@@ -129,55 +130,73 @@ AST_Module *
AST_Generator::create_module (UTL_Scope *s,
UTL_ScopedName *n)
{
+ // We create this first so if we find a module with the
+ // same name from an included file, we can add its
+ // members to the new module's scope.
AST_Module *retval = 0;
+ ACE_NEW_RETURN (retval,
+ AST_Module (n),
+ 0);
- // Check for another module of the same name in the scope.
+ AST_Module *m = 0;
+
+ // Check for another module of the same name in this scope.
for (UTL_ScopeActiveIterator iter (s, UTL_Scope::IK_decls);
!iter.is_done ();
iter.next ())
{
// Can't just check node type here, since it could be a
// template module or template module instantiation.
- AST_Module *m = AST_Module::narrow_from_decl (iter.item ());
- if (m && m->local_name ()->compare (n->last_component ()))
+ m = AST_Module::narrow_from_decl (iter.item ());
+
+ if (m != 0)
{
- // Create this new module with referance to the
- // "first" previous module found in scope.
- ACE_NEW_RETURN (retval, AST_Module (n, m), 0);
- retval->prefix (const_cast<char *> (m->prefix ()));
- return retval;
+ // Does it have the same name as the one we're
+ // supposed to create.
+ if (m->local_name ()->compare (n->last_component ()))
+ {
+ // Get m's previous_ member, plus all it's decls,
+ // into the new modules's previous_ member.
+ retval->add_to_previous (m);
+ retval->prefix (const_cast<char *> (m->prefix ()));
+ }
}
}
- // Since the scope didn't contain the same module name, it
- // doesn't mean that we haven't see it before. If the scope
- // is itself a module, and has been previously opened, any
- // of the previous openings may contain a previous opening
+ // 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.
- // AST_Module *prev_module = AST_Module::narrow_from_scope (s);
- AST_Module *prev_module = AST_Module::narrow_from_scope (s);
- if (prev_module)
+ m = AST_Module::narrow_from_scope (s);
+
+ if (m != 0)
{
- while (!!(prev_module= prev_module->previous_opening ()))
+ for (ACE_Unbounded_Set<AST_Module *>::CONST_ITERATOR i (
+ m->prev_mods ());
+ !i.done ();
+ i.advance ())
{
- for (UTL_ScopeActiveIterator iter (prev_module, UTL_Scope::IK_decls);
- !iter.is_done ();
- iter.next ())
+ AST_Module **mm = 0;
+ i.next (mm);
+
+ for (UTL_ScopeActiveIterator si (*mm, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
{
- AST_Module *m = AST_Module::narrow_from_decl (iter.item ());
- if (m && m->local_name ()->compare (n->last_component ()))
+ AST_Decl *d = si.item ();
+
+ if (retval->local_name ()->case_compare (d->local_name ()))
{
- // Create this new module with referance to the
- // "first" previous module found in scope.
- ACE_NEW_RETURN (retval, AST_Module (n, m), 0);
- return retval;
+ m = AST_Module::narrow_from_decl (d);
+
+ if (m != 0)
+ {
+ retval->add_to_previous (m);
+ }
}
}
}
}
- // There is no previous module to this one
- ACE_NEW_RETURN (retval, AST_Module (n), 0);
return retval;
}
@@ -220,17 +239,18 @@ AST_Generator::create_interface_fwd (UTL_ScopedName *n,
bool is_local,
bool is_abstract)
{
- AST_Interface
- *full_defn = this->create_interface (n,
- 0,
- -1,
- 0,
- 0,
- is_local,
- is_abstract);
+ AST_Interface *full_defn = this->create_interface (n,
+ 0,
+ -1,
+ 0,
+ 0,
+ is_local,
+ is_abstract);
+
AST_InterfaceFwd *retval = 0;
ACE_NEW_RETURN (retval,
- AST_InterfaceFwd (full_defn, n),
+ AST_InterfaceFwd (full_defn,
+ n),
0);
full_defn->fwd_decl (retval);
@@ -269,7 +289,8 @@ AST_Generator::create_valuetype (UTL_ScopedName *n,
// The following helps with OBV_ namespace generation.
AST_Module *m = AST_Module::narrow_from_scope (retval->defined_in ());
- if (m)
+
+ if (m != 0)
{
m->set_has_nested_valuetype ();
}
diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp
index aab81d8fcdb..bd543a996aa 100644
--- a/TAO/TAO_IDL/ast/ast_module.cpp
+++ b/TAO/TAO_IDL/ast/ast_module.cpp
@@ -102,39 +102,23 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "nr_extern.h"
AST_Decl::NodeType const
- AST_Module::NT = AST_Decl::NT_module;
+AST_Module::NT = AST_Decl::NT_module;
-AST_Module::AST_Module (UTL_ScopedName *n, AST_Module *previous)
- : AST_Decl (AST_Decl::NT_module, n),
- UTL_Scope (AST_Decl::NT_module),
- pd_has_nested_valuetype_ (0),
- previous_opening_ (previous),
- last_in_same_parent_scope_ (this),
- from_inst_ (0)
+bool AST_Module::in_prev_ = false;
+
+AST_Module::AST_Module (UTL_ScopedName *n)
+ : AST_Decl (AST_Decl::NT_module,
+ n),
+ UTL_Scope (AST_Decl::NT_module),
+ pd_has_nested_valuetype (0),
+ from_inst_ (0)
{
- // NOTE previous passed into this constructor should be
- // the FIRST module that is a previous opening of this same
- // module in the scope in which it is stored. Later on if
- // the module is validated and added to it's scope, the
- // previous_opening_ will be adjusted to be the immediatly
- // previous opening of this module. See fe_add_module ()
- // below.
}
AST_Module::~AST_Module (void)
{
}
-void
-AST_Module::destroy (void)
-{
- this->UTL_Scope::destroy ();
- this->AST_Decl::destroy ();
-}
-
-IMPL_NARROW_FROM_DECL(AST_Module)
-IMPL_NARROW_FROM_SCOPE(AST_Module)
-
// Dump this AST_Module node to the ostream o.
void
AST_Module::dump (ACE_OSTREAM_TYPE &o)
@@ -147,38 +131,30 @@ AST_Module::dump (ACE_OSTREAM_TYPE &o)
this->dump_i (o, "}");
}
-// We actually want to match the LAST module found in
-// the scope being searched not the FIRST one in the
-// list.
-AST_Decl *
-AST_Module::adjust_found (
- bool /*ignore_fwd*/,
- bool /*full_def_only*/)
-{
- return this->last_in_same_parent_scope_;
-}
// Involved in OBV_ namespace generation.
void
AST_Module::set_has_nested_valuetype (void)
{
UTL_Scope *parent = this->defined_in ();
- if (parent && !this->pd_has_nested_valuetype_)
+
+ if (!this->pd_has_nested_valuetype && parent)
{
AST_Module *pm = AST_Module::narrow_from_scope (parent);
- if (pm)
+
+ if (pm != 0)
{
pm->set_has_nested_valuetype ();
}
}
- this->pd_has_nested_valuetype_ = 1;
+ this->pd_has_nested_valuetype = 1;
}
bool
AST_Module::has_nested_valuetype (void)
{
- return this->pd_has_nested_valuetype_;
+ return this->pd_has_nested_valuetype;
}
int
@@ -186,13 +162,15 @@ AST_Module::be_add_interface (AST_Interface *i,
AST_Interface *ix)
{
// Add it to scope.
- this->add_to_scope (i, ix);
+ this->add_to_scope (i,
+ ix);
// Add it to set of locally referenced symbols.
this->add_to_referenced (i,
false,
i->local_name (),
ix);
+
return 0;
}
@@ -206,6 +184,7 @@ AST_Module::be_add_valuetype (AST_ValueType *v)
this->add_to_referenced (v,
false,
v->local_name ());
+
return 0;
}
@@ -215,6 +194,7 @@ AST_Module::referenced (AST_Decl *e,
Identifier *id)
{
bool refd = this->UTL_Scope::referenced (e, id);
+
if (refd)
{
return true;
@@ -222,43 +202,67 @@ AST_Module::referenced (AST_Decl *e,
AST_Decl *d =
this->look_in_prev_mods_local (e->local_name (), true);
- if (!d)
+
+ if (0 == d)
{
return false;
}
-
+
AST_Type *t = AST_Type::narrow_from_decl (d);
- return (!t || t->is_defined ());
+ return 0 == t || t->is_defined ();
}
-AST_Module *
-AST_Module::previous_opening ()
+void
+AST_Module::add_to_previous (AST_Module *m)
{
- return this->previous_opening_;
+ this->prev_mods_.insert (m);
}
AST_Decl *
AST_Module::look_in_prev_mods_local (Identifier *e,
bool ignore_fwd)
{
- for (AST_Module *po = this->previous_opening_;
- po;
- po = po->previous_opening_)
+ AST_Module **m = 0;
+ AST_Decl *d = 0;
+
+ // If there are more than two openings of this module, we want
+ // to get the last one - the one that will have the decls from
+ // all the previous openings added to previous_.
+ for (ACE_Unbounded_Set<AST_Module *>::CONST_ITERATOR iter (
+ this->prev_mods_);
+ !iter.done ();
+ iter.advance ())
{
- for (UTL_ScopeActiveIterator iter (po, UTL_Scope::IK_decls);
- !iter.is_done ();
- iter.next ())
+ iter.next (m);
+
+ for (UTL_ScopeActiveIterator i (*m, UTL_Scope::IK_decls);
+ !i.is_done ();
+ i.next ())
{
- AST_Decl *d = iter.item ();
- if ((!ignore_fwd || !d->is_fwd ())
- && !!(d = d->adjust_found (ignore_fwd, false))
- && e->case_compare (d->local_name ()))
+ d = i.item ();
+
+ if (ignore_fwd)
+ {
+ AST_Decl::NodeType nt = d->node_type ();
+
+ if (nt == AST_Decl::NT_interface_fwd
+ || nt == AST_Decl::NT_eventtype_fwd
+ || nt == AST_Decl::NT_component_fwd
+ || nt == AST_Decl::NT_struct_fwd
+ || nt == AST_Decl::NT_union_fwd
+ || nt == AST_Decl::NT_valuetype_fwd)
+ {
+ continue;
+ }
+ }
+
+ if (e->case_compare (d->local_name ()))
{
return d;
}
}
}
-
+
return 0;
}
@@ -266,34 +270,79 @@ AST_Decl *
AST_Module::look_in_prev_mods (UTL_ScopedName *e,
bool full_def_only)
{
- for (AST_Module *po = this->previous_opening_;
- po;
- po = po->previous_opening_)
+ AST_Module **m = 0;
+ AST_Decl *d = 0;
+
+ // If there are more than two openings of this module, we want
+ // to get the last one - the one that will have the decls from
+ // all the previous openings added to previous_.
+ for (ACE_Unbounded_Set<AST_Module *>::CONST_ITERATOR iter (
+ this->prev_mods_);
+ !iter.done ();
+ iter.advance ())
{
- for (UTL_ScopeActiveIterator iter (po, UTL_Scope::IK_decls);
- !iter.is_done ();
- iter.next ())
+ iter.next (m);
+
+ for (UTL_ScopeActiveIterator i (*m, UTL_Scope::IK_decls);
+ !i.is_done ();
+ i.next ())
{
- AST_Decl *d = iter.item ();
- if (!!(d = d->adjust_found (full_def_only, full_def_only))
- && e->head ()->case_compare (d->local_name ()))
+ d = i.item ();
+
+ if (full_def_only)
{
+ AST_Decl::NodeType nt = d->node_type ();
+
+ if (nt == AST_Decl::NT_interface_fwd
+ || nt == AST_Decl::NT_eventtype_fwd
+ || nt == AST_Decl::NT_component_fwd
+ || nt == AST_Decl::NT_struct_fwd
+ || nt == AST_Decl::NT_union_fwd
+ || nt == AST_Decl::NT_valuetype_fwd)
+ {
+ continue;
+ }
+ }
+
+ if (e->head ()->case_compare (d->local_name ()))
+ {
+ UTL_Scope *s = DeclAsScope (d);
UTL_ScopedName *sn =
static_cast<UTL_ScopedName *> (e->tail ());
- if (sn)
+
+ if (sn == 0)
{
- UTL_Scope *s = DeclAsScope (d);
- return s ? s->lookup_by_name_r (sn, full_def_only) : 0;
+ return d;
+ }
+ else if (s != 0)
+ {
+ d = s->lookup_by_name_r (sn, full_def_only);
+
+ if (d != 0)
+ {
+ return d;
+ }
}
-
- return d;
}
}
}
-
+
return 0;
}
+ACE_Unbounded_Set<AST_Module *> &
+AST_Module::prev_mods (void)
+{
+ return this->prev_mods_;
+}
+
+void
+AST_Module::destroy (void)
+{
+ this->UTL_Scope::destroy ();
+ this->AST_Decl::destroy ();
+}
+
int
AST_Module::ast_accept (ast_visitor *visitor)
{
@@ -316,7 +365,16 @@ AST_Decl *
AST_Module::special_lookup (UTL_ScopedName *e,
bool full_def_only)
{
- return this->look_in_prev_mods (e, full_def_only);
+ AST_Decl *d = 0;
+
+ if (!AST_Module::in_prev_)
+ {
+ AST_Module::in_prev_ = true;
+ d = this->look_in_prev_mods (e, full_def_only);
+ AST_Module::in_prev_ = false;
+ }
+
+ return d;
}
//================================================
@@ -324,41 +382,38 @@ AST_Module::special_lookup (UTL_ScopedName *e,
AST_PredefinedType *
AST_Module::fe_add_predefined_type (AST_PredefinedType *t)
{
- return AST_PredefinedType::narrow_from_decl (
- this->fe_add_decl (t));
+ return
+ AST_PredefinedType::narrow_from_decl (
+ this->fe_add_decl (t));
}
AST_Module *
AST_Module::fe_add_module (AST_Module *t)
{
+ AST_Decl *d;
+ AST_Module *m = 0;
+
+ UTL_Scope *scope = t->defined_in ();
+ const char *prefix_holder = 0;
+
// If our prefix is empty, we check to see if an ancestor has one.
- if (!ACE_OS::strcmp (t->prefix (), ""))
+ while (ACE_OS::strcmp (t->prefix (), "") == 0 && scope != 0)
{
- UTL_Scope *scope = t->defined_in ();
- while (scope)
- {
- AST_Decl *parent = ScopeAsDecl (scope);
- const char *prefix_holder = parent->prefix ();
- if (!prefix_holder)
- {
- // We have reached global scope.
- break;
- }
+ AST_Decl *parent = ScopeAsDecl (scope);
+ prefix_holder = parent->prefix ();
- t->prefix (const_cast<char *> (prefix_holder));
- if (ACE_OS::strcmp (t->prefix (), ""))
- {
- break;
- }
-
- scope = parent->defined_in ();
+ // We have reached global scope.
+ if (prefix_holder == 0)
+ {
+ break;
}
+
+ t->prefix (const_cast<char *> (prefix_holder));
+ scope = parent->defined_in ();
}
// Already defined and cannot be redefined? Or already used?
- AST_Module *m = 0;
- AST_Decl *d = this->lookup_for_add (t);
- if (d)
+ if ((d = this->lookup_for_add (t)) != 0)
{
if (!can_be_redefined (d))
{
@@ -369,62 +424,37 @@ AST_Module::fe_add_module (AST_Module *t)
return 0;
}
- // has_ancestor() returns TRUE if both nodes are the same.
m = AST_Module::narrow_from_decl (d);
- if (t != m && t->has_ancestor (d))
+
+ // has_ancestor() returns TRUE if both nodes are the same.
+ if (t != m)
{
- idl_global->err ()->redefinition_in_scope (t, d);
- return 0;
+ if (t->has_ancestor (d))
+ {
+ idl_global->err ()->redefinition_in_scope (t,
+ d);
+ return 0;
+ }
}
const char *prev_prefix = d->prefix ();
const char *this_prefix = t->prefix ();
- if (!ACE_OS::strcmp (this_prefix, ""))
+ if (ACE_OS::strcmp (this_prefix, "") == 0)
{
t->prefix (const_cast<char *> (prev_prefix));
}
- else if (!ACE_OS::strcmp (prev_prefix, ""))
+ else
{
- d->prefix (const_cast<char *> (this_prefix));
- }
- }
-
- // Now we are actually adding this new module to the active
- // scopes, ensure that the previous openings are all updated
- // so that this new module is recorded as the current
- // "last module" definition in our scope.
- AST_Module *first_opening = t->previous_opening_;
- if (first_opening)
- {
- // When we created the module we simply stored the first
- // previous module we found (if any), we actually want
- // to refer to that module's LAST opening in that same scope
- // except this module itself (which isn't yet recorded anyway).
- t->previous_opening_ = first_opening->last_in_same_parent_scope_;
- if (first_opening->defined_in () == this)
- {
- // Since the previous openings are in our own scope,
- // make sure that these all point to this new module.
- for (AST_Module *pm = t->previous_opening_;
- pm;
- pm = pm->previous_opening_)
+ if (ACE_OS::strcmp (prev_prefix, "") == 0)
{
- pm->last_in_same_parent_scope_ = t;
- if (pm == first_opening)
- {
- // Even if there are still more previous modules,
- // the ones before this one are in a different
- // scope and do not need to be updated.
- break;
- }
+ d->prefix (const_cast<char *> (this_prefix));
}
}
}
- // If this node is not a reopened module, add it to scope
- // and referenced.
- if (!m || t != m)
+ // If this node is not a reopened module, add it to scope and referenced.
+ if (m == 0 || t != m)
{
// Add it to scope.
this->add_to_scope (t);
@@ -613,3 +643,6 @@ AST_Module::fe_add_porttype (AST_PortType *t)
AST_PortType::narrow_from_decl (
this->fe_add_decl (t));
}
+
+IMPL_NARROW_FROM_DECL(AST_Module)
+IMPL_NARROW_FROM_SCOPE(AST_Module)
diff --git a/TAO/TAO_IDL/be/be_module.cpp b/TAO/TAO_IDL/be/be_module.cpp
index 4e58cf830bd..12830451390 100644
--- a/TAO/TAO_IDL/be/be_module.cpp
+++ b/TAO/TAO_IDL/be/be_module.cpp
@@ -1,3 +1,4 @@
+
//=============================================================================
/**
* @file be_module.cpp
@@ -7,6 +8,7 @@
* Extension of class AST_Module that provides additional means for C++
* mapping of a module
*
+ *
* @author Copyright 1994-1995 by Sun Microsystems
* @author Inc. and Aniruddha Gokhale
*/
@@ -15,13 +17,15 @@
#include "be_module.h"
#include "be_visitor.h"
-be_module::be_module (UTL_ScopedName *n, AST_Module *previous)
+be_module::be_module (UTL_ScopedName *n)
: COMMON_Base (),
- AST_Decl (AST_Decl::NT_module, n),
+ AST_Decl (AST_Decl::NT_module,
+ n),
UTL_Scope (AST_Decl::NT_module),
- AST_Module (n, previous),
+ AST_Module (n),
be_scope (AST_Decl::NT_module),
- be_decl (AST_Decl::NT_module, n)
+ be_decl (AST_Decl::NT_module,
+ n)
{
}
diff --git a/TAO/TAO_IDL/include/utl_scope.h b/TAO/TAO_IDL/include/utl_scope.h
index 5756f966643..6fa5da565f0 100644
--- a/TAO/TAO_IDL/include/utl_scope.h
+++ b/TAO/TAO_IDL/include/utl_scope.h
@@ -508,6 +508,8 @@ private:
iter_lookup_by_name_local (AST_Decl *d,
UTL_ScopedName *e,
bool full_def_only = false);
+
+ AST_Decl *local_checks (AST_Decl *d, bool full_def_only);
};
// Active iterator for a UTL_Scope node
diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp
index 58850ed7805..7869415dc57 100644
--- a/TAO/TAO_IDL/util/utl_scope.cpp
+++ b/TAO/TAO_IDL/util/utl_scope.cpp
@@ -281,49 +281,49 @@ UTL_Scope::redef_clash (AST_Decl::NodeType new_nt,
AST_Decl::NodeType scope_elem_nt)
{
switch (new_nt)
- {
- case AST_Decl::NT_module:
- return scope_elem_nt != AST_Decl::NT_module;
+ {
+ case AST_Decl::NT_module:
+ return scope_elem_nt != AST_Decl::NT_module;
- case AST_Decl::NT_struct:
- case AST_Decl::NT_struct_fwd:
- return scope_elem_nt != AST_Decl::NT_struct_fwd;
+ case AST_Decl::NT_struct:
+ case AST_Decl::NT_struct_fwd:
+ return scope_elem_nt != AST_Decl::NT_struct_fwd;
- case AST_Decl::NT_union:
- case AST_Decl::NT_union_fwd:
- return scope_elem_nt != AST_Decl::NT_union_fwd;
+ case AST_Decl::NT_union:
+ case AST_Decl::NT_union_fwd:
+ return scope_elem_nt != AST_Decl::NT_union_fwd;
- case AST_Decl::NT_interface:
- return scope_elem_nt != AST_Decl::NT_interface_fwd;
+ case AST_Decl::NT_interface:
+ return scope_elem_nt != AST_Decl::NT_interface_fwd;
- case AST_Decl::NT_component:
- return scope_elem_nt != AST_Decl::NT_component_fwd;
+ case AST_Decl::NT_component:
+ return scope_elem_nt != AST_Decl::NT_component_fwd;
- case AST_Decl::NT_interface_fwd:
- return ( scope_elem_nt != AST_Decl::NT_interface_fwd
- && scope_elem_nt != AST_Decl::NT_interface);
+ case AST_Decl::NT_interface_fwd:
+ return ( scope_elem_nt != AST_Decl::NT_interface_fwd
+ && scope_elem_nt != AST_Decl::NT_interface);
- case AST_Decl::NT_component_fwd:
- return ( scope_elem_nt != AST_Decl::NT_component_fwd
- && scope_elem_nt != AST_Decl::NT_component);
+ case AST_Decl::NT_component_fwd:
+ return ( scope_elem_nt != AST_Decl::NT_component_fwd
+ && scope_elem_nt != AST_Decl::NT_component);
- case AST_Decl::NT_valuetype:
- return scope_elem_nt != AST_Decl::NT_valuetype_fwd;
+ case AST_Decl::NT_valuetype:
+ return scope_elem_nt != AST_Decl::NT_valuetype_fwd;
- case AST_Decl::NT_eventtype:
- return scope_elem_nt != AST_Decl::NT_eventtype_fwd;
+ case AST_Decl::NT_eventtype:
+ return scope_elem_nt != AST_Decl::NT_eventtype_fwd;
- case AST_Decl::NT_valuetype_fwd:
- return ( scope_elem_nt != AST_Decl::NT_valuetype_fwd
- && scope_elem_nt != AST_Decl::NT_valuetype);
+ case AST_Decl::NT_valuetype_fwd:
+ return ( scope_elem_nt != AST_Decl::NT_valuetype_fwd
+ && scope_elem_nt != AST_Decl::NT_valuetype);
- case AST_Decl::NT_eventtype_fwd:
- return ( scope_elem_nt != AST_Decl::NT_eventtype_fwd
- && scope_elem_nt != AST_Decl::NT_eventtype);
+ case AST_Decl::NT_eventtype_fwd:
+ return ( scope_elem_nt != AST_Decl::NT_eventtype_fwd
+ && scope_elem_nt != AST_Decl::NT_eventtype);
- default:
- return true;
- }
+ default:
+ return true;
+ }
}
void
@@ -487,9 +487,9 @@ UTL_Scope::fe_add_decl (AST_Decl *t)
AST_Decl::NodeType tnt = t->node_type ();
AST_Decl::NodeType dnt = d->node_type ();
- // Factories are not inherited, so they can be
- // redefined, but not in the same scope (home or
- // valuetype).
+ /// Factories are not inherited, so they can be
+ /// redefined, but not in the same scope (home or
+ /// valuetype).
bool inherited_factory =
( tnt == AST_Decl::NT_factory
&& dnt == AST_Decl::NT_factory
@@ -505,12 +505,12 @@ UTL_Scope::fe_add_decl (AST_Decl *t)
}
}
- // For convenience, AST_Template_Module_Inst inherits
- // from AST_Field, but has a node type of NT_module.
- // Since we then can't add it using fe_add_module(), a
- // check is needed here to avoid a redefinition error,
- // if the instantiated module is meant to reopen a
- // previous one.
+ /// For convenience, AST_Template_Module_Inst inherits
+ /// from AST_Field, but has a node type of NT_module.
+ /// Since we then can't add it using fe_add_module(), a
+ /// check is needed here to avoid a redefinition error,
+ /// if the instantiated module is meant to reopen a
+ /// previous one.
AST_Decl::NodeType lnt = d->node_type ();
AST_Decl::NodeType ant = t->node_type ();
@@ -574,8 +574,8 @@ UTL_Scope::fe_add_ref_decl (AST_Field *t)
}
}
- // Catches struct/union/exception which all maintain a queue
- // for fields as distinct from decls and enum values.
+ /// Catches struct/union/exception which all maintain a queue
+ /// for fields as distinct from decls and enum values.
AST_Structure *s = AST_Structure::narrow_from_scope (this);
if (s)
{
@@ -611,8 +611,8 @@ UTL_Scope::fe_add_full_struct_type (AST_Structure *t)
AST_Decl::NodeType nt = ScopeAsDecl (this)->node_type ();
- // Decls inside a struct or union are also referenced by
- // fields, and so must be handled differently.
+ /// Decls inside a struct or union are also referenced by
+ /// fields, and so must be handled differently.
if ( nt == AST_Decl::NT_struct
|| nt == AST_Decl::NT_union
|| nt == AST_Decl::NT_except)
@@ -638,15 +638,18 @@ UTL_Scope::fe_add_fwd_struct_type (AST_StructureFwd *t)
AST_Decl *d = this->lookup_for_add (t);
if (d)
{
+ AST_Decl::NodeType nt = d->node_type ();
+
// There used to be another check here ANDed with the one below:
// d->defined_in () == this. But lookup_for_add() calls only
// lookup_by_name_local(), which does not bump up the scope,
// and look_in_prev_mods() for modules. If look_in_prev_mods()
// finds something, the scopes will NOT be the same pointer
// value, but the result is what we want.
- if (d->node_type () == AST_Decl::NT_struct)
+ if (nt == AST_Decl::NT_struct)
{
- t->set_full_definition (AST_Structure::narrow_from_decl (d));
+ AST_Structure *s = AST_Structure::narrow_from_decl (d);
+ t->set_full_definition (s);
}
else if (!can_be_redefined (d))
{
@@ -1000,7 +1003,8 @@ UTL_Scope::lookup_pseudo (Identifier *e)
i.next ())
{
AST_Decl *d = i.item ();
- if (e->case_compare (d->local_name ()))
+ Identifier *item_name = d->local_name ();
+ if (e->case_compare (item_name))
{
// These have to be located here because we are just looking
// up a scoped name - skip for imported nodes.
@@ -1212,134 +1216,169 @@ UTL_Scope::lookup_by_name_local (Identifier *e,
!i.is_done ();
i.next ())
{
- AST_Decl *d = i.item ()->adjust_found (true, full_def_only);
- if (d)
+ AST_Decl *tmp = i.item ();
+ Identifier *item_name = tmp->local_name ();
+
+ if (item_name
+ // Right now we populate the global scope with all the CORBA basic
+ // types, so something like 'ULong' in an IDL file will find a
+ // match, unless we skip over these items. This is a workaround until
+ // there's time to fix the code generation for CORBA basic types.
+ && (in_corba || ACE_OS::strcmp (tmp->name ()->head ()->get_string (), "CORBA"))
+ && e->case_compare (item_name))
{
- Identifier *item_name = d->local_name ();
- if (item_name
- // Right now we populate the global scope with
- // all the CORBA basic types, so something like
- // 'ULong' in an IDL file will find a match,
- // unless we skip over these items. This is a
- // workaround until there's time to fix the code
- // generation for CORBA basic types.
- && (in_corba || ACE_OS::strcmp (
- d->name ()->head ()->get_string (), "CORBA"))
- && e->case_compare (item_name))
+ if (AST_Template_Module_Ref::narrow_from_decl (tmp))
+ {
+ // An IDL module has been created in this scope corresponding
+ // to this node. That's the one we want to match, and it
+ // occurs in the scope right after this node, so we'll match
+ // what we're looking for on the next iteration.
+ continue;
+ }
+
+ d = tmp;
+ AST_Decl::NodeType nt = tmp->node_type ();
+ if (nt == AST_Decl::NT_module)
+ {
+ // We are wanting the LAST module opening in this scope, so having
+ // stored this one, keep searching in case we find another later on.
+ continue;
+ }
+
+ // Special case for forward declared types,
+ // In this case, we want to return
+ // the full definition member, whether defined yet or not.
+ // NOTE: corresponding full_definition fe_add_* methods
+ // depend on the behavior below!
+ if ( nt == AST_Decl::NT_struct_fwd
+ || nt == AST_Decl::NT_union_fwd)
+ {
+ d = AST_StructureFwd::narrow_from_decl (tmp)->full_definition ();
+ }
+ else if ( nt == AST_Decl::NT_interface_fwd
+ || nt == AST_Decl::NT_valuetype_fwd
+ || nt == AST_Decl::NT_component_fwd
+ || nt == AST_Decl::NT_eventtype_fwd)
{
- return d;
+ d = AST_InterfaceFwd::narrow_from_decl (tmp)->full_definition ();
}
+
+ break; // We have found the one and only one we are looking for.
}
}
- // Ok the name wasn't found in the current scope, if this
- // scope is a module, we can check it's previous openings!
- AST_Module *m = AST_Module::narrow_from_scope (this);
- if (m)
+ if (!d)
{
- d = m->look_in_prev_mods_local (e);
- if (d && (!full_def_only || d->is_defined ()))
+ AST_Module *m = AST_Module::narrow_from_scope (this);
+ if (m)
{
- return d;
+ d = m->look_in_prev_mods_local (e);
+ if (d && full_def_only && !d->is_defined ())
+ {
+ d = 0;
+ }
}
- }
- else
- {
- // Or if this scope is an interface, we can check if
- // it was inherited!
- AST_Interface *i =
- AST_Interface::narrow_from_scope (this);
- if (i)
+ else
{
- d = i->look_in_inherited_local (e);
- if (d)
+ AST_Interface *i =
+ AST_Interface::narrow_from_scope (this);
+ if (i)
{
- return d;
+ d = i->look_in_inherited_local (e);
}
}
}
- // There are some cases where the iteration over IK_decls
- // above will fail because what we're searching for has
- // been added only to the local types. It's less complicated
- // to do the iteration below only as a last resort.
- for (UTL_ScopeActiveIterator i (this, IK_localtypes);
- !i.is_done ();
- i.next ())
+ /// There are some cases where the iteration over IK_decls
+ /// above will fail because what we're searching for has been
+ /// added only to the local types. It's less complicated to
+ /// do the iteration below only as a last resort.
+ if (!d)
{
- d = i.item ();
- if (e->case_compare (d->local_name ()))
+ for (UTL_ScopeActiveIterator i (this, IK_localtypes);
+ !i.is_done ();
+ i.next ())
{
- return d;
+ AST_Decl *l = i.item ();
+ if (e->case_compare (l->local_name ()))
+ {
+ d = l;
+ break;
+ }
}
}
- return 0;
+ return d;
}
AST_Decl *
UTL_Scope::lookup_by_name (UTL_ScopedName *e,
bool full_def_only)
{
+ /// Empty name? Exit immediately.
if (!e)
{
return 0;
}
- // If name starts with "::" or "" start lookup in global scope,
- // if we're not there already, short_circuiting the
- // scope-expanding iteration below.
- UTL_Scope *work = this;
+ UTL_ScopedName *work_name = e;
+ UTL_Scope *work_scope = this;
+
+ /// If name starts with "::" or "" start lookup in global scope,
+ /// if we're not there already, short_circuiting the
+ /// scope-expanding iteration below.
const bool global_scope_name = this->is_global_name (e->head ());
if (global_scope_name)
{
- e = static_cast<UTL_ScopedName *> (e->tail ());
- work = idl_global->root ();
+ work_name = static_cast<UTL_ScopedName *> (e->tail ());
+ work_scope = idl_global->root ();
}
- AST_Decl *d = work->lookup_by_name_r (e, full_def_only);
- if (!d)
- {
- // If all else fails, expand the scope upwards
- for (UTL_Scope *parent = ScopeAsDecl (work)->defined_in ();
- parent;
- parent = ScopeAsDecl (parent)->defined_in ())
- {
- d = parent->lookup_by_name_r (e, full_def_only);
- if (d)
- {
- break;
- }
- }
- }
+ AST_Decl *d =
+ work_scope->lookup_by_name_r (work_name, full_def_only);
+
+ UTL_Scope *outer = ScopeAsDecl (work_scope)->defined_in ();
ACE_Unbounded_Queue<AST_Decl *> &masks =
idl_global->masking_scopes ();
- if (d && !global_scope_name)
+
+ /// If all else fails, expand the scope, otherwise
+ /// try to match the rest of the scoped name.
+ while (!d && outer)
{
+ d = outer->lookup_by_name_r (work_name, full_def_only);
+
+ AST_Decl *s = ScopeAsDecl (outer);
+ outer = s->defined_in ();
+ }
+
+ if (!global_scope_name && d)
+ {
+ ACE_CDR::ULong slot = 0uL;
+ AST_Decl *outer_scope = 0;
const char *head = e->head ()->get_string ();
- ACE_Unbounded_Queue<AST_Decl *>::CONST_ITERATOR i (masks);
- AST_Decl **item = 0;
- if (i.next (item))
+ for (ACE_Unbounded_Queue<AST_Decl *>::CONST_ITERATOR i (masks);
+ !i.done ();
+ i.advance (), ++slot)
{
- // The first queue item (last enqueued) will always
- // match e->head(), but does not indicate an error.
- AST_Decl *outer_decl = *item;
+ AST_Decl **item = 0;
+ i.next (item);
- // Now check that the rest of the names don't collide
- while (i.advance ())
+ /// The first queue item (last enqueued) will always
+ /// match e->head(), but does not indicate an error.
+ if (!slot)
{
- i.next (item);
- const char *lname =
- (*item)->local_name ()->get_string ();
- if (!ACE_OS::strcmp (lname, head)
- && !(*item)->masking_checks (outer_decl))
- {
- idl_global->err ()
- ->scope_masking_error (d, *item);
- d = 0; // Hidden scopes can't be used indirectly.
- break;
- }
+ outer_scope = *item;
+ continue;
+ }
+
+ const char *lname = (*item)->local_name ()->get_string ();
+ if (!ACE_OS::strcmp (lname, head)
+ && !(*item)->masking_checks (outer_scope))
+ {
+ idl_global->err ()->scope_masking_error (d, *item);
+ d = 0;
+ break;
}
}
}
@@ -1353,96 +1392,105 @@ AST_Decl *
UTL_Scope::lookup_by_name_r (UTL_ScopedName *e,
bool full_def_only)
{
- bool work_another_level;
- UTL_Scope *work = this;
- do
+ // Will catch Object, TypeCode, TCKind, ValueBase and
+ // AbstractBase. A non-zero result of this lookup determines the
+ // generation of some #includes and, whether successful or not,
+ // incurs no extra overhead.
+ AST_Decl *d = this->lookup_pseudo (e->head ());
+ if (d)
{
- AST_Decl *d = work->lookup_pseudo (e->head ());
- if (d)
+ return d;
+ }
+
+ if (this->idl_keyword_clash (e->head ()))
+ {
+ return 0;
+ }
+
+ /// Before proceeding to normal lookup, check if the name
+ /// matches a template module parameter. If so, the return
+ /// value is created on the heap and is owned by the caller
+ /// of this lookup.
+ if (e->length () == 1)
+ {
+ AST_Param_Holder *param_holder =
+ UTL_Scope::match_param (e);
+
+ // Since we are inside the scope of a template module, any
+ // single-segment scoped name that matches a template
+ // parameter name has to be a reference to that parameter,
+ // so we return the created placeholder. If there's no
+ // match, 0 is returned, and we proceed with the regular
+ // lookup.
+ if (param_holder)
{
- return d;
+ return param_holder;
}
+ }
- if (work->idl_keyword_clash (e->head ()))
+ bool in_corba = !ACE_OS::strcmp (e->head ()->get_string (), "CORBA");
+ for (UTL_ScopeActiveIterator i (this, IK_decls);
+ !i.is_done ();
+ i.next ())
+ {
+ AST_Decl *tmp = i.item ();
+
+ // Right now we populate the global scope with all the CORBA basic
+ // types, so something like 'ULong' in an IDL file will find a
+ // match, unless we skip over these items. This is a workaround until
+ // there's time to fix the code generation for CORBA basic types.
+ if (!in_corba
+ && !ACE_OS::strcmp (tmp->name ()->head ()->get_string (), "CORBA"))
{
- return 0;
+ continue;
}
- // Before proceeding to normal lookup, check if the name
- // matches a template module parameter. If so, the return
- // value is created on the heap and is owned by the caller
- // of this lookup.
- if (e->length () == 1)
+ if (tmp->local_name ()->case_compare (e->head ()))
{
- AST_Param_Holder *param_holder =
- UTL_Scope::match_param (e);
-
- // Since we are inside the scope of a template module, any
- // single-segment scoped name that matches a template
- // parameter name has to be a reference to that parameter,
- // so we return the created placeholder. If there's no
- // match, 0 is returned, and we proceed with the regular
- // lookup.
- if (param_holder)
+ d = tmp;
+ if (e->length () == 1)
{
- return param_holder;
+ d = this->local_checks (d, full_def_only);
}
- }
-
- work_another_level = false; // Until we find something.
- bool in_corba =
- !ACE_OS::strcmp (e->head ()->get_string (), "CORBA");
- for (UTL_ScopeActiveIterator i (work, IK_decls);
- !i.is_done ();
- i.next ())
- {
- if (!!(d = i.item ()->adjust_found (true, full_def_only))
- && (in_corba ||
- ACE_OS::strcmp (d->name ()->head ()->get_string (),
- "CORBA"))
- && d->local_name ()->case_compare (e->head ()))
+ else
{
- // Ok we found a match, is there any more to find?
- if (e->length () == 1)
+ UTL_Scope *s = DeclAsScope (d);
+ if (s)
{
- return d; // Last scope name matched
- }
+ idl_global->masking_scopes ().enqueue_head (d);
- work = DeclAsScope (d); // The next scope to search
- if (!work)
- {
- // Template weirdness, actual one we want should be
- // found next in this search, keep going.
- continue;
+ UTL_ScopedName *sn =
+ static_cast<UTL_ScopedName *> (e->tail ());
+ d = s->lookup_by_name_r (sn, full_def_only);
}
-
- work_another_level = true;
- idl_global->masking_scopes ().enqueue_head (d);
- e = static_cast<UTL_ScopedName *> (e->tail ());
- break;
}
}
- } while (work_another_level);
+ }
- // A rare enough case that it's worth it to separate it and
- // do it as a last resort. Catches anonymnous types, enums
- // and members with their types defined all in one statement.
- if (e->length () == 1)
+ /// A rare enough case that it's worth it to separate it and
+ /// do it as a last resort. Catches anonymnous types, enums
+ /// and members with their types defined all in one statement.
+ if (!d)
{
- for (UTL_ScopeActiveIterator i (work, IK_localtypes);
+ for (UTL_ScopeActiveIterator i (this, IK_localtypes);
!i.is_done ();
i.next ())
{
- AST_Decl *d = i.item ();
- if (d->local_name ()->case_compare (e->head ()))
+ AST_Decl *tmp = i.item ();
+ if (tmp->local_name ()->case_compare (e->head ()))
{
- return d;
+ d = tmp;
+ break;
}
}
}
- // Last resort, check other module openings of working scope.
- return work->special_lookup (e, full_def_only);
+ if (!d)
+ {
+ d = this->special_lookup (e, full_def_only);
+ }
+
+ return d;
}
// Add a node to set of nodes referenced in this scope.
@@ -1507,15 +1555,21 @@ UTL_Scope::add_to_referenced (AST_Decl *e,
}
else if (this->referenced (ex))
{
- long i;
- for (i = this->pd_referenced_used;
- 0 < i && this->pd_referenced [i - 1] != ex;
- --i)
+ for (long i = this->pd_referenced_used; 0 < i; --i)
{
- this->pd_referenced [i] = this->pd_referenced [i - 1];
+ this->pd_referenced[i] = this->pd_referenced[i - 1];
+
+ if (this->pd_referenced[i - 1] == ex)
+ {
+ this->pd_referenced[i] = e;
+ break;
+ }
+ }
+
+ if (0 < this->pd_referenced_used)
+ {
+ ++this->pd_referenced_used;
}
- this->pd_referenced [i] = e;
- ++this->pd_referenced_used;
}
// Now, if recursive is specified and "this" is not a common ancestor
@@ -1555,6 +1609,7 @@ UTL_Scope::add_to_name_referenced (Identifier *id)
}
delete [] this->pd_name_referenced;
+
this->pd_name_referenced = name_tmp;
}
@@ -1574,6 +1629,7 @@ UTL_Scope::replace_referenced (AST_Decl *old_decl,
break;
}
}
+
}
void
@@ -1602,7 +1658,6 @@ UTL_Scope::add_to_scope (AST_Decl *e,
Identifier *decl_name = e->local_name ();
char *decl_string = decl_name->get_string ();
- AST_Decl::NodeType new_nt = e->node_type ();
// First, make sure there's no clash between e, that was
// just declared, and some other identifier referenced
@@ -1620,6 +1675,7 @@ UTL_Scope::add_to_scope (AST_Decl *e,
// error, unless they're both modules (which can be
// reopened) or we have a belated definition of a
// forward-declared interface.
+ AST_Decl::NodeType new_nt = e->node_type ();
AST_Decl::NodeType scope_elem_nt = (*tmp)->node_type ();
if (decl_name->compare (ref_name)
@@ -1708,6 +1764,7 @@ UTL_Scope::add_to_scope (AST_Decl *e,
}
delete [] this->pd_decls;
+
this->pd_decls = tmp;
}
@@ -1718,14 +1775,17 @@ UTL_Scope::add_to_scope (AST_Decl *e,
}
else
{
- long i;
- for (i = this->pd_decls_used;
- 0 < i && this->pd_decls [i - 1] != ex;
- --i)
+ for (long i = this->pd_decls_used; 0 < i; --i)
{
- this->pd_decls [i] = this->pd_decls [i - 1];
+ this->pd_decls[i] = this->pd_decls[i - 1];
+
+ if (this->pd_decls[i - 1] == ex)
+ {
+ this->pd_decls[i] = e;
+ break;
+ }
}
- this->pd_decls [i] = e;
+
++this->pd_decls_used;
}
}
@@ -1766,13 +1826,10 @@ bool
UTL_Scope::referenced (AST_Decl *e,
Identifier *id)
{
- Identifier *test = e->local_name ();
- AST_Decl::NodeType nt = e->node_type ();
-
AST_Decl **tmp = this->pd_referenced;
for (long i = this->pd_referenced_used;
- i--; // NOTE test with i--
- ++tmp)
+ 0 < i;
+ --i, ++tmp)
{
// Same node?
if (*tmp == e)
@@ -1782,10 +1839,14 @@ UTL_Scope::referenced (AST_Decl *e,
// Are we definging a forward declared struct, union, or interface,
// or reopening a module?
- if (!this->redef_clash (nt, (*tmp)->node_type ())
- && (*tmp)->local_name ()->compare (test))
+ if (!this->redef_clash (e->node_type (), (*tmp)->node_type ()))
{
- return false;
+ Identifier *member = (*tmp)->local_name ();
+ Identifier *test = e->local_name ();
+ if (member->compare (test))
+ {
+ return false;
+ }
}
}
@@ -1799,8 +1860,8 @@ UTL_Scope::referenced (AST_Decl *e,
{
Identifier **name_tmp = this->pd_name_referenced;
for (long j = this->pd_name_referenced_used;
- j--; // NOTE test with j--
- ++name_tmp)
+ 0 < j;
+ --j, ++name_tmp)
{
// If we are a module, there is no clash, if we
// are an interface, this is not the right place to
@@ -1809,18 +1870,18 @@ UTL_Scope::referenced (AST_Decl *e,
// that was, and it can appear any number of times
// in this scope without a clash.
AST_Decl::NodeType nt = e->node_type ();
- if ( nt != AST_Decl::NT_module
+ if (id->compare (*name_tmp)
+ && nt != AST_Decl::NT_module
&& nt != AST_Decl::NT_param_holder
- && e->defined_in () == this
- && id->compare (*name_tmp))
+ && e->defined_in () == this)
{
idl_global->err ()->redef_error (id->get_string (),
(*name_tmp)->get_string ());
return true;
}
// No clash if one or the other of the identifiers was escaped.
- else if (!(id->escaped () ^ (*name_tmp)->escaped ())
- && id->case_compare_quiet (*name_tmp))
+ else if (id->case_compare_quiet (*name_tmp)
+ && !(id->escaped () ^ (*name_tmp)->escaped ()))
{
if (idl_global->case_diff_error ())
{
@@ -1936,19 +1997,24 @@ UTL_Scope::match_param (UTL_ScopedName *e)
return 0;
}
+ AST_Param_Holder *retval = 0;
const char *name = e->first_component ()->get_string ();
- FE_Utils::T_Param_Info *param = 0;
for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*params);
- i.next (param);
+ !i.done ();
i.advance ())
{
+ FE_Utils::T_Param_Info *param = 0;
+ i.next (param);
+
if (param->name_ == name)
{
- return idl_global->gen ()->create_param_holder (e, param);
+ retval =
+ idl_global->gen ()->create_param_holder (e, param);
+ break;
}
}
- return 0;
+ return retval;
}
bool
@@ -1989,11 +2055,12 @@ UTL_Scope::arg_specific_error (AST_Decl *t)
AST_Argument *arg = AST_Argument::narrow_from_decl (t);
AST_Argument::Direction d = arg->direction ();
+ AST_Operation::Flags flag = op->flags ();
- // Cannot add OUT or INOUT argument to oneway operation.
+ /// Cannot add OUT or INOUT argument to oneway operation.
if (( d == AST_Argument::dir_OUT
|| d == AST_Argument::dir_INOUT)
- && op->flags () == AST_Operation::OP_oneway)
+ && flag == AST_Operation::OP_oneway)
{
idl_global->err ()->error2 (UTL_Error::EIDL_ONEWAY_CONFLICT,
t,
@@ -2001,8 +2068,9 @@ UTL_Scope::arg_specific_error (AST_Decl *t)
return true;
}
- // This error is not caught in y.tab.cpp so we check for it here.
AST_Type *arg_type = arg->field_type ();
+
+ /// This error is not caught in y.tab.cpp so we check for it here.
if ( arg_type->node_type () == AST_Decl::NT_array
&& arg_type->anonymous ())
{
@@ -2016,14 +2084,14 @@ UTL_Scope::arg_specific_error (AST_Decl *t)
void
UTL_Scope::smart_local_add (AST_Decl *t)
{
- // Catches struct, union * exception
+ /// Catches struct, union * exception
AST_Structure *s = AST_Structure::narrow_from_scope (this);
- // Catches AST_Field and AST_UnionBranch.
+ /// Catches AST_Field and AST_UnionBranch.
AST_Field *f = AST_Field::narrow_from_decl (t);
- // Decls inside a struct/union/exception are also referenced by
- // fields, and so must be handled differently.
+ /// Decls inside a struct/union/exception are also referenced by
+ /// fields, and so must be handled differently.
if (s && !f)
{
this->add_to_local_types (t);
@@ -2051,7 +2119,7 @@ UTL_Scope::smart_local_add (AST_Decl *t)
}
}
-// Determines if a name is global.
+/// Determines if a name is global.
bool
UTL_Scope::is_global_name (Identifier *i)
{
@@ -2061,7 +2129,12 @@ UTL_Scope::is_global_name (Identifier *i)
}
ACE_CString cmp (i->get_string (), 0, false);
- return (cmp == "" || cmp == "::");
+ if (cmp == "" || cmp == "::")
+ {
+ return true;
+ }
+
+ return false;
}
AST_Decl *
@@ -2103,8 +2176,14 @@ UTL_Scope::iter_lookup_by_name_local (AST_Decl *d,
else
{
AST_Interface *i = AST_Interface::narrow_from_decl (d);
- result = i ? i->look_in_inherited_local (e->head ())
- : sc->look_in_prev_mods_local (e->head (), true);
+ if (i)
+ {
+ result = i->look_in_inherited_local (e->head ());
+ }
+ else
+ {
+ result = sc->look_in_prev_mods_local (e->head (), true);
+ }
}
UTL_ScopedName *sn = (UTL_ScopedName *) e->tail ();
@@ -2126,6 +2205,48 @@ UTL_Scope::iter_lookup_by_name_local (AST_Decl *d,
return result;
}
+AST_Decl *
+UTL_Scope::local_checks (AST_Decl *d, bool full_def_only)
+{
+ AST_Decl *retval = 0;
+
+ // Special case for forward declared types,
+ // In this case, we want to return
+ // the full definition member, whether defined yet or not.
+ // NOTE: corresponding full_definition fe_add_* methods
+ // depend on the behavior below!
+ AST_Decl::NodeType nt = d->node_type ();
+ if ( nt == AST_Decl::NT_struct_fwd
+ || nt == AST_Decl::NT_union_fwd)
+ {
+ AST_Structure *s =
+ AST_StructureFwd::narrow_from_decl (d)->full_definition ();
+
+ retval = (full_def_only && !s->is_defined () ? 0 : s);
+ }
+ else if ( nt == AST_Decl::NT_interface_fwd
+ || nt == AST_Decl::NT_valuetype_fwd
+ || nt == AST_Decl::NT_component_fwd
+ || nt == AST_Decl::NT_eventtype_fwd)
+ {
+ AST_Interface *i =
+ AST_InterfaceFwd::narrow_from_decl (d)->full_definition ();
+
+ retval = (full_def_only && !i->is_defined () ? 0 : i);
+ }
+ else if (!AST_Template_Module_Ref::narrow_from_decl (d))
+ {
+ // If we are not a template module reference, ok. If so,
+ // however, we don't want to return that type, we want
+ // the regular module which will follow it immediately
+ // in this scope, return 0 and catch it on the nest
+ // iteration.
+ retval = d;
+ }
+
+ return retval;
+}
+
IMPL_NARROW_FROM_SCOPE(UTL_Scope)
// UTL_SCOPE_ACTIVE_ITERATOR