diff options
Diffstat (limited to 'CIAO/CCF/CCF')
291 files changed, 37168 insertions, 0 deletions
diff --git a/CIAO/CCF/CCF/CIDL/CIDL.mpc b/CIAO/CCF/CCF/CIDL/CIDL.mpc new file mode 100644 index 00000000000..833f3979582 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/CIDL.mpc @@ -0,0 +1,15 @@ +//$Id$ + +project(CIDL): cidlc { + sharedname = + staticname = CIDL + libout = .. + + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction + ./SemanticAction/Impl + } +} diff --git a/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp b/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..6bc50409d28 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp @@ -0,0 +1,27 @@ +// file : CCF/CIDL/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace CIDL + { + LexicalAnalyzer:: + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is) + : IDL2::LexicalAnalyzer (is), + IDL3::LexicalAnalyzer (is) + { + // Keywords (alphabetic order). + + keyword_table_.insert ("composition"); + keyword_table_.insert ("entity" ); + keyword_table_.insert ("executor" ); + keyword_table_.insert ("implements" ); + keyword_table_.insert ("process" ); + keyword_table_.insert ("service" ); + keyword_table_.insert ("session" ); + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp b/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..978c06b8bef --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp @@ -0,0 +1,22 @@ +// file : CCF/CIDL/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_LEXICAL_ANALYZER_HPP +#define CCF_CIDL_LEXICAL_ANALYZER_HPP + +#include "CCF/IDL3/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace CIDL + { + class LexicalAnalyzer : public virtual IDL3::LexicalAnalyzer + { + public: + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is); + }; + } +} + +#endif // CCF_CIDL_LEXICAL_ANALYZER_HPP diff --git a/CIAO/CCF/CCF/CIDL/Parser.cpp b/CIAO/CCF/CCF/CIDL/Parser.cpp new file mode 100644 index 00000000000..790410f3921 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Parser.cpp @@ -0,0 +1,242 @@ +// file : CCF/CIDL/Parser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/Parser.hpp" + +// +// Note: DO NOT run emacs indenter (or any other indentation tool) over +// this file because it will most likely break BNF indentation. +// + +namespace CCF +{ + namespace CIDL + { + using IDL2::Parsing::DiagnosticType; + using IDL2::Parsing::RecoveryMethod; + + Parser:: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f) + : IDL2::Parser (context, dout, l, f), + IDL3::Parser (context, dout, l, f), + lexer_ (l), + actions_ (f), + + COMPOSITION ("composition"), + ENTITY ("entity" ), + EXECUTOR ("executor" ), + IMPLEMENTS ("implements" ), + PROCESS ("process" ), + SERVICE ("service" ), + SESSION ("session" ), + + // Composition + // + act_composition_begin ( + this, &Parser::act_composition_begin_core), + + act_composition_open_scope ( + f.composition (), &SemanticAction::Scope::open_scope), + + act_composition_close_scope ( + f.composition (), &SemanticAction::Scope::close_scope), + + act_composition_end ( + f.composition (), &SemanticAction::Composition::end), + + + // Home Executor + // + act_home_executor_begin ( + f.home_executor (), &SemanticAction::HomeExecutor::begin), + + act_home_executor_implements ( + f.home_executor (), &SemanticAction::HomeExecutor::implements), + + act_home_executor_manages ( + f.home_executor (), &SemanticAction::HomeExecutor::manages), + + act_home_executor_end ( + f.home_executor (), &SemanticAction::HomeExecutor::end) + + { + IDL3::Parser::extension = + composition_decl + | extension + ; + + // + // Composition + // + composition_decl = + COMPOSITION + >> guard + ( + ( + assertion ("composition category expected", + DiagnosticType::BEFORE) + ( + composition_category + ) + >> assertion ("composition name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_composition_begin] + + >> assertion ("'{' expected", + f.composition (), + &SemanticAction::Composition::end) + ( + LCBRACE[act_composition_open_scope] + ) + + >> assertion ("home executor declaration expected", + f.composition (), + &SemanticAction::Composition::close_scope, + &SemanticAction::Composition::end, + DiagnosticType::BEFORE) + ( + hood (home_executor_decl) + [ + handler (f.composition (), + &SemanticAction::Composition::close_scope, + &SemanticAction::Composition::end) + ] + ) + + >> assertion ("'}' expected", + f.composition (), + &SemanticAction::Composition::close_scope, + &SemanticAction::Composition::end, + DiagnosticType::BEFORE) + ( + RCBRACE[act_composition_close_scope] + ) + + >> assertion ("';' expected", + f.composition (), + &SemanticAction::Composition::end, + RecoveryMethod::NONE) + ( + SEMI[act_composition_end] + ) + + )[error_handler] + ; + + composition_category = + ENTITY + | PROCESS + | SERVICE + | SESSION + ; + + + // + // Home executor + // + home_executor_decl = + HOME + >> EXECUTOR + >> guard + ( + assertion ("home executor name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_home_executor_begin] + ) + + >> assertion ("'{' expected", + f.home_executor (), + &SemanticAction::HomeExecutor::end) + ( + LCBRACE + ) + + >> assertion ("implements declaration expected", + f.home_executor (), + &SemanticAction::HomeExecutor::end, + DiagnosticType::BEFORE) + ( + hood (home_executor_home_impl_decl) + [ + handler (f.home_executor (), + &SemanticAction::HomeExecutor::end) + ] + ) + + >> assertion ("manages declaration expected", + f.home_executor (), + &SemanticAction::HomeExecutor::end, + DiagnosticType::BEFORE) + ( + hood (home_executor_executor_decl) + [ + handler (f.home_executor (), + &SemanticAction::HomeExecutor::end) + ] + ) + + >> assertion ("'}' expected", + f.home_executor (), + &SemanticAction::HomeExecutor::end, + DiagnosticType::BEFORE) + ( + RCBRACE + ) + + >> assertion ("';' expected", + f.home_executor (), + &SemanticAction::HomeExecutor::end, + RecoveryMethod::NONE) + ( + SEMI[act_home_executor_end] + ) + + )[error_handler] + ; + + + home_executor_home_impl_decl = + IMPLEMENTS + >> guard + ( + assertion ("home name expected", + DiagnosticType::BEFORE) + ( + identifier[act_home_executor_implements] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + + home_executor_executor_decl = + MANAGES + >> guard + ( + assertion ("executor name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_home_executor_manages] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/Parser.hpp b/CIAO/CCF/CCF/CIDL/Parser.hpp new file mode 100644 index 00000000000..719f97f184d --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Parser.hpp @@ -0,0 +1,123 @@ +// file : CCF/CIDL/Parser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_PARSER_HPP +#define CCF_CIDL_PARSER_HPP + +#include "CCF/CompilerElements/Context.hpp" + +#include "CCF/IDL3/Parser.hpp" + +#include "CCF/CIDL/LexicalAnalyzer.hpp" +#include "CCF/CIDL/SemanticAction.hpp" + +namespace CCF +{ + namespace CIDL + { + using IDL3::ActionExecutor; + using IDL3::NoArgAction; + using IDL3::OneArgAction; + using IDL3::TwoArgAction; + + class Parser : public virtual IDL3::Parser + { + protected: + LexicalAnalyzer const& lexer_; + SemanticAction::Factory& actions_; + + // + // Primitives (alphabetic order). + // + + KeywordParser COMPOSITION; + KeywordParser ENTITY; + KeywordParser EXECUTOR; + KeywordParser IMPLEMENTS; + KeywordParser PROCESS; + KeywordParser SERVICE; + KeywordParser SESSION; + + // + // Language + // + + Rule extension; + + // Composition + Rule composition_decl; + Rule composition_category; + + // Home executor + Rule home_executor_decl; + Rule home_executor_home_impl_decl; + Rule home_executor_executor_decl; + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + protected: + void + act_composition_begin_core (Iterator begin, Iterator) const + { + SemanticAction::Composition::Category::Value c; + + if((*begin)->lexeme () == "entity") + { + c = SemanticAction::Composition::Category::entity; + } + else if ((*begin)->lexeme () == "process") + { + c = SemanticAction::Composition::Category::process; + } + else if ((*begin)->lexeme () == "service") + { + c = SemanticAction::Composition::Category::service; + } + else + { + c = SemanticAction::Composition::Category::session; + } + + begin++; + + actions_.composition ().begin ( + ReferenceCounting::strict_cast<SimpleIdentifier> (*begin), c); + } + + // Composition + // + ActionExecutor<Parser> + act_composition_begin; + + ScopeAction + act_composition_open_scope; + + ScopeAction + act_composition_close_scope; + + NoArgAction<SemanticAction::Composition> + act_composition_end; + + // Home Executor + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_begin; + + OneArgAction<IdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_implements; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_manages; + + NoArgAction<SemanticAction::HomeExecutor> + act_home_executor_end; + }; + } +} + +#endif // CCF_CIDL_PARSER_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction.hpp new file mode 100644 index 00000000000..faf75dbc28a --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction.hpp @@ -0,0 +1,17 @@ +// file : CCF/CIDL/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_HPP + +#include "CCF/IDL3/SemanticAction.hpp" + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" + +#include "CCF/CIDL/SemanticAction/Factory.hpp" + +#endif // CCF_CIDL_SEMANTIC_ACTION_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp new file mode 100644 index 00000000000..e8eb6f99924 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp @@ -0,0 +1,29 @@ +// file : CCF/CIDL/SemanticAction/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticAction/Composition.hpp" + +#include <ostream> + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + } + } +} + +namespace +{ + char* labels[] = {"entity", "process", "service", "session" }; +} + +std::ostream& +operator<< (std::ostream& o, + CCF::CIDL::SemanticAction::Composition::Category::Value v) +{ + return o << labels[v]; +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp new file mode 100644 index 00000000000..8c46b83326c --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp @@ -0,0 +1,48 @@ +// file : CCF/CIDL/SemanticAction/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +#include <iosfwd> + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + struct Composition : Scope + { + struct Category + { + enum Value + { + entity , process, service, session + }; + }; + + virtual void + begin (SimpleIdentifierPtr const& id, Category::Value category) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +std::ostream& +operator<< (std::ostream& o, + CCF::CIDL::SemanticAction::Composition::Category::Value v); + +#endif // CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..83c80bdf56b --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp @@ -0,0 +1,23 @@ +// file : CCF/CIDL/SemanticAction/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +#include "CCF/CIDL/Token.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + using IDL3::SemanticAction::Scope; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..521602ac70f --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp @@ -0,0 +1,31 @@ +// file : CCF/CIDL/SemanticAction/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP +#define CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + struct Composition; + struct HomeExecutor; + + struct Factory : virtual IDL3::SemanticAction::Factory + { + virtual Composition& + composition () = 0; + + virtual HomeExecutor& + home_executor () = 0; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp new file mode 100644 index 00000000000..ca32411c320 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp @@ -0,0 +1,38 @@ +// file : CCF/CIDL/SemanticAction/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + struct HomeExecutor + { + virtual ~HomeExecutor () + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + implements (IdentifierPtr const& id) = 0; + + virtual void + manages (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp new file mode 100644 index 00000000000..a39a801cd15 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp @@ -0,0 +1,83 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticAction/Impl/Composition.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Composition:: + Composition (Context& c) + : ScopeBase<SemanticGraph::Composition> (c) + { + } + + void Composition:: + begin (SimpleIdentifierPtr const& id, Category::Value c) + { + if (ctx.trace ()) cerr << "composition " << id << endl; + + if(c == Category::entity) + { + now (ctx.tu ().new_node<EntityComposition> ( + ctx.file (), id->line ())); + } + else if (c == Category::process) + { + now (ctx.tu ().new_node<ProcessComposition> ( + ctx.file (), id->line ())); + } + else if (c == Category::service) + { + now (ctx.tu ().new_node<ServiceComposition> ( + ctx.file (), id->line ())); + } + else + { + now (ctx.tu ().new_node<SessionComposition> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), id->lexeme ()); + } + + void Composition:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Composition:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Composition:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp new file mode 100644 index 00000000000..9bfce6dc78c --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp @@ -0,0 +1,42 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + struct Composition : SemanticAction::Composition, + ScopeBase<SemanticGraph::Composition> + { + Composition (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id, Category::Value c); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..5e4a0e2525e --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,27 @@ +// file : CCF/CIDL/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include "CCF/CIDL/SemanticAction/Elements.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using IDL3::SemanticAction::Impl::Context; + using IDL3::SemanticAction::Impl::Base; + using IDL3::SemanticAction::Impl::ScopeBase; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..37a6e589ca5 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,35 @@ +// file : CCF/CIDL/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : IDL2::SemanticAction::Impl::Factory (context, dout, tu), + IDL3::SemanticAction::Impl::Factory (context, dout, tu), + + composition_ (ctx_), + home_executor_ (ctx_) + { + } + } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..4cea4e35b82 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,53 @@ +// file : CCF/CIDL/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/CIDL/SemanticAction/Factory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +#include "CCF/CIDL/SemanticAction/Impl/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + struct Factory : virtual CIDL::SemanticAction::Factory, + virtual IDL3::SemanticAction::Impl::Factory + { + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + virtual SemanticAction::Composition& + composition () + { + return composition_; + } + + virtual SemanticAction::HomeExecutor& + home_executor () + { + return home_executor_; + } + + private: + Composition composition_; + HomeExecutor home_executor_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp new file mode 100644 index 00000000000..acbb6e9f5e0 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp @@ -0,0 +1,119 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeExecutor:: + HomeExecutor (Context& c) + : Base (c) + { + } + + void HomeExecutor:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "home executor " << id << endl; + + id_ = id; + he_ = &ctx.tu ().new_node<SemanticGraph::HomeExecutor> ( + ctx.file (), id->line ()); + } + + void HomeExecutor:: + implements (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "implements " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + c_ = 0; + + try + { + try + { + SemanticGraph::Home& h ( + resolve<SemanticGraph::Home> (from, name, Flags::defined)); + + c_ = &dynamic_cast<SemanticGraph::Component&> ( + h.manages ().managee ()); + + ctx.tu ().new_edge<Implements> (*he_, h); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid implements specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no home with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in implements specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to implement forward-declared home " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "implementation of forward-declared home is illegal" + << endl; + } + } + + void HomeExecutor:: + manages (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "manages " << id << endl; + + if (c_ != 0) + { + SemanticGraph::ComponentExecutor& ce ( + ctx.tu ().new_node<SemanticGraph::ComponentExecutor> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Implements> (ce, *c_); + + ctx.tu ().new_edge<Defines> (ctx.scope (), ce, id->lexeme ()); + ctx.tu ().new_edge<Defines> (ctx.scope (), *he_, id_->lexeme ()); + + ctx.tu ().new_edge<Manages> (*he_, ce); + } + } + + void HomeExecutor:: + end () + { + id_ = 0; + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp new file mode 100644 index 00000000000..23d3a3e7cca --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp @@ -0,0 +1,46 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + struct HomeExecutor : SemanticAction::HomeExecutor, Base + { + HomeExecutor (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + implements (IdentifierPtr const& id); + + virtual void + manages (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SimpleIdentifierPtr id_; + SemanticGraph::HomeExecutor* he_; + SemanticGraph::Component* c_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph.hpp b/CIAO/CCF/CCF/CIDL/SemanticGraph.hpp new file mode 100644 index 00000000000..9e4d2006029 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph.hpp @@ -0,0 +1,15 @@ +// file : CCF/CIDL/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL3/SemanticGraph.hpp" + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +#endif // CCF_CIDL_SEMANTIC_GRAPH_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp new file mode 100644 index 00000000000..429699d1b5d --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp @@ -0,0 +1,126 @@ +// file : CCF/CIDL/SemanticGraph/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // Composition + // + // + namespace + { + TypeInfo + composition_init_ () + { + TypeInfo ti (typeid (Composition)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo composition_ (composition_init_ ()); + } + + TypeInfo const& Composition:: + static_type_info () { return composition_; } + + Composition:: + ~Composition () + { + } + + + // EntityComposition + // + // + namespace + { + TypeInfo + entity_composition_init_ () + { + TypeInfo ti (typeid (EntityComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo entity_composition_ (entity_composition_init_ ()); + } + + TypeInfo const& EntityComposition:: + static_type_info () { return entity_composition_; } + + + // ProcessComposition + // + // + namespace + { + TypeInfo + process_composition_init_ () + { + TypeInfo ti (typeid (ProcessComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo process_composition_ (process_composition_init_ ()); + } + + TypeInfo const& ProcessComposition:: + static_type_info () { return process_composition_; } + + + // ServiceComposition + // + // + namespace + { + TypeInfo + service_composition_init_ () + { + TypeInfo ti (typeid (ServiceComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo service_composition_ (service_composition_init_ ()); + } + + TypeInfo const& ServiceComposition:: + static_type_info () { return service_composition_; } + + + // SessionComposition + // + // + namespace + { + TypeInfo + session_composition_init_ () + { + TypeInfo ti (typeid (SessionComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo session_composition_ (session_composition_init_ ()); + } + + TypeInfo const& SessionComposition:: + static_type_info () { return session_composition_; } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp new file mode 100644 index 00000000000..663029580da --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp @@ -0,0 +1,103 @@ +// file : CCF/CIDL/SemanticGraph/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + class Composition : public virtual Scope + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Composition () // Only for virtual inheritance. + { + type_info (static_type_info ()); + } + + virtual + ~Composition () = 0; + }; + + class EntityComposition : public virtual Composition + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + EntityComposition (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + class ProcessComposition : public virtual Composition + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ProcessComposition (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + class ServiceComposition : public virtual Composition + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ServiceComposition (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + class SessionComposition : public virtual Composition + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + SessionComposition (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..349f1854786 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp @@ -0,0 +1,33 @@ +// file : CCF/CIDL/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + implements_init_ () + { + TypeInfo ti (typeid (Implements)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo implements_ (implements_init_ ()); + } + + TypeInfo const& Implements:: + static_type_info () { return implements_; } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..625221116e7 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp @@ -0,0 +1,65 @@ +// file : CCF/CIDL/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using namespace IDL3::SemanticGraph; + + + class Implements : public virtual Edge + { + public: + Type& + implementer () const + { + return *implementer_; + } + + Type& + implementee () const + { + return *implementee_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Implements () + { + type_info (static_type_info ()); + } + + void + set_left_node (Type& n) + { + implementer_ = &n; + } + + void + set_right_node (Type& n) + { + implementee_ = &n; + } + + private: + Type* implementer_; + Type* implementee_; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp new file mode 100644 index 00000000000..9a4214bcd0e --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp @@ -0,0 +1,81 @@ +// file : CCF/CIDL/SemanticGraph/Executor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Executor + // + // + namespace + { + TypeInfo + executor_init_ () + { + TypeInfo ti (typeid (Executor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo executor_ (executor_init_ ()); + } + + TypeInfo const& Executor:: + static_type_info () { return executor_; } + + Executor:: + ~Executor () + { + } + + + // ComponentExecutor + // + // + namespace + { + TypeInfo + component_executorinit_ () + { + TypeInfo ti (typeid (ComponentExecutor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo component_executor (component_executorinit_ ()); + } + + TypeInfo const& ComponentExecutor:: + static_type_info () { return component_executor; } + + + // HomeExecutor + // + // + namespace + { + TypeInfo + home_executorinit_ () + { + TypeInfo ti (typeid (HomeExecutor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo home_executor (home_executorinit_ ()); + } + + TypeInfo const& HomeExecutor:: + static_type_info () { return home_executor; } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp b/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp new file mode 100644 index 00000000000..378638b2187 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp @@ -0,0 +1,122 @@ +// file : CCF/CIDL/SemanticGraph/Executor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + // + // + // + class Executor : public virtual Type + { + public: + Implements& + implements () const + { + return *implements_; + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Executor () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Executor () = 0; + + void + add_edge_left (Implements& e) + { + implements_ = &e; + } + + private: + Implements* implements_; + }; + + + // + // + // + class ComponentExecutor : public virtual Executor + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ComponentExecutor (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class HomeExecutor : public virtual Executor + { + public: + Manages& + manages () const + { + return *manages_; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeExecutor (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + using Executor::add_edge_left; + + void + add_edge_left (Manages& e) + { + manages_ = &e; + } + + private: + Manages* manages_; + }; + + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP diff --git a/CIAO/CCF/CCF/CIDL/Token.hpp b/CIAO/CCF/CCF/CIDL/Token.hpp new file mode 100644 index 00000000000..40bd13b252c --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Token.hpp @@ -0,0 +1,34 @@ +// file : CCF/CIDL/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TOKEN_HPP +#define CCF_CIDL_TOKEN_HPP + +#include "CCF/IDL3/Token.hpp" + +namespace CCF +{ + namespace CIDL + { + using IDL3::Token; + using IDL3::TokenPtr; + using IDL3::TokenList; + using IDL3::EndOfStream; + using IDL3::EndOfStreamPtr; + using IDL3::Keyword; + using IDL3::KeywordPtr; + using IDL3::Punctuation; + using IDL3::PunctuationPtr; + using IDL3::Identifier; + using IDL3::IdentifierPtr; + using IDL3::SimpleIdentifier; + using IDL3::SimpleIdentifierPtr; + using IDL3::ScopedIdentifier; + using IDL3::ScopedIdentifierPtr; + using IDL3::StringLiteral; + using IDL3::StringLiteralPtr; + } +} + +#endif // CCF_CIDL_TOKEN_HPP diff --git a/CIAO/CCF/CCF/CIDL/Traversal.hpp b/CIAO/CCF/CCF/CIDL/Traversal.hpp new file mode 100644 index 00000000000..119c813f554 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal.hpp @@ -0,0 +1,15 @@ +// file : CCF/CIDL/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_HPP +#define CCF_CIDL_TRAVERSAL_HPP + +#include "CCF/IDL3/Traversal.hpp" + +#include "CCF/CIDL/Traversal/Elements.hpp" + +#include "CCF/CIDL/Traversal/Composition.hpp" +#include "CCF/CIDL/Traversal/Executor.hpp" + +#endif // CCF_CIDL_TRAVERSAL_HPP diff --git a/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp b/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp new file mode 100644 index 00000000000..e93fa976e7e --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp @@ -0,0 +1,60 @@ +// file : CCF/CIDL/Traversal/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_COMPOSITION_HPP +#define CCF_CIDL_TRAVERSAL_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/Traversal/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + template <typename T> + struct CompositionTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + + typedef + CompositionTemplate <SemanticGraph::Composition> + Composition; + + typedef + CompositionTemplate <SemanticGraph::EntityComposition> + EntityComposition; + + typedef + CompositionTemplate <SemanticGraph::ProcessComposition> + ProcessComposition; + + typedef + CompositionTemplate <SemanticGraph::ServiceComposition> + ServiceComposition; + + + typedef + CompositionTemplate <SemanticGraph::SessionComposition> + SessionComposition; + } + } +} + +#include "CCF/CIDL/Traversal/Composition.tpp" + +#endif // CCF_CIDL_TRAVERSAL_COMPOSITION_HPP diff --git a/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp b/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp new file mode 100644 index 00000000000..8a6ff03e496 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp @@ -0,0 +1,41 @@ +// file : CCF/CIDL/Traversal/Composition.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + + template <typename T> + void CompositionTemplate<T>:: + traverse (T& c) + { + pre (c); + name (c); + names (c); + post (c); + } + + template <typename T> + void CompositionTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void CompositionTemplate<T>:: + name (T&) + { + } + + template <typename T> + void CompositionTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp b/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp new file mode 100644 index 00000000000..72ffd2613db --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp @@ -0,0 +1,36 @@ +// file : CCF/CIDL/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_ELEMENTS_HPP +#define CCF_CIDL_TRAVERSAL_ELEMENTS_HPP + +#include "CCF/IDL3/Traversal/Elements.hpp" + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + using namespace IDL3::Traversal; + + // + // + // + struct Implements : Edge<SemanticGraph::Implements> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.implementee ()); + } + }; + + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp b/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp new file mode 100644 index 00000000000..efcb9681d66 --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp @@ -0,0 +1,195 @@ +// file : CCF/CIDL/Traversal/Executor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/Traversal/Executor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // Executor + // + // + void Executor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + post (e); + } + + void Executor:: + pre (Type&) + { + } + + void Executor:: + name (Type&) + { + } + + void Executor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void Executor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void Executor:: + implements_pre (Type&) + { + } + + void Executor:: + implements_post (Type&) + { + } + + void Executor:: + post (Type&) + { + } + + + // ComponentExecutor + // + // + void ComponentExecutor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + post (e); + } + + void ComponentExecutor:: + pre (Type&) + { + } + + void ComponentExecutor:: + name (Type&) + { + } + + void ComponentExecutor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void ComponentExecutor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void ComponentExecutor:: + implements_pre (Type&) + { + } + + void ComponentExecutor:: + implements_post (Type&) + { + } + + void ComponentExecutor:: + post (Type&) + { + } + + + + // HomeExecutor + // + // + void HomeExecutor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + manages (e); + post (e); + } + + void HomeExecutor:: + pre (Type&) + { + } + + void HomeExecutor:: + name (Type&) + { + } + + void HomeExecutor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void HomeExecutor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void HomeExecutor:: + implements_pre (Type&) + { + } + + void HomeExecutor:: + implements_post (Type&) + { + } + + void HomeExecutor:: + manages (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.manages ()); + } + + void HomeExecutor:: + manages (Type& e) + { + manages_pre (e); + manages (e, edge_traverser ()); + manages_post (e); + } + + void HomeExecutor:: + manages_pre (Type&) + { + } + + void HomeExecutor:: + manages_post (Type&) + { + } + + void HomeExecutor:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp b/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp new file mode 100644 index 00000000000..6bb543aee9d --- /dev/null +++ b/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp @@ -0,0 +1,125 @@ +// file : CCF/CIDL/Traversal/Executor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_EXECUTOR_HPP +#define CCF_CIDL_TRAVERSAL_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +#include "CCF/CIDL/Traversal/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // + // + // + struct Executor : Node<SemanticGraph::Executor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct ComponentExecutor : Node<SemanticGraph::ComponentExecutor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct HomeExecutor : Node<SemanticGraph::HomeExecutor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + manages (Type&, EdgeDispatcherBase&); + + virtual void + manages (Type&); + + virtual void + manages_pre (Type&); + + virtual void + manages_post (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_EXECUTOR_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc b/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc new file mode 100644 index 00000000000..e978244e1ae --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc @@ -0,0 +1,7 @@ +//$Id$ + +project(CodeGenerationKit): cidlc { + sharedname = + staticname = CodeGenerationKit + libout = .. +} diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp new file mode 100644 index 00000000000..018aea6ffcf --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp @@ -0,0 +1,5 @@ +// file : CCF/CodeGenerationKit/CommandLine.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/CommandLine.hpp" diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp new file mode 100644 index 00000000000..1d77e8ea026 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp @@ -0,0 +1,237 @@ +// file : CCF/CodeGenerationKit/CommandLine.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_HPP +#define COMMAND_LINE_HPP + +#include <algorithm> +#include <vector> +#include <string> + +//@@ this stuff needs proper reimplementation + +class CommandLine +{ +public: + CommandLine () + { + } + + // Option constrain checking +public: + + bool + require (std::string option) const throw () + { + return std::find_if (options.begin (), + options.end (), + OptionNamePredicat (option)) != options.end (); + } + + bool + depends (std::string dependant, + std::string principal) const throw () + { + Options::const_iterator begin = options.begin (); + Options::const_iterator end = options.end (); + + if (std::find_if (begin, end, OptionNamePredicat (dependant)) != end) + { + return std::find_if (begin, end, OptionNamePredicat (principal)) != end; + } + else + { + return true; + } + } + + bool + inconsistent (std::string a, + std::string b) const throw () + { + Options::const_iterator begin = options.begin (); + Options::const_iterator end = options.end (); + + if (std::find_if (begin, end, OptionNamePredicat (a)) != end) + { + return std::find_if (begin, end, OptionNamePredicat (b)) == end; + } + else + { + return true; + } + } + + std::string + get_value (std::string name, std::string const& not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end () && !(i->value ().empty ())) + { + return i->value (); + } + else + { + return not_found_value; + } + } + + // @@ the option should probably be searched in reverse order + // + + std::string + get_value (std::string name, char const* not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end () && !(i->value ().empty ())) + { + return i->value (); + } + else + { + return std::string (not_found_value); + } + } + + bool + get_value (std::string name, bool not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end ()) + { + return true; + } + else + { + return not_found_value; + } + } + + bool + get_all_values (std::string name, std::vector<std::string> &values) + { + Options::iterator i (options.begin ()); + + while ((i = std::find_if (i, + options.end (), + OptionNamePredicat (name))) != options.end ()) + { + values.push_back (i->value ()); + ++i; + } + + return values.size () != 0; + } + + struct Option + { + Option (std::string const& name) + : name_ (name) + { + } + + Option (std::string const& name, + std::string const& value) + : name_ (name), + value_ (value) + { + } + + std::string const& + name () const + { + return name_; + } + + std::string const& + value () const + { + return value_; + } + + private: + std::string name_; + std::string value_; + }; + + typedef + std::vector<Option> + Options; + + typedef + Options::const_iterator + OptionsIterator; + + OptionsIterator + options_begin () const + { + return options.begin (); + } + + OptionsIterator + options_end () const + { + return options.end (); + } + + // Arguments + // + // + + typedef + std::vector<std::string> + Arguments; + + typedef + Arguments::const_iterator + ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments.end (); + } + +public: + + struct OptionNamePredicat + { + OptionNamePredicat (std::string const& name) + : name_ (name) + { + } + + bool operator ()(Option const& option) throw () + { + return name_ == option.name (); + } + + private: + std::string const name_; + }; + + std::string command; + Options options; + Arguments arguments; +}; + +#endif // COMMAND_LINE_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp new file mode 100644 index 00000000000..a7c6961cf1f --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp @@ -0,0 +1,338 @@ +// file : CCF/CodeGenerationKit/CommandLineDescriptor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_DESCRIPTOR_H +#define COMMAND_LINE_DESCRIPTOR_H + +#include <map> +#include <list> +#include <vector> +#include <string> +#include <ostream> +#include <cassert> + + +namespace CL +{ + struct OptionType + { + enum Value + { + flag, + value + }; + + OptionType (Value v) + : v_ (v) + { + } + + operator Value () const + { + return v_; + } + + private: + Value v_; + }; + + + class OptionDescription + { + public: + OptionDescription (std::string name, + std::string description, + OptionType type, + bool optional = true) + : optional_ (optional), + type_ (type), + name_ (name), + value_synopsis_ (), + description_ (description) + { + // There should be value_synopsis for non-flag options. + // + assert (type == OptionType::flag); + } + + + OptionDescription (std::string name, + std::string value_synopsis, + std::string description, + OptionType type, + bool optional = true) + : optional_ (optional), + type_ (type), + name_ (name), + value_synopsis_ (value_synopsis), + description_ (description) + { + } + + public: + bool + optional () const + { + return optional_; + } + + OptionType + type () const + { + return type_; + } + + std::string + name () const + { + return name_; + } + + std::string + value_synopsis () const + { + return value_synopsis_; + } + + std::string + description () const + { + return description_; + } + + + private: + bool optional_; + OptionType type_; + std::string name_; + std::string value_synopsis_; + std::string description_; + }; + + + class Description + { + public: + Description (std::string command) + : command_ (command) + { + } + + private: + Description (Description const&); + + Description& + operator= (Description const&); + + private: + // We are storing pointer to elements in this list in the map below. + // To prevent element moving we will use list instead of vector. + // + typedef + std::list<OptionDescription> + OptionDescriptionList; + + typedef + std::map<std::string, OptionDescription*> + OptionDescriptionMap; + + public: + + std::string + command () const + { + return command_; + } + + + public: + typedef + OptionDescriptionList::const_iterator + OptionIterator; + + OptionIterator + begin_option () const + { + return options_.begin (); + } + + OptionIterator + end_option () const + { + return options_.end (); + } + + typedef + OptionDescriptionMap::const_iterator + OptionMapIterator; + + OptionDescription const* + find_option (std::string const& option) const + { + OptionDescriptionMap::const_iterator i ( + option_map_.find (option)); + + return i == option_map_.end () ? 0 : i->second; + } + + void + add_option (OptionDescription const& od) + { + options_.push_back (od); + option_map_[od.name ()] = &options_.back (); + } + + private: + typedef + std::vector<std::string> + ArgumentDescriptionList; + + public: + typedef + ArgumentDescriptionList::const_iterator + ArgumentIterator; + + ArgumentIterator + begin_argument () const + { + return arguments_.begin (); + } + + ArgumentIterator + end_argument () const + { + return arguments_.end (); + } + + void + add_argument (std::string arg) + { + arguments_.push_back (arg); + } + + private: + std::string command_; + OptionDescriptionList options_; + OptionDescriptionMap option_map_; + ArgumentDescriptionList arguments_; + }; + + inline void + print_text (std::ostream& os, Description const& d) + { + using std::endl; + + os << d.command (); + + Description::OptionIterator ob = d.begin_option (); + Description::OptionIterator oe = d.end_option (); + + if (ob != oe) + { + os << " { OPTIONS }"; + } + + Description::ArgumentIterator ab = d.begin_argument (); + Description::ArgumentIterator ae = d.end_argument (); + + for (; ab != ae; ab++) + { + os << " <" << *ab << ">"; + } + + os << endl << endl; + + for (; ob != oe; ob++) + { + bool flag (ob->type () == OptionType::flag); + bool optional (ob->optional ()); + std::string prefix (ob->name ().length () == 1 ? "-" : "--"); + + os << (optional ? "[" : "") << prefix << ob->name () + << (flag ? "" : " ") << ob->value_synopsis () + << (optional ? "]" : "") + << endl; + + os << "\t\t" << ob->description () << endl << endl; + } + + } + + + inline void + print_html (std::ostream& os, Description const& d) + { + using std::endl; + + os << "<html>" << endl + << "<body>" << endl + << "<div align=\"center\">" << endl + << "<table width=\"700\" border=\"0\" cellspacing=\"0\" " + << "cellpadding=\"0\">" << endl + << "<tr>" << endl + << "<td>" << endl; + + os << "<p>" << endl + << "<code>" << endl; + + os << d.command (); + + Description::OptionIterator ob = d.begin_option (); + Description::OptionIterator oe = d.end_option (); + + if (ob != oe) + { + os << " { OPTIONS }"; + } + + Description::ArgumentIterator ab = d.begin_argument (); + Description::ArgumentIterator ae = d.end_argument (); + + for (; ab != ae; ab++) + { + os << " <" << *ab << ">"; + } + + os << endl + << "</code>" << endl + << "</p>" << endl; + + + os << "<dl>" << endl; + + for (; ob != oe; ob++) + { + bool flag (ob->type () == OptionType::flag); + bool optional (ob->optional ()); + std::string prefix (ob->name ().length () == 1 ? "-" : "--"); + + os << "<dt>" << endl + << "<code>" << endl + << (optional ? "[" : "") << prefix << ob->name () + << (flag ? "" : " ") << ob->value_synopsis () + << (optional ? "]" : "") << endl + << "</code>" << endl + << "</dt>" << endl; + + os << "<dd>" << endl + << "<p>" << endl + << ob->description () << endl + << "</p>" << endl + << "</dd>" << endl; + } + + os << "</dl>" << endl; + + os << "</td>" << endl + << "</tr>" << endl + << "</table>" << endl + << "</div>" << endl + << "</body>" << endl + << "</html>" << endl; + + } +} + + +#endif // COMMAND_LINE_DESCRIPTOR_H diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp new file mode 100644 index 00000000000..5f7d1d603bd --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp @@ -0,0 +1,120 @@ +// file : CCF/CodeGenerationKit/CommandLineParser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/CommandLineParser.hpp" + +#include <string> +#include <iostream> + +using std::cerr; +using std::endl; + +bool +parse (int argc, char* argv[], CL::Description const& cld, CommandLine& cl) +{ + cl.command = argv[0]; + + bool seen_double_dash (false); + + for (int i (1); i < argc; ++i) + { + std::string arg (argv[i]); + + if (seen_double_dash) + { + cl.arguments.push_back (arg); + continue; + } + + if (arg == "--") + { + seen_double_dash = true; + continue; + } + + if (arg.length () > 0 && arg[0] == '-') + { + if (arg.length () > 1 && arg[1] == '-') + { + // Double-dash (long) option. + // + + std::string op (arg, 2); + + if (CL::OptionDescription const* d = cld.find_option (op)) + { + if (d->type () == CL::OptionType::value) + { + if (++i >= argc) + { + cerr << argv[0] << ": argument expected for option '--" + << op << "'" << endl; + return false; + } + + // cerr << "--" << op << ": " << argv[i] << endl; + + cl.options.push_back (CommandLine::Option (op, argv[i])); + } + else + cl.options.push_back (CommandLine::Option (op)); + + continue; + } + } + else + { + // Single-dash (short) option. We support two formats: '-D foo' and + // -Dfoo. + // + std::string op (arg, 1, 1); + + if (CL::OptionDescription const* d = cld.find_option (op)) + { + if (d->type () == CL::OptionType::value) + { + std::string value; + + if (arg.length () > 2) + { + value.assign (arg, 2, arg.size () - 2); + } + else + { + if (++i >= argc) + { + cerr << argv[0] << ": argument expected for option '-" + << op << "'" << endl; + return false; + } + + value = argv[i]; + } + + // cerr << "-" << op << ": " << value << endl; + + cl.options.push_back (CommandLine::Option (op, value)); + } + else + { + if (arg.length () > 2) + { + cerr << argv[0] << ": argument not expected for option '-" + << op << "' in '" << arg << "'" << endl; + return false; + } + + cl.options.push_back (CommandLine::Option (op)); + } + + continue; + } + } + } + + cl.arguments.push_back (arg); + } + + return true; +} diff --git a/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp new file mode 100644 index 00000000000..2e85dc7e266 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp @@ -0,0 +1,14 @@ +// file : CCF/CodeGenerationKit/CommandLineParser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_PARSER_H +#define COMMAND_LINE_PARSER_H + +#include "CCF/CodeGenerationKit/CommandLine.hpp" +#include "CCF/CodeGenerationKit/CommandLineDescriptor.hpp" + +bool +parse (int argc, char* argv[], CL::Description const&, CommandLine&); + +#endif // COMMAND_LINE_PARSER_H diff --git a/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp b/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp new file mode 100644 index 00000000000..713f917e834 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp @@ -0,0 +1,61 @@ +// file : CCF/CodeGenerationKit/IndentationBuffer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER_HPP + +#include "CCF/CompilerElements/ExH.hpp" + +#include <string> + +namespace Indentation +{ + template <typename C> + class Buffer + { + public: + class Exception_ {}; + typedef + ExH::Compound <Exception_, ExH::Logic::DescriptiveException> + Exception; + + class EndOfStream_ {}; + typedef + ExH::Compound <EndOfStream_, Exception> + EndOfStream; + + public: + virtual + ~Buffer () throw () {} + + public: + typedef + std::char_traits<C> + traits_type; + + typedef + typename traits_type::char_type + char_type; + + typedef + typename traits_type::int_type + int_type; + + public: + virtual int_type + put (char_type c) throw (Exception, ExH::System::Exception) = 0; + + // Unbuffer flushes internal formatting buffers (if any). + // Note that unbuffer is not exactly flushing since it can + // result in formatting errors and in general can not be + // called at arbitrary points. Natural use case would be + // to call unbuffer at the end of the stream when no more + // data is expected. + // + virtual void + unbuffer () throw (EndOfStream, Exception, ExH::System::Exception) = 0; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp b/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp new file mode 100644 index 00000000000..b7451969555 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp @@ -0,0 +1,385 @@ +// file : CCF/CodeGenerationKit/IndentationCxx.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_CXX_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_CXX_HPP + +#include <deque> +#include <stack> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + template <typename C> + class Cxx : public Buffer<C> + { + public: + typedef + typename Buffer<C>::traits_type + traits_type; + + typedef + typename Buffer<C>::char_type + char_type; + + typedef + typename Buffer<C>::int_type + int_type; + + typedef + typename Buffer<C>::EndOfStream + EndOfStream; + + public: + Cxx (Buffer<C>& out) + : out_ (out), + position_ (0), + paren_balance_ (0), + spaces_ (2), + construct_ (OTHER) + { + indentation_.push (0); + } + + virtual + ~Cxx () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + bool defaulting = false; + + if (!hold_.empty () && hold_.back () == '(') + { + unbuffer (); // We don't need to hold it any more. + + if (c == '\n') + indentation_.push (indentation_.top () + spaces_); + else + indentation_.push (position_); + } + + switch (c) + { + case '\n': + { + hold_.push_back (c); + position_ = 0; // Starting a new line. + + if (construct_ == CXX_COMMENT) + { + //std::cerr << "end comment" << endl; + construct_ = OTHER; + } + + break; + } + case '{': + { + ensure_new_line (); + output_indentation (); + result = write (c); + ensure_new_line (); + + indentation_.push (indentation_.top () + spaces_); + + break; + } + case '}': + { + if (indentation_.size () > 1) + indentation_.pop (); + + // Reduce multiple newlines to one. + while (hold_.size () > 1) + { + typename Hold::reverse_iterator i = hold_.rbegin (); + if (*i == '\n' && *(i + 1) == '\n') hold_.pop_back (); + else break; + } + + ensure_new_line (); + output_indentation (); + + hold_.push_back (c); + + + // Add double newline after '}'. + // + hold_.push_back ('\n'); + hold_.push_back ('\n'); + position_ = 0; + + break; + } + case ';': + { + if (paren_balance_ != 0) + { + // We are inside for (;;) statement. Nothing to do here. + // + defaulting = true; + } + else + { + // Handling '};' case. + // + + bool brace (false); + + if (hold_.size () > 1 && hold_.back () == '\n') + { + bool pop_nl (false); + + for (typename Hold::reverse_iterator + i (hold_.rbegin ()), e (hold_.rend ()); i != e; ++i) + { + if (*i != '\n') + { + if (*i == '}') brace = pop_nl = true; + break; + } + } + + if (pop_nl) while (hold_.back () == '\n') hold_.pop_back (); + } + + output_indentation (); + result = write (c); + position_++; + + if (brace) + { + hold_.push_back ('\n'); + hold_.push_back ('\n'); + } + + if (construct_ != STRING_LITERAL && construct_ != CHAR_LITERAL) + { + ensure_new_line (); + } + } + + break; + } + case '\\': + { + if (construct_ != CXX_COMMENT) + { + output_indentation (); + hold_.push_back (c); + position_++; + } + else + defaulting = true; + + break; + } + case '\"': + { + if (construct_ != CXX_COMMENT && + (hold_.empty () || hold_.back () != '\\')) + { + // not escape sequence + if (construct_ == STRING_LITERAL) construct_ = OTHER; + else construct_ = STRING_LITERAL; + } + + defaulting = true; + break; + } + case '\'': + { + if (construct_ != CXX_COMMENT && + (hold_.empty () || hold_.back () != '\\')) + { + // not escape sequence + if (construct_ == CHAR_LITERAL) construct_ = OTHER; + else + { + //std::cerr << "char literal" << endl; + construct_ = CHAR_LITERAL; + } + + } + + defaulting = true; + break; + } + case '(': + { + if (construct_ == OTHER) + { + // Hold it so that we can see what's coming next. + // + output_indentation (); + hold_.push_back (c); + position_++; + paren_balance_++; + } + else + defaulting = true; + + break; + } + case ')': + { + if (construct_ == OTHER) + { + if (indentation_.size () > 1) + indentation_.pop (); + + if (paren_balance_ > 0) + paren_balance_--; + } + + defaulting = true; + break; + } + case '/': + { + if (construct_ == OTHER) + { + if (!hold_.empty () && hold_.back () == '/') + { + construct_ = CXX_COMMENT; + //std::cerr << "start comment" << endl; + defaulting = true; + } + else + { + output_indentation (); + hold_.push_back (c); + position_++; + } + } + else + { + defaulting = true; + } + + break; + } + default: + { + defaulting = true; + break; + } + } + + if (defaulting) + { + output_indentation (); + result = write (c); + position_++; + } + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + int_type result; + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + //@@ failed + if (result == traits_type::eof ()) + { + throw EndOfStream ("unable to flush buffer"); + } + + hold_.pop_front (); + } + } + + private: + class Full {}; + + void + ensure_new_line () + { + if (hold_.empty () || hold_.back () != '\n') + { + hold_.push_back ('\n'); + position_ = 0; // Starting a new line. + } + } + + + void + output_indentation () throw (Full) + { + if (!hold_.empty () && hold_.back () == '\n') + { + for (unsigned long i = 0; i < indentation_.top (); i++) + write (' '); + + position_ += indentation_.top (); + } + } + + int_type + write (char_type c) throw (Full) + { + hold_.push_back (c); + + int_type result (traits_type::eof ()); + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) + throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer<C>& out_; + unsigned long position_; // Current position on the line. + unsigned long paren_balance_; // ( ) balance. + std::stack<unsigned long> indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + CXX_COMMENT, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp b/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp new file mode 100644 index 00000000000..24f9866eac4 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp @@ -0,0 +1,277 @@ +// file : CCF/CodeGenerationKit/IndentationIDL.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + template <typename C> + class IDL : public Buffer<C> + { + public: + typedef + typename Buffer<C>::traits_type + traits_type; + + typedef + typename Buffer<C>::char_type + char_type; + + typedef + typename Buffer<C>::int_type + int_type; + + typedef + typename Buffer<C>::EndOfStream + EndOfStream; + + public: + IDL (Buffer<C>& out) + : out_ (out), + indentation_ (0), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~IDL () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + bool defaulting = false; + switch (c) + { + case '\n': + { + hold_.push_back (c); + break; + } + case '{': + { + ensure_new_line (); + output_indentation (); + result = write (c); + ensure_new_line (); + indentation_++; + break; + } + case '}': + { + if (indentation_ > 0) indentation_--; + + // Reduce multiple newlines to one. + while (hold_.size () > 1) + { + typename Hold::reverse_iterator i = hold_.rbegin (); + if (*i == '\n' && *(i + 1) == '\n') hold_.pop_back (); + else break; + } + + ensure_new_line (); + output_indentation (); + + hold_.push_back (c); + + // result = write (c); + + //ensure_new_line (); + + // Add double newline after '}'. + // + hold_.push_back ('\n'); + hold_.push_back ('\n'); + + + break; + } + case ';': + { + // Handling '};' case. + // + + bool brace (false); + + if (hold_.size () > 1 && hold_.back () == '\n') + { + bool pop_nl (false); + + for (typename Hold::reverse_iterator + i (hold_.rbegin ()), e (hold_.rend ()); i != e; ++i) + { + if (*i != '\n') + { + if (*i == '}') brace = pop_nl = true; + break; + } + } + + if (pop_nl) while (hold_.back () == '\n') hold_.pop_back (); + } + + output_indentation (); + result = write (c); + + if (brace) + { + hold_.push_back ('\n'); + hold_.push_back ('\n'); + } + + if (construct_ != STRING_LITERAL && construct_ != CHAR_LITERAL) + { + ensure_new_line (); + } + break; + } + case '\\': + { + hold_.push_back (c); + break; + } + case '\"': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == STRING_LITERAL) construct_ = OTHER; + else construct_ = STRING_LITERAL; + } + + defaulting = true; + break; + } + case '\'': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == CHAR_LITERAL) construct_ = OTHER; + else construct_ = CHAR_LITERAL; + } + + defaulting = true; + break; + } + default: + { + defaulting = true; + break; + } + } + + if (defaulting) + { + output_indentation (); + result = write (c); + } + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + int_type result; + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + //@@ failed + if (result == traits_type::eof ()) + { + throw EndOfStream ("unable to flush buffer"); + } + + hold_.pop_front (); + } + } + + private: + class Full {}; + + void + ensure_new_line () + { + if (hold_.empty () || hold_.back () != '\n') + { + hold_.push_back ('\n'); + } + } + + + void + output_indentation () throw (Full) + { + if (!hold_.empty () && hold_.back () == '\n') + { + for (unsigned long i = 0; i < indentation_ * spaces_; i++) + { + write (' '); + } + } + } + + int_type + write (char_type c) throw (Full) + { + hold_.push_back (c); + + int_type result (traits_type::eof ()); + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer<C>& out_; + unsigned long indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp b/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp new file mode 100644 index 00000000000..40259a694f6 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp @@ -0,0 +1,153 @@ +// file : CCF/CodeGenerationKit/IndentationImplanter.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER +#define CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER + +#include <ostream> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + template <typename C> + class ToStreamBufAdapter : public std::basic_streambuf<C> + { + public: + typedef + typename std::basic_streambuf<C>::traits_type + traits_type; + + typedef + typename std::basic_streambuf<C>::char_type + char_type; + + typedef + typename std::basic_streambuf<C>::int_type + int_type; + + public: + ToStreamBufAdapter (Buffer<C>& b) + : buffer_ (b) + { + } + + virtual int_type + overflow (int_type c) + { + return buffer_.put (traits_type::to_char_type (c)); + } + + virtual int + sync () + { + return 0; + } + + private: + Buffer<C>& buffer_; + }; + + template <typename C> + class FromStreamBufAdapter : public Buffer<C> + { + public: + typedef + typename Buffer<C>::traits_type + traits_type; + + typedef + typename Buffer<C>::char_type + char_type; + + typedef + typename Buffer<C>::int_type + int_type; + + typedef + typename Buffer<C>::Exception + Exception; + + public: + FromStreamBufAdapter (std::basic_streambuf<C>& b) + : buffer_ (b) + { + } + + virtual int_type + put (char_type c) throw (Exception, ExH::System::Exception) + { + return buffer_.sputc (c); + } + + virtual void + unbuffer () throw (ExH::System::Exception) + { + try + { + if (buffer_.pubsync () == 0) return; + } + catch (std::ios_base::failure const&) + { + } + + throw Exception ("underlying std::streambuf::sync failed"); + } + + private: + std::basic_streambuf<C>& buffer_; + }; + + template <template <typename> class BufferType, typename C = char> + class Implanter + { + public: + Implanter (std::basic_ostream<C>& os) + : os_ (os), + prev_ (os_.rdbuf ()), + from_adapter_ (*prev_), + buffer_ (from_adapter_), + to_adapter_ (buffer_) + { + os_.rdbuf (&to_adapter_); + } + + template <typename Arg0> + Implanter (std::basic_ostream<C>& os, Arg0 a0) + : os_ (os), + prev_ (os_.rdbuf ()), + from_adapter_ (*prev_), + buffer_ (from_adapter_, a0), + to_adapter_ (buffer_) + { + os_.rdbuf (&to_adapter_); + } + + ~Implanter () + { + try + { + buffer_.unbuffer (); + } + catch (...) + { + // there is nothing I can do... + } + + os_.rdbuf (prev_); + } + + private: + std::basic_ostream<C>& os_; + std::basic_streambuf<C>* prev_; + + FromStreamBufAdapter<C> from_adapter_; + + BufferType<C> buffer_; + + ToStreamBufAdapter<C> to_adapter_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER diff --git a/CIAO/CCF/CCF/CodeGenerationKit/IndentationXML.hpp b/CIAO/CCF/CCF/CodeGenerationKit/IndentationXML.hpp new file mode 100644 index 00000000000..774a70e501f --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/IndentationXML.hpp @@ -0,0 +1,233 @@ +// file : CCF/CodeGenerationKit/IndentationXML.hpp +// author : Diego Sevilla Ruiz <dsevilla@ditec.um.es> +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + template <typename C> + class XML : public Buffer<C> + { + public: + typedef + typename Buffer<C>::traits_type + traits_type; + + typedef + typename Buffer<C>::char_type + char_type; + + typedef + typename Buffer<C>::int_type + int_type; + + typedef + typename Buffer<C>::EndOfStream + EndOfStream; + + public: + XML (Buffer<C>& out) + : out_ (out), + indentation_ (0), + base_indent_ (indentation_), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~XML () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + switch (c) + { + case '\n': + { + flush_buffer (); + + // If we are inside a tag, just output an artificial tab character + if (construct_ == INSIDE_TAG) + { + hold_.push_back (c); + c = traits_type::to_int_type (' '); + + // spaces_ - 1 because at the end the last space will be + // put into the hold_ queue. + for (unsigned long i = 0; i < spaces_ - 1; i++) + hold_.push_back (c); + } + + base_indent_ = indentation_; + + break; + } + + // Case with <?xxx and <!DOCTYPE (for example). + // We still don't handle XML comments + case '?': + case '!': + { + if (construct_ == INSIDE_TAG && hold_.back () == '<') + indentation_--; + + break; + } + + case '<': + { + //@@ This construct must not be INSIDE_TAG + if (construct_ == OTHER) + { + construct_ = INSIDE_TAG; + indentation_++; + } + + break; + } + + case '>': + { + if (construct_ == INSIDE_TAG) + construct_ = OTHER; + + break; + } + + case '/': + { + if (construct_ == INSIDE_TAG) + { + if (hold_.back () == '<') + indentation_ -= 2; + else + indentation_--; + + if (indentation_ < 0) + indentation_ = 0; + } + + break; + } + + case '\"': + { + if (construct_ == INSIDE_TAG) + construct_ = STRING_LITERAL; + else if (construct_ == STRING_LITERAL) + construct_ = INSIDE_TAG; + + break; + } + + } + + hold_.push_back (c); + + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + try + { + flush_buffer (); + } catch (const Full&) + { + throw EndOfStream ("unable to flush buffer"); + } + } + + private: + class Full {}; + + void + flush_buffer () throw (Full) + { + long delta = indentation_ - base_indent_; + + if (delta > 0) + delta = 0; + + while (!hold_.empty ()) + { + int_type c = hold_.front (); + + write (c); + + if (c == '\n') + output_indentation (base_indent_ + delta); + + hold_.pop_front (); + } + } + + void + output_indentation (unsigned long indentation) throw (Full) + { + for (unsigned long i = 0; i < indentation * spaces_; i++) + { + write (' '); + } + } + + int_type + write (int_type c) throw (Full) + { + int_type result; + + result = out_.put (c); + + if (result == traits_type::eof ()) throw Full (); + + return result; + } + + + private: + Buffer<C>& out_; + long indentation_; + unsigned long base_indent_; + unsigned long spaces_; + + enum Construct + { + OTHER, + /* Strings literals can only happen inside tags, like: + * <tag whatever="xxx + */ + STRING_LITERAL, + INSIDE_TAG + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP diff --git a/CIAO/CCF/CCF/CodeGenerationKit/Regex.hpp b/CIAO/CCF/CCF/CodeGenerationKit/Regex.hpp new file mode 100644 index 00000000000..b92ed9d4f42 --- /dev/null +++ b/CIAO/CCF/CCF/CodeGenerationKit/Regex.hpp @@ -0,0 +1,51 @@ +// file : CCF/CodeGenerationKit/Regex.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_REGEX_HPP +#define CCF_RUNTIME_REGEX_HPP + +#include <string> +#include <boost/regex.hpp> + +namespace regex +{ + template <typename C> + std::basic_string<C> + perl_s (std::basic_string<C> const& src, std::basic_string<C> const& e) + { + typedef std::basic_string<C> string; + typedef typename string::size_type size; + + if (e.empty ()) + return src; + + C delimiter (e[0]); + + size first = e.find (delimiter); + size middle = e.find (delimiter, first + 1); + size last = e.find (delimiter, middle + 1); + + string pattern (e, first + 1, middle - first - 1); + string format (e, middle + 1, last - middle - 1); + + //std::cout << pattern << " " << format << std::endl; + + boost::basic_regex<C> expr (pattern); + + return regex_merge ( + src, + expr, + format, + boost::match_default | boost::format_all ); + } + + template <typename C> + std::basic_string<C> + perl_s (std::basic_string<C> const& src, C const* e) + { + return perl_s (src, std::basic_string<C> (e)); + } +} + +#endif // CCF_RUNTIME_REGEX_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc b/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc new file mode 100644 index 00000000000..54b81f8c557 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc @@ -0,0 +1,7 @@ +//$Id$ + +project(CompilerElements): cidlc { + sharedname = + staticname = CompilerElements + libout = .. +} diff --git a/CIAO/CCF/CCF/CompilerElements/Context.hpp b/CIAO/CCF/CCF/CompilerElements/Context.hpp new file mode 100644 index 00000000000..fe799e32b48 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Context.hpp @@ -0,0 +1,112 @@ +// file : CCF/CompilerElements/Context.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_COMPILER_ELEMENTS_CONTEXT_HPP +#define CCF_COMPILER_ELEMENTS_CONTEXT_HPP + +#include <map> +#include <string> +#include <Utility/Hetero/Container.hpp> + +namespace CCF +{ + namespace CompilerElements + { + class Context + { + typedef + std::map<std::string, Utility::Hetero::Container> + Map; + + public: + Context () + { + } + + public: + class NotFound {}; + class Typing {}; + + Map::size_type + count (char const* key) const throw () + { + return map_.count (key); + } + + template <typename T> + T const& + get (char const* key) const throw (NotFound, Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) throw NotFound (); + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + + } + + template <typename T> + T const& + get (char const* key, T const& def) const throw (Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) return def; + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + template <typename T> + void + set (char const* key, T const& value) throw (Typing) + { + try + { + if (!map_.insert (std::pair<std::string, + Utility::Hetero::Container>(key, value)).second) + { + Map::iterator i = map_.find (key); + i->second.template value <T> () = value; + } + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + void + remove (char const* key) throw (NotFound) + { + Map::iterator i (map_.find (key)); + + if (i == map_.end ()) throw NotFound (); + + map_.erase (i); + } + + private: + Map map_; + + private: + // Copy semanic is not supported. + Context (Context const&) throw (); + Context& operator= (Context const&) throw (); + }; + } +} + +#endif // CCF_COMPILER_ELEMENTS_CONTEXT_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp b/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp new file mode 100644 index 00000000000..34eb0006b69 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp @@ -0,0 +1,192 @@ +// file : CCF/CompilerElements/Diagnostic.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_DIAGNOSTIC_HPP +#define CCF_DIAGNOSTIC_HPP + +#include <string> +#include <sstream> +#include <iostream> + +#include "CCF/CompilerElements/ExH.hpp" + +//@@ Should be inside CCF namespace + +namespace Diagnostic +{ + // + // + // + class Record : public std::ostringstream + { + public: + + struct Type + { + enum Value + { + INFO, + WARNING, + ERROR + }; + }; + + Record (Type::Value type, + std::string file, + unsigned long line, + std::string description = "") + : std::ostringstream (description), + type_ (type), + file_ (file), + line_ (line) + { + } + + public: + + Type::Value + type () const + { + return type_; + } + + std::string + file () const + { + return file_; + } + + unsigned long line () const + { + return line_; + } + + std::string + description () const + { + return str (); + } + + private: + Type::Value type_; + std::string file_; + unsigned long line_; + }; + + + // + // + // + struct Info : public Record + { + Info (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::INFO, file, line, description) + { + } + }; + + + // + // + // + struct Warning : public Record + { + Warning (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::WARNING, file, line, description) + { + } + }; + + + // + // + // + struct Error : public Record + { + Error (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::ERROR, file, line, description) + { + } + }; + + + // + // + // + class Stream + { + public: + + Stream () + : info_count_ (0), + warning_count_ (0), + error_count_ (0) + { + } + + + Stream& + operator<< (Record const& msg) + { + std::cerr << msg.file () << ":" << msg.line () << ": " + << msg.description () << std::endl; + + switch (msg.type ()) + { + case Record::Type::INFO: + { + info_count_++; + break; + } + case Record::Type::WARNING: + { + warning_count_++; + } + case Record::Type::ERROR: + { + error_count_++; + } + } + + return *this; + } + + public: + unsigned long + info_count () + { + return info_count_; + } + + unsigned long + warning_coun () + { + return warning_count_; + } + + unsigned long + error_count () + { + return error_count_; + } + + private: + unsigned long info_count_; + unsigned long warning_count_; + unsigned long error_count_; + + private: + // Copy semanic is not supported. + Stream (Stream const&) throw (); + Stream& operator= (Stream const&) throw (); + }; +} + +#endif // CCF_DIAGNOSTIC_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/ExH.hpp b/CIAO/CCF/CCF/CompilerElements/ExH.hpp new file mode 100644 index 00000000000..ad7e1b71950 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/ExH.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/ExH.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_EX_H_H +#define CCF_RUNTIME_EX_H_H + +#include "Utility/ExH/ExH.hpp" + +namespace ExH = Utility::ExH; + +#endif // CCF_RUNTIME_EX_H_H diff --git a/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp b/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp new file mode 100644 index 00000000000..ba9483f04e6 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp @@ -0,0 +1,33 @@ +// file : CCF/CompilerElements/FileSystem.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_FILE_SYSTEM_HPP +#define CCF_RUNTIME_FILE_SYSTEM_HPP + +#include <string> + +#include <boost/filesystem/path.hpp> +#include <boost/filesystem/fstream.hpp> +#include <boost/filesystem/exception.hpp> +#include <boost/filesystem/operations.hpp> + +namespace fs +{ + using namespace boost::filesystem; + + inline path + normalize (path const& p) + { + path result; + + for (path::iterator i (p.begin ()), e (p.end ()); i != e; ++i) + { + if (*i != ".") result /= path (*i, native); + } + + return result; + } +} + +#endif // CCF_RUNTIME_FILE_SYSTEM_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/Introspection.cpp b/CIAO/CCF/CCF/CompilerElements/Introspection.cpp new file mode 100644 index 00000000000..9e625e0272a --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Introspection.cpp @@ -0,0 +1,26 @@ +// file : CCF/CompilerElements/Introspection.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// +// This is a hack to avoid link dependency on Utility library. +// + +#include "Utility/Introspection/Object.hpp" + +namespace Utility +{ + namespace Introspection + { + namespace + { + TypeInfo object_ (typeid (Object)); + } + + TypeInfo const& Object:: + static_type_info () throw () + { + return object_; + } + } +} diff --git a/CIAO/CCF/CCF/CompilerElements/Introspection.hpp b/CIAO/CCF/CCF/CompilerElements/Introspection.hpp new file mode 100644 index 00000000000..898e596fa88 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Introspection.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/Introspection.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_INTROSPECTION_HPP +#define CCF_RUNTIME_INTROSPECTION_HPP + +#include "Utility/Introspection/Introspection.hpp" + +namespace Introspection = Utility::Introspection; + +#endif // CCF_RUNTIME_INTROSPECTION_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/Preprocessor.cpp b/CIAO/CCF/CCF/CompilerElements/Preprocessor.cpp new file mode 100644 index 00000000000..e52750ba74e --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Preprocessor.cpp @@ -0,0 +1,955 @@ +// file : CCF/CompilerElements/Preprocessor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <deque> +#include <locale> +#include <string> + +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; +using std::string; + +namespace CCF +{ + namespace CompilerElements + { + namespace CPP + { + /* + namespace Phase2 + { + class TokenPrototype + { + public: + struct Type + { + enum Value + { + punctuation, + keyword, + identifier + eos + }; + }; + + TokenPrototype (Type::Value type, string const& lexeme) + : type_ (type), lexeme_ (lexeme) + { + } + + Type::Value + type () const + { + return type_; + } + + string + lexeme () const + { + return lexeme_; + } + + private: + Type::Value type_; + string lexeme_; + }; + + bool + operator== (TokenPrototype const& a, TokenPrototype const& b) + { + return a.type () == b.type () && a.lexeme () == b.lexeme (); + } + + class Token : public TokenPrototype + { + public: + Token (Type::Value type, + string const& lexeme, + unsigned long line) + : TokenPrototype (type, lexeme), line_ (line) + { + } + + unsigned long + line () const + { + return line_; + } + + private: + unsigned long line_; + }; + + + class Scanner : public TokenStream<Token> + { + public: + Scanner (TokenStream<CPP::Token>& is) + : is_ (is) + { + } + + virtual Token + next () + { + try + { + InToken t (get_ns ()); + + switch (t) + { + case '#': + { + return Token (Token::Type::punctuation, "#", t.line ()); + } + case '\n': + { + return Token (Token::Type::punctuation, "\n", t.line ()); + } + } + } + catch (EOS const&) + { + } + } + + private: + typedef + CPP::Token + InToken; + + class EOS {}; + + InToken + get () throw (EOS) + { + if (ibuffer_.empty ()) + { + InToken t (is_.next ()); + if (t == InToken::eos) throw EOS (); + return t; + } + else + { + InToken t (ibuffer_.front ()); + ibuffer_.pop_front (); + + if (t == InToken::eos) throw EOS (); + return t; + } + } + + // Get first non-space token + // + InToken + get_ns () throw (EOS) + { + InToken t (get ()); + + while (is_space (t)) t = get (); + } + + bool + is_space (InToken const& t) + { + return t == ' ' || t == '\t'; + } + + private: + TokenStream<CPP::Token>& is_; + std::deque<InTokent> ibuffer_; + }; + } + */ + + // PreprocessorImpl + // + // + class Preprocessor::PreprocessorImpl : public TokenStream<Token> + { + public: + virtual + ~PreprocessorImpl () + { + } + + PreprocessorImpl (TokenStream<char>& is, Symbols const& symbols) + : loc_ ("C"), + state_ (State::preprocessing), + ln_ (1), + is_ (is), + dsa_ (copy_), + symbols_ (symbols), + balance_ (0), + skip_balance_ (0) + { + } + + virtual Token + next () + { + while (true) + { + if (line_.empty ()) + scan_line (); + + Token t (line_.front ()); + line_.pop_front (); + + if (skip_balance_ != 0 && t != Token::eos) + continue; + + return t; + } + } + + private: + + // Line-scanning + // + // + + class DequeStreamAdapter : public TokenStream<Token> + { + public: + DequeStreamAdapter (std::deque<Token>& d) + : d_ (d) + { + } + + virtual Token + next () + { + Token t (d_.front ()); + d_.pop_front (); + return t; + } + + private: + std::deque<Token>& d_; + }; + + void + scan_line () + { + bool eos (false); + + while (line_.empty () && !eos) + { + for (;;) + { + Token t (next_token ()); + + if (t == Token::eos) + { + eos = true; + + // Add new line if it's missing at the end of line. + // + if (!line_.empty () && line_.back () != '\n') + { + //@@ should issue a warning here + // + line_.push_back (Token ('\n', line_.back ().line ())); + } + } + else + { + line_.push_back (t); + } + + if (eos || t == '\n') break; + } + + /* + cerr << "line: \'"; + + for (std::deque<Token>::iterator + i (line_.begin ()), e (line_.end ()); i != e; ++i) + { + if (*i != Token::eos) cerr << *i; + } + + cerr << '\'' << endl; + */ + + // Check if it is a PP directive + // + + if (!line_.empty ()) + { + copy_ = line_; + ls_buffer_.clear (); + copy_.push_back (Token::eos); // add eos + + try + { + Token t (ls_get_ns ()); + + // cerr << "t = \'" << t << '\'' << endl; + + if (t == '#') + { + scan_directive (); + } + } + catch (EOS const&) + { + // cerr << "EOS" << endl; + + // error condition? + Token t ('\n', line_.front ().line ()); + line_.clear (); + line_.push_back (t); + } + } + } + + if (eos) + { + if (balance_ > 0) + { + cerr << "missing endif directive at the end of file" << endl; + } + + line_.push_back (Token::eos); + } + } + + + void + scan_directive () + { + Token t (ls_get_ns ()); + + string lexeme; + + if (std::isalpha<char> (t, loc_)) + { + for (;std::isalpha<char> (t, loc_); t = ls_get ()) + lexeme += t; + + ls_ret (t); + } + + // cerr << "lexeme " << lexeme << endl; + + if (lexeme == "include") + { + scan_include (); + return; + } + else if (lexeme == "if") + { + ++balance_; + } + else if (lexeme == "ifdef" || lexeme == "ifndef") + { + ++balance_; + + string symbol; + Token t (ls_get_ns ()); + + + if (is_first_id_char (t)) + { + for (;is_id_char (t); t = ls_get ()) + symbol += t; + ls_ret (t); + } + + if (!symbol.empty ()) + { + //cerr << "symbol " << symbol << endl; + + if (skip_balance_ == 0) // Unless we are already skipping. + { + bool defined (symbols_.find (symbol) != symbols_.end ()); + + if ((!defined && lexeme == "ifdef") || + (defined && lexeme == "ifndef")) + skip_balance_ = balance_; + } + } + else + { + cerr << t.line () << ": no symbol specified for " << lexeme + << " directive" << endl; + throw EOS (); //@@ tmp + } + } + else if (lexeme == "elif" || lexeme == "else") + { + // For now we treat elif just like else. + // + if (skip_balance_ == balance_) + skip_balance_ = 0; + else if (skip_balance_ == 0) // Unless we are already skipping. + skip_balance_ = balance_; // Start skipping now. + } + else if (lexeme == "endif") + { + if (skip_balance_ == balance_) + skip_balance_ = 0; + + if (balance_ > 0) + --balance_; + else + { + cerr << t.line () << ": extraneous endif directive" << endl; + throw EOS (); //@@ tmp + } + } + else if (lexeme == "error") + { + if (skip_balance_ == 0) + { + string msg; + Token t (ls_get_ns ()); + + if (t != '\n') + { + for (;t != '\n'; t = ls_get ()) + msg += t; + ls_ret (t); + } + + cerr << t.line () << ": error: " << msg << endl; + throw EOS (); //@@ tmp + } + } + + // By default we replace this directive with a newline. + // + { + Token t ('\n', line_.front ().line ()); + line_.clear (); + line_.push_back (t); + } + } + + void + scan_include () + { + Token t (ls_get_ns ()); + + char finilizer; + + switch (t) + { + case '\"': + { + finilizer = '\"'; + break; + + } + case '<': + { + finilizer = '>'; + break; + } + default: + { + cerr << t.line () << ": invalid include directive" << endl; + throw EOS (); //@@ tmp + } + } + + string path; + + for (t = ls_get (); t != finilizer && t != '\n'; t = ls_get ()) + { + path += t; + } + + if (t != finilizer) + { + cerr << t.line () << ": invalid include directive" << endl; + throw EOS (); // @@ tmp + } + + string repl (finilizer == '>' ? "__binclude \"" : "__qinclude \""); + repl += path + "\";\n"; + + line_.clear (); + + for (string::const_iterator i (repl.begin ()), e (repl.end ()); + i != e; ++i) + { + line_.push_back (Token (*i, t.line ())); + } + } + + // Char-scanning + // + // + + Token + next_token () + { + if (!obuffer_.empty ()) + { + Token t (obuffer_.front ()); + obuffer_.pop_front (); + return t; + } + + try + { + switch (state_) + { + case State::preprocessing: + { + return preprocessing (); + } + case State::string_literal: + { + return string_literal (); + } + case State::char_literal: + { + return char_literal (); + } + } + } + catch (EOS const&) + { + } + + return Token::eos; + } + + Token + preprocessing () + { + unsigned long l (ln_); + char_type c (get ()); + + switch (c) + { + case '\'': + { + state_ = State::char_literal; + break; + } + case '\"': + { + state_ = State::string_literal; + break; + } + case '\\': + { + return escape (); + } + case '\n': + { + ++ln_; + break; + } + case '/': + { + return slash (); + } + } + + return Token (c, l); + } + + + Token + string_literal () + { + unsigned long l (ln_); + char_type c (get ()); + + switch (c) + { + case '\"': + { + state_ = State::preprocessing; + break; + } + case '\\': + { + return escape (); + } + case '\n': + { + ++ln_; + break; + } + } + + return Token (c, l); + } + + + Token + char_literal () + { + unsigned long l (ln_); + char_type c (get ()); + + switch (c) + { + case '\'': + { + state_ = State::preprocessing; + break; + } + case '\\': + { + return escape (); + } + case '\n': + { + ++ln_; + break; + } + } + + return Token (c, l); + } + + + Token + escape () + { + try + { + char_type c (get ()); + + switch (c) + { + case '\n': + { + ++ln_; + return next_token (); + } + case '\'': + { + if (state_ != State::char_literal && + state_ != State::string_literal) + { + state_ = State::char_literal; + } + + put (Token ('\'', ln_)); + return Token ('\\', ln_); + } + case '\"': + { + if (state_ != State::char_literal && + state_ != State::string_literal) + { + state_ = State::string_literal; + } + + put (Token ('\"', ln_)); + return Token ('\\', ln_); + } + default: + { + ret (c); + return Token ('\\', ln_); + } + } + } + catch (EOS const&) + { + ret_eos (); + return Token ('\\', ln_); + } + } + + + Token + slash () + { + unsigned long l (ln_); + + try + { + char_type c (get ()); + + switch (c) + { + case '*': // C comment + { + return c_comment (); + } + case '/': // C++ comment + { + return cxx_comment (); + } + default: + { + ret (c); + break; + } + } + } + catch (EOS const&) + { + ret_eos (); + } + + return Token ('/', l); + } + + + Token + c_comment () + { + // Replace the whole C comment with the single space. + // + unsigned long l (ln_); + + try + { + char_type c (get ()); + + for (bool done (false); !done;) + { + switch (c) + { + case '\n': + { + ++ln_; + break; + } + case '*': + { + c = get (); + if (c == '/') done = true; + continue; + } + } + + c = get (); + } + } + catch (EOS const&) + { + put (Token::eos); + } + + return Token (' ', l); + } + + + Token + cxx_comment () + { + // Replace the whole C++ comment with the single space. + // + unsigned long l (ln_); + + try + { + for (bool done (false); !done;) + { + char_type c (get ()); + + switch (c) + { + case '\n': + { + ++ln_; + done = true; + break; + } + } + } + } + catch (EOS const&) + { + put (Token::eos); + } + + return Token ('\n', l); + } + + // Low-level utility functions. + // + private: + typedef + TokenStream<char>::int_type + int_type; + + typedef + TokenStream<char>::char_type + char_type; + + char_type + to_char_type (int_type i) + { + return TokenStream<char>::to_char_type (i); + } + + bool + eos (int_type i) + { + return TokenStream<char>::eos () == i; + } + + class EOS {}; + + char_type + get () throw (EOS) + { + int_type i; + + if (ibuffer_.empty ()) + { + i = is_.next (); + } + else + { + i = ibuffer_.front (); + ibuffer_.pop_front (); + } + + if (eos (i)) throw EOS (); + + return to_char_type (i); + } + + void + ret (char_type t) + { + ibuffer_.push_front (t); + } + + void + ret_eos () + { + ibuffer_.push_front (TokenStream<char>::eos ()); + } + + void + put (Token const& t) + { + obuffer_.push_back (t); + } + + + // line-scanner utility functions + // + // + void + ls_ret (Token const& t) + { + ls_buffer_.push_front (t); + } + + Token + ls_get () throw (EOS) + { + if (ls_buffer_.empty ()) + { + Token t (dsa_.next ()); + if (t == Token::eos) throw EOS (); + return t; + } + else + { + Token t (ls_buffer_.front ()); + ls_buffer_.pop_front (); + + if (t == Token::eos) throw EOS (); + return t; + } + } + + // Get first non-space token + // + Token + ls_get_ns () throw (EOS) + { + Token t (ls_get ()); + + while (ls_is_space (t)) t = ls_get (); + return t; + } + + bool + ls_is_space (Token const& t) + { + return t == ' ' || t == '\t'; + } + + bool + is_first_id_char (Token const& t) + { + return std::isalpha<char> (t, loc_) || t == '_'; + } + + bool + is_id_char (Token const& t) + { + return std::isalnum<char> (t, loc_) || t == '_'; + } + + private: + struct State + { + enum Value + { + preprocessing, + string_literal, + char_literal + }; + }; + + std::locale loc_; + + State::Value state_; + unsigned long ln_; + + TokenStream<char>& is_; + + std::deque<int_type> ibuffer_; + std::deque<Token> obuffer_; + + std::deque<Token> line_; + + std::deque<Token> copy_; + DequeStreamAdapter dsa_; + std::deque<Token> ls_buffer_; + + Symbols symbols_; + unsigned long balance_; // Current #if*/#endif balance. + unsigned long skip_balance_; // #if*/#endif balance at which we began + // skipping. 0 indicates no skipping. + + }; + + + // Preprocessor + // + // + Preprocessor:: + ~Preprocessor () + { + } + + Preprocessor:: + Preprocessor (TokenStream<char>& is, Symbols const& symbols) + : impl_ (new PreprocessorImpl (is, symbols)) + { + } + + Token Preprocessor:: + next () + { + return impl_->next (); + } + } + } +} diff --git a/CIAO/CCF/CCF/CompilerElements/Preprocessor.hpp b/CIAO/CCF/CCF/CompilerElements/Preprocessor.hpp new file mode 100644 index 00000000000..994c889a3f8 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/Preprocessor.hpp @@ -0,0 +1,45 @@ +// file : CCF/CompilerElements/Preprocessor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_COMPILER_ELEMENTS_PREPROCESSOR_HPP +#define CCF_COMPILER_ELEMENTS_PREPROCESSOR_HPP + +#include <memory> +#include <string> +#include <set> + +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/PreprocessorToken.hpp" + +namespace CCF +{ + namespace CompilerElements + { + namespace CPP + { + typedef + std::set<std::string> + Symbols; + + class Preprocessor : public TokenStream<Token> + { + public: + virtual + ~Preprocessor (); + + Preprocessor (TokenStream<char>& is, Symbols const&); + + virtual Token + next (); + + private: + class PreprocessorImpl; + + std::auto_ptr<PreprocessorImpl> impl_; + }; + } + } +} + +#endif // CCF_COMPILER_ELEMENTS_PREPROCESSOR_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.cpp b/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.cpp new file mode 100644 index 00000000000..5f3e629243e --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.cpp @@ -0,0 +1,57 @@ +// file : CCF/CompilerElements/PreprocessorToken.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CompilerElements/PreprocessorToken.hpp" + +namespace CCF +{ + namespace CompilerElements + { + namespace CPP + { + Token const Token::eos; + + Token:: + Token (char c, unsigned long line) + : c_ (traits::to_int_type (c)), line_ (line) + { + } + + Token:: + Token () + : c_ (traits::eof ()), line_ (0) + { + } + + Token:: + operator char () const throw (EOS) + { + if (*this == eos) throw EOS (); + + return traits::to_char_type (c_); + } + + + unsigned long Token:: + line () const throw (EOS) + { + if (*this == eos) throw EOS (); + + return line_; + } + + bool + operator== (Token const& a, Token const& b) + { + return a.c_ == b.c_; + } + + bool + operator!= (Token const& a, Token const& b) + { + return a.c_ != b.c_; + } + } + } +} diff --git a/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.hpp b/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.hpp new file mode 100644 index 00000000000..5c82076a01c --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/PreprocessorToken.hpp @@ -0,0 +1,58 @@ +// file : CCF/CompilerElements/PreprocessorToken.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_COMPILER_ELEMENTS_PREPROCESSOR_TOKEN_HPP +#define CCF_COMPILER_ELEMENTS_PREPROCESSOR_TOKEN_HPP + +#include <string> + +//@@ It is probably a good idea to move preprocessor into a +// separate library. +// + +namespace CCF +{ + namespace CompilerElements + { + namespace CPP + { + class Token + { + public: + static Token const eos; + + public: + Token (char c, unsigned long line); + + class EOS {}; + + operator char () const throw (EOS); + + unsigned long + line () const throw (EOS); + + friend bool + operator== (Token const& a, Token const& b); + + friend bool + operator!= (Token const& a, Token const& b); + + private: + // Constructs eos token. + // + Token (); + + private: + typedef + std::char_traits<char> + traits; + + traits::int_type c_; + unsigned long line_; + }; + } + } +} + +#endif // CCF_COMPILER_ELEMENTS_PREPROCESSOR_TOKEN_HPP diff --git a/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp b/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp new file mode 100644 index 00000000000..0c3e0057d59 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/ReferenceCounting.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_REFERENCE_COUNTING_H +#define CCF_RUNTIME_REFERENCE_COUNTING_H + +#include "Utility/ReferenceCounting/ReferenceCounting.hpp" + +namespace ReferenceCounting = Utility::ReferenceCounting; + +#endif // CCF_RUNTIME_REFERENCE_COUNTING_H diff --git a/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp b/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp new file mode 100644 index 00000000000..6dac816bed4 --- /dev/null +++ b/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp @@ -0,0 +1,90 @@ +// file : CCF/CompilerElements/TokenStream.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_COMPILER_ELEMENTS_TOKEN_STREAM_HPP +#define CCF_COMPILER_ELEMENTS_TOKEN_STREAM_HPP + +#include <string> +#include <istream> + +namespace CCF +{ + namespace CompilerElements + { + template <typename Token> + class TokenStream + { + public: + // (JP 06-04-06) Not required by C++ spec, but it + // eliminates buggy GCC warnings. + virtual ~TokenStream () {} + + virtual Token + next () = 0; + }; + + template <> + class TokenStream<char> + { + public: + typedef + std::char_traits<char> + traits; + + typedef + traits::int_type + int_type; + + typedef + traits::char_type + char_type; + + public: + virtual int_type + next () = 0; + + static char_type + to_char_type (int_type i) + { + return traits::to_char_type (i); + } + + static int_type + eos () + { + return traits::eof (); + } + + virtual ~TokenStream () + { + } + }; + + class InputStreamAdapter : public TokenStream<char> + { + public: + InputStreamAdapter (std::istream& is) + : is_ (is) + { + } + + virtual ~InputStreamAdapter () + { + } + + public: + + virtual int_type + next () + { + return is_.get (); + } + + private: + std::istream& is_; + }; + } +} + +#endif // CCF_COMPILER_ELEMENTS_TOKEN_STREAM_HPP diff --git a/CIAO/CCF/CCF/IDL2/IDL2.mpc b/CIAO/CCF/CCF/IDL2/IDL2.mpc new file mode 100644 index 00000000000..74273a71a7f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/IDL2.mpc @@ -0,0 +1,16 @@ +//$Id$ + +project(IDL2): cidlc { + sharedname = + staticname = IDL2 + libout = .. + + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction + ./SemanticAction/Impl + + } +} diff --git a/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp b/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..e357a1a0c28 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp @@ -0,0 +1,964 @@ +// file : CCF/IDL2/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +#include <stdlib.h> // strtol +#include <iostream> + +using std::cerr; +using std::endl; +using std::string; +using std::pair; +using std::size_t; + +namespace CCF +{ + namespace IDL2 + { + LexicalAnalyzer:: + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is) + : loc_ ("C"), is_ (is) + { + // Keywords (alphabetic order). + // + + keyword_table_.insert ("abstract" ); + keyword_table_.insert ("attribute" ); + keyword_table_.insert ("__binclude" ); + keyword_table_.insert ("case" ); + keyword_table_.insert ("const" ); + keyword_table_.insert ("custom" ); + keyword_table_.insert ("default" ); + keyword_table_.insert ("exception" ); + keyword_table_.insert ("enum" ); + keyword_table_.insert ("factory" ); + keyword_table_.insert ("getraises" ); + keyword_table_.insert ("in" ); + keyword_table_.insert ("inout" ); + keyword_table_.insert ("interface" ); + keyword_table_.insert ("__qinclude" ); + keyword_table_.insert ("local" ); + keyword_table_.insert ("module" ); + keyword_table_.insert ("native" ); + keyword_table_.insert ("oneway" ); + keyword_table_.insert ("out" ); + keyword_table_.insert ("private" ); + keyword_table_.insert ("public" ); + keyword_table_.insert ("raises" ); + keyword_table_.insert ("readonly" ); + keyword_table_.insert ("sequence" ); + keyword_table_.insert ("setraises" ); + keyword_table_.insert ("struct" ); + keyword_table_.insert ("supports" ); + keyword_table_.insert ("switch" ); + keyword_table_.insert ("truncatable"); + keyword_table_.insert ("typedef" ); + keyword_table_.insert ("typeid" ); + keyword_table_.insert ("typeprefix" ); + keyword_table_.insert ("union" ); + keyword_table_.insert ("valuetype" ); + + // Identifiers (alphabetic order). + // + // Note: if you are planning to hack something up + // in the code below, first make sure you understand + // how everything works! + // + + IdentifierTreeNode end; + + identifier_tree_["Object" ] = end; + identifier_tree_["ValueBase"] = end; + identifier_tree_["any" ] = end; + identifier_tree_["boolean" ] = end; + identifier_tree_["char" ] = end; + identifier_tree_["double" ] = end; + identifier_tree_["float" ] = end; + + IdentifierTreeNode long_; + long_["" ] = end; + long_["double"] = end; + long_["long" ] = end; + + identifier_tree_["long" ] = long_; + identifier_tree_["octet" ] = end; + identifier_tree_["short" ] = end; + identifier_tree_["string" ] = end; + + IdentifierTreeNode unsigned_long_; + unsigned_long_["" ] = end; + unsigned_long_["long"] = end; + + IdentifierTreeNode unsigned_; + unsigned_["long" ] = unsigned_long_; + unsigned_["short" ] = end; + + identifier_tree_["unsigned" ] = unsigned_; + identifier_tree_["void" ] = end; + identifier_tree_["wchar" ] = end; + identifier_tree_["wstring" ] = end; + + // punctuation (pair-matched). + // + punctuation_table_.insert (":"); + punctuation_table_.insert (","); + punctuation_table_.insert ("{"); + punctuation_table_.insert ("}"); + punctuation_table_.insert ("["); + punctuation_table_.insert ("]"); + punctuation_table_.insert ("("); + punctuation_table_.insert (")"); + punctuation_table_.insert ("<"); + punctuation_table_.insert (">"); + punctuation_table_.insert (";"); + + // operators + // + operator_table_.insert ("+"); // add + operator_table_.insert ("&"); // and + operator_table_.insert ("~"); // com + operator_table_.insert ("/"); // div + operator_table_.insert ("="); // eq + operator_table_.insert ("<<"); // lsh + operator_table_.insert ("*"); // mul + operator_table_.insert ("|"); // or + operator_table_.insert ("%"); // rem + operator_table_.insert ("-"); // sub + operator_table_.insert (">>"); // rsh + operator_table_.insert ("^"); // xor + } + + + LexicalAnalyzer::Char LexicalAnalyzer:: + get () + { + if (!ibuffer_.empty ()) + { + Char c = ibuffer_.front (); + ibuffer_.pop_front (); + return c; + } + else + { + return is_.next (); + } + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + peek () + { + if (ibuffer_.empty ()) + { + ibuffer_.push_back (is_.next ()); + } + + return ibuffer_.front (); + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + peek_more () + { + while (ibuffer_.size () < 2) + { + ibuffer_.push_back (is_.next ()); + } + + return ibuffer_.at (1); + } + + void LexicalAnalyzer:: + ret (Char const& c) + { + ibuffer_.push_front (c); + } + + + TokenPtr LexicalAnalyzer:: + next () + { + while (true) // Recovery loop. + { + Char c = skip_space (get ()); + + if (is_eos (c)) return TokenPtr (new EndOfStream (0)); + + TokenPtr token; + + if (character_literal (c, token)) return token; + + if (string_literal (c, token)) return token; + + if (integer_literal (c, token)) return token; + + // Check for identifier after literals because it can be + // triggered by wide string prefix (L"..."). + // + if (is_alpha (c) || c == '_' || (c == ':' && peek () == ':')) + { + return identifier (c); + } + + // Check for punctuation after identifier because ':' in + // scoped name will trigger. + // + if (operator_ (c, token)) return token; + + if (punctuation (c, token)) return token; + + cerr << c.line () << ": error: unable to derive any token " + << "from \'" << c << "\'" << endl; + + + //Do some primitive error recovery. + // + while (c != ';') + { + c = skip_space (get ()); + if (is_eos (c)) return TokenPtr (new EndOfStream (0)); + } + } + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + skip_space (Char c) + { + while (!is_eos (c) && is_space (c)) c = get (); + + return c; + } + + bool LexicalAnalyzer:: + read_simple_identifier (string& lexeme, CharBuffer& buf) + { + Char c = skip_space (get ()); + + buf.push_back (c); + + if (is_eos (c)) return false; + + if (is_alpha (c) || c == '_') + { + lexeme += c; + + while (true) + { + c = peek (); + + if (is_eos (c)) + { + cerr << "warning: no new line at the end of file" << endl; + break; + } + + if (is_alnum (c) || c == '_') + { + get (); + buf.push_back (c); + lexeme += c; + continue; + } + + break; + } + + return true; + } + + return false; + } + + + bool LexicalAnalyzer:: + traverse_identifier_tree (string& lexeme, IdentifierTreeNode const& node) + { + if (node.map_.empty ()) return true; + + CharBuffer buf; + string part; + + if (read_simple_identifier (part, buf)) + { + IdentifierTreeNode::PrefixMap::const_iterator i ( + node.map_.find (part)); + + if (i != node.map_.end ()) + { + if (traverse_identifier_tree (part, i->second)) + { + lexeme += " " + part; + return true; + } + } + } + + // Return characters to the buffer in case we couldn't + // match anything. + + for(;!buf.empty (); buf.pop_back ()) ret (buf.back ()); + + // Check is the node.map_ contains empty key which indicates + // that what we've got is good enough. + // + return node.map_.find ("") != node.map_.end (); + } + + + TokenPtr LexicalAnalyzer:: + identifier (Char c) + { + unsigned long line (c.line ()); + + string lexeme; + + enum + { + simple, + scoped, + other + } type = simple; + + if (c == ':') + { + //@@ not checking for eos here + if ((c = get ()) != ':') + { + cerr << "error: " << c.line () << ": \':\' expected." + << endl; + + return TokenPtr (new EndOfStream (0)); + //@@ error handling is lame for lexical analyzer. + } + + lexeme = "::"; + type = scoped; + c = get (); + } + + // First caracter of an identifier. + // + if (is_eos (c)) + { + cerr << "error: invalid identifier" << endl; + return TokenPtr (new EndOfStream (0)); + } + + if (is_alpha (c) || c == '_') + { + lexeme += c; + } + else + { + cerr << "error: invalid identifier" << endl; + return TokenPtr (new EndOfStream (0)); + } + + while (true) + { + c = peek (); + + if (is_eos (c)) + { + cerr << "warning: no new line at the end of file" << endl; + break; + } + + // cerr << "lexer::identifier: peeking on \'" << c.char_ () + // << "\'; current lexeme \'" << lexeme << "\'" + // << endl; + + if (is_alnum (c) || c == '_') + { + get (); + lexeme += c; + continue; + } + + if (c == ':' && peek_more () == ':') + { + get (); + get (); + lexeme += "::"; + if (type == simple) type = other; + continue; + } + + break; + } + + //cerr << "lexer: found identifier with lexeme \'" + // << lexeme << "\'" << endl; + + if (type == simple) + { + // Check if it's a keyword. + { + KeywordTable::const_iterator i (keyword_table_.find (lexeme)); + + if (i != keyword_table_.end ()) + { + return TokenPtr (new Keyword (*i, line)); + } + + // This part is tricky. If it's after 6pm then come back + // in the morning. In essence I want the same name + // ('string' and 'wstring') to be recognized as a keyword + // in one case and as an identifier in the other. When + // we see 'string' followed by '<' we want it to be a + // keyword. If it's just all by itself then we want to treat + // it as an identifier (since it is a complete construct + // by itself). So here we are going to check for that. + // + + if (lexeme == "string" || lexeme == "wstring") + { + Char c = skip_space (get ()); + ret (c); + + if (c == '<') + { + return TokenPtr (new Keyword (lexeme, line)); + } + } + } + + // Check if it is a reserved identifier. + // + + { + IdentifierTreeNode::PrefixMap::const_iterator i ( + identifier_tree_.map_.find (lexeme)); + + if (i != identifier_tree_.map_.end ()) + { + if (traverse_identifier_tree (lexeme, i->second)) + { + return TokenPtr ( + new SimpleIdentifier (lexeme, line)); + } + else + { + //@@ error + } + } + } + + // Check if it is a boolean literal. + // + if (lexeme == "TRUE" || lexeme == "FALSE") + { + return TokenPtr (new BooleanLiteral (lexeme, line)); + } + + // Default to SimpleIdentifier. + // + return TokenPtr (new SimpleIdentifier (lexeme, line)); + } + else if (type == scoped) + { + return TokenPtr (new ScopedIdentifier (lexeme, line)); + } + else //type == other + { + return TokenPtr (new Identifier (lexeme, line)); + } + } + + bool LexicalAnalyzer:: + punctuation (Char c, TokenPtr& token) + { + unsigned long line (c.line ()); + + PunctuationTable::const_iterator i = punctuation_table_.begin (); + + while (true) + { + for (;i != punctuation_table_.end () && (*i)[0] != c; ++i); + + if (i == punctuation_table_.end ()) return false; + + if (i->size () == 2) // two-character punctuation + { + Char pc (peek ()); + + if (!is_eos (pc) && (*i)[1] == pc) + { + get (); + } + else + { + // Move on to the next candidate. + // + ++i; + continue; + } + } + + token = TokenPtr (new Punctuation (*i, line)); + return true; + } + } + + bool LexicalAnalyzer:: + operator_ (Char c, TokenPtr& token) + { + unsigned long line (c.line ()); + + OperatorTable::const_iterator i = operator_table_.begin (); + + while (true) + { + for (;i != operator_table_.end () && (*i)[0] != c; ++i); + + if (i == operator_table_.end ()) return false; + + if (i->size () == 2) // two-character operator + { + Char pc (peek ()); + + if (!is_eos (pc) && (*i)[1] == pc) + { + get (); + } + else + { + // Move on to the next candidate. + // + ++i; + continue; + } + } + + token = TokenPtr (new Operator (*i, line)); + return true; + } + } + + pair<char, size_t> LexicalAnalyzer:: + scan_char (char const* s) throw (Format) + { + if (*s == '\0') + { + throw Format (); + } + else if (*s != '\\') + { + return pair<char, size_t> (*s, 1); + } + else + { + // Expected size is 2. + // + pair<char, size_t> r ('\0', 2); + + switch (*++s) + { + case 'n': + r.first = '\n'; + break; + + case 't': + r.first = '\t'; + break; + + case 'v': + r.first = '\v'; + break; + + case 'b': + r.first = '\b'; + break; + + case 'r': + r.first = '\r'; + break; + + case 'f': + r.first = '\f'; + break; + + case 'a': + r.first = '\a'; + break; + + case '\\': + r.first = '\\'; + break; + + case '?': + r.first = '\?'; + break; + + case '\'': + r.first = '\''; + break; + + case '"': + r.first = '\"'; + break; + + case 'x': + { + // hex + + char c (*++s); + + if(is_hex_digit (c)) + { + // Maximum 2 digits. + // + string holder (s, 2); + + char* end; + + // Cannot fail. -1 < v < 256. + // + long v (strtol(holder.c_str (), &end, 16)); + + r.first = static_cast<char> (v); + r.second = 2 + end - holder.c_str (); + } + else + { + throw Format (); + } + break; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + // Maximum 3 digits. + // + string holder (s, 3); + + char* end; + + // Cannot fail. + // + long v (strtol(holder.c_str (), &end, 8)); + + if (v < 0 || v > 255) throw Format (); + + r.first = static_cast<char> (v); + r.second = 1 + end - holder.c_str (); + + break; + } + default: + { + throw Format (); + } + } + + return r; + + } + } + + string LexicalAnalyzer:: + scan_string (string const& s) throw (Format) + { + string r; + + char const* p = s.c_str (); + + while (*p != '\0') + { + pair<char, size_t> c (scan_char (p)); + + if (c.first == '\0') throw Format (); + + r += c.first; + p += c.second; + } + + return r; + } + + + bool LexicalAnalyzer:: + character_literal (Char c, TokenPtr& token) + { + if (c != '\'') return false; + + unsigned long line (c.line ()); + string lexeme; + + Char prev (c); + + while (true) + { + c = get (); + + if (is_eos (c)) + { + cerr << "error: end of file while reading character literal" + << endl; + break; + } + + if (c == '\'' && prev != '\\') break; + + lexeme += c; + prev = c; + } + + try + { + pair<char, size_t> r (scan_char (lexeme.c_str ())); + if (r.second != lexeme.size ()) throw Format (); + + token = TokenPtr (new CharacterLiteral (r.first, lexeme, line)); + return true; + } + catch (Format const&) + { + cerr << "error: invalid character literal format" << endl; + return false; + } + } + + bool LexicalAnalyzer:: + string_literal (Char c, TokenPtr& token) + { + if (c != '\"') return false; + + unsigned long line (c.line ()); + string lexeme; + string value; + + try + { + while (true) + { + string r (string_literal_trailer ()); + value += scan_string (r); + lexeme += '\"' + r + '\"'; + + // Check if there are more strings. + // + + c = skip_space (get ()); + + if (c != '\"') + { + ret (c); // put it back + break; + } + + + // Add single space as a string separator. + // + lexeme += " "; + } + + // cerr << "string literal: <" << lexeme << ">/<" << value << ">" + // << endl; + + token = TokenPtr (new StringLiteral (value, lexeme, line)); + return true; + } + catch (Format const&) + { + cerr << "error: invalid string literal format" << endl; + return false; + } + } + + string LexicalAnalyzer:: + string_literal_trailer () + { + string r; + + Char prev ('\"', 0); + + while (true) + { + Char c = get (); + + if (is_eos (c)) + { + cerr << "error: end of file while reading string literal" << endl; + break; + } + + if (c == '\"' && prev != '\\') break; + + r += c; + prev = c; + } + + return r; + } + + unsigned long long LexicalAnalyzer:: + scan_integer (string const& s, unsigned short base) + throw (Format, Boundary) + { + unsigned long long const max (~0ULL); + unsigned long long bound (max / base); + + + char const* p (s.c_str ()); + + // Skip leading 0 if any. + // + while (*p != '\0' && *p == '0') ++p; + + + unsigned long long result (0); + + while(*p != '\0') + { + unsigned short digit; + + char c (to_upper (*p)); + + if (is_dec_digit (c)) + { + digit = c - '0'; + } + else if (is_hex_digit (c)) + { + digit = c - 'A' + 10; + } + else + { + throw Format (); + } + + if (digit > base) throw Format (); + + if (result > bound) + { + // cerr << "boundary: base: " << base << "; bound: " << std::hex + // << bound << "; result: " << std::hex << result << endl; + + throw Boundary (); + } + + + result *= base; + result += digit; + + ++p; + } + + return result; + } + + //@@ need to return unparsed characters for recovery (like in + // integer_literal). + // + bool LexicalAnalyzer:: + integer_literal (Char c, TokenPtr& token) + { + try + { + if (!is_dec_digit (c)) return false; + + unsigned long line (c.line ()); + + ret (c); // Temporarily return the character. + + string lexeme, number; + + unsigned short base (10); // assume 10 + + // Determine base and get rid of its identifications. + // + // + if (c == '0') + { + lexeme += c; + + get (); + + Char pc (peek ()); + + if (!is_eos (pc)) + { + if (pc == 'x' || pc == 'X') + { + get (); + base = 16; + lexeme += pc; + + c = peek (); + } + else + { + base = 8; + if (!is_oct_digit (pc)) + { + number += c; // this is needed to handle single 0 + } + + c = pc; + } + } + else + { + number += c; // this is needed to handle single 0 + } + } + + while (true) + { + // Make sure c is a legal character. + // + + if (is_eos (c)) break; + + if (base == 8 && !is_oct_digit (c)) + { + break; + } + else if (base == 10 && !is_dec_digit (c)) + { + break; + } + else if (!is_hex_digit (c)) + { + break; + } + + get (); + + lexeme += c; + number += c; + + c = peek (); + } + + if (number.empty ()) throw Format (); + + unsigned long long value (scan_integer (number, base)); + + //cerr << "integer literal: <" << lexeme << ">/<" << number << ">/<" + // << value << ">" << endl; + + token = TokenPtr (new IntegerLiteral (value, lexeme, line)); + return true; + } + catch (Format const&) + { + cerr << "error: invalid integer literal format" << endl; + return false; + } + catch (Boundary const&) + { + cerr << "error: integer literal is too big" << endl; + return false; + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp b/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..e75641e40c8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp @@ -0,0 +1,203 @@ +// file : CCF/IDL2/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_LEXICAL_ANALYZER_HPP +#define CCF_IDL2_LEXICAL_ANALYZER_HPP + +#include <set> +#include <map> +#include <deque> +#include <locale> +#include <string> + +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/PreprocessorToken.hpp" +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + //@@ Call to get() after eof is illegal. + // + // + + class LexicalAnalyzer : public CompilerElements::TokenStream<TokenPtr> + { + public: + virtual + ~LexicalAnalyzer () throw () {} + + public: + + typedef + CompilerElements::CPP::Token + Char; + + typedef + std::deque<Char> + CharBuffer; + + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is); + + virtual TokenPtr + next (); + + protected: + virtual Char + skip_space (Char c); + + virtual TokenPtr + identifier (Char c); + + virtual bool + punctuation (Char c, TokenPtr& token); + + virtual bool + operator_ (Char c, TokenPtr& token); + + virtual bool + character_literal (Char c, TokenPtr& token); + + virtual bool + string_literal (Char c, TokenPtr& token); + + virtual std::string + string_literal_trailer (); + + virtual bool + integer_literal (Char c, TokenPtr& token); + + // Literal scanners. + // + // + class Format {}; + class Boundary {}; + + std::pair<char, std::size_t> + scan_char (char const* s) throw (Format); + + std::string + scan_string (std::string const& s) throw (Format); + + unsigned long long + scan_integer (std::string const& s, unsigned short base) + throw (Format, Boundary); + + protected: + virtual Char + get (); + + virtual Char + peek (); + + virtual Char + peek_more (); + + virtual void + ret (Char const& c); + + protected: + // Character utility functions. + // + bool + is_alpha (char c) const + { + return std::isalpha (c, loc_); + } + + bool + is_oct_digit (char c) const + { + return std::isdigit (c, loc_) && c != '8' && c != '9'; + } + + bool + is_dec_digit (char c) const + { + return std::isdigit (c, loc_); + } + + bool + is_hex_digit (char c) const + { + return std::isxdigit (c, loc_); + } + + bool + is_alnum (char c) const + { + return std::isalnum (c, loc_); + } + + bool + is_space (char c) const + { + return std::isspace (c, loc_); + } + + bool + is_eos (Char const& c) const + { + return c == Char::eos; + } + + char + to_upper (char c) const + { + return std::toupper (c, loc_); + } + + protected: + typedef + std::set<std::string> + KeywordTable; + + struct IdentifierTreeNode + { + typedef + std::map<std::string, IdentifierTreeNode> + PrefixMap; + + IdentifierTreeNode& + operator[] (char const* key) + { + return map_[key]; + } + + PrefixMap map_; + }; + + typedef + std::set<std::string> + PunctuationTable; + + typedef + std::set<std::string> + OperatorTable; + + protected: + bool + read_simple_identifier (std::string& lexeme, CharBuffer& buf); + + bool + traverse_identifier_tree (std::string& lexeme, + IdentifierTreeNode const& node); + + protected: + std::locale loc_; + + CompilerElements::TokenStream<Char>& is_; + + CharBuffer ibuffer_; + + KeywordTable keyword_table_; + IdentifierTreeNode identifier_tree_; + PunctuationTable punctuation_table_; + OperatorTable operator_table_; + }; + } +} + +#endif // CCF_IDL2_LEXICAL_ANALYZER_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parser.cpp b/CIAO/CCF/CCF/IDL2/Parser.cpp new file mode 100644 index 00000000000..c368ad2b5d7 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Parser.cpp @@ -0,0 +1,2360 @@ +// file : CCF/IDL2/Parser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Parser.hpp" + +// +// Note: DO NOT run emacs indenter (or any other indentation tool) over +// this file because it will most likely break BNF indentation. +// + +namespace CCF +{ + namespace IDL2 + { + using Parsing::DiagnosticType; + using Parsing::RecoveryMethod; + + Parser:: + ~Parser () + { + } + + Parser:: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f) + : dout_ (dout), + lexer_ (l), + actions_ (f), + + error_handler (context, dout), + + ABSTRACT ("abstract" ), + ATTRIBUTE ("attribute" ), + BINCLUDE ("__binclude" ), + CASE ("case" ), + CONST ("const" ), + CUSTOM ("custom" ), + DEFAULT ("default" ), + ENUM ("enum" ), + EXCEPTION ("exception" ), + FACTORY ("factory" ), + GETRAISES ("getraises" ), + IN ("in" ), + INOUT ("inout" ), + INTERFACE ("interface" ), + QINCLUDE ("__qinclude" ), + LOCAL ("local" ), + MODULE ("module" ), + NATIVE ("native" ), + ONEWAY ("oneway" ), + OUT ("out" ), + PRIVATE ("private" ), + PUBLIC ("public" ), + RAISES ("raises" ), + READONLY ("readonly" ), + SEQUENCE ("sequence" ), + SETRAISES ("setraises" ), + STRING ("string" ), + STRUCT ("struct" ), + SUPPORTS ("supports" ), + SWITCH ("switch" ), + TRUNCATABLE ("truncatable"), + TYPEDEF ("typedef" ), + TYPEID ("typeid" ), + TYPEPREFIX ("typeprefix" ), + UNION ("union" ), + VALUETYPE ("valuetype" ), + WSTRING ("wstring" ), + + COLON (":"), + COMMA (","), + LCBRACE ("{"), + RCBRACE ("}"), + LSBRACE ("["), + RSBRACE ("]"), + LPAREN ("("), + RPAREN (")"), + LT ("<"), + GT (">"), + SEMI (";"), + + + ADD ("+"), + AND ("&"), + COM ("~"), + DIV ("/"), + EQ ("="), + LSH ("<<"), + MUL ("*"), + OR ("|"), + REM ("%"), + SUB ("-"), + RSH (">>"), + XOR ("^"), + + + // Attribute + // + // + act_attribute_begin_ro ( + f.attribute (), &SemanticAction::Attribute::begin_ro), + + act_attribute_begin_rw ( + f.attribute (), &SemanticAction::Attribute::begin_rw), + + act_attribute_type ( + f.attribute (), &SemanticAction::Attribute::type), + + act_attribute_name ( + f.attribute (), &SemanticAction::Attribute::name), + + act_attribute_get_raises ( + f.attribute (), &SemanticAction::Attribute::get_raises), + + act_attribute_set_raises ( + f.attribute (), &SemanticAction::Attribute::set_raises), + + act_attribute_end ( + f.attribute (), &SemanticAction::Attribute::end), + + // Const + // + act_const_begin ( + f.const_ (), &SemanticAction::Const::begin), + + act_const_expr ( + f.const_ (), &SemanticAction::Const::expr), + + // Enum + // + // + act_enum_begin ( + f.enum_ (), &SemanticAction::Enum::begin), + + act_enum_enumerator ( + f.enum_ (), &SemanticAction::Enum::enumerator), + + act_enum_end ( + f.enum_ (), &SemanticAction::Enum::end), + + + // Expression + // + + act_const_expr_flush ( + f.numeric_expression (), + &SemanticAction::NumericExpression::flush), + + act_numeric_expression_const ( + f.numeric_expression (), + &SemanticAction::NumericExpression::const_), + + act_numeric_expression_integer_literal ( + f.numeric_expression (), + &SemanticAction::NumericExpression::integer_literal), + + act_numeric_expression_pre ( + f.numeric_expression (), + &SemanticAction::NumericExpression::pre), + + act_numeric_expression_pos ( + f.numeric_expression (), + &SemanticAction::NumericExpression::pos), + + act_numeric_expression_neg ( + f.numeric_expression (), + &SemanticAction::NumericExpression::neg), + + act_numeric_expression_com ( + f.numeric_expression (), + &SemanticAction::NumericExpression::com), + + act_numeric_expression_mul ( + f.numeric_expression (), + &SemanticAction::NumericExpression::mul), + + act_numeric_expression_div ( + f.numeric_expression (), + &SemanticAction::NumericExpression::div), + + act_numeric_expression_rem ( + f.numeric_expression (), + &SemanticAction::NumericExpression::rem), + + act_numeric_expression_add ( + f.numeric_expression (), + &SemanticAction::NumericExpression::add), + + act_numeric_expression_sub ( + f.numeric_expression (), + &SemanticAction::NumericExpression::sub), + + act_numeric_expression_rsh ( + f.numeric_expression (), + &SemanticAction::NumericExpression::rsh), + + act_numeric_expression_lsh ( + f.numeric_expression (), + &SemanticAction::NumericExpression::lsh), + + act_numeric_expression_and ( + f.numeric_expression (), + &SemanticAction::NumericExpression::and_), + + act_numeric_expression_xor ( + f.numeric_expression (), + &SemanticAction::NumericExpression::xor_), + + act_numeric_expression_or ( + f.numeric_expression (), + &SemanticAction::NumericExpression::or_), + + // Exception + // + // + act_exception_begin ( + f.exception (), &SemanticAction::Exception::begin), + + act_exception_open_scope ( + f.exception (), &SemanticAction::Scope::open_scope), + + act_exception_close_scope ( + f.exception (), &SemanticAction::Scope::close_scope), + + act_exception_end ( + f.exception (), &SemanticAction::Exception::end), + + + // Include + // + // + act_include_quote ( + f.include (), &SemanticAction::Include::quote), + + act_include_bracket ( + f.include (), &SemanticAction::Include::bracket), + + act_include_end ( + f.include (), &SemanticAction::Include::end), + + + // Interface + // + // + act_interface_begin_abstract_def ( + f.interface (), &SemanticAction::Interface::begin_abstract_def), + + act_interface_begin_abstract_fwd ( + f.interface (), &SemanticAction::Interface::begin_abstract_fwd), + + act_interface_begin_local_def ( + f.interface (), &SemanticAction::Interface::begin_local_def), + + act_interface_begin_local_fwd ( + f.interface (), &SemanticAction::Interface::begin_local_fwd), + + act_interface_begin_unconstrained_def ( + f.interface (), + &SemanticAction::Interface::begin_unconstrained_def), + + act_interface_begin_unconstrained_fwd ( + f.interface (), + &SemanticAction::Interface::begin_unconstrained_fwd), + + act_interface_inherits ( + f.interface (), &SemanticAction::Interface::inherits), + + act_interface_open_scope ( + f.interface (), &SemanticAction::Scope::open_scope), + + act_interface_close_scope ( + f.interface (), &SemanticAction::Scope::close_scope), + + act_interface_end (f.interface (), &SemanticAction::Interface::end), + + + // Member + // + // + act_member_type ( + f.member (), &SemanticAction::Member::type), + + act_member_name ( + f.member (), &SemanticAction::Member::name), + + act_member_end ( + f.member (), &SemanticAction::Member::end), + + + // Module + // + // + act_module_begin (f.module (), &SemanticAction::Module::begin), + + act_module_open_scope ( + f.module (), &SemanticAction::Scope::open_scope), + + act_module_close_scope ( + f.module (), &SemanticAction::Scope::close_scope), + + act_module_end (f.module (), &SemanticAction::Module::end), + + + // Native + // + // + act_native_name ( + f.native (), &SemanticAction::Native::name), + + act_native_end ( + f.native (), &SemanticAction::Native::end), + + + // Operation + // + // + act_operation_one_way ( + f.operation (), &SemanticAction::Operation::one_way), + + act_operation_two_way ( + f.operation (), &SemanticAction::Operation::two_way), + + act_operation_type ( + f.operation (), &SemanticAction::Operation::type), + + act_operation_name ( + f.operation (), &SemanticAction::Operation::name), + + act_operation_parameter ( + this, &Parser::act_operation_parameter_core), + + act_operation_raises ( + f.operation (), &SemanticAction::Operation::raises), + + + // Struct + // + // + act_struct_begin_def ( + f.struct_ (), &SemanticAction::Struct::begin_def), + + act_struct_begin_fwd ( + f.struct_ (), &SemanticAction::Struct::begin_fwd), + + act_struct_open_scope ( + f.struct_ (), &SemanticAction::Scope::open_scope), + + act_struct_close_scope ( + f.struct_ (), &SemanticAction::Scope::close_scope), + + act_struct_end (f.struct_ (), &SemanticAction::Struct::end), + + + // Typedef + // + // + act_typedef_pre ( + f.typedef_ (), &SemanticAction::Typedef::pre), + + act_typedef_begin ( + f.typedef_ (), &SemanticAction::Typedef::begin), + + act_typedef_begin_unbounded_seq ( + f.typedef_ (), &SemanticAction::Typedef::begin_unbounded_seq), + + act_typedef_begin_bounded_seq ( + f.typedef_ (), &SemanticAction::Typedef::begin_bounded_seq), + + act_typedef_begin_bounded_string ( + f.typedef_ (), &SemanticAction::Typedef::begin_bounded_string), + + act_typedef_begin_bounded_wstring ( + f.typedef_ (), &SemanticAction::Typedef::begin_bounded_wstring), + + act_typedef_begin_array ( + f.typedef_ (), &SemanticAction::Typedef::begin_array), + + act_typedef_bound ( + f.typedef_ (), &SemanticAction::Typedef::bound), + + act_typedef_declarator ( + f.typedef_ (), &SemanticAction::Typedef::declarator), + + act_typedef_end ( + f.typedef_ (), &SemanticAction::Typedef::end), + + + // TypeId + // + // + act_type_id_begin (f.type_id (), &SemanticAction::TypeId::begin), + act_type_id_end (f.type_id (), &SemanticAction::TypeId::end), + + + // TypePrefix + // + // + act_type_prefix_begin (f.type_prefix (), + &SemanticAction::TypePrefix::begin), + + act_type_prefix_end (f.type_prefix (), + &SemanticAction::TypePrefix::end), + + // Union + // + // + act_union_begin_def ( + f.union_ (), &SemanticAction::Union::begin_def), + + act_union_begin_fwd ( + f.union_ (), &SemanticAction::Union::begin_fwd), + + act_union_type ( + f.union_ (), &SemanticAction::Union::type), + + act_union_open_scope ( + f.union_ (), &SemanticAction::Scope::open_scope), + + act_union_member_type ( + f.union_ (), &SemanticAction::Union::member_type), + + act_union_member_name ( + f.union_ (), &SemanticAction::Union::member_name), + + act_union_close_scope ( + f.union_ (), &SemanticAction::Scope::close_scope), + + act_union_end ( + f.union_ (), &SemanticAction::Union::end), + + + // ValueType + // + // + act_value_type_begin_abstract_def ( + f.value_type (), &SemanticAction::ValueType::begin_abstract_def), + + act_value_type_begin_abstract_fwd ( + f.value_type (), &SemanticAction::ValueType::begin_abstract_fwd), + + act_value_type_begin_concrete_def ( + f.value_type (), &SemanticAction::ValueType::begin_concrete_def), + + act_value_type_begin_concrete_fwd ( + f.value_type (), &SemanticAction::ValueType::begin_concrete_fwd), + + act_value_type_inherits ( + f.value_type (), &SemanticAction::ValueType::inherits), + + act_value_type_supports ( + f.value_type (), &SemanticAction::ValueType::supports), + + act_value_type_open_scope ( + f.value_type (), &SemanticAction::Scope::open_scope), + + act_value_type_close_scope ( + f.value_type (), &SemanticAction::Scope::close_scope), + + act_value_type_end ( + f.value_type (), &SemanticAction::ValueType::end), + + + // ValueTypeFactory + // + act_value_type_factory_name ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::name), + + act_value_type_factory_parameter ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::parameter), + + act_value_type_factory_raises ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::raises), + + + + // ValueTypeMember + // + act_value_type_member_begin_private ( + f.value_type_member (), + &SemanticAction::ValueTypeMember::begin_private), + + act_value_type_member_begin_public ( + f.value_type_member (), + &SemanticAction::ValueTypeMember::begin_public), + + act_value_type_member_type ( + f.value_type_member (), &SemanticAction::ValueTypeMember::type), + + act_value_type_member_name ( + f.value_type_member (), &SemanticAction::ValueTypeMember::name), + + act_value_type_member_end ( + f.value_type_member (), &SemanticAction::ValueTypeMember::end) + + { + language = + guard + ( + guard + ( + assertion ("declaration or include directive expected", + DiagnosticType::BEFORE) + ( + (+import >> *declaration) + | +declaration + ) + >> assertion ("declaration or include directive expected", + DiagnosticType::BEFORE) + ( + EOS + ) + )[error_handler] + )[root_error_handler] // Stops bailing out (rethrowing). + ; + + import = include_decl + ; + + include_decl = + ( + (QINCLUDE >> string_literal[act_include_quote]) + | (BINCLUDE >> string_literal[act_include_bracket]) + ) + >> SEMI[act_include_end] + ; + + // There are two classes of types: The first class includes + // interface and valuetype. The second class includes all + // other types like struct, etc. I wonder how I can represent + // it in the grammar. + // + + declaration = + abstract_type_decl + | const_decl + | extension + | local_type_decl + | module_decl + | type_decl + | type_id_decl + | type_prefix_decl + | unconstrained_interface_decl + | concrete_value_type_decl + ; + + type_decl = + enum_decl + | exception_decl + | native_decl + | struct_decl + | typedef_decl + | union_decl + ; + + type_id_decl = + TYPEID + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("string literal expected", + DiagnosticType::BEFORE) + ( + string_literal + ) + )[act_type_id_begin] + + >> assertion ("';' expected", + f.type_id (), + &SemanticAction::TypeId::end, + RecoveryMethod::NONE) + ( + SEMI[act_type_id_end] + ) + )[error_handler] + ; + + type_prefix_decl = + TYPEPREFIX + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("string literal expected", + DiagnosticType::BEFORE) + ( + string_literal + ) + )[act_type_prefix_begin] + + >> assertion ("';' expected", + f.type_prefix (), + &SemanticAction::TypePrefix::end, + RecoveryMethod::NONE) + ( + SEMI[act_type_prefix_end] + ) + )[error_handler] + ; + + abstract_type_decl = + ABSTRACT + >> guard + ( + assertion ("interface or valuetype declaration expected") + ( + (INTERFACE >> abstract_interface_decl) + | + (VALUETYPE >> abstract_value_type_decl) + ) + )[error_handler] + ; + + local_type_decl = + LOCAL + >> guard + ( + assertion ("interface declaration expected") + ( + INTERFACE >> local_interface_decl + ) + )[error_handler] + ; + + module_decl = + MODULE + >> guard + ( + assertion ("module name expected") + ( + simple_identifier[act_module_begin] + ) + >> assertion ("'{' expected", + f.module (), + &SemanticAction::Module::end) + ( + LCBRACE[act_module_open_scope] + ) + >> assertion ("declaration expected", + f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end, + DiagnosticType::BEFORE) + ( + hood (+declaration) + [ + handler (f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end) + ] + ) + >> assertion ("declaration or '}' expected", + f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end, + DiagnosticType::BEFORE) + ( + RCBRACE[act_module_close_scope] + ) + >> assertion ("';' expected", + f.module (), + &SemanticAction::Module::end, + RecoveryMethod::NONE) + ( + SEMI[act_module_end] + ) + )[error_handler] + ; + + // const + // + // + const_decl = + CONST + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("const name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_const_begin] + >> assertion ("'=' expected") + ( + EQ[act_const_expr_flush] // flush expression stacks + ) + >> assertion ("const expression expected") + ( + const_expr[act_const_expr] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + + // const expression + // + // + + const_expr = + boolean_const_expr + | character_const_expr + | numeric_const_expr + | string_const_expr + ; + + boolean_const_expr = boolean_literal; + + character_const_expr = character_literal; + + string_const_expr = string_literal; + + + // + // + numeric_const_expr = + guard + ( + numeric_or_expr + )[error_handler] + ; + + numeric_or_expr = + numeric_xor_expr + >> *( + OR[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_xor_expr + ) + )[act_numeric_expression_or] + ; + + numeric_xor_expr = + numeric_and_expr + >> *( + XOR[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_and_expr + ) + )[act_numeric_expression_xor] + ; + + + numeric_and_expr = + numeric_shift_expr + >> *( + AND[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_shift_expr + ) + )[act_numeric_expression_and] + ; + + numeric_shift_expr = + numeric_add_expr + >> *( + ( + RSH[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_add_expr + ) + )[act_numeric_expression_rsh] + | + ( + LSH[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_add_expr + ) + )[act_numeric_expression_lsh] + ) + ; + + numeric_add_expr = + numeric_mul_expr + >> *( + ( ADD[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_mul_expr + ) + )[act_numeric_expression_add] + + | + ( SUB[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_mul_expr + ) + )[act_numeric_expression_sub] + ) + ; + + numeric_mul_expr = + numeric_unary_expr + >> *( + ( MUL[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_unary_expr + ) + )[act_numeric_expression_mul] + + | + ( DIV[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_unary_expr + ) + )[act_numeric_expression_div] + + | + ( REM[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_unary_expr + ) + )[act_numeric_expression_rem] + ) + ; + + numeric_unary_expr = + numeric_primary_expr + + | ADD[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_primary_expr[act_numeric_expression_pos] + ) + + | SUB[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_primary_expr[act_numeric_expression_neg] + ) + + | COM[act_numeric_expression_pre] + >> assertion ("expression expected") + ( + numeric_primary_expr[act_numeric_expression_com] + ) + ; + + numeric_primary_expr = + identifier[act_numeric_expression_const] + | integer_literal[act_numeric_expression_integer_literal] + | LPAREN + >> assertion ("expression expected") + ( + numeric_const_expr + ) + >> assertion ("')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ; + + + // enum + // + // + enum_decl = + ENUM + >> guard + ( + assertion ("enum name expected") + ( + simple_identifier[act_enum_begin] + ) + >> hood + ( + assertion ("'{' expected") + ( + LCBRACE + ) + >> enumerator_decl >> *(COMMA >> enumerator_decl) + >> assertion ("',' or '}' expected", + DiagnosticType::BEFORE) + ( + RCBRACE + ) + ) + [ + handler (f.enum_ (), + &SemanticAction::Enum::end) + ] + >> assertion ("';' expected", + f.enum_ (), + &SemanticAction::Enum::end, + RecoveryMethod::NONE) + ( + SEMI[act_enum_end] + ) + )[error_handler] + ; + + enumerator_decl = + assertion ("enumerator name expected") + ( + simple_identifier[act_enum_enumerator] + ) + ; + + + // interface + // + // + abstract_interface_decl = + guard + ( + assertion ("abstract interface declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_interface_begin_abstract_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_interface_begin_abstract_def] + + >> hood + ( + interface_inheritance_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_interface_open_scope] + ) + >> hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_interface_begin_abstract_def][act_interface_open_scope] + + >> hood + ( + hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + ) + )[error_handler] + ; + + local_interface_decl = + guard + ( + assertion ("local interface declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_interface_begin_local_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_interface_begin_local_def] + + >> hood + ( + interface_inheritance_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_interface_open_scope] + ) + >> hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_interface_begin_local_def][act_interface_open_scope] + + >> hood + ( + hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + ) + )[error_handler] + ; + + unconstrained_interface_decl = + INTERFACE + >> guard + ( + assertion ("interface declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_interface_begin_unconstrained_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_interface_begin_unconstrained_def] + + >> hood + ( + interface_inheritance_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_interface_open_scope] + ) + >> hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_interface_begin_unconstrained_def][act_interface_open_scope] + + >> hood + ( + hood (interface_body) + [ + handler (f.interface (), + &SemanticAction::Interface::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_interface_close_scope] + ) + ) + [ + handler (f.interface (), + &SemanticAction::Interface::end) + ] + + >> assertion ("';' expected", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + ) + )[error_handler] + ; + + interface_inheritance_spec = + guard + ( + assertion ("base interface name expected") + ( + identifier[act_interface_inherits] + ) + >> *( + COMMA + >> assertion ("base eventtype name expected") + ( + identifier[act_interface_inherits] + ) + ) + )[error_handler] + ; + + interface_body = + *( + const_decl + | type_decl + | type_id_decl + | type_prefix_decl + + | attribute_decl + | operation_decl + ) + ; + + + // attribute + // + // + attribute_decl = + guard + ( + ( + ( + READONLY + >> assertion ("'attribute' expected") + ( + ATTRIBUTE + ) + )[act_attribute_begin_ro] + + >> hood (attribute_ro_decl_trailer) + [ + handler (f.attribute (), + &SemanticAction::Attribute::end) + ] + >> assertion ("';' expected", + f.attribute (), + &SemanticAction::Attribute::end, + RecoveryMethod::NONE) + ( + SEMI[act_attribute_end] + ) + ) + | + ( + ATTRIBUTE[act_attribute_begin_rw] + >> hood (attribute_rw_decl_trailer) + [ + handler (f.attribute (), + &SemanticAction::Attribute::end) + ] + >> assertion ("';' expected", + f.attribute (), + &SemanticAction::Attribute::end, + RecoveryMethod::NONE) + ( + SEMI[act_attribute_end] + ) + ) + )[error_handler] + ; + + + attribute_ro_decl_trailer = + assertion ("attribute type name expected") + ( + identifier[act_attribute_type] + ) + >> assertion ("attribute name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_attribute_name] + ) + >> !( + attribute_ro_raises_spec + | + +( + COMMA + >> assertion ("attribute name expected") + ( + simple_identifier[act_attribute_name] + ) + ) + ) + ; + + attribute_rw_decl_trailer = + assertion ("attribute type name expected") + ( + identifier[act_attribute_type] + ) + >> assertion ("attribute name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_attribute_name] + ) + >> !( + attribute_rw_raises_spec + | + +( + COMMA + >> assertion ("attribute name expected") + ( + simple_identifier[act_attribute_name] + ) + ) + ) + ; + + attribute_ro_raises_spec = + RAISES + >> attribute_get_raises_list; + + + attribute_rw_raises_spec = + ( + (GETRAISES >> attribute_get_raises_list) + >> !(SETRAISES >> attribute_set_raises_list) + ) + | + (SETRAISES >> attribute_set_raises_list) + ; + + attribute_get_raises_list = + assertion ("'(' expected") + ( + LPAREN + ) + >> assertion ("exception name expected") + ( + identifier[act_attribute_get_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_attribute_get_raises] + ) + ) + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ; + + attribute_set_raises_list = + assertion ("'(' expected") + ( + LPAREN + ) + >> assertion ("exception name expected") + ( + identifier[act_attribute_set_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_attribute_set_raises] + ) + ) + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ; + + + // exception + // + // + exception_decl = + EXCEPTION + >> guard + ( + assertion ("exception name expected") + ( + simple_identifier[act_exception_begin] + ) + >> hood + ( + assertion ("'{' expected") + ( + LCBRACE[act_exception_open_scope] + ) + >> hood (exception_body) + [ + handler (f.exception (), + &SemanticAction::Exception::close_scope) + ] + >> assertion ("member declaration or '}' expected", + f.exception (), + &SemanticAction::Exception::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_exception_close_scope] + ) + ) + [ + handler (f.exception (), + &SemanticAction::Exception::end) + ] + >> assertion ("';' expected", + f.exception (), + &SemanticAction::Exception::end, + RecoveryMethod::NONE) + ( + SEMI[act_exception_end] + ) + )[error_handler] + ; + + exception_body = + *member_decl + ; + + + // direction specifier + // + // + direction_specifier = + IN + | OUT + | INOUT + ; + + + // member + // + // + member_decl = + identifier[act_member_type] + >> guard + ( + hood + ( + assertion ("member name expected") + ( + simple_identifier[act_member_name] + ) + >> *( + COMMA + >> assertion ("member name expected") + ( + simple_identifier[act_member_name] + ) + ) + ) + [ + handler (f.member (), + &SemanticAction::Member::end) + ] + >> assertion ("';' expected", + f.member (), + &SemanticAction::Member::end, + RecoveryMethod::NONE) + ( + SEMI[act_member_end] + ) + )[error_handler] + ; + + // native + // + // + native_decl = + NATIVE + >> guard + ( + assertion ("native name expected") + ( + simple_identifier[act_native_name] + ) + >> assertion ("';' expected", + f.native (), + &SemanticAction::Native::end, + RecoveryMethod::NONE) + ( + SEMI[act_native_end] + ) + )[error_handler] + ; + + + // operation + // + // + operation_decl = + guard + ( + ( + ( + ONEWAY[act_operation_one_way] + >> assertion ("operation return type name expected") + ( + identifier[act_operation_type] + ) + ) + | + ( + identifier[act_operation_two_way][act_operation_type] + ) + ) + >> operation_decl_trailer + )[error_handler] + ; + + + operation_decl_trailer = + assertion ("operation name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_operation_name] + ) + >> assertion ("'(' expected") + ( + LPAREN + ) + >> operation_parameter_list + >> assertion ("parameter declaration or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> !( + RAISES + >> assertion ("'(' expected") + ( + LPAREN + ) + >> operation_raises_list + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + ; + + operation_parameter_list = + *( + operation_parameter + >> *( + COMMA + >> assertion ("parameter declaration expected") + ( + operation_parameter + ) + ) + ) + ; + + operation_parameter = + ( + direction_specifier + >> assertion ("parameter type name expected") + ( + identifier + ) + >> assertion ("parameter name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_operation_parameter] + ; + + operation_raises_list = + assertion ("exception name expected") + ( + identifier[act_operation_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_operation_raises] + ) + ) + ; + + + // struct + // + // + struct_decl = + STRUCT + >> guard + ( + assertion ("struct declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_struct_begin_fwd][act_struct_end] + | + ( + ( + simple_identifier + >> LCBRACE + )[act_struct_begin_def][act_struct_open_scope] + >> hood + ( + hood + ( + assertion ("member declaration expected", + DiagnosticType::BEFORE) + ( + struct_body + ) + ) + [ + handler (f.struct_ (), + &SemanticAction::Struct::close_scope) + ] + >> assertion ("member declaration or '}' expected", + f.struct_ (), + &SemanticAction::Struct::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_struct_close_scope] + ) + ) + [ + handler (f.struct_ (), + &SemanticAction::Struct::end) + ] + >> assertion ("';' expected", + f.struct_ (), + &SemanticAction::Struct::end, + RecoveryMethod::NONE) + ( + SEMI[act_struct_end] + ) + ) + ) + )[error_handler] + ; + + struct_body = + +member_decl + ; + + + // typedef + // + // + + typedef_decl = + TYPEDEF[act_typedef_pre] + >> guard + ( + assertion ("type name expected") + ( + typedef_type_spec + ) + >> typedef_declarator + >> *(COMMA >> typedef_declarator) + >> assertion ("';' expected", + f.typedef_ (), + &SemanticAction::Typedef::end, + RecoveryMethod::NONE) + ( + SEMI[act_typedef_end] + ) + )[error_handler] + ; + + typedef_declarator = + ( + assertion ("typedef name expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + simple_identifier + ) + >> !( LSBRACE[act_typedef_begin_array][act_const_expr_flush] + >> assertion ("const expression expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + numeric_const_expr[act_typedef_bound] + ) + >> assertion ("']' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + RSBRACE + ) + ) + >> *( LSBRACE[act_const_expr_flush] + >> assertion ("const expression expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + numeric_const_expr[act_typedef_bound] + ) + >> assertion ("']' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + RSBRACE + ) + ) + )[act_typedef_declarator] + ; + + typedef_type_spec = + identifier[act_typedef_begin] + | + ( + SEQUENCE + >> assertion ("'<' expected") + ( + LT + ) + >> ( + (identifier >> GT)[act_typedef_begin_unbounded_seq] + | + ( + assertion ("sequence type name expected") + ( + identifier[act_typedef_begin_bounded_seq] + ) + >> assertion ("'>' or ',' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + COMMA[act_const_expr_flush] // flush expression stacks + ) + >> assertion ("const expression expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + numeric_const_expr[act_typedef_bound] + ) + >> assertion ("'>' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + GT + ) + ) + ) + ) + | + ( + STRING + >> assertion ("'<' expected") + ( + LT[act_const_expr_flush] // flush expression stacks + ) + >> assertion ("const expression expected") + ( + numeric_const_expr[act_typedef_begin_bounded_string] + ) + >> assertion ("'>' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + GT + ) + ) + | + ( + WSTRING + >> assertion ("'<' expected") + ( + LT[act_const_expr_flush] // flush expression stacks + ) + >> assertion ("const expression expected") + ( + numeric_const_expr[act_typedef_begin_bounded_wstring] + ) + >> assertion ("'>' expected", + f.typedef_ (), + &SemanticAction::Typedef::end) + ( + GT + ) + ) + ; + + // union + // + // + + union_decl = + UNION + >> guard + ( + assertion ("union declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_union_begin_fwd][act_union_end] + | + ( + ( + simple_identifier + >> SWITCH + )[act_union_begin_def] + + >> hood (union_def_trailer) + [ + handler (f.union_ (), + &SemanticAction::Union::end) + ] + >> assertion ("';' expected", + f.union_ (), + &SemanticAction::Union::end, + RecoveryMethod::NONE) + ( + SEMI[act_union_end] + ) + ) + ) + )[error_handler] + ; + + union_def_trailer = + assertion ("'(' expected") + ( + LPAREN + ) + >> assertion ("discriminator type name expected") + ( + identifier[act_union_type] + ) + >> assertion ("')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> assertion ("'{' expected") + ( + LCBRACE[act_union_open_scope] + ) + >> hood + ( + assertion ("case statement expected") + ( + union_body + ) + ) + [ + handler (f.union_ (), + &SemanticAction::Union::close_scope) + ] + >> assertion ("case statement or \'}\' expected", + f.union_ (), + &SemanticAction::Union::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_union_close_scope] + ) + ; + + + union_body = + +guard + ( + +union_case_label + >> assertion ("type name expected", + DiagnosticType::BEFORE) + ( + identifier[act_union_member_type] + ) + >> assertion ("member name expected") + ( + simple_identifier[act_union_member_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + union_case_label = + ( + CASE[act_const_expr_flush] // flush expression stacks + >> assertion ("const expression expected") + ( + const_expr + ) + >> assertion ("':' expected") + ( + COLON + ) + ) + | + ( DEFAULT + >> assertion ("':' expected") + ( + COLON + ) + ) + ; + + + // valuetype + // + // + abstract_value_type_decl = + guard + ( + assertion ("abstract valuetype declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_value_type_begin_abstract_fwd][act_value_type_end] + | + ( + ( + simple_identifier + >> COLON + )[act_value_type_begin_abstract_def] + + >> hood + ( + value_type_inheritance_spec + >> !(SUPPORTS >> value_type_supports_spec) + >> assertion ("'{' expected") + ( + LCBRACE[act_value_type_open_scope] + ) + >> hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_value_type_begin_abstract_def] + + >> hood + ( + value_type_supports_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_value_type_open_scope] + ) + >> hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_value_type_begin_abstract_def][act_value_type_open_scope] + + >> hood + ( + hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + ) + )[error_handler] + ; + + + concrete_value_type_decl = + VALUETYPE + >> guard + ( + assertion ("valuetype declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_value_type_begin_concrete_fwd][act_value_type_end] + | + ( + ( + simple_identifier + >> COLON + )[act_value_type_begin_concrete_def] + + >> hood + ( + value_type_inheritance_spec + >> !(SUPPORTS >> value_type_supports_spec) + >> assertion ("'{' expected") + ( + LCBRACE[act_value_type_open_scope] + ) + >> hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_value_type_begin_concrete_def] + + >> hood + ( + value_type_supports_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_value_type_open_scope] + ) + >> hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_value_type_begin_concrete_def][act_value_type_open_scope] + + >> hood + ( + hood (value_type_body) + [ + handler (f.value_type (), + &SemanticAction::ValueType::close_scope) + ] + >> assertion ("declaration or '}' expected", + f.value_type (), + &SemanticAction::ValueType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_value_type_close_scope] + ) + ) + [ + handler (f.value_type (), + &SemanticAction::ValueType::end) + ] + + >> assertion ("';' expected", + f.value_type (), + &SemanticAction::ValueType::end, + RecoveryMethod::NONE) + ( + SEMI[act_value_type_end] + ) + ) + ) + )[error_handler] + ; + + value_type_inheritance_spec = + guard + ( + assertion ("base valuetype name expected") + ( + identifier[act_value_type_inherits] + ) + >> *( + COMMA + >> assertion ("base valuetype name expected") + ( + identifier[act_value_type_inherits] + ) + ) + )[error_handler] + ; + + value_type_supports_spec = + guard + ( + assertion ("supported interface name expected") + ( + identifier[act_value_type_supports] + ) + >> *( + COMMA + >> assertion ("supported interface name expected") + ( + identifier[act_value_type_supports] + ) + ) + )[error_handler] + ; + + value_type_body = + *( + const_decl + | type_decl + | type_id_decl + | type_prefix_decl + + | attribute_decl + | operation_decl + | value_type_member_decl + | value_type_factory_decl + ) + ; + + + // valuetype factory + // + // + value_type_factory_decl = + FACTORY + >> guard + ( + assertion ("factory name expected") + ( + simple_identifier[act_value_type_factory_name] + ) + >> assertion ("'(' expected") + ( + LPAREN + ) + >> value_type_factory_parameter_list + >> assertion ("parameter declaration or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> !( + RAISES + >> assertion ("'(' expected") + ( + LPAREN + ) + >> value_type_factory_raises_list + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + value_type_factory_parameter_list = + *( + value_type_factory_parameter + >> *(COMMA >> value_type_factory_parameter) + ) + ; + + value_type_factory_parameter = + IN + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("parameter name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_value_type_factory_parameter] + )[error_handler] + ; + + value_type_factory_raises_list = + guard + ( + assertion ("exception name expected") + ( + identifier[act_value_type_factory_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_value_type_factory_raises] + ) + ) + )[error_handler] + ; + + + // valuetype member + // + // + value_type_member_decl = + ( + PUBLIC[act_value_type_member_begin_public] + | PRIVATE[act_value_type_member_begin_private] + ) + >> guard + ( + assertion ("type name expected") + ( + identifier[act_value_type_member_type] + ) + >> assertion ("member name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_value_type_member_name] + ) + >> *( + COMMA + >> assertion ("member name expected") + ( + simple_identifier[act_value_type_member_name] + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Parser.hpp b/CIAO/CCF/CCF/IDL2/Parser.hpp new file mode 100644 index 00000000000..2a6e6b92b01 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Parser.hpp @@ -0,0 +1,872 @@ +// file : CCF/IDL2/Parser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSER_HPP +#define CCF_IDL2_PARSER_HPP + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" + +#include "CCF/IDL2/SemanticAction.hpp" +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +#include "CCF/IDL2/Parsing/Elements.hpp" +#include "CCF/IDL2/Parsing/Action.hpp" +#include "CCF/IDL2/Parsing/Recovery.hpp" + +// #$%^ing MS. +// +#ifdef CONST +#undef CONST +#undef FACTORY +#undef IN +#undef OUT +#endif + + +namespace CCF +{ + namespace IDL2 + { + using Parsing::ActionExecutor; + using Parsing::NoArgAction; + using Parsing::OneArgAction; + using Parsing::TwoArgAction; + + class Parser + { + public: + virtual + ~Parser (); + + protected: + Diagnostic::Stream& dout_; + LexicalAnalyzer const& lexer_; + SemanticAction::Factory& actions_; + + protected: + typedef + Parsing::Iterator + Iterator; + + // + // Primitives + // + + typedef + Parsing::EndOfStreamParser + EndOfStreamParser; + + typedef + Parsing::KeywordParser + KeywordParser; + + typedef + Parsing::PunctuationParser + PunctuationParser; + + typedef + Parsing::OperatorParser + OperatorParser; + + typedef + Parsing::IdentifierParser + IdentifierParser; + + typedef + Parsing::SimpleIdentifierParser + SimpleIdentifierParser; + + + typedef + Parsing::RecoveryDescriptor + RecoveryDescriptor; + + typedef + Parsing::Assertion + Assertion; + + typedef + Parsing::RecoveryStatus + RecoveryStatus; + + typedef + Parsing::Guard + Guard; + + //@@ names are not thought out weel for error handling + + struct ErrorHandler + { + ErrorHandler (CompilerElements::Context& context, + Diagnostic::Stream& dout) + : dout_ (dout), + context_ (context) + { + } + + RecoveryStatus + operator() (Parsing::Scanner const& s, Parsing::Error e) const + { + Iterator i = e.where; + + switch (e.descriptor->diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << e.descriptor->description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + i--; + + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "after \'" << (*i)->lexeme () << "\': " + << e.descriptor->description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + if (e.descriptor->action_one_.get ()) + e.descriptor->action_one_->execute (); + + if (e.descriptor->action_two_.get ()) + e.descriptor->action_two_->execute (); + + switch (e.descriptor->recovery_) + { + case Parsing::RecoveryMethod::STANDARD: + { + unsigned long balance = 0; + + for (Iterator t = e.where; t != s.last; t++) + { + //std::cerr << "error recovery: skipping " << (*t)->lexeme () + // << std::endl; + + if ((*t)->lexeme () == "{") balance++; + else if ((*t)->lexeme () == "}") + { + if (balance > 0) balance--; + else + { + t++; + if ((*t)->lexeme () == ";") t++; + + int length = t - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + if (balance == 0 && (*t)->lexeme () == ";") + { + int length = t - s.first + 1; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + switch (e.descriptor->diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "after \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + e.descriptor->recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor->diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor->action_one_.reset (); + e.descriptor->action_two_.reset (); + + // return RecoveryStatus (RecoveryStatus::rethrow); + throw e; + } + case Parsing::RecoveryMethod::NONE: + default: + { + int length = e.where - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + case Parsing::RecoveryMethod::BAIL_OUT: + { + e.descriptor->recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor->diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor->action_one_.reset (); + e.descriptor->action_two_.reset (); + + // return RecoveryStatus (RecoveryStatus::rethrow); + throw e; + } + } + } + + Diagnostic::Stream& dout_; + CompilerElements::Context& context_; + }; + + struct RootErrorHandler + { + RecoveryStatus + operator() (Parsing::Scanner const&, Parsing::Error&) const + { + return RecoveryStatus (RecoveryStatus::fail); + } + }; + + struct handler + { + template<typename Object> + handler (Object& obj, + void (Object::*action_one)()) + : action_one_ (Parsing::call_thunk (obj, action_one)), + action_two_ (0) + { + } + + template<typename Object> + handler (Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)()) + : action_one_ (Parsing::call_thunk (obj, action_one)), + action_two_ (Parsing::call_thunk (obj, action_two)) + { + } + + handler (handler const& h) + : action_one_ (h.action_one_.get () ? h.action_one_->clone () : 0), + action_two_ (h.action_two_.get () ? h.action_two_->clone () : 0) + { + } + + RecoveryStatus + operator() (Parsing::Scanner const&, Parsing::Error e) const + { + /* + assert ( + e.descriptor->diagnostic_ == Parsing::DiagnosticType::NONE && + e.descriptor->recovery_ == Parsing::RecoveryMethod::BAIL_OUT + ); + */ + + if (action_one_.get ()) action_one_->execute (); + if (action_two_.get ()) action_two_->execute (); + + // return RecoveryStatus (RecoveryStatus::rethrow); + throw e; + } + + std::auto_ptr<Parsing::Thunk> action_one_; + std::auto_ptr<Parsing::Thunk> action_two_; + }; + + Guard guard; + Guard hood; + Assertion assertion; + ErrorHandler error_handler; + RootErrorHandler root_error_handler; + + // End of stream parser. + // + EndOfStreamParser EOS; + + // Keyword parsers (alphabetic order). + // + KeywordParser ABSTRACT; + KeywordParser ATTRIBUTE; + KeywordParser BINCLUDE; + KeywordParser CASE; + KeywordParser CONST; + KeywordParser CUSTOM; + KeywordParser DEFAULT; + KeywordParser ENUM; + KeywordParser EXCEPTION; + KeywordParser FACTORY; + KeywordParser GETRAISES; + KeywordParser IN; + KeywordParser INOUT; + KeywordParser INTERFACE; + KeywordParser QINCLUDE; + KeywordParser LOCAL; + KeywordParser MODULE; + KeywordParser NATIVE; + KeywordParser ONEWAY; + KeywordParser OUT; + KeywordParser PRIVATE; + KeywordParser PUBLIC; + KeywordParser RAISES; + KeywordParser READONLY; + KeywordParser SEQUENCE; + KeywordParser SETRAISES; + KeywordParser STRING; + KeywordParser STRUCT; + KeywordParser SUPPORTS; + KeywordParser SWITCH; + KeywordParser TRUNCATABLE; + KeywordParser TYPEDEF; + KeywordParser TYPEID; + KeywordParser TYPEPREFIX; + KeywordParser UNION; + KeywordParser VALUETYPE; + KeywordParser WSTRING; + + // Punctuation parsers (alphabetic group order). + // + PunctuationParser COLON; + PunctuationParser COMMA; + PunctuationParser LCBRACE; + PunctuationParser RCBRACE; + PunctuationParser LSBRACE; + PunctuationParser RSBRACE; + PunctuationParser LPAREN; + PunctuationParser RPAREN; + PunctuationParser LT; + PunctuationParser GT; + PunctuationParser SEMI; + + OperatorParser ADD; + OperatorParser AND; + OperatorParser COM; + OperatorParser DIV; + OperatorParser EQ; + OperatorParser LSH; + OperatorParser MUL; + OperatorParser OR; + OperatorParser REM; + OperatorParser SUB; + OperatorParser RSH; + OperatorParser XOR; + + + IdentifierParser identifier; + SimpleIdentifierParser simple_identifier; + + Parsing::BooleanLiteralParser boolean_literal; + Parsing::CharacterLiteralParser character_literal; + Parsing::IntegerLiteralParser integer_literal; + Parsing::StringLiteralParser string_literal; + + // + // Language + // + typedef + Parsing::Rule + Rule; + + Rule language; + Rule import; + Rule declaration; + Rule extension; + + Rule include_decl; + + Rule type_decl; + + Rule module_decl; + + Rule const_decl; + Rule const_expr; + + Rule enum_decl; + Rule enumerator_decl; + + Rule boolean_const_expr; + Rule character_const_expr; + Rule numeric_const_expr; + + Rule numeric_or_expr; + Rule numeric_xor_expr; + Rule numeric_and_expr; + Rule numeric_shift_expr; + Rule numeric_add_expr; + Rule numeric_mul_expr; + Rule numeric_unary_expr; + Rule numeric_primary_expr; + + Rule string_const_expr; + + Rule abstract_type_decl; + Rule local_type_decl; + + Rule abstract_interface_decl; + Rule local_interface_decl; + Rule unconstrained_interface_decl; + Rule interface_inheritance_spec; + Rule interface_body; + + Rule attribute_decl; + Rule attribute_ro_decl_trailer; + Rule attribute_rw_decl_trailer; + Rule attribute_ro_raises_spec; + Rule attribute_rw_raises_spec; + Rule attribute_get_raises_list; + Rule attribute_set_raises_list; + + Rule exception_decl; + Rule exception_body; + + Rule direction_specifier; + + Rule member_decl; + + Rule native_decl; + + Rule operation_decl; + Rule operation_decl_trailer; + Rule operation_parameter_list; + Rule operation_parameter; + Rule operation_raises_list; + + Rule struct_decl; + Rule struct_body; + + Rule typedef_decl; + Rule typedef_declarator; + Rule typedef_type_spec; + + Rule type_id_decl; + Rule type_prefix_decl; + + Rule union_decl; + Rule union_def_trailer; + Rule union_body; + Rule union_case_label; + + Rule abstract_value_type_decl; + Rule concrete_value_type_decl; + Rule value_type_inheritance_spec; + Rule value_type_supports_spec; + Rule value_type_body; + + Rule value_type_factory_decl; + Rule value_type_factory_parameter_list; + Rule value_type_factory_parameter; + Rule value_type_factory_raises_list; + + Rule value_type_member_decl; + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + virtual Rule const& + start() const + { + return language; + } + + protected: + + // + // Semantic actions + // + typedef + NoArgAction<SemanticAction::Scope> + ScopeAction; + + + // Attribute + // + // + NoArgAction<SemanticAction::Attribute> + act_attribute_begin_ro, act_attribute_begin_rw; + + OneArgAction<IdentifierPtr, SemanticAction::Attribute> + act_attribute_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Attribute> + act_attribute_name; + + OneArgAction<IdentifierPtr, SemanticAction::Attribute> + act_attribute_get_raises; + + OneArgAction<IdentifierPtr, SemanticAction::Attribute> + act_attribute_set_raises; + + NoArgAction<SemanticAction::Attribute> + act_attribute_end; + + // Const + // + TwoArgAction<IdentifierPtr, SimpleIdentifierPtr, SemanticAction::Const> + act_const_begin; + + NoArgAction<SemanticAction::Const> + act_const_expr; + + + // Enum + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Enum> + act_enum_begin, act_enum_enumerator; + + NoArgAction<SemanticAction::Enum> + act_enum_end; + + // Expression + // + NoArgAction<SemanticAction::NumericExpression> + act_const_expr_flush; + + OneArgAction<IdentifierPtr, SemanticAction::NumericExpression> + act_numeric_expression_const; + + OneArgAction<IntegerLiteralPtr, SemanticAction::NumericExpression> + act_numeric_expression_integer_literal; + + OneArgAction<OperatorPtr, SemanticAction::NumericExpression> + act_numeric_expression_pre; + + NoArgAction<SemanticAction::NumericExpression> + act_numeric_expression_pos, + act_numeric_expression_neg, + act_numeric_expression_com, + act_numeric_expression_mul, + act_numeric_expression_div, + act_numeric_expression_rem, + act_numeric_expression_add, + act_numeric_expression_sub, + act_numeric_expression_rsh, + act_numeric_expression_lsh, + act_numeric_expression_and, + act_numeric_expression_xor, + act_numeric_expression_or; + + + // Exception + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Exception> + act_exception_begin; + + ScopeAction + act_exception_open_scope; + + ScopeAction + act_exception_close_scope; + + NoArgAction<SemanticAction::Exception> + act_exception_end; + + + // Include + // + // + OneArgAction<StringLiteralPtr, SemanticAction::Include> + act_include_quote, act_include_bracket; + + NoArgAction<SemanticAction::Include> + act_include_end; + + // Interface + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Interface> + act_interface_begin_abstract_def, + act_interface_begin_abstract_fwd, + act_interface_begin_local_def, + act_interface_begin_local_fwd, + act_interface_begin_unconstrained_def, + act_interface_begin_unconstrained_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::Interface> + act_interface_inherits; + + ScopeAction + act_interface_open_scope; + + ScopeAction + act_interface_close_scope; + + NoArgAction<SemanticAction::Interface> + act_interface_end; + + + // Member + // + // + OneArgAction<IdentifierPtr, SemanticAction::Member> + act_member_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Member> + act_member_name; + + NoArgAction<SemanticAction::Member> + act_member_end; + + + // Module + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Module> + act_module_begin; + + ScopeAction + act_module_open_scope; + + ScopeAction + act_module_close_scope; + + NoArgAction<SemanticAction::Module> + act_module_end; + + // Native + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Native> + act_native_name; + + NoArgAction<SemanticAction::Native> + act_native_end; + + + // Operation + // + // + NoArgAction<SemanticAction::Operation> + act_operation_one_way, act_operation_two_way; + + OneArgAction<IdentifierPtr, SemanticAction::Operation> + act_operation_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Operation> + act_operation_name; + + void + act_operation_parameter_core (Iterator begin, Iterator) const + { + SemanticAction::Operation::Direction::Value d; + + if((*begin)->lexeme () == "in") + { + d = SemanticAction::Operation::Direction::in; + } + else if((*begin)->lexeme () == "out") + { + d = SemanticAction::Operation::Direction::out; + } + else + { + d = SemanticAction::Operation::Direction::inout; + } + + begin++; + + actions_.operation ().parameter ( + d, + ReferenceCounting::strict_cast<Identifier>(*begin), + ReferenceCounting::strict_cast<SimpleIdentifier>(*(begin + 1))); + } + + ActionExecutor<Parser> + act_operation_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::Operation> + act_operation_raises; + + + // Struct + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Struct> + act_struct_begin_def; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Struct> + act_struct_begin_fwd; + + ScopeAction + act_struct_open_scope; + + ScopeAction + act_struct_close_scope; + + NoArgAction<SemanticAction::Struct> + act_struct_end; + + + // Typedef + // + // + OneArgAction<KeywordPtr, SemanticAction::Typedef> + act_typedef_pre; + + OneArgAction<IdentifierPtr, SemanticAction::Typedef> + act_typedef_begin; + + OneArgAction<IdentifierPtr, SemanticAction::Typedef> + act_typedef_begin_unbounded_seq; + + OneArgAction<IdentifierPtr, SemanticAction::Typedef> + act_typedef_begin_bounded_seq; + + NoArgAction<SemanticAction::Typedef> + act_typedef_begin_bounded_string; + + NoArgAction<SemanticAction::Typedef> + act_typedef_begin_bounded_wstring; + + NoArgAction<SemanticAction::Typedef> + act_typedef_begin_array; + + NoArgAction<SemanticAction::Typedef> + act_typedef_bound; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Typedef> + act_typedef_declarator; + + NoArgAction<SemanticAction::Typedef> + act_typedef_end; + + + // TypeId + // + // + TwoArgAction<IdentifierPtr, + StringLiteralPtr, + SemanticAction::TypeId> + act_type_id_begin; + + NoArgAction<SemanticAction::TypeId> + act_type_id_end; + + + // TypePrefix + // + // + TwoArgAction<IdentifierPtr, + StringLiteralPtr, + SemanticAction::TypePrefix> + act_type_prefix_begin; + + NoArgAction<SemanticAction::TypePrefix> + act_type_prefix_end; + + // Union + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Union> + act_union_begin_def, act_union_begin_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::Union> + act_union_type; + + ScopeAction + act_union_open_scope; + + OneArgAction<IdentifierPtr, SemanticAction::Union> + act_union_member_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Union> + act_union_member_name; + + ScopeAction + act_union_close_scope; + + NoArgAction<SemanticAction::Union> + act_union_end; + + + // ValueType + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::ValueType> + act_value_type_begin_abstract_def, + act_value_type_begin_abstract_fwd, + act_value_type_begin_concrete_def, + act_value_type_begin_concrete_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::ValueType> + act_value_type_inherits, act_value_type_supports; + + ScopeAction + act_value_type_open_scope; + + ScopeAction + act_value_type_close_scope; + + NoArgAction<SemanticAction::ValueType> + act_value_type_end; + + + // ValueTypeFactory + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::ValueTypeFactory> + act_value_type_factory_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::ValueTypeFactory> + act_value_type_factory_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::ValueTypeFactory> + act_value_type_factory_raises; + + + // ValueTypeMember + // + NoArgAction<SemanticAction::ValueTypeMember> + act_value_type_member_begin_private; + + NoArgAction<SemanticAction::ValueTypeMember> + act_value_type_member_begin_public; + + OneArgAction<IdentifierPtr, SemanticAction::ValueTypeMember> + act_value_type_member_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::ValueTypeMember> + act_value_type_member_name; + + NoArgAction<SemanticAction::ValueTypeMember> + act_value_type_member_end; + + }; + } +} + +#endif // CCF_IDL2_PARSER_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp new file mode 100644 index 00000000000..2737abafb58 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp @@ -0,0 +1,142 @@ +// file : CCF/IDL2/Parsing/Action.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSING_ACTION_HPP +#define CCF_IDL2_PARSING_ACTION_HPP + +#include "CCF/IDL2/Parsing/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + // + // + // + template <typename Obj> + class ActionExecutor + { + public: + + typedef + void (Obj::*SemanticAction)(Iterator, Iterator) const; + + ActionExecutor (Obj const* obj, SemanticAction action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + (obj_->*action_) (begin, end); + } + + private: + Obj const* obj_; + SemanticAction action_; + }; + + + // + // + // + template <typename Obj> + class NoArgAction + { + public: + + typedef + void (Obj::*Action)(); + + NoArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator, Iterator) const + { + (obj_.*action_) (); + } + + private: + Obj& obj_; + Action action_; + }; + + + //@@ Should prbably use Type instead of TypePtr + // + // + // + template <typename TypePtr, typename Obj> + class OneArgAction + { + public: + + typedef + void (Obj::*Action)(TypePtr const&); + + OneArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + if (end - begin != 1 ) + { + //@@ throw + } + + //@@ error handling if the strict_cast fails + (obj_.*action_) ( + ReferenceCounting::strict_cast<typename TypePtr::Type> (*begin)); + } + + private: + Obj& obj_; + Action action_; + }; + + + // + // + // + template <typename Arg1, typename Arg2, typename Obj> + class TwoArgAction + { + public: + + typedef + void (Obj::*Action)(Arg1 const&, Arg2 const&); + + TwoArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + if (end - begin != 2 ) + { + //@@ throw + } + + //@@ error handling if strict_cast fails + (obj_.*action_) ( + ReferenceCounting::strict_cast<typename Arg1::Type> (*begin), + ReferenceCounting::strict_cast<typename Arg2::Type> (*(begin + 1))); + } + + private: + Obj& obj_; + Action action_; + }; + } + } +} + +#endif // CCF_IDL2_PARSING_ACTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp new file mode 100644 index 00000000000..88e091d8845 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp @@ -0,0 +1,168 @@ +// file : CCF/IDL2/Parsing/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSING_ELEMENTS_HPP +#define CCF_IDL2_PARSING_ELEMENTS_HPP + +#include <string> + +#include <boost/spirit.hpp> + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + using namespace boost::spirit; + + typedef + TokenList::iterator + Iterator; + + typedef + scanner<Iterator, scanner_policies<> > + Scanner; + + typedef + rule<Scanner> + Rule; + + + // + // + // + template <typename Type> + struct IdentityParser : public parser <IdentityParser<Type> > + { + typedef + IdentityParser + self_t; + + IdentityParser (std::string lexeme) + : lexeme_ (lexeme) + { + } + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0 && + lexeme_ == t->lexeme ()) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + + private: + std::string lexeme_; + }; + + typedef + IdentityParser<Keyword> + KeywordParser; + + typedef + IdentityParser<Punctuation> + PunctuationParser; + + typedef + IdentityParser<Operator> + OperatorParser; + + // + // + // + template <typename Type> + struct TypeParser : public parser <TypeParser<Type> > + { + typedef + TypeParser + self_t; + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + }; + + typedef + TypeParser<EndOfStream> + EndOfStreamParser; + + typedef + TypeParser<Identifier> + IdentifierParser; + + typedef + TypeParser<SimpleIdentifier> + SimpleIdentifierParser; + + typedef + TypeParser<ScopedIdentifier> + ScopedIdentifierParser; + + // Literal parsers. + // + + typedef + TypeParser<BooleanLiteral> + BooleanLiteralParser; + + typedef + TypeParser<CharacterLiteral> + CharacterLiteralParser; + + typedef + TypeParser<IntegerLiteral> + IntegerLiteralParser; + + typedef + TypeParser<StringLiteral> + StringLiteralParser; + + // + // + // + inline bool + parse (Iterator const& first_, + Iterator const& last, + Rule const& rule) + { + Iterator first = first_; + Scanner scan(first, last); + match<nil_t> hit = rule.parse(scan); + + bool result = parse_info<Iterator>( + first, hit, hit && (first == last), hit.length()).full; + + return result; + } + } + } +} + +#endif // CCF_IDL2_PARSING_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp b/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp new file mode 100644 index 00000000000..d8b3739b335 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp @@ -0,0 +1,325 @@ +// file : CCF/IDL2/Parsing/Recovery.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSING_RECOVERY_HPP +#define CCF_IDL2_PARSING_RECOVERY_HPP + +#include <memory> + +#include "CCF/CompilerElements/ReferenceCounting.hpp" +#include "CCF/IDL2/Parsing/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + + // + // + // + struct RecoveryMethod + { + enum Value + { + NONE, + STANDARD, + BAIL_OUT + }; + }; + + + // + // + // + struct DiagnosticType + { + enum Value + { + BEFORE, + AFTER, + NONE + }; + }; + + + // + // + // + class Thunk + { + public: + virtual + ~Thunk () {} + + virtual void + execute () = 0; + + virtual Thunk* + clone () const = 0; + }; + + + // + // + // + template<typename Object> + class ThunkImpl : public Thunk + { + public: + typedef void (Object::*Func)(); + + ThunkImpl (Object& obj, Func func) + : obj_(obj), + func_ (func) + { + } + + virtual void + execute () + { + (obj_.*func_)(); + } + + virtual Thunk* + clone () const + { + return new ThunkImpl<Object> (obj_, func_); + } + + private: + Object& obj_; + Func func_; + }; + + // + // + // + template<typename Object> + Thunk* + call_thunk (Object& obj, void (Object::*func)()) + { + return new ThunkImpl<Object> (obj, func); + } + + + // + // + // + struct RecoveryDescriptor : + public virtual ReferenceCounting::DefaultImpl <> + { + virtual ~RecoveryDescriptor () throw () {} + + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic) + : action_one_ (0), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (call_thunk (obj, action_two)), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + RecoveryDescriptor (RecoveryDescriptor const& rd) + : action_one_ (rd.action_one_.get () ? rd.action_one_->clone () : 0), + action_two_ (rd.action_two_.get () ? rd.action_two_->clone () : 0), + description_ (rd.description_), + recovery_ (rd.recovery_), + diagnostic_ (rd.diagnostic_) + { + } + + + std::auto_ptr<Thunk> action_one_; + std::auto_ptr<Thunk> action_two_; + std::string description_; + RecoveryMethod::Value recovery_; + DiagnosticType::Value diagnostic_; + }; + + typedef + ReferenceCounting::StrictPtr<RecoveryDescriptor> + RecoveryDescriptorPtr; + + + // I have to use a pointer to RecoveryDescriptor instead of + // just RecoveryDescriptor to subvert constness of descriptor + // member in spirit::parser_error. + // + // + + typedef + parser_error<RecoveryDescriptorPtr, Iterator> + Error; + + + // + // + // + struct Assertion + { + typedef + assertion<RecoveryDescriptorPtr> + AssertionImpl; + + AssertionImpl + operator () (RecoveryMethod::Value recovery = RecoveryMethod::NONE) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ("", recovery, DiagnosticType::NONE))); + } + + AssertionImpl + operator () (std::string d, + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor (d, recovery, diagnostic))); + } + + AssertionImpl + operator () (std::string d, + DiagnosticType::Value diagnostic) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, RecoveryMethod::STANDARD, diagnostic))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, recovery, diagnostic, obj, action_one))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + DiagnosticType::Value diagnostic) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, RecoveryMethod::STANDARD, diagnostic, obj, action_one))); + } + + template<typename Object> + AssertionImpl + operator () (Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + "", recovery, DiagnosticType::NONE, obj, action_one))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, recovery, diagnostic, obj, action_one, action_two))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + DiagnosticType::Value diagnostic) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, RecoveryMethod::STANDARD, diagnostic, obj, action_one, action_two))); + } + + + template<typename Object> + AssertionImpl + operator () (Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ("", + recovery, + DiagnosticType::NONE, + obj, + action_one, + action_two))); + } + + }; + + typedef + error_status<> + RecoveryStatus; + + typedef + guard<RecoveryDescriptorPtr> + Guard; + } + } +} + +#endif // CCF_IDL2_PARSING_RECOVERY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction.hpp new file mode 100644 index 00000000000..7311cf90910 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction.hpp @@ -0,0 +1,31 @@ +// file : CCF/IDL2/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Const.hpp" +#include "CCF/IDL2/SemanticAction/Enum.hpp" +#include "CCF/IDL2/SemanticAction/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL2/SemanticAction/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Member.hpp" +#include "CCF/IDL2/SemanticAction/Module.hpp" +#include "CCF/IDL2/SemanticAction/Native.hpp" +#include "CCF/IDL2/SemanticAction/NumericExpression.hpp" +#include "CCF/IDL2/SemanticAction/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/TypeId.hpp" +#include "CCF/IDL2/SemanticAction/Union.hpp" +#include "CCF/IDL2/SemanticAction/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeFactory.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeMember.hpp" + +#endif // CCF_IDL2_SEMANTIC_ACTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp new file mode 100644 index 00000000000..9d002fbc3f5 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp @@ -0,0 +1,47 @@ +// file : CCF/IDL2/SemanticAction/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Attribute + { + virtual ~Attribute () + { + } + + virtual void + begin_ro () = 0; + + virtual void + begin_rw () = 0; + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + get_raises (IdentifierPtr const& id) = 0; + + virtual void + set_raises (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Const.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Const.hpp new file mode 100644 index 00000000000..92e1ee09dbe --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Const.hpp @@ -0,0 +1,33 @@ +// file : CCF/IDL2/SemanticAction/Const.hpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_CONST_HPP +#define CCF_IDL2_SEMANTIC_ACTION_CONST_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Const + { + virtual ~Const () + { + } + + virtual void + begin (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + expr () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_CONST_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..3bd1f4bdd99 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL2/SemanticAction/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Scope + { + virtual ~Scope () + { + } + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Enum.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Enum.hpp new file mode 100644 index 00000000000..468da206b6e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Enum.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Enum.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_ENUM_HPP +#define CCF_IDL2_SEMANTIC_ACTION_ENUM_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Enum + { + virtual ~Enum () + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + enumerator (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_ENUM_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp new file mode 100644 index 00000000000..3bd7323c943 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/SemanticAction/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Exception : Scope + { + virtual ~Exception () + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_EXCEPTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..2f84d760710 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp @@ -0,0 +1,104 @@ +// file : CCF/IDL2/SemanticAction/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Attribute; + struct Const; + struct Enum; + struct Exception; + struct Include; + struct Interface; + struct Member; + struct Module; + struct Native; + struct NumericExpression; + struct Operation; + struct Struct; + struct Typedef; + struct TypeId; + struct TypePrefix; + struct Union; + struct ValueType; + struct ValueTypeFactory; + struct ValueTypeMember; + + // + // + // + struct Factory + { + virtual + ~Factory () {} + + virtual Attribute& + attribute () = 0; + + virtual Const& + const_ () = 0; + + virtual SemanticAction::Enum& + enum_ () = 0; + + virtual SemanticAction::Exception& + exception () = 0; + + virtual Include& + include () = 0; + + virtual Interface& + interface () = 0; + + virtual Member& + member () = 0; + + virtual Module& + module () = 0; + + virtual Native& + native () = 0; + + virtual NumericExpression& + numeric_expression () = 0; + + virtual Operation& + operation () = 0; + + virtual Struct& + struct_ () = 0; + + virtual Typedef& + typedef_ () = 0; + + virtual TypeId& + type_id () = 0; + + virtual TypePrefix& + type_prefix () = 0; + + virtual Union& + union_ () = 0; + + virtual ValueType& + value_type () = 0; + + virtual ValueTypeFactory& + value_type_factory () = 0; + + virtual ValueTypeMember& + value_type_member () = 0; + }; + + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp new file mode 100644 index 00000000000..dde00c85988 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp @@ -0,0 +1,205 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Attribute:: + Attribute (Context& c) + : Base (c) + { + } + + void Attribute:: + begin_ro () + { + if (ctx.trace ()) cerr << "readonly attribute" << endl; + + readonly_ = true; + + + } + + void Attribute:: + begin_rw () + { + if (ctx.trace ()) cerr << "readwrite attribute" << endl; + + readonly_ = false; + } + + void Attribute:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + type_ = 0; + + try + { + try + { + type_ = &resolve<Type> (from, name, Flags::complete); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid attribute declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an attribute type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Attribute:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << id << endl; + + if (type_ != 0) + { + if (readonly_) + a_ = &ctx.tu ().new_node<ReadAttribute> ( + ctx.file (), id->line ()); + else + a_ = &ctx.tu ().new_node<ReadWriteAttribute> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Belongs> (*a_, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), *a_, id->lexeme ()); + } + } + + void Attribute:: + get_raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "get-raise " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<GetRaises> ( + dynamic_cast<ReadAttribute&> (*a_), e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + + void Attribute:: + set_raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "set-raise " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<SetRaises> ( + dynamic_cast<WriteAttribute&> (*a_), e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + + void Attribute:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp new file mode 100644 index 00000000000..88bc8e5016a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp @@ -0,0 +1,55 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Attribute : SemanticAction::Attribute, Base + { + Attribute (Context& c); + + virtual void + begin_ro (); + + virtual void + begin_rw (); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + get_raises (IdentifierPtr const& id); + + virtual void + set_raises (IdentifierPtr const& id); + + virtual void + end (); + + private: + bool readonly_; + SemanticGraph::Type* type_; + SemanticGraph::Attribute* a_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.cpp new file mode 100644 index 00000000000..9685d0874ee --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.cpp @@ -0,0 +1,119 @@ +// file : CCF/IDL2/SemanticAction/Impl/Const.cpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Const.hpp" + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Const:: + Const (Context& c) + : Base (c) + { + } + + void Const:: + begin (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) + cerr << "const " << type_id << " " << name_id << endl; + + const_ = 0; + + SimpleName name (name_id->lexeme ()); + Name type_name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, type_name, Flags::complete)); + + if (dynamic_cast<Octet*> (&t) || + dynamic_cast<Short*> (&t) || + dynamic_cast<UnsignedShort*> (&t) || + dynamic_cast<Long*> (&t) || + dynamic_cast<UnsignedLong*> (&t) || + dynamic_cast<LongLong*> (&t) || + dynamic_cast<UnsignedLongLong*> (&t)) + { + // Integer constant. + // + const_ = &ctx.tu ().new_node<SemanticGraph::IntConst> ( + ctx.file (), name_id->line ()); + + ctx.tu ().new_edge<Belongs> (*const_, t); + ctx.tu ().new_edge<Defines> (ctx.scope (), *const_, name); + } + + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid const declaration" << endl; + throw; + } + + //@@ I am not handling NotUnique here. For example if + // I provide module name as type then the compiler + // will ICE. Think about other places it may happen + // (attribute, value memebr, typeded, others?). + // + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << type_name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << type_name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as a const type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Const:: + expr () + { + //@@ Need to check if int_exp_stack is empty. + // + if (const_ && ctx.int_exp_size () > 0) + { + IntExpression& expr (ctx.int_exp_pop ()); + + ctx.tu ().new_edge<Initializes> (expr, *const_); + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.hpp new file mode 100644 index 00000000000..37ac3153d16 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Const.hpp @@ -0,0 +1,39 @@ +// file : CCF/IDL2/SemanticAction/Impl/Const.hpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_CONST_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_CONST_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Const.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Const : SemanticAction::Const, Base + { + Const (Context& c); + + virtual void + begin (IdentifierPtr const& type, + SimpleIdentifierPtr const& name); + + virtual void + expr (); + + private: + SemanticGraph::Const* const_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_CONST_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp new file mode 100644 index 00000000000..0076b9d757c --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp @@ -0,0 +1,133 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace +{ + bool trace (false); +} + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // @@ Need pointer iterator adapter. + + using namespace SemanticGraph; + using SemanticGraph::Scope; + + Nameables + resolve (TranslationUnit& tu, + ScopedName const& from, + Name const& name) throw (NotFound) + { + + if (trace) cerr << "resolve: starting resolution process for \'" + << name << "\' from \'" << from << "\'" << endl; + + Nameables r; + + // Check if name is already scoped. + // + if (name.scoped ()) + { + r = tu.lookup (ScopedName (name)); + } + else + { + // Obtain all nodes corresponding to this scope name. + // + + for (ScopedName next (from);;) + { + Nameables scopes (tu.lookup (next)); + + // Lookup the name in each scope. + // + for (Nameables::const_iterator + i (scopes.begin ()), end (scopes.end ()); + i != end; ++i) + { + if (Scope* s = dynamic_cast<Scope*> (*i)) + { + s->lookup (name, r); + } + } + + if (r.begin () != r.end () || next.simple ()) + { + // Found something -or- at the root scope. + // + break; + } + + next = ScopedName (next.begin (), next.end () - 1); + } + } + + if (r.begin () == r.end ()) + { + if (trace) cerr << "resolve: resolution process for \'" + << name << "\' from \'" << from << "\' failed." + << endl; + + throw NotFound (); + } + else + { + if (trace) cerr << "resolve: resolution process for \'" + << name << "\' from \'" << from << "\' succeeded:" + << endl; + + for (Nameables::const_iterator i (r.begin ()), end (r.end ()); + i != end; ++i) + { + if (trace) cerr << "\t\'" << (**i).scoped_name () << "\'" + << endl; + } + } + + return r; + } + + + // Lookup *all* scopes for a simple name + // + // + Nameable* + lookup (SemanticGraph::TranslationUnit& tu, + SemanticGraph::Scope& in, + SemanticGraph::SimpleName const& name) throw (NotUnique) + { + Nameables r; + + Nameables scopes (tu.lookup (in.scoped_name ())); + + for (Nameables::const_iterator + i (scopes.begin ()), end (scopes.end ()); + i != end; ++i) + { + dynamic_cast<Scope&> (**i).lookup (name, r); + } + + if (r.size () > 1) throw NotUnique (); + + if (r.empty ()) return 0; + + return *(r.begin ()); + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..51da2657b5d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,320 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include <stack> + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +/* + Design notes: + + (1) I am using stack-based approach to handle cases like this: + + struct A + { + struct B + { + struct C + { + ... + } c; + + } b; + }; + + Even though you can't write the same let's say for interface + I am still using stack approach for consistency and possible + meta-coding. + +*/ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + + // + // + // + class Context + { + public: + Context (bool trace, + SemanticGraph::TranslationUnit& tu, + CompilerElements::Context& parsing_context) + : trace_ (trace), + tu_ (tu), + parsing_context_ (parsing_context) + { + } + + bool + trace () + { + return trace_; + } + + SemanticGraph::TranslationUnit& + tu () const + { + return tu_; + } + + SemanticGraph::Scope& + scope () const + { + return *scope_; + } + + void + scope (SemanticGraph::Scope& scope) + { + scope_ = &scope; + } + + SemanticGraph::TranslationRegion& + region () const + { + return *region_; + } + + void + region (SemanticGraph::TranslationRegion& r) + { + region_ = &r; + } + + CompilerElements::Context& + parsing_context () const + { + return parsing_context_; + } + + SemanticGraph::Path const& + file () const + { + return parsing_context_.get<SemanticGraph::Path> ("file-path"); + } + + public: + void + int_exp_push (SemanticGraph::IntExpression& e) + { + int_exp_stack_.push (&e); + } + + SemanticGraph::IntExpression& + int_exp_pop () + { + SemanticGraph::IntExpression& e (*int_exp_stack_.top ()); + int_exp_stack_.pop (); + return e; + } + + std::size_t + int_exp_size () + { + return int_exp_stack_.size (); + } + + void + int_exp_flush () + { + while (int_exp_stack_.size ()) + int_exp_stack_.pop (); + } + + private: + bool trace_; + SemanticGraph::TranslationUnit& tu_; + SemanticGraph::TranslationRegion* region_; + SemanticGraph::Scope* scope_; + + CompilerElements::Context& parsing_context_; + + std::stack<SemanticGraph::IntExpression*> int_exp_stack_; + + private: + Context (Context const&); + void operator= (Context const&); + }; + + + // + // + // + class Base + { + protected: + virtual + ~Base () + { + } + + Base (Context& c) + : ctx (c) + { + } + + protected: + + class Resolve {}; + + template <typename Id> + struct ExceptionTemplate : Resolve + { + explicit + ExceptionTemplate (SemanticGraph::ScopedName name) + : name_ (name) + { + } + + SemanticGraph::ScopedName + name () const + { + return name_; + } + + private: + SemanticGraph::ScopedName name_; + }; + + + struct NotFound : Resolve {}; + + class WrongType_ {}; + typedef ExceptionTemplate<WrongType_> WrongType; + + class NotUnique : Resolve {}; + + class NotDefined_ {}; + typedef ExceptionTemplate<NotDefined_> NotDefined; + + class NotComplete_ {}; + typedef ExceptionTemplate<NotComplete_> NotComplete; + + struct Flags + { + enum Value + { + none = 0x00, + complete = 0x01, + defined = 0x02 + }; + }; + + template <typename T> + T& + resolve (SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name, + Flags::Value flags = Flags::none) + throw (NotFound, NotUnique, WrongType, NotDefined, NotComplete); + + + class AlreadyInherited_ {}; + typedef ExceptionTemplate<AlreadyInherited_> AlreadyInherited; + + class AlreadySupported_ {}; + typedef ExceptionTemplate<AlreadySupported_> AlreadySupported; + + template<typename I> + void + check_inheritance (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadyInherited); + + template<typename I> + void + check_support (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadySupported); + + protected: + Context& ctx; + }; + + + // + // + // + template <typename T> + class ScopeBase : public Base + { + protected: + ScopeBase (Context& c) + : Base (c) + { + } + + protected: + T& + now () const + { + return *now_; + } + + void + now (T& t) + { + now_ = &t; + } + + void + push (SemanticGraph::Scope& t) + { + stack_.push (&t); + } + + void + pop () + { + stack_.pop (); + } + + SemanticGraph::Scope& + top () + { + return *stack_.top (); + } + + private: + T* now_; + std::stack<SemanticGraph::Scope*> stack_; + }; + + + // + // + // + class NotFound {}; + class NotUnique {}; + + SemanticGraph::Nameables + resolve (SemanticGraph::TranslationUnit& tu, + SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name) throw (NotFound); + + + + + SemanticGraph::Nameable* + lookup (SemanticGraph::TranslationUnit& tu, + SemanticGraph::Scope& in, + SemanticGraph::SimpleName const& name) throw (NotUnique); + } + } + } +} + +#include "CCF/IDL2/SemanticAction/Impl/Elements.tpp" + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp new file mode 100644 index 00000000000..13d4e8905d4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp @@ -0,0 +1,94 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + template <typename T> + T& Base:: + resolve (SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name, + Flags::Value flags) + throw (NotFound, NotUnique, WrongType, NotDefined, NotComplete) + { + using namespace SemanticGraph; + + try + { + Nameables nodes (Impl::resolve (ctx.tu (), from, name)); + + + if (nodes.size () != 1) throw NotUnique (); + + Nameable& node (**(nodes.begin ())); + + try + { + T& t (dynamic_cast<T&> (node)); + + if (flags & Flags::defined) + { + if (!t.defined ()) throw NotDefined (node.scoped_name ()); + } + + if (flags & Flags::complete) + { + SemanticGraph::Type& type ( + dynamic_cast<SemanticGraph::Type&> (t)); + + if (!type.complete ()) + { + throw NotComplete (node.scoped_name ()); + } + } + + return t; + } + catch (std::bad_cast const&) + { + throw WrongType (node.scoped_name ()); + } + } + catch (Impl::NotFound const&) + { + throw NotFound (); + } + } + + template<typename I> + void Base:: + check_inheritance (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadyInherited) + { + for (;begin != end; ++begin) + { + if ((**begin).inheritee () == t) + { + throw AlreadyInherited (t.scoped_name ()); + } + } + } + + template<typename I> + void Base:: + check_support (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadySupported) + { + for (;begin != end; ++begin) + { + if ((**begin).supportee () == t) + { + throw AlreadySupported (t.scoped_name ()); + } + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.cpp new file mode 100644 index 00000000000..cece740ed39 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.cpp @@ -0,0 +1,72 @@ +// file : CCF/IDL2/SemanticAction/Impl/Enum.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Enum.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Enum:: + Enum (Context& c) + : Base (c) + { + } + + void Enum:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "enum " << id << endl; + + type_ = 0; + + SimpleName name (id->lexeme ()); + + type_ = &ctx.tu ().new_node<SemanticGraph::Enum> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Defines> (ctx.scope (), *type_, name); + } + + void Enum:: + enumerator (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "enumerator " << id << endl; + + //@@ Need to check for redeclaration of the name. + // + + SimpleName name (id->lexeme ()); + + if (type_ != 0) + { + Enumerator& e ( + ctx.tu ().new_node<Enumerator> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (e, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), e, name); + } + } + + void Enum:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.hpp new file mode 100644 index 00000000000..df25fb0455f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Enum.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Impl/Enum.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ENUM_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ENUM_HPP + +#include "CCF/IDL2/SemanticGraph/Enum.hpp" +#include "CCF/IDL2/SemanticAction/Enum.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Enum : SemanticAction::Enum, Base + { + Enum (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + enumerator (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SemanticGraph::Enum* type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ENUM_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp new file mode 100644 index 00000000000..63af631c4b9 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp @@ -0,0 +1,67 @@ +// file : CCF/IDL2/SemanticAction/Impl/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Exception.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Exception:: + Exception (Context& c) + : ScopeBase<SemanticGraph::Exception> (c) + { + } + + void Exception:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "exception " << id << endl; + + SimpleName name (id->lexeme ()); + + now (ctx.tu ().new_node<SemanticGraph::Exception> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Exception:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Exception:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Exception:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp new file mode 100644 index 00000000000..6ed44048b36 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/SemanticAction/Impl/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Exception : SemanticAction::Exception, + ScopeBase<SemanticGraph::Exception> + { + Exception (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..6a680d14831 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,102 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + template <typename X> + void Factory:: + define_fund_type (Root& root, SimpleName const& name) + { + ctx_.tu ().template new_edge<Defines> ( + root, + ctx_.tu ().template new_node<X> ("fundamental-types", 0), name); + } + + Factory:: + Factory (CompilerElements::Context& parsing_context, + Diagnostic::Stream&, + SemanticGraph::TranslationUnit& tu) + : ctx_ (parsing_context.get ("trace-semantic-action", false), + tu, + parsing_context), + + attribute_ (ctx_), + const__ (ctx_), + enum__ (ctx_), + exception_ (ctx_), + include_ (ctx_), + interface_ (ctx_), + member_ (ctx_), + module_ (ctx_), + native_ (ctx_), + numeric_expression_ (ctx_), + operation_ (ctx_), + struct__ (ctx_), + typedef__ (ctx_), + type_id_ (ctx_), + type_prefix_ (ctx_), + union__ (ctx_), + value_type_ (ctx_), + value_type_factory_ (ctx_), + value_type_member_ (ctx_) + { + // Implied translation region with fundamental types. + // + TranslationRegion& ftr ( + tu.new_node<TranslationRegion> ( + "fundamental-type", 0)); + + tu.new_edge<ContainsImplied> (tu, ftr, "fundamental-type"); + + Root& fr (tu.new_node<Root> ("fundamental-types", 0)); + tu.new_edge<ContainsRoot> (ftr, fr); + + define_fund_type<Object> (fr, "Object"); + define_fund_type<ValueBase> (fr, "ValueBase"); + define_fund_type<Any> (fr, "any"); + define_fund_type<Boolean> (fr, "boolean"); + define_fund_type<Char> (fr, "char"); + define_fund_type<Double> (fr, "double"); + define_fund_type<Float> (fr, "float"); + define_fund_type<Long> (fr, "long"); + define_fund_type<LongDouble> (fr, "long double"); + define_fund_type<LongLong> (fr, "long long"); + define_fund_type<Octet> (fr, "octet"); + define_fund_type<Short> (fr, "short"); + define_fund_type<String> (fr, "string"); + define_fund_type<UnsignedLong> (fr, "unsigned long"); + define_fund_type<UnsignedLongLong> (fr, "unsigned long long"); + define_fund_type<UnsignedShort> (fr, "unsigned short"); + define_fund_type<Void> (fr, "void"); + define_fund_type<Wchar> (fr, "wchar"); + define_fund_type<Wstring> (fr, "wstring"); + + TranslationRegion& principal ( + tu.new_node<TranslationRegion> (ctx_.file (), 0)); + + tu.new_edge<ContainsPrincipal> (tu, principal); + + Root& root (tu.new_node<Root> (ctx_.file (), 0)); + tu.new_edge<ContainsRoot> (principal, root); + + ctx_.region (principal); + ctx_.scope (root); + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..f385fdec57f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,200 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/CompilerElements/Diagnostic.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +//@@ It would be nice to move this includes into .cpp +// +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Const.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Enum.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Member.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Native.hpp" +#include "CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/Impl/TypeId.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Union.hpp" +#include "CCF/IDL2/SemanticAction/Impl/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp" +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Factory : virtual IDL2::SemanticAction::Factory + { + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + virtual SemanticAction::Attribute& + attribute () + { + return attribute_; + } + + virtual SemanticAction::Const& + const_ () + { + return const__; + } + + virtual SemanticAction::Enum& + enum_ () + { + return enum__; + } + + virtual SemanticAction::Exception& + exception () + { + return exception_; + } + + virtual SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Interface& + interface () + { + return interface_; + } + + virtual SemanticAction::Member& + member () + { + return member_; + } + + virtual SemanticAction::Module& + module () + { + return module_; + } + + virtual SemanticAction::Native& + native () + { + return native_; + } + + virtual SemanticAction::NumericExpression& + numeric_expression () + { + return numeric_expression_; + } + + virtual SemanticAction::Operation& + operation () + { + return operation_; + } + + virtual SemanticAction::Struct& + struct_ () + { + return struct__; + } + + virtual SemanticAction::Typedef& + typedef_ () + { + return typedef__; + } + + virtual SemanticAction::TypeId& + type_id () + { + return type_id_; + } + + virtual SemanticAction::TypePrefix& + type_prefix () + { + return type_prefix_; + } + + virtual SemanticAction::Union& + union_ () + { + return union__; + } + + virtual SemanticAction::ValueType& + value_type () + { + return value_type_; + } + + virtual ValueTypeFactory& + value_type_factory () + { + return value_type_factory_; + } + + virtual SemanticAction::ValueTypeMember& + value_type_member () + { + return value_type_member_; + } + + protected: + Context ctx_; + + private: + template <typename X> + void + define_fund_type (SemanticGraph::Root& root, + SemanticGraph::SimpleName const& name); + + private: + Attribute attribute_; + Const const__; + Enum enum__; + Exception exception_; + Include include_; + Interface interface_; + Member member_; + Module module_; + Native native_; + NumericExpression numeric_expression_; + Operation operation_; + Struct struct__; + Typedef typedef__; + TypeId type_id_; + TypePrefix type_prefix_; + Union union__; + ValueType value_type_; + ValueTypeFactory value_type_factory_; + ValueTypeMember value_type_member_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..5fcbe4a0c31 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp @@ -0,0 +1,50 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // @@ This is left unimplemented for now. Later, code from + // IDL3 should be copied here. Or better yet this implementation + // should allow customization via overriding. + // + Include:: + Include (Context& c) + : ctx (c) + { + } + + void Include:: + quote (StringLiteralPtr const& sl) + { + if (ctx.trace ()) cerr << "__qinclude " << sl << endl; + } + + void Include:: + bracket (StringLiteralPtr const& sl) + { + if (ctx.trace ()) cerr << "__binclude " << sl << endl; + } + + void Include:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..57b573e23a3 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP + + +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Include : SemanticAction::Include + { + Include (Context& c); + + virtual void + quote (StringLiteralPtr const& sl); + + virtual void + bracket (StringLiteralPtr const& sl); + + virtual void + end (); + + private: + Context& ctx; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp new file mode 100644 index 00000000000..63c5dc9d5be --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp @@ -0,0 +1,260 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Interface:: + Interface (Context& c) + : ScopeBase<SemanticGraph::Interface> (c) + { + } + + void Interface:: + begin_abstract_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract interface def " << id << endl; + + qualifier_ = Qualifier::abstract; + + SimpleName name (id->lexeme ()); + + //@@ Not handling NotUnique exception. + // + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_abstract_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract interface fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + begin_local_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "local interface def " << id << endl; + + qualifier_ = Qualifier::local; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<LocalInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<LocalInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_local_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "local interface fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<LocalInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<LocalInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + begin_unconstrained_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "unconstrained interface def " << id + << endl; + + qualifier_ = Qualifier::unconstrained; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<UnconstrainedInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<UnconstrainedInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_unconstrained_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "unconstrained interface fwd " << id + << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<UnconstrainedInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<UnconstrainedInterface> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + switch (qualifier_) + { + case Qualifier::abstract: + { + if (dynamic_cast<AbstractInterface*> (&i)) break; + + throw WrongType (i.scoped_name ()); + } + case Qualifier::unconstrained: + { + if (dynamic_cast<UnconstrainedInterface*> (&i) || + dynamic_cast<AbstractInterface*> (&i)) break; + + throw WrongType (i.scoped_name ()); + } + default: break; + } + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + i); + + ctx.tu ().new_edge<Inherits> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from forward-declared interface is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly inheriting from interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void Interface:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Interface:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Interface:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp new file mode 100644 index 00000000000..f25315a1a28 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp @@ -0,0 +1,69 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Interface : SemanticAction::Interface, + ScopeBase<SemanticGraph::Interface> + { + Interface (Context& c); + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id); + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_local_def (SimpleIdentifierPtr const& id); + + virtual void + begin_local_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_unconstrained_def (SimpleIdentifierPtr const& id); + + virtual void + begin_unconstrained_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + + private: + struct Qualifier + { + enum Value { abstract, local, unconstrained }; + }; + + Qualifier::Value qualifier_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp new file mode 100644 index 00000000000..790bb2a6c95 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp @@ -0,0 +1,113 @@ +// file : CCF/IDL2/SemanticAction/Impl/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Member.hpp" + +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Member:: + Member (Context& c) + : Base (c) + { + } + + void Member:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "member " << id << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + // With introduction of CORBA 3.1 we have a new beast: + // struct with incoplete members which itself becomes + // incomplete. + // + type_ = &resolve<Type> (from, name/*, Flags::complete*/); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid member declaration" << endl; + throw; + } + + //@@ I am not handling NotUnique here. For example if + // I provide module name as type then the compiler + // will ICE. Think about other places it may happen + // (attribute, value memebr, typeded, others?). + // + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type as a member type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + + void Member:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + SimpleName name (id->lexeme ()); + + SemanticGraph::Member& m ( + ctx.tu ().new_node<SemanticGraph::Member> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (m, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), m, name); + } + } + + void Member:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp new file mode 100644 index 00000000000..2ec51a1ab01 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Impl/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Member.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Member : SemanticAction::Member, Base + { + Member (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SemanticGraph::Type* type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp new file mode 100644 index 00000000000..b2b003d6d73 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp @@ -0,0 +1,65 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Module:: + Module (Context& c) + : ScopeBase<SemanticGraph::Module> (c) + { + } + + void Module:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "module " << id << endl; + + now (ctx.tu ().new_node<SemanticGraph::Module> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), id->lexeme ()); + } + + void Module:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Module:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Module:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp new file mode 100644 index 00000000000..1fbbc4c78fc --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP + +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticAction/Module.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Module : SemanticAction::Module, + ScopeBase<SemanticGraph::Module> + { + Module (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.cpp new file mode 100644 index 00000000000..162fd1d5bfe --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.cpp @@ -0,0 +1,51 @@ +// file : CCF/IDL2/SemanticAction/Impl/Native.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Native.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Native.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Native:: + Native (Context& c) + : Base (c) + { + } + + void Native:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "native " << id << endl; + + SimpleName name (id->lexeme ()); + + SemanticGraph::Native& n ( + ctx.tu ().new_node<SemanticGraph::Native> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Defines> (ctx.scope (), n, name); + } + + void Native:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.hpp new file mode 100644 index 00000000000..52875c58862 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Native.hpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/SemanticAction/Impl/Native.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_NATIVE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_NATIVE_HPP + +#include "CCF/IDL2/SemanticAction/Native.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Native : SemanticAction::Native, Base + { + Native (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_NATIVE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.cpp new file mode 100644 index 00000000000..e949438aff8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.cpp @@ -0,0 +1,351 @@ +// file : CCF/IDL2/SemanticAction/Impl/NumericExpression.cpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + NumericExpression:: + NumericExpression (Context& c) + : Base (c) + { + } + + void NumericExpression:: + flush () + { + if (ctx.trace ()) + cerr << "expression" << endl; + + ctx.int_exp_flush (); + } + + void NumericExpression:: + const_ (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "const " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Const& c (resolve<Const> (from, name)); + + if (IntConst* ic = dynamic_cast<IntConst*> (&c)) + { + ctx.int_exp_push (*ic); + } + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid reference to const" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no const with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a const declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-const as a reference to const is illegal" + << endl; + } + } + + void NumericExpression:: + integer_literal (IntegerLiteralPtr const& il) + { + if (ctx.trace ()) + cerr << "integer literal " << il->value () << endl; + + ctx.int_exp_push ( + ctx.tu ().new_node<IntLiteral> ( + ctx.file (), il->line (), il->value ())); + } + + void NumericExpression:: + pre (OperatorPtr const& op) + { + line_ = op->line (); + } + + void NumericExpression:: + pos () + { + if (ctx.trace ()) + cerr << "unary +" << endl; + + // Nothing to do. + } + + void NumericExpression:: + neg () + { + if (ctx.trace ()) + cerr << "unary -" << endl; + + if (ctx.int_exp_size () < 1) + return; + + IntExpression& expr (ctx.int_exp_pop ()); + + IntNeg& neg (ctx.tu ().new_node<IntNeg> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntNegates> (neg, expr); + + ctx.int_exp_push (neg); + } + + void NumericExpression:: + com () + { + if (ctx.trace ()) + cerr << "unary ~" << endl; + + if (ctx.int_exp_size () < 1) + return; + + IntExpression& expr (ctx.int_exp_pop ()); + + IntCom& com (ctx.tu ().new_node<IntCom> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntComplements> (com, expr); + + ctx.int_exp_push (com); + } + + void NumericExpression:: + mul () + { + if (ctx.trace ()) + cerr << "*" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& multiplier (ctx.int_exp_pop ()); + IntExpression& multiplicand (ctx.int_exp_pop ()); + + IntMul& mul (ctx.tu ().new_node<IntMul> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntMultiplies> (mul, multiplicand); + ctx.tu ().new_edge<IntMultiplies> (mul, multiplier); + + ctx.int_exp_push (mul); + } + + void NumericExpression:: + div () + { + if (ctx.trace ()) + cerr << "/" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& divisor (ctx.int_exp_pop ()); + IntExpression& divident (ctx.int_exp_pop ()); + + IntDiv& div (ctx.tu ().new_node<IntDiv> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntDivides> (div, divident); + ctx.tu ().new_edge<IntDivides> (div, divisor); + + ctx.int_exp_push (div); + } + + void NumericExpression:: + rem () + { + if (ctx.trace ()) + cerr << "%" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& divisor (ctx.int_exp_pop ()); + IntExpression& divident (ctx.int_exp_pop ()); + + IntRem& rem (ctx.tu ().new_node<IntRem> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntDivides> (rem, divident); + ctx.tu ().new_edge<IntDivides> (rem, divisor); + + ctx.int_exp_push (rem); + } + + + void NumericExpression:: + add () + { + if (ctx.trace ()) + cerr << "+" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& second_item (ctx.int_exp_pop ()); + IntExpression& first_item (ctx.int_exp_pop ()); + + IntAdd& add (ctx.tu ().new_node<IntAdd> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntAdds> (add, first_item); + ctx.tu ().new_edge<IntAdds> (add, second_item); + + ctx.int_exp_push (add); + } + + void NumericExpression:: + sub () + { + if (ctx.trace ()) + cerr << "-" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& subtrahend (ctx.int_exp_pop ()); + IntExpression& minuend (ctx.int_exp_pop ()); + + IntSub& sub (ctx.tu ().new_node<IntSub> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntSubtracts> (sub, minuend); + ctx.tu ().new_edge<IntSubtracts> (sub, subtrahend); + + ctx.int_exp_push (sub); + } + + void NumericExpression:: + rsh () + { + if (ctx.trace ()) + cerr << ">>" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& factor (ctx.int_exp_pop ()); + IntExpression& pattern (ctx.int_exp_pop ()); + + IntRsh& rsh (ctx.tu ().new_node<IntRsh> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntShifts> (rsh, pattern); + ctx.tu ().new_edge<IntShifts> (rsh, factor); + + ctx.int_exp_push (rsh); + } + + void NumericExpression:: + lsh () + { + if (ctx.trace ()) + cerr << "<<" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& factor (ctx.int_exp_pop ()); + IntExpression& pattern (ctx.int_exp_pop ()); + + IntLsh& lsh (ctx.tu ().new_node<IntLsh> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntShifts> (lsh, pattern); + ctx.tu ().new_edge<IntShifts> (lsh, factor); + + ctx.int_exp_push (lsh); + } + + void NumericExpression:: + and_ () + { + if (ctx.trace ()) + cerr << "&" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& second_pattern (ctx.int_exp_pop ()); + IntExpression& first_pattern (ctx.int_exp_pop ()); + + IntAnd& and_ (ctx.tu ().new_node<IntAnd> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntConjuncts> (and_, first_pattern); + ctx.tu ().new_edge<IntConjuncts> (and_, second_pattern); + + ctx.int_exp_push (and_); + } + + void NumericExpression:: + xor_ () + { + if (ctx.trace ()) + cerr << "^" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& second_pattern (ctx.int_exp_pop ()); + IntExpression& first_pattern (ctx.int_exp_pop ()); + + IntXor& xor_ (ctx.tu ().new_node<IntXor> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntExclusivelyDisjuncts> (xor_, first_pattern); + ctx.tu ().new_edge<IntExclusivelyDisjuncts> (xor_, second_pattern); + + ctx.int_exp_push (xor_); + } + + void NumericExpression:: + or_ () + { + if (ctx.trace ()) + cerr << "|" << endl; + + if (ctx.int_exp_size () < 2) + return; + + IntExpression& second_pattern (ctx.int_exp_pop ()); + IntExpression& first_pattern (ctx.int_exp_pop ()); + + IntOr& or_ (ctx.tu ().new_node<IntOr> (ctx.file (), line_)); + + ctx.tu ().new_edge<IntInclusivelyDisjuncts> (or_, first_pattern); + ctx.tu ().new_edge<IntInclusivelyDisjuncts> (or_, second_pattern); + + ctx.int_exp_push (or_); + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp new file mode 100644 index 00000000000..fe0b399cb60 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp @@ -0,0 +1,84 @@ +// file : CCF/IDL2/SemanticAction/Impl/NumericExpression.hpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_NUMERIC_EXPRESSION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_NUMERIC_EXPRESSION_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticAction/NumericExpression.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct NumericExpression : SemanticAction::NumericExpression, Base + { + NumericExpression (Context& c); + + virtual void + flush (); + + virtual void + const_ (IdentifierPtr const&); + + virtual void + integer_literal (IntegerLiteralPtr const&); + + virtual void + pre (OperatorPtr const&); + + virtual void + pos (); + + virtual void + neg (); + + virtual void + com (); + + virtual void + mul (); + + virtual void + div (); + + virtual void + rem (); + + virtual void + add (); + + virtual void + sub (); + + virtual void + rsh (); + + virtual void + lsh (); + + virtual void + and_ (); + + virtual void + xor_ (); + + virtual void + or_ (); + + + private: + unsigned long line_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_NUMERIC_EXPRESSION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp new file mode 100644 index 00000000000..7401e2f65ea --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp @@ -0,0 +1,266 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Operation:: + Operation (Context& c) + : Base (c) + { + } + + void Operation:: + one_way () + { + if (ctx.trace ()) cerr << "oneway "; + one_way_ = true; + } + + void Operation:: + two_way () + { + if (ctx.trace ()) cerr << "twoway "; + one_way_ = false; + } + + void Operation:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "operation " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name, Flags::complete); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid operation declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type as an operation return type is illegal" + << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Operation:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (one_way_) + { + if (dynamic_cast<Void*> (type_) == 0) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid operation declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "oneway operation should have void as a return type" + << endl; + } + + op_ = &ctx.tu ().new_node<OneWayOperation> ( + ctx.file (), id->line ()); + } + else + op_ = &ctx.tu ().new_node<TwoWayOperation> ( + ctx.file (), id->line ()); + + SimpleName name (id->lexeme ()); + ctx.tu ().new_edge<Defines> (ctx.scope (), *op_, name); + + if (type_) + { + ctx.tu ().new_edge<Returns> (*op_, *type_); + } + } + + + void Operation:: + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter " << direction << " " + << type_id << " " << name_id << endl; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + struct NotIn : Resolve {}; + + try + { + try + { + if (one_way_ && direction != Direction::in) + throw NotIn (); + + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter* p (0); + + switch (direction) + { + case Direction::in: + { + p = &ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ()); + break; + } + case Direction::out: + { + p = &ctx.tu ().new_node<OutParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ()); + break; + } + case Direction::inout: + { + p = &ctx.tu ().new_node<InOutParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ()); + break; + } + } + + ctx.tu ().new_edge<Belongs> (*p, t); + ctx.tu ().new_edge<Receives> (*op_, *p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an operation parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + catch (NotIn const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "parameter of oneway operation should have \'in\' " + << "direction" << endl; + } + } + + + void Operation:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + struct OneWay : Resolve {}; + + try + { + try + { + if (one_way_) + throw OneWay (); + + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*op_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + catch (OneWay const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "oneway operation may not raise exceptions" << endl; + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp new file mode 100644 index 00000000000..e45cef9fcf4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + struct Operation : SemanticAction::Operation, Base + { + Operation (Context& c); + + virtual void + one_way (); + + virtual void + two_way (); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + bool one_way_; + SemanticGraph::Type* type_; + SemanticGraph::Operation* op_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp new file mode 100644 index 00000000000..966eba12824 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp @@ -0,0 +1,99 @@ +// file : CCF/IDL2/SemanticAction/Impl/Struct.cpp +// author : Jeff Parsons <j.parsons@vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Struct.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Struct:: + Struct (Context& c) + : ScopeBase<SemanticGraph::Struct> (c) + { + } + + // @@ I need a mechanism for propagating exceptions from + // semantic actions to the parser in order to stop + // semantic action invocation. + // + + void Struct:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "struct def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Struct&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Struct> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Struct:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "struct fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Struct&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Struct> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Struct:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Struct:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Struct:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp new file mode 100644 index 00000000000..0fafd69962f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp @@ -0,0 +1,45 @@ +// file : CCF/IDL2/SemanticAction/Impl/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP + +#include "CCF/IDL2/SemanticGraph/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Struct : SemanticAction::Struct, + ScopeBase<SemanticGraph::Struct> + { + Struct (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp new file mode 100644 index 00000000000..816d83f6d12 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp @@ -0,0 +1,146 @@ +// file : CCF/IDL2/SemanticAction/Impl/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/TypeId.hpp" + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" + +// These inclusions are needed to ensure that typeprefix is applied to a +// suitable declaration. + +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + // TypeId + // + // + TypeId:: + TypeId (Context& c) + : ctx (c) + { + } + + void TypeId:: + begin (IdentifierPtr const& d, StringLiteralPtr const& id) + { + if (ctx.trace ()) + cerr << "typeid " << d << " " << id << endl; + + Name name (d->lexeme ()); + SemanticGraph::StringLiteral tid (id->value ()); + + try + { + ScopedName from (ctx.scope ().scoped_name ()); + Nameables nodes (resolve (ctx.tu (), from, name)); + + ScopedName full ((**(nodes.begin ())).scoped_name ()); + + SemanticGraph::TypeId& ti ( + ctx.tu ().new_node<SemanticGraph::TypeId> ( + ctx.file (), d->line (), full, tid)); + + ctx.tu ().new_edge<Defines> (ctx.scope (), ti, "typeid"); + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << d->line () << ": error: " + << "invalid typeid declaration" << endl; + + cerr << ctx.file () << ":" << d->line () << ": error: " + << "no declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + } + + void TypeId:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + + // TypePrefix + // + // + TypePrefix:: + TypePrefix (Context& c) + : ctx (c) + { + } + + void TypePrefix:: + begin (IdentifierPtr const& d, StringLiteralPtr const& prefix) + { + if (ctx.trace ()) cerr << "typeprefix " << d << " " << prefix + << endl; + + Name name (d->lexeme ()); + SemanticGraph::StringLiteral tprefix (prefix->value ()); + + try + { + ScopedName from (ctx.scope ().scoped_name ()); + Nameables nodes (resolve (ctx.tu (), from, name)); + + Nameable& node (**(nodes.begin ())); + + dynamic_cast<SemanticGraph::Scope&> (node); + + ScopedName full (node.scoped_name ()); + + SemanticGraph::TypePrefix& tp ( + ctx.tu ().new_node<SemanticGraph::TypePrefix> ( + ctx.file (), d->line (), full, tprefix)); + + ctx.tu ().new_edge<Defines> (ctx.scope (), tp, "typeprefix"); + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << d->line () << ": error: " + << "invalid typeprefix declaration" << endl; + + cerr << ctx.file () << ":" << d->line () << ": error: " + << "no declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + catch (std::bad_cast const&) + { + cerr << ctx.file () << ":" << d->line () << ": error: " + << "invalid typeprefix declaration" << endl; + + cerr << ctx.file () << ":" << d->line () << ": error: " + << "no suitable declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + } + + void TypePrefix:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp new file mode 100644 index 00000000000..e88971eade4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticAction/Impl/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticAction/TypeId.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + struct TypeId : SemanticAction::TypeId + { + TypeId (Context& c); + + virtual void + begin (IdentifierPtr const& d, StringLiteralPtr const& id); + + virtual void + end (); + + private: + Context& ctx; + }; + + + // + // + // + struct TypePrefix : SemanticAction::TypePrefix + { + TypePrefix (Context& c); + + virtual void + begin (IdentifierPtr const& d, StringLiteralPtr const& prefix); + + virtual void + end (); + + private: + Context& ctx; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp new file mode 100644 index 00000000000..fcd4257fa52 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp @@ -0,0 +1,327 @@ +// file : CCF/IDL2/SemanticAction/Impl/Typedef.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Typedef.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Array.hpp" +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" +#include "CCF/IDL2/SemanticGraph/String.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +//@@ names used in smantic actions are inconsistent +// e.g. begin () vs name (), etc +// + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Typedef:: + Typedef (Context& c) + : Base (c) + { + } + + void Typedef:: + pre (KeywordPtr const& id) + { + line_ = id->line (); + } + + void Typedef:: + begin (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "typedef " << id << endl; + + define_ = false; + type_ = 0; + array_type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid typedef declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type in typedef is illegal" << endl; + } + } + + void Typedef:: + begin_unbounded_seq (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "typedef u-sequence<" << id << ">" << endl; + + define_ = true; + type_ = 0; + array_type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name)); + + UnboundedSequence& s ( + ctx.tu ().new_node<UnboundedSequence> ( + ctx.file (), line_)); + + ctx.tu ().new_edge<ArgumentsWithType> (t, s); + + type_ = &s; + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid sequence declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type in sequence specialization is illegal" + << endl; + } + } + + void Typedef:: + begin_bounded_seq (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "typedef b-sequence<" << id << ">" << endl; + + define_ = true; + type_ = 0; + array_type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name)); + + BoundedSequence& s ( + ctx.tu ().new_node<BoundedSequence> ( + ctx.file (), line_)); + + ctx.tu ().new_edge<ArgumentsWithType> (t, s); + + type_ = &s; + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid sequence declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type in sequence specialization is illegal" + << endl; + } + } + + void Typedef:: + begin_bounded_string () + { + if (ctx.trace ()) cerr << "typedef b-string" << endl; + + define_ = true; + type_ = 0; + array_type_ = 0; + + type_ = &ctx.tu ().new_node<BoundedString> (ctx.file (), line_); + bound (); + } + + void Typedef:: + begin_bounded_wstring () + { + if (ctx.trace ()) cerr << "typedef b-wstring" << endl; + + define_ = true; + type_ = 0; + array_type_ = 0; + + type_ = &ctx.tu ().new_node<BoundedWideString> (ctx.file (), line_); + bound (); + } + + void Typedef:: + begin_array () + { + if (ctx.trace ()) cerr << "array" << endl; + + define_ = true; + array_type_ = 0; + + if (type_ == 0) + return; + + if (type_->named_begin () == type_->named_end ()) + { + cerr << ctx.file () << ":" << line_ << ": error: " + << "anonymous types in array declarations " + << "are not supported" << endl; + + cerr << ctx.file () << ":" << line_ << ": error: " + << "use another typedef to name this type" << endl; + + return; + } + + Array& a (ctx.tu ().new_node<Array> (ctx.file (), line_)); + ctx.tu ().new_edge<ArgumentsWithType> (*type_, a); + + array_type_ = &a; + } + + void Typedef:: + bound () + { + if (ctx.trace ()) cerr << "bound" << endl; + + if (ctx.int_exp_size () < 1) + return; + + IntExpression& expr (ctx.int_exp_pop ()); + + if (array_type_ != 0) + { + Specialization& s (dynamic_cast<Specialization&> (*array_type_)); + ctx.tu ().new_edge<ArgumentsWithValue> (expr, s); + } + else if (type_ != 0) + { + Specialization& s (dynamic_cast<Specialization&> (*type_)); + ctx.tu ().new_edge<ArgumentsWithValue> (expr, s); + } + } + + void Typedef:: + declarator (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + SimpleName name (id->lexeme ()); + + try + { + if (lookup (ctx.tu (), ctx.scope (), name) == 0) + { + if (array_type_ != 0) + { + assert (define_); + + ctx.tu ().new_edge<Defines> (ctx.scope (), *array_type_, name); + + define_ = false; + array_type_ = 0; + } + else if (type_ != 0) + { + if (define_) + { + ctx.tu ().new_edge<Defines> (ctx.scope (), *type_, name); + define_ = false; + } + else + { + ctx.tu ().new_edge<Aliases> (ctx.scope (), *type_, name); + } + } + return; + } + } + catch (NotUnique const& ) + { + } + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid typedef declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "redeclaration of name " << name << endl; + + array_type_ = 0; + } + + void Typedef:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp new file mode 100644 index 00000000000..638bbc8afd8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp @@ -0,0 +1,65 @@ +// file : CCF/IDL2/SemanticAction/Impl/Typedef.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Typedef : SemanticAction::Typedef, Base + { + Typedef (Context& c); + + virtual void + pre (KeywordPtr const& id); + + virtual void + begin (IdentifierPtr const& id); + + virtual void + begin_unbounded_seq (IdentifierPtr const& id); + + virtual void + begin_bounded_seq (IdentifierPtr const& id); + + virtual void + begin_bounded_string (); + + virtual void + begin_bounded_wstring (); + + virtual void + begin_array (); + + virtual void + bound (); + + virtual void + declarator (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + bool define_; + unsigned long line_; + SemanticGraph::Type* type_; + SemanticGraph::Type* array_type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.cpp new file mode 100644 index 00000000000..375b8a9abab --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.cpp @@ -0,0 +1,225 @@ +// file : CCF/IDL2/SemanticAction/Impl/Union.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Union.hpp" + +#include "CCF/IDL2/SemanticGraph/Enum.hpp" +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Union:: + Union (Context& c) + : ScopeBase<SemanticGraph::Union> (c) + { + } + + void Union:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "union def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Union&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Union> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Union:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "union fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Union&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Union> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Union:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "type " << id << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name); + + if (!(dynamic_cast<Enum*> (type_) || + dynamic_cast<Boolean*> (type_) || + dynamic_cast<Char*> (type_) || + dynamic_cast<Wchar*> (type_) || + dynamic_cast<Short*> (type_) || + dynamic_cast<UnsignedShort*> (type_) || + dynamic_cast<Long*> (type_) || + dynamic_cast<UnsignedLong*> (type_) || + dynamic_cast<LongLong*> (type_) || + dynamic_cast<UnsignedLongLong*> (type_))) + { + throw WrongType (type_->scoped_name ()); + } + + ctx.tu ().new_edge<ArgumentsWithType> (*type_, now ()); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid union declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a valid discriminant type" << endl; + } + } + + void Union:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Union:: + member_type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "type " << id << endl; + + member_type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + // With introduction of CORBA 3.1 we have a new beast: + // union with incoplete members which itself becomes + // incomplete. + // + member_type_ = &resolve<Type> (from, name/*, Flags::complete*/); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid union member declaration" << endl; + throw; + } + + //@@ I am not handling NotUnique here. For example if + // I provide module name as type then the compiler + // will ICE. Think about other places it may happen + // (attribute, value memebr, typeded, others?). + // + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type as an member type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Union:: + member_name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "name " << id << endl; + + if (member_type_) + { + SimpleName name (id->lexeme ()); + + SemanticGraph::UnionMember& m ( + ctx.tu ().new_node<SemanticGraph::UnionMember> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (m, *member_type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), m, name); + } + } + + void Union:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Union:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.hpp new file mode 100644 index 00000000000..8ab8022c62a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Union.hpp @@ -0,0 +1,57 @@ +// file : CCF/IDL2/SemanticAction/Impl/Union.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_UNION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_UNION_HPP + +#include "CCF/IDL2/SemanticGraph/Union.hpp" +#include "CCF/IDL2/SemanticAction/Union.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct Union : SemanticAction::Union, ScopeBase<SemanticGraph::Union> + { + Union (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + type (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + member_type (IdentifierPtr const& id); + + virtual void + member_name (SimpleIdentifierPtr const& id); + + virtual void + close_scope (); + + virtual void + end (); + + private: + SemanticGraph::Type* type_; + SemanticGraph::Type* member_type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_UNION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp new file mode 100644 index 00000000000..3d6b92132e6 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp @@ -0,0 +1,293 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/ValueType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + ValueType:: + ValueType (Context& c) + : ScopeBase<SemanticGraph::ValueType> (c) + { + } + + void ValueType:: + begin_abstract_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract valuetype def " << id << endl; + + qualifier_ = Qualifier::abstract; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractValueType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractValueType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void ValueType:: + begin_abstract_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract valuetype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractValueType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractValueType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void ValueType:: + begin_concrete_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete valuetype def " << id << endl; + + qualifier_ = Qualifier::concrete; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteValueType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteValueType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void ValueType:: + begin_concrete_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete valuetype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteValueType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteValueType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void ValueType:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::ValueType& v ( + resolve<SemanticGraph::ValueType> (from, name, Flags::defined)); + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + v); + + + bool abstract (dynamic_cast<AbstractValueType*> (&v) != 0); + + if (dynamic_cast<AbstractValueType*> (&now ()) != 0) + { + // Abstract valuetype may only inherit from abstract ones. + // + if (!abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "abstract valuetype `" << now ().name () + << "\' may not inherit from concrete valuetype `" + << v.scoped_name () << "\'" << endl; + return; + } + } + else + { + // Concrete valuetype may inherit from single concrete + // valutype in which case it should be the first in the + // inheritance list. + // + if (now ().inherits_begin () != now ().inherits_end () && + !abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "concrete valuetype `" << v.scoped_name () + << "\' is not the first in the inheritance list of " + << "valuetype `" << now ().name () << "\'" << endl; + return; + } + } + + ctx.tu ().new_edge<Inherits> (now (), v); + ctx.tu ().new_edge<Extends> (now (), v); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no valuetype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from the forward-declared valuetype " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from a forward-declared valuetype is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly inheriting from valuetype \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void ValueType:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void ValueType:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void ValueType:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void ValueType:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.hpp new file mode 100644 index 00000000000..da0bea59a84 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.hpp @@ -0,0 +1,65 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_HPP + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct ValueType : SemanticAction::ValueType, + ScopeBase<SemanticGraph::ValueType> + { + ValueType (Context& c); + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id); + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + + private: + struct Qualifier + { + enum Value { abstract, concrete }; + }; + + Qualifier::Value qualifier_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp new file mode 100644 index 00000000000..f87138f9b70 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp @@ -0,0 +1,152 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + ValueTypeFactory:: + ValueTypeFactory (Context& c) + : Base (c) + { + } + + void ValueTypeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + f_ = 0; + + SemanticGraph::ValueType& h ( + dynamic_cast<SemanticGraph::ValueType&>(ctx.scope ())); + + SimpleName name (id->lexeme ()); + + f_ = &ctx.tu ().new_node<SemanticGraph::ValueTypeFactory> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*f_, h); + ctx.tu ().new_edge<Defines> (ctx.scope (), *f_, name); + } + + + void ValueTypeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (f_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*f_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void ValueTypeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (f_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*f_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp new file mode 100644 index 00000000000..949492152e5 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeFactory.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct ValueTypeFactory : SemanticAction::ValueTypeFactory, Base + { + ValueTypeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::ValueTypeFactory* f_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp new file mode 100644 index 00000000000..c85b8023a07 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp @@ -0,0 +1,149 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp" + +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + ValueTypeMember:: + ValueTypeMember (Context& c) + : Base (c) + { + } + + void ValueTypeMember:: + begin_private () + { + if (ctx.trace ()) + cerr << "private valuetype member" << endl; + + access_ = SemanticGraph::ValueTypeMember::Access::private_; + } + + void ValueTypeMember:: + begin_public () + { + if (ctx.trace ()) + cerr << "public valuetype member" << endl; + + access_ = SemanticGraph::ValueTypeMember::Access::public_; + } + + void ValueTypeMember:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << " type: " << id << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name, Flags::complete); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid valuetype member declaration" << endl; + throw; + } + + //@@ I am not handling NotUnique here. For example if + // I provide module name as type then the compiler + // will ICE. Think about other places it may happen + // (attribute, value memebr, typeded, others?). + // + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-type as a valuetype member type is illegal" + << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + + void ValueTypeMember:: + name (SimpleIdentifierPtr const& id) + { + using namespace SemanticGraph; + + if (ctx.trace ()) cerr << " name: " << id << endl; + + if (type_) + { + SimpleName name (id->lexeme ()); + + SemanticGraph::ValueTypeMember* m; + + switch (access_) + { + case SemanticGraph::ValueTypeMember::Access::private_: + { + m = &ctx.tu ().new_node<ValueTypePrivateMember> ( + ctx.file (), id->line ()); + break; + } + case SemanticGraph::ValueTypeMember::Access::public_: + { + m = &ctx.tu ().new_node<ValueTypePublicMember> ( + ctx.file (), id->line ()); + break; + } + default: + { + abort (); + } + } + + ctx.tu ().new_edge<Belongs> (*m, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), *m, name); + } + } + + void ValueTypeMember:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp new file mode 100644 index 00000000000..96e575cd35f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp @@ -0,0 +1,48 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeMember.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct ValueTypeMember : SemanticAction::ValueTypeMember, Base + { + ValueTypeMember (Context& c); + + virtual void + begin_private (); + + virtual void + begin_public (); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SemanticGraph::ValueTypeMember::Access::Value access_; + SemanticGraph::Type* type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp new file mode 100644 index 00000000000..dda020e73d5 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Include + { + virtual ~Include () + { + } + + virtual void + quote (StringLiteralPtr const& sl) = 0; + + virtual void + bracket (StringLiteralPtr const& sl) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp new file mode 100644 index 00000000000..1f5a327caee --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticAction/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Interface : Scope + { + virtual ~Interface () + { + } + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_local_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_local_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_unconstrained_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_unconstrained_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Member.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Member.hpp new file mode 100644 index 00000000000..e706b7d1a78 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Member.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Member + { + virtual ~Member () + { + } + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp new file mode 100644 index 00000000000..49e9eea7723 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/SemanticAction/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Module : Scope + { + virtual ~Module () + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Native.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Native.hpp new file mode 100644 index 00000000000..368920f2615 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Native.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL2/SemanticAction/Native.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_NATIVE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_NATIVE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Native + { + virtual ~Native () + { + } + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_NATIVE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/NumericExpression.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/NumericExpression.hpp new file mode 100644 index 00000000000..671019133de --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/NumericExpression.hpp @@ -0,0 +1,77 @@ +// file : CCF/IDL2/SemanticAction/NumericExpression.hpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_NUMERIC_EXPRESSION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_NUMERIC_EXPRESSION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct NumericExpression + { + virtual ~NumericExpression () + { + } + + virtual void + flush () = 0; + + virtual void + const_ (IdentifierPtr const&) = 0; + + virtual void + integer_literal (IntegerLiteralPtr const&) = 0; + + virtual void + pre (OperatorPtr const&) = 0; + + virtual void + pos () = 0; + + virtual void + neg () = 0; + + virtual void + com () = 0; + + virtual void + mul () = 0; + + virtual void + div () = 0; + + virtual void + rem () = 0; + + virtual void + add () = 0; + + virtual void + sub () = 0; + + virtual void + rsh () = 0; + + virtual void + lsh () = 0; + + virtual void + and_ () = 0; + + virtual void + xor_ () = 0; + + virtual void + or_ () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_NUMERIC_EXPRESSION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp new file mode 100644 index 00000000000..b75d48400a4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp @@ -0,0 +1,29 @@ +// file : CCF/IDL2/SemanticAction/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Operation.hpp" + +#include <ostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + } + } +} + +namespace +{ + char* labels[] = {"in", "out", "inout"}; +} + +std::ostream& +operator<< (std::ostream& o, + CCF::IDL2::SemanticAction::Operation::Direction::Value d) +{ + return o << labels[d]; +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp new file mode 100644 index 00000000000..7cdd069faa0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp @@ -0,0 +1,62 @@ +// file : CCF/IDL2/SemanticAction/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP + +#include <iosfwd> + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Operation + { + virtual ~Operation () + { + } + + virtual void + one_way () = 0; + + virtual void + two_way () = 0; + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + struct Direction + { + enum Value + { + in = 0, + out, + inout + }; + }; + + virtual void + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +std::ostream& +operator<< (std::ostream& o, + CCF::IDL2::SemanticAction::Operation::Direction::Value d); + +#endif // CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp new file mode 100644 index 00000000000..8a53b85ff15 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Struct.hpp +// author : Jeff Parsons <j.parsons@vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Struct : Scope + { + virtual ~Struct () + { + } + + virtual void + begin_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp new file mode 100644 index 00000000000..535fbc80654 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp @@ -0,0 +1,46 @@ +// file : CCF/IDL2/SemanticAction/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct TypeId + { + virtual ~TypeId () + { + } + + virtual void + begin (IdentifierPtr const& name, StringLiteralPtr const& id) = 0; + + virtual void + end () = 0; + }; + + + struct TypePrefix + { + virtual ~TypePrefix () + { + } + + virtual void + begin (IdentifierPtr const& name, StringLiteralPtr const& prefix) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp new file mode 100644 index 00000000000..ad90573a6bb --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticAction/Typedef.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP +#define CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Typedef + { + virtual ~Typedef () + { + } + + virtual void + pre (KeywordPtr const& id) = 0; + + virtual void + begin (IdentifierPtr const& id) = 0; + + virtual void + begin_unbounded_seq (IdentifierPtr const& id) = 0; + + virtual void + begin_bounded_seq (IdentifierPtr const& id) = 0; + + virtual void + begin_bounded_string () = 0; + + virtual void + begin_bounded_wstring () = 0; + + virtual void + begin_array () = 0; + + virtual void + bound () = 0; + + virtual void + declarator (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/Union.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/Union.hpp new file mode 100644 index 00000000000..8b7c5d51f46 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/Union.hpp @@ -0,0 +1,53 @@ +// file : CCF/IDL2/SemanticAction/Union.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_UNION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_UNION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct Union : Scope + { + virtual ~Union () + { + } + + virtual void + begin_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + type (IdentifierPtr const& id) = 0; + + //@@ Scope declares these functions. Why do I need to + // repeat it here? + // + virtual void + open_scope () = 0; + + virtual void + member_type (IdentifierPtr const& id) = 0; + + virtual void + member_name (SimpleIdentifierPtr const& id) = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_UNION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/ValueType.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueType.hpp new file mode 100644 index 00000000000..2db412f6a32 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueType.hpp @@ -0,0 +1,53 @@ +// file : CCF/IDL2/SemanticAction/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct ValueType : Scope + { + virtual ~ValueType () + { + } + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp new file mode 100644 index 00000000000..f7239c45a94 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL2/SemanticAction/ValueTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct ValueTypeFactory + { + virtual ~ValueTypeFactory () + { + } + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeMember.hpp b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeMember.hpp new file mode 100644 index 00000000000..08fc89fd028 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeMember.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/ValueTypeMember.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_MEMBER_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct ValueTypeMember + { + virtual ~ValueTypeMember () + { + } + + virtual void + begin_private () = 0; + + virtual void + begin_public () = 0; + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp new file mode 100644 index 00000000000..224b0abb7df --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL2/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Array.hpp" +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" +#include "CCF/IDL2/SemanticGraph/Enum.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticGraph/Literals.hpp" +#include "CCF/IDL2/SemanticGraph/Member.hpp" +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Name.hpp" +#include "CCF/IDL2/SemanticGraph/Native.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" +#include "CCF/IDL2/SemanticGraph/String.hpp" +#include "CCF/IDL2/SemanticGraph/Struct.hpp" +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" +#include "CCF/IDL2/SemanticGraph/Union.hpp" +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.cpp new file mode 100644 index 00000000000..3847a6b1ae3 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/SemanticGraph/Array.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Array.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Array + // + // + namespace + { + TypeInfo + array_init_ () + { + TypeInfo ti (typeid (Array)); + ti.add_base ( + Access::PUBLIC, true, Specialization::static_type_info ()); + return ti; + } + + TypeInfo array_ (array_init_ ()); + } + + TypeInfo const& Array:: + static_type_info () { return array_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.hpp new file mode 100644 index 00000000000..baf2e5afe70 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Array.hpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticGraph/Array.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ARRAY_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ARRAY_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Array : public virtual Specialization + { + public: + Type& + type () const + { + return + dynamic_cast<ArgumentsWithType&> (**arguments_begin ()).type (); + } + + // You will have to iterate through Arguments edges starting + // from begin + 1 to get to the list of bounds. I suggest that + // you use traversal instead. + // + + virtual bool + complete () const + { + // Is this the right semantic for arrays? + // + return type ().complete (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Array (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ARRAY_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp new file mode 100644 index 00000000000..2b2a99b09fb --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp @@ -0,0 +1,145 @@ +// file : CCF/IDL2/SemanticGraph/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Attribute + // + // + namespace + { + TypeInfo + attribute_init_ () + { + TypeInfo ti (typeid (Attribute)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo attribute_ (attribute_init_ ()); + } + + TypeInfo const& Attribute:: + static_type_info () { return attribute_; } + + Attribute:: + ~Attribute () + { + } + + + // GetRaises + // + // + namespace + { + TypeInfo + get_raises_init_ () + { + TypeInfo ti (typeid (GetRaises)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo get_raises_ (get_raises_init_ ()); + } + + TypeInfo const& GetRaises:: + static_type_info () { return get_raises_; } + + + // ReadAttribute + // + // + namespace + { + TypeInfo + read_attribute_init_ () + { + TypeInfo ti (typeid (ReadAttribute)); + ti.add_base (Access::PUBLIC, true, Attribute::static_type_info ()); + return ti; + } + + TypeInfo read_attribute_ (read_attribute_init_ ()); + } + + TypeInfo const& ReadAttribute:: + static_type_info () { return read_attribute_; } + + + // SetRaises + // + // + namespace + { + TypeInfo + set_raises_init_ () + { + TypeInfo ti (typeid (SetRaises)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo set_raises_ (set_raises_init_ ()); + } + + TypeInfo const& SetRaises:: + static_type_info () { return set_raises_; } + + + // WriteAttribute + // + // + namespace + { + TypeInfo + write_attribute_init_ () + { + TypeInfo ti (typeid (WriteAttribute)); + ti.add_base (Access::PUBLIC, true, Attribute::static_type_info ()); + return ti; + } + + TypeInfo write_attribute_ (write_attribute_init_ ()); + } + + TypeInfo const& WriteAttribute:: + static_type_info () { return write_attribute_; } + + + // ReadWriteAttribute + // + // + namespace + { + TypeInfo + read_write_attribute_init_ () + { + TypeInfo ti (typeid (ReadWriteAttribute)); + ti.add_base ( + Access::PUBLIC, true, ReadAttribute::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, WriteAttribute::static_type_info ()); + return ti; + } + + TypeInfo read_write_attribute_ (read_write_attribute_init_ ()); + } + + TypeInfo const& ReadWriteAttribute:: + static_type_info () { return read_write_attribute_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp new file mode 100644 index 00000000000..c5f041f5c3d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp @@ -0,0 +1,264 @@ +// file : CCF/IDL2/SemanticGraph/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Attribute : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Attribute () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Attribute () = 0; + }; + + + // + // + // + class ReadAttribute; + + // + // + // + class GetRaises : public virtual Edge + { + public: + ReadAttribute& + attribute () const + { + return *attribute_; + } + + Exception& + exception () const + { + return *exception_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + GetRaises () + { + type_info (static_type_info ()); + } + + void + set_left_node (ReadAttribute& a) + { + attribute_ = &a; + } + + void + set_right_node (Exception& n) + { + exception_ = &n; + } + + private: + ReadAttribute* attribute_; + Exception* exception_; + }; + + + // + // + // + class ReadAttribute : public virtual Attribute + { + typedef + std::vector<GetRaises*> + GetRaises_; + + public: + typedef + GetRaises_::const_iterator + GetRaisesIterator; + + GetRaisesIterator + get_raises_begin () const + { + return get_raises_.begin (); + } + + GetRaisesIterator + get_raises_end () const + { + return get_raises_.end (); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ReadAttribute (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + void + add_edge_left (GetRaises& e) + { + get_raises_.push_back (&e); + } + + private: + GetRaises_ get_raises_; + }; + + + // + // + // + class WriteAttribute; + + // + // + // + class SetRaises : public virtual Edge + { + public: + WriteAttribute& + attribute () const + { + return *attribute_; + } + + Exception& + exception () const + { + return *exception_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + SetRaises () + { + type_info (static_type_info ()); + } + + void + set_left_node (WriteAttribute& a) + { + attribute_ = &a; + } + + void + set_right_node (Exception& n) + { + exception_ = &n; + } + + private: + WriteAttribute* attribute_; + Exception* exception_; + }; + + + class WriteAttribute : public virtual Attribute + { + typedef + std::vector<SetRaises*> + SetRaises_; + + public: + typedef + SetRaises_::const_iterator + SetRaisesIterator; + + SetRaisesIterator + set_raises_begin () const + { + return set_raises_.begin (); + } + + SetRaisesIterator + set_raises_end () const + { + return set_raises_.end (); + } + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + WriteAttribute (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + void + add_edge_left (SetRaises& e) + { + set_raises_.push_back (&e); + } + + private: + SetRaises_ set_raises_; + }; + + + // + // + // + class ReadWriteAttribute : public virtual ReadAttribute, + public virtual WriteAttribute + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ReadWriteAttribute (Path const& path, unsigned long line) + : Node (path, line), + ReadAttribute (path, line), + WriteAttribute (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..824c7634404 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp @@ -0,0 +1,656 @@ +// file : CCF/IDL2/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +#include <ostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Edge + // + // + Edge:: + ~Edge () + { + } + + Edge:: + Edge () + { + type_info (static_type_info ()); + } + + namespace + { + TypeInfo + edge_init_ () + { + TypeInfo ti (typeid (Edge)); + // I don't really need this information + // ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); + return ti; + } + + TypeInfo edge_ (edge_init_ ()); + } + + TypeInfo const& Edge:: + static_type_info () { return edge_; } + + + // Node + // + // + Node:: + ~Node () + { + } + + Node:: + Node (Path const& file, unsigned long line) + : file_ (file), line_ (line) + { + type_info (static_type_info ()); + } + + Node:: + Node () + { + abort (); // This ctor should never be called. + } + + namespace + { + TypeInfo + node_init_ () + { + TypeInfo ti (typeid (Node)); + // I don't really need this information + // ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); + return ti; + } + + TypeInfo node_ (node_init_ ()); + } + + TypeInfo const& Node:: + static_type_info () { return node_; } + + + // Names + // + // + namespace + { + TypeInfo + names_init_ () + { + TypeInfo ti (typeid (Names)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo names_ (names_init_ ()); + } + + TypeInfo const& Names:: + static_type_info () { return names_; } + + + // Defines + // + // + namespace + { + TypeInfo + defines_init_ () + { + TypeInfo ti (typeid (Defines)); + ti.add_base ( + Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo defines_ (defines_init_ ()); + } + + TypeInfo const& Defines:: + static_type_info () { return defines_; } + + + // Mentions + // + // + namespace + { + TypeInfo + mentions_init_ () + { + TypeInfo ti (typeid (Mentions)); + ti.add_base (Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo mentions_ (mentions_init_ ()); + } + + TypeInfo const& Mentions:: + static_type_info () { return mentions_; } + + + // Aliases + // + // + namespace + { + TypeInfo + aliases_init_ () + { + TypeInfo ti (typeid (Aliases)); + ti.add_base ( + Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo aliases_ (aliases_init_ ()); + } + + TypeInfo const& Aliases:: + static_type_info () { return aliases_; } + + + // Nameable + // + // + + Nameable:: + ~Nameable () + { + } + + SimpleName Nameable:: + name () const + { + // The first entry should either be Mentions or Defines + // and it is the 'primary' name of the nameable entity. + // + return named_[0]->name (); + } + + ScopedName Nameable:: + scoped_name () const + { + // In general, scope that named us is named, in turn, + // by somebody else. + // + return ScopedName (named_[0]->scope ().scoped_name (), name ()); + } + + namespace + { + TypeInfo + nameable_init_ () + { + TypeInfo ti (typeid (Nameable)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo nameable_ (nameable_init_ ()); + } + + TypeInfo const& Nameable:: + static_type_info () { return nameable_; } + + + // Extends + // + // + namespace + { + TypeInfo + extends_init_ () + { + TypeInfo ti (typeid (Extends)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo extends_ (extends_init_ ()); + } + + TypeInfo const& Extends:: + static_type_info () { return extends_; } + + + // Scope + // + // + Scope:: + ~Scope () + { + } + + Nameables Scope:: + lookup (Name const& name) const + { + Nameables r; + lookup (name, r); + return r; + } + + void Scope:: + lookup (Name const& name, Nameables& result) const + { + SimpleName first (*name.begin ()); + + NamesIteratorPair pair (find (first)); + + if (pair.first != pair.second) // Found something. + { + if (name.simple ()) // last name + { + for (NamesIterator n (pair.first); n != pair.second; ++n) + { + result.insert (&((**n).named ())); + } + } + else + { + Name rest (name.begin () + 1, name.end ()); + + for (NamesIterator n (pair.first); n != pair.second; ++n) + { + Nameable& node ((**n).named ()); + if (Scope* s = dynamic_cast<Scope*> (&node)) + { + s->lookup (rest, result); + } + } + } + } + else // Try scopes that we are an extension of. + { + for (ExtendsIterator i (extends_begin ()), e (extends_end ()); + i != e; ++i) + { + (**i).extendee ().lookup (name, result); + } + } + } + + void Scope:: + add_edge_left (Names& e) + { + names_.push_back (&e); + names_map_[e.name ()].push_back (&e); + } + + namespace + { + TypeInfo + scope_init_ () + { + TypeInfo ti (typeid (Scope)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo scope_ (scope_init_ ()); + } + + TypeInfo const& Scope:: + static_type_info () { return scope_; } + + + // Type + // + // + namespace + { + TypeInfo + type_init_ () + { + TypeInfo ti (typeid (Type)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_ (type_init_ ()); + } + + TypeInfo const& Type:: + static_type_info () { return type_; } + + Type:: + ~Type () + { + } + + // Instance + // + // + namespace + { + TypeInfo + instance_init_ () + { + TypeInfo ti (typeid (Instance)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo instance_ (instance_init_ ()); + } + + TypeInfo const& Instance:: + static_type_info () { return instance_; } + + Instance:: + ~Instance () + { + } + + // Belongs + // + // + namespace + { + TypeInfo + belongs_init_ () + { + TypeInfo ti (typeid (Belongs)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo belongs_ (belongs_init_ ()); + } + + TypeInfo const& Belongs:: + static_type_info () { return belongs_; } + + + // Specialization + // + // + namespace + { + TypeInfo + specialization_init_ () + { + TypeInfo ti (typeid (Specialization)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo specialization_ ( + specialization_init_ ()); + } + + TypeInfo const& Specialization:: + static_type_info () { return specialization_; } + + void Specialization:: + add_edge_right (ArgumentsWithType& e) + { + arguments_.push_back (&e); + } + + void Specialization:: + add_edge_right (ArgumentsWithValue& e) + { + arguments_.push_back (&e); + } + + Specialization:: + ~Specialization () + { + } + + + // Arguments + // + // + namespace + { + TypeInfo + arguments_init_ () + { + TypeInfo ti (typeid (Arguments)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo arguments_ (arguments_init_ ()); + } + + TypeInfo const& Arguments:: + static_type_info () { return arguments_; } + + + // ArgumentsWithType + // + // + namespace + { + TypeInfo + arguments_with_type_init_ () + { + TypeInfo ti (typeid (ArgumentsWithType)); + ti.add_base (Access::PUBLIC, true, Arguments::static_type_info ()); + return ti; + } + + TypeInfo arguments_with_type_ (arguments_with_type_init_ ()); + } + + TypeInfo const& ArgumentsWithType:: + static_type_info () { return arguments_with_type_; } + + + // ArgumentsWithValue + // + // + namespace + { + TypeInfo + arguments_with_value_init_ () + { + TypeInfo ti (typeid (ArgumentsWithValue)); + ti.add_base (Access::PUBLIC, true, Arguments::static_type_info ()); + return ti; + } + + TypeInfo arguments_with_value_ (arguments_with_value_init_ ()); + } + + TypeInfo const& ArgumentsWithValue:: + static_type_info () { return arguments_with_value_; } + + Expression& ArgumentsWithValue:: + value () const + { + return dynamic_cast<Expression&> (argument ()); + } + + void ArgumentsWithValue:: + set_left_node (Expression& n) + { + Arguments::set_left_node (n); + } + + // IsA + // + // + namespace + { + TypeInfo + is_a_init_ () + { + TypeInfo ti (typeid (IsA)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo is_a_ (is_a_init_ ()); + } + + TypeInfo const& IsA:: + static_type_info () { return is_a_; } + + + // Inherits + // + // + namespace + { + TypeInfo + inherits_init_ () + { + TypeInfo ti (typeid (Inherits)); + ti.add_base (Access::PUBLIC, true, IsA::static_type_info ()); + return ti; + } + + TypeInfo inherits_ (inherits_init_ ()); + } + + TypeInfo const& Inherits:: + static_type_info () { return inherits_; } + + + // Initializes + // + // + namespace + { + TypeInfo + initializes_init_ () + { + TypeInfo ti (typeid (Initializes)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo initializes_ (initializes_init_ ()); + } + + TypeInfo const& Initializes:: + static_type_info () { return initializes_; } + + + // Expression + // + // + namespace + { + TypeInfo + expression_init_ () + { + TypeInfo ti (typeid (Expression)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo expression_ (expression_init_ ()); + } + + TypeInfo const& Expression:: + static_type_info () { return expression_; } + + Expression:: + ~Expression () + { + } + + + // Const + // + // + namespace + { + TypeInfo + const_init_ () + { + TypeInfo ti (typeid (Const)); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Expression::static_type_info ()); + return ti; + } + + TypeInfo const_ (const_init_ ()); + } + + TypeInfo const& Const:: + static_type_info () { return const_; } + + Const:: + ~Const () + { + } + + // Contains + // + // + namespace + { + TypeInfo + contains_init_ () + { + TypeInfo ti (typeid (Contains)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo contains_ (contains_init_ ()); + } + + TypeInfo const& Contains:: + static_type_info () { return contains_; } + + + // Container + // + // + namespace + { + TypeInfo + container_init_ () + { + TypeInfo ti (typeid (Container)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo container_ (container_init_ ()); + } + + TypeInfo const& Container:: + static_type_info () { return container_; } + + Container:: + ~Container () + { + } + } + } +} + +// +// +std::ostream& +operator<< (std::ostream& os, CCF::IDL2::SemanticGraph::Path const& path) +{ + return os << path.native_file_string (); +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..1f0c850f25e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp @@ -0,0 +1,1078 @@ +// file : CCF/IDL2/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include <set> +#include <vector> +#include <iosfwd> + +#include "Graph.hpp" + +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Introspection.hpp" +#include "CCF/CompilerElements/Context.hpp" + +#include "CCF/IDL2/SemanticGraph/Name.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + typedef fs::path Path; + + // + // + // + + class Node; + class Edge; + + + // Node & Edge + // + // + class Edge : public virtual Introspection::Object + { + public: + CompilerElements::Context const& + context () const + { + return context_; + } + + CompilerElements::Context& + context () + { + return context_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + virtual + ~Edge (); + + Edge (); + + private: + CompilerElements::Context context_; + }; + + inline bool + operator== (Edge const& x, Edge const& y) + { + return &x == &y; + } + + class Node : public virtual Introspection::Object + { + public: + CompilerElements::Context const& + context () const + { + return context_; + } + + CompilerElements::Context& + context () + { + return context_; + } + + public: + Path const& + file () const + { + return file_; + } + + unsigned long + line () const + { + return line_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + virtual + ~Node () = 0; + + Node (Path const& path, unsigned long line); + + Node (); // For virtual inheritance only. + + // This is a bunch of experimantal sink functions that allow + // extensions in the form of one-way edges (see Executor stuff + // in CIDL for example). + // + void + add_edge_left (Edge&) + { + } + + void + add_edge_right (Edge&) + { + } + + private: + Path file_; + unsigned long line_; + CompilerElements::Context context_; + }; + + inline bool + operator== (Node const& x, Node const& y) + { + return &x == &y; + } + + + // + // + // + class Scope; + class Nameable; + + class Names : public virtual Edge + { + public: + SimpleName + name () const + { + return name_; + } + + Scope& + scope () const + { + return *scope_; + } + + Nameable& + named () const + { + return *named_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Names (SimpleName const& name) + : name_ (name) + { + type_info (static_type_info ()); + } + + void + set_left_node (Scope& n) + { + scope_ = &n; + } + + void + set_right_node (Nameable& n) + { + named_ = &n; + } + + private: + Scope* scope_; + Nameable* named_; + SimpleName name_; + }; + + class Defines : public virtual Names + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Defines (SimpleName const& name) + : Names (name) + { + type_info (static_type_info ()); + } + }; + + + class Mentions : public virtual Names + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Mentions (SimpleName const& name) + : Names (name) + { + type_info (static_type_info ()); + } + }; + + + class Aliases : public virtual Names + { + public: + SimpleName + synonym () const + { + return name (); + } + + /* + + Let me know if you need this function. + + ScopedName + eponym () const + { + } + */ + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Aliases (SimpleName const& synonym) + : Names (synonym) + + { + type_info (static_type_info ()); + } + }; + + + class Nameable : public virtual Node + { + typedef + std::vector<Names*> + Named_; + + public: + virtual SimpleName + name () const; + + virtual ScopedName + scoped_name () const; + + bool + defined () const + { + return defined_; + } + + typedef + Named_::const_iterator + NamedIterator; + + NamedIterator + named_begin () const + { + return named_.begin (); + } + + NamedIterator + named_end () const + { + return named_.end (); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Nameable () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Nameable () = 0; + + void + add_edge_right (Defines& e) + { + defined_ = true; + named_.push_back (&e); + } + + void + add_edge_right (Names& e) + { + named_.push_back (&e); + } + + private: + Named_ named_; + bool defined_; + }; + + typedef + std::set<Nameable*> + Nameables; + + class Scope; + + class Extends : public virtual Edge + { + public: + Scope& extender () const + { + return *extender_; + } + + Scope& extendee () const + { + return *extendee_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Extends () + { + type_info (static_type_info ()); + } + + void + set_left_node (Scope& s) + { + extender_ = &s; + } + + void + set_right_node (Scope& s) + { + extendee_ = &s; + } + + private: + Scope* extender_; + Scope* extendee_; + }; + + class Scope : public virtual Nameable + { + private: + typedef + std::vector<Extends*> + Extends_; + + typedef + std::vector<Names*> + Names_; + + typedef + std::map<SimpleName, Names_> + NamesMap_; + + public: + // + // + typedef + Extends_::const_iterator + ExtendsIterator; + + ExtendsIterator + extends_begin () const + { + return extends_.begin (); + } + + ExtendsIterator + extends_end () const + { + return extends_.end (); + } + + + // + // + typedef + Names_::const_iterator + NamesIterator; + + typedef + std::pair <NamesIterator, NamesIterator> + NamesIteratorPair; + + NamesIterator + names_begin () const + { + return names_.begin (); + } + + NamesIterator + names_end () const + { + return names_.end (); + } + + NamesIteratorPair + find (SimpleName const& name) const + { + NamesMap_::const_iterator i (names_map_.find (name)); + if (i == names_map_.end ()) + { + return NamesIteratorPair (names_.end (), names_.end ()); + } + else + { + return NamesIteratorPair (i->second.begin (), i->second.end ()); + } + } + + Nameables + lookup (Name const& name) const; + + void + lookup (Name const& name, Nameables& result) const; + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Scope () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Scope () = 0; + + void + add_edge_left (Names& e); + + void + add_edge_left (Extends& e) + { + extends_.push_back (&e); + } + + void + add_edge_right (Extends&) + { + } + + using Nameable::add_edge_right; + + private: + Extends_ extends_; + + Names_ names_; + NamesMap_ names_map_; + }; + + + + // + // + // + class Belongs; + class ArgumentsWithType; + + //@@ I can make an alias Classifies for Belongs? + // + + class Type : public virtual Nameable + { + public: + virtual bool + complete () const = 0; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Type () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Type () = 0; + + using Nameable::add_edge_right; + + void + add_edge_right (Belongs& e) + { + slassifies_.push_back (&e); + } + + void + add_edge_left (ArgumentsWithType&) + { + } + + using Node::add_edge_right; + using Node::add_edge_left; + + private: + typedef + std::vector<Belongs*> + Classifies_; + + Classifies_ slassifies_; + }; + + + class Instance : public virtual Node + { + public: + Belongs& + belongs () const + { + return *belongs_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Instance () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Instance () = 0; + + void + add_edge_left (Belongs& e) + { + belongs_ = &e; + } + + private: + Belongs* belongs_; + }; + + + class Belongs : public virtual Edge + { + public: + Instance& + instance () const + { + return *instance_; + } + + Type& + type () const + { + return *type_; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Belongs () + { + type_info (static_type_info ()); + } + + void + set_left_node (Instance& n) + { + instance_ = &n; + } + + void + set_right_node (Type& n) + { + type_ = &n; + } + + private: + Instance* instance_; + Type* type_; + }; + + + // + // + class Arguments; + class ArgumentsWithType; + class ArgumentsWithValue; + + class Specialization: public virtual Type + { + typedef + std::vector<Arguments*> + Arguments_; + + public: + typedef + Arguments_::const_iterator + ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments_.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments_.end (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Specialization () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Specialization () = 0; + + void + add_edge_right (ArgumentsWithType& e); + + void + add_edge_right (ArgumentsWithValue& e); + + private: + Arguments_ arguments_; + }; + + + class Arguments: public virtual Edge + { + public: + Specialization& + specialization () const + { + return *specialization_; + } + + Node& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Arguments () + { + type_info (static_type_info ()); + } + + void + set_left_node (Node& n) + { + argument_ = &n; + } + + void + set_right_node (Specialization& n) + { + specialization_ = &n; + } + + private: + Specialization* specialization_; + Node* argument_; + }; + + class ArgumentsWithType: public virtual Arguments + { + public: + Type& + type () const + { + return dynamic_cast<Type&> (argument ()); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ArgumentsWithType () + { + type_info (static_type_info ()); + } + + void + set_left_node (Type& n) + { + Arguments::set_left_node (n); + } + }; + + class Expression; + + class ArgumentsWithValue: public virtual Arguments + { + public: + Expression& + value () const; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ArgumentsWithValue () + { + type_info (static_type_info ()); + } + + void + set_left_node (Expression& n); + }; + + // + // + // + class IsA : public virtual Edge + { + public: + virtual Type& + subject () const + { + return *subject_; + } + + virtual Type& + object () const + { + return *object_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IsA () + { + type_info (static_type_info ()); + } + + void + set_left_node (Type& n) + { + subject_ = &n; + } + + void + set_right_node (Type& n) + { + object_ = &n; + } + + private: + Type* subject_; + Type* object_; + }; + + + // + // + // + class Inherits : public virtual IsA + { + public: + virtual Type& + inheritor () const + { + return subject (); + } + + virtual Type& + inheritee () const + { + return object (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Inherits () + { + type_info (static_type_info ()); + } + }; + + + // + // + + class Expression; + class Const; + + class Initializes: public virtual Edge + { + public: + Expression& + expression () const + { + return *expression_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Initializes () + { + type_info (static_type_info ()); + } + + void + set_left_node (Expression& e) + { + expression_ = &e; + } + + void + set_right_node (Const&) + { + } + + private: + Expression* expression_; + }; + + + class Expression: public virtual Node + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Expression () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Expression () = 0; + + void + add_edge_left (Initializes&) + { + } + + void + add_edge_left (ArgumentsWithValue&) + { + } + }; + + + class Const: public virtual Instance, + public virtual Nameable, + public virtual Expression + { + public: + Initializes& + initialized () const + { + return *initialized_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Const () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Const () = 0; + + using Instance::add_edge_left; + using Expression::add_edge_left; + + void + add_edge_right (Initializes& i) + { + initialized_ = &i; + } + + using Nameable::add_edge_right; + + private: + Initializes* initialized_; + }; + + + // + // + // + + class Container; + + class Contains : public virtual Edge + { + public: + Node& + element () const + { + return *element_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Contains () + { + type_info (static_type_info ()); + } + + void + set_left_node (Container& n) + { + container_ = &n; + } + + void + set_right_node (Node& n) + { + element_ = &n; + } + + private: + Container* container_; + Node* element_; + }; + + + class Container : public virtual Node + { + typedef + std::vector<Contains*> + Contains_; + + public: + typedef + Contains_::const_iterator + ContainsIterator; + + ContainsIterator + contains_begin () const + { + return contains_.begin (); + } + + ContainsIterator + contains_end () const + { + return contains_.end (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Container () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Container () = 0; + + void + add_edge_left (Contains& e) + { + contains_.push_back (&e); + } + + private: + Contains_ contains_; + }; + } + } +} + +// ADL won't find it because Path is a typedef. Note that this +// function prints in native format. +// +std::ostream& +operator<< (std::ostream& os, CCF::IDL2::SemanticGraph::Path const& path); + +#include "CCF/IDL2/SemanticGraph/Elements.tpp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp new file mode 100644 index 00000000000..a3a1615fe85 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp @@ -0,0 +1,14 @@ +// file : CCF/IDL2/SemanticGraph/Elements.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + } + } +} + diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.cpp new file mode 100644 index 00000000000..e5de88c449e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.cpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticGraph/Enum.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Enum.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Enum + // + // + namespace + { + TypeInfo + enum_init_ () + { + TypeInfo ti (typeid (Enum)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo enum_ (enum_init_ ()); + } + + TypeInfo const& Enum:: + static_type_info () { return enum_; } + + + // Enumerator + // + // + namespace + { + TypeInfo + enumerator_init_ () + { + TypeInfo ti (typeid (Enumerator)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo enumerator_ (enumerator_init_ ()); + } + + TypeInfo const& Enumerator:: + static_type_info () { return enumerator_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.hpp new file mode 100644 index 00000000000..9179b471791 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Enum.hpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticGraph/Enum.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ENUM_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ENUM_HPP + +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Enum : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Enum (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + class Enumerator : public virtual Nameable, public virtual IntConst + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Enumerator (Path const& path, unsigned long line) + : Node (path, line), IntConst (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ENUM_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp new file mode 100644 index 00000000000..9ed3a7e494b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/SemanticGraph/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + exception_init_ () + { + TypeInfo ti (typeid (Exception)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo exception_ (exception_init_ ()); + } + + TypeInfo const& Exception:: + static_type_info () { return exception_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp new file mode 100644 index 00000000000..712cdf1ca8a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp @@ -0,0 +1,51 @@ +// file : CCF/IDL2/SemanticGraph/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Raises; + + class Exception : public virtual Type, public virtual Scope + { + public: + virtual bool + complete () const + { + return defined (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Exception (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_right (Raises&) + { + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp new file mode 100644 index 00000000000..789accfe3b9 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp @@ -0,0 +1,443 @@ +// file : CCF/IDL2/SemanticGraph/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // FundamentalType + // + // + namespace + { + TypeInfo + fundamental_type_init_ () + { + TypeInfo ti (typeid (FundamentalType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo fundamental_type_ (fundamental_type_init_ ()); + } + + TypeInfo const& FundamentalType:: + static_type_info () { return fundamental_type_; } + + FundamentalType:: + ~FundamentalType () + { + } + + + // Object + // + // + namespace + { + TypeInfo + object_init_ () + { + TypeInfo ti (typeid (Object)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo object_ (object_init_ ()); + } + + TypeInfo const& Object:: + static_type_info () { return object_; } + + + // ValueBase + // + // + namespace + { + TypeInfo + value_base_init_ () + { + TypeInfo ti (typeid (ValueBase)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo value_base_ (value_base_init_ ()); + } + + TypeInfo const& ValueBase:: + static_type_info () { return value_base_; } + + + // Any + // + // + namespace + { + TypeInfo + any_init_ () + { + TypeInfo ti (typeid (Any)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo any_ (any_init_ ()); + } + + TypeInfo const& Any:: + static_type_info () { return any_; } + + + // Boolean + // + // + namespace + { + TypeInfo + boolean_init_ () + { + TypeInfo ti (typeid (Boolean)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo boolean_ (boolean_init_ ()); + } + + TypeInfo const& Boolean:: + static_type_info () { return boolean_; } + + + // Char + // + // + namespace + { + TypeInfo + char_init_ () + { + TypeInfo ti (typeid (Char)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo char_ (char_init_ ()); + } + + TypeInfo const& Char:: + static_type_info () { return char_; } + + + // Double + // + // + namespace + { + TypeInfo + double_init_ () + { + TypeInfo ti (typeid (Double)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo double_ (double_init_ ()); + } + + TypeInfo const& Double:: + static_type_info () { return double_; } + + + // Float + // + // + namespace + { + TypeInfo + float_init_ () + { + TypeInfo ti (typeid (Float)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo float_ (float_init_ ()); + } + + TypeInfo const& Float:: + static_type_info () { return float_; } + + + // Long + // + // + namespace + { + TypeInfo + long_init_ () + { + TypeInfo ti (typeid (Long)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_ (long_init_ ()); + } + + TypeInfo const& Long:: + static_type_info () { return long_; } + + + // LongDouble + // + // + namespace + { + TypeInfo + long_double_init_ () + { + TypeInfo ti (typeid (LongDouble)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_double_ (long_double_init_ ()); + } + + TypeInfo const& LongDouble:: + static_type_info () { return long_double_; } + + + // LongLong + // + // + namespace + { + TypeInfo + long_long_init_ () + { + TypeInfo ti (typeid (LongLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_long_ (long_long_init_ ()); + } + + TypeInfo const& LongLong:: + static_type_info () { return long_long_; } + + + // Octet + // + // + namespace + { + TypeInfo + octet_init_ () + { + TypeInfo ti (typeid (Octet)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo octet_ (octet_init_ ()); + } + + TypeInfo const& Octet:: + static_type_info () { return octet_; } + + + // Short + // + // + namespace + { + TypeInfo + short_init_ () + { + TypeInfo ti (typeid (Short)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo short_ (short_init_ ()); + } + + TypeInfo const& Short:: + static_type_info () { return short_; } + + + // String + // + // + namespace + { + TypeInfo + string_init_ () + { + TypeInfo ti (typeid (String)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo string_ (string_init_ ()); + } + + TypeInfo const& String:: + static_type_info () { return string_; } + + + // UnsignedLong + // + // + namespace + { + TypeInfo + unsigned_long_init_ () + { + TypeInfo ti (typeid (UnsignedLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_long_ (unsigned_long_init_ ()); + } + + TypeInfo const& UnsignedLong:: + static_type_info () { return unsigned_long_; } + + + // UnsignedLongLong + // + // + namespace + { + TypeInfo + unsigned_long_long_init_ () + { + TypeInfo ti (typeid (UnsignedLongLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_long_long_ (unsigned_long_long_init_ ()); + } + + TypeInfo const& UnsignedLongLong:: + static_type_info () { return unsigned_long_long_; } + + + // UnsignedShort + // + // + namespace + { + TypeInfo + unsigned_short_init_ () + { + TypeInfo ti (typeid (UnsignedShort)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_short_ (unsigned_short_init_ ()); + } + + TypeInfo const& UnsignedShort:: + static_type_info () { return unsigned_short_; } + + + // Void + // + // + namespace + { + TypeInfo + void_init_ () + { + TypeInfo ti (typeid (Void)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo void_ (void_init_ ()); + } + + TypeInfo const& Void:: + static_type_info () { return void_; } + + + // Wchar + // + // + namespace + { + TypeInfo + wchar_init_ () + { + TypeInfo ti (typeid (Wchar)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo wchar_ (wchar_init_ ()); + } + + TypeInfo const& Wchar:: + static_type_info () { return wchar_; } + + + // Wstring + // + // + namespace + { + TypeInfo + wstring_init_ () + { + TypeInfo ti (typeid (Wstring)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo wstring_ (wstring_init_ ()); + } + + TypeInfo const& Wstring:: + static_type_info () { return wstring_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 new file mode 100644 index 00000000000..da1d8eca574 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 @@ -0,0 +1,103 @@ +divert(-1) + +# file : CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +include(`Fundamental.m4') + +define(`fundamental_type', + `fundamental_type_impl(`make_class_name(`$1')', `make_var_name(`$1')')') + + +define(`fundamental_type_impl', ` + + // $1 + // + // + namespace + { + TypeInfo + $2_init_ () + { + TypeInfo ti (typeid ($1)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo $2_ ($2_init_ ()); + } + + TypeInfo const& $1:: + static_type_info () { return $2_; }') + +divert(0)dnl +dnl +dnl +dnl +// file : CCF/IDL2/SemanticGraph/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // FundamentalType + // + // + namespace + { + TypeInfo + fundamental_type_init_ () + { + TypeInfo ti (typeid (FundamentalType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo fundamental_type_ (fundamental_type_init_ ()); + } + + TypeInfo const& FundamentalType:: + static_type_info () { return fundamental_type_; } + + FundamentalType:: + ~FundamentalType () + { + } +dnl +fundamental_type(`object') +fundamental_type(`value base') +fundamental_type(`any') +fundamental_type(`boolean') +fundamental_type(`char') +fundamental_type(`double') +fundamental_type(`float') +fundamental_type(`long') +fundamental_type(`long double') +fundamental_type(`long long') +fundamental_type(`octet') +fundamental_type(`short') +fundamental_type(`string') +fundamental_type(`unsigned long') +fundamental_type(`unsigned long long') +fundamental_type(`unsigned short') +fundamental_type(`void') +fundamental_type(`wchar') +fundamental_type(`wstring') +dnl + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp new file mode 100644 index 00000000000..a756acc352e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp @@ -0,0 +1,427 @@ +// file : CCF/IDL2/SemanticGraph/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // @@ Object & ValueBase should be of interface & valuetype types? + // + // + class FundamentalType : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + FundamentalType () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~FundamentalType () = 0; + }; + + + // + // + // + class Object : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Object (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ValueBase : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueBase (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Any : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Any (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Boolean : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Boolean (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Char : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Char (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Double : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Double (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Float : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Float (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Long : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Long (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LongDouble : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LongDouble (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LongLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LongLong (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Octet : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Octet (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Short : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Short (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class String : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + String (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedLong (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedLongLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedLongLong (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedShort : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedShort (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Void : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Void (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Wchar : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Wchar (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Wstring : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Wstring (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 new file mode 100644 index 00000000000..864dcd76435 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 @@ -0,0 +1,102 @@ +divert(-1) + +# file : CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +include(`Fundamental.m4') + +define(`fundamental_type', `fundamental_type_impl(`make_class_name(`$1')', `$1')') + +define(`fundamental_type_impl', ` + + // + // + // + class $1 : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + $1 (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + };') +divert(0)dnl +dnl +dnl +dnl +// file : CCF/IDL2/SemanticGraph/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // @@ Object & ValueBase should be of interface & valuetype types? + // + // + class FundamentalType : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + FundamentalType () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~FundamentalType () = 0; + }; +dnl +fundamental_type(`Object') +fundamental_type(`ValueBase') +fundamental_type(`any') +fundamental_type(`boolean') +fundamental_type(`char') +fundamental_type(`double') +fundamental_type(`float') +fundamental_type(`long') +fundamental_type(`long double') +fundamental_type(`long long') +fundamental_type(`octet') +fundamental_type(`short') +fundamental_type(`string') +fundamental_type(`unsigned long') +fundamental_type(`unsigned long long') +fundamental_type(`unsigned short') +fundamental_type(`void') +fundamental_type(`wchar') +fundamental_type(`wstring') +dnl + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 new file mode 100644 index 00000000000..5aaab71bd76 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 @@ -0,0 +1,17 @@ +# file : CCF/IDL2/SemanticGraph/Fundamental.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +define(`upcase', `translit(`$*', `a-z', `A-Z')') + + +define(`capitalize_word', + `regexp(`$1', `^\(.\)\(.*\)', `upcase(`\1')`\2'')') + + +define(`capitalize', + `patsubst(`$1', `\w+', `capitalize_word(`\&')')') + +define(`make_class_name', `patsubst(capitalize(`$1'), ` ')') + +define(`make_var_name', `patsubst(`$1', ` ', `_')') diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp new file mode 100644 index 00000000000..f71140569de --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp @@ -0,0 +1,91 @@ +// file : CCF/IDL2/SemanticGraph/Graph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef ELEMENT_GRAPH_HPP +#define ELEMENT_GRAPH_HPP + +#include <map> +#include <set> +#include <vector> +#include <string> +#include <memory> + +#include <iostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + template <typename N, typename E> + class Graph + { + public: + ~Graph (); + + public: + template <typename T> + T& + new_node (); + + template <typename T, typename A0> + T& + new_node (A0 const& a0); + + template <typename T, typename A0, typename A1> + T& + new_node (A0 const& a0, A1 const& a1); + + template <typename T, typename A0, typename A1, typename A2> + T& + new_node (A0 const& a0, A1 const& a1, A2 const& a2); + + template <typename T, + typename A0, + typename A1, + typename A2, + typename A3> + T& + new_node (A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3); + + void + delete_node (N const& n); + + public: + template <typename T, typename X, typename Y> + T& + new_edge (X& left, Y& right); + + template <typename T, typename X, typename Y, + typename A0> + T& + new_edge (X& left, Y& right, A0 const& a0); + + template <typename T, typename X, typename Y, + typename A0, + typename A1> + T& + new_edge (X& left, Y& right, A0 const& a0, A1 const& a1); + + void + delete_edge (E const& e); + + protected: + typedef N* NodePtr; + typedef E* EdgePtr; + + typedef std::set<NodePtr> Nodes_; + typedef std::set<EdgePtr> Edges_; + + Nodes_ nodes_; + Edges_ edges_; + }; + } + } +} + +#include "Graph.tpp" + +#endif // ELEMENT_GRAPH_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp new file mode 100644 index 00000000000..37a952a3f34 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp @@ -0,0 +1,188 @@ +// file : CCF/IDL2/SemanticGraph/Graph.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Graph + // + // + + + template <typename N, typename E> + template <typename T> + T& Graph<N, E>:: + new_node () + { + T* n (new T); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + template <typename T, typename A0> + T& Graph<N, E>:: + new_node (A0 const& a0) + { + T* n (new T (a0)); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + template <typename T, typename A0, typename A1> + T& Graph<N, E>:: + new_node (A0 const& a0, A1 const& a1) + { + T* n (new T (a0, a1)); //@@ auto + nodes_.insert (n); + return *n; + } + + template <typename N, typename E> + template <typename T, typename A0, typename A1, typename A2> + T& Graph<N, E>:: + new_node (A0 const& a0, A1 const& a1, A2 const& a2) + { + T* n (new T (a0, a1, a2)); //@@ auto + nodes_.insert (n); + return *n; + } + + template <typename N, typename E> + template <typename T, + typename A0, + typename A1, + typename A2, + typename A3> + T& Graph<N, E>:: + new_node (A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) + { + T* n (new T (a0, a1, a2, a3)); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + void Graph<N, E>:: + delete_node (N const& nr) + { + N* n (&nr); + + for (E* e (n->remove_edge_ ()); e != 0; e = n->remove_edge_ ()) + { + // One endpoint of the edge has removed this edge from + // its edge set. Now handle the other endpoint. + // + if (e->left_ () == n) e->right_ ()->remove_edge_ (e); + else e->left_ ()->remove_edge_ (e); + + // Delete the edge. + // + edges_.erase (e); + + delete e; //@@ auto + } + + nodes_.erase (n); + + delete n; //@@ auto + } + + + template <typename N, typename E> + template <typename T, typename X, typename Y> + T& Graph<N, E>:: + new_edge (X& left, Y& right) + { + T* e (new T); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + template <typename T, typename X, typename Y, + typename A0> + T& Graph<N, E>:: + new_edge (X& left, Y& right, A0 const& a0) + { + T* e (new T (a0)); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + template <typename T, typename X, typename Y, + typename A0, + typename A1> + T& Graph<N, E>:: + new_edge (X& left, Y& right, A0 const& a0, A1 const& a1) + { + T* e (new T (a0, a1)); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + void Graph<N, E>:: + delete_edge (E const& er) + { + E* e (&er); + + e->left_ ()->remove_edge_ (e); + e->right_ ()->remove_edge_ (e); + + edges_.erase (e); + + delete e; //@@ auto + } + + + template <typename N, typename E> + Graph<N, E>:: + ~Graph () + { + //@@ auto + + for (typename Edges_::iterator i (edges_.begin ()), end (edges_.end ()); + i != end; + ++i) delete *i; + + for (typename Nodes_::iterator i (nodes_.begin ()), end (nodes_.end ()); + i != end; + ++i) delete *i; + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.cpp new file mode 100644 index 00000000000..a6633df762b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.cpp @@ -0,0 +1,486 @@ +// file : CCF/IDL2/SemanticGraph/IntExpression.cpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // IntExpression + // + namespace + { + TypeInfo + int_expression_init_ () + { + TypeInfo ti (typeid (IntExpression)); + ti.add_base (Access::PUBLIC, true, Expression::static_type_info ()); + return ti; + } + + TypeInfo int_expression_ (int_expression_init_ ()); + } + + TypeInfo const& IntExpression:: + static_type_info () { return int_expression_; } + + IntExpression:: + ~IntExpression () + { + } + + // IntLiteral + // + namespace + { + TypeInfo + int_literal_init_ () + { + TypeInfo ti (typeid (IntLiteral)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_literal_ (int_literal_init_ ()); + } + + TypeInfo const& IntLiteral:: + static_type_info () { return int_literal_; } + + + // IntConst + // + namespace + { + TypeInfo + int_const_init_ () + { + TypeInfo ti (typeid (IntConst)); + ti.add_base (Access::PUBLIC, true, Const::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_const_ (int_const_init_ ()); + } + + TypeInfo const& IntConst:: + static_type_info () { return int_const_; } + + + // NEG + // + + namespace + { + TypeInfo + int_negates_init_ () + { + TypeInfo ti (typeid (IntNegates)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_negates_ (int_negates_init_ ()); + } + + TypeInfo const& IntNegates:: + static_type_info () { return int_negates_; } + + namespace + { + TypeInfo + int_neg_init_ () + { + TypeInfo ti (typeid (IntNeg)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_neg_ (int_neg_init_ ()); + } + + TypeInfo const& IntNeg:: + static_type_info () { return int_neg_; } + + + // COM + // + + namespace + { + TypeInfo + int_complements_init_ () + { + TypeInfo ti (typeid (IntComplements)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_complements_ (int_complements_init_ ()); + } + + TypeInfo const& IntComplements:: + static_type_info () { return int_complements_; } + + namespace + { + TypeInfo + int_com_init_ () + { + TypeInfo ti (typeid (IntCom)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_com_ (int_com_init_ ()); + } + + TypeInfo const& IntCom:: + static_type_info () { return int_com_; } + + + // MUL + // + + namespace + { + TypeInfo + int_multiplies_init_ () + { + TypeInfo ti (typeid (IntMultiplies)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_multiplies_ (int_multiplies_init_ ()); + } + + TypeInfo const& IntMultiplies:: + static_type_info () { return int_multiplies_; } + + namespace + { + TypeInfo + int_mul_init_ () + { + TypeInfo ti (typeid (IntMul)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_mul_ (int_mul_init_ ()); + } + + TypeInfo const& IntMul:: + static_type_info () { return int_mul_; } + + + // DIV + // + + namespace + { + TypeInfo + int_divides_init_ () + { + TypeInfo ti (typeid (IntDivides)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_divides_ (int_divides_init_ ()); + } + + TypeInfo const& IntDivides:: + static_type_info () { return int_divides_; } + + namespace + { + TypeInfo + int_div_init_ () + { + TypeInfo ti (typeid (IntDiv)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_div_ (int_div_init_ ()); + } + + TypeInfo const& IntDiv:: + static_type_info () { return int_div_; } + + namespace + { + TypeInfo + int_rem_init_ () + { + TypeInfo ti (typeid (IntRem)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_rem_ (int_rem_init_ ()); + } + + TypeInfo const& IntRem:: + static_type_info () { return int_rem_; } + + + // ADD + // + + namespace + { + TypeInfo + int_adds_init_ () + { + TypeInfo ti (typeid (IntAdds)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_adds_ (int_adds_init_ ()); + } + + TypeInfo const& IntAdds:: + static_type_info () { return int_adds_; } + + namespace + { + TypeInfo + int_add_init_ () + { + TypeInfo ti (typeid (IntAdd)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_add_ (int_add_init_ ()); + } + + TypeInfo const& IntAdd:: + static_type_info () { return int_add_; } + + + // SUB + // + + namespace + { + TypeInfo + int_subtracts_init_ () + { + TypeInfo ti (typeid (IntSubtracts)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_subtracts_ (int_subtracts_init_ ()); + } + + TypeInfo const& IntSubtracts:: + static_type_info () { return int_subtracts_; } + + namespace + { + TypeInfo + int_sub_init_ () + { + TypeInfo ti (typeid (IntSub)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_sub_ (int_sub_init_ ()); + } + + TypeInfo const& IntSub:: + static_type_info () { return int_sub_; } + + + // RSH & LSH + // + + namespace + { + TypeInfo + int_shifts_init_ () + { + TypeInfo ti (typeid (IntShifts)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_shifts_ (int_shifts_init_ ()); + } + + TypeInfo const& IntShifts:: + static_type_info () { return int_shifts_; } + + namespace + { + TypeInfo + int_rsh_init_ () + { + TypeInfo ti (typeid (IntRsh)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_rsh_ (int_rsh_init_ ()); + } + + TypeInfo const& IntRsh:: + static_type_info () { return int_rsh_; } + + namespace + { + TypeInfo + int_lsh_init_ () + { + TypeInfo ti (typeid (IntLsh)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_lsh_ (int_lsh_init_ ()); + } + + TypeInfo const& IntLsh:: + static_type_info () { return int_lsh_; } + + + // AND + // + + namespace + { + TypeInfo + int_conjuncts_init_ () + { + TypeInfo ti (typeid (IntConjuncts)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_conjuncts_ (int_conjuncts_init_ ()); + } + + TypeInfo const& IntConjuncts:: + static_type_info () { return int_conjuncts_; } + + namespace + { + TypeInfo + int_and_init_ () + { + TypeInfo ti (typeid (IntAnd)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_and_ (int_and_init_ ()); + } + + TypeInfo const& IntAnd:: + static_type_info () { return int_and_; } + + + // XOR + // + + namespace + { + TypeInfo + int_exclusively_disjuncts_init_ () + { + TypeInfo ti (typeid (IntExclusivelyDisjuncts)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_exclusively_disjuncts_ ( + int_exclusively_disjuncts_init_ ()); + } + + TypeInfo const& IntExclusivelyDisjuncts:: + static_type_info () { return int_exclusively_disjuncts_; } + + namespace + { + TypeInfo + int_xor_init_ () + { + TypeInfo ti (typeid (IntXor)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_xor_ (int_xor_init_ ()); + } + + TypeInfo const& IntXor:: + static_type_info () { return int_xor_; } + + + // OR + // + + namespace + { + TypeInfo + int_inclusively_disjuncts_init_ () + { + TypeInfo ti (typeid (IntInclusivelyDisjuncts)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo int_inclusively_disjuncts_ ( + int_inclusively_disjuncts_init_ ()); + } + + TypeInfo const& IntInclusivelyDisjuncts:: + static_type_info () { return int_inclusively_disjuncts_; } + + namespace + { + TypeInfo + int_or_init_ () + { + TypeInfo ti (typeid (IntOr)); + ti.add_base ( + Access::PUBLIC, true, IntExpression::static_type_info ()); + return ti; + } + + TypeInfo int_or_ (int_or_init_ ()); + } + + TypeInfo const& IntOr:: + static_type_info () { return int_or_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.hpp new file mode 100644 index 00000000000..263563e9bb6 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/IntExpression.hpp @@ -0,0 +1,1013 @@ +// file : CCF/IDL2/SemanticGraph/IntExpression.hpp +// author : Boris Kolpackov <boris@kolpackov.net> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_INT_EXPRESSION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_INT_EXPRESSION_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + class IntExpression: public virtual Expression + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntExpression () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~IntExpression () = 0; + }; + + + // + // + class IntLiteral: public virtual IntExpression + { + public: + unsigned long long + value () const + { + return value_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntLiteral (Path const& path, + unsigned long line, + unsigned long long value) + : Node (path, line), value_ (value) + { + type_info (static_type_info ()); + } + + private: + unsigned long long value_; + }; + + + // + // + class IntConst: public virtual Const, + public virtual IntExpression + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntConst (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // NEG + // + + class IntNeg; + + class IntNegates: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntNegates () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntNeg&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntNeg: public virtual IntExpression + { + public: + IntNegates& + negates () const + { + return *negates_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntNeg (Path const& path, unsigned long line) + : Node (path, line), negates_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntNegates& n) + { + negates_ = &n; + } + + private: + IntNegates* negates_; + }; + + + // COM + // + + class IntCom; + + class IntComplements: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntComplements () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntCom&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntCom: public virtual IntExpression + { + public: + IntComplements& + complements () const + { + return *complements_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntCom (Path const& path, unsigned long line) + : Node (path, line), complements_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntComplements& n) + { + complements_ = &n; + } + + private: + IntComplements* complements_; + }; + + + // MUL + // + + class IntMul; + + class IntMultiplies: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntMultiplies () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntMul&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntMul: public virtual IntExpression + { + public: + IntMultiplies& + first_factor () const + { + return *first_factor_; + } + + IntMultiplies& + second_factor () const + { + return *second_factor_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntMul (Path const& path, unsigned long line) + : Node (path, line), + first_factor_ (0), + second_factor_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntMultiplies& d) + { + if (first_factor_ == 0) + first_factor_ = &d; + else + second_factor_ = &d; + } + + private: + IntMultiplies* first_factor_; + IntMultiplies* second_factor_; + }; + + + // DIV & REM + // + + class IntDiv; + class IntRem; + + class IntDivides: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntDivides () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntDiv&) + { + } + + void + set_left_node (IntRem&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntDiv: public virtual IntExpression + { + public: + IntDivides& + divident () const + { + return *divident_; + } + + IntDivides& + divisor () const + { + return *divisor_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntDiv (Path const& path, unsigned long line) + : Node (path, line), + divident_ (0), + divisor_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntDivides& d) + { + if (divident_ == 0) + divident_ = &d; + else + divisor_ = &d; + } + + private: + IntDivides* divident_; + IntDivides* divisor_; + }; + + class IntRem: public virtual IntExpression + { + public: + IntDivides& + divident () const + { + return *divident_; + } + + IntDivides& + divisor () const + { + return *divisor_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntRem (Path const& path, unsigned long line) + : Node (path, line), + divident_ (0), + divisor_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntDivides& d) + { + if (divident_ == 0) + divident_ = &d; + else + divisor_ = &d; + } + + private: + IntDivides* divident_; + IntDivides* divisor_; + }; + + + // ADD + // + + class IntAdd; + + class IntAdds: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntAdds () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntAdd&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntAdd: public virtual IntExpression + { + public: + IntAdds& + first_item () const + { + return *first_item_; + } + + IntAdds& + second_item () const + { + return *second_item_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntAdd (Path const& path, unsigned long line) + : Node (path, line), + first_item_ (0), + second_item_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntAdds& d) + { + if (first_item_ == 0) + first_item_ = &d; + else + second_item_ = &d; + } + + private: + IntAdds* first_item_; + IntAdds* second_item_; + }; + + + // SUB + // + + class IntSub; + + class IntSubtracts: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntSubtracts () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntSub&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntSub: public virtual IntExpression + { + public: + IntSubtracts& + minuend () const + { + return *minuend_; + } + + IntSubtracts& + subtrahend () const + { + return *subtrahend_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntSub (Path const& path, unsigned long line) + : Node (path, line), + minuend_ (0), + subtrahend_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntSubtracts& d) + { + if (minuend_ == 0) + minuend_ = &d; + else + subtrahend_ = &d; + } + + private: + IntSubtracts* minuend_; + IntSubtracts* subtrahend_; + }; + + + // RSH & LSH + // + + class IntRsh; + class IntLsh; + + class IntShifts: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntShifts () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntRsh&) + { + } + + void + set_left_node (IntLsh&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntRsh: public virtual IntExpression + { + public: + IntShifts& + pattern () const + { + return *pattern_; + } + + IntShifts& + factor () const + { + return *factor_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntRsh (Path const& path, unsigned long line) + : Node (path, line), + pattern_ (0), + factor_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntShifts& d) + { + if (pattern_ == 0) + pattern_ = &d; + else + factor_ = &d; + } + + private: + IntShifts* pattern_; + IntShifts* factor_; + }; + + class IntLsh: public virtual IntExpression + { + public: + IntShifts& + pattern () const + { + return *pattern_; + } + + IntShifts& + factor () const + { + return *factor_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntLsh (Path const& path, unsigned long line) + : Node (path, line), + pattern_ (0), + factor_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntShifts& d) + { + if (pattern_ == 0) + pattern_ = &d; + else + factor_ = &d; + } + + private: + IntShifts* pattern_; + IntShifts* factor_; + }; + + + // AND + // + + class IntAnd; + + class IntConjuncts: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntConjuncts () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntAnd&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntAnd: public virtual IntExpression + { + public: + IntConjuncts& + first_pattern () const + { + return *first_pattern_; + } + + IntConjuncts& + second_pattern () const + { + return *second_pattern_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntAnd (Path const& path, unsigned long line) + : Node (path, line), + first_pattern_ (0), + second_pattern_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntConjuncts& d) + { + if (first_pattern_ == 0) + first_pattern_ = &d; + else + second_pattern_ = &d; + } + + private: + IntConjuncts* first_pattern_; + IntConjuncts* second_pattern_; + }; + + + // XOR + // + + class IntXor; + + class IntExclusivelyDisjuncts: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntExclusivelyDisjuncts () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntXor&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntXor: public virtual IntExpression + { + public: + IntExclusivelyDisjuncts& + first_pattern () const + { + return *first_pattern_; + } + + IntExclusivelyDisjuncts& + second_pattern () const + { + return *second_pattern_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntXor (Path const& path, unsigned long line) + : Node (path, line), + first_pattern_ (0), + second_pattern_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntExclusivelyDisjuncts& d) + { + if (first_pattern_ == 0) + first_pattern_ = &d; + else + second_pattern_ = &d; + } + + private: + IntExclusivelyDisjuncts* first_pattern_; + IntExclusivelyDisjuncts* second_pattern_; + }; + + + // OR + // + + class IntOr; + + class IntInclusivelyDisjuncts: public virtual Edge + { + public: + IntExpression& + argument () const + { + return *argument_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntInclusivelyDisjuncts () + { + type_info (static_type_info ()); + } + + void + set_left_node (IntOr&) + { + } + + void + set_right_node (IntExpression& e) + { + argument_ = &e; + } + + private: + IntExpression* argument_; + }; + + + class IntOr: public virtual IntExpression + { + public: + IntInclusivelyDisjuncts& + first_pattern () const + { + return *first_pattern_; + } + + IntInclusivelyDisjuncts& + second_pattern () const + { + return *second_pattern_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IntOr (Path const& path, unsigned long line) + : Node (path, line), + first_pattern_ (0), + second_pattern_ (0) + { + type_info (static_type_info ()); + } + + void + add_edge_left (IntInclusivelyDisjuncts& d) + { + if (first_pattern_ == 0) + first_pattern_ = &d; + else + second_pattern_ = &d; + } + + private: + IntInclusivelyDisjuncts* first_pattern_; + IntInclusivelyDisjuncts* second_pattern_; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_INT_EXPRESSION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp new file mode 100644 index 00000000000..4083549f3e2 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp @@ -0,0 +1,122 @@ +// file : CCF/IDL2/SemanticGraph/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // Interface + // + // + namespace + { + TypeInfo + interface_init_ () + { + TypeInfo ti (typeid (Interface)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo interface_ (interface_init_ ()); + } + + TypeInfo const& Interface:: + static_type_info () { return interface_; } + + Interface:: + ~Interface () + { + } + + // Supports + // + // + namespace + { + TypeInfo + supports_init_ () + { + TypeInfo ti (typeid (Supports)); + ti.add_base (Access::PUBLIC, true, IsA::static_type_info ()); + return ti; + } + + TypeInfo supports_ (supports_init_ ()); + } + + TypeInfo const& Supports:: + static_type_info () { return supports_; } + + + // AbstractInterface + // + // + namespace + { + TypeInfo + abstract_interface_init_ () + { + TypeInfo ti (typeid (AbstractInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo abstract_interface_ (abstract_interface_init_ ()); + } + + TypeInfo const& AbstractInterface:: + static_type_info () { return abstract_interface_; } + + + // LocalInterface + // + // + namespace + { + TypeInfo + local_interface_init_ () + { + TypeInfo ti (typeid (LocalInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo local_interface_ (local_interface_init_ ()); + } + + TypeInfo const& LocalInterface:: + static_type_info () { return local_interface_; } + + + // UnconstrainedInterface + // + // + namespace + { + TypeInfo + unconstrained_interface_init_ () + { + TypeInfo ti (typeid (UnconstrainedInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo unconstrained_interface_ (unconstrained_interface_init_ ()); + } + + TypeInfo const& UnconstrainedInterface:: + static_type_info () { return unconstrained_interface_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp new file mode 100644 index 00000000000..1335b69a6cb --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp @@ -0,0 +1,181 @@ +// file : CCF/IDL2/SemanticGraph/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Interface : public virtual Type, public virtual Scope + { + typedef + std::vector <Inherits*> + Inherits_; + + public: + typedef + Inherits_::const_iterator + InheritsIterator; + + InheritsIterator + inherits_begin () const + { + return inherits_.begin (); + } + + InheritsIterator + inherits_end () const + { + return inherits_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Interface () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Interface () = 0; + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_.push_back (&e); + } + + void + add_edge_right (Inherits&) + { + } + + private: + Inherits_ inherits_; + }; + + + // + // + // + class Supports : public virtual IsA + { + public: + virtual Type& + supporter () const + { + return subject (); + } + + virtual Type& + supportee () const + { + return object (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Supports () + { + type_info (static_type_info ()); + } + + void + set_right_node (Interface& n) + { + IsA::set_right_node (n); + } + }; + + + // + // + // + class AbstractInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractInterface (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LocalInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LocalInterface (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnconstrainedInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnconstrainedInterface (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp new file mode 100644 index 00000000000..86c64116b23 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp @@ -0,0 +1,24 @@ +// file : CCF/IDL2/SemanticGraph/Literals.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Literals.hpp" + +#include <ostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + } + } +} + +std::ostream& +operator<< (std::ostream& o, + CCF::IDL2::SemanticGraph::StringLiteral const& lit) +{ + return o << '\"' << lit.literal () << '\"'; +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp new file mode 100644 index 00000000000..b2a350027db --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticGraph/Literals.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP + +#include <string> +#include <iosfwd> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class StringLiteral + { + public: + StringLiteral (std::string const& literal) + : literal_ (literal) + { + } + + std::string + literal () const + { + return literal_; + } + + private: + std::string literal_; + }; + + inline bool + operator== (StringLiteral const& a, StringLiteral const& b) + { + return a.literal () == b.literal (); + } + + inline bool + operator!= (StringLiteral const& a, StringLiteral const& b) + { + return a.literal () != b.literal (); + } + } + } +} + +std::ostream& +operator<< (std::ostream&, CCF::IDL2::SemanticGraph::StringLiteral const&); + +#endif // CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.cpp new file mode 100644 index 00000000000..597be660772 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.cpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/SemanticGraph/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + member_init_ () + { + TypeInfo ti (typeid (Member)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo member_ (member_init_ ()); + } + + TypeInfo const& Member:: + static_type_info () { return member_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp new file mode 100644 index 00000000000..d37f5a5dd74 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticGraph/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Member : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Member (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp new file mode 100644 index 00000000000..9e7aeb542e4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp @@ -0,0 +1,33 @@ +// file : CCF/IDL2/SemanticGraph/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + module_init_ () + { + TypeInfo ti (typeid (Module)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo module_ (module_init_ ()); + } + + TypeInfo const& Module:: + static_type_info () { return module_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.hpp new file mode 100644 index 00000000000..8807f2b55bc --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticGraph/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Module : public virtual Scope + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Module (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp new file mode 100644 index 00000000000..374446661df --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp @@ -0,0 +1,253 @@ +// file : CCF/IDL2/SemanticGraph/Name.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Name.hpp" + +#include <ostream> + +/* +#include <iostream> + +using std::cerr; +using std::endl; +*/ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + + // SimpleName + // + // + + SimpleName:: + SimpleName (char const* name) throw (InvalidName) + : escaped_ (name[0] == '_'), + name_ (escaped_ ? name + 1 : name) + { + if (name_.find (':') != std::string::npos) + throw InvalidName (); + } + + SimpleName:: + SimpleName (std::string const& name) throw (InvalidName) + : escaped_ (name[0] == '_'), + name_ (name, escaped_ ? 1 : 0) + { + if (name_.find (':') != std::string::npos) + throw InvalidName (); + } + + SimpleName + operator+ (SimpleName const& name, std::string const& str) + { + return SimpleName (name.str () + str); + } + + SimpleName + operator+ (std::string const& str, SimpleName const& name) + { + return SimpleName (str + name.str ()); + } + + // Name + // + // + Name:: + Name (SimpleName const& name) + : name_cache_ (name.unescaped_str ()) + { + name_.push_back (name); + } + + Name:: + Name (char const* name) throw (InvalidName) + { + init (name); + } + + Name:: + Name (std::string const& name) throw (InvalidName) + { + init (name); + } + + void Name:: + init (std::string const& name) throw (InvalidName) + { + // cerr << "parsing name \'" << name_cache_ << "\' {"<< endl; + + for (std::string::size_type pos (0), next (name.find ("::", pos));; + next = name.find ("::", pos)) + { + std::string simple_name ( + name, + pos, + next == std::string::npos ? next : next - pos); + + // cerr << "\t\'" << simple_name << '\'' << endl; + + if (simple_name.empty () && !name_.empty ()) + { + // Empty name (file-scope) is only valid when + // it is first. + // + throw InvalidName (); + } + + name_.push_back (SimpleName (simple_name)); + name_cache_ += (pos != 0 ? "::" : "") + + name_.back ().unescaped_str (); + + if (next == std::string::npos) + break; + + pos = next + 2; + } + + // cerr << "parsing name }" << name_cache_ << endl; + + if (name_.empty ()) + throw InvalidName (); + } + + + Name:: + Name (Iterator begin, Iterator end) throw (InvalidName) + { + for (Iterator i (begin); i != end; ++i) + { + name_cache_ += (i != begin ? "::" : "") + i->unescaped_str (); + name_.push_back (*i); + } + + if (name_.empty ()) + throw InvalidName (); + } + + bool Name:: + scoped () const + { + return name_[0] == SimpleName (""); + } + + bool Name:: + simple () const + { + return name_.size () == 1; + } + + // ScopedName + // + // + + ScopedName:: + ScopedName (char const* name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (std::string const& name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (Iterator begin, Iterator end) throw (InvalidName) + : Name (begin, end) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (Name const& name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (ScopedName const& scope, Name const& name) + throw (InvalidName) + : Name (scope.str () + "::" + name.str ()) + { + if (!scoped ()) throw InvalidName (); + } + + SimpleName ScopedName:: + simple_name () const + { + return *(end () - 1); + } + + ScopedName ScopedName:: + scope_name () const throw (FileScope) + { + Iterator end (this->end () - 1); + + if (begin () == end) throw FileScope (); + + return ScopedName (begin (), end); + } + + + // NamePrinter + // + int const name_printer_index = std::ios_base::xalloc (); + + NamePrinter::~NamePrinter () + { + } + + void NamePrinter:: + print (std::ostream& os, Name const& n) + { + for (Name::Iterator b (n.begin ()), i (b); i != n.end (); ++i) + { + if (i != b) + os << "::"; + + print (os, *i); + } + } + } + } +} + +std::ostream& +operator << (std::ostream& o, + CCF::IDL2::SemanticGraph::SimpleName const& name) +{ + using namespace CCF::IDL2::SemanticGraph; + + if (void* tmp = o.pword (name_printer_index)) + { + NamePrinter* p (reinterpret_cast<NamePrinter*> (tmp)); + p->print (o, name); + return o; + } + else + return o << name.str (); +} + +std::ostream& +operator << (std::ostream& o, CCF::IDL2::SemanticGraph::Name const& name) +{ + using namespace CCF::IDL2::SemanticGraph; + + if (void* tmp = o.pword (name_printer_index)) + { + NamePrinter* p (reinterpret_cast<NamePrinter*> (tmp)); + p->print (o, name); + return o; + } + else + return o << name.str (); +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp new file mode 100644 index 00000000000..50dd752aa6a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp @@ -0,0 +1,239 @@ +// file : CCF/IDL2/SemanticGraph/Name.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP + +#include <vector> +#include <string> +#include <iosfwd> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + //@@ better names for names: maybe SimpleName, ScopedName, FullName? + // + // + + class InvalidName {}; + + class SimpleName + { + public: + SimpleName (char const* name) throw (InvalidName); + SimpleName (std::string const& name) throw (InvalidName); + + public: + // Comparisons are escape-insensitive. + // + bool + operator< (SimpleName const& other) const + { + return name_ < other.name_; + } + + bool + operator== (SimpleName const& other) const + { + return name_ == other.name_; + } + + bool + operator!= (SimpleName const& other) const + { + return name_ != other.name_; + } + + public: + bool + escaped () const + { + return escaped_; + } + + std::string + str () const + { + return (escaped_ ? "_" : "") + name_; + } + + std::string + unescaped_str () const + { + return name_; + } + + private: + bool escaped_; + std::string name_; + }; + + // The following operators preserve escaping. + // + SimpleName + operator+ (SimpleName const& name, std::string const& str); + + SimpleName + operator+ (std::string const& str, SimpleName const& name); + + + // + // + // + class Name + { + typedef + std::vector<SimpleName> + Name_; + + public: + Name (SimpleName const& name); + + Name (char const* name) throw (InvalidName); + Name (std::string const& name) throw (InvalidName); + + typedef + Name_::const_iterator + Iterator; + + Name (Iterator begin, Iterator end) throw (InvalidName); + + public: + // Comparisons are escape-insensitive. + // + bool + operator< (Name const& other) const + { + return name_cache_ < other.name_cache_; + } + + bool + operator== (Name const& other) const + { + return name_cache_ == other.name_cache_; + } + + bool + operator!= (Name const& other) const + { + return name_cache_ != other.name_cache_; + } + + public: + Iterator + begin () const + { + return name_.begin (); + } + + Iterator + end () const + { + return name_.end (); + } + + public: + bool + scoped () const; + + bool + simple () const; + + public: + std::string + str () const + { + std::string r; + + for (Iterator b (begin ()), i (b), e (end ()); i != e; ++i) + r += (i != b ? "::" : "") + i->str (); + + return r; + } + + std::string + unescaped_str () const + { + return name_cache_; + } + + private: + void + init (std::string const& name) throw (InvalidName); + + private: + Name_ name_; + std::string name_cache_; // Unescaped name cache. + }; + + // Should always start with "::". Can be just "::" which + // means it's a file-scope. + // + // + class ScopedName : public Name + { + public: + ScopedName (char const* name) throw (InvalidName); + + ScopedName (std::string const& name) throw (InvalidName); + + ScopedName (Iterator begin, Iterator end) throw (InvalidName); + + explicit + ScopedName (Name const& name) throw (InvalidName); + + ScopedName (ScopedName const& scope, Name const& name) + throw (InvalidName); + + public: + SimpleName + simple_name () const; + + class FileScope {}; + + ScopedName + scope_name () const throw (FileScope); + }; + + + // Name printer index for the stream's pword. + // + extern int const name_printer_index; + + // + // + struct NamePrinter + { + virtual ~NamePrinter (); + + virtual void + print (std::ostream&, SimpleName const&) = 0; + + // The default implementation prints individul simple names + // using the print function above seperated by '::'. + // + virtual void + print (std::ostream&, Name const&); + + }; + } + } +} + +// Uses the name printer (see above) If it is installed, otherwise +// prints in the escaped form. +// +std::ostream& +operator << (std::ostream&, CCF::IDL2::SemanticGraph::SimpleName const&); + +// Uses the name printer (see above) If it is installed, otherwise +// prints in the escaped form. +// +std::ostream& +operator << (std::ostream& o, CCF::IDL2::SemanticGraph::Name const& name); + +#endif // CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.cpp new file mode 100644 index 00000000000..b2c29fe2881 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.cpp @@ -0,0 +1,33 @@ +// file : CCF/IDL2/SemanticGraph/Native.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Native.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + native_init_ () + { + TypeInfo ti (typeid (Native)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo native_ (native_init_ ()); + } + + TypeInfo const& Native:: + static_type_info () { return native_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.hpp new file mode 100644 index 00000000000..89c7b3f6a0e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Native.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticGraph/Native.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_NATIVE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_NATIVE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Native : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Native (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_NATIVE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp new file mode 100644 index 00000000000..690f6d8173d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp @@ -0,0 +1,228 @@ +// file : CCF/IDL2/SemanticGraph/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Receives + // + // + namespace + { + TypeInfo + receives_init_ () + { + TypeInfo ti (typeid (Receives)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo receives_ (receives_init_ ()); + } + + TypeInfo const& Receives:: + static_type_info () { return receives_; } + + + // Returns + // + // + namespace + { + TypeInfo + returns_init_ () + { + TypeInfo ti (typeid (Returns)); + ti.add_base (Access::PUBLIC, true, Belongs::static_type_info ()); + return ti; + } + + TypeInfo returns_ (returns_init_ ()); + } + + TypeInfo const& Returns:: + static_type_info () { return returns_; } + + + // Raises + // + // + namespace + { + TypeInfo + raises_init_ () + { + TypeInfo ti (typeid (Raises)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo raises_ (raises_init_ ()); + } + + TypeInfo const& Raises:: + static_type_info () { return raises_; } + + + + // Parameter + // + // + namespace + { + TypeInfo + parameter_init_ () + { + TypeInfo ti (typeid (Parameter)); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo parameter_ (parameter_init_ ()); + } + + TypeInfo const& Parameter:: + static_type_info () { return parameter_; } + + Parameter:: + ~Parameter () + { + } + + + // InParameter + // + // + namespace + { + TypeInfo + in_parameter_init_ () + { + TypeInfo ti (typeid (InParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo in_parameter_ (in_parameter_init_ ()); + } + + TypeInfo const& InParameter:: + static_type_info () { return in_parameter_; } + + + // OutParameter + // + // + namespace + { + TypeInfo + out_parameter_init_ () + { + TypeInfo ti (typeid (OutParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo out_parameter_ (out_parameter_init_ ()); + } + + TypeInfo const& OutParameter:: + static_type_info () { return out_parameter_; } + + + // InOutParameter + // + // + namespace + { + TypeInfo + in_out_parameter_init_ () + { + TypeInfo ti (typeid (InOutParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo in_out_parameter_ (in_out_parameter_init_ ()); + } + + TypeInfo const& InOutParameter:: + static_type_info () { return in_out_parameter_; } + + + // Operation + // + // + namespace + { + TypeInfo + operation_init_ () + { + TypeInfo ti (typeid (Operation)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo operation_ (operation_init_ ()); + } + + TypeInfo const& Operation:: + static_type_info () { return operation_; } + + Operation:: + ~Operation () + { + } + + + // OneWayOperation + // + // + namespace + { + TypeInfo + one_way_operation_init_ () + { + TypeInfo ti (typeid (OneWayOperation)); + ti.add_base (Access::PUBLIC, true, Operation::static_type_info ()); + return ti; + } + + TypeInfo one_way_operation_ (one_way_operation_init_ ()); + } + + TypeInfo const& OneWayOperation:: + static_type_info () { return one_way_operation_; } + + + // TwoWayOperation + // + // + namespace + { + TypeInfo + two_way_operation_init_ () + { + TypeInfo ti (typeid (TwoWayOperation)); + ti.add_base (Access::PUBLIC, true, Operation::static_type_info ()); + return ti; + } + + TypeInfo two_way_operation_ (two_way_operation_init_ ()); + } + + TypeInfo const& TwoWayOperation:: + static_type_info () { return two_way_operation_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp new file mode 100644 index 00000000000..2f0a5d1686a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp @@ -0,0 +1,359 @@ +// file : CCF/IDL2/SemanticGraph/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP + +#include <string> + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Operation; + class Parameter; + + // Operation receives parameter + // + // + class Receives : public virtual Edge + { + public: + Operation& + operation () const + { + return *operation_; + } + + Parameter& + parameter () const + { + return *parameter_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Receives () + { + type_info (static_type_info ()); + } + + void + set_left_node (Operation& n) + { + operation_ = &n; + } + + void + set_right_node (Parameter& n) + { + parameter_ = &n; + } + + private: + Operation* operation_; + Parameter* parameter_; + }; + + + // Operation returns + // + // + class Returns : public virtual Belongs + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Returns () + { + type_info (static_type_info ()); + } + }; + + + // Raises + // + // + class Raises : public virtual Edge + { + public: + Operation& + operation () const + { + return *operation_; + } + + Exception& + exception () const + { + return *exception_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Raises () + { + type_info (static_type_info ()); + } + + void + set_left_node (Operation& n) + { + operation_ = &n; + } + + void + set_right_node (Exception& n) + { + exception_ = &n; + } + + private: + Operation* operation_; + Exception* exception_; + }; + + + // + // + // + class Parameter : public virtual Instance + { + public: + std::string + name () const + { + return name_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Parameter (std::string const& name) // For virtual inheritance only. + : name_ (name) + { + type_info (static_type_info ()); + } + + virtual + ~Parameter () = 0; + + void + add_edge_right (Receives&) + { + } + + private: + std::string name_; + }; + + + class InParameter : public virtual Parameter + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + InParameter (Path const& path, + unsigned long line, + std::string const& name) + : Node (path, line), Parameter (name) + { + type_info (static_type_info ()); + } + }; + + class OutParameter : public virtual Parameter + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + OutParameter (Path const& path, + unsigned long line, + std::string const& name) + : Node (path, line), Parameter (name) + { + type_info (static_type_info ()); + } + }; + + class InOutParameter : public virtual Parameter + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + InOutParameter (Path const& path, + unsigned long line, + std::string const& name) + : Node (path, line), Parameter (name) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Operation : public virtual Nameable, public virtual Instance + { + typedef + std::vector<Receives*> + Receives_; + + typedef + std::vector<Raises*> + Raises_; + + public: + typedef + Receives_::const_iterator + ReceivesIterator; + + ReceivesIterator + receives_begin () const + { + return receives_.begin (); + } + + ReceivesIterator + receives_end () const + { + return receives_.end (); + } + + typedef + Raises_::const_iterator + RaisesIterator; + + RaisesIterator + raises_begin () const + { + return raises_.begin (); + } + + RaisesIterator + raises_end () const + { + return raises_.end (); + } + + Returns& + returns () const + { + return dynamic_cast<Returns&> (belongs ()); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Operation () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Operation () = 0; + + + void + add_edge_left (Receives& e) + { + receives_.push_back (&e); + } + + void + add_edge_left (Raises& e) + { + raises_.push_back (&e); + } + + void + add_edge_left (Returns& e) + { + Instance::add_edge_left (e); + } + + private: + Receives_ receives_; + Raises_ raises_; + }; + + + // + // + // + class OneWayOperation : public virtual Operation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + OneWayOperation (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class TwoWayOperation : public virtual Operation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TwoWayOperation (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp new file mode 100644 index 00000000000..5c95be2c67c --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp @@ -0,0 +1,82 @@ +// file : CCF/IDL2/SemanticGraph/Sequence.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Sequence + // + // + namespace + { + TypeInfo + sequence_init_ () + { + TypeInfo ti (typeid (Sequence)); + ti.add_base ( + Access::PUBLIC, true, Specialization::static_type_info ()); + return ti; + } + + TypeInfo sequence_ (sequence_init_ ()); + } + + TypeInfo const& Sequence:: + static_type_info () { return sequence_; } + + Sequence:: + ~Sequence () + { + } + + + // UnboundedSequence + // + // + namespace + { + TypeInfo + unbounded_sequence_init_ () + { + TypeInfo ti (typeid (UnboundedSequence)); + ti.add_base (Access::PUBLIC, true, Sequence::static_type_info ()); + return ti; + } + + TypeInfo unbounded_sequence_ (unbounded_sequence_init_ ()); + } + + TypeInfo const& UnboundedSequence:: + static_type_info () { return unbounded_sequence_; } + + + // BoundedSequence + // + // + namespace + { + TypeInfo + bounded_sequence_init_ () + { + TypeInfo ti (typeid (BoundedSequence)); + ti.add_base (Access::PUBLIC, true, Sequence::static_type_info ()); + return ti; + } + + TypeInfo bounded_sequence_ (bounded_sequence_init_ ()); + } + + TypeInfo const& BoundedSequence:: + static_type_info () { return bounded_sequence_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp new file mode 100644 index 00000000000..333b55fed2a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp @@ -0,0 +1,106 @@ +// file : CCF/IDL2/SemanticGraph/Sequence.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Sequence : public virtual Specialization + { + public: + Type& + type () const + { + return + dynamic_cast<ArgumentsWithType&> (**arguments_begin ()).type (); + } + + virtual bool + complete () const + { + return type ().complete (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Sequence () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Sequence () = 0; + }; + + + // + // + // + class UnboundedSequence : public virtual Sequence + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnboundedSequence (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class BoundedSequence : public virtual Sequence + { + public: + IntExpression& + bound () const + { + ArgumentsIterator i (arguments_begin ()); + + ++i; // Bound is always second to the type. + + return + dynamic_cast<IntExpression&> ( + dynamic_cast<ArgumentsWithValue&> (**i).value ()); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + BoundedSequence (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/String.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/String.cpp new file mode 100644 index 00000000000..578c87361d4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/String.cpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticGraph/String.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/String.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // BoundedString + // + // + namespace + { + TypeInfo + bounded_string_init_ () + { + TypeInfo ti (typeid (BoundedString)); + ti.add_base ( + Access::PUBLIC, true, Specialization::static_type_info ()); + return ti; + } + + TypeInfo bounded_string_ (bounded_string_init_ ()); + } + + TypeInfo const& BoundedString:: + static_type_info () { return bounded_string_; } + + + // BoundedWideString + // + // + namespace + { + TypeInfo + bounded_wide_string_init_ () + { + TypeInfo ti (typeid (BoundedWideString)); + ti.add_base ( + Access::PUBLIC, true, Specialization::static_type_info ()); + return ti; + } + + TypeInfo bounded_wide_string_ (bounded_wide_string_init_ ()); + } + + TypeInfo const& BoundedWideString:: + static_type_info () { return bounded_wide_string_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/String.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/String.hpp new file mode 100644 index 00000000000..484a8a778ec --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/String.hpp @@ -0,0 +1,87 @@ +// file : CCF/IDL2/SemanticGraph/String.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_STRING_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_STRING_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + class BoundedString : public virtual Specialization + { + public: + IntExpression& + bound () const + { + return + dynamic_cast<IntExpression&> ( + dynamic_cast<ArgumentsWithValue&> ( + **arguments_begin ()).value ()); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + BoundedString (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + class BoundedWideString : public virtual Specialization + { + public: + IntExpression& + bound () const + { + return + dynamic_cast<IntExpression&> ( + dynamic_cast<ArgumentsWithValue&> ( + **arguments_begin ()).value ()); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + BoundedWideString (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_STRING_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp new file mode 100644 index 00000000000..46fd9b9ef3a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp @@ -0,0 +1,67 @@ +// file : CCF/IDL2/SemanticGraph/Struct.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Struct.hpp" +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + struct_init_ () + { + TypeInfo ti (typeid (Struct)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo struct_ (struct_init_ ()); + } + + TypeInfo const& Struct:: + static_type_info () { return struct_; } + + bool Struct:: + complete () const + { + if (defined ()) + { + CompilerElements::Context& ctx ( + const_cast<CompilerElements::Context&> (context ())); + + if (ctx.count ("struct-complete-test")) + return true; + + ctx.set ("struct-complete-test", true); + bool c (true); + + for (Scope::NamesIterator i (names_begin ()); + c && i != names_end (); + ++i) + { + Member const& m (dynamic_cast<Member&> ((*i)->named ())); + Type const& t (m.belongs ().type ()); + + if (!t.complete ()) + c = false; + } + + ctx.remove ("struct-complete-test"); + return c; + } + + return false; + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp new file mode 100644 index 00000000000..5e186bfd0ff --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticGraph/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Struct : public virtual Type, public virtual Scope + { + public: + virtual bool + complete () const; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Struct (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp new file mode 100644 index 00000000000..b925da62259 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp @@ -0,0 +1,255 @@ +// file : CCF/IDL2/SemanticGraph/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // ContainsPrincipal + // + // + namespace + { + TypeInfo + contains_principal_init_ () + { + TypeInfo ti (typeid (ContainsPrincipal)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_principal_ (contains_principal_init_ ()); + } + + TypeInfo const& ContainsPrincipal:: + static_type_info () { return contains_principal_; } + + + // ContainsImplied + // + // + namespace + { + TypeInfo + contains_implied_init_ () + { + TypeInfo ti (typeid (ContainsImplied)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_implied_ (contains_implied_init_ ()); + } + + TypeInfo const& ContainsImplied:: + static_type_info () { return contains_implied_; } + + + // ContainsRoot + // + // + namespace + { + TypeInfo + contains_root_init_ () + { + TypeInfo ti (typeid (ContainsRoot)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_root_ (contains_root_init_ ()); + } + + TypeInfo const& ContainsRoot:: + static_type_info () { return contains_root_; } + + + // Includes + // + // + namespace + { + TypeInfo + includes_init_ () + { + TypeInfo ti (typeid (Includes)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo includes_ (includes_init_ ()); + } + + TypeInfo const& Includes:: + static_type_info () { return includes_; } + + + // QuoteIncludes + // + // + namespace + { + TypeInfo + quote_includes_init_ () + { + TypeInfo ti (typeid (QuoteIncludes)); + ti.add_base (Access::PUBLIC, true, Includes::static_type_info ()); + return ti; + } + + TypeInfo quote_includes_ (quote_includes_init_ ()); + } + + TypeInfo const& QuoteIncludes:: + static_type_info () { return quote_includes_; } + + + + // BracketIncludes + // + // + namespace + { + TypeInfo + bracket_includes_init_ () + { + TypeInfo ti (typeid (BracketIncludes)); + ti.add_base (Access::PUBLIC, true, Includes::static_type_info ()); + return ti; + } + + TypeInfo bracket_includes_ (bracket_includes_init_ ()); + } + + TypeInfo const& BracketIncludes:: + static_type_info () { return bracket_includes_; } + + + // Root + // + // + namespace + { + TypeInfo + root_init_ () + { + TypeInfo ti (typeid (Root)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo root_ (root_init_ ()); + } + + TypeInfo const& Root:: + static_type_info () { return root_; } + + + // TranslationRegion + // + // + + Nameables TranslationRegion:: + lookup (ScopedName const& name) const + { + Nameables r; + lookup (name, r); + return r; + } + + void TranslationRegion:: + lookup (ScopedName const& name, Nameables& result) const + { + bool root (name.simple ()); + + Name rest (name.begin () + (root ? 0 : 1), name.end ()); + + for (ContainsIterator i (contains_begin ()), end (contains_end ()); + i != end; ++i) + { + Node& node ((**i).element ()); + + if (Root* r = dynamic_cast<Root*> (&node)) + { + if (root) + { + result.insert (r); + } + else + { + r->lookup (rest, result); + } + } + else + { + dynamic_cast<TranslationRegion&> (node).lookup (name, result); + } + } + } + + + namespace + { + TypeInfo + translation_region_init_ () + { + TypeInfo ti (typeid (TranslationRegion)); + ti.add_base (Access::PUBLIC, true, Container::static_type_info ()); + return ti; + } + + TypeInfo translation_region_ (translation_region_init_ ()); + } + + TypeInfo const& TranslationRegion:: + static_type_info () { return translation_region_; } + + + // TranslationUnit + // + // + + Nameables TranslationUnit:: + lookup (ScopedName const& name) const + { + Nameables r; + + for (ContainsIterator i (contains_begin ()), end (contains_end ()); + i != end; ++i) + { + TranslationRegion& tr ( + dynamic_cast<TranslationRegion&>((**i).element ())); + + tr.lookup (name, r); + } + + return r; + } + + namespace + { + TypeInfo + translation_unit_init_ () + { + TypeInfo ti (typeid (TranslationUnit)); + ti.add_base (Access::PUBLIC, true, Container::static_type_info ()); + return ti; + } + + TypeInfo translation_unit_ (translation_unit_init_ ()); + } + + TypeInfo const& TranslationUnit:: + static_type_info () { return translation_unit_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp new file mode 100644 index 00000000000..42df2ed2c13 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp @@ -0,0 +1,287 @@ +// file : CCF/IDL2/SemanticGraph/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP + +#include <vector> +#include <string> + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Root; + class TranslationRegion; + class TranslationUnit; + + + // + // + // + class ContainsPrincipal : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsPrincipal () + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationUnit& n); + + void + set_right_node (TranslationRegion& n); + }; + + + // + // + // + class ContainsImplied : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsImplied (std::string const& name = "") + : name_ (name) + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationUnit& n); + + void + set_right_node (TranslationRegion& n); + + private: + std::string name_; + }; + + + // + // + // + class ContainsRoot : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsRoot () + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationRegion& n); + + void + set_right_node (Root& n); + }; + + // + // + // + class Includes : public virtual Contains + { + public: + Path + file () const + { + return file_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Includes (Path const& file) + : file_ (file) + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationRegion& n); + + void + set_right_node (TranslationRegion& n); + + private: + Path file_; + }; + + + // + // + // + class QuoteIncludes : public virtual Includes + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + QuoteIncludes (Path const& file) + : Includes (file) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class BracketIncludes : public virtual Includes + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + BracketIncludes (Path const& file) + : Includes (file) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Root : public virtual Scope + { + public: + virtual SimpleName + name () const + { + return SimpleName (""); + } + + virtual ScopedName + scoped_name () const + { + return ScopedName (""); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Root (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + void + add_edge_right (Contains&) + { + // TranslationRegion contains Root + } + }; + + + // + // + // + class TranslationRegion : public virtual Container + { + public: + Nameables + lookup (ScopedName const& name) const; + + void + lookup (ScopedName const& name, Nameables& result) const; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TranslationRegion (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + void + add_edge_right (Contains&) + { + } + }; + + + class TranslationUnit : public virtual Container, + public Graph<Node, Edge> + { + public: + TranslationUnit (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + Nameables + lookup (ScopedName const& name) const; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + void + add_edge_left (ContainsPrincipal& e) + { + Container::add_edge_left (e); + } + + void + add_edge_left (ContainsImplied& e) + { + Container::add_edge_left (e); + } + + private: + TranslationUnit (TranslationUnit const&); + void operator= (TranslationUnit const&); + }; + } + } +} + +#include "CCF/IDL2/SemanticGraph/Translation.ipp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp new file mode 100644 index 00000000000..8168cd87762 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp @@ -0,0 +1,73 @@ +// file : CCF/IDL2/SemanticGraph/Translation.ipp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // ContainsPrincipal + // + // + inline void ContainsPrincipal:: + set_left_node (TranslationUnit& n) + { + Contains::set_left_node (n); + } + + inline void ContainsPrincipal:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + + // ContainsImplied + // + // + inline void ContainsImplied:: + set_left_node (TranslationUnit& n) + { + Contains::set_left_node (n); + } + + inline void ContainsImplied:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + + // ContainsRoot + // + // + inline void ContainsRoot:: + set_left_node (TranslationRegion& n) + { + Contains::set_left_node (n); + } + + inline void ContainsRoot:: + set_right_node (Root& n) + { + Contains::set_right_node (n); + } + + + // Includes + // + // + inline void Includes:: + set_left_node (TranslationRegion& n) + { + Contains::set_left_node (n); + } + + inline void Includes:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp new file mode 100644 index 00000000000..7f7a1f69479 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticGraph/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // TypeId + // + // + namespace + { + TypeInfo + type_id_init_ () + { + TypeInfo ti (typeid (TypeId)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_id_ (type_id_init_ ()); + } + + TypeInfo const& TypeId:: + static_type_info () { return type_id_; } + + + // TypePrefix + // + // + namespace + { + TypeInfo + type_prefix_init_ () + { + TypeInfo ti (typeid (TypePrefix)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_prefix_ (type_prefix_init_ ()); + } + + TypeInfo const& TypePrefix:: + static_type_info () { return type_prefix_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp new file mode 100644 index 00000000000..accb6f83226 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp @@ -0,0 +1,104 @@ +// file : CCF/IDL2/SemanticGraph/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Literals.hpp" + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class TypeId : public virtual Nameable + { + public: + //@@ declaration is a bad name. + // + ScopedName + declaration () const + { + return name_; + } + + StringLiteral + id () const + { + return id_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TypeId (Path const& path, + unsigned long line, + ScopedName const& name, + StringLiteral const& id) + : Node (path, line), + name_ (name), + id_ (id) + { + type_info (static_type_info ()); + } + + private: + ScopedName name_; + StringLiteral id_; + }; + + + // + // + // + class TypePrefix : public virtual Nameable + { + public: + ScopedName + declaration () const + { + return name_; + } + + StringLiteral + prefix () const + { + return prefix_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TypePrefix (Path const& path, + unsigned long line, + ScopedName const& name, + StringLiteral const& prefix) + : Node (path, line), + name_ (name), + prefix_ (prefix) + { + type_info (static_type_info ()); + } + + private: + ScopedName name_; + StringLiteral prefix_; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.cpp new file mode 100644 index 00000000000..4fccb9a0ebc --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.cpp @@ -0,0 +1,177 @@ +// file : CCF/IDL2/SemanticGraph/Union.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Union.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // Selects + // + // + namespace + { + TypeInfo + selects_init_ () + { + TypeInfo ti (typeid (Selects)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo selects_ (selects_init_ ()); + } + + TypeInfo const& Selects:: + static_type_info () { return selects_; } + + + // UnionMember + // + // + namespace + { + TypeInfo + union_member_init_ () + { + TypeInfo ti (typeid (UnionMember)); + ti.add_base (Access::PUBLIC, true, Member::static_type_info ()); + return ti; + } + + TypeInfo union_member_ (union_member_init_ ()); + } + + TypeInfo const& UnionMember:: + static_type_info () { return union_member_; } + + + // Selector + // + // + namespace + { + TypeInfo + selector_init_ () + { + TypeInfo ti (typeid (Selector)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo selector_ (selector_init_ ()); + } + + TypeInfo const& Selector:: + static_type_info () { return selector_; } + + Selector:: + ~Selector () + { + } + + // DefaultSelector + // + // + namespace + { + TypeInfo + default_selector_init_ () + { + TypeInfo ti (typeid (DefaultSelector)); + ti.add_base (Access::PUBLIC, true, Selector::static_type_info ()); + return ti; + } + + TypeInfo default_selector_ (default_selector_init_ ()); + } + + TypeInfo const& DefaultSelector:: + static_type_info () { return default_selector_; } + + + // ValueSelector + // + // + namespace + { + TypeInfo + value_selector_init_ () + { + TypeInfo ti (typeid (ValueSelector)); + ti.add_base (Access::PUBLIC, true, Selector::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo value_selector_ (value_selector_init_ ()); + } + + TypeInfo const& ValueSelector:: + static_type_info () { return value_selector_; } + + // Union + // + // + namespace + { + TypeInfo + union_init_ () + { + TypeInfo ti (typeid (Union)); + + ti.add_base ( + Access::PUBLIC, true, Specialization::static_type_info ()); + + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo union_ (union_init_ ()); + } + + TypeInfo const& Union:: + static_type_info () { return union_; } + + bool Union:: + complete () const + { + if (defined ()) + { + CompilerElements::Context& ctx ( + const_cast<CompilerElements::Context&> (context ())); + + if (ctx.count ("union-complete-test")) + return true; + + ctx.set ("union-complete-test", true); + bool c (true); + + for (Scope::NamesIterator i (names_begin ()); + c && i != names_end (); + ++i) + { + Member const& m (dynamic_cast<Member&> ((*i)->named ())); + Type const& t (m.belongs ().type ()); + + if (!t.complete ()) + c = false; + } + + ctx.remove ("union-complete-test"); + return c; + } + + return false; + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.hpp new file mode 100644 index 00000000000..2512358db03 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/Union.hpp @@ -0,0 +1,158 @@ +// file : CCF/IDL2/SemanticGraph/Union.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_UNION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_UNION_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Selector; + class UnionMember; + + class Selects : public virtual Edge + { + public: + Selector& + selector () const + { + return *selector_; + } + + UnionMember& + member () const + { + return *member_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Selects () + { + type_info (static_type_info ()); + } + + void + set_left_node (Selector& n) + { + selector_ = &n; + } + + void + set_right_node (UnionMember& n) + { + member_ = &n; + } + + private: + Selector* selector_; + UnionMember* member_; + }; + + class UnionMember : public virtual Member + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnionMember (Path const& path, unsigned long line) + : Node (path, line), Member (path, line) + { + type_info (static_type_info ()); + } + }; + + class Selector : public virtual Node + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Selector () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~Selector () = 0; + }; + + class DefaultSelector : public virtual Selector + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + DefaultSelector (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + class ValueSelector : public virtual Selector, + public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueSelector (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + class Union : public virtual Specialization, + public virtual Scope + { + public: + virtual bool + complete () const; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Union (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + + using Specialization::add_edge_left; + using Specialization::add_edge_right; + using Scope::add_edge_left; + using Scope::add_edge_right; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_UNION_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp new file mode 100644 index 00000000000..1d151613dcc --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp @@ -0,0 +1,102 @@ +// file : CCF/IDL2/SemanticGraph/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // ValueType + // + // + namespace + { + TypeInfo + value_type_init_ () + { + TypeInfo ti (typeid (ValueType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo value_type_ (value_type_init_ ()); + } + + TypeInfo const& ValueType:: + static_type_info () { return value_type_; } + + ValueType:: + ~ValueType () + { + } + + // AbstractValueType + // + // + namespace + { + TypeInfo + abstract_value_type_init_ () + { + TypeInfo ti (typeid (AbstractValueType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo abstract_value_type_ (abstract_value_type_init_ ()); + } + + TypeInfo const& AbstractValueType:: + static_type_info () { return abstract_value_type_; } + + + // ConcreteValueType + // + // + namespace + { + TypeInfo + concrete_value_type_init_ () + { + TypeInfo ti (typeid (ConcreteValueType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo concrete_value_type_ (concrete_value_type_init_ ()); + } + + TypeInfo const& ConcreteValueType:: + static_type_info () { return concrete_value_type_; } + + + // ValueTypeFactory + // + // + namespace + { + TypeInfo + value_type_factory_init_ () + { + TypeInfo ti (typeid (ValueTypeFactory)); + ti.add_base ( + Access::PUBLIC, true, TwoWayOperation::static_type_info ()); + return ti; + } + + TypeInfo value_type_factory_ (value_type_factory_init_ ()); + } + + TypeInfo const& ValueTypeFactory:: + static_type_info () { return value_type_factory_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp new file mode 100644 index 00000000000..f918ee17dc6 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp @@ -0,0 +1,174 @@ +// file : CCF/IDL2/SemanticGraph/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" // Supports + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class ValueType : public virtual Type, + public virtual Scope + { + typedef + std::vector <Inherits*> + Inherits_; + + typedef + std::vector <Supports*> + Supports_; + + public: + typedef + Inherits_::const_iterator + InheritsIterator; + + InheritsIterator + inherits_begin () const + { + return inherits_.begin (); + } + + InheritsIterator + inherits_end () const + { + return inherits_.end (); + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueType () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~ValueType () = 0; + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_.push_back (&e); + } + + void + add_edge_right (Inherits&) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + private: + Inherits_ inherits_; + Supports_ supports_; + }; + + + // + // + // + class AbstractValueType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractValueType (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ConcreteValueType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ConcreteValueType (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ValueTypeFactory : public virtual TwoWayOperation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueTypeFactory (Path const& path, unsigned long line) + : Node (path, line), TwoWayOperation (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.cpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.cpp new file mode 100644 index 00000000000..0afeabd5fd0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.cpp @@ -0,0 +1,90 @@ +// file : CCF/IDL2/SemanticGraph/ValueTypeMember.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // ValueTypeMember + // + // + namespace + { + TypeInfo + value_type_member_init_ () + { + TypeInfo ti (typeid (ValueTypeMember)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo + value_type_member_ (value_type_member_init_ ()); + } + + TypeInfo const& ValueTypeMember:: + static_type_info () { return value_type_member_; } + + ValueTypeMember:: + ~ValueTypeMember () + { + } + + + // ValueTypePrivateMember + // + // + namespace + { + TypeInfo + value_type_private_member_init_ () + { + TypeInfo ti (typeid (ValueTypePrivateMember)); + ti.add_base (Access::PUBLIC, + true, + ValueTypeMember::static_type_info ()); + return ti; + } + + TypeInfo + value_type_private_member_ (value_type_private_member_init_ ()); + } + + TypeInfo const& ValueTypePrivateMember:: + static_type_info () { return value_type_private_member_; } + + + // ValueTypePublicMember + // + // + namespace + { + TypeInfo + value_type_public_member_init_ () + { + TypeInfo ti (typeid (ValueTypePublicMember)); + ti.add_base (Access::PUBLIC, + true, + ValueTypeMember::static_type_info ()); + return ti; + } + + TypeInfo + value_type_public_member_ (value_type_public_member_init_ ()); + } + + TypeInfo const& ValueTypePublicMember:: + static_type_info () { return value_type_public_member_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.hpp b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.hpp new file mode 100644 index 00000000000..47649de0c6a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueTypeMember.hpp @@ -0,0 +1,107 @@ +// file : CCF/IDL2/SemanticGraph/ValueTypeMember.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + + // + // + // + class ValueTypeMember : public virtual Nameable, + public virtual Instance + { + public: + struct Access + { + enum Value + { + public_, + private_ + }; + }; + + virtual Access::Value + access () const = 0; + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + ValueTypeMember () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~ValueTypeMember () = 0; + }; + + + // + // + // + class ValueTypePrivateMember : public virtual ValueTypeMember + { + public: + virtual Access::Value + access () const + { + return Access::private_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueTypePrivateMember (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ValueTypePublicMember : public virtual ValueTypeMember + { + public: + virtual Access::Value + access () const + { + return Access::public_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueTypePublicMember (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/Token.cpp b/CIAO/CCF/CCF/IDL2/Token.cpp new file mode 100644 index 00000000000..a251329a2d8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Token.cpp @@ -0,0 +1,13 @@ +// file : CCF/IDL2/Token.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + } +} + diff --git a/CIAO/CCF/CCF/IDL2/Token.hpp b/CIAO/CCF/CCF/IDL2/Token.hpp new file mode 100644 index 00000000000..078a987e4e4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Token.hpp @@ -0,0 +1,348 @@ +// file : CCF/IDL2/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TOKEN_HPP +#define CCF_IDL2_TOKEN_HPP + +#include <vector> +#include <string> +#include <ostream> + +#include "CCF/CompilerElements/ReferenceCounting.hpp" + +namespace CCF +{ + namespace IDL2 + { + // + // + // + class Token : public ReferenceCounting::DefaultImpl <> + { + protected: + Token (std::string lexeme, unsigned long line) + : lexeme_ (lexeme), + line_ (line) + { + } + + public: + virtual + ~Token () throw () {} + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + + public: + std::string + lexeme () const + { + return lexeme_; + } + + unsigned long + line () const + { + return line_; + } + + private: + std::string lexeme_; + unsigned long line_; + }; + + typedef + ReferenceCounting::StrictPtr<Token> + TokenPtr; + + typedef + std::vector<TokenPtr> + TokenList; + + // + // + // + class EndOfStream : public Token + { + public: + EndOfStream (unsigned long line) + : Token ("<end-of-stream>", line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<EndOfStream> + EndOfStreamPtr; + + // + // + // + class Keyword : public Token + { + public: + Keyword (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Keyword> + KeywordPtr; + + // + // + // + class Punctuation : public Token + { + public: + Punctuation (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + + virtual + ~Punctuation () throw () {} + }; + + typedef + ReferenceCounting::StrictPtr<Punctuation> + PunctuationPtr; + + + // + // + // + class Operator : public Token + { + public: + Operator (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + + virtual + ~Operator () throw () {} + }; + + typedef + ReferenceCounting::StrictPtr<Operator> + OperatorPtr; + + + // + // + // + class Identifier : public Token + { + public: + Identifier (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Identifier> + IdentifierPtr; + + + // + // + // + class SimpleIdentifier : public Identifier + { + public: + SimpleIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<SimpleIdentifier> + SimpleIdentifierPtr; + + + // + // + // + class ScopedIdentifier : public Identifier + { + public: + ScopedIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<ScopedIdentifier> + ScopedIdentifierPtr; + + + // + // + // + class Literal : public Token + { + public: + Literal (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Literal> + LiteralPtr; + + + // + // + // + class BooleanLiteral : public Literal + { + public: + BooleanLiteral (std::string lexeme, unsigned long line) + : Literal (lexeme, line) + { + } + + bool + value () const + { + return lexeme () == "TRUE"; + } + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + }; + + typedef + ReferenceCounting::StrictPtr<BooleanLiteral> + BooleanLiteralPtr; + + + // + // + // + class CharacterLiteral : public Literal + { + public: + CharacterLiteral (char c, std::string lexeme, unsigned long line) + : Literal (lexeme, line), c_ (c) + { + } + + char + value () const + { + return c_; + } + + virtual void + print (std::ostream& o) + { + //@@ todo + o << lexeme (); + } + + private: + char c_; + }; + + typedef + ReferenceCounting::StrictPtr<CharacterLiteral> + CharacterLiteralPtr; + + + // + // + // + class IntegerLiteral : public Literal + { + public: + IntegerLiteral (unsigned long long value, + std::string lexeme, + unsigned long line) + : Literal (lexeme, line), value_ (value) + { + } + + unsigned long long + value () const + { + return value_; + } + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + + private: + unsigned long long value_; + }; + + typedef + ReferenceCounting::StrictPtr<IntegerLiteral> + IntegerLiteralPtr; + + + // + // + // + class StringLiteral : public Literal + { + public: + virtual + ~StringLiteral () throw () {} + + StringLiteral (std::string const& value, + std::string const& lexeme, + unsigned long line) + : Literal (lexeme, line), value_ (value) + { + } + + std::string + value () const + { + return value_; + } + + virtual void + print (std::ostream& o) + { + //@@ todo + o << lexeme (); + } + + private: + std::string value_; + }; + + typedef + ReferenceCounting::StrictPtr<StringLiteral> + StringLiteralPtr; + } +} + +inline std::ostream& +operator<< (std::ostream& o, CCF::IDL2::TokenPtr const& t) +{ + if (t != 0) t->print (o); + return o; +} + +#endif // CCF_IDL2_TOKEN_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal.hpp b/CIAO/CCF/CCF/IDL2/Traversal.hpp new file mode 100644 index 00000000000..2c56e2b3f2b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal.hpp @@ -0,0 +1,31 @@ +// file : CCF/IDL2/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_HPP +#define CCF_IDL2_TRAVERSAL_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/Traversal/Array.hpp" +#include "CCF/IDL2/Traversal/Attribute.hpp" +#include "CCF/IDL2/Traversal/Enum.hpp" +#include "CCF/IDL2/Traversal/Exception.hpp" +#include "CCF/IDL2/Traversal/Fundamental.hpp" +#include "CCF/IDL2/Traversal/IntExpression.hpp" +#include "CCF/IDL2/Traversal/Interface.hpp" +#include "CCF/IDL2/Traversal/Member.hpp" +#include "CCF/IDL2/Traversal/Module.hpp" +#include "CCF/IDL2/Traversal/Native.hpp" +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL2/Traversal/Struct.hpp" +#include "CCF/IDL2/Traversal/Sequence.hpp" +#include "CCF/IDL2/Traversal/String.hpp" +#include "CCF/IDL2/Traversal/Struct.hpp" +#include "CCF/IDL2/Traversal/Translation.hpp" +#include "CCF/IDL2/Traversal/TypeId.hpp" +#include "CCF/IDL2/Traversal/Union.hpp" +#include "CCF/IDL2/Traversal/ValueType.hpp" +#include "CCF/IDL2/Traversal/ValueTypeMember.hpp" + +#endif // CCF_IDL2_TRAVERSAL_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Array.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Array.cpp new file mode 100644 index 00000000000..e142383535f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Array.cpp @@ -0,0 +1,78 @@ +// file : CCF/IDL2/Traversal/Array.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Array.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Array:: + traverse (Type& a) + { + pre (a); + arguments_with_type (a); + arguments_with_value (a); + name (a); + post (a); + } + + void Array:: + pre (Type&) + { + } + + void Array:: + arguments_with_type (Type& a, EdgeDispatcherBase& d) + { + d.traverse (**a.arguments_begin ()); + } + + void Array:: + arguments_with_type (Type& a) + { + arguments_with_type (a, edge_traverser ()); + } + + void Array:: + arguments_with_value (Type& a, EdgeDispatcherBase& d) + { + Type::ArgumentsIterator + b (a.arguments_begin ()), e (a.arguments_end ()); + + ++b; // Bounds start afterthe type. + + iterate_and_traverse (b, + e, + d, + *this, + &Array::comma, + a); + } + + void Array:: + arguments_with_value (Type& a) + { + arguments_with_value (a, edge_traverser ()); + } + + void Array:: + comma (Type&) + { + } + + void Array:: + name (Type&) + { + } + + void Array:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Array.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Array.hpp new file mode 100644 index 00000000000..fb608c6df9a --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Array.hpp @@ -0,0 +1,51 @@ +// file : CCF/IDL2/Traversal/Array.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ARRAY_HPP +#define CCF_IDL2_TRAVERSAL_ARRAY_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Array.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Array : Node<SemanticGraph::Array> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + arguments_with_type (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_type (Type&); + + virtual void + arguments_with_value (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_value (Type&); + + virtual void + comma (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_ARRAY_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp new file mode 100644 index 00000000000..42ff8bd21bf --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp @@ -0,0 +1,280 @@ +// file : CCF/IDL2/Traversal/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Attribute + // + // + void Attribute:: + traverse (Type& a) + { + pre (a); + belongs (a); + name (a); + post (a); + } + + void Attribute:: + pre (Type&) + { + } + + void Attribute:: + belongs (Type& a, EdgeDispatcherBase& d) + { + d.traverse (a.belongs ()); + } + + void Attribute:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void Attribute:: + name (Type&) + { + } + + void Attribute:: + post (Type&) + { + } + + // ReadAttribute + // + // + void ReadAttribute:: + traverse (Type& a) + { + pre (a); + belongs (a); + name (a); + get_raises (a); + post (a); + } + + void ReadAttribute:: + pre (Type&) + { + } + + void ReadAttribute:: + belongs (Type& a, EdgeDispatcherBase& d) + { + d.traverse (a.belongs ()); + } + + void ReadAttribute:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void ReadAttribute:: + name (Type&) + { + } + + void ReadAttribute:: + get_raises (Type& a, EdgeDispatcherBase& d) + { + iterate_and_traverse (a.get_raises_begin (), a.get_raises_end (), d); + } + + void ReadAttribute:: + get_raises (Type& a) + { + Type::GetRaisesIterator + b (a.get_raises_begin ()), + e (a.get_raises_end ()); + + if (b != e) + { + get_raises_pre (a); + iterate_and_traverse (b, + e, + edge_traverser (), + *this, + &ReadAttribute::comma, + a); + get_raises_post (a); + } + else + { + get_raises_none (a); + } + } + + void ReadAttribute:: + get_raises_pre (Type&) + { + } + + void ReadAttribute:: + get_raises_post (Type&) + { + } + + void ReadAttribute:: + get_raises_none (Type&) + { + } + + void ReadAttribute:: + post (Type&) + { + } + + void ReadAttribute:: + comma (Type&) + { + } + + + // ReadWriteAttribute + // + // + void ReadWriteAttribute:: + traverse (Type& a) + { + pre (a); + belongs (a); + name (a); + get_raises (a); + set_raises (a); + post (a); + } + + void ReadWriteAttribute:: + pre (Type&) + { + } + + void ReadWriteAttribute:: + belongs (Type& a, EdgeDispatcherBase& d) + { + d.traverse (a.belongs ()); + } + + void ReadWriteAttribute:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void ReadWriteAttribute:: + name (Type&) + { + } + + void ReadWriteAttribute:: + get_raises (Type& a, EdgeDispatcherBase& d) + { + iterate_and_traverse (a.get_raises_begin (), a.get_raises_end (), d); + } + + void ReadWriteAttribute:: + get_raises (Type& a) + { + Type::GetRaisesIterator + b (a.get_raises_begin ()), + e (a.get_raises_end ()); + + if (b != e) + { + get_raises_pre (a); + iterate_and_traverse (b, + e, + edge_traverser (), + *this, + &ReadWriteAttribute::comma, + a); + get_raises_post (a); + } + else + { + get_raises_none (a); + } + } + + void ReadWriteAttribute:: + get_raises_pre (Type&) + { + } + + void ReadWriteAttribute:: + get_raises_post (Type&) + { + } + + void ReadWriteAttribute:: + get_raises_none (Type&) + { + } + + void ReadWriteAttribute:: + set_raises (Type& a, EdgeDispatcherBase& d) + { + iterate_and_traverse (a.set_raises_begin (), a.set_raises_end (), d); + } + + void ReadWriteAttribute:: + set_raises (Type& a) + { + Type::SetRaisesIterator + b (a.set_raises_begin ()), + e (a.set_raises_end ()); + + if (b != e) + { + set_raises_pre (a); + iterate_and_traverse (b, + e, + edge_traverser (), + *this, + &ReadWriteAttribute::comma, + a); + set_raises_post (a); + } + else + { + set_raises_none (a); + } + } + + void ReadWriteAttribute:: + set_raises_pre (Type&) + { + } + + void ReadWriteAttribute:: + set_raises_post (Type&) + { + } + + void ReadWriteAttribute:: + set_raises_none (Type&) + { + } + + void ReadWriteAttribute:: + post (Type&) + { + } + + void ReadWriteAttribute:: + comma (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp new file mode 100644 index 00000000000..522671b6609 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp @@ -0,0 +1,170 @@ +// file : CCF/IDL2/Traversal/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ATTRIBUTE_HPP +#define CCF_IDL2_TRAVERSAL_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct GetRaises : Edge<SemanticGraph::GetRaises> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.exception ()); + } + }; + + + // + // + // + struct SetRaises : Edge<SemanticGraph::SetRaises> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.exception ()); + } + }; + + + // + // + // + struct Attribute : Node<SemanticGraph::Attribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + + // + // + // + struct ReadAttribute : Node<SemanticGraph::ReadAttribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + get_raises (Type&, EdgeDispatcherBase&); + + virtual void + get_raises (Type&); + + virtual void + get_raises_pre (Type&); + + virtual void + get_raises_post (Type&); + + virtual void + get_raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + + + // + // + // + struct ReadWriteAttribute : Node<SemanticGraph::ReadWriteAttribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + get_raises (Type&, EdgeDispatcherBase&); + + virtual void + get_raises (Type&); + + virtual void + get_raises_pre (Type&); + + virtual void + get_raises_post (Type&); + + virtual void + get_raises_none (Type&); + + virtual void + set_raises (Type&, EdgeDispatcherBase&); + + virtual void + set_raises (Type&); + + virtual void + set_raises_pre (Type&); + + virtual void + set_raises_post (Type&); + + virtual void + set_raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_ATTRIBUTE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp new file mode 100644 index 00000000000..c7a24089a42 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp new file mode 100644 index 00000000000..03793aafeef --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp @@ -0,0 +1,471 @@ +// file : CCF/IDL2/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ELEMENTS_HPP +#define CCF_IDL2_TRAVERSAL_ELEMENTS_HPP + +#include <map> +#include <set> + +#include "CCF/CompilerElements/Introspection.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +/* +#include <iostream> + +using std::cerr; +using std::endl; +*/ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + template<typename T> + class Traverser + { + protected: + virtual + ~Traverser (); + + virtual void + trampoline (T& n) = 0; + + template <typename> + friend class Dispatcher; + }; + + + // + // + // + template <typename T> + class Dispatcher + { + public: + virtual + ~Dispatcher (); + + virtual void + traverse (T& n); + + void + map (Introspection::TypeId id, Traverser<T>& t) + { + Traversers& traversers (traversal_map_[id]); + traversers.push_back (&t); + } + + public: + typedef + std::vector<Traverser<T>*> + Traversers; + + typedef + std::map<Introspection::TypeId, Traversers> + TraversalMap; + + typedef + typename TraversalMap::const_iterator + Iterator; + + Iterator + begin () const + { + return traversal_map_.begin (); + } + + Iterator + end () const + { + return traversal_map_.end (); + } + + private: + struct TypeInfoComparator + { + bool + operator () (Introspection::TypeInfo const& x, + Introspection::TypeInfo const& y) const + { + return x.type_id () < y.type_id (); + } + }; + + typedef + std::map<Introspection::TypeInfo, unsigned long, TypeInfoComparator> + LevelMap; + + typedef + std::set<Introspection::TypeInfo, TypeInfoComparator> + TypeInfoSet; + + static unsigned long + compute_levels (Introspection::TypeInfo const& ti, + unsigned long cur, + LevelMap& map); + + static void + flatten_tree (Introspection::TypeInfo const& ti, TypeInfoSet& set); + + private: + TraversalMap traversal_map_; + }; + + + // + // + // + typedef + Dispatcher<SemanticGraph::Node> + NodeDispatcherBase; + + typedef + Dispatcher<SemanticGraph::Edge> + EdgeDispatcherBase; + + + // + // + // + class NodeDispatcher : public virtual NodeDispatcherBase + { + public: + void + edge_traverser (EdgeDispatcherBase& d) + { + //@@ this should be done in Dispatcher in merge() function? + // + for (EdgeDispatcherBase::Iterator i (d.begin ()), end (d.end ()); + i != end; ++i) + { + for (EdgeDispatcherBase::Traversers::const_iterator + t (i->second.begin ()), end (i->second.end ()); + t != end; ++t) + { + dispatcher_.map (i->first, **t); + } + } + } + + protected: + template <typename I> + void + iterate_and_traverse (I begin, I end, EdgeDispatcherBase& d) + { + for (; begin != end; ++begin) + { + d.traverse (**begin); + } + } + + template <typename I, typename X, typename A> + void + iterate_and_traverse (I begin, + I end, + EdgeDispatcherBase& d, + X& x, + void (X::*f)(A&), + A& a) + { + for (I i (begin); i != end;) + { + d.traverse (**i); + + if (++i != end) (x.*f) (a); + } + } + + EdgeDispatcherBase& + edge_traverser () + { + return dispatcher_; + } + + protected: + EdgeDispatcherBase dispatcher_; + }; + + + class EdgeDispatcher : public virtual EdgeDispatcherBase + { + public: + //@@ this should be done in Dispatcher in merge() function? + // + void + node_traverser (NodeDispatcherBase& d) + { + for (NodeDispatcherBase::Iterator i (d.begin ()), end (d.end ()); + i != end; ++i) + { + for (NodeDispatcherBase::Traversers::const_iterator + t (i->second.begin ()), end (i->second.end ()); + t != end; ++t) + { + dispatcher_.map (i->first, **t); + } + } + } + + protected: + NodeDispatcherBase& + node_traverser () + { + return dispatcher_; + } + + protected: + NodeDispatcherBase dispatcher_; + }; + + + // + // + // + template <typename T> + struct Node : Traverser<SemanticGraph::Node>, virtual NodeDispatcher + { + typedef + T + Type; + + Node () + { + map (typeid (Type), *this); + } + + virtual void + trampoline (SemanticGraph::Node& n) + { + //cerr << "trampoline for " << &n << " to type " + // << typeid (Type).name () << endl; + + traverse (dynamic_cast<Type&> (n)); + } + + virtual void + traverse (Type&) = 0; + }; + + + template <typename T> + struct Edge : Traverser <SemanticGraph::Edge>, virtual EdgeDispatcher + { + typedef + T + Type; + + Edge () + { + map (typeid (Type), *this); + } + + virtual void + trampoline (SemanticGraph::Edge& e) + { + traverse (dynamic_cast<Type&> (e)); + } + + + virtual void + traverse (Type& e) = 0; + }; + + // Edges + // + // + struct Names : Edge<SemanticGraph::Names> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + struct Defines : Edge<SemanticGraph::Defines> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + struct Mentions : Edge<SemanticGraph::Mentions> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + + struct Aliases : Edge<SemanticGraph::Aliases> + { + virtual void + traverse (Type& a) + { + pre (a); + type (a); + name (a); + post (a); + } + + virtual void + pre (Type&) + { + } + + virtual void + type (Type& e) + { + node_traverser ().traverse (e.named ()); + } + + virtual void + name (Type&) + { + } + + virtual void + post (Type&) + { + } + }; + + + struct Belongs : Edge<SemanticGraph::Belongs> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.type ()); + } + }; + + + struct Arguments : Edge<SemanticGraph::Arguments> + { + virtual void + traverse (Type& a) + { + node_traverser ().traverse (a.argument ()); + } + }; + + struct ArgumentsWithType : Edge<SemanticGraph::ArgumentsWithType> + { + virtual void + traverse (Type& a) + { + node_traverser ().traverse (a.type ()); + } + }; + + struct ArgumentsWithValue : Edge<SemanticGraph::ArgumentsWithValue> + { + virtual void + traverse (Type& a) + { + node_traverser ().traverse (a.value ()); + } + }; + + struct Inherits : Edge<SemanticGraph::Inherits> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.inheritee ()); + } + }; + + + struct Contains : Edge<SemanticGraph::Contains> + { + }; + + + // Nodes + // + // + struct Nameable : Node<SemanticGraph::Nameable> + { + }; + + + template <typename T> + struct ScopeTemplate : Node<T> + { + public: + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T& s) + { + names (s); + } + + virtual void + names (T& s) + { + names_pre (s); + names (s, this->edge_traverser ()); + names_post (s); + } + + virtual void + names (T& s, EdgeDispatcherBase& d) + { + iterate_and_traverse (s.names_begin (), s.names_end (), d); + } + + virtual void + names_pre (T&) + { + } + + virtual void + names_post (T&) + { + } + }; + + + // + // + // + typedef + ScopeTemplate<SemanticGraph::Scope> + Scope; + + + // + // + // + struct Type : Node<SemanticGraph::Type> + { + virtual void + traverse (SemanticGraph::Type&) = 0; + }; + } + } +} + +#include "CCF/IDL2/Traversal/Elements.tpp" + +#endif // CCF_IDL2_TRAVERSAL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp b/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp new file mode 100644 index 00000000000..60cace27f69 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp @@ -0,0 +1,128 @@ +// file : CCF/IDL2/Traversal/Elements.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Traverser + // + // + + template<typename T> + Traverser<T>:: + ~Traverser () + { + } + + // Dispatcher + // + // + + template <typename T> + Dispatcher<T>:: + ~Dispatcher () + { + } + + template <typename T> + void Dispatcher<T>:: + traverse (T& n) + { + LevelMap levels; + + unsigned long max = compute_levels (n.type_info (), 0, levels); + + + //cerr << "starting dispatch process for " + // << n.type_info ().type_id () << " with " + // << max << " levels" << endl; + + for (unsigned long l = 0; l < max + 1; ++l) + { + TypeInfoSet dispatched; + + for (typename LevelMap::const_iterator + i (levels.begin ()), e (levels.end ()); + i != e; ++i) + { + if (i->second == l) + { + typename TraversalMap::const_iterator v ( + traversal_map_.find (i->first.type_id ())); + + if (v != traversal_map_.end ()) + { + //cerr << "dispatching traversers for " + // << n.type_info ().type_id () << " as " + // << i->first.type_id () << endl; + + Traversers const& traversers (v->second); + for (typename Traversers::const_iterator + ti (traversers.begin ()), te (traversers.end ()); + ti != te; ++ti) + { + (*ti)->trampoline (n); + } + + flatten_tree (i->first, dispatched); + } + } + } + + // Remove traversed types from level map. + // + for (typename TypeInfoSet::const_iterator i = dispatched.begin (); + i != dispatched.end (); + ++i) + { + levels.erase (*i); + } + } + } + + template <typename T> + unsigned long Dispatcher<T>:: + compute_levels (Introspection::TypeInfo const& ti, + unsigned long cur, + LevelMap& map) + { + unsigned long ret = cur; + + if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur; + + for (Introspection::TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + unsigned long t = compute_levels (i->type_info (), cur + 1, map); + if (t > ret) ret = t; + } + + return ret; + } + + template <typename T> + void Dispatcher<T>:: + flatten_tree (Introspection::TypeInfo const& ti, TypeInfoSet& set) + { + set.insert (ti); + + for (Introspection::TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + flatten_tree (i->type_info (), set); + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Enum.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Enum.cpp new file mode 100644 index 00000000000..35df538f85b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Enum.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Enum.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Enum.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Enum.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Enum.hpp new file mode 100644 index 00000000000..d789f30b1b0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Enum.hpp @@ -0,0 +1,30 @@ +// file : CCF/IDL2/Traversal/Enum.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ENUM_HPP +#define CCF_IDL2_TRAVERSAL_ENUM_HPP + +#include "CCF/IDL2/SemanticGraph/Enum.hpp" +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Minimal support for now. Talk to me if you need more. + // + struct Enum : Node<SemanticGraph::Enum> + { + }; + + struct Enumerator : Node<SemanticGraph::Enumerator> + { + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_ENUM_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp new file mode 100644 index 00000000000..21e41784c71 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/Traversal/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Exception:: + traverse (Type& s) + { + pre (s); + name (s); + names (s); + post (s); + } + + void Exception:: + pre (Type&) + { + } + + void Exception:: + name (Type&) + { + } + + void Exception:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp new file mode 100644 index 00000000000..23eda73f1a7 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL2/Traversal/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_EXCEPTION_HPP +#define CCF_IDL2_TRAVERSAL_EXCEPTION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Exception : ScopeTemplate<SemanticGraph::Exception> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_EXCEPTION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp new file mode 100644 index 00000000000..4dd6760cebe --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp new file mode 100644 index 00000000000..c4e10d18057 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp @@ -0,0 +1,101 @@ +// file : CCF/IDL2/Traversal/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP +#define CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + typedef + Node<SemanticGraph::FundamentalType> + FundamentalType; + + typedef + Node<SemanticGraph::Object> + Object; + + typedef + Node<SemanticGraph::ValueBase> + ValueBase; + + typedef + Node<SemanticGraph::Any> + Any; + + typedef + Node<SemanticGraph::Boolean> + Boolean; + + typedef + Node<SemanticGraph::Char> + Char; + + typedef + Node<SemanticGraph::Double> + Double; + + typedef + Node<SemanticGraph::Float> + Float; + + typedef + Node<SemanticGraph::Long> + Long; + + typedef + Node<SemanticGraph::LongDouble> + LongDouble; + + typedef + Node<SemanticGraph::LongLong> + LongLong; + + typedef + Node<SemanticGraph::Octet> + Octet; + + typedef + Node<SemanticGraph::Short> + Short; + + typedef + Node<SemanticGraph::String> + String; + + typedef + Node<SemanticGraph::UnsignedLong> + UnsignedLong; + + typedef + Node<SemanticGraph::UnsignedLongLong> + UnsignedLongLong; + + typedef + Node<SemanticGraph::UnsignedShort> + UnsignedShort; + + typedef + Node<SemanticGraph::Void> + Void; + + typedef + Node<SemanticGraph::Wchar> + Wchar; + + typedef + Node<SemanticGraph::Wstring> + Wstring; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/IntExpression.hpp b/CIAO/CCF/CCF/IDL2/Traversal/IntExpression.hpp new file mode 100644 index 00000000000..8e111874251 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/IntExpression.hpp @@ -0,0 +1,757 @@ +// file : CCF/IDL2/Traversal/IntExpression.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_INT_EXPRESSION_HPP +#define CCF_IDL2_TRAVERSAL_INT_EXPRESSION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/IntExpression.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + typedef + Node<SemanticGraph::IntExpression> + IntExpression; + + // + // + typedef + Node<SemanticGraph::IntLiteral> + IntLiteral; + + // + // + typedef + Node<SemanticGraph::IntConst> + IntConst; + + + // NEG + // + + struct IntNegates: Edge<SemanticGraph::IntNegates> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntNeg: Node<SemanticGraph::IntNeg> + { + virtual void + traverse (Type& n) + { + pre (n); + negates (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + negates (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.negates ()); + } + + virtual void + negates (Type& n) + { + negates (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // COM + // + + struct IntComplements: Edge<SemanticGraph::IntComplements> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntCom: Node<SemanticGraph::IntCom> + { + virtual void + traverse (Type& n) + { + pre (n); + complements (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + complements (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.complements ()); + } + + virtual void + complements (Type& n) + { + complements (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // MUL + // + + struct IntMultiplies: Edge<SemanticGraph::IntMultiplies> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntMul: Node<SemanticGraph::IntMul> + { + virtual void + traverse (Type& n) + { + pre (n); + multiplies_first_factor (n); + sign (n); + multiplies_second_factor (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + multiplies_first_factor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.first_factor ()); + } + + virtual void + multiplies_first_factor (Type& n) + { + multiplies_first_factor (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + multiplies_second_factor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. second_factor ()); + } + + virtual void + multiplies_second_factor (Type& n) + { + multiplies_second_factor (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // DIV & REM + // + + struct IntDivides: Edge<SemanticGraph::IntDivides> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntDiv: Node<SemanticGraph::IntDiv> + { + virtual void + traverse (Type& n) + { + pre (n); + divides_divident (n); + sign (n); + divides_divisor (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + divides_divident (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.divident ()); + } + + virtual void + divides_divident (Type& n) + { + divides_divident (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + divides_divisor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. divisor ()); + } + + virtual void + divides_divisor (Type& n) + { + divides_divisor (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + struct IntRem: Node<SemanticGraph::IntRem> + { + virtual void + traverse (Type& n) + { + pre (n); + divides_divident (n); + sign (n); + divides_divisor (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + divides_divident (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.divident ()); + } + + virtual void + divides_divident (Type& n) + { + divides_divident (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + divides_divisor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. divisor ()); + } + + virtual void + divides_divisor (Type& n) + { + divides_divisor (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // ADD + // + + struct IntAdds: Edge<SemanticGraph::IntAdds> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntAdd: Node<SemanticGraph::IntAdd> + { + virtual void + traverse (Type& n) + { + pre (n); + adds_first_item (n); + sign (n); + adds_second_item (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + adds_first_item (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.first_item ()); + } + + virtual void + adds_first_item (Type& n) + { + adds_first_item (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + adds_second_item (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. second_item ()); + } + + virtual void + adds_second_item (Type& n) + { + adds_second_item (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // SUB + // + + struct IntSubtracts: Edge<SemanticGraph::IntSubtracts> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntSub: Node<SemanticGraph::IntSub> + { + virtual void + traverse (Type& n) + { + pre (n); + subtracts_minuend (n); + sign (n); + subtracts_subtrahend (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + subtracts_minuend (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.minuend ()); + } + + virtual void + subtracts_minuend (Type& n) + { + subtracts_minuend (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + subtracts_subtrahend (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. subtrahend ()); + } + + virtual void + subtracts_subtrahend (Type& n) + { + subtracts_subtrahend (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // RSH & LSH + // + + struct IntShifts: Edge<SemanticGraph::IntShifts> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntRsh: Node<SemanticGraph::IntRsh> + { + virtual void + traverse (Type& n) + { + pre (n); + shifts_pattern (n); + sign (n); + shifts_factor (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + shifts_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.pattern ()); + } + + virtual void + shifts_pattern (Type& n) + { + shifts_pattern (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + shifts_factor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. factor ()); + } + + virtual void + shifts_factor (Type& n) + { + shifts_factor (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + struct IntLsh: Node<SemanticGraph::IntLsh> + { + virtual void + traverse (Type& n) + { + pre (n); + shifts_pattern (n); + sign (n); + shifts_factor (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + shifts_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.pattern ()); + } + + virtual void + shifts_pattern (Type& n) + { + shifts_pattern (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + shifts_factor (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. factor ()); + } + + virtual void + shifts_factor (Type& n) + { + shifts_factor (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // AND + // + + struct IntConjuncts: Edge<SemanticGraph::IntConjuncts> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntAnd: Node<SemanticGraph::IntAnd> + { + virtual void + traverse (Type& n) + { + pre (n); + conjuncts_first_pattern (n); + sign (n); + conjuncts_second_pattern (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + conjuncts_first_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.first_pattern ()); + } + + virtual void + conjuncts_first_pattern (Type& n) + { + conjuncts_first_pattern (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + conjuncts_second_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. second_pattern ()); + } + + virtual void + conjuncts_second_pattern (Type& n) + { + conjuncts_second_pattern (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // Xor + // + + struct IntExclusivelyDisjuncts: + Edge<SemanticGraph::IntExclusivelyDisjuncts> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntXor: Node<SemanticGraph::IntXor> + { + virtual void + traverse (Type& n) + { + pre (n); + exclusively_disjuncts_first_pattern (n); + sign (n); + exclusively_disjuncts_second_pattern (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + exclusively_disjuncts_first_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.first_pattern ()); + } + + virtual void + exclusively_disjuncts_first_pattern (Type& n) + { + exclusively_disjuncts_first_pattern (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + exclusively_disjuncts_second_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. second_pattern ()); + } + + virtual void + exclusively_disjuncts_second_pattern (Type& n) + { + exclusively_disjuncts_second_pattern (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + + + // Or + // + + struct IntInclusivelyDisjuncts: + Edge<SemanticGraph::IntInclusivelyDisjuncts> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.argument ()); + } + }; + + struct IntOr: Node<SemanticGraph::IntOr> + { + virtual void + traverse (Type& n) + { + pre (n); + inclusively_disjuncts_first_pattern (n); + sign (n); + inclusively_disjuncts_second_pattern (n); + post (n); + } + + virtual void + pre (Type&) + { + } + + virtual void + inclusively_disjuncts_first_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n.first_pattern ()); + } + + virtual void + inclusively_disjuncts_first_pattern (Type& n) + { + inclusively_disjuncts_first_pattern (n, edge_traverser ()); + } + + virtual void + sign (Type&) + { + } + + virtual void + inclusively_disjuncts_second_pattern (Type& n, EdgeDispatcherBase& d) + { + d.traverse (n. second_pattern ()); + } + + virtual void + inclusively_disjuncts_second_pattern (Type& n) + { + inclusively_disjuncts_second_pattern (n, edge_traverser ()); + } + + virtual void + post (Type&) + { + } + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_INT_EXPRESSION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp new file mode 100644 index 00000000000..fb6cbf9686c --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp new file mode 100644 index 00000000000..b0c05f36b80 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp @@ -0,0 +1,89 @@ +// file : CCF/IDL2/Traversal/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_INTERFACE_HPP +#define CCF_IDL2_TRAVERSAL_INTERFACE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Supports : Edge<SemanticGraph::Supports> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.supportee ()); + } + }; + + + template <typename T> + struct InterfaceTemplate : ScopeTemplate<T> + { + /* GCC#13590/DR#39 + using ScopeTemplate<T>::edge_traverser; + */ + + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + inherits (T&, EdgeDispatcherBase& d); + + virtual void + inherits (T&); + + virtual void + inherits_pre (T&); + + virtual void + inherits_post (T&); + + virtual void + inherits_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + + typedef + InterfaceTemplate<SemanticGraph::Interface> + Interface; + + + typedef + InterfaceTemplate<SemanticGraph::AbstractInterface> + AbstractInterface; + + typedef + InterfaceTemplate<SemanticGraph::LocalInterface> + LocalInterface; + + typedef + InterfaceTemplate<SemanticGraph::UnconstrainedInterface> + UnconstrainedInterface; + } + } +} + +#include "CCF/IDL2/Traversal/Interface.tpp" + +#endif // CCF_IDL2_TRAVERSAL_INTERFACE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp b/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp new file mode 100644 index 00000000000..23d2bfd922d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp @@ -0,0 +1,99 @@ +// file : CCF/IDL2/Traversal/Interface.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + template <typename T> + void InterfaceTemplate<T>:: + traverse (T& i) + { + pre (i); + name (i); + inherits (i); + names (i); + post (i); + } + + template <typename T> + void InterfaceTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + name (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits (T& i, EdgeDispatcherBase& d) + { + iterate_and_traverse (i.inherits_begin (), + i.inherits_end (), + d); + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits (T& i) + { + typename T::InheritsIterator + b (i.inherits_begin ()), e (i.inherits_end ()); + + if (b != e) + { + inherits_pre (i); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &InterfaceTemplate::comma, + i); + inherits_post (i); + } + else + { + inherits_none (i); + } + + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_pre (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_post (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_none (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + post (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Member.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Member.cpp new file mode 100644 index 00000000000..01299a0b00c --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Member.cpp @@ -0,0 +1,50 @@ +// file : CCF/IDL2/Traversal/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Member:: + traverse (Type& m) + { + pre (m); + belongs (m); + name (m); + post (m); + } + + void Member:: + pre (Type&) + { + } + + void Member:: + belongs (Type& m, EdgeDispatcherBase& d) + { + d.traverse (m.belongs ()); + } + + void Member:: + belongs (Type& m) + { + belongs (m, edge_traverser ()); + } + + void Member:: + name (Type&) + { + } + + void Member:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp new file mode 100644 index 00000000000..a0f05e6f33f --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/Traversal/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_MEMBER_HPP +#define CCF_IDL2_TRAVERSAL_MEMBER_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Member : Node<SemanticGraph::Member> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp new file mode 100644 index 00000000000..62f5d70aa9c --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp new file mode 100644 index 00000000000..994c40dd590 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp @@ -0,0 +1,48 @@ +// file : CCF/IDL2/Traversal/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_MODULE_HPP +#define CCF_IDL2_TRAVERSAL_MODULE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Module : ScopeTemplate<SemanticGraph::Module> + { + virtual void + traverse (Type& m) + { + pre (m); + name (m); + names (m); + post (m); + } + + virtual void + pre (Type&) + { + } + + virtual void + name (Type&) + { + } + + virtual void + post (Type&) + { + } + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_MODULE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Native.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Native.cpp new file mode 100644 index 00000000000..59a99bec8ad --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Native.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Native.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Native.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Native.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Native.hpp new file mode 100644 index 00000000000..ad70473c234 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Native.hpp @@ -0,0 +1,24 @@ +// file : CCF/IDL2/Traversal/Native.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_NATIVE_HPP +#define CCF_IDL2_TRAVERSAL_NATIVE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Native.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + typedef + Node<SemanticGraph::Native> + Native; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_NATIVE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp new file mode 100644 index 00000000000..2fca9de465b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp new file mode 100644 index 00000000000..04a426301f0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp @@ -0,0 +1,178 @@ +// file : CCF/IDL2/Traversal/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_OPERATION_HPP +#define CCF_IDL2_TRAVERSAL_OPERATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct Receives : Edge<SemanticGraph::Receives> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.parameter ()); + } + }; + + + // + // + // + struct Returns : Edge<SemanticGraph::Returns> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.type ()); + } + }; + + // + // + // + struct Raises : Edge<SemanticGraph::Raises> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.exception ()); + } + }; + + // + // + // + template<typename T> + struct ParameterTemplate : Node<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + belongs (T&, EdgeDispatcherBase&); + + virtual void + belongs (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + typedef + ParameterTemplate<SemanticGraph::Parameter> + Parameter; + + typedef + ParameterTemplate<SemanticGraph::InParameter> + InParameter; + + typedef + ParameterTemplate<SemanticGraph::InOutParameter> + InOutParameter; + + typedef + ParameterTemplate<SemanticGraph::OutParameter> + OutParameter; + + // + // + // + template <typename T> + struct OperationTemplate : Node<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + returns (T&, EdgeDispatcherBase&); + + virtual void + returns (T&); + + virtual void + name (T&); + + virtual void + receives (T&, EdgeDispatcherBase&); + + virtual void + receives (T&); + + virtual void + receives_pre (T&); + + virtual void + receives_post (T&); + + virtual void + receives_none (T&); + + virtual void + raises (T&, EdgeDispatcherBase&); + + virtual void + raises (T&); + + virtual void + raises_pre (T&); + + virtual void + raises_post (T&); + + virtual void + raises_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + typedef + OperationTemplate<SemanticGraph::Operation> + Operation; + + typedef + OperationTemplate<SemanticGraph::OneWayOperation> + OneWayOperation; + + typedef + OperationTemplate<SemanticGraph::TwoWayOperation> + TwoWayOperation; + } + } +} + +#include "CCF/IDL2/Traversal/Operation.tpp" + +#endif // CCF_IDL2_TRAVERSAL_OPERATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp b/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp new file mode 100644 index 00000000000..bcb3760ec3b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp @@ -0,0 +1,201 @@ +// file : CCF/IDL2/Traversal/Operation.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // ParameterTemplate + // + // + template<typename T> + void ParameterTemplate<T>:: + traverse (T& p) + { + pre (p); + belongs (p); + name (p); + post (p); + } + + template<typename T> + void ParameterTemplate<T>:: + pre (T&) + { + } + + template<typename T> + void ParameterTemplate<T>:: + belongs (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template<typename T> + void ParameterTemplate<T>:: + belongs (T& p) + { + belongs (p, this->edge_traverser ()); + } + + template<typename T> + void ParameterTemplate<T>:: + name (T&) + { + } + + template<typename T> + void ParameterTemplate<T>:: + post (T&) + { + } + + + // OperationTemplate + // + // + template<typename T> + void OperationTemplate<T>:: + traverse (T& o) + { + pre (o); + returns (o); + name (o); + receives (o); + raises (o); + post (o); + } + + template<typename T> + void OperationTemplate<T>:: + pre (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + returns (T& o, EdgeDispatcherBase& d) + { + d.traverse (o.returns ()); + } + + template<typename T> + void OperationTemplate<T>:: + returns (T& o) + { + returns (o, this->edge_traverser ()); + } + + template<typename T> + void OperationTemplate<T>:: + name (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + receives (T& o, EdgeDispatcherBase& d) + { + iterate_and_traverse (o.receives_begin (), o.receives_end (), d); + } + + template<typename T> + void OperationTemplate<T>:: + receives (T& o) + { + typename T::ReceivesIterator + b (o.receives_begin ()), e (o.receives_end ()); + + if (b != e) + { + receives_pre (o); + iterate_and_traverse ( + b, e, this->edge_traverser (), *this, &OperationTemplate<T>::comma, o); + receives_post (o); + } + else + { + receives_none (o); + } + } + + template<typename T> + void OperationTemplate<T>:: + receives_pre (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + receives_post (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + receives_none (T&) + { + } + + + template<typename T> + void OperationTemplate<T>:: + raises (T& o, EdgeDispatcherBase& d) + { + iterate_and_traverse (o.raises_begin (), o.raises_end (), d); + } + + template<typename T> + void OperationTemplate<T>:: + raises (T& o) + { + typename T::RaisesIterator b (o.raises_begin ()), e (o.raises_end ()); + + if (b != e) + { + raises_pre (o); + iterate_and_traverse ( + b, e, this->edge_traverser (), *this, &OperationTemplate<T>::comma, o); + raises_post (o); + } + else + { + raises_none (o); + } + } + + template<typename T> + void OperationTemplate<T>:: + raises_pre (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + raises_post (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + raises_none (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + post (T&) + { + } + + template<typename T> + void OperationTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp new file mode 100644 index 00000000000..c781cdcfb97 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp @@ -0,0 +1,111 @@ +// file : CCF/IDL2/Traversal/Sequence.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Sequence.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // UnboundedSequence + // + + void UnboundedSequence:: + traverse (Type& us) + { + pre (us); + arguments_with_type (us); + name (us); + post (us); + } + + void UnboundedSequence:: + pre (Type&) + { + } + + void UnboundedSequence:: + arguments_with_type (Type& us, EdgeDispatcherBase& d) + { + d.traverse (**us.arguments_begin ()); + } + + void UnboundedSequence:: + arguments_with_type (Type& us) + { + arguments_with_type (us, edge_traverser ()); + } + + void UnboundedSequence:: + name (Type&) + { + } + + void UnboundedSequence:: + post (Type&) + { + } + + + // BoundedSequence + // + + void BoundedSequence:: + traverse (Type& bs) + { + pre (bs); + arguments_with_type (bs); + arguments_with_value (bs); + name (bs); + post (bs); + } + + void BoundedSequence:: + pre (Type&) + { + } + + void BoundedSequence:: + arguments_with_type (Type& bs, EdgeDispatcherBase& d) + { + d.traverse (**bs.arguments_begin ()); + } + + void BoundedSequence:: + arguments_with_type (Type& bs) + { + arguments_with_type (bs, edge_traverser ()); + } + + void BoundedSequence:: + arguments_with_value (Type& bs, EdgeDispatcherBase& d) + { + Type::ArgumentsIterator i (bs.arguments_begin ()); + + ++i; // Bound is always second to the type. + + d.traverse (**i); + } + + void BoundedSequence:: + arguments_with_value (Type& bs) + { + arguments_with_value (bs, edge_traverser ()); + } + + void BoundedSequence:: + name (Type&) + { + } + + void BoundedSequence:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp new file mode 100644 index 00000000000..8011ff85c38 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp @@ -0,0 +1,69 @@ +// file : CCF/IDL2/Traversal/Sequence.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_SEQUENCE_HPP +#define CCF_IDL2_TRAVERSAL_SEQUENCE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct UnboundedSequence : Node<SemanticGraph::UnboundedSequence> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + arguments_with_type (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_type (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + + struct BoundedSequence : Node<SemanticGraph::BoundedSequence> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + arguments_with_type (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_type (Type&); + + virtual void + arguments_with_value (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_value (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_SEQUENCE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/String.cpp b/CIAO/CCF/CCF/IDL2/Traversal/String.cpp new file mode 100644 index 00000000000..0d1e23883ed --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/String.cpp @@ -0,0 +1,93 @@ +// file : CCF/IDL2/Traversal/String.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/String.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // BoundedString + // + + void BoundedString:: + traverse (Type& s) + { + pre (s); + arguments_with_value (s); + name (s); + post (s); + } + + void BoundedString:: + pre (Type&) + { + } + + void BoundedString:: + arguments_with_value (Type& s, EdgeDispatcherBase& d) + { + d.traverse (**s.arguments_begin ()); + } + + void BoundedString:: + arguments_with_value (Type& s) + { + arguments_with_value (s, edge_traverser ()); + } + + void BoundedString:: + name (Type&) + { + } + + void BoundedString:: + post (Type&) + { + } + + + // BoundedWideString + // + + void BoundedWideString:: + traverse (Type& s) + { + pre (s); + arguments_with_value (s); + name (s); + post (s); + } + + void BoundedWideString:: + pre (Type&) + { + } + + void BoundedWideString:: + arguments_with_value (Type& s, EdgeDispatcherBase& d) + { + d.traverse (**s.arguments_begin ()); + } + + void BoundedWideString:: + arguments_with_value (Type& s) + { + arguments_with_value (s, edge_traverser ()); + } + + void BoundedWideString:: + name (Type&) + { + } + + void BoundedWideString:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/String.hpp b/CIAO/CCF/CCF/IDL2/Traversal/String.hpp new file mode 100644 index 00000000000..7fca6eb7972 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/String.hpp @@ -0,0 +1,64 @@ +// file : CCF/IDL2/Traversal/String.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_STRING_HPP +#define CCF_IDL2_TRAVERSAL_STRING_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/String.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct BoundedString : Node<SemanticGraph::BoundedString> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + arguments_with_value (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_value (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + + + struct BoundedWideString : Node<SemanticGraph::BoundedWideString> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + arguments_with_value (Type&, EdgeDispatcherBase&); + + virtual void + arguments_with_value (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_STRING_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp new file mode 100644 index 00000000000..c9e4a23ee0d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/Traversal/Struct.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Struct.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Struct:: + traverse (Type& s) + { + pre (s); + name (s); + names (s); + post (s); + } + + void Struct:: + pre (Type&) + { + } + + void Struct:: + name (Type&) + { + } + + void Struct:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp new file mode 100644 index 00000000000..0ab61f8ef85 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/Traversal/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_STRUCT_HPP +#define CCF_IDL2_TRAVERSAL_STRUCT_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Struct.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Struct : ScopeTemplate<SemanticGraph::Struct> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_STRUCT_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp new file mode 100644 index 00000000000..e3fcd58e272 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/Traversal/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // TranslationRegion + // + // + void TranslationRegion:: + traverse (SemanticGraph::TranslationRegion& r) + { + iterate_and_traverse (r.contains_begin (), + r.contains_end (), + edge_traverser ()); + } + + + // TranslationUnit + // + // + void TranslationUnit:: + traverse (SemanticGraph::TranslationUnit& u) + { + iterate_and_traverse (u.contains_begin (), + u.contains_end (), + edge_traverser ()); + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp new file mode 100644 index 00000000000..7fc3f58c5d4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp @@ -0,0 +1,107 @@ +// file : CCF/IDL2/Traversal/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_TRANSLATION_HPP +#define CCF_IDL2_TRAVERSAL_TRANSLATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Some edges. + // + // + struct ContainsPrincipal : Edge<SemanticGraph::ContainsPrincipal> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct ContainsImplied : Edge<SemanticGraph::ContainsImplied> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct ContainsRoot : Edge<SemanticGraph::ContainsRoot> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct Includes : Edge<SemanticGraph::Includes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct QuoteIncludes : Edge<SemanticGraph::QuoteIncludes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct BracketIncludes : Edge<SemanticGraph::BracketIncludes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + + // + // + // + typedef + ScopeTemplate <SemanticGraph::Root> + Root; + + + // + // + // + struct TranslationRegion : Node<SemanticGraph::TranslationRegion> + { + virtual void + traverse (SemanticGraph::TranslationRegion&); + }; + + + // + // + // + struct TranslationUnit : Node<SemanticGraph::TranslationUnit> + { + virtual void + traverse (SemanticGraph::TranslationUnit&); + }; + + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_TRANSLATION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp b/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp new file mode 100644 index 00000000000..1e42505b5d7 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp b/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp new file mode 100644 index 00000000000..eb917dd69cb --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/Traversal/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_TYPE_ID_HPP +#define CCF_IDL2_TRAVERSAL_TYPE_ID_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Typeid and typeprefix are two idiotic constructs of IDL. + // They normally should not result in any directly generated + // code so only minimal (and most generic) support is provided. + // + + struct TypeId : Node<SemanticGraph::TypeId> + { + }; + + struct TypePrefix : Node<SemanticGraph::TypePrefix> + { + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_TYPE_ID_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Union.cpp b/CIAO/CCF/CCF/IDL2/Traversal/Union.cpp new file mode 100644 index 00000000000..b14f518983e --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Union.cpp @@ -0,0 +1,81 @@ +// file : CCF/IDL2/Traversal/Union.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Union.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // UnionMember + // + // + void UnionMember:: + traverse (Type& m) + { + pre (m); + belongs (m); + name (m); + post (m); + } + + void UnionMember:: + pre (Type&) + { + } + + void UnionMember:: + belongs (Type& m, EdgeDispatcherBase& d) + { + d.traverse (m.belongs ()); + } + + void UnionMember:: + belongs (Type& m) + { + belongs (m, edge_traverser ()); + } + + void UnionMember:: + name (Type&) + { + } + + void UnionMember:: + post (Type&) + { + } + + + // Union + // + // + void Union:: + traverse (Type& s) + { + pre (s); + name (s); + names (s); + post (s); + } + + void Union:: + pre (Type&) + { + } + + void Union:: + name (Type&) + { + } + + void Union:: + post (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/Union.hpp b/CIAO/CCF/CCF/IDL2/Traversal/Union.hpp new file mode 100644 index 00000000000..2bcad1eb4ea --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/Union.hpp @@ -0,0 +1,63 @@ +// file : CCF/IDL2/Traversal/Union.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_UNION_HPP +#define CCF_IDL2_TRAVERSAL_UNION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Union.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct UnionMember : Node<SemanticGraph::UnionMember> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct Union : ScopeTemplate<SemanticGraph::Union> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_UNION_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp new file mode 100644 index 00000000000..63dce1325df --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/ValueType.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp new file mode 100644 index 00000000000..a99ee48e814 --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp @@ -0,0 +1,89 @@ +// file : CCF/IDL2/Traversal/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP +#define CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + template <typename T> + struct ValueTypeTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + inherits (T&, EdgeDispatcherBase& d); + + virtual void + inherits (T&); + + virtual void + inherits_pre (T&); + + virtual void + inherits_post (T&); + + virtual void + inherits_none (T&); + + virtual void + supports (T&, EdgeDispatcherBase& d); + + virtual void + supports (T&); + + virtual void + supports_pre (T&); + + virtual void + supports_post (T&); + + virtual void + supports_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + + typedef + ValueTypeTemplate<SemanticGraph::ValueType> + ValueType; + + typedef + ValueTypeTemplate<SemanticGraph::AbstractValueType> + AbstractValueType; + + typedef + ValueTypeTemplate<SemanticGraph::ConcreteValueType> + ConcreteValueType; + + typedef + OperationTemplate<SemanticGraph::ValueTypeFactory> + ValueTypeFactory; + } + } +} + +#include "CCF/IDL2/Traversal/ValueType.tpp" + +#endif // CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp new file mode 100644 index 00000000000..e5582c4c61b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp @@ -0,0 +1,150 @@ +// file : CCF/IDL2/Traversal/ValueType.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + template <typename T> + void ValueTypeTemplate<T>:: + traverse (T& v) + { + pre (v); + name (v); + inherits (v); + supports (v); + names (v); + post (v); + } + + template <typename T> + void ValueTypeTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + name (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + inherits (T& v, EdgeDispatcherBase& d) + { + iterate_and_traverse (v.inherits_begin (), + v.inherits_end (), + d); + } + + template <typename T> + void ValueTypeTemplate<T>:: + inherits (T& v) + { + typename T::InheritsIterator + b (v.inherits_begin ()), e (v.inherits_end ()); + + if (b != e) + { + inherits_pre (v); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &ValueTypeTemplate::comma, + v); + inherits_post (v); + } + else + { + inherits_none (v); + } + } + + template <typename T> + void ValueTypeTemplate<T>:: + inherits_pre (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + inherits_post (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + inherits_none (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + supports (T& v, EdgeDispatcherBase& d) + { + iterate_and_traverse (v.supports_begin (), + v.supports_end (), + d); + } + + template <typename T> + void ValueTypeTemplate<T>:: + supports (T& v) + { + typename T::SupportsIterator + b (v.supports_begin ()), e (v.supports_end ()); + + if (b != e) + { + supports_pre (v); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &ValueTypeTemplate::comma, + v); + supports_post (v); + } + else + { + supports_none (v); + } + } + + template <typename T> + void ValueTypeTemplate<T>:: + supports_pre (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + supports_post (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + supports_none (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + post (T&) + { + } + + template <typename T> + void ValueTypeTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.hpp b/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.hpp new file mode 100644 index 00000000000..f579f7d765d --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.hpp @@ -0,0 +1,59 @@ +// file : CCF/IDL2/Traversal/ValueTypeMember.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_VALUE_TYPE_MEMBER_HPP +#define CCF_IDL2_TRAVERSAL_VALUE_TYPE_MEMBER_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + template <typename T> + struct ValueTypeMemberTemplate : Node<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + belongs (T&, EdgeDispatcherBase&); + + virtual void + belongs (T&); + + virtual void + name (T&); + + virtual void + post (T&); + + using Node<T>::edge_traverser; + }; + + typedef + ValueTypeMemberTemplate<SemanticGraph::ValueTypeMember> + ValueTypeMember; + + typedef + ValueTypeMemberTemplate<SemanticGraph::ValueTypePrivateMember> + ValueTypePrivateMember; + + typedef + ValueTypeMemberTemplate<SemanticGraph::ValueTypePublicMember> + ValueTypePublicMember; + } + } +} + +#include "CCF/IDL2/Traversal/ValueTypeMember.tpp" + +#endif // CCF_IDL2_TRAVERSAL_VALUE_TYPE_MEMBER_HPP diff --git a/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.tpp b/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.tpp new file mode 100644 index 00000000000..9629a9e056b --- /dev/null +++ b/CIAO/CCF/CCF/IDL2/Traversal/ValueTypeMember.tpp @@ -0,0 +1,54 @@ +// file : CCF/IDL2/Traversal/ValueTypeMember.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + template <typename T> + void ValueTypeMemberTemplate<T>:: + traverse (T& m) + { + pre (m); + belongs (m); + name (m); + post (m); + } + + template <typename T> + void ValueTypeMemberTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void ValueTypeMemberTemplate<T>:: + belongs (T& m, EdgeDispatcherBase& d) + { + d.traverse (m.belongs ()); + } + + template <typename T> + void ValueTypeMemberTemplate<T>:: + belongs (T& m) + { + belongs (m, edge_traverser ()); + } + + template <typename T> + void ValueTypeMemberTemplate<T>:: + name (T&) + { + } + + template <typename T> + void ValueTypeMemberTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/IDL3.mpc b/CIAO/CCF/CCF/IDL3/IDL3.mpc new file mode 100644 index 00000000000..593cc40c098 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/IDL3.mpc @@ -0,0 +1,15 @@ +//$Id$ + +project(IDL3): cidlc { + sharedname = + staticname = IDL3 + libout = .. + + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction/Impl + + } +} diff --git a/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp b/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..efabb4cf3c1 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp @@ -0,0 +1,30 @@ +// file : CCF/IDL3/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace IDL3 + { + LexicalAnalyzer:: + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is) + : IDL2::LexicalAnalyzer (is) + { + // Keywords (alphabetic order). + + keyword_table_.insert ("component"); + keyword_table_.insert ("consumes" ); + keyword_table_.insert ("emits" ); + keyword_table_.insert ("eventtype"); + keyword_table_.insert ("home" ); + keyword_table_.insert ("finder" ); + keyword_table_.insert ("manages" ); + keyword_table_.insert ("multiple" ); + keyword_table_.insert ("provides" ); + keyword_table_.insert ("publishes"); + keyword_table_.insert ("uses" ); + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp b/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..d0b581cee05 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp @@ -0,0 +1,22 @@ +// file : CCF/IDL3/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_LEXICAL_ANALYZER_HPP +#define CCF_IDL3_LEXICAL_ANALYZER_HPP + +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace IDL3 + { + class LexicalAnalyzer : public virtual IDL2::LexicalAnalyzer + { + public: + LexicalAnalyzer (CompilerElements::TokenStream<Char>& is); + }; + } +} + +#endif // CCF_IDL3_LEXICAL_ANALYZER_HPP diff --git a/CIAO/CCF/CCF/IDL3/Parser.cpp b/CIAO/CCF/CCF/IDL3/Parser.cpp new file mode 100644 index 00000000000..acb791f92c4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Parser.cpp @@ -0,0 +1,1154 @@ +// file : CCF/IDL3/Parser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/Parser.hpp" + +// +// Note: DO NOT run emacs indenter (or any other indentation tool) over +// this file because it will most likely break BNF indentation. +// + +namespace CCF +{ + namespace IDL3 + { + using IDL2::Parsing::DiagnosticType; + using IDL2::Parsing::RecoveryMethod; + + Parser:: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f) + : IDL2::Parser (context, dout, l, f), + + COMPONENT ("component"), + CONSUMES ("consumes" ), + EMITS ("emits" ), + EVENTTYPE ("eventtype"), + HOME ("home" ), + FINDER ("finder" ), + MANAGES ("manages" ), + MULTIPLE ("multiple" ), + PROVIDES ("provides" ), + PUBLISHES ("publishes"), + USES ("uses" ), + + + // Component + // + act_component_begin_def ( + f.component (), &SemanticAction::Component::begin_def), + + act_component_begin_fwd ( + f.component (), &SemanticAction::Component::begin_fwd), + + act_component_inherits ( + f.component (), &SemanticAction::Component::inherits), + + act_component_supports ( + f.component (), &SemanticAction::Component::supports), + + act_component_open_scope ( + f.component (), &SemanticAction::Scope::open_scope), + + act_component_close_scope ( + f.component (), &SemanticAction::Scope::close_scope), + + act_component_end ( + f.component (), &SemanticAction::Component::end), + + + // Provides + // + act_provides_type (f.provides (), &SemanticAction::Provides::type), + act_provides_name (f.provides (), &SemanticAction::Provides::name), + + + // Uses + // + act_uses_multiple (f.uses (), &SemanticAction::Uses::multiple), + act_uses_type (f.uses (), &SemanticAction::Uses::type), + act_uses_name (f.uses (), &SemanticAction::Uses::name), + + + // Publishes + // + act_publishes_type ( + f.publishes (), &SemanticAction::Publishes::type), + + act_publishes_name ( + f.publishes (), &SemanticAction::Publishes::name), + + + // Emits + // + act_emits_type (f.emits (), &SemanticAction::Emits::type), + act_emits_name (f.emits (), &SemanticAction::Emits::name), + + + // Consumes + // + act_consumes_type (f.consumes (), &SemanticAction::Consumes::type), + act_consumes_name (f.consumes (), &SemanticAction::Consumes::name), + + + // EventType + // + act_event_type_begin_abstract_def ( + f.event_type (), &SemanticAction::EventType::begin_abstract_def), + + act_event_type_begin_abstract_fwd ( + f.event_type (), &SemanticAction::EventType::begin_abstract_fwd), + + act_event_type_begin_concrete_def ( + f.event_type (), &SemanticAction::EventType::begin_concrete_def), + + act_event_type_begin_concrete_fwd ( + f.event_type (), &SemanticAction::EventType::begin_concrete_fwd), + + act_event_type_inherits ( + f.event_type (), &SemanticAction::EventType::inherits), + + act_event_type_supports ( + f.event_type (), &SemanticAction::EventType::supports), + + act_event_type_open_scope ( + f.event_type (), &SemanticAction::Scope::open_scope), + + act_event_type_close_scope ( + f.event_type (), &SemanticAction::Scope::close_scope), + + act_event_type_end ( + f.event_type (), &SemanticAction::EventType::end), + + // EventTypeFactory + // + act_event_type_factory_name ( + f.event_type_factory (), &SemanticAction::EventTypeFactory::name), + + act_event_type_factory_parameter ( + f.event_type_factory (), &SemanticAction::EventTypeFactory::parameter), + + act_event_type_factory_raises ( + f.event_type_factory (), &SemanticAction::EventTypeFactory::raises), + + + // Home + // + act_home_begin ( + f.home (), &SemanticAction::Home::begin), + + act_home_inherits ( + f.home (), &SemanticAction::Home::inherits), + + act_home_supports ( + f.home (), &SemanticAction::Home::supports), + + act_home_manages ( + f.home (), &SemanticAction::Home::manages), + + act_home_open_scope ( + f.home (), &SemanticAction::Scope::open_scope), + + act_home_close_scope ( + f.home (), &SemanticAction::Scope::close_scope), + + act_home_end ( + f.home (), &SemanticAction::Home::end), + + + // HomeFactory + // + act_home_factory_name ( + f.home_factory (), &SemanticAction::HomeFactory::name), + + act_home_factory_parameter ( + f.home_factory (), &SemanticAction::HomeFactory::parameter), + + act_home_factory_raises ( + f.home_factory (), &SemanticAction::HomeFactory::raises), + + + // HomeFinder + // + act_home_finder_name ( + f.home_finder (), &SemanticAction::HomeFinder::name), + + act_home_finder_parameter ( + f.home_finder (), &SemanticAction::HomeFinder::parameter), + + act_home_finder_raises ( + f.home_finder (), &SemanticAction::HomeFinder::raises) + + { + IDL2::Parser::extension = + component_decl + | concrete_event_type_decl + | home_decl + | extension + ; + + IDL2::Parser::abstract_type_decl = + ABSTRACT + >> guard + ( + assertion ("interface, valuetype or eventtype declaration expected") + ( + (INTERFACE >> abstract_interface_decl) + | + (VALUETYPE >> abstract_value_type_decl) + | + (EVENTTYPE >> abstract_event_type_decl) + ) + )[error_handler] + ; + + // component + // + // + + component_decl = + COMPONENT + >> guard + ( + assertion ("component declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_component_begin_fwd][act_component_end] + | + ( + ( + simple_identifier + >> COLON + )[act_component_begin_def] + + >> hood + ( + component_inheritance_spec + >> !(SUPPORTS >> component_support_spec) + >> assertion ("'{' expected") + ( + LCBRACE[act_component_open_scope] + ) + >> hood (component_body) + [ + handler (f.component (), + &SemanticAction::Component::close_scope) + ] + >> assertion ("'}' expected", + f.component (), + &SemanticAction::Component::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_component_close_scope] + ) + ) + [ + handler (f.component (), + &SemanticAction::Component::end) + ] + + >> assertion ("';' expected", + f.component (), + &SemanticAction::Component::end, + RecoveryMethod::NONE) + ( + SEMI[act_component_end] + ) + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_component_begin_def] + + >> hood + ( + component_support_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_component_open_scope] + ) + >> hood (component_body) + [ + handler (f.component (), + &SemanticAction::Component::close_scope) + ] + >> assertion ("'}' expected", + f.component (), + &SemanticAction::Component::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_component_close_scope] + ) + ) + [ + handler (f.component (), + &SemanticAction::Component::end) + ] + + >> assertion ("';' expected", + f.component (), + &SemanticAction::Component::end, + RecoveryMethod::NONE) + ( + SEMI[act_component_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_component_begin_def][act_component_open_scope] + + >> hood + ( + hood (component_body) + [ + handler (f.component (), + &SemanticAction::Component::close_scope) + ] + >> assertion ("'}' expected", + f.component (), + &SemanticAction::Component::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_component_close_scope] + ) + ) + [ + handler (f.component (), + &SemanticAction::Component::end) + ] + + >> assertion ("';' expected", + f.component (), + &SemanticAction::Component::end, + RecoveryMethod::NONE) + ( + SEMI[act_component_end] + ) + ) + ) + )[error_handler] + ; + + component_inheritance_spec = + guard + ( + assertion ("base component name expected") + ( + identifier[act_component_inherits] + ) + )[error_handler] + ; + + component_support_spec = + guard + ( + assertion ("supported interface name expected") + ( + identifier[act_component_supports] + ) + >> *( + COMMA + >> assertion ("supported interface name expected") + ( + identifier[act_component_supports] + ) + ) + )[error_handler] + ; + + component_body = + *( provides_decl + | uses_decl + | emits_decl + | publishes_decl + | consumes_decl + | attribute_decl + ) + ; + + // ports + // + // + provides_decl = + PROVIDES + >> guard + ( + assertion ("interface name expected") + ( + identifier[act_provides_type] + ) + >> assertion ("provides name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_provides_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + uses_decl = + USES + >> guard + ( + !(MULTIPLE[act_uses_multiple]) + >> assertion ("interface name expected") + ( + identifier[act_uses_type] + ) + >> assertion ("uses name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_uses_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + emits_decl = + EMITS + >> guard + ( + assertion ("eventtype name expected") + ( + identifier[act_emits_type] + ) + >> assertion ("emits name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_emits_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + publishes_decl = + PUBLISHES + >> guard + ( + assertion ("eventtype name expected") + ( + identifier[act_publishes_type] + ) + >> assertion ("publishes name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_publishes_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + consumes_decl = + CONSUMES + >> guard + ( + assertion ("eventtype name expected") + ( + identifier[act_consumes_type] + ) + >> assertion ("consumes name expected", + DiagnosticType::BEFORE) + ( + simple_identifier[act_consumes_name] + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + + // eventtype + // + // + abstract_event_type_decl = + guard + ( + assertion ("abstract eventtype declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_event_type_begin_abstract_fwd][act_event_type_end] + | + ( + ( + simple_identifier + >> COLON + )[act_event_type_begin_abstract_def] + + >> hood + ( + event_type_inheritance_spec + >> !(SUPPORTS >> event_type_supports_spec) + >> assertion ("'{' expected") + ( + LCBRACE[act_event_type_open_scope] + ) + >> hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_event_type_begin_abstract_def] + + >> hood + ( + event_type_supports_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_event_type_open_scope] + ) + >> hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_event_type_begin_abstract_def][act_event_type_open_scope] + + >> hood + ( + hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + ) + )[error_handler] + ; + + + concrete_event_type_decl = + EVENTTYPE + >> guard + ( + assertion ("eventtype declaration expected", + DiagnosticType::BEFORE) + ( + ( + simple_identifier + >> SEMI + )[act_event_type_begin_concrete_fwd][act_event_type_end] + | + ( + ( + simple_identifier + >> COLON + )[act_event_type_begin_concrete_def] + + >> hood + ( + event_type_inheritance_spec + >> !(SUPPORTS >> event_type_supports_spec) + >> assertion ("'{' expected") + ( + LCBRACE[act_event_type_open_scope] + ) + >> hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_event_type_begin_concrete_def] + + >> hood + ( + event_type_supports_spec + >> assertion ("'{' expected") + ( + LCBRACE[act_event_type_open_scope] + ) + >> hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + | + ( + ( + simple_identifier + >> LCBRACE + )[act_event_type_begin_concrete_def][act_event_type_open_scope] + + >> hood + ( + hood (event_type_body) + [ + handler (f.event_type (), + &SemanticAction::EventType::close_scope) + ] + >> assertion ("'}' expected", + f.event_type (), + &SemanticAction::EventType::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_event_type_close_scope] + ) + ) + [ + handler (f.event_type (), + &SemanticAction::EventType::end) + ] + + >> assertion ("';' expected", + f.event_type (), + &SemanticAction::EventType::end, + RecoveryMethod::NONE) + ( + SEMI[act_event_type_end] + ) + ) + ) + )[error_handler] + ; + + event_type_inheritance_spec = + guard + ( + assertion ("base eventtype name expected") + ( + identifier[act_event_type_inherits] + ) + >> *( + COMMA + >> assertion ("base eventtype name expected") + ( + identifier[act_event_type_inherits] + ) + ) + )[error_handler] + ; + + event_type_supports_spec = + guard + ( + assertion ("supported interface name expected") + ( + identifier[act_event_type_supports] + ) + >> *( + COMMA + >> assertion ("supported interface name expected") + ( + identifier[act_event_type_supports] + ) + ) + )[error_handler] + ; + + event_type_body = + *( + const_decl + | type_decl + | type_id_decl + | type_prefix_decl + + | attribute_decl + | operation_decl + | value_type_member_decl + | event_type_factory_decl + ) + ; + + + // eventtype factory + // + // + event_type_factory_decl = + FACTORY + >> guard + ( + assertion ("factory name expected") + ( + simple_identifier[act_event_type_factory_name] + ) + >> assertion ("'(' expected") + ( + LPAREN + ) + >> event_type_factory_parameter_list + >> assertion ("parameter declaration or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> !( + RAISES + >> assertion ("'(' expected") + ( + LPAREN + ) + >> event_type_factory_raises_list + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + event_type_factory_parameter_list = + *( + event_type_factory_parameter + >> *(COMMA >> event_type_factory_parameter) + ) + ; + + event_type_factory_parameter = + IN + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("parameter name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_event_type_factory_parameter] + )[error_handler] + ; + + event_type_factory_raises_list = + guard + ( + assertion ("exception name expected") + ( + identifier[act_event_type_factory_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_event_type_factory_raises] + ) + ) + )[error_handler] + ; + + // + // home + // + home_decl = + HOME + >> guard + ( + assertion ("home name expected") + ( + simple_identifier[act_home_begin] + ) + >> hood + ( + !(COLON >> home_inheritance_spec) + >> !(SUPPORTS >> home_support_spec) + >> assertion ("'manages' expected", + DiagnosticType::BEFORE) + ( + MANAGES + ) + >> assertion ("executor name expected") + ( + identifier[act_home_manages] + ) + >> assertion ("'{' expected") + ( + LCBRACE[act_home_open_scope] + ) + >> hood (home_body) + [ + handler (f.home (), + &SemanticAction::Home::close_scope) + ] + >> assertion ("'}' expected", + f.home (), + &SemanticAction::Home::close_scope, + DiagnosticType::BEFORE) + ( + RCBRACE[act_home_close_scope] + ) + ) + [ + handler (f.home (), + &SemanticAction::Home::end) + ] + >> assertion ("';' expected", + f.home (), + &SemanticAction::Home::end, + RecoveryMethod::NONE) + ( + SEMI[act_home_end] + ) + )[error_handler] + ; + + home_inheritance_spec = + guard + ( + assertion ("base home name expected") + ( + identifier[act_home_inherits] + ) + )[error_handler] + ; + + home_support_spec = + guard + ( + assertion ("supported interface name expected") + ( + identifier[act_home_supports] + ) + >> *( + COMMA + >> assertion ("supported interface name expected") + ( + identifier[act_home_supports] + ) + ) + )[error_handler] + ; + + home_body = + *( + const_decl + | type_decl + | type_id_decl + | type_prefix_decl + + | attribute_decl + | operation_decl + | home_factory_decl + | home_finder_decl + ) + ; + + // home factory + // + // + home_factory_decl = + FACTORY + >> guard + ( + assertion ("factory name expected") + ( + simple_identifier[act_home_factory_name] + ) + >> assertion ("'(' expected") + ( + LPAREN + ) + >> home_factory_parameter_list + >> assertion ("parameter declaration or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> !( + RAISES + >> assertion ("'(' expected") + ( + LPAREN + ) + >> home_factory_raises_list + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + home_factory_parameter_list = + *( + home_factory_parameter + >> *(COMMA >> home_factory_parameter) + ) + ; + + home_factory_parameter = + IN + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("parameter name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_home_factory_parameter] + )[error_handler] + ; + + home_factory_raises_list = + guard + ( + assertion ("exception name expected") + ( + identifier[act_home_factory_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_home_factory_raises] + ) + ) + )[error_handler] + ; + + + // home finder + // + // + home_finder_decl = + FINDER + >> guard + ( + assertion ("finder name expected") + ( + simple_identifier[act_home_finder_name] + ) + >> assertion ("'(' expected") + ( + LPAREN + ) + >> home_finder_parameter_list + >> assertion ("parameter declaration or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + >> !( + RAISES + >> assertion ("'(' expected") + ( + LPAREN + ) + >> home_finder_raises_list + >> assertion ("',' or ')' expected", + DiagnosticType::BEFORE) + ( + RPAREN + ) + ) + >> assertion ("';' expected", + RecoveryMethod::NONE) + ( + SEMI + ) + )[error_handler] + ; + + home_finder_parameter_list = + *( + home_finder_parameter + >> *(COMMA >> home_finder_parameter) + ) + ; + + home_finder_parameter = + IN + >> guard + ( + ( + assertion ("type name expected") + ( + identifier + ) + >> assertion ("parameter name expected", + DiagnosticType::BEFORE) + ( + simple_identifier + ) + )[act_home_finder_parameter] + )[error_handler] + ; + + home_finder_raises_list = + guard + ( + assertion ("exception name expected") + ( + identifier[act_home_finder_raises] + ) + >> *( + COMMA + >> assertion ("exception name expected") + ( + identifier[act_home_finder_raises] + ) + ) + )[error_handler] + ; + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/Parser.hpp b/CIAO/CCF/CCF/IDL3/Parser.hpp new file mode 100644 index 00000000000..715045f2466 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Parser.hpp @@ -0,0 +1,256 @@ +// file : CCF/IDL3/Parser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_PARSER_HPP +#define CCF_IDL3_PARSER_HPP + +#include "CCF/IDL2/Parser.hpp" + +#include "CCF/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/SemanticAction.hpp" + +namespace CCF +{ + namespace IDL3 + { + using IDL2::ActionExecutor; + using IDL2::NoArgAction; + using IDL2::OneArgAction; + using IDL2::TwoArgAction; + + class Parser : public virtual IDL2::Parser + { + protected: + // + // Primitives (alphabetic order). + // + + KeywordParser COMPONENT; + KeywordParser CONSUMES; + KeywordParser EMITS; + KeywordParser EVENTTYPE; + KeywordParser HOME; + KeywordParser FINDER; + KeywordParser MANAGES; + KeywordParser MULTIPLE; + KeywordParser PROVIDES; + KeywordParser PUBLISHES; + KeywordParser USES; + + + // + // Language + // + + Rule extension; + + // component + // + Rule component_decl; + Rule component_inheritance_spec; + Rule component_support_spec; + Rule component_body; + + Rule provides_decl; + Rule uses_decl; + Rule emits_decl; + Rule publishes_decl; + Rule consumes_decl; + + // eventtype + // + Rule abstract_event_type_decl; + Rule concrete_event_type_decl; + Rule event_type_inheritance_spec; + Rule event_type_supports_spec; + Rule event_type_body; + + Rule event_type_factory_decl; + Rule event_type_factory_parameter_list; + Rule event_type_factory_parameter; + Rule event_type_factory_raises_list; + + // home + // + Rule home_decl; + Rule home_inheritance_spec; + Rule home_support_spec; + Rule home_body; + + Rule home_factory_decl; + Rule home_factory_parameter_list; + Rule home_factory_parameter; + Rule home_factory_raises_list; + + Rule home_finder_decl; + Rule home_finder_parameter_list; + Rule home_finder_parameter; + Rule home_finder_raises_list; + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + protected: + // Component + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Component> + act_component_begin_def, act_component_begin_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::Component> + act_component_inherits; + + OneArgAction<IdentifierPtr, SemanticAction::Component> + act_component_supports; + + ScopeAction + act_component_open_scope; + + ScopeAction + act_component_close_scope; + + NoArgAction<SemanticAction::Component> + act_component_end; + + + // Provides + // + OneArgAction<IdentifierPtr, SemanticAction::Provides> + act_provides_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Provides> + act_provides_name; + + + // Uses + // + NoArgAction<SemanticAction::Uses> + act_uses_multiple; + + OneArgAction<IdentifierPtr, SemanticAction::Uses> + act_uses_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Uses> + act_uses_name; + + + // Publishes + // + OneArgAction<IdentifierPtr, SemanticAction::Publishes> + act_publishes_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Publishes> + act_publishes_name; + + + // Emits + // + OneArgAction<IdentifierPtr, SemanticAction::Emits> + act_emits_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Emits> + act_emits_name; + + + // Consumes + // + OneArgAction<IdentifierPtr, SemanticAction::Consumes> + act_consumes_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Consumes> + act_consumes_name; + + + // EventType + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::EventType> + act_event_type_begin_abstract_def, + act_event_type_begin_abstract_fwd, + act_event_type_begin_concrete_def, + act_event_type_begin_concrete_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::EventType> + act_event_type_inherits, act_event_type_supports; + + ScopeAction + act_event_type_open_scope; + + ScopeAction + act_event_type_close_scope; + + NoArgAction<SemanticAction::EventType> + act_event_type_end; + + // EventTypeFactory + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::EventTypeFactory> + act_event_type_factory_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::EventTypeFactory> + act_event_type_factory_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::EventTypeFactory> + act_event_type_factory_raises; + + + // Home + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Home> + act_home_begin; + + OneArgAction<IdentifierPtr, SemanticAction::Home> + act_home_inherits; + + OneArgAction<IdentifierPtr, SemanticAction::Home> + act_home_supports; + + OneArgAction<IdentifierPtr, SemanticAction::Home> + act_home_manages; + + ScopeAction + act_home_open_scope; + + ScopeAction + act_home_close_scope; + + NoArgAction<SemanticAction::Home> + act_home_end; + + + // HomeFactory + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeFactory> + act_home_factory_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::HomeFactory> + act_home_factory_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::HomeFactory> + act_home_factory_raises; + + + // HomeFinder + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeFinder> + act_home_finder_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::HomeFinder> + act_home_finder_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::HomeFinder> + act_home_finder_raises; + + }; + } +} + +#endif // CCF_IDL3_PARSER_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction.hpp new file mode 100644 index 00000000000..ae0f9d21b2e --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction.hpp @@ -0,0 +1,26 @@ +// file : CCF/IDL3/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HPP + +#include "CCF/IDL2/SemanticAction.hpp" + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +#include "CCF/IDL3/SemanticAction/Component.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventTypeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/HomeFinder.hpp" +#include "CCF/IDL3/SemanticAction/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Uses.hpp" + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +#endif // CCF_IDL3_SEMANTIC_ACTION_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp new file mode 100644 index 00000000000..9a8eeb645c8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_ACTION_COMPONENT_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Component : Scope + { + virtual void + begin_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_COMPONENT_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp new file mode 100644 index 00000000000..23d2507ea17 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL3/SemanticAction/Consumes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_CONSUMES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_CONSUMES_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Consumes + { + virtual ~Consumes () + { + } + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_CONSUMES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..7637a0c473c --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp @@ -0,0 +1,23 @@ +// file : CCF/IDL3/SemanticAction/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_ELEMENTS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_ELEMENTS_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +#include "CCF/IDL3/Token.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + using IDL2::SemanticAction::Scope; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp new file mode 100644 index 00000000000..43a6555a8eb --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL3/SemanticAction/Emits.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_EMITS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_EMITS_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Emits + { + virtual ~Emits () + { + } + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EMITS_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp new file mode 100644 index 00000000000..f6891d6ee24 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp @@ -0,0 +1,49 @@ +// file : CCF/IDL3/SemanticAction/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct EventType : Scope + { + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp new file mode 100644 index 00000000000..f476b31f93b --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL3/SemanticAction/EventTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct EventTypeFactory + { + virtual ~EventTypeFactory () + { + } + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..8dd3ae3d25f --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp @@ -0,0 +1,68 @@ +// file : CCF/IDL3/SemanticAction/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_FACTORY_HPP + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Component; + struct Provides; + struct Uses; + struct Publishes; + struct Emits; + struct Consumes; + struct EventType; + struct EventTypeFactory; + struct Home; + struct HomeFactory; + struct HomeFinder; + + + struct Factory : virtual IDL2::SemanticAction::Factory + { + virtual Component& + component () = 0; + + virtual Provides& + provides () = 0; + + virtual Uses& + uses () = 0; + + virtual Publishes& + publishes () = 0; + + virtual Emits& + emits () = 0; + + virtual Consumes& + consumes () = 0; + + virtual EventType& + event_type () = 0; + + virtual EventTypeFactory& + event_type_factory () = 0; + + virtual Home& + home () = 0; + + virtual HomeFactory& + home_factory () = 0; + + virtual HomeFinder& + home_finder () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp new file mode 100644 index 00000000000..9dac172d39e --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_HOME_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HOME_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Home : Scope + { + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + manages (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp new file mode 100644 index 00000000000..ae060698b8f --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL3/SemanticAction/HomeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_HOME_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HOME_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct HomeFactory + { + virtual ~HomeFactory () + { + } + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp new file mode 100644 index 00000000000..bf2d9ef9803 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL3/SemanticAction/HomeFinder.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_HOME_FINDER_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HOME_FINDER_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct HomeFinder + { + virtual ~HomeFinder () + { + } + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_FINDER_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp new file mode 100644 index 00000000000..68cec9313ae --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp @@ -0,0 +1,202 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Component:: + Component (Context& c) + : ScopeBase<SemanticGraph::Component> (c) + { + } + + void Component:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Component:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Component:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Component& c ( + resolve<SemanticGraph::Component> (from, name, Flags::defined)); + + ctx.tu ().new_edge<Inherits> (now (), c); + ctx.tu ().new_edge<Extends> (now (), c); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from forward-declared component is illegal" + << endl; + } + } + + void Component:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + //@@ Implementation of *_scope is the same for all cases. + // + void Component:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Component:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Component:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp new file mode 100644 index 00000000000..768799784e8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp @@ -0,0 +1,51 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Component : SemanticAction::Component, + ScopeBase<SemanticGraph::Component> + { + Component (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp new file mode 100644 index 00000000000..56dd0ef3b0a --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp @@ -0,0 +1,88 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Consumes:: + Consumes (Context& c) + : Base (c) + { + } + + void Consumes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "consumes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid consumes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in consumes declaration is illegal" + << endl; + } + } + + void Consumes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Consumer& c (ctx.tu ().new_node<Consumer> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (c, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), c, id->lexeme ()); + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp new file mode 100644 index 00000000000..65214fb90eb --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Consumes : SemanticAction::Consumes, Base + { + Consumes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..c52ff827fa5 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,30 @@ +// file : CCF/IDL3/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using IDL2::SemanticAction::Impl::Context; + using IDL2::SemanticAction::Impl::Base; + using IDL2::SemanticAction::Impl::ScopeBase; + + using IDL2::SemanticAction::Impl::lookup; + + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp new file mode 100644 index 00000000000..6f49a05016c --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp @@ -0,0 +1,88 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Emits:: + Emits (Context& c) + : Base (c) + { + } + + void Emits:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "emits " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid emits declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in emits declaration is illegal" + << endl; + } + } + + void Emits:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Emitter& e (ctx.tu ().new_node<Emitter> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (e, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), e, id->lexeme ()); + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp new file mode 100644 index 00000000000..30c0f254756 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Emits : SemanticAction::Emits, Base + { + Emits (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp new file mode 100644 index 00000000000..f68eda81cae --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp @@ -0,0 +1,293 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + EventType:: + EventType (Context& c) + : ScopeBase<SemanticGraph::EventType> (c) + { + } + + void EventType:: + begin_abstract_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "abstract eventtype def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void EventType:: + begin_abstract_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "abstract eventtype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void EventType:: + begin_concrete_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "concrete eventtype def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void EventType:: + begin_concrete_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete eventtype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void EventType:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::ValueType& v ( + resolve<SemanticGraph::ValueType> (from, name, Flags::defined)); + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + v); + + + bool abstract (dynamic_cast<AbstractValueType*> (&v) != 0); + + if (dynamic_cast<AbstractValueType*> (&now ()) != 0) + { + // Abstract eventtype may only inherit from abstract ones. + // + if (!abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "abstract eventtype `" << now ().name () + << "\' may not inherit from concrete valuetype `" + << v.scoped_name () << "\'" << endl; + return; + } + } + else + { + // Concrete eventtype may inherit from single concrete + // valutype in which case it should be the first in the + // inheritance list. + // + if (now ().inherits_begin () != now ().inherits_end () && + !abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "concrete valuetype `" << v.scoped_name () + << "\' is not the first in the inheritance list of " + << "eventtype `" << now ().name () << "\'" << endl; + return; + } + } + + ctx.tu ().new_edge<Inherits> (now (), v); + ctx.tu ().new_edge<Extends> (now (), v); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no valuetype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from the forward-declared valuetype " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from a forward-declared valuetype is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly inheriting from valuetype \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void EventType:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void EventType:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void EventType:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void EventType:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp new file mode 100644 index 00000000000..f82502be83c --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp @@ -0,0 +1,57 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct EventType : SemanticAction::EventType, + ScopeBase<SemanticGraph::EventType> + { + EventType (Context& c); + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id); + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp new file mode 100644 index 00000000000..8e8544815c0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp @@ -0,0 +1,152 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + EventTypeFactory:: + EventTypeFactory (Context& c) + : Base (c) + { + } + + void EventTypeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + f_ = 0; + + SemanticGraph::EventType& h ( + dynamic_cast<SemanticGraph::EventType&>(ctx.scope ())); + + SimpleName name (id->lexeme ()); + + f_ = &ctx.tu ().new_node<SemanticGraph::EventTypeFactory> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*f_, h); + ctx.tu ().new_edge<Defines> (ctx.scope (), *f_, name); + } + + + void EventTypeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (f_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*f_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void EventTypeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (f_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*f_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp new file mode 100644 index 00000000000..1489651b7c8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventTypeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct EventTypeFactory : SemanticAction::EventTypeFactory, Base + { + EventTypeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::EventTypeFactory* f_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..233d931b97e --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : IDL2::SemanticAction::Impl::Factory (context, dout, tu), + + component_ (ctx_), + consumes_ (ctx_), + emits_ (ctx_), + event_type_ (ctx_), + event_type_factory_ (ctx_), + home_ (ctx_), + home_factory_ (ctx_), + home_finder_ (ctx_), + include_ (ctx_, dout, *this), + provides_ (ctx_), + publishes_ (ctx_), + uses_ (ctx_) + { + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..fc6b80a9a6b --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,134 @@ +// file : CCF/IDL3/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Factory : virtual IDL3::SemanticAction::Factory, + virtual IDL2::SemanticAction::Impl::Factory + { + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + virtual SemanticAction::Consumes& + consumes () + { + return consumes_; + } + + virtual SemanticAction::Component& + component () + { + return component_; + } + + virtual SemanticAction::Emits& + emits () + { + return emits_; + } + + + virtual SemanticAction::EventType& + event_type () + { + return event_type_; + } + + virtual EventTypeFactory& + event_type_factory () + { + return event_type_factory_; + } + + + virtual SemanticAction::Home& + home () + { + return home_; + } + + virtual SemanticAction::HomeFactory& + home_factory () + { + return home_factory_; + } + + virtual SemanticAction::HomeFinder& + home_finder () + { + return home_finder_; + } + + virtual IDL2::SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Provides& + provides () + { + return provides_; + } + + virtual SemanticAction::Publishes& + publishes () + { + return publishes_; + } + + virtual SemanticAction::Uses& + uses () + { + return uses_; + } + + private: + + Component component_; + Consumes consumes_; + Emits emits_; + EventType event_type_; + EventTypeFactory event_type_factory_; + Home home_; + HomeFactory home_factory_; + HomeFinder home_finder_; + Include include_; + Provides provides_; + Publishes publishes_; + Uses uses_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp new file mode 100644 index 00000000000..d6be4cf9c72 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp @@ -0,0 +1,230 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Home:: + Home (Context& c) + : ScopeBase<SemanticGraph::Home> (c) + { + } + + void Home:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "home " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Home&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Home> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + + void Home:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Home& h ( + resolve<SemanticGraph::Home> (from, name, Flags::defined)); + + ctx.tu ().new_edge<Inherits> (now (), h); + ctx.tu ().new_edge<Extends> (now (), h); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no home with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from forward-declared home " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from forward-declared home is illegal" + << endl; + } + } + + + void Home:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support from forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + + void Home:: + manages (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "manages " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + ctx.tu ().new_edge<Manages> ( + now (), + resolve<SemanticGraph::Component> (from, name, Flags::defined)); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid manages specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in manages specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to manage forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "management of forward-declared component is illegal" + << endl; + } + } + + void Home:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Home:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Home:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp new file mode 100644 index 00000000000..459f78c89db --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp @@ -0,0 +1,50 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Home : SemanticAction::Home, ScopeBase<SemanticGraph::Home> + { + Home (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + manages (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp new file mode 100644 index 00000000000..b47e0b13410 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp @@ -0,0 +1,155 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeFactory:: + HomeFactory (Context& c) + : Base (c) + { + } + + void HomeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + hf_ = 0; + + SemanticGraph::Home& h ( + dynamic_cast<SemanticGraph::Home&>(ctx.scope ())); + + SemanticGraph::Component& c ( + dynamic_cast<SemanticGraph::Component&>(h.manages ().managee ())); + + SimpleName name (id->lexeme ()); + + hf_ = &ctx.tu ().new_node<SemanticGraph::HomeFactory> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*hf_, c); + ctx.tu ().new_edge<Defines> (ctx.scope (), *hf_, name); + } + + + void HomeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (hf_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*hf_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void HomeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (hf_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*hf_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp new file mode 100644 index 00000000000..1e6eccfb443 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct HomeFactory : SemanticAction::HomeFactory, Base + { + HomeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::HomeFactory* hf_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp new file mode 100644 index 00000000000..89fe20f36f4 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp @@ -0,0 +1,155 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeFinder:: + HomeFinder (Context& c) + : Base (c) + { + } + + void HomeFinder:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + hf_ = 0; + + SemanticGraph::Home& h ( + dynamic_cast<SemanticGraph::Home&>(ctx.scope ())); + + SemanticGraph::Component& c ( + dynamic_cast<SemanticGraph::Component&>(h.manages ().managee ())); + + SimpleName name (id->lexeme ()); + + hf_ = &ctx.tu ().new_node<SemanticGraph::HomeFinder> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*hf_, c); + ctx.tu ().new_edge<Defines> (ctx.scope (), *hf_, name); + } + + + void HomeFinder:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (hf_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*hf_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as a finder parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void HomeFinder:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (hf_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*hf_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp new file mode 100644 index 00000000000..0467eeda3ec --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFinder.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + + struct HomeFinder : SemanticAction::HomeFinder, Base + { + HomeFinder (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::HomeFinder* hf_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..3e4b42a5267 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp @@ -0,0 +1,284 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/Parser.hpp" + +#include <vector> +#include <string> +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Include:: + Include (Context& c, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory) + : Base (c), + dout_ (dout), + action_factory_ (action_factory) + { + abs_path_stack_.push ( + fs::normalize ( + fs::complete ( + ctx.parsing_context ().get<fs::path> ("file-path")))); + } + + void Include:: + quote (StringLiteralPtr const& sl) + { + impl (sl, quote_); + } + + void Include:: + bracket (StringLiteralPtr const& sl) + { + impl (sl, bracket_); + } + + + void Include:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + void Include:: + impl (StringLiteralPtr const& sl, Type_ type) + { + CompilerElements::Context& pctx (ctx.parsing_context ()); + + std::string prefix; + + if (type == quote_) + { + prefix = std::string ("include") + " \"" + sl->value () + "\""; + } + else + { + prefix = std::string ("include") + " <" + sl->value () + ">"; + } + + if (ctx.trace ()) cerr << prefix << endl; + + try + { + fs::ifstream ifs; + ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); + + fs::path include_path (sl->value ()); + fs::path complete_path (include_path); + + if (ctx.trace ()) cerr << prefix << ": staring resolution." + << endl; + + if (complete_path.is_complete ()) + { + complete_path = fs::normalize (complete_path); + + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + } + else + { + bool found (false); + + if (type == quote_) + { + fs::path rel_path (abs_path_stack_.top ().branch_path ()); + + complete_path = fs::normalize (rel_path / include_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + typedef std::vector<fs::path> SearchPaths; + + SearchPaths const& search_paths ( + pctx.get<SearchPaths> ("include-search-paths")); + + for (SearchPaths::const_iterator + i (search_paths.begin ()), + e (search_paths.end ()); i != e && !found; ++i) + { + complete_path = *i / include_path; + + if (!complete_path.is_complete ()) + { + complete_path = complete (complete_path); + } + + complete_path = fs::normalize (complete_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': file not found" << endl; + return; + } + } + } + + if (ctx.trace ()) cerr << prefix << ": resolved to " + << complete_path.string () << endl; + + //@@ for some reason ifs throws exception if I don't reset it + // to original state. It probably has something to do with + // call to get after eof. + // + ifs.exceptions (std::ios_base::iostate (0)); + + TranslationRegion& r ( + ctx.tu ().new_node<TranslationRegion> (include_path, 0)); + + if (type == quote_) + { + ctx.tu ().new_edge<QuoteIncludes> ( + ctx.region (), r, include_path); + } + else + { + ctx.tu ().new_edge<BracketIncludes> ( + ctx.region (), r, include_path); + } + + // Set new current region. + // + stack_.push (&ctx.region ()); + ctx.region (r); + + // Create Root scope for new region. + // + Root& root (ctx.tu ().new_node<Root> (include_path, 0)); + ctx.tu ().new_edge<ContainsRoot> (r, root); + ctx.scope (root); + + // Store previous relative path and current absolute. + // + rel_path_stack_.push (pctx.get<fs::path> ("file-path")); + pctx.set("file-path", include_path); + + abs_path_stack_.push (complete_path); + + + // Parse the file. + // + // + + //@@ this code is highly experimental + CompilerElements::InputStreamAdapter isa (ifs); + + CompilerElements::CPP::Symbols const& symbols ( + pctx.get<CompilerElements::CPP::Symbols> ("cpp-symbols")); + CompilerElements::CPP::Preprocessor pp (isa, symbols); + + IDL3::LexicalAnalyzer lexer (pp); + + TokenList token_stream; + + //@@ bad token comparison + for (TokenPtr token = lexer.next ();; token = lexer.next ()) + { + token_stream.push_back (token); + if (ReferenceCounting::strict_cast<EndOfStream> (token) != 0) + break; + } + + if (token_stream.size () > 1) + { + IDL3::Parser parser (pctx, dout_, lexer, action_factory_); + + IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + } + + // Restore paths + // + abs_path_stack_.pop (); + + pctx.set("file-path", rel_path_stack_.top ()); + rel_path_stack_.pop (); + + + // Restore region. + // + ctx.region (*stack_.top ()); + stack_.pop (); + + // Create new Root scope. + // + { + Root& root (ctx.tu ().new_node<Root> (ctx.file (), 0)); + ctx.tu ().new_edge<ContainsRoot> (ctx.region (), root); + ctx.scope (root); + } + } + catch (fs::filesystem_error const&) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': unable to open in read mode" << endl; + } + catch (std::ios_base::failure const&) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': unable to open in read mode" << endl; + } + } + + bool Include:: + handle_already_included (fs::path const& path, + StringLiteralPtr const&) + { + if(!include_file_set_.insert (path).second) + { + // cerr << "warning: skipping already included file " << sl + // << endl; + return true; + } + return false; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..9c699fe20ba --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp @@ -0,0 +1,84 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP + +#include <set> +#include <stack> + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // Note: overriding IDL2 include to allow inclusion of IDL3 files. + // + // + struct Include : IDL2::SemanticAction::Include, Base + { + public: + Include (Context& c, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory); + + virtual void + quote (StringLiteralPtr const& sl); + + virtual void + bracket (StringLiteralPtr const& sl); + + virtual void + end (); + + private: + enum Type_ + { + quote_, + bracket_ + }; + + virtual void + impl (StringLiteralPtr const& sl, Type_ type); + + bool + handle_already_included (fs::path const& path, + StringLiteralPtr const& sl); + private: + Diagnostic::Stream& dout_; + SemanticAction::Factory& action_factory_; + + std::stack<SemanticGraph::TranslationRegion*> stack_; + std::stack<fs::path> abs_path_stack_, rel_path_stack_; + + struct FilePathComparator + { + bool operator () (fs::path const& x, fs::path const& y) const + { + return x.string () < y.string (); + } + }; + + std::set<fs::path, FilePathComparator> include_file_set_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp new file mode 100644 index 00000000000..4bfc9818c65 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp @@ -0,0 +1,89 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Provides:: + Provides (Context& c) + : Base (c) + { + } + + void Provides:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "provides " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid provides declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an interface declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-interface type in provides declaration is " + << "illegal" << endl; + } + } + + void Provides:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Provider& p ( + ctx.tu ().new_node<Provider> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp new file mode 100644 index 00000000000..14dff782045 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Provides : SemanticAction::Provides, Base + { + Provides (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp new file mode 100644 index 00000000000..01ccd4a2347 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp @@ -0,0 +1,89 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Publishes:: + Publishes (Context& c) + : Base (c) + { + } + + void Publishes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "publishes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid publishes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in publishes declaration is illegal" + << endl; + } + } + + void Publishes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Publisher& p ( + ctx.tu ().new_node<Publisher> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp new file mode 100644 index 00000000000..584704acd66 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Publishes : SemanticAction::Publishes, Base + { + Publishes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp new file mode 100644 index 00000000000..ce32f39dea0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp @@ -0,0 +1,101 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Uses:: + Uses (Context& c) + : Base (c), multiple_ (false) + { + } + + void Uses:: + multiple () + { + multiple_ = true; + } + + void Uses:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "uses " << (multiple_ ? "multiple ": "") << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid uses declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an interface declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-interface type in uses declaration is " + << "illegal" << endl; + } + } + + void Uses:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + User* u; + + if (multiple_) + u = &ctx.tu ().new_node<MultiUser> (ctx.file (), id->line ()); + else + u = &ctx.tu ().new_node<SingleUser> (ctx.file (), id->line ()); + + ctx.tu ().new_edge<Belongs> (*u, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), *u, id->lexeme ()); + } + + multiple_ = false; + } + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp new file mode 100644 index 00000000000..bf7331ad172 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Uses.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Uses : SemanticAction::Uses, Base + { + Uses (Context& c); + + virtual void + multiple (); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + bool multiple_; + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp new file mode 100644 index 00000000000..30323092fa2 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL3/SemanticAction/Provides.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_PROVIDES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_PROVIDES_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Provides + { + virtual ~Provides () + { + } + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PROVIDES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp new file mode 100644 index 00000000000..e30eacb456e --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL3/SemanticAction/Publishes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_PUBLISHES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_PUBLISHES_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Publishes + { + virtual ~Publishes () + { + } + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PUBLISHES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp b/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp new file mode 100644 index 00000000000..453a6def984 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL3/SemanticAction/Uses.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_USES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_USES_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + struct Uses + { + virtual ~Uses () + { + } + + virtual void + multiple () = 0; + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_USES_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp b/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp new file mode 100644 index 00000000000..9192ca3b04c --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp @@ -0,0 +1,16 @@ +// file : CCF/IDL3/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL2/SemanticGraph.hpp" + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +#endif // CCF_IDL3_SEMANTIC_GRAPH_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp new file mode 100644 index 00000000000..da8d0dde24b --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp @@ -0,0 +1,187 @@ +// file : CCF/IDL3/SemanticGraph/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticGraph/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Provider + // + // + namespace + { + TypeInfo + provider_init_ () + { + TypeInfo ti (typeid (Provider)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo provider_ (provider_init_ ()); + } + + TypeInfo const& Provider:: + static_type_info () { return provider_; } + + + // User + // + // + namespace + { + TypeInfo + user_init_ () + { + TypeInfo ti (typeid (User)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo user_ (user_init_ ()); + } + + TypeInfo const& User:: + static_type_info () { return user_; } + + User:: + ~User () + { + } + + + // MultiUser + // + // + namespace + { + TypeInfo + multi_user_init_ () + { + TypeInfo ti (typeid (MultiUser)); + ti.add_base (Access::PUBLIC, true, User::static_type_info ()); + return ti; + } + + TypeInfo multi_user_ (multi_user_init_ ()); + } + + TypeInfo const& MultiUser:: + static_type_info () { return multi_user_; } + + + // SingleUser + // + // + namespace + { + TypeInfo + single_user_init_ () + { + TypeInfo ti (typeid (SingleUser)); + ti.add_base (Access::PUBLIC, true, User::static_type_info ()); + return ti; + } + + TypeInfo single_user_ (single_user_init_ ()); + } + + TypeInfo const& SingleUser:: + static_type_info () { return single_user_; } + + // Publisher + // + // + namespace + { + TypeInfo + publisher_init_ () + { + TypeInfo ti (typeid (Publisher)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo publisher_ (publisher_init_ ()); + } + + TypeInfo const& Publisher:: + static_type_info () { return publisher_; } + + + // Emitter + // + // + namespace + { + TypeInfo + emitter_init_ () + { + TypeInfo ti (typeid (Emitter)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo emitter_ (emitter_init_ ()); + } + + TypeInfo const& Emitter:: + static_type_info () { return emitter_; } + + + // Consumer + // + // + namespace + { + TypeInfo + consumer_init_ () + { + TypeInfo ti (typeid (Consumer)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo consumer_ (consumer_init_ ()); + } + + TypeInfo const& Consumer:: + static_type_info () { return consumer_; } + + + // Component + // + // + namespace + { + TypeInfo + component_init_ () + { + TypeInfo ti (typeid (Component)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo component_ (component_init_ ()); + } + + TypeInfo const& Component:: + static_type_info () { return component_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp new file mode 100644 index 00000000000..f3d7b7784e8 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp @@ -0,0 +1,234 @@ +// file : CCF/IDL3/SemanticGraph/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class Provider : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Provider (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class User : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + User () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~User () = 0; + }; + + + class MultiUser : public virtual User + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + MultiUser (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + class SingleUser : public virtual User + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + SingleUser (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Publisher : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Publisher (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Emitter : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Emitter (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Consumer : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Consumer (Path const& path, unsigned long line) + : Node (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Component : public virtual Type, public virtual Scope + { + typedef + std::vector <Supports*> + Supports_; + + public: + Inherits* + inherits () const + { + return inherits_; + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Component (Path const& path, unsigned long line) + : Node (path, line), inherits_ (0) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_ = &e; + } + + void + add_edge_right (Inherits&) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + void + add_edge_right (Manages&) + { + } + + private: + Inherits* inherits_; + Supports_ supports_; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..ab49a698842 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp @@ -0,0 +1,34 @@ +// file : CCF/IDL3/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + namespace + { + TypeInfo + manages_init_ () + { + TypeInfo ti (typeid (Manages)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo manages_ (manages_init_ ()); + } + + TypeInfo const& Manages:: + static_type_info () { return manages_; } + + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..b6577b6ff2e --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp @@ -0,0 +1,67 @@ +// file : CCF/IDL3/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using namespace CCF::IDL2::SemanticGraph; + + // + // + // + class Manages : public virtual Edge + { + public: + Node& + manager () const + { + return *manager_; + } + + Node& + managee () const + { + return *managee_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Manages () + { + type_info (static_type_info ()); + } + + void + set_left_node (Node& n) + { + manager_ = &n; + } + + void + set_right_node (Node& n) + { + managee_ = &n; + } + + private: + Node* manager_; + Node* managee_; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp new file mode 100644 index 00000000000..9fde39c008d --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp @@ -0,0 +1,106 @@ +// file : CCF/IDL3/SemanticGraph/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // EventType + // + // + namespace + { + TypeInfo + event_type_init_ () + { + TypeInfo ti (typeid (EventType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo event_type_ (event_type_init_ ()); + } + + TypeInfo const& EventType:: + static_type_info () { return event_type_; } + + EventType:: + ~EventType () + { + } + + + // AbstractEventType + // + // + namespace + { + TypeInfo + abstract_event_type_init_ () + { + TypeInfo ti (typeid (AbstractEventType)); + ti.add_base (Access::PUBLIC, true, EventType::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, AbstractValueType::static_type_info ()); + return ti; + } + + TypeInfo abstract_event_type_ (abstract_event_type_init_ ()); + } + + TypeInfo const& AbstractEventType:: + static_type_info () { return abstract_event_type_; } + + + // ConcreteEventType + // + // + namespace + { + TypeInfo + concrete_event_type_init_ () + { + TypeInfo ti (typeid (ConcreteEventType)); + ti.add_base (Access::PUBLIC, true, EventType::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, ConcreteValueType::static_type_info ()); + return ti; + } + + TypeInfo concrete_event_type_ (concrete_event_type_init_ ()); + } + + TypeInfo const& ConcreteEventType:: + static_type_info () { return concrete_event_type_; } + + + // EventTypeFactory + // + // + namespace + { + TypeInfo + event_type_factory_init_ () + { + TypeInfo ti (typeid (EventTypeFactory)); + ti.add_base ( + Access::PUBLIC, true, ValueTypeFactory::static_type_info ()); + return ti; + } + + TypeInfo event_type_factory_ (event_type_factory_init_ ()); + } + + TypeInfo const& EventTypeFactory:: + static_type_info () { return event_type_factory_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp new file mode 100644 index 00000000000..203ee321f66 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp @@ -0,0 +1,104 @@ +// file : CCF/IDL3/SemanticGraph/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class EventType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + EventType () // For virtual inheritance only. + { + type_info (static_type_info ()); + } + + virtual + ~EventType () = 0; + }; + + + // + // + // + class AbstractEventType : public virtual EventType, + public virtual AbstractValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractEventType (Path const& path, unsigned long line) + : Node (path, line), AbstractValueType (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ConcreteEventType : public virtual EventType, + public virtual ConcreteValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ConcreteEventType (Path const& path, unsigned long line) + : Node (path, line), ConcreteValueType (path, line) + { + type_info (static_type_info ()); + } + }; + + // + // + // + class EventTypeFactory : public virtual ValueTypeFactory + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + EventTypeFactory (Path const& path, unsigned long line) + : Node (path, line), + TwoWayOperation (path, line), + ValueTypeFactory (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp new file mode 100644 index 00000000000..deb3dacffa0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp @@ -0,0 +1,79 @@ +// file : CCF/IDL3/SemanticGraph/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Home + // + // + namespace + { + TypeInfo + home_init_ () + { + TypeInfo ti (typeid (Home)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo home_ (home_init_ ()); + } + + TypeInfo const& Home:: + static_type_info () { return home_; } + + + // HomeFactory + // + // + namespace + { + TypeInfo + home_factory_init_ () + { + TypeInfo ti (typeid (HomeFactory)); + ti.add_base ( + Access::PUBLIC, true, TwoWayOperation::static_type_info ()); + return ti; + } + + TypeInfo home_factory_ (home_factory_init_ ()); + } + + TypeInfo const& HomeFactory:: + static_type_info () { return home_factory_; } + + + // HomeFinder + // + // + namespace + { + TypeInfo + home_finder_init_ () + { + TypeInfo ti (typeid (HomeFinder)); + ti.add_base ( + Access::PUBLIC, true, TwoWayOperation::static_type_info ()); + return ti; + } + + TypeInfo home_finder_ (home_finder_init_ ()); + } + + TypeInfo const& HomeFinder:: + static_type_info () { return home_finder_; } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp b/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp new file mode 100644 index 00000000000..d243d468cbe --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp @@ -0,0 +1,149 @@ +// file : CCF/IDL3/SemanticGraph/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" +#include "CCF/IDL3/SemanticGraph/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class Home : public virtual Type, public virtual Scope + { + typedef + std::vector <Supports*> + Supports_; + + public: + Manages& + manages () const + { + return *manages_; + } + + Inherits* + inherits () const + { + return inherits_; + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Home (Path const& path, unsigned long line) + : Node (path, line), inherits_ (0) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Manages& e) + { + manages_ = &e; + } + + void + add_edge_left (Inherits& e) + { + inherits_ = &e; + } + + void + add_edge_right (Inherits&) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + private: + Manages* manages_; + Inherits* inherits_; + Supports_ supports_; + }; + + + // + // + // + class HomeFactory : public virtual TwoWayOperation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeFactory (Path const& path, unsigned long line) + : Node (path, line), TwoWayOperation (path, line) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class HomeFinder : public virtual TwoWayOperation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeFinder (Path const& path, unsigned long line) + : Node (path, line), TwoWayOperation (path, line) + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP diff --git a/CIAO/CCF/CCF/IDL3/Token.hpp b/CIAO/CCF/CCF/IDL3/Token.hpp new file mode 100644 index 00000000000..4a18aae6f13 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Token.hpp @@ -0,0 +1,34 @@ +// file : CCF/IDL3/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TOKEN_HPP +#define CCF_IDL3_TOKEN_HPP + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL3 + { + using IDL2::Token; + using IDL2::TokenPtr; + using IDL2::TokenList; + using IDL2::EndOfStream; + using IDL2::EndOfStreamPtr; + using IDL2::Keyword; + using IDL2::KeywordPtr; + using IDL2::Punctuation; + using IDL2::PunctuationPtr; + using IDL2::Identifier; + using IDL2::IdentifierPtr; + using IDL2::SimpleIdentifier; + using IDL2::SimpleIdentifierPtr; + using IDL2::ScopedIdentifier; + using IDL2::ScopedIdentifierPtr; + using IDL2::StringLiteral; + using IDL2::StringLiteralPtr; + } +} + +#endif // CCF_IDL3_TOKEN_HPP diff --git a/CIAO/CCF/CCF/IDL3/Traversal.hpp b/CIAO/CCF/CCF/IDL3/Traversal.hpp new file mode 100644 index 00000000000..aa83bd51156 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal.hpp @@ -0,0 +1,16 @@ +// file : CCF/IDL3/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_HPP +#define CCF_IDL3_TRAVERSAL_HPP + +#include "CCF/IDL2/Traversal.hpp" + +#include "CCF/IDL3/Traversal/Elements.hpp" + +#include "CCF/IDL3/Traversal/Component.hpp" +#include "CCF/IDL3/Traversal/EventType.hpp" +#include "CCF/IDL3/Traversal/Home.hpp" + +#endif // CCF_IDL3_TRAVERSAL_HPP diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp b/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp new file mode 100644 index 00000000000..1519650415c --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp @@ -0,0 +1,128 @@ +// file : CCF/IDL3/Traversal/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" + +#include "CCF/IDL3/Traversal/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // Component + // + // + void Component:: + traverse (Type& c) + { + pre (c); + name (c); + inherits (c); + supports (c); + names (c); + post (c); + } + + void Component:: + pre (Type&) + { + } + + void Component:: + name (Type&) + { + } + + void Component:: + inherits (Type& c, EdgeDispatcherBase& d) + { + if (SemanticGraph::Inherits* inh = c.inherits ()) + { + d.traverse (*inh); + } + } + + void Component:: + inherits (Type& c) + { + if (SemanticGraph::Inherits* inh = c.inherits ()) + { + inherits_pre (c); + edge_traverser ().traverse (*inh); + inherits_post (c); + } + else + { + inherits_none (c); + } + } + + void Component:: + inherits_pre (Type&) + { + } + + void Component:: + inherits_post (Type&) + { + } + + void Component:: + inherits_none (Type&) + { + } + + void Component:: + supports (Type& c, EdgeDispatcherBase& d) + { + iterate_and_traverse (c.supports_begin (), c.supports_end (), d); + } + + void Component:: + supports (Type& c) + { + Type::SupportsIterator b (c.supports_begin ()), e (c.supports_end ()); + + if (b != e) + { + supports_pre (c); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &Component::comma, c); + supports_post (c); + } + else + { + supports_none (c); + } + } + + void Component:: + supports_pre (Type&) + { + } + + void Component:: + supports_post (Type&) + { + } + + void Component:: + supports_none (Type&) + { + } + + void Component:: + post (Type&) + { + } + + void Component:: + comma (Type&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp b/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp new file mode 100644 index 00000000000..ebc0f79c704 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp @@ -0,0 +1,319 @@ +// file : CCF/IDL3/Traversal/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_COMPONENT_HPP +#define CCF_IDL3_TRAVERSAL_COMPONENT_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + struct PortTemplate : Node<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T&); + }; + + template <typename T> + struct PortAccessorTemplate : Node<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + returns (T&, EdgeDispatcherBase&); + + virtual void + returns (T&); + + virtual void + name (T&); + + virtual void + receives (T&, EdgeDispatcherBase&); + + virtual void + receives (T&); + + virtual void + receives_pre (T&); + + virtual void + receives_post (T&); + + virtual void + raises (T&, EdgeDispatcherBase&); + + virtual void + raises (T&); + + virtual void + raises_pre (T&); + + virtual void + raises_post (T&); + + virtual void + post (T&); + }; + + template <typename T> + struct PortGetTemplate : PortAccessorTemplate<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + returns (T&); + }; + + template <typename T> + struct PortSetTemplate : PortAccessorTemplate<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + receives (T&); + }; + + template <typename T> + struct PortDataTemplate : Node<T> + { + /* GCC#13590/DR#39 + using Node<T>::edge_traverser; + */ + + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + belongs (T&, EdgeDispatcherBase&); + + virtual void + belongs (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + // + // + // + typedef + PortTemplate<SemanticGraph::Provider> + Provider; + + typedef + PortGetTemplate<SemanticGraph::Provider> + ProviderGet; + + typedef + PortSetTemplate<SemanticGraph::Provider> + ProviderSet; + + typedef + PortDataTemplate<SemanticGraph::Provider> + ProviderData; + + // + // + // + typedef + PortTemplate<SemanticGraph::User> + User; + + typedef + PortGetTemplate<SemanticGraph::User> + UserGet; + + typedef + PortSetTemplate<SemanticGraph::User> + UserSet; + + typedef + PortDataTemplate<SemanticGraph::User> + UserData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::MultiUser> + MultiUser; + + typedef + PortGetTemplate<SemanticGraph::MultiUser> + MultiUserGet; + + typedef + PortSetTemplate<SemanticGraph::MultiUser> + MultiUserSet; + + typedef + PortDataTemplate<SemanticGraph::MultiUser> + MultiUserData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::SingleUser> + SingleUser; + + typedef + PortGetTemplate<SemanticGraph::SingleUser> + SingleUserGet; + + typedef + PortSetTemplate<SemanticGraph::SingleUser> + SingleUserSet; + + typedef + PortDataTemplate<SemanticGraph::SingleUser> + SingleUserData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::Publisher> + Publisher; + + typedef + PortGetTemplate<SemanticGraph::Publisher> + PublisherGet; + + typedef + PortSetTemplate<SemanticGraph::Publisher> + PublisherSet; + + typedef + PortDataTemplate<SemanticGraph::Publisher> + PublisherData; + + // + // + // + typedef + PortTemplate<SemanticGraph::Emitter> + Emitter; + + typedef + PortGetTemplate<SemanticGraph::Emitter> + EmitterGet; + + typedef + PortSetTemplate<SemanticGraph::Emitter> + EmitterSet; + + typedef + PortDataTemplate<SemanticGraph::Emitter> + EmitterData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::Consumer> + Consumer; + + typedef + PortGetTemplate<SemanticGraph::Consumer> + ConsumerGet; + + typedef + PortSetTemplate<SemanticGraph::Consumer> + ConsumerSet; + + typedef + PortDataTemplate<SemanticGraph::Consumer> + ConsumerData; + + // + // + // + struct Component : ScopeTemplate<SemanticGraph::Component> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&, EdgeDispatcherBase&); + + virtual void + inherits (Type&); + + virtual void + inherits_pre (Type&); + + virtual void + inherits_post (Type&); + + virtual void + inherits_none (Type&); + + virtual void + supports (Type&, EdgeDispatcherBase&); + + virtual void + supports (Type&); + + virtual void + supports_pre (Type&); + + virtual void + supports_post (Type&); + + virtual void + supports_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + } + } +} + +#include "CCF/IDL3/Traversal/Component.tpp" + +#endif // CCF_IDL3_TRAVERSAL_COMPONENT_HPP diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp b/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp new file mode 100644 index 00000000000..fc74e4c717b --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp @@ -0,0 +1,195 @@ +// file : CCF/IDL3/Traversal/Component.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // + // + // + template <typename T> + void PortTemplate<T>:: + traverse (T& p) + { + this->edge_traverser ().traverse (p.belongs ()); + } + + + // PortAccessorTemplate + // + // + template <typename T> + void PortAccessorTemplate<T>:: + traverse (T& p) + { + pre (p); + returns (p); + name (p); + receives (p); + raises (p); + post (p); + } + + template <typename T> + void PortAccessorTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + returns (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template <typename T> + void PortAccessorTemplate<T>:: + returns (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + name (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives (T& p, EdgeDispatcherBase& d) + { + // @@ Still thinking about the way of making + // fake parameter. + // + d.traverse (p.belongs ()); + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives (T& p) + { + receives_pre (p); + receives_post (p); + + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives_pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives_post (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises (T&, EdgeDispatcherBase&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises (T& p) + { + raises_pre (p); + raises_post (p); + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises_pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises_post (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + post (T&) + { + } + + // PortGetTemplate + // + // + template <typename T> + void PortGetTemplate<T>:: + returns (T& p) + { + PortAccessorTemplate<T>::returns (p, this->edge_traverser ()); + } + + + // PortSetTemplate + // + // + template <typename T> + void PortSetTemplate<T>:: + receives (T& p) + { + receives_pre (p); + PortAccessorTemplate<T>::receives (p, this->edge_traverser ()); + receives_post (p); + } + + + // PortDataTemplate + // + // + template <typename T> + void PortDataTemplate<T>:: + traverse (T& p) + { + pre (p); + belongs (p); + name (p); + post (p); + } + + template <typename T> + void PortDataTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void PortDataTemplate<T>:: + belongs (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template <typename T> + void PortDataTemplate<T>:: + belongs (T& p) + { + belongs (p, this->edge_traverser ()); + } + + template <typename T> + void PortDataTemplate<T>:: + name (T&) + { + } + + template <typename T> + void PortDataTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp b/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp new file mode 100644 index 00000000000..b92c5cf70fd --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp @@ -0,0 +1,21 @@ +// file : CCF/IDL3/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_ELEMENTS_HPP +#define CCF_IDL3_TRAVERSAL_ELEMENTS_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + using namespace IDL2::Traversal; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_ELEMENTS_HPP diff --git a/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp b/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp new file mode 100644 index 00000000000..941dfad76e6 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp @@ -0,0 +1,90 @@ +// file : CCF/IDL3/Traversal/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP +#define CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" + +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + struct EventTypeTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + inherits (T&, EdgeDispatcherBase&); + + virtual void + inherits (T&); + + virtual void + inherits_pre (T&); + + virtual void + inherits_post (T&); + + virtual void + inherits_none (T&); + + virtual void + supports (T&, EdgeDispatcherBase&); + + virtual void + supports (T&); + + virtual void + supports_pre (T&); + + virtual void + supports_post (T&); + + virtual void + supports_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + + typedef + EventTypeTemplate<SemanticGraph::EventType> + EventType; + + typedef + EventTypeTemplate<SemanticGraph::AbstractEventType> + AbstractEventType; + + typedef + EventTypeTemplate<SemanticGraph::ConcreteEventType> + ConcreteEventType; + + typedef + OperationTemplate<SemanticGraph::EventTypeFactory> + EventTypeFactory; + } + } +} + +#include "CCF/IDL3/Traversal/EventType.tpp" + +#endif // CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP diff --git a/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp b/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp new file mode 100644 index 00000000000..92c985c6176 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp @@ -0,0 +1,151 @@ +// file : CCF/IDL3/Traversal/EventType.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + void EventTypeTemplate<T>:: + traverse (T& et) + { + pre (et); + name (et); + inherits (et); + supports (et); + names (et); + post (et); + } + + template <typename T> + void EventTypeTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + name (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits (T& et, EdgeDispatcherBase& d) + { + iterate_and_traverse (et.inherits_begin (), + et.inherits_end (), + d); + + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits (T& et) + { + typename T::InheritsIterator + b (et.inherits_begin ()), e (et.inherits_end ()); + + if (b != e) + { + inherits_pre (et); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &EventTypeTemplate::comma, + et); + inherits_post (et); + } + else + { + inherits_none (et); + } + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_none (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports (T& et, EdgeDispatcherBase& d) + { + iterate_and_traverse (et.supports_begin (), + et.supports_end (), + d); + } + + template <typename T> + void EventTypeTemplate<T>:: + supports (T& et) + { + typename T::SupportsIterator + b (et.supports_begin ()), e (et.supports_end ()); + + if (b != e) + { + supports_pre (et); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &EventTypeTemplate::comma, + et); + supports_post (et); + } + else + { + supports_none (et); + } + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_none (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp b/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp new file mode 100644 index 00000000000..a6132394dc0 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp @@ -0,0 +1,381 @@ +// file : CCF/IDL3/Traversal/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/Traversal/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // Home + // + // + void Home:: + traverse (Type& h) + { + pre (h); + name (h); + inherits (h); + supports (h); + manages (h); + names (h); + post (h); + } + + void Home:: + pre (Type&) + { + } + + void Home:: + name (Type&) + { + } + + void Home:: + inherits (Type& h, EdgeDispatcherBase& d) + { + if (SemanticGraph::Inherits* inh = h.inherits ()) + { + d.traverse (*inh); + } + } + + void Home:: + inherits (Type& h) + { + if (SemanticGraph::Inherits* inh = h.inherits ()) + { + inherits_pre (h); + edge_traverser ().traverse (*inh); + inherits_post (h); + } + else + { + inherits_none (h); + } + } + + void Home:: + inherits_pre (Type&) + { + } + + void Home:: + inherits_post (Type&) + { + } + + void Home:: + inherits_none (Type&) + { + } + + void Home:: + supports (Type& h, EdgeDispatcherBase& d) + { + iterate_and_traverse (h.supports_begin (), h.supports_end (), d); + } + + void Home:: + supports (Type& h) + { + Type::SupportsIterator b (h.supports_begin ()), e (h.supports_end ()); + + if (b != e) + { + supports_pre (h); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &Home::comma, h); + supports_post (h); + } + else + { + supports_none (h); + } + } + + void Home:: + supports_pre (Type&) + { + } + + void Home:: + supports_post (Type&) + { + } + + void Home:: + supports_none (Type&) + { + } + + void Home:: + manages (Type& h, EdgeDispatcherBase& d) + { + d.traverse (h.manages ()); + } + + void Home:: + manages (Type& h) + { + manages_pre (h); + manages (h, edge_traverser ()); + manages_post (h); + } + + void Home:: + manages_pre (Type&) + { + } + + void Home:: + manages_post (Type&) + { + } + + void Home:: + post (Type&) + { + } + + void Home:: + comma (Type&) + { + } + +/* + // HomeFactory + // + // + void HomeFactory:: + traverse (Type& hf) + { + pre (hf); + returns (hf); + name (hf); + receives (hf); + raises (hf); + post (hf); + } + + void HomeFactory:: + pre (Type&) + { + } + + void HomeFactory:: + returns (Type& hf, EdgeDispatcherBase& d) + { + d.traverse (hf.returns ()); + } + + void HomeFactory:: + returns (Type& hf) + { + returns (hf, edge_traverser ()); + } + + void HomeFactory:: + name (Type&) + { + } + + void HomeFactory:: + receives (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.receives_begin (), hf.receives_end (), d); + } + + void HomeFactory:: + receives (Type& hf) + { + receives_pre (hf); + iterate_and_traverse (hf.receives_begin (), + hf.receives_end (), + edge_traverser (), + *this, + &HomeFactory::comma, + hf); + receives_post (hf); + } + + void HomeFactory:: + receives_pre (Type&) + { + } + + void HomeFactory:: + receives_post (Type&) + { + } + + void HomeFactory:: + raises (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.raises_begin (), hf.raises_end (), d); + } + + void HomeFactory:: + raises (Type& hf) + { + Type::RaisesIterator b (hf.raises_begin ()), e (hf.raises_end ()); + + if (b != e) + { + raises_pre (hf); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &HomeFactory::comma, hf); + raises_post (hf); + } + else + { + raises_none (hf); + } + } + + void HomeFactory:: + raises_pre (Type&) + { + } + + void HomeFactory:: + raises_post (Type&) + { + } + + void HomeFactory:: + raises_none (Type&) + { + } + + void HomeFactory:: + post (Type&) + { + } + + void HomeFactory:: + comma (Type&) + { + } + + // HomeFinder + // + // + void HomeFinder:: + traverse (Type& hf) + { + pre (hf); + returns (hf); + name (hf); + receives (hf); + raises (hf); + post (hf); + } + + void HomeFinder:: + pre (Type&) + { + } + + void HomeFinder:: + returns (Type& hf, EdgeDispatcherBase& d) + { + d.traverse (hf.returns ()); + } + + void HomeFinder:: + returns (Type& hf) + { + returns (hf, edge_traverser ()); + } + + void HomeFinder:: + name (Type&) + { + } + + void HomeFinder:: + receives (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.receives_begin (), hf.receives_end (), d); + } + + void HomeFinder:: + receives (Type& hf) + { + receives_pre (hf); + iterate_and_traverse (hf.receives_begin (), + hf.receives_end (), + edge_traverser (), + *this, + &HomeFinder::comma, + hf); + receives_post (hf); + } + + void HomeFinder:: + receives_pre (Type&) + { + } + + void HomeFinder:: + receives_post (Type&) + { + } + + void HomeFinder:: + raises (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.raises_begin (), hf.raises_end (), d); + } + + void HomeFinder:: + raises (Type& hf) + { + Type::RaisesIterator b (hf.raises_begin ()), e (hf.raises_end ()); + + if (b != e) + { + raises_pre (hf); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &HomeFinder::comma, hf); + raises_post (hf); + } + else + { + raises_none (hf); + } + } + + void HomeFinder:: + raises_pre (Type&) + { + } + + void HomeFinder:: + raises_post (Type&) + { + } + + void HomeFinder:: + raises_none (Type&) + { + } + + void HomeFinder:: + post (Type&) + { + } + + void HomeFinder:: + comma (Type&) + { + } +*/ + } + } +} diff --git a/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp b/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp new file mode 100644 index 00000000000..076bbab68c3 --- /dev/null +++ b/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp @@ -0,0 +1,219 @@ +// file : CCF/IDL3/Traversal/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_HOME_HPP +#define CCF_IDL3_TRAVERSAL_HOME_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + + // + // + // + struct Manages : Edge<SemanticGraph::Manages> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.managee ()); + } + }; + + // + // + // + struct Home : ScopeTemplate<SemanticGraph::Home> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&, EdgeDispatcherBase&); + + virtual void + inherits (Type&); + + virtual void + inherits_pre (Type&); + + virtual void + inherits_post (Type&); + + virtual void + inherits_none (Type&); + + virtual void + supports (Type&, EdgeDispatcherBase&); + + virtual void + supports (Type&); + + virtual void + supports_pre (Type&); + + virtual void + supports_post (Type&); + + virtual void + supports_none (Type&); + + virtual void + manages (Type&, EdgeDispatcherBase&); + + virtual void + manages (Type&); + + virtual void + manages_pre (Type&); + + virtual void + manages_post (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + + + // + // + // + /* + struct HomeFactory : Node<SemanticGraph::HomeFactory> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + returns (Type&, EdgeDispatcherBase&); + + virtual void + returns (Type&); + + virtual void + name (Type&); + + virtual void + receives (Type&, EdgeDispatcherBase&); + + virtual void + receives (Type&); + + virtual void + receives_pre (Type&); + + virtual void + receives_post (Type&); + + virtual void + raises (Type&, EdgeDispatcherBase&); + + virtual void + raises (Type&); + + virtual void + raises_pre (Type&); + + virtual void + raises_post (Type&); + + virtual void + raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + */ + + typedef + OperationTemplate<SemanticGraph::HomeFactory> + HomeFactory; + + // + // + // + /* + struct HomeFinder : Node<SemanticGraph::HomeFinder> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + returns (Type&, EdgeDispatcherBase&); + + virtual void + returns (Type&); + + virtual void + name (Type&); + + virtual void + receives (Type&, EdgeDispatcherBase&); + + virtual void + receives (Type&); + + virtual void + receives_pre (Type&); + + virtual void + receives_post (Type&); + + virtual void + raises (Type&, EdgeDispatcherBase&); + + virtual void + raises (Type&); + + virtual void + raises_pre (Type&); + + virtual void + raises_post (Type&); + + virtual void + raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + */ + + typedef + OperationTemplate<SemanticGraph::HomeFinder> + HomeFinder; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_HOME_HPP |