diff options
Diffstat (limited to 'modules/CIAO/CCF/CCF/IDL3')
65 files changed, 7189 insertions, 0 deletions
diff --git a/modules/CIAO/CCF/CCF/IDL3/IDL3.mpc b/modules/CIAO/CCF/CCF/IDL3/IDL3.mpc new file mode 100644 index 00000000000..593cc40c098 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp b/modules/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..efabb4cf3c1 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp b/modules/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..d0b581cee05 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Parser.cpp b/modules/CIAO/CCF/CCF/IDL3/Parser.cpp new file mode 100644 index 00000000000..acb791f92c4 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Parser.hpp b/modules/CIAO/CCF/CCF/IDL3/Parser.hpp new file mode 100644 index 00000000000..715045f2466 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction.hpp new file mode 100644 index 00000000000..ae0f9d21b2e --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp new file mode 100644 index 00000000000..9a8eeb645c8 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp new file mode 100644 index 00000000000..36d64ce5797 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp @@ -0,0 +1,28 @@ +// 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 void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_CONSUMES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..7637a0c473c --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp new file mode 100644 index 00000000000..819383a2df4 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp @@ -0,0 +1,28 @@ +// 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 void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EMITS_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp new file mode 100644 index 00000000000..f6891d6ee24 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp new file mode 100644 index 00000000000..12514bb773e --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/EventTypeFactory.hpp @@ -0,0 +1,32 @@ +// 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 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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..8dd3ae3d25f --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp new file mode 100644 index 00000000000..9dac172d39e --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp new file mode 100644 index 00000000000..405370f3f64 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp @@ -0,0 +1,32 @@ +// 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 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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp new file mode 100644 index 00000000000..e24cf65065b --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFinder.hpp @@ -0,0 +1,32 @@ +// 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 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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp new file mode 100644 index 00000000000..68cec9313ae --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp new file mode 100644 index 00000000000..768799784e8 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp new file mode 100644 index 00000000000..56dd0ef3b0a --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp new file mode 100644 index 00000000000..65214fb90eb --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..c52ff827fa5 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp new file mode 100644 index 00000000000..6f49a05016c --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp new file mode 100644 index 00000000000..30c0f254756 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp new file mode 100644 index 00000000000..f68eda81cae --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp new file mode 100644 index 00000000000..f82502be83c --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp new file mode 100644 index 00000000000..8e8544815c0 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp new file mode 100644 index 00000000000..1489651b7c8 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..233d931b97e --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..fc6b80a9a6b --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp new file mode 100644 index 00000000000..d6be4cf9c72 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp new file mode 100644 index 00000000000..459f78c89db --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp new file mode 100644 index 00000000000..b47e0b13410 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp new file mode 100644 index 00000000000..1e6eccfb443 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp new file mode 100644 index 00000000000..89fe20f36f4 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp new file mode 100644 index 00000000000..0467eeda3ec --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..3e4b42a5267 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..9c699fe20ba --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp new file mode 100644 index 00000000000..4bfc9818c65 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp new file mode 100644 index 00000000000..14dff782045 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp new file mode 100644 index 00000000000..01ccd4a2347 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp new file mode 100644 index 00000000000..584704acd66 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp new file mode 100644 index 00000000000..ce32f39dea0 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp new file mode 100644 index 00000000000..bf7331ad172 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp new file mode 100644 index 00000000000..3b54f53b050 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp @@ -0,0 +1,28 @@ +// 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 void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PROVIDES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp new file mode 100644 index 00000000000..46fa0a65892 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp @@ -0,0 +1,28 @@ +// 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 void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PUBLISHES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp new file mode 100644 index 00000000000..dcd571bf5fa --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp @@ -0,0 +1,31 @@ +// 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 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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp new file mode 100644 index 00000000000..9192ca3b04c --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp new file mode 100644 index 00000000000..da8d0dde24b --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp new file mode 100644 index 00000000000..f3d7b7784e8 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..ab49a698842 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..b6577b6ff2e --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp new file mode 100644 index 00000000000..9fde39c008d --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp new file mode 100644 index 00000000000..203ee321f66 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp new file mode 100644 index 00000000000..deb3dacffa0 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp new file mode 100644 index 00000000000..d243d468cbe --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Token.hpp b/modules/CIAO/CCF/CCF/IDL3/Token.hpp new file mode 100644 index 00000000000..4a18aae6f13 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal.hpp b/modules/CIAO/CCF/CCF/IDL3/Traversal.hpp new file mode 100644 index 00000000000..aa83bd51156 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp new file mode 100644 index 00000000000..1519650415c --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp new file mode 100644 index 00000000000..ebc0f79c704 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp new file mode 100644 index 00000000000..fc74e4c717b --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp new file mode 100644 index 00000000000..b92c5cf70fd --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp new file mode 100644 index 00000000000..941dfad76e6 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp new file mode 100644 index 00000000000..92c985c6176 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp new file mode 100644 index 00000000000..a6132394dc0 --- /dev/null +++ b/modules/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/modules/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp b/modules/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp new file mode 100644 index 00000000000..076bbab68c3 --- /dev/null +++ b/modules/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 |