diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-09-13 02:42:51 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-09-13 02:42:51 +0000 |
commit | 0517e6f21bc1cc23ba081f8e838db48943b246ae (patch) | |
tree | 775024fbaa5813c4c7ae7b896f8860c7c5c2c76c | |
parent | 142a003dc85d6cecc514fc35d6e6ebd5c69cf254 (diff) | |
download | ATCD-0517e6f21bc1cc23ba081f8e838db48943b246ae.tar.gz |
ChangeLogTag: Tue Sep 12 21:29:30 2000 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r-- | TAO/TAO_IDL/ast/ast_module.cpp | 1035 | ||||
-rw-r--r-- | TAO/TAO_IDL/fe/fe_interface_header.cpp | 369 | ||||
-rw-r--r-- | TAO/TAO_IDL/util/utl_scope.cpp | 1619 | ||||
-rw-r--r-- | TAO/tests/IDL_Test/reopen_include1.idl | 13 | ||||
-rw-r--r-- | TAO/tests/IDL_Test/reopen_include2.idl | 18 | ||||
-rw-r--r-- | TAO/tests/IDL_Test/reopened_modules.idl | 25 |
6 files changed, 1787 insertions, 1292 deletions
diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp index a611386b4dc..646054633b0 100644 --- a/TAO/TAO_IDL/ast/ast_module.cpp +++ b/TAO/TAO_IDL/ast/ast_module.cpp @@ -62,32 +62,31 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_module.cc - Implementation of class AST_Module - * - * AST_Modules denote IDL module declarations - * AST_Modules are subclasses of AST_Decl (they are not a type!) and - * of UTL_Scope. - */ +// Implementation of class AST_Module + +// AST_Modules denote IDL module declarations +// AST_Modules are subclasses of AST_Decl (they are not a type!) and +// of UTL_Scope. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_module, "$Id$") -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. + AST_Module::AST_Module () { } AST_Module::AST_Module (UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (AST_Decl::NT_module, n, p), - UTL_Scope(AST_Decl::NT_module), + : AST_Decl (AST_Decl::NT_module, + n, + p), + UTL_Scope (AST_Decl::NT_module), pd_has_nested_valuetype (0) { } @@ -96,67 +95,63 @@ AST_Module::~AST_Module (void) { } -/* - * Private operations - */ +// Add this AST_PredefinedType node (a predefined type declaration) to +// this scope. -/* - * Public operations - */ +AST_PredefinedType * +AST_Module::fe_add_predefined_type (AST_PredefinedType *t) +{ + AST_Decl *d = 0; -/* - * Redefinition of inherited virtual operations - */ + // Already defined and cannot be redefined? Or already used? + if ((d = this->lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } -/* - * Add this AST_PredefinedType node (a predefined type declaration) to - * this scope - */ -AST_PredefinedType *AST_Module::fe_add_predefined_type(AST_PredefinedType *t) -{ - AST_Decl *d; + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + if (t->has_ancestor (d)) + { + idl_global->err()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Module node (a module declaration) to this scope - */ -AST_Module *AST_Module::fe_add_module (AST_Module *t) +// Add this AST_Module node (a module declaration) to this scope. +AST_Module * +AST_Module::fe_add_module (AST_Module *t) { AST_Decl *d; AST_Module *m = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { @@ -164,29 +159,34 @@ AST_Module *AST_Module::fe_add_module (AST_Module *t) t, this, d); - return NULL; + return 0; } - // if our platform supports namespaces, we allow reopening - // modules. However, if namespace support is not available, this is flagged - // as an error + // If our platform supports namespaces, we allow reopening + // modules. However, if namespace support is not available, this is + // flagged as an error. #ifndef ACE_HAS_USING_KEYWORD if (referenced (d, t->local_name ()) && !d->imported () - && !ACE_BIT_ENABLED (idl_global->compile_flags (), IDL_CF_NOWARNINGS)) + && !ACE_BIT_ENABLED (idl_global->compile_flags (), + IDL_CF_NOWARNINGS)) { UTL_String *s = t->file_name (); long lineno = t->line (); - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%s:warning: %s:%d: %s%s"), - ACE_TEXT (idl_global->prog_name ()), - ACE_TEXT ((idl_global->read_from_stdin () - ? "standard input" - : s->get_string ())), - lineno, - ACE_TEXT ("reopening module but platform does not\n"), - ACE_TEXT ("support namespaces, generated code may not compile\n")), - 0); + + ACE_ERROR_RETURN (( + LM_ERROR, + ACE_TEXT ("%s:warning: %s:%d: %s%s"), + ACE_TEXT (idl_global->prog_name ()), + ACE_TEXT ((idl_global->read_from_stdin () + ? "standard input" + : s->get_string ())), + lineno, + ACE_TEXT ("Reopening module but platform does not support\n"), + ACE_TEXT (" namespaces, generated code may not compile\n") + ), + 0 + ); } #endif /* ACE_HAS_USING_KEYWORD */ @@ -197,8 +197,9 @@ AST_Module *AST_Module::fe_add_module (AST_Module *t) { if (t->has_ancestor (d)) { - idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; } } } @@ -206,13 +207,10 @@ AST_Module *AST_Module::fe_add_module (AST_Module *t) // If this node is not a reopened module, add it to scope and referenced. if (m == 0 || t != m) { - /* - * Add it to scope - */ + // Add it to scope. this->add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ + + // Add it to set of locally referenced symbols. this->add_to_referenced (t, I_FALSE, t->local_name ()); @@ -221,30 +219,28 @@ AST_Module *AST_Module::fe_add_module (AST_Module *t) return t; } -/* - * Add this AST_Interface node (an interface declaration) to this scope - */ -AST_Interface *AST_Module::fe_add_interface (AST_Interface *t) +// Add this AST_Interface node (an interface declaration) to this scope. +AST_Interface * +AST_Module::fe_add_interface (AST_Interface *t) { - AST_Decl *predef; - AST_Interface *fwd; + AST_Decl *predef = 0; + AST_Interface *fwd = 0; - /* - * Already defined? - */ - if ((predef = lookup_for_add (t, I_FALSE)) != NULL) + // Already defined? + if ((predef = lookup_for_add (t, I_FALSE)) != 0) { - /* - * Treat fwd declared interfaces specially - */ + // Treat fwd declared interfaces specially if (predef->node_type() == AST_Decl::NT_interface) { fwd = AST_Interface::narrow_from_decl (predef); - if (fwd == NULL) - return NULL; + if (fwd == 0) + { + return 0; + } - if (!fwd->is_defined ()) /* Forward declared and not defined yet */ + // Forward declared and not defined yet. + if (!fwd->is_defined ()) { if (fwd->defined_in () != this) { @@ -253,14 +249,11 @@ AST_Interface *AST_Module::fe_add_interface (AST_Interface *t) t, this); - return NULL; + return 0; } } - - /* - * OK, not illegal redef of forward declaration. Now check whether - * it has been referenced already - */ + // OK, not illegal redef of forward declaration. Now check whether. + // it has been referenced already. else if (referenced (predef, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, @@ -268,7 +261,7 @@ AST_Interface *AST_Module::fe_add_interface (AST_Interface *t) this, predef); - return NULL; + return 0; } } else if (!can_be_redefined (predef)) @@ -278,7 +271,7 @@ AST_Interface *AST_Module::fe_add_interface (AST_Interface *t) this, predef); - return NULL; + return 0; } else if (referenced (predef, t->local_name ())) { @@ -287,416 +280,514 @@ AST_Interface *AST_Module::fe_add_interface (AST_Interface *t) this, predef); - return NULL; + return 0; } else if (t->has_ancestor (predef)) { idl_global->err ()->redefinition_in_scope (t, predef); - return NULL; + return 0; } } - /* - * Add it to scope - */ + + // Add it to scope this->add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ + + // Add it to set of locally referenced symbols this->add_to_referenced (t, I_FALSE, t->local_name ()); return t; } -/* - * Add this AST_InterfaceFwd node (a forward declaration of an IDL - * interface) to this scope - */ -AST_InterfaceFwd *AST_Module::fe_add_interface_fwd(AST_InterfaceFwd *i) +// Add this AST_InterfaceFwd node (a forward declaration of an IDL +// interface) to this scope. +AST_InterfaceFwd * +AST_Module::fe_add_interface_fwd (AST_InterfaceFwd *i) { - AST_Decl *d; - AST_Interface *itf; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(i, I_FALSE)) != NULL) { - if (d->node_type() == AST_Decl::NT_interface && - d->defined_in() == this) { - itf = AST_Interface::narrow_from_decl(d); - if (itf == NULL) - return NULL; + AST_Decl *d = 0; + AST_Interface *itf = 0; - // %! redefinition of forward; type check not implemented - i->set_full_definition(itf); //%! memory leak - return i; - } - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, i, this, d); - return NULL; - } - if (referenced(d, i->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, i, this, d); - return NULL; - } - if (i->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(i, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (i, I_FALSE)) != 0) + { + if (d->node_type () == AST_Decl::NT_interface + && d->defined_in () == this) + { + itf = AST_Interface::narrow_from_decl (d); + + if (itf == 0) + { + return 0; + } + + // @@ Redefinition of forward. Type check not implemented. + i->set_full_definition (itf); // @@ Memory leak. + return i; + } + + if (!can_be_redefined (d)) { + + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + i, + this, + d); + return 0; + } + + if (this->referenced (d, i->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + i, + this, + d); + return 0; + } + + if (i->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (i, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(i); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(i, I_FALSE, i->local_name ()); + + // Add it to scope + this->add_to_scope (i); + + // Add it to set of locally referenced symbols + this->add_to_referenced (i, + I_FALSE, + i->local_name ()); return i; } -/* - * Add this AST_Constant node (a constant declaration) to this scope - */ -AST_Constant *AST_Module::fe_add_constant(AST_Constant *t) +// Add this AST_Constant node (a constant declaration) to this scope. +AST_Constant * +AST_Module::fe_add_constant (AST_Constant *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return NULL; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Exception node (an exception declaration) to this scope - */ -AST_Exception *AST_Module::fe_add_exception(AST_Exception *t) +// Add this AST_Exception node (an exception declaration) to this scope +AST_Exception * +AST_Module::fe_add_exception (AST_Exception *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Union node (a union declaration) to this scope - */ -AST_Union *AST_Module::fe_add_union(AST_Union *t) +// Add this AST_Union node (a union declaration) to this scope +AST_Union * +AST_Module::fe_add_union (AST_Union *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Structure node (a struct declaration) to this scope - */ -AST_Structure *AST_Module::fe_add_structure(AST_Structure *t) +// Add this AST_Structure node (a struct declaration) to this scope. +AST_Structure * +AST_Module::fe_add_structure (AST_Structure *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced(d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor(d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Enum node (an enum declaration) to this scope - */ -AST_Enum *AST_Module::fe_add_enum(AST_Enum *t) +// Add this AST_Enum node (an enum declaration) to this scope. +AST_Enum * +AST_Module::fe_add_enum (AST_Enum *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced(d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor(d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_EnumVal node (an enumerator declaration) to this scope - * This is done to conform to the C++ scoping rules which declare - * enumerators in the enclosing scope (in addition to declaring them - * in the enum itself) - */ -AST_EnumVal *AST_Module::fe_add_enum_val(AST_EnumVal *t) +// Add this AST_EnumVal node (an enumerator declaration) to this scope +// This is done to conform to the C++ scoping rules which declare +// enumerators in the enclosing scope (in addition to declaring them +// in the enum itself). +AST_EnumVal * +AST_Module::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add(t, I_FALSE)) != 0) + { + if (!can_be_redefined(d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced(d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor(d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Typedef node (a typedef) to this scope - */ -AST_Typedef *AST_Module::fe_add_typedef(AST_Typedef *t) +// Add this AST_Typedef node (a typedef) to this scope. +AST_Typedef * +AST_Module::fe_add_typedef (AST_Typedef *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add(t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor(d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Native (a native declaration) to this scope - */ -AST_Native *AST_Module::fe_add_native (AST_Native *t) +// Add an AST_Native (a native declaration) to this scope. +AST_Native * +AST_Module::fe_add_native (AST_Native *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Module node to the ostream o - */ +// Dump this AST_Module node to the ostream o. void -AST_Module::dump(ostream &o) +AST_Module::dump (ostream &o) { o << "module "; - local_name()->dump(o); + this->local_name ()->dump (o); o << " {\n"; - UTL_Scope::dump(o); - idl_global->indent()->skip_to(o); + UTL_Scope::dump (o); + idl_global->indent ()->skip_to (o); o << "}"; } -// involved in OBV_ namespace generation +// Involved in OBV_ namespace generation. void -AST_Module::set_has_nested_valuetype () +AST_Module::set_has_nested_valuetype (void) { #ifdef IDL_HAS_VALUETYPE UTL_Scope *parent = this->defined_in (); - if (!pd_has_nested_valuetype && parent) + + if (!this->pd_has_nested_valuetype && parent) { AST_Module *pm = AST_Module::narrow_from_scope (parent); + if (pm) - pm->set_has_nested_valuetype (); + { + pm->set_has_nested_valuetype (); + } } - pd_has_nested_valuetype = 1; + + this->pd_has_nested_valuetype = 1; #endif /* IDL_HAS_VALUETYPE */ } idl_bool -AST_Module::has_nested_valuetype () +AST_Module::has_nested_valuetype (void) { - return pd_has_nested_valuetype; + return this->pd_has_nested_valuetype; } int -AST_Module::be_add_interface (AST_Interface *i, AST_Interface *ix) +AST_Module::be_add_interface (AST_Interface *i, + AST_Interface *ix) { - /* - * Add it to scope - */ - add_to_scope(i, ix); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(i, I_FALSE, i->local_name (), ix); + // Add it to scope. + this->add_to_scope (i, + ix); + + // Add it to set of locally referenced symbols + this->add_to_referenced (i, + I_FALSE, + i->local_name (), + ix); return 0; } @@ -704,47 +795,69 @@ AST_Module::be_add_interface (AST_Interface *i, AST_Interface *ix) void AST_Module::add_CORBA_members (void) { - AST_PredefinedType *pdt; - - pdt = idl_global->gen ()->create_predefined_type ( - AST_PredefinedType::PT_pseudo, - new UTL_ScopedName ( - new Identifier ("TypeCode", - 1, - 0, - I_FALSE), - NULL), - NULL); - - this->fe_add_predefined_type (pdt); - - pdt = idl_global->gen ()->create_predefined_type ( - AST_PredefinedType::PT_pseudo, - new UTL_ScopedName ( - new Identifier ("TCKind", - 1, - 0, - I_FALSE), - NULL), - NULL); - - this->fe_add_predefined_type (pdt); + UTL_ScopedName *sn = 0; + Identifier *id = 0; + + ACE_NEW (id, + Identifier ("TypeCode", + 1, + 0, + I_FALSE)); + + ACE_NEW (sn, + UTL_ScopedName (id, + 0)); + + AST_PredefinedType *pdt = + idl_global->gen ()->create_predefined_type ( + AST_PredefinedType::PT_pseudo, + sn, + 0 + ); + + this->fe_add_predefined_type (pdt); + + ACE_NEW (id, + Identifier ("TCKind", + 1, + 0, + I_FALSE)); + + ACE_NEW (sn, + UTL_ScopedName (id, + 0)); + + pdt = + idl_global->gen ()->create_predefined_type ( + AST_PredefinedType::PT_pseudo, + sn, + 0 + ); + + this->fe_add_predefined_type (pdt); # ifdef IDL_HAS_VALUETYPE - if (idl_global->obv_support ()) - { - pdt = idl_global->gen()->create_predefined_type ( - AST_PredefinedType::PT_pseudo, - new UTL_ScopedName ( - new Identifier ("ValueBase", - 1, - 0, - I_FALSE), - NULL), - NULL); + if (idl_global->obv_support ()) + { + ACE_NEW (id, + Identifier ("ValueBase", + 1, + 0, + I_FALSE)); + + ACE_NEW (sn, + UTL_ScopedName (id, + 0)); + + pdt = + idl_global->gen ()->create_predefined_type ( + AST_PredefinedType::PT_pseudo, + sn, + 0 + ); - this->fe_add_predefined_type (pdt); - } + this->fe_add_predefined_type (pdt); + } # endif /* IDL_HAS_VALUETYPE */ } @@ -787,21 +900,25 @@ AST_Decl * AST_Module::look_in_previous (Identifier *e) { AST_Decl *d = 0; + AST_Decl *retval = 0; ACE_Unbounded_Set_Iterator<AST_Decl *> iter (this->previous_); + // 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_. while (!iter.done ()) { d = *iter; if (e->case_compare (d->local_name ())) { - return d; + retval = d; } iter++; } - return 0; + return retval; } void @@ -809,9 +926,7 @@ AST_Module::destroy (void) { } -/* - * Narrowing methods - */ +// Narrowing methods IMPL_NARROW_METHODS2(AST_Module, AST_Decl, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Module) IMPL_NARROW_FROM_SCOPE(AST_Module) diff --git a/TAO/TAO_IDL/fe/fe_interface_header.cpp b/TAO/TAO_IDL/fe/fe_interface_header.cpp index 8d44332cf3d..4920f4d41ba 100644 --- a/TAO/TAO_IDL/fe/fe_interface_header.cpp +++ b/TAO/TAO_IDL/fe/fe_interface_header.cpp @@ -62,32 +62,25 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * fe_interface_header.cc - Implements the FE private class FE_InterfaceHeader - * - * FE_InterfaceHeader instances are used to store information about an - * interface header as the interface is being parsed and before the - * AST_Interface node used to represent this interface is created. - */ - -#include "idl.h" -#include "idl_extern.h" +// FE_InterfaceHeader instances are used to store information about an +// interface header as the interface is being parsed and before the +// AST_Interface node used to represent this interface is created. -#include "fe_private.h" +#include "idl.h" +#include "idl_extern.h" +#include "fe_private.h" ACE_RCSID(fe, fe_interface_header, "$Id$") -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor FE_InterfaceHeader::FE_InterfaceHeader (UTL_ScopedName *n, UTL_NameList *nl, UTL_NameList *supports, idl_bool compile_now) - : pd_interface_name(n) + : pd_interface_name (n) { if (compile_now) { @@ -100,115 +93,107 @@ FE_InterfaceHeader::~FE_InterfaceHeader (void) { } -/* - * Private operations - */ - // Compute flattened, non-repeating list of inherited interfaces #undef INCREMENT -#define INCREMENT 512 +#define INCREMENT 512 -/* - * Private storage used to store interfaces seen already in the - * computation of the unique inheritance list - */ -static AST_Interface **iseen = NULL; -static long iallocated = 0; -static long iused = 0; +// Private storage used to store interfaces seen already in the +// computation of the unique inheritance list. +static AST_Interface **iseen = 0; +static long iallocated = 0; +static long iused = 0; // Same as above, but the list is flattened and // includes all ancestors, not just immediate ones. -static AST_Interface **iseen_flat = NULL; -static long iallocated_flat = 0; -static long iused_flat = 0; +static AST_Interface **iseen_flat = 0; +static long iallocated_flat = 0; +static long iused_flat = 0; -/* - * Add an interface to an inheritance spec - */ +// Add an interface to an inheritance spec. static void add_inheritance (AST_Interface *i) { - long k; - AST_Interface **oiseen; + AST_Interface **oiseen; - /* - * Make sure there's space for one more - */ + // Make sure there's space for one more. if (iallocated == iused) { if (iallocated == 0) { iallocated = INCREMENT; - iseen = new AST_Interface *[iallocated]; + + ACE_NEW (iseen, + AST_Interface *[iallocated]); } else { oiseen = iseen; iallocated += INCREMENT; - iseen = new AST_Interface *[iallocated]; - for (k = 0; k < iused; k++) - iseen[k] = oiseen[k]; + ACE_NEW (iseen, + AST_Interface *[iallocated]); + + for (long k = 0; k < iused; k++) + { + iseen[k] = oiseen[k]; + } delete oiseen; } } - /* - * OK, now insert it - */ - iseen[iused] = i; - iused++; + + // OK, now insert it. + iseen[iused++] = i; } // Add an interface to the flat list. static void add_inheritance_flat (AST_Interface *i) { - long k; - AST_Interface **oiseen_flat; + AST_Interface **oiseen_flat; - /* - * Make sure there's space for one more - */ + // Make sure there's space for one more if (iallocated_flat == iused_flat) { if (iallocated_flat == 0) { iallocated_flat = INCREMENT; - iseen_flat = new AST_Interface *[iallocated_flat]; + + ACE_NEW (iseen_flat, + AST_Interface *[iallocated_flat]); } else { oiseen_flat = iseen_flat; iallocated_flat += INCREMENT; - iseen_flat = new AST_Interface *[iallocated_flat]; - for (k = 0; k < iused_flat; k++) - iseen_flat[k] = oiseen_flat[k]; + ACE_NEW (iseen_flat, + AST_Interface *[iallocated_flat]); + + for (long k = 0; k < iused_flat; k++) + { + iseen_flat[k] = oiseen_flat[k]; + } delete oiseen_flat; } } - /* - * OK, now insert it - */ - iseen_flat[iused_flat] = i; - iused_flat++; + + // OK, now insert it + iseen_flat[iused_flat++] = i; } -/* - * Have we already seen this interface? - */ +// Have we already seen this interface? static long already_seen (AST_Interface *ip) { - long i; - - for (i = 0; i < iused; i++) + for (long i = 0; i < iused; i++) { if (iseen[i] == ip) - return I_TRUE; + { + return I_TRUE; + } } return I_FALSE; @@ -218,12 +203,12 @@ already_seen (AST_Interface *ip) static long already_seen_flat (AST_Interface *ip) { - long i; - - for (i = 0; i < iused_flat; i++) + for (long i = 0; i < iused_flat; i++) { if (iseen_flat[i] == ip) - return I_TRUE; + { + return I_TRUE; + } } return I_FALSE; @@ -241,30 +226,30 @@ FE_InterfaceHeader::is_abstract (void) return 0; } -/* - * Add this interface to the list of inherited if not already there - */ +// Add this interface to the list of inherited if not already there. void FE_InterfaceHeader::compile_one_inheritance (AST_Interface *i) { - /* - * Check for badly formed interface - */ + // Check for badly formed interface. if (i == NULL) - return; - /* - * If we've seen it already then don't expand again - */ + { + return; + } + + // If we've seen it already then don't expand again. if (already_seen (i)) - return; - /* - * OK, add i to the list of inherited interfaces - */ + { + return; + } + + // OK, add i to the list of inherited interfaces. add_inheritance (i); - // And add i to the flat list as well + // And add i to the flat list as well. if (!already_seen_flat (i)) - add_inheritance_flat (i); + { + add_inheritance_flat (i); + } // Add i's parents to the flat list. AST_Interface **parents = i->inherits (); @@ -275,89 +260,107 @@ FE_InterfaceHeader::compile_one_inheritance (AST_Interface *i) AST_Interface *tmp = parents[j]; if (already_seen_flat (tmp)) - continue; + { + continue; + } add_inheritance_flat (tmp); } } -/* - * Compute the list of top-level interfaces this one inherits from - */ +// Compute the list of top-level interfaces this one inherits from. void FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, UTL_NameList *supports) { - UTL_NamelistActiveIterator *l; - AST_Decl *d; - AST_Interface *i; - long j, k; - UTL_NameList *nl; - int loops; - long ichecked = 0; - idl_bool inh_err = 0; - idl_bool in_supports = 0; + UTL_NamelistActiveIterator *l = 0; + AST_Decl *d = 0; + AST_Interface *i = 0; + long j, k; + UTL_NameList *nl = ifaces; + long ichecked = 0; + idl_bool inh_err = 0; + idl_bool in_supports = 0; iused = 0; iused_flat = 0; - /* - * Compute expanded flattened non-repeating list of interfaces - * which this one inherits from - */ - nl = ifaces; - // loop twice if nl and supports are nonempty - for (loops = 0; loops < 2; ++loops) + + //Compute expanded flattened non-repeating list of interfaces + // which this one inherits from. + + // Loop twice if nl and supports are nonempty. + for (int loops = 0; loops < 2; ++loops) { if (nl != NULL) { - l = new UTL_NamelistActiveIterator (nl); + ACE_NEW (l, + UTL_NamelistActiveIterator (nl)); - while (!(l->is_done ())) + while (!l->is_done ()) { - /* - * Check that scope stack is valid - */ - if (idl_global->scopes ()->top () == NULL) + // Check that scope stack is valid + if (idl_global->scopes ()->top () == 0) { idl_global->err ()->lookup_error (l->item ()); return; } - /* - * Look it up - */ - d = idl_global->scopes ()->top ()->lookup_by_name (l->item (), - I_TRUE); - /* - * Not found? - */ - if (d == NULL) + + // Look it up + UTL_Scope *s = idl_global->scopes ()->top (); + + d = s->lookup_by_name (l->item (), + I_TRUE); + + if (d == 0) + { + AST_Decl *sad = ScopeAsDecl (s); + + if (sad->node_type () == AST_Decl::NT_module) + { + AST_Module *m = AST_Module::narrow_from_decl (sad); + + d = m->look_in_previous (l->item ()->last_component ()); + } + } + + // Not found? + if (d == 0) { idl_global->err ()->lookup_error (l->item ()); return; } - /* - * Not an appropriate interface? - */ + + // Not an appropriate interface? while (d->node_type () == AST_Decl::NT_typedef) - d = AST_Typedef::narrow_from_decl (d)->base_type (); + { + d = AST_Typedef::narrow_from_decl (d)->base_type (); + } if (d->node_type () == AST_Decl::NT_interface) - i = AST_Interface::narrow_from_decl (d); + { + i = AST_Interface::narrow_from_decl (d); + } else - i = NULL; + { + i = 0; + } - if (i != NULL) + if (i != 0) { if (in_supports) { - inh_err = ! this->check_supports (i); + inh_err = !this->check_supports (i); } else { if (ichecked == 0) - inh_err = ! this->check_first (i); + { + inh_err = !this->check_first (i); + } else - inh_err = ! this->check_further (i); + { + inh_err = !this->check_further (i); + } } } else @@ -369,12 +372,10 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, { idl_global->err ()->inheritance_error (pd_interface_name, d); - return; //%! really ? inh_err=0; and test the remaining...? + return; // @@ really ? inh_err=0; and test the remaining...? } - /* - * Forward declared interface? - */ + // Forward declared interface? if (!i->is_defined ()) { idl_global->err ()->inheritance_fwd_error (pd_interface_name, @@ -382,20 +383,18 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, return; } - /* - * OK, see if we have to add this to the list of interfaces - * inherited from - */ - compile_one_inheritance (i); + // OK, see if we have to add this to the list of interfaces + // inherited from. + this->compile_one_inheritance (i); - /* - * Next element in header list - */ - ++ ichecked; + // Next element in header list. + ++ichecked; l->next (); } + delete l; } + in_supports = 1; nl = supports; } @@ -405,33 +404,39 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, this->pd_inherits_flat = new AST_Interface *[iused_flat]; for (j = 0; j < iused_flat; j++) - this->pd_inherits_flat[j] = iseen_flat[j]; + { + this->pd_inherits_flat[j] = iseen_flat[j]; + } this->pd_n_inherits_flat = iused_flat; // Then the list of immediate ancestors - pd_inherits = new AST_Interface *[iused]; + ACE_NEW (this->pd_inherits, + AST_Interface *[iused]); for (k = 0; k < iused; k++) - this->pd_inherits[k] = iseen[k]; + { + this->pd_inherits[k] = iseen[k]; + } this->pd_n_inherits = iused; } // check_ methods called from compile_inheritance() -// overridden in derived classes +// overridden in derived classes. idl_bool FE_InterfaceHeader::check_first (AST_Interface *i) { - // nothing special for the first + // Nothing special for the first. return this->check_further (i); } idl_bool FE_InterfaceHeader::check_further (AST_Interface *i) { - if (i && ! i->is_valuetype () && - (this->is_local () || !i->is_local ())) + if (i != 0 + && !i->is_valuetype () + && (this->is_local () || !i->is_local ())) { return 1; } @@ -447,53 +452,45 @@ FE_InterfaceHeader::check_supports (AST_Interface *) return 0; } - -/* - * Public operations - */ - -/* - * Redefinition of inherited virtual operations - */ - -/* - * Data accessors - */ +// Data accessors UTL_ScopedName * FE_InterfaceHeader::interface_name (void) { - return pd_interface_name; + return this->pd_interface_name; } AST_Interface ** FE_InterfaceHeader::inherits (void) { - return pd_inherits; + return this->pd_inherits; } long FE_InterfaceHeader::n_inherits (void) { - return pd_n_inherits; + return this->pd_n_inherits; } AST_Interface ** FE_InterfaceHeader::inherits_flat (void) { - return pd_inherits_flat; + return this->pd_inherits_flat; } long FE_InterfaceHeader::n_inherits_flat (void) { - return pd_n_inherits_flat; + return this->pd_n_inherits_flat; } FE_Local_InterfaceHeader::FE_Local_InterfaceHeader (UTL_ScopedName *n, UTL_NameList *nl, UTL_NameList *supports) - : FE_InterfaceHeader (n, nl, supports, 0) + : FE_InterfaceHeader (n, + nl, + supports, + 0) { compile_inheritance (nl, supports); @@ -509,7 +506,10 @@ FE_Abstract_InterfaceHeader::FE_Abstract_InterfaceHeader (UTL_ScopedName *n, UTL_NameList *nl, UTL_NameList *supports) - : FE_InterfaceHeader (n, nl, supports, 0) + : FE_InterfaceHeader (n, + nl, + supports, + 0) { compile_inheritance (nl, supports); @@ -528,7 +528,10 @@ FE_Abstract_InterfaceHeader::is_abstract (void) FE_obv_header::FE_obv_header (UTL_ScopedName *n, UTL_NameList *nl, UTL_NameList *supports) - : FE_InterfaceHeader (n, nl, supports,0), + : FE_InterfaceHeader (n, + nl, + supports, + 0), truncatable_ (0), n_concrete_ (0) { @@ -540,10 +543,12 @@ FE_obv_header::FE_obv_header (UTL_ScopedName *n, idl_bool FE_obv_header::check_first (AST_Interface *i) { - if (i && i->is_valuetype ()) + if (i != 0 && i->is_valuetype ()) { - if (! i->is_abstract_valuetype ()) - ++ n_concrete_; + if (!i->is_abstract_valuetype ()) + { + ++this->n_concrete_; + } return 1; } @@ -556,7 +561,9 @@ FE_obv_header::check_first (AST_Interface *i) idl_bool FE_obv_header::check_further (AST_Interface *i) { - if (i && i->is_valuetype () && i->is_abstract_valuetype ()) + if (i != 0 + && i->is_valuetype () + && i->is_abstract_valuetype ()) { return 1; } @@ -569,7 +576,7 @@ FE_obv_header::check_further (AST_Interface *i) idl_bool FE_obv_header::check_supports (AST_Interface *i) { - if (i && ! i->is_valuetype ()) + if (i && !i->is_valuetype ()) { return 1; } @@ -581,9 +588,9 @@ FE_obv_header::check_supports (AST_Interface *i) long -FE_obv_header::n_concrete () +FE_obv_header::n_concrete (void) { - return n_concrete_; + return this->n_concrete_; } // #endif /* IDL_HAS_VALUETYPE */ diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp index 22a55d56727..67e66eff109 100644 --- a/TAO/TAO_IDL/util/utl_scope.cpp +++ b/TAO/TAO_IDL/util/utl_scope.cpp @@ -62,11 +62,7 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ - -/* - * utl_scope.cc - Implementation of class UTL_Scope - */ +*/ #include "idl.h" #include "idl_extern.h" @@ -76,31 +72,49 @@ ACE_RCSID(util, utl_scope, "$Id$") #undef INCREMENT #define INCREMENT 64 -/* - * Static functions - */ -static Identifier *_global_scope_name = NULL; -static Identifier *_global_scope_root_name = NULL; +// Static variables. +static Identifier *_global_scope_name = 0; +static Identifier *_global_scope_root_name = 0; -/* - * Determines if a name is global - */ +// Static functions. + +// Determines if a name is global. static long -is_global_name(Identifier *i) +is_global_name (Identifier *i) { long comp_result = 0; - if (i == NULL) return comp_result; + if (i == 0) + { + return comp_result; + } - if (_global_scope_name == NULL) - _global_scope_name = new Identifier("::", 1, 0, I_FALSE); + if (_global_scope_name == 0) + { + ACE_NEW_RETURN (_global_scope_name, + Identifier ("::", + 1, + 0, + I_FALSE), + 0); + } + + if (_global_scope_root_name == 0) + { + ACE_NEW_RETURN (_global_scope_root_name, + Identifier ("", + 1, + 0, + I_FALSE), + 0); + } - if (_global_scope_root_name == NULL) - _global_scope_root_name = new Identifier("", 1, 0, I_FALSE); + comp_result = i->compare (_global_scope_name); - comp_result = i->compare(_global_scope_name); - if (!comp_result) - comp_result = i->compare(_global_scope_root_name); + if (comp_result == 0) + { + comp_result = i->compare (_global_scope_root_name); + } return comp_result; } @@ -114,165 +128,188 @@ iter_lookup_by_name_local (AST_Decl *d, { AST_Typedef *td = 0; - // Remove all the layers of typedefs + // Remove all the layers of typedefs. while (d != NULL && d->node_type () == AST_Decl::NT_typedef) { td = AST_Typedef::narrow_from_decl (d); - if (td == NULL) - return NULL; + if (td == 0) + { + return 0; + } d = td->base_type (); } - if (d == NULL) - return NULL; + if (d == 0) + { + return 0; + } - // Try to convert the AST_Decl to a UTL_Scope + // Try to convert the AST_Decl to a UTL_Scope. UTL_Scope *sc = DeclAsScope (d); - if (sc == NULL) - return NULL; + if (sc == 0) + { + return 0; + } // Look up the first component of the scoped name. AST_Decl *result = sc->lookup_by_name_local (e->head (), index); - if (result == NULL) - return NULL; + if (result == 0) + { + return 0; + } else { UTL_ScopedName *sn = (UTL_ScopedName *) e->tail (); - if (sn == NULL) - // We're done. - return result; + if (sn == 0) + { + // We're done. + return result; + } else - // Look up the next component of the scoped name. - result = iter_lookup_by_name_local (result, - sn, - 0); - - if (result != NULL) - // We're done. - return result; + { + // Look up the next component of the scoped name. + result = iter_lookup_by_name_local (result, + sn, + 0); + } + + if (result != 0) + { + // We're done. + return result; + } else - // Maybe we're on the wrong branch of reopened - // and/or nested modules, so let's see if there's - // another branch. - return iter_lookup_by_name_local (d, - e, - index + 1); + { + // Maybe we're on the wrong branch of reopened + // and/or nested modules, so let's see if there's + // another branch. If 'index' gets as high as the + // number of members in the scope, the call above + // to lookup_by_name_local will catch it and return 0. + return iter_lookup_by_name_local (d, + e, + index + 1); + } } } -/* - * Constructor(s) - */ -UTL_Scope::UTL_Scope() - : pd_scope_node_type(AST_Decl::NT_module), - pd_decls(NULL), - pd_decls_allocated(0), - pd_decls_used(0), - pd_local_types(NULL), - pd_locals_allocated(0), - pd_locals_used(0), - pd_referenced(NULL), - pd_referenced_allocated(0), - pd_referenced_used(0), - pd_name_referenced(NULL), - pd_name_referenced_allocated(0), - pd_name_referenced_used(0) -{ -} - -UTL_Scope::UTL_Scope(AST_Decl::NodeType nt) - : pd_scope_node_type(nt), - pd_decls(NULL), - pd_decls_allocated(0), - pd_decls_used(0), - pd_local_types(NULL), - pd_locals_allocated(0), - pd_locals_used(0), - pd_referenced(NULL), - pd_referenced_allocated(0), - pd_referenced_used(0), - pd_name_referenced(NULL), - pd_name_referenced_allocated(0), - pd_name_referenced_used(0) +// Constructors + +UTL_Scope::UTL_Scope (void) + : pd_scope_node_type (AST_Decl::NT_module), + pd_decls (0), + pd_decls_allocated (0), + pd_decls_used (0), + pd_local_types (0), + pd_locals_allocated (0), + pd_locals_used (0), + pd_referenced (0), + pd_referenced_allocated (0), + pd_referenced_used (0), + pd_name_referenced (0), + pd_name_referenced_allocated (0), + pd_name_referenced_used (0) { } -/* - * Private operations - */ +UTL_Scope::UTL_Scope (AST_Decl::NodeType nt) + : pd_scope_node_type (nt), + pd_decls (0), + pd_decls_allocated (0), + pd_decls_used (0), + pd_local_types (0), + pd_locals_allocated (0), + pd_locals_used (0), + pd_referenced (0), + pd_referenced_allocated (0), + pd_referenced_used (0), + pd_name_referenced (0), + pd_name_referenced_allocated (0), + pd_name_referenced_used (0) +{ +} -static -AST_Decl * add_type(AST_Type *type) +// Private operations + +static AST_Decl * +add_type (AST_Type *type) { - AST_Decl * result = 0; - UTL_Scope * scope = 0; + AST_Decl *result = 0; + UTL_Scope *scope = 0; - switch (type->node_type()) { + switch (type->node_type()) + { case AST_Decl::NT_array: result = - idl_global->root()->add_array(AST_Array::narrow_from_decl(type)); + idl_global->root ()->add_array (AST_Array::narrow_from_decl (type)); break; case AST_Decl::NT_enum: - result = type->defined_in()->add_enum(AST_Enum::narrow_from_decl(type)); - scope = AST_Enum::narrow_from_decl(type); + result = + type->defined_in ()->add_enum (AST_Enum::narrow_from_decl (type)); + scope = AST_Enum::narrow_from_decl (type); break; case AST_Decl::NT_sequence: result = - idl_global->root()->add_sequence(AST_Sequence::narrow_from_decl(type)); + idl_global->root ()->add_sequence ( + AST_Sequence::narrow_from_decl (type) + ); break; case AST_Decl::NT_string: case AST_Decl::NT_wstring: result = - idl_global->root()->add_string(AST_String::narrow_from_decl(type)); + idl_global->root ()->add_string (AST_String::narrow_from_decl (type)); break; case AST_Decl::NT_struct: result = - type->defined_in()-> - add_structure(AST_Structure::narrow_from_decl(type)); - scope = AST_Structure::narrow_from_decl(type); + type->defined_in ()->add_structure ( + AST_Structure::narrow_from_decl (type) + ); + scope = AST_Structure::narrow_from_decl (type); break; case AST_Decl::NT_union: result = - type->defined_in()->add_union(AST_Union::narrow_from_decl(type)); - scope = AST_Union::narrow_from_decl(type); + type->defined_in ()->add_union (AST_Union::narrow_from_decl (type)); + scope = AST_Union::narrow_from_decl (type); break; default: - // for non-complex types, like predefined types - // no additional add needed, assume everything is ok + // For non-complex types, like predefined types + // no additional add needed, assume everything is ok. result = (AST_Decl *) 1; break; - } - if (scope) - result = scope->call_add(); + } + + if (scope != 0) + { + result = scope->call_add (); + } + return result; } -/* - * Protected operations - */ +// Protected operations. -/* - * Special version of lookup which only looks at the local name instead of - * the fully scoped name, when doing lookups. This version is intended to - * be used only by the CFE add_xxx functions - */ +// Special version of lookup which only looks at the local name instead of +// the fully scoped name, when doing lookups. This version is intended to +// be used only by the CFE add_xxx functions. AST_Decl * -UTL_Scope::lookup_for_add(AST_Decl *d, idl_bool) +UTL_Scope::lookup_for_add (AST_Decl *d, + idl_bool) { - if (d == NULL) - return NULL; - return lookup_by_name_local(d->local_name(), 0); + if (d == 0) + { + return 0; + } + + return lookup_by_name_local (d->local_name (), + 0); } -/* - * Public operations - */ +// Public operations // Narrowing IMPL_NARROW_METHODS0(UTL_Scope) @@ -284,176 +321,317 @@ IMPL_NARROW_FROM_SCOPE(UTL_Scope) // and don't do a thing. These members are simply dummies to retain // compatibility with pre-two-pass compiler back-ends. -AST_PredefinedType *UTL_Scope::add_predefined_type(AST_PredefinedType *p) +AST_PredefinedType * +UTL_Scope::add_predefined_type (AST_PredefinedType *p) { - if (p == NULL) return NULL; - p->set_added(I_TRUE); + if (p == 0) + { + return 0; + } + + p->set_added (I_TRUE); return p; } -AST_Module *UTL_Scope::add_module(AST_Module *m) +AST_Module * +UTL_Scope::add_module (AST_Module *m) { - if (m == NULL) return NULL; - m->set_added(I_TRUE); + if (m == 0) + { + return 0; + } + + m->set_added (I_TRUE); return m; } -AST_Interface *UTL_Scope::add_interface(AST_Interface *i) +AST_Interface * +UTL_Scope::add_interface (AST_Interface *i) { - if (i == NULL) return NULL; - i->set_added(I_TRUE); + if (i == 0) + { + return 0; + } + + i->set_added (I_TRUE); return i; } -AST_InterfaceFwd *UTL_Scope::add_interface_fwd(AST_InterfaceFwd *i) +AST_InterfaceFwd * +UTL_Scope::add_interface_fwd (AST_InterfaceFwd *i) { - if (i == NULL) return NULL; - i->set_added(I_TRUE); + if (i == 0) + { + return 0; + } + + i->set_added (I_TRUE); return i; } -AST_Exception *UTL_Scope::add_exception(AST_Exception *e) +AST_Exception * +UTL_Scope::add_exception (AST_Exception *e) { - if (e == NULL) return NULL; - e->set_added(I_TRUE); + if (e == 0) + { + return 0; + } + + e->set_added (I_TRUE); return e; } -AST_Constant *UTL_Scope::add_constant(AST_Constant *c) +AST_Constant * +UTL_Scope::add_constant (AST_Constant *c) { - if (c == NULL) return NULL; - c->set_added(I_TRUE); + if (c == 0) + { + return 0; + } + + c->set_added (I_TRUE); return c; } -UTL_StrList *UTL_Scope::add_context(UTL_StrList *c) +UTL_StrList * +UTL_Scope::add_context (UTL_StrList *c) { return c; } -UTL_NameList *UTL_Scope::add_exceptions(UTL_NameList *e) +UTL_NameList * +UTL_Scope::add_exceptions (UTL_NameList *e) { return e; } -AST_Attribute *UTL_Scope::add_attribute(AST_Attribute *a) +AST_Attribute * +UTL_Scope::add_attribute (AST_Attribute *a) { - if (a == NULL) return NULL; - a->set_added(I_TRUE); - if (!a->field_type()->added()) { - return add_type(a->field_type()) ? a : 0 ; - } else - return a; + if (a == 0) + { + return NULL; + } + + a->set_added (I_TRUE); + + if (!a->field_type ()->added ()) + { + return add_type (a->field_type ()) ? a : 0; + } + else + { + return a; + } } -AST_Operation *UTL_Scope::add_operation(AST_Operation *o) +AST_Operation * +UTL_Scope::add_operation (AST_Operation *o) { - if (o == NULL) return NULL; - o->set_added(I_TRUE); - if (!o->return_type()->added()) { - return add_type(o->return_type()) ? o : 0 ; - } else - return o; + if (o == 0) + { + return 0; + } + + o->set_added (I_TRUE); + + if (!o->return_type ()->added ()) + { + return add_type (o->return_type ()) ? o : 0; + } + else + { + return o; + } } -AST_Argument *UTL_Scope::add_argument(AST_Argument *a) +AST_Argument * +UTL_Scope::add_argument (AST_Argument *a) { - if (a == NULL) return NULL; - a->set_added(I_TRUE); - if (!a->field_type()->added()) { - return add_type(a->field_type()) ? a : 0 ; - } else - return a; + if (a == 0) + { + return 0; + } + + a->set_added (I_TRUE); + + if (!a->field_type ()->added ()) + { + return add_type (a->field_type ()) ? a : 0; + } + else + { + return a; + } } -AST_Union *UTL_Scope::add_union(AST_Union *u) +AST_Union * +UTL_Scope::add_union (AST_Union *u) { - if (u == NULL) return NULL; - u->set_added(I_TRUE); + if (u == 0) + { + return 0; + } + + u->set_added (I_TRUE); return u; } -AST_UnionBranch *UTL_Scope::add_union_branch(AST_UnionBranch *u) +AST_UnionBranch * +UTL_Scope::add_union_branch (AST_UnionBranch *u) { - if (u == NULL) return NULL; - u->set_added(I_TRUE); - if (!u->field_type()->added()) { - return add_type(u->field_type()) ? u : 0 ; - } else - return u; + if (u == 0) + { + return 0; + } + + u->set_added (I_TRUE); + + if (!u->field_type ()->added ()) + { + return add_type (u->field_type ()) ? u : 0; + } + else + { + return u; + } } -AST_Structure *UTL_Scope::add_structure(AST_Structure *s) +AST_Structure * +UTL_Scope::add_structure (AST_Structure *s) { - if (s == NULL) return NULL; - s->set_added(I_TRUE); + if (s == 0) + { + return 0; + } + + s->set_added (I_TRUE); return s; } -AST_Field *UTL_Scope::add_field(AST_Field *f) +AST_Field * +UTL_Scope::add_field (AST_Field *f) { - if (f == NULL) return NULL; - f->set_added(I_TRUE); - if (!f->field_type()->added()) { - return add_type(f->field_type()) ? f : 0 ; - } else - return f; + if (f == 0) + { + return 0; + } + + f->set_added (I_TRUE); + + if (!f->field_type ()->added ()) + { + return add_type (f->field_type ()) ? f : 0; + } + else + { + return f; + } } -AST_Enum *UTL_Scope::add_enum(AST_Enum *e) +AST_Enum * +UTL_Scope::add_enum (AST_Enum *e) { - if (e == NULL) return NULL; - e->set_added(I_TRUE); + if (e == 0) + { + return 0; + } + + e->set_added (I_TRUE); return e; } -AST_EnumVal *UTL_Scope::add_enum_val(AST_EnumVal *e) +AST_EnumVal * +UTL_Scope::add_enum_val (AST_EnumVal *e) { - if (e == NULL) return NULL; - e->set_added(I_TRUE); + if (e == 0) + { + return 0; + } + + e->set_added (I_TRUE); return e; } -AST_Typedef *UTL_Scope::add_typedef(AST_Typedef *t) +AST_Typedef * +UTL_Scope::add_typedef (AST_Typedef *t) { - if (t == NULL) return NULL; - t->set_added(I_TRUE); - if (!t->base_type()->added()) { - return add_type(t->base_type()) ? t : 0 ; - } else - return t; + if (t == 0) + { + return 0; + } + + t->set_added (I_TRUE); + if (!t->base_type ()->added ()) + { + return add_type (t->base_type ()) ? t : 0; + } + else + { + return t; + } } -AST_Sequence *UTL_Scope::add_sequence(AST_Sequence *s) +AST_Sequence * +UTL_Scope::add_sequence (AST_Sequence *s) { - if (s == NULL) return NULL; - s->set_added(I_TRUE); - if (!s->base_type()->added()) { - return add_type(s->base_type()) ? s : 0 ; - } else - return s; + if (s == 0) + { + return 0; + } + + s->set_added (I_TRUE); + + if (!s->base_type ()->added ()) + { + return add_type (s->base_type ()) ? s : 0; + } + else + { + return s; + } } -AST_String *UTL_Scope::add_string(AST_String *s) +AST_String * +UTL_Scope::add_string (AST_String *s) { - if (s == NULL) return NULL; - s->set_added(I_TRUE); + if (s == 0) + { + return 0; + } + + s->set_added (I_TRUE); return s; } -AST_Array *UTL_Scope::add_array(AST_Array *a) +AST_Array * +UTL_Scope::add_array (AST_Array *a) { - if (a == NULL) return NULL; - a->set_added(I_TRUE); - if (!a->base_type()->added()) { - return add_type(a->base_type()) ? a : 0 ; - } else - return a; + if (a == 0) + { + return 0; + } + + a->set_added (I_TRUE); + + if (!a->base_type ()->added ()) + { + return add_type (a->base_type ()) ? a : 0; + } + else + { + return a; + } } -AST_Native *UTL_Scope::add_native (AST_Native *n) +AST_Native * +UTL_Scope::add_native (AST_Native *n) { - if (n == NULL) return NULL; + if (n == 0) + { + return 0; + } + n->set_added (I_TRUE); return n; } @@ -463,330 +641,383 @@ AST_Native *UTL_Scope::add_native (AST_Native *n) // All members of the protocol defined in UTL_Scope simply return NULL // and don't do a thing. This ensures that runtime errors will discover // operations which should have been redefined to allow certain kinds of -// AST nodes to appear in a given context +// AST nodes to appear in a given context. -AST_PredefinedType *UTL_Scope::fe_add_predefined_type(AST_PredefinedType *) +AST_PredefinedType * +UTL_Scope::fe_add_predefined_type (AST_PredefinedType *) { - return NULL; + return 0; } -AST_Module *UTL_Scope::fe_add_module(AST_Module *) +AST_Module * +UTL_Scope::fe_add_module (AST_Module *) { return NULL; } -AST_Interface *UTL_Scope::fe_add_interface(AST_Interface *) +AST_Interface * +UTL_Scope::fe_add_interface (AST_Interface *) { - return NULL; + return 0; } -AST_InterfaceFwd *UTL_Scope::fe_add_interface_fwd(AST_InterfaceFwd *) +AST_InterfaceFwd * +UTL_Scope::fe_add_interface_fwd (AST_InterfaceFwd *) { - return NULL; + return 0; } -AST_Exception *UTL_Scope::fe_add_exception(AST_Exception *) +AST_Exception * +UTL_Scope::fe_add_exception (AST_Exception *) { - return NULL; + return 0; } -AST_Constant *UTL_Scope::fe_add_constant(AST_Constant *) +AST_Constant * +UTL_Scope::fe_add_constant (AST_Constant *) { - return NULL; + return 0; } -UTL_StrList *UTL_Scope::fe_add_context(UTL_StrList *) +UTL_StrList * +UTL_Scope::fe_add_context (UTL_StrList *) { - return NULL; + return 0; } -UTL_NameList *UTL_Scope::fe_add_exceptions(UTL_NameList *) +UTL_NameList * +UTL_Scope::fe_add_exceptions (UTL_NameList *) { - return NULL; + return 0; } -AST_Attribute *UTL_Scope::fe_add_attribute(AST_Attribute *) +AST_Attribute * +UTL_Scope::fe_add_attribute (AST_Attribute *) { - return NULL; + return 0; } -AST_Operation *UTL_Scope::fe_add_operation(AST_Operation *) +AST_Operation * +UTL_Scope::fe_add_operation (AST_Operation *) { - return NULL; + return 0; } -AST_Argument *UTL_Scope::fe_add_argument(AST_Argument *) +AST_Argument * +UTL_Scope::fe_add_argument (AST_Argument *) { - return NULL; + return 0; } -AST_Union *UTL_Scope::fe_add_union(AST_Union *) +AST_Union * +UTL_Scope::fe_add_union (AST_Union *) { - return NULL; + return 0; } -AST_UnionBranch *UTL_Scope::fe_add_union_branch(AST_UnionBranch *) +AST_UnionBranch * +UTL_Scope::fe_add_union_branch (AST_UnionBranch *) { - return NULL; + return 0; } -AST_Structure *UTL_Scope::fe_add_structure(AST_Structure *) +AST_Structure * +UTL_Scope::fe_add_structure (AST_Structure *) { - return NULL; + return 0; } -AST_Field *UTL_Scope::fe_add_field(AST_Field *) +AST_Field * +UTL_Scope::fe_add_field (AST_Field *) { - return NULL; + return 0; } -AST_Enum *UTL_Scope::fe_add_enum(AST_Enum *) +AST_Enum * +UTL_Scope::fe_add_enum (AST_Enum *) { - return NULL; + return 0; } -AST_EnumVal *UTL_Scope::fe_add_enum_val(AST_EnumVal *) +AST_EnumVal * +UTL_Scope::fe_add_enum_val (AST_EnumVal *) { - return NULL; + return 0; } -AST_Typedef *UTL_Scope::fe_add_typedef(AST_Typedef *) +AST_Typedef * +UTL_Scope::fe_add_typedef (AST_Typedef *) { - return NULL; + return 0; } -AST_Sequence *UTL_Scope::fe_add_sequence(AST_Sequence *) +AST_Sequence * +UTL_Scope::fe_add_sequence (AST_Sequence *) { - return NULL; + return 0; } -AST_String *UTL_Scope::fe_add_string(AST_String *) +AST_String * +UTL_Scope::fe_add_string (AST_String *) { - return NULL; + return 0; } -AST_Array *UTL_Scope::fe_add_array(AST_Array *) +AST_Array * +UTL_Scope::fe_add_array (AST_Array *) { - return NULL; + return 0; } -AST_Native *UTL_Scope::fe_add_native (AST_Native *) +AST_Native * +UTL_Scope::fe_add_native (AST_Native *) { - return NULL; + return 0; } // This is the second pass of the front end // It calls the public add protocol on everything in scope. // It calls the add_xx functions of the most derived AST_Node. -AST_Decl *UTL_Scope::call_add() -{ - AST_Decl *result = NULL; - AST_Decl *decl; - - UTL_ScopeActiveIterator *i; - UTL_Scope *scope; - - i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_decls); - while(!(i->is_done())) { - decl = i->item(); - scope = 0; - switch (decl->node_type()) { - case AST_Decl::NT_argument: - result = add_argument(AST_Argument::narrow_from_decl(decl)); - break; - case AST_Decl::NT_array: - result = add_array(AST_Array::narrow_from_decl(decl)); - break; - case AST_Decl::NT_attr: - result = add_attribute(AST_Attribute::narrow_from_decl(decl)); - break; - case AST_Decl::NT_const: - result = add_constant(AST_Constant::narrow_from_decl(decl)); - break; - case AST_Decl::NT_enum: - scope = AST_Enum::narrow_from_decl(decl); - result = add_enum(AST_Enum::narrow_from_decl(decl)); - break; - case AST_Decl::NT_enum_val: - result = add_enum_val(AST_EnumVal::narrow_from_decl(decl)); - break; - case AST_Decl::NT_except: - scope = AST_Exception::narrow_from_decl(decl); - result = add_exception(AST_Exception::narrow_from_decl(decl)); - break; - case AST_Decl::NT_field: - result = add_field(AST_Field::narrow_from_decl(decl)); - break; - case AST_Decl::NT_interface: - scope = AST_Interface::narrow_from_decl(decl); - result = add_interface(AST_Interface::narrow_from_decl(decl)); - break; - case AST_Decl::NT_interface_fwd: - result = add_interface_fwd(AST_InterfaceFwd::narrow_from_decl(decl)); - break; - case AST_Decl::NT_module: - scope = AST_Module::narrow_from_decl(decl); - result = add_module(AST_Module::narrow_from_decl(decl)); - break; - case AST_Decl::NT_native: - result = add_native (AST_Native::narrow_from_decl(decl)); - break; - case AST_Decl::NT_op: - result = add_operation(AST_Operation::narrow_from_decl(decl)); - scope = AST_Operation::narrow_from_decl(decl); - break; - case AST_Decl::NT_pre_defined: - result = - add_predefined_type(AST_PredefinedType::narrow_from_decl(decl)); - break; - case AST_Decl::NT_sequence: - result = add_sequence(AST_Sequence::narrow_from_decl(decl)); - break; - case AST_Decl::NT_string: - case AST_Decl::NT_wstring: - result = add_string(AST_String::narrow_from_decl(decl)); - break; - case AST_Decl::NT_struct: - result = add_structure(AST_Structure::narrow_from_decl(decl)); - scope = AST_Structure::narrow_from_decl(decl); - break; - case AST_Decl::NT_typedef: - result = add_typedef(AST_Typedef::narrow_from_decl(decl)); - break; - case AST_Decl::NT_union: - result = add_union(AST_Union::narrow_from_decl(decl)); - scope = AST_Union::narrow_from_decl(decl); - break; - case AST_Decl::NT_union_branch: - result = add_union_branch(AST_UnionBranch::narrow_from_decl(decl)); - break; - default: - return NULL; - } - if (scope) - scope->call_add(); - i->next(); - } +AST_Decl * +UTL_Scope::call_add (void) +{ + AST_Decl *result = 0; + AST_Decl *decl = 0; + + UTL_ScopeActiveIterator *i = 0; + UTL_Scope *scope = 0; + + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + 0); + + while(!i->is_done()) + { + decl = i->item (); + scope = 0; + switch (decl->node_type()) + { + case AST_Decl::NT_argument: + result = add_argument (AST_Argument::narrow_from_decl (decl)); + break; + case AST_Decl::NT_array: + result = add_array (AST_Array::narrow_from_decl (decl)); + break; + case AST_Decl::NT_attr: + result = add_attribute (AST_Attribute::narrow_from_decl (decl)); + break; + case AST_Decl::NT_const: + result = add_constant (AST_Constant::narrow_from_decl (decl)); + break; + case AST_Decl::NT_enum: + scope = AST_Enum::narrow_from_decl (decl); + result = add_enum (AST_Enum::narrow_from_decl (decl)); + break; + case AST_Decl::NT_enum_val: + result = add_enum_val (AST_EnumVal::narrow_from_decl (decl)); + break; + case AST_Decl::NT_except: + scope = AST_Exception::narrow_from_decl (decl); + result = add_exception (AST_Exception::narrow_from_decl (decl)); + break; + case AST_Decl::NT_field: + result = add_field (AST_Field::narrow_from_decl (decl)); + break; + case AST_Decl::NT_interface: + scope = AST_Interface::narrow_from_decl (decl); + result = add_interface (AST_Interface::narrow_from_decl (decl)); + break; + case AST_Decl::NT_interface_fwd: + result = + add_interface_fwd (AST_InterfaceFwd::narrow_from_decl (decl)); + break; + case AST_Decl::NT_module: + scope = AST_Module::narrow_from_decl (decl); + result = add_module (AST_Module::narrow_from_decl (decl)); + break; + case AST_Decl::NT_native: + result = add_native (AST_Native::narrow_from_decl (decl)); + break; + case AST_Decl::NT_op: + result = add_operation (AST_Operation::narrow_from_decl (decl)); + scope = AST_Operation::narrow_from_decl (decl); + break; + case AST_Decl::NT_pre_defined: + result = + add_predefined_type (AST_PredefinedType::narrow_from_decl (decl)); + break; + case AST_Decl::NT_sequence: + result = add_sequence (AST_Sequence::narrow_from_decl (decl)); + break; + case AST_Decl::NT_string: + case AST_Decl::NT_wstring: + result = add_string (AST_String::narrow_from_decl (decl)); + break; + case AST_Decl::NT_struct: + result = add_structure (AST_Structure::narrow_from_decl (decl)); + scope = AST_Structure::narrow_from_decl (decl); + break; + case AST_Decl::NT_typedef: + result = add_typedef (AST_Typedef::narrow_from_decl (decl)); + break; + case AST_Decl::NT_union: + result = add_union (AST_Union::narrow_from_decl (decl)); + scope = AST_Union::narrow_from_decl (decl); + break; + case AST_Decl::NT_union_branch: + result = + add_union_branch (AST_UnionBranch::narrow_from_decl (decl)); + break; + default: + return 0; + } + + if (scope != 0) + { + scope->call_add (); + } + + i->next (); + } return result; } -// Private lookup mechanism +// Private lookup mechanism. -/* - * Lookup the node for a primitive (built in) type - */ +// Lookup the node for a primitive (built in) type AST_Decl * -UTL_Scope::lookup_primitive_type(AST_Expression::ExprType et) +UTL_Scope::lookup_primitive_type (AST_Expression::ExprType et) { - AST_Decl *as_decl; - UTL_Scope *ancestor; - AST_PredefinedType *t; - UTL_ScopeActiveIterator *i; + AST_Decl *as_decl = 0; + UTL_Scope *ancestor = 0; + AST_PredefinedType *t = 0; + UTL_ScopeActiveIterator *i = 0; AST_PredefinedType::PredefinedType pdt; - as_decl = ScopeAsDecl(this); - if (as_decl == NULL) - return NULL; - ancestor = as_decl->defined_in(); - if (ancestor != NULL) - return ancestor->lookup_primitive_type(et); - - switch (et) { - case AST_Expression::EV_short: - pdt = AST_PredefinedType::PT_short; - break; - case AST_Expression::EV_ushort: - pdt = AST_PredefinedType::PT_ushort; - break; - case AST_Expression::EV_long: - pdt = AST_PredefinedType::PT_long; - break; - case AST_Expression::EV_ulong: - pdt = AST_PredefinedType::PT_ulong; - break; - case AST_Expression::EV_longlong: - pdt = AST_PredefinedType::PT_longlong; - break; - case AST_Expression::EV_ulonglong: - pdt = AST_PredefinedType::PT_ulonglong; - break; - case AST_Expression::EV_float: - pdt = AST_PredefinedType::PT_float; - break; - case AST_Expression::EV_double: - pdt = AST_PredefinedType::PT_double; - break; - case AST_Expression::EV_longdouble: - pdt = AST_PredefinedType::PT_longdouble; - break; - case AST_Expression::EV_char: - pdt = AST_PredefinedType::PT_char; - break; - case AST_Expression::EV_wchar: - pdt = AST_PredefinedType::PT_wchar; - break; - case AST_Expression::EV_octet: - pdt = AST_PredefinedType::PT_octet; - break; - case AST_Expression::EV_bool: - pdt = AST_PredefinedType::PT_boolean; - break; - case AST_Expression::EV_any: - pdt = AST_PredefinedType::PT_any; - break; - case AST_Expression::EV_void: - pdt = AST_PredefinedType::PT_void; - break; - case AST_Expression::EV_string: - case AST_Expression::EV_wstring: - case AST_Expression::EV_none: - default: - return NULL; - } - i = new UTL_ScopeActiveIterator(this, UTL_Scope::IK_decls); - while (!(i->is_done())) { - as_decl = i->item(); - if (as_decl->node_type() == AST_Decl::NT_pre_defined) { - t = AST_PredefinedType::narrow_from_decl(as_decl); - if (t == NULL) { - i->next(); - continue; - } - if (t->pt() == pdt) { - delete i; - return t; - } - } - i->next(); - } + as_decl = ScopeAsDecl (this); + + if (as_decl == 0) + { + return 0; + } + ancestor = as_decl->defined_in (); + + if (ancestor != 0) + { + return ancestor->lookup_primitive_type (et); + } + + switch (et) + { + case AST_Expression::EV_short: + pdt = AST_PredefinedType::PT_short; + break; + case AST_Expression::EV_ushort: + pdt = AST_PredefinedType::PT_ushort; + break; + case AST_Expression::EV_long: + pdt = AST_PredefinedType::PT_long; + break; + case AST_Expression::EV_ulong: + pdt = AST_PredefinedType::PT_ulong; + break; + case AST_Expression::EV_longlong: + pdt = AST_PredefinedType::PT_longlong; + break; + case AST_Expression::EV_ulonglong: + pdt = AST_PredefinedType::PT_ulonglong; + break; + case AST_Expression::EV_float: + pdt = AST_PredefinedType::PT_float; + break; + case AST_Expression::EV_double: + pdt = AST_PredefinedType::PT_double; + break; + case AST_Expression::EV_longdouble: + pdt = AST_PredefinedType::PT_longdouble; + break; + case AST_Expression::EV_char: + pdt = AST_PredefinedType::PT_char; + break; + case AST_Expression::EV_wchar: + pdt = AST_PredefinedType::PT_wchar; + break; + case AST_Expression::EV_octet: + pdt = AST_PredefinedType::PT_octet; + break; + case AST_Expression::EV_bool: + pdt = AST_PredefinedType::PT_boolean; + break; + case AST_Expression::EV_any: + pdt = AST_PredefinedType::PT_any; + break; + case AST_Expression::EV_void: + pdt = AST_PredefinedType::PT_void; + break; + case AST_Expression::EV_string: + case AST_Expression::EV_wstring: + case AST_Expression::EV_none: + default: + return 0; + } + + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + 0); + + while (!i->is_done()) + { + as_decl = i->item (); + + if (as_decl->node_type () == AST_Decl::NT_pre_defined) + { + t = AST_PredefinedType::narrow_from_decl (as_decl); + + if (t == NULL) + { + i->next (); + continue; + } + + if (t->pt () == pdt) + { + delete i; + return t; + } + } + + i->next (); + } delete i; - return NULL; + return 0; } -// Look through inherited interfaces +// Look through inherited interfaces. AST_Decl * UTL_Scope::look_in_inherited (UTL_ScopedName *e, idl_bool treat_as_ref) { - AST_Decl *d = NULL; - AST_Decl *d_before = NULL; + AST_Decl *d = 0; + AST_Decl *d_before = 0; AST_Interface *i = AST_Interface::narrow_from_scope (this); AST_Interface **is; long nis; - // This scope is not an interface.. - if (i == NULL) + // This scope is not an interface. + if (i == 0) { - return NULL; + return 0; } - // Can't look in an interface which was not yet defined + // Can't look in an interface which was not yet defined. if (!i->is_defined ()) { idl_global->err ()->fwd_decl_lookup (i, e); - return NULL; + return 0; } //OK, loop through inherited interfaces. @@ -794,29 +1025,49 @@ UTL_Scope::look_in_inherited (UTL_ScopedName *e, // (Don't leave the inheritance hierarchy, no module or global ...) // Find all and report ambiguous results as error. - for (nis = i->n_inherits (), is = i->inherits (); nis > 0; nis--, is++) + for (nis = i->n_inherits (), is = i->inherits (); nis > 0; nis--, is++) { d = (*is)->lookup_by_name (e, treat_as_ref, 0 /* not in_parent */); - if (d != NULL) + if (d != 0) { - if (d_before == NULL) - { // first result found + if (d_before == 0) + { // First result found. d_before = d; } else - { // conflict against further results ? + { + // Conflict against further results? if (d != d_before) { - cerr << "warning in " << idl_global->filename ()->get_string () - << " line " << idl_global->lineno () << ": " ; - e->dump (cerr); - cerr << " is ambiguous in scope.\nFound "; - d->name ()->dump (cerr); - cerr << " and "; - d_before->name ()->dump (cerr); - cerr << ".\n"; + ACE_ERROR_RETURN (( + LM_ERROR, + "warning in %s line %d: ", + idl_global->filename ()->get_string (), + idl_global->lineno () + ), + 0 + ); + + e->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR_RETURN ((LM_ERROR, + " is ambiguous in scope.\n" + "Found "), + 0); + + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR_RETURN ((LM_ERROR, + " and "), + 0); + + d_before->name ()->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR_RETURN ((LM_ERROR, + ".\n"), + 0); } } } @@ -825,7 +1076,7 @@ UTL_Scope::look_in_inherited (UTL_ScopedName *e, return d_before; } -// Look up a String * in local scope only +// Look up a String * in local scope only. AST_Decl * UTL_Scope::lookup_by_name_local (Identifier *e, long index) @@ -842,22 +1093,31 @@ UTL_Scope::lookup_by_name_local (Identifier *e, if (equal) { - return NULL; + return 0; + } + + if (index == ACE_static_cast (long, this->nmembers ())) + { + return 0; } - UTL_ScopeActiveIterator *i = - new UTL_ScopeActiveIterator (this, - UTL_Scope::IK_both); - AST_Decl *d; + UTL_ScopeActiveIterator *i = 0; + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_both), + 0); + + AST_Decl *d = 0; + Identifier *item_name = 0; - // Iterate over this scope - while (!(i->is_done ())) + // Iterate over this scope. + while (!i->is_done ()) { d = i->item (); - Identifier *item_name = d->local_name (); + item_name = d->local_name (); - if (item_name == NULL) + if (item_name == 0) { i->next (); continue; @@ -913,63 +1173,61 @@ UTL_Scope::lookup_by_name_local (Identifier *e, } } -/* - * Implements lookup by name for scoped names - */ +// Implements lookup by name for scoped names AST_Decl * UTL_Scope::lookup_by_name (UTL_ScopedName *e, idl_bool treat_as_ref, idl_bool in_parent) { - AST_Decl *d; - UTL_Scope *t = NULL; + AST_Decl *d = 0; + UTL_Scope *t = 0; // Empty name? error - if (e == NULL) + if (e == 0) { - return NULL; + return 0; } - // If name starts with "::" or "" start lookup in global scope + // If name starts with "::" or "" start lookup in global scope. if (is_global_name (e->head ())) { - // Get parent scope + // Get parent scope. d = ScopeAsDecl (this); - if (d == NULL) + if (d == 0) { - return NULL; + return 0; } t = d->defined_in (); // If this is the global scope.. - if (t == NULL) + if (t == 0) { - // Look up tail of name starting here + // Look up tail of name starting here. d = lookup_by_name ((UTL_ScopedName *) e->tail (), treat_as_ref, in_parent); - // Now return whatever we have + // Now return whatever we have. return d; } - // OK, not global scope yet, so simply iterate with parent scope + // OK, not global scope yet, so simply iterate with parent scope. d = t->lookup_by_name (e, treat_as_ref, in_parent); // If treat_as_ref is true and d is not NULL, add d to - // set of nodes referenced here - if (treat_as_ref && d != NULL) + // set of nodes referenced here. + if (treat_as_ref && d != 0) { add_to_referenced (d, I_FALSE, 0); } - // Now return what we have + // Now return what we have. return d; } @@ -979,9 +1237,10 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, while (1) { - d = lookup_by_name_local (e->head (), index); + d = lookup_by_name_local (e->head (), + index); - if (d == NULL) + if (d == 0) { // Special case for scope which is an interface. We have to look @@ -993,19 +1252,19 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, treat_as_ref); } - if ((d == NULL) && in_parent) + if ((d == 0) && in_parent) { // OK, not found. Go down parent scope chain. d = ScopeAsDecl (this); - if (d != NULL) + if (d != 0) { t = d->defined_in (); - if (t == NULL) + if (t == 0) { - d = NULL; + d = 0; } else { @@ -1018,7 +1277,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, // If treat_as_ref is true and d is not NULL, add d to // set of nodes referenced here - if (treat_as_ref && d != NULL) + if (treat_as_ref && d != 0) { Identifier *id = 0; AST_Decl::NodeType nt = d->node_type (); @@ -1048,14 +1307,14 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, AST_Type *t = AST_Type::narrow_from_decl (d); // Are we a type, rather than an identifier? - if (t != NULL) + if (t != 0) { // Are we defined in this scope or just referenced? if (d->defined_in () == this) { UTL_Scope *s = ScopeAsDecl (this)->defined_in (); - if (s != NULL) + if (s != 0) { AST_Decl *parent = ScopeAsDecl (s); @@ -1081,14 +1340,16 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, // of subsequent elements of the name, if any. UTL_ScopedName *sn = (UTL_ScopedName *) e->tail (); - if (sn != NULL) - d = iter_lookup_by_name_local (d, - sn, - 0); + if (sn != 0) + { + d = iter_lookup_by_name_local (d, + sn, + 0); + } - // If treat_as_ref is true and d is not NULL, add d to + // If treat_as_ref is true and d is not 0, add d to // set of nodes referenced here - if (treat_as_ref && d != NULL) + if (treat_as_ref && d != 0) { add_to_referenced (d, I_FALSE, @@ -1096,91 +1357,107 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, } // All OK, name fully resolved - if (d != NULL) - return d; + if (d != 0) + { + return d; + } else - index++; + { + index++; + } } } -// Add a node to set of nodes referenced in this scope +// Add a node to set of nodes referenced in this scope. void UTL_Scope::add_to_referenced (AST_Decl *e, idl_bool recursive, Identifier *id, AST_Decl *ex) { - UTL_Scope *s; - AST_Decl **tmp; - AST_Interface *itf; - long oreferenced_allocated; - long i; + UTL_Scope *s = 0; + AST_Decl **tmp; + AST_Interface *itf = 0; + long oreferenced_allocated; + long i; - if (e == NULL) return; + if (e == 0) + { + return; + } // Special case for forward declared interfaces in the // scope in which they're defined. Cannot add before full - // definition is seen + // definition is seen. if (e->node_type() == AST_Decl::NT_interface) { itf = AST_Interface::narrow_from_decl(e); - if (itf != NULL && itf->defined_in() == this && !itf->is_defined()) + if (itf != 0 + && itf->defined_in () == this + && !itf->is_defined ()) { return; } } - // Only insert if it is not there already - if (referenced (e, id)) + + // Only insert if it is not there already. + if (this->referenced (e, id)) { return; } - // Make sure there's space for one more decl - if (pd_referenced_allocated == pd_referenced_used) + // Make sure there's space for one more decl. + if (this->pd_referenced_allocated == this->pd_referenced_used) { - oreferenced_allocated = pd_referenced_allocated; + oreferenced_allocated = this->pd_referenced_allocated; pd_referenced_allocated += INCREMENT; - tmp = new AST_Decl *[pd_referenced_allocated]; + + ACE_NEW (tmp, + AST_Decl *[this->pd_referenced_allocated]); for (i = 0; i < oreferenced_allocated; i++) { - tmp[i] = pd_referenced[i]; + tmp[i] = this->pd_referenced[i]; } - delete [] pd_referenced; + delete [] this->pd_referenced; - pd_referenced = tmp; + this->pd_referenced = tmp; } - // Insert new decl - pd_referenced[pd_referenced_used++] = e; + // Insert new decl. + this->pd_referenced[this->pd_referenced_used++] = e; - // Insert new reference + // Insert new reference. if (ex == 0) - pd_referenced[pd_referenced_used++] = e; - else if (referenced (ex)) { - for (i = pd_referenced_used; i > 0; i--) + this->pd_referenced[this->pd_referenced_used++] = e; + } + else if (this->referenced (ex)) + { + for (i = this->pd_referenced_used; i > 0; i--) { - pd_referenced[i] = pd_referenced[i-1]; - if (pd_referenced[i-1] == ex) + this->pd_referenced[i] = this->pd_referenced[i - 1]; + + if (this->pd_referenced[i-1] == ex) { - pd_referenced[i] = e; + this->pd_referenced[i] = e; break; } } - ++pd_referenced_used; + + ++this->pd_referenced_used; } // Now, if recursive is specified and "this" is not a common ancestor // of the referencing scope and the scope of definition of "e" then - // add "e" to the set of referenced nodes in the parent of "this" + // add "e" to the set of referenced nodes in the parent of "this". if (recursive && !(e->has_ancestor (ScopeAsDecl (this)))) { s = e->defined_in (); - if (s != NULL) + if (s != 0) { s->add_to_referenced (e, recursive, @@ -1191,25 +1468,27 @@ UTL_Scope::add_to_referenced (AST_Decl *e, // Add the identifier arg, if non-null, to the identifier list. if (id) { - if (pd_name_referenced_allocated == pd_name_referenced_used) + if (this->pd_name_referenced_allocated == this->pd_name_referenced_used) { - long name_referenced_allocated = pd_name_referenced_allocated; + long name_referenced_allocated = this->pd_name_referenced_allocated; pd_name_referenced_allocated += INCREMENT; - Identifier **name_tmp = - new Identifier *[pd_name_referenced_allocated]; + + Identifier **name_tmp = 0; + ACE_NEW (name_tmp, + Identifier *[this->pd_name_referenced_allocated]); for (i = 0; i < name_referenced_allocated; i++) { - name_tmp[i] = pd_name_referenced[i]; + name_tmp[i] = this->pd_name_referenced[i]; } - delete [] pd_name_referenced; + delete [] this->pd_name_referenced; - pd_name_referenced = name_tmp; + this->pd_name_referenced = name_tmp; } - // Insert new identifier - pd_name_referenced[pd_name_referenced_used++] = id; + // Insert new identifier. + this->pd_name_referenced[this->pd_name_referenced_used++] = id; } } @@ -1217,13 +1496,14 @@ void UTL_Scope::replace_referenced (AST_Decl *old_decl, AST_Decl *new_decl) { - int i; - for (i = 0; i < pd_referenced_used; i++) - if (pd_referenced[i] == old_decl) - { - pd_referenced[i] = new_decl; - break; - } + for (int i = 0; i < this->pd_referenced_used; i++) + { + if (this->pd_referenced[i] == old_decl) + { + this->pd_referenced[i] = new_decl; + break; + } + } } @@ -1232,26 +1512,30 @@ void UTL_Scope::replace_scope (AST_Decl *old_decl, AST_Decl *new_decl) { - int i; - for (i = 0; i < pd_decls_used; i++) - if (pd_decls[i] == old_decl) - { - pd_decls[i] = new_decl; - break; - } + for (int i = 0; i < pd_decls_used; i++) + { + if (this->pd_decls[i] == old_decl) + { + this->pd_decls[i] = new_decl; + break; + } + } } -// Add a node to set of nodes declared in this scope +// Add a node to set of nodes declared in this scope. void UTL_Scope::add_to_scope (AST_Decl *e, AST_Decl *ex) { - if (e == NULL) return; + if (e == 0) + { + return; + } AST_Decl **tmp = this->pd_referenced; - UTL_IdListActiveIterator *iter; + UTL_IdListActiveIterator *iter = 0; long i = this->pd_referenced_used; Identifier *decl_name = e->local_name (); @@ -1277,7 +1561,10 @@ UTL_Scope::add_to_scope (AST_Decl *e, // then only the top level of whatever scoped name // is used may clash with a local declaration. UTL_ScopedName *s = (*tmp)->name (); - iter = new UTL_IdListActiveIterator (s); + + ACE_NEW (iter, + UTL_IdListActiveIterator (s)); + ref_name = iter->item (); ref_string = ref_name->get_string (); @@ -1362,11 +1649,13 @@ UTL_Scope::add_to_scope (AST_Decl *e, } // Now make sure there's space for one more. - if (pd_decls_allocated == pd_decls_used) + if (this->pd_decls_allocated == this->pd_decls_used) { - long odecls_allocated = pd_decls_allocated; - pd_decls_allocated += INCREMENT; - tmp = new AST_Decl *[pd_decls_allocated]; + long odecls_allocated = this->pd_decls_allocated; + this->pd_decls_allocated += INCREMENT; + + ACE_NEW (tmp, + AST_Decl *[pd_decls_allocated]); for (i = 0; i < odecls_allocated; i++) { @@ -1379,52 +1668,60 @@ UTL_Scope::add_to_scope (AST_Decl *e, } - // Insert new decl + // Insert new decl. if (ex == 0) - pd_decls[pd_decls_used++] = e; + { + this->pd_decls[this->pd_decls_used++] = e; + } else { - for (i = pd_decls_used; i > 0; i--) + for (i = this->pd_decls_used; i > 0; i--) { - pd_decls[i] = pd_decls[i-1]; - if (pd_decls[i-1] == ex) + this->pd_decls[i] = this->pd_decls[i - 1]; + + if (this->pd_decls[i - 1] == ex) { - pd_decls[i] = e; + this->pd_decls[i] = e; break; } } - ++pd_decls_used; + ++this->pd_decls_used; } } -// Add a node to set of nodes representing manifest types defined in this scope +// Add a node to set of nodes representing manifest +// types defined in this scope. void -UTL_Scope::add_to_local_types(AST_Decl *e) +UTL_Scope::add_to_local_types (AST_Decl *e) { - AST_Decl **tmp; - long olocals_allocated; - long i; - - if (e == NULL) return; + if (e == 0) + { + return; + } - // Make sure there's space for one more - if (pd_locals_allocated == pd_locals_used) { + // Make sure there's space for one more. + if (this->pd_locals_allocated == this->pd_locals_used) + { + long olocals_allocated = pd_locals_allocated; + pd_locals_allocated += INCREMENT; - olocals_allocated = pd_locals_allocated; - pd_locals_allocated += INCREMENT; - tmp = new AST_Decl *[pd_locals_allocated]; + AST_Decl **tmp = 0; + ACE_NEW (tmp, + AST_Decl *[this->pd_locals_allocated]); - for (i = 0; i < olocals_allocated; i++) - tmp[i] = pd_local_types[i]; + for (long i = 0; i < olocals_allocated; i++) + { + tmp[i] = this->pd_local_types[i]; + } - delete [] pd_local_types; + delete [] this->pd_local_types; - pd_local_types = tmp; - } + this->pd_local_types = tmp; + } - // Insert new decl - pd_local_types[pd_locals_used++] = e; + // Insert new decl. + this->pd_local_types[this->pd_locals_used++] = e; } // Has this node been referenced here before? @@ -1439,17 +1736,24 @@ UTL_Scope::referenced (AST_Decl *e, for (; i > 0; i--, tmp++) { - if (*tmp == e) // Same node? - return I_TRUE; + // Same node? + if (*tmp == e) + { + return I_TRUE; + } + if ((*tmp)->node_type () == AST_Decl::NT_interface_fwd && e->node_type () == AST_Decl::NT_interface) { member = (*tmp)->local_name (); test = e->local_name (); + // If we're just defining a forward // declared interface, no need to go any further. if (member->compare (test) == I_TRUE) - return I_FALSE; + { + return I_FALSE; + } } } @@ -1503,7 +1807,8 @@ UTL_Scope::referenced (AST_Decl *e, } } - return I_FALSE; // Not found + // Not found + return I_FALSE; } // Redefinition of inherited virtual operations @@ -1512,22 +1817,29 @@ UTL_Scope::referenced (AST_Decl *e, void UTL_Scope::dump (ostream &o) { - UTL_ScopeActiveIterator *i; - AST_Decl *d; + UTL_ScopeActiveIterator *i = 0; + AST_Decl *d = 0; if (idl_global->indent () == 0) - idl_global->set_indent (new UTL_Indenter ()); + { + UTL_Indenter *idnt = 0; + ACE_NEW (idnt, + UTL_Indenter); + + idl_global->set_indent (idnt); + } idl_global->indent ()->increase (); if (pd_locals_used > 0) { - i = new UTL_ScopeActiveIterator (this, - UTL_Scope::IK_localtypes); + ACE_NEW (i, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_localtypes)); o << ("\n/* Locally defined types: */\n"); - while (!(i->is_done ())) + while (!i->is_done ()) { d = i->item (); @@ -1546,12 +1858,13 @@ UTL_Scope::dump (ostream &o) if (pd_decls_used > 0) { - i = new UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls); + ACE_NEW (i, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls)); o << ACE_TEXT ("\n/* Declarations: */\n"); - while (!(i->is_done ())) + while (!i->is_done ()) { d = i->item (); @@ -1573,9 +1886,9 @@ UTL_Scope::dump (ostream &o) // How many entries are defined? unsigned long -UTL_Scope::nmembers() +UTL_Scope::nmembers (void) { - return pd_decls_used; + return this->pd_decls_used; } void @@ -1585,77 +1898,95 @@ UTL_Scope::destroy (void) // UTL_SCOPE_ACTIVE_ITERATOR -// Constructor -UTL_ScopeActiveIterator::UTL_ScopeActiveIterator( - UTL_Scope *s, - UTL_Scope::ScopeIterationKind i) - : iter_source(s), - ik(i), - stage(i == UTL_Scope::IK_both - ? UTL_Scope::IK_decls - : i), - il(0) +// Constructor. +UTL_ScopeActiveIterator::UTL_ScopeActiveIterator ( + UTL_Scope *s, + UTL_Scope::ScopeIterationKind i + ) + : iter_source (s), + ik(i), + stage(i == UTL_Scope::IK_both ? UTL_Scope::IK_decls : i), + il(0) { } -// Public operations +// Public operations. -// Advance to next iterm +// Advance to next item. void -UTL_ScopeActiveIterator::next() +UTL_ScopeActiveIterator::next (void) { - il++; + this->il++; } -// Get current item -AST_Decl * -UTL_ScopeActiveIterator::item() +// Get current item. +AST_Decl * +UTL_ScopeActiveIterator::item (void) { - if (is_done()) - return NULL; + if (this->is_done ()) + { + return 0; + } + if (stage == UTL_Scope::IK_decls) - return iter_source->pd_decls[il]; + { + return this->iter_source->pd_decls[il]; + } + if (stage == UTL_Scope::IK_localtypes) - return iter_source->pd_local_types[il]; + { + return this->iter_source->pd_local_types[il]; + } - return NULL; + return 0; } // Is this iteration done? idl_bool -UTL_ScopeActiveIterator::is_done() +UTL_ScopeActiveIterator::is_done (void) { - long limit; + long limit = + (stage == UTL_Scope::IK_decls) + ? iter_source->pd_decls_used + : iter_source->pd_locals_used; + + for (;;) + { + // Last element? + if (this->il < limit) + { + return I_FALSE; + } - limit = (stage == UTL_Scope::IK_decls) - ? iter_source->pd_decls_used - : iter_source->pd_locals_used; + // Already done local types? + if (this->stage == UTL_Scope::IK_localtypes) + { + return I_TRUE; + } - for (;;) { - if (il < limit) // Last element? - return I_FALSE; - if (stage == UTL_Scope::IK_localtypes) // Already done local types? - return I_TRUE; - if (ik == UTL_Scope::IK_decls) // Only want decls? - return I_TRUE; + // Only want decls? + if (this->ik == UTL_Scope::IK_decls) + { + return I_TRUE; + } - // Switch to next stage - stage = UTL_Scope::IK_localtypes; - il = 0; - limit = iter_source->pd_locals_used; - } + // Switch to next stage. + this->stage = UTL_Scope::IK_localtypes; + this->il = 0; + limit = this->iter_source->pd_locals_used; + } } // What kind of iterator is this? UTL_Scope::ScopeIterationKind -UTL_ScopeActiveIterator::iteration_kind() +UTL_ScopeActiveIterator::iteration_kind (void) { - return ik; + return this->ik; } // And where are we in the iteration? UTL_Scope::ScopeIterationKind -UTL_ScopeActiveIterator::iteration_stage() +UTL_ScopeActiveIterator::iteration_stage (void) { - return stage; + return this->stage; } diff --git a/TAO/tests/IDL_Test/reopen_include1.idl b/TAO/tests/IDL_Test/reopen_include1.idl index b3b01440da0..a0770bcc4de 100644 --- a/TAO/tests/IDL_Test/reopen_include1.idl +++ b/TAO/tests/IDL_Test/reopen_include1.idl @@ -29,4 +29,17 @@ module frag typedef sequence<double> dub_seq; }; +// These are in each file in the reopened_modules chain, +// and in reopened_modules.idl, test interface parent lookup. +module A +{ + module B + { + interface X1 + { + string getX1 (); + }; + }; +}; + #endif /* IDL_TEST_REOPEN_INCLUDE1_IDL */ diff --git a/TAO/tests/IDL_Test/reopen_include2.idl b/TAO/tests/IDL_Test/reopen_include2.idl index 056481436af..141eecea088 100644 --- a/TAO/tests/IDL_Test/reopen_include2.idl +++ b/TAO/tests/IDL_Test/reopen_include2.idl @@ -45,4 +45,22 @@ module XX typedef long whah; }; +module A +{ + module B + { + }; +}; + +module A +{ + module B + { + interface X2 + { + string getX2 (); + }; + }; +}; + #endif /* IDL_TEST_REOPEN_INCLUDE2_IDL */ diff --git a/TAO/tests/IDL_Test/reopened_modules.idl b/TAO/tests/IDL_Test/reopened_modules.idl index aff703bd2b5..6eaa6fb9c04 100644 --- a/TAO/tests/IDL_Test/reopened_modules.idl +++ b/TAO/tests/IDL_Test/reopened_modules.idl @@ -26,28 +26,28 @@ // a chain of inclusions #include "reopen_include2.idl" -module A +module AA { - module B + module BB { interface x1 {}; }; }; -module A +module AA { - module B + module BB { - module C + module CC { interface x2 { // 'A::B::' should be implicit void op1 (in x1 obj); // 'A::' should be implicit - void op2 (in B::x1 obj); + void op2 (in BB::x1 obj); // Just for reference - void op3 (in A::B::x1 obj); + void op3 (in AA::BB::x1 obj); }; }; }; @@ -200,3 +200,14 @@ module foo }; }; +module A +{ + module B + { + interface X3 : X1, X2 + { + string getX3(); + }; + }; +}; + |