diff options
-rw-r--r-- | TAO/ChangeLog | 18 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_decl.cpp | 6 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_interface.cpp | 1 | ||||
-rw-r--r-- | TAO/TAO_IDL/fe/idl.ll | 19 | ||||
-rw-r--r-- | TAO/TAO_IDL/fe/lex.yy.cpp | 20 | ||||
-rw-r--r-- | TAO/TAO_IDL/include/idl_global.h | 7 | ||||
-rw-r--r-- | TAO/TAO_IDL/util/utl_global.cpp | 30 |
7 files changed, 88 insertions, 13 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 5d5634c098f..8901fe4f6ce 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,21 @@ +Tue Jan 6 20:43:53 2004 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/ast/ast_decl.cpp: + * TAO_IDL/ast/ast_interface.cpp: + * TAO_IDL/fe/idl.ll: + * TAO_IDL/fe/lex.yy.cpp: + * TAO_IDL/include/idl_global.h: + * TAO_IDL/util/utl_global.cpp: + + Added hash table to match #pragma prefix directives with + file names. This table is used to manage the prefix associated + with the root scope. Using preprocessor file directives, as + was done previously, is not sufficient. This change enables + the calculation of the repository id, which contains the prefix, + to be done sooner, at AST node creation time, since the root + prefix is updated with each file change and with each prefix + directive. This fix closes [BUGID:1687]. + Tue Jan 6 16:36:27 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu> * tests/Two_Objects/run_test.pl: diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index 2b31782eb3d..e0d6d1792f5 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -437,8 +437,9 @@ AST_Decl::compute_repoID (void) long first = I_TRUE; long second = I_FALSE; char *name = 0; - const char *prefix = this->prefix_; + const char *prefix = (this->prefix_ ? this->prefix_ : ""); UTL_Scope *scope = this->defined_in (); + const char *parent_prefix = 0; // If our prefix is empty, we check to see if an ancestor has one. while (ACE_OS::strcmp (prefix, "") == 0 && scope != 0) @@ -451,7 +452,8 @@ AST_Decl::compute_repoID (void) break; } - prefix = parent->prefix (); + parent_prefix = parent->prefix (); + prefix = (parent_prefix ? parent_prefix : ""); scope = parent->defined_in (); } diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index 1c1c3b02c52..4dbe2afb6e4 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -133,6 +133,7 @@ AST_Interface::AST_Interface (UTL_ScopedName *n, { this->size_type (AST_Type::VARIABLE); // always the case this->has_constructor (I_TRUE); // always the case + this->compute_repoID (); } AST_Interface::~AST_Interface (void) diff --git a/TAO/TAO_IDL/fe/idl.ll b/TAO/TAO_IDL/fe/idl.ll index 7e6c7b79e3c..5251193a711 100644 --- a/TAO/TAO_IDL/fe/idl.ll +++ b/TAO/TAO_IDL/fe/idl.ll @@ -573,14 +573,29 @@ idl_store_pragma (char *buf) delete [] trash; } + UTL_Scope *top_scope = idl_global->scopes ().top (); + if (depth > 1) { - UTL_Scope *top_scope = idl_global->scopes ().top (); - top_scope->has_prefix (1); + top_scope->has_prefix (I_TRUE); ScopeAsDecl (top_scope)->prefix_scope (top_scope); } idl_global->pragma_prefixes ().push (new_prefix); + + if (idl_global->in_main_file ()) + { + idl_global->root ()->prefix (new_prefix); + idl_global->root ()->set_imported (I_FALSE); + top_scope->has_prefix (I_TRUE); + } + + ACE_CString ext_id; + ext_id.set (idl_global->filename ()->get_string (), + 0); + char *int_id = ACE::strnew (new_prefix); + (void) idl_global->file_prefixes ().rebind (ext_id, + int_id); } } else if (ACE_OS::strncmp (buf + 8, "version", 7) == 0) diff --git a/TAO/TAO_IDL/fe/lex.yy.cpp b/TAO/TAO_IDL/fe/lex.yy.cpp index 96eb07408ce..f3fdd8b0fb2 100644 --- a/TAO/TAO_IDL/fe/lex.yy.cpp +++ b/TAO/TAO_IDL/fe/lex.yy.cpp @@ -869,6 +869,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_expression.h" #include "ast_argument.h" #include "ast_operation.h" +#include "ast_root.h" #include "fe_interface_header.h" #include "global_extern.h" #include "fe_private.h" @@ -2766,14 +2767,29 @@ idl_store_pragma (char *buf) delete [] trash; } + UTL_Scope *top_scope = idl_global->scopes ().top (); + if (depth > 1) { - UTL_Scope *top_scope = idl_global->scopes ().top (); - top_scope->has_prefix (1); + top_scope->has_prefix (I_TRUE); ScopeAsDecl (top_scope)->prefix_scope (top_scope); } idl_global->pragma_prefixes ().push (new_prefix); + + if (idl_global->in_main_file ()) + { + idl_global->root ()->prefix (new_prefix); + idl_global->root ()->set_imported (I_FALSE); + top_scope->has_prefix (I_TRUE); + } + + ACE_CString ext_id; + ext_id.set (idl_global->filename ()->get_string (), + 0); + char *int_id = ACE::strnew (new_prefix); + (void) idl_global->file_prefixes ().rebind (ext_id, + int_id); } } else if (ACE_OS::strncmp (buf + 8, "version", 7) == 0) diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h index 423714ecfba..93b81fdde1f 100644 --- a/TAO/TAO_IDL/include/idl_global.h +++ b/TAO/TAO_IDL/include/idl_global.h @@ -518,6 +518,10 @@ public: void add_include_path (const char *s); // Add another path to 'include_paths_'. + ACE_Hash_Map_Manager<ACE_CString, char *, ACE_Null_Mutex> & + file_prefixes (void); + // Accessor for the IDL keyword container. + private: // Data UTL_ScopeStack pd_scopes; // Store scopes stack @@ -596,6 +600,9 @@ private: ACE_Unbounded_Queue<char *> include_paths_; // List of -I options passed to us. + + ACE_Hash_Map_Manager<ACE_CString, char *, ACE_Null_Mutex> file_prefixes_; + // Associates a prefix with a file. }; diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 60306808591..226f34aa435 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -1134,6 +1134,22 @@ IDL_GlobalData::update_prefix (char *filename) ACE_CString tmp ("", 0, 0); char *main_filename = this->pd_main_filename->get_string (); + ACE_CString ext_id (filename); + char *prefix = 0; + + int status = this->file_prefixes_.find (ext_id, prefix); + + if (status == 0) + { + this->pd_root->prefix (prefix); + } + else + { + prefix = ACE::strnew (""); + (void) this->file_prefixes_.bind (ext_id, prefix); + this->pd_root->prefix (""); + } + // The first branch is executed if we are finishing an // included IDL file (but the current filename has not yet // been changed). So we check for (1) the current filename is @@ -1154,17 +1170,10 @@ IDL_GlobalData::update_prefix (char *filename) this->pragma_prefixes_.pop (trash); delete [] trash; } - else - { - char *current = 0; - this->pragma_prefixes_.top (current); - this->pd_root->prefix (current); - } } else { this->pragma_prefixes_.push (tmp.rep ()); - this->pd_root->prefix ((char *) tmp.fast_rep ()); } } @@ -1302,3 +1311,10 @@ IDL_GlobalData::add_include_path (const char *s) { this->include_paths_.enqueue_tail (ACE::strnew (s)); } + +ACE_Hash_Map_Manager<ACE_CString, char *, ACE_Null_Mutex> & +IDL_GlobalData::file_prefixes (void) +{ + return this->file_prefixes_; +} + |