summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/CIAO/CIDLC/CIDLC.vcproj6
-rw-r--r--TAO/CIAO/CIDLC/DescriptorGenerator.cpp56
-rw-r--r--TAO/CIAO/CIDLC/Literals.hpp12
-rw-r--r--TAO/CIAO/CIDLC/RepositoryIdGenerator.cpp64
-rw-r--r--TAO/CIAO/CIDLC/RepositoryIdGenerator.hpp2
-rw-r--r--TAO/CIAO/CIDLC/cidlc.cpp23
-rw-r--r--TAO/CIAO/ChangeLog12
7 files changed, 126 insertions, 49 deletions
diff --git a/TAO/CIAO/CIDLC/CIDLC.vcproj b/TAO/CIAO/CIDLC/CIDLC.vcproj
index 1e926921abf..291b9be1b33 100644
--- a/TAO/CIAO/CIDLC/CIDLC.vcproj
+++ b/TAO/CIAO/CIDLC/CIDLC.vcproj
@@ -134,6 +134,9 @@
RelativePath=".\ExecutorMappingGenerator.cpp">
</File>
<File
+ RelativePath=".\RepositoryIdGenerator.cpp">
+ </File>
+ <File
RelativePath=".\ServantGenerator.cpp">
</File>
<File
@@ -160,6 +163,9 @@
RelativePath=".\Literals.hpp">
</File>
<File
+ RelativePath=".\RepositoryIdGenerator.hpp">
+ </File>
+ <File
RelativePath=".\ServantGenerator.hpp">
</File>
<File
diff --git a/TAO/CIAO/CIDLC/DescriptorGenerator.cpp b/TAO/CIAO/CIDLC/DescriptorGenerator.cpp
index 0bc925df5e4..dd3aca4bcad 100644
--- a/TAO/CIAO/CIDLC/DescriptorGenerator.cpp
+++ b/TAO/CIAO/CIDLC/DescriptorGenerator.cpp
@@ -1,6 +1,7 @@
// $Id$
#include "DescriptorGenerator.hpp"
+#include "Literals.hpp"
#include <ostream>
@@ -31,11 +32,62 @@ namespace
string
compute_repo_id (DeclarationPtr const& d)
{
- string middle =
+ if (d->context ().count (
+ StringLiterals::STRS[StringLiterals::REPO_ID]))
+ {
+ return
+ d->context ().get<string> (
+ StringLiterals::STRS[StringLiterals::REPO_ID]);
+ }
+
+ string prefix ("");
+ TypePrefixPtr tp;
+
+ if (d->context ().count (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]))
+ {
+ tp =
+ d->context ().get<TypePrefixPtr> (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]);
+
+ prefix = tp->prefix ().str ();
+ }
+ else
+ {
+ DeclarationPtr parent = d->scope ();
+
+ while (parent != 0)
+ {
+ if (parent->context ().count (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]))
+ {
+ tp =
+ parent->context ().get<TypePrefixPtr> (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]);
+
+ prefix = tp->prefix ().str ();
+ break;
+ }
+
+ if (parent->dynamic_type<CCF::IDL2::SyntaxTree::FileScope> () != 0)
+ break;
+ else parent = parent->scope ();
+ }
+ }
+
+ if (prefix != "") prefix += "/";
+
+ string scope_name =
regex::perl_s (name_to_string (d->name ().in_file_scope ()),
"%::%/%",
'%');
- return "IDL:" + middle + ":1.0";
+
+ string repo_id = "IDL:" + prefix + scope_name + ":1.0";
+
+ // Store the repo id for possible future reference.
+ d->context ().set<string> (StringLiterals::STRS[StringLiterals::REPO_ID],
+ repo_id);
+ return repo_id;
}
typedef
diff --git a/TAO/CIAO/CIDLC/Literals.hpp b/TAO/CIAO/CIDLC/Literals.hpp
index e66213907e4..df36b2340cc 100644
--- a/TAO/CIAO/CIDLC/Literals.hpp
+++ b/TAO/CIAO/CIDLC/Literals.hpp
@@ -57,7 +57,12 @@ namespace StringLiterals
"namespace CIAO_GLUE", // GLUE_NS
// Commonly used base class.
- "public virtual PortableServer::RefCountServantBase" // INH_RCSB
+ "public virtual PortableServer::RefCountServantBase", // INH_RCSB
+
+ // Labels for things stored in a SyntaxTree node's Context.
+ "CIDLC::RepositoryIdGenerator::TypeId", // TYPE_ID
+ "CIDLC::RepositoryIdGenerator::TypePrefix", // TYPE_PREFIX
+ "CIDLC::RepositoryIdGenerator::RepoId" // REPO_ID
};
// Index into the strings above.
@@ -87,6 +92,9 @@ namespace StringLiterals
COMP_NAMES,
COMP_ECB,
GLUE_NS,
- INH_RCSB
+ INH_RCSB,
+ TYPE_ID,
+ TYPE_PREFIX,
+ REPO_ID
};
}
diff --git a/TAO/CIAO/CIDLC/RepositoryIdGenerator.cpp b/TAO/CIAO/CIDLC/RepositoryIdGenerator.cpp
index 6b2bf88881e..c7409a67a3a 100644
--- a/TAO/CIAO/CIDLC/RepositoryIdGenerator.cpp
+++ b/TAO/CIAO/CIDLC/RepositoryIdGenerator.cpp
@@ -3,6 +3,7 @@
// cvs-id : $Id$
#include "RepositoryIdGenerator.hpp"
+#include "Literals.hpp"
#include "CCF/CompilerElements/Diagnostic.hpp"
@@ -19,9 +20,6 @@ namespace
char const* const
type_prefix_label = "CIDLC::RepositoryIdGenerator::TypePrefix";
-
- char const* const
- rep_id_label = "CIDLC::RepositoryIdGenerator::RepId";
}
namespace
@@ -32,27 +30,28 @@ namespace
class TypeIdLabelGenerator : public Traversal::TypeId
{
public:
- TypeIdLabelGenerator (Diagnostic::Stream dout)
+ TypeIdLabelGenerator (Diagnostic::Stream& dout)
: dout_ (dout)
{
}
virtual void
- traverse (TypeIdDeclPtr const& ti)
+ traverse (TypeIdPtr const& ti)
{
ScopedName decl_name (ti->declaration ());
DeclarationTable::IteratorPair iters (
- ti->scope ()->table ()->lookup (decl_name));
+ ti->scope ()->table ().lookup (decl_name));
for (; iters.first != iters.second; ++iters.first)
{
DeclarationPtr decl (*iters.first);
- if (decl->context ().count (type_id_label))
+ if (decl->context ().count (
+ StringLiterals::STRS[StringLiterals::TYPE_ID]))
{
- //@@ Seems ti should containt filename and line
- // of it's origin.
+ //@@ Seems it should contain filename and line
+ // of its origin.
//
Diagnostic::Error err ("???", 0);
@@ -70,7 +69,10 @@ namespace
}
else
{
- decl->context ().set (type_id_label, ti);
+ decl->context ().set (
+ StringLiterals::STRS[StringLiterals::TYPE_ID], ti);
+ decl->context ().set (
+ StringLiterals::STRS[StringLiterals::REPO_ID], ti->id ().str ());
}
}
}
@@ -86,29 +88,31 @@ namespace
class TypePrefixLabelGenerator : public Traversal::TypePrefix
{
public:
- TypePrefixLabelGenerator (Diagnostic::Stream dout)
+ TypePrefixLabelGenerator (Diagnostic::Stream& dout)
: dout_ (dout)
{
}
virtual void
- traverse (TypePrefixDeclPtr const& tp)
+ traverse (TypePrefixPtr const& tp)
{
ScopedName decl_name (tp->declaration ());
DeclarationTable::IteratorPair iters (
- tp->scope ()->table ()->lookup (decl_name));
+ tp->scope ()->table ().lookup (decl_name));
for (; iters.first != iters.second; ++iters.first)
{
DeclarationPtr decl (*iters.first);
- if (decl->context ().count (type_prefix_label))
+ if (decl->context ().count (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]))
{
- TypePrefixDeclPtr prev (
- decl->context ().get<TypePrefixDeclPtr> (type_prefix_label));
+ TypePrefixPtr prev (
+ decl->context ().get<TypePrefixPtr> (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX]));
- if (prev->prefix != tp->prefix ())
+ if (prev->prefix () != tp->prefix ())
{
//@@ Seems tp should containt filename and line
@@ -131,7 +135,8 @@ namespace
}
else
{
- decl->context ().set (type_prefix_label, tp);
+ decl->context ().set (
+ StringLiterals::STRS[StringLiterals::TYPE_PREFIX], tp);
}
}
}
@@ -145,8 +150,6 @@ namespace
bool RepositoryIdGenerator::
generate (TranslationUnitPtr const& u)
{
- // Phase One: generate labels
- //
{
Diagnostic::Stream dout;
@@ -154,8 +157,8 @@ generate (TranslationUnitPtr const& u)
TypePrefixLabelGenerator type_prefix (dout);
Traversal::Scope scope;
- module.add_scope_delegate (&type_id);
- module.add_scope_delegate (&type_prefix);
+ scope.add_scope_delegate (&type_id);
+ scope.add_scope_delegate (&type_prefix);
Traversal::TranslationRegion region (&scope);
@@ -164,21 +167,10 @@ generate (TranslationUnitPtr const& u)
unit.dispatch (u);
+ if (dout.error_count () != 0) return false;
+
//@@ check errors
}
-
-
- // Phase Two: generate repository id's (@@ that's for you, Jeff ;-)
- //
-
- // A few notes:
- //
- // (1) There is no need to generate repid's for declarations outside
- // PrincipalTranslationUnit (i.e. for declarations that were
- // #includ'ed) since we normally don't generate any code for them.
- //
- //
-
-
+
return true;
}
diff --git a/TAO/CIAO/CIDLC/RepositoryIdGenerator.hpp b/TAO/CIAO/CIDLC/RepositoryIdGenerator.hpp
index d566cc88c1c..811f5919bc8 100644
--- a/TAO/CIAO/CIDLC/RepositoryIdGenerator.hpp
+++ b/TAO/CIAO/CIDLC/RepositoryIdGenerator.hpp
@@ -14,7 +14,7 @@
class RepositoryIdGenerator
{
public:
- void
+ bool
generate (CCF::CIDL::SyntaxTree::TranslationUnitPtr const&);
};
diff --git a/TAO/CIAO/CIDLC/cidlc.cpp b/TAO/CIAO/CIDLC/cidlc.cpp
index f7d3ff3b1b4..d98ab29a988 100644
--- a/TAO/CIAO/CIDLC/cidlc.cpp
+++ b/TAO/CIAO/CIDLC/cidlc.cpp
@@ -16,6 +16,7 @@
#include "ExecutorMappingGenerator.hpp"
#include "ServantGenerator.hpp"
+#include "RepositoryIdGenerator.hpp"
#include "DescriptorGenerator.hpp"
#include <iostream>
@@ -46,9 +47,9 @@ int main (int argc, char* argv[])
ExecutorMappingGenerator lem_gen;
ServantGenerator svnt_gen (cl);
+ RepositoryIdGenerator repid_gen;
DescriptorGenerator desc_gen;
-
if (cl.get_value ("help", false) || cl.get_value ("help-html", false))
{
CL::Description d (argv[0]);
@@ -117,9 +118,9 @@ int main (int argc, char* argv[])
// get after eof.
ifs.exceptions (ios_base::iostate (0));
- std::istream& is = ifs.is_open ()
- ? static_cast<std::istream&> (ifs)
- : static_cast<std::istream&> (std::cin);
+ std::istream& is =
+ ifs.is_open () ? static_cast<std::istream&> (ifs)
+ : static_cast<std::istream&> (std::cin);
InputStreamAdapter isa (is);
Preprocessor pp (isa);
@@ -136,6 +137,7 @@ int main (int argc, char* argv[])
std::cout << c ;
}
+
return 0;
}
@@ -247,17 +249,22 @@ int main (int argc, char* argv[])
if (diagnostic_stream.error_count () != 0) return -1;
- // Generate executor mapping
+ // Generate executor mapping.
{
lem_gen.generate (cl, unit);
}
- // Generate servant code
+ // Generate servant code.
{
svnt_gen.generate (unit);
}
+
+ // Compute repository IDs in a separate pass.
+ {
+ repid_gen.generate (unit);
+ }
- // Generate descriptor code
+ // Generate descriptor code.
{
desc_gen.generate (cl, unit);
}
@@ -268,6 +275,6 @@ int main (int argc, char* argv[])
}
catch (...)
{
- cerr << "exception: " << "unknow" << endl;
+ cerr << "exception: " << "unknown" << endl;
}
}
diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog
index 0cd79f0a47a..fcdf50e70d3 100644
--- a/TAO/CIAO/ChangeLog
+++ b/TAO/CIAO/ChangeLog
@@ -1,3 +1,15 @@
+Fri Oct 10 18:39:18 2003 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * CIDLC/CIDLC.vcproj:
+ * CIDLC/DescriptorGenerator.cpp:
+ * CIDLC/Literals.hpp:
+ * CIDLC/RepositoryIdGenerator.cpp:
+ * CIDLC/RepositoryIdGenerator.hpp:
+ * CIDLC/cidlc.cpp:
+
+ Added backend support for typeid and typeprefix, used in
+ computing the repository id string.
+
Fri Oct 10 15:54:00 2003 Boris Kolpackov <boris@dre.vanderbilt.edu>
* CCF/CCF/IDL2/LexicalAnalyzer.hpp: