diff options
author | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-07-29 21:02:57 +0000 |
---|---|---|
committer | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-07-29 21:02:57 +0000 |
commit | 8e74d5c4835d2697a751d14f34e8fce8dd2bb815 (patch) | |
tree | 91f29899344d7aa43f3fb4f19411a74d51b4f5ab | |
parent | ae9e3373f3b5f62634d2df1f13748cc29f42246b (diff) | |
download | ATCD-8e74d5c4835d2697a751d14f34e8fce8dd2bb815.tar.gz |
Initial revision
196 files changed, 20101 insertions, 0 deletions
diff --git a/TAO/CIAO/CCF/Bootstrap.rules b/TAO/CIAO/CCF/Bootstrap.rules new file mode 100644 index 00000000000..0f60a4c3cda --- /dev/null +++ b/TAO/CIAO/CCF/Bootstrap.rules @@ -0,0 +1,93 @@ +# file : Bootstrap.rules +# author : Boris Kolpackov <boris@kolpackov.net> +# cvs-id : $id$ + +# basics +# +# + +define set +$(eval $1 := $(strip $2)) +endef + +define get +$(value $(strip $1)) +endef + +define sub +$(shell echo $$(($1-$2))) +endef + +define add +$(shell echo $$(($1+$2))) +endef + +# stack +# +# + +define push +$(eval $1 +=$(strip $2)) +endef + +define pop +$(eval $1 :=$(wordlist 1,$(call sub, $(words $(value $(strip $1))), 1),$(value $(strip $1)))) +endef + +define top +$(word $(words $(value $(strip $1))),$(value $(strip $1))) +endef + +# local +# +# + +define path_to_id +$(subst /,_,$(subst .,_,$(strip $1))) +endef + +MAKEFILE := $(word $(call sub,$(words $(MAKEFILE_LIST)),1),$(MAKEFILE_LIST)) +INCLUSION_ID := $(call path_to_id,$(MAKEFILE)) + +define get_inclusion_id +$(INCLUSION_ID) +endef + +define local_set +$(eval $(strip $(call get_inclusion_id))_$1 := $(strip $2)) +endef + +define local_get +$($(strip $(call get_inclusion_id))_$1) +endef + +define local_origin +$(origin $(strip $(call get_inclusion_id))_$1) +endef + + +define _get_inclusion_count +$(if $(call local_get,INCLUSION_COUNT),$(call local_get,INCLUSION_COUNT),0) +endef + +define _set_inclusion_count +$(call local_set,INCLUSION_COUNT,$1) +endef + +# include +# +# + +define include +$(strip + $(eval $(call push, include_stack, $(MAKEFILE))) \ + $(eval MAKEFILE :=$(strip $1)) \ + $(eval $(call push, inclusion_id_stack, $(INCLUSION_ID))) \ + $(eval $(call _set_inclusion_count,$(call add,$(call _get_inclusion_count),1))) \ + $(eval INCLUSION_ID :=$(INCLUSION_ID)_$(call local_get,INCLUSION_COUNT)_$(call path_to_id,$1)) \ + $(eval include $1) \ + $(eval INCLUSION_ID :=$(call top, inclusion_id_stack)) \ + $(eval $(call pop, inclusion_id_stack)) \ + $(eval MAKEFILE :=$(call top, include_stack)) \ + $(eval $(call pop, include_stack))) +endef diff --git a/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..3fb305e6aa1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp @@ -0,0 +1,27 @@ +// file : CCF/CIDL/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace CIDL + { + LexicalAnalyzer:: + LexicalAnalyzer (TokenStream<char>& is) + : IDL2::LexicalAnalyzer (is), + IDL3::LexicalAnalyzer (is) + { + // Keywords (alphabetic order). + + keyword_table_.insert ("composition"); + keyword_table_.insert ("entity" ); + keyword_table_.insert ("executor" ); + keyword_table_.insert ("implements" ); + keyword_table_.insert ("process" ); + keyword_table_.insert ("service" ); + keyword_table_.insert ("session" ); + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp b/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..cbcaa9a84af --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.hpp @@ -0,0 +1,22 @@ +// file : CCF/CIDL/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_LEXICAL_ANALYZER_HPP +#define CCF_CIDL_LEXICAL_ANALYZER_HPP + +#include "CCF/IDL3/LexicalAnalyzer.hpp" + +namespace CCF +{ + namespace CIDL + { + class LexicalAnalyzer : public virtual IDL3::LexicalAnalyzer + { + public: + LexicalAnalyzer (TokenStream<char>& is); + }; + } +} + +#endif // CCF_CIDL_LEXICAL_ANALYZER_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/Makefile.alt new file mode 100644 index 00000000000..52d7722dafb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Makefile.alt @@ -0,0 +1,19 @@ +# file : CCF/CIDL/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := Makefile.archive +target_directory_list := SyntaxTree Traversal SemanticAction +default_makefile_name := Makefile.alt + +Makefile.archive : SyntaxTree Traversal SemanticAction + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/CCF/CIDL/Makefile.archive b/TAO/CIAO/CCF/CCF/CIDL/Makefile.archive new file mode 100644 index 00000000000..0fac4c23f8e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Makefile.archive @@ -0,0 +1,29 @@ +# file : CCF/CIDL/Makefile.archive +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.pre.rules) + +cxx_translation_units := LexicalAnalyzer.cpp Parser.cpp + +translated_units := SyntaxTree/Composition.o \ + SyntaxTree/HomeExecutor.o + +translated_units += Traversal/Composition.o \ + Traversal/HomeExecutor.o + +translated_units += SemanticAction/Composition.o + +module_base := CIDL +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.post.rules) diff --git a/TAO/CIAO/CCF/CCF/CIDL/Parser.cpp b/TAO/CIAO/CCF/CCF/CIDL/Parser.cpp new file mode 100644 index 00000000000..15da8627f44 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Parser.cpp @@ -0,0 +1,129 @@ +// file : CCF/CIDL/Parser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/Parser.hpp" + +// +// Note: DO NOT run emacs indenter (or any other indentation tool) over +// this file because it will most likely break BNF indentation. +// + +namespace CCF +{ + namespace CIDL + { + Parser:: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f) + : IDL2::Parser (context, dout, l, f), + IDL3::Parser (context, dout, l, f), + lexer_ (l), + actions_ (f), + + COMPOSITION ("composition"), + ENTITY ("entity" ), + EXECUTOR ("executor" ), + IMPLEMENTS ("implements" ), + PROCESS ("process" ), + SERVICE ("service" ), + SESSION ("session" ), + + // Composition + // + act_composition_begin ( + this, &Parser::act_composition_begin_core), + + act_composition_open_scope ( + f.composition (), &SemanticAction::Scope::open_scope), + + act_composition_close_scope ( + f.composition (), &SemanticAction::Scope::close_scope), + + act_composition_end ( + f.composition (), &SemanticAction::Composition::end), + + + // Home Executor + // + act_home_executor_begin ( + f.home_executor (), &SemanticAction::HomeExecutor::begin), + + act_home_executor_open_scope ( + f.home_executor (), &SemanticAction::Scope::open_scope), + + act_home_executor_implements ( + f.home_executor (), &SemanticAction::HomeExecutor::implements), + + act_home_executor_manages ( + f.home_executor (), &SemanticAction::HomeExecutor::manages), + + act_home_executor_close_scope ( + f.home_executor (), &SemanticAction::Scope::open_scope), + + act_home_executor_end ( + f.home_executor (), &SemanticAction::HomeExecutor::end) + + { + IDL3::Parser::extension = + composition_decl + | extension + ; + + // + // Composition + // + composition_decl = + composition_header + >> LBRACE[act_composition_open_scope] + >> home_executor_decl + >> RBRACE[act_composition_close_scope] + >> SEMI[act_composition_end] + ; + + composition_header = + COMPOSITION + >> (composition_category >> simple_identifier)[act_composition_begin] + ; + + composition_category = + ENTITY + | PROCESS + | SERVICE + | SESSION + ; + + // + // Home executor + // + home_executor_decl = + home_executor_header + >> LBRACE[act_home_executor_open_scope] + >> home_executor_home_impl_decl + >> home_executor_executor_decl + >> RBRACE[act_home_executor_close_scope] + >> SEMI[act_home_executor_end] + ; + + home_executor_header = + HOME + >> EXECUTOR + >> simple_identifier[act_home_executor_begin] + ; + + home_executor_home_impl_decl = + IMPLEMENTS + >> identifier[act_home_executor_implements] + >> SEMI + ; + + home_executor_executor_decl = + MANAGES + >> simple_identifier[act_home_executor_manages] + >> SEMI + ; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Parser.hpp b/TAO/CIAO/CCF/CCF/CIDL/Parser.hpp new file mode 100644 index 00000000000..ccc54ae51cf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Parser.hpp @@ -0,0 +1,132 @@ +// file : CCF/CIDL/Parser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_PARSER_HPP +#define CCF_CIDL_PARSER_HPP + +#include "CCF/CompilerElements/Context.hpp" + +#include "CCF/IDL3/Parser.hpp" + +#include "CCF/CIDL/LexicalAnalyzer.hpp" +#include "CCF/CIDL/SemanticAction.hpp" + +namespace CCF +{ + namespace CIDL + { + using IDL3::ActionExecutor; + using IDL3::NoArgAction; + using IDL3::OneArgAction; + using IDL3::TwoArgAction; + + class Parser : public virtual IDL3::Parser + { + protected: + LexicalAnalyzer const& lexer_; + SemanticAction::Factory& actions_; + + // + // Primitives (alphabetic order). + // + + KeywordParser COMPOSITION; + KeywordParser ENTITY; + KeywordParser EXECUTOR; + KeywordParser IMPLEMENTS; + KeywordParser PROCESS; + KeywordParser SERVICE; + KeywordParser SESSION; + + // + // Language + // + + Rule extension; + + // Composition + Rule composition_decl; + Rule composition_header; + Rule composition_category; + + // Home executor + Rule home_executor_decl; + Rule home_executor_header; + Rule home_executor_body; + Rule home_executor_home_impl_decl; + Rule home_executor_executor_decl; + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + protected: + void + act_composition_begin_core (Iterator begin, Iterator end) const + { + SemanticAction::Composition::Category::Value c; + + if((*begin)->lexeme () == "entity") + { + c = SemanticAction::Composition::Category::ENTITY; + } + else if ((*begin)->lexeme () == "process") + { + c = SemanticAction::Composition::Category::PROCESS; + } + else if ((*begin)->lexeme () == "service") + { + c = SemanticAction::Composition::Category::SERVICE; + } + else + { + c = SemanticAction::Composition::Category::SESSION; + } + + begin++; + + actions_.composition ().begin ( + ReferenceCounting::strict_cast<SimpleIdentifier> (*begin), c); + } + + // Composition + // + ActionExecutor<Parser> + act_composition_begin; + + ScopeAction + act_composition_open_scope; + + ScopeAction + act_composition_close_scope; + + NoArgAction<SemanticAction::Composition> + act_composition_end; + + // Home Executor + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_begin; + + ScopeAction + act_home_executor_open_scope; + + OneArgAction<IdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_implements; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_manages; + + ScopeAction + act_home_executor_close_scope; + + NoArgAction<SemanticAction::HomeExecutor> + act_home_executor_end; + }; + } +} + +#endif // CCF_CIDL_PARSER_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp new file mode 100644 index 00000000000..cb0a6db08dd --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp @@ -0,0 +1,26 @@ +// file : CCF/CIDL/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_HPP + +#include "CCF/IDL3/SemanticAction.hpp" + +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" + +#include "CCF/CIDL/SemanticAction/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + using namespace IDL3::SemanticAction; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp new file mode 100644 index 00000000000..039d60022f9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp @@ -0,0 +1,27 @@ +// file : CCF/CIDL/SemanticAction/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SemanticAction/Composition.hpp" + +#include <ostream> + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace + { + char* labels[] = {"entity", "process", "service", "session" }; + } + + std::ostream& + operator<< (std::ostream& o, Composition::Category::Value v) + { + return o << labels[v]; + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp new file mode 100644 index 00000000000..8c413208099 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp @@ -0,0 +1,48 @@ +// file : CCF/CIDL/SemanticAction/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +#include <iosfwd> + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + // + // + // + class Composition : public virtual Scope + { + public: + struct Category + { + enum Value + { + ENTITY = 0, + PROCESS, + SERVICE, + SESSION + }; + + friend std::ostream& + operator<< (std::ostream& o, Value v); + }; + + virtual void + begin (SimpleIdentifierPtr const& id, Category::Value category) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..6abc20b7e1b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Elements.hpp @@ -0,0 +1,23 @@ +// file : CCF/CIDL/SemanticAction/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +#include "CCF/CIDL/Token.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + using IDL3::SemanticAction::Scope; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..dd7ba59cee3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp @@ -0,0 +1,32 @@ +// file : CCF/CIDL/SemanticAction/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP +#define CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + // + // + // + class Factory : public virtual IDL3::SemanticAction::Factory + { + public: + virtual Composition& + composition () = 0; + + virtual HomeExecutor& + home_executor () = 0; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp new file mode 100644 index 00000000000..0c6c0b10ae9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/HomeExecutor.hpp @@ -0,0 +1,38 @@ +// file : CCF/CIDL/SemanticAction/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + // + // + // + class HomeExecutor : public virtual Scope + { + public: + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + implements (IdentifierPtr const& id) = 0; + + virtual void + manages (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_HOME_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp new file mode 100644 index 00000000000..1f0f7eb5fb8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp @@ -0,0 +1,19 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SemanticAction/Impl/Composition.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp new file mode 100644 index 00000000000..1dd83d8ed70 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp @@ -0,0 +1,94 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP + +#include "CCF/CIDL/SyntaxTree/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Composition : + public virtual SemanticAction::Composition, + public virtual ScopeBase<SyntaxTree::CompositionPtr> + { + public: + virtual + ~Composition () throw () {} + + Composition (bool trace, SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::CompositionPtr> (scope), + trace_ (trace) + { + } + + virtual void + begin (SimpleIdentifierPtr const& id, Category::Value c) + { + if (trace_) cerr << "composition " << c << " " << id << endl; + + SyntaxTree::SimpleName name (id->lexeme ()); + + SyntaxTree::Composition::Category::Value category = + SyntaxTree::Composition::Category::SESSION; + + if (c == Category::ENTITY) + { + category = SyntaxTree::Composition::Category::ENTITY; + } + else if (c == Category::PROCESS) + { + category = SyntaxTree::Composition::Category::PROCESS; + } + else if (c == Category::SERVICE) + { + category = SyntaxTree::Composition::Category::SERVICE; + } + + SyntaxTree::CompositionPtr cp ( + new SyntaxTree::Composition (name, category, scope_)); + + scope_->insert (cp); + push (cp); + } + + virtual void + open_scope () + { + scope_ = top (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + pop (); + if (trace_) cerr << "end" << endl; + } + + private: + bool trace_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..422d57f3ed9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,24 @@ +// file : CCF/CIDL/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using IDL3::SemanticAction::Impl::ScopeBase; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..1b32c0b14c1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,19 @@ +// file : CCF/CIDL/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..441f95b48a6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,65 @@ +// file : CCF/CIDL/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/CIDL/SemanticAction/Factory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +#include "CCF/CIDL/SemanticAction/Impl/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Factory : public virtual CIDL::SemanticAction::Factory, + public virtual IDL3::SemanticAction::Impl::Factory + { + public: + virtual + ~Factory () throw () {} + + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SyntaxTree::TranslationRegionPtr const& r) + : IDL2::SemanticAction::Impl::Factory (context, dout, r), + IDL3::SemanticAction::Impl::Factory (context, dout, r), + trace_ (context.get ("cidl::semantic-action::trace", false)), + composition_ (trace_, scope_), + home_executor_ (trace_, scope_) + { + } + public: + virtual SemanticAction::Composition& + composition () + { + return composition_; + } + + virtual SemanticAction::HomeExecutor& + home_executor () + { + return home_executor_; + } + + private: + bool trace_; + Composition composition_; + HomeExecutor home_executor_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp new file mode 100644 index 00000000000..a0cf40b7b8e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp @@ -0,0 +1,19 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp new file mode 100644 index 00000000000..8364f526cbb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp @@ -0,0 +1,161 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP + +#include "CCF/CIDL/SyntaxTree/HomeExecutor.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class HomeExecutor : + public virtual SemanticAction::HomeExecutor, + public virtual ScopeBase<SyntaxTree::HomeExecutorPtr> + { + public: + virtual + ~HomeExecutor () throw () {} + + HomeExecutor (bool trace, SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::HomeExecutorPtr> (scope), + trace_ (trace), + name_ (""), + implements_ (""), + manages_ ("") + + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "home executor " << id << endl; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + open_scope () + { + // Note: nothing is expected to go to home executor scope + // so watch for grammar changes. + } + + virtual void + implements (IdentifierPtr const& id) + { + if (trace_) cerr << "implements " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct ImplementsPredicate : public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + if (type != "home") throw IncompatibleType (type); + + return d->dynamic_type<TypeDecl> ()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + implements_ = sn; + } + catch (ImplementsPredicate::IncompatibleType const& e) + { + cerr << "error: invalid implements specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in home executor implements clause is illegal" + << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid implements specification" << endl; + cerr << "no home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid implements specification" << endl; + cerr << "no defined home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "implementing forward-declared home is illegal" + << endl; + } + + } + + virtual void + manages (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "manages " << id << endl; + manages_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + close_scope () + { + // Note: nothing is expected to go to home executor scope + // so watch for grammar changes. + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + + using namespace SyntaxTree; + + HomeExecutorPtr he (new SyntaxTree::HomeExecutor ( + name_, + scope_, + implements_, + manages_)); + scope_->insert (he); + } + private: + bool trace_; + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedName implements_; + SyntaxTree::SimpleName manages_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.alt new file mode 100644 index 00000000000..90017394a9f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.alt @@ -0,0 +1,18 @@ +# file : CCF/CIDL/SemanticAction/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := Composition.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree.hpp b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree.hpp new file mode 100644 index 00000000000..5a94d3fa045 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree.hpp @@ -0,0 +1,24 @@ +// file : CCF/CIDL/SyntaxTree.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SYNTAX_TREE_HPP +#define CCF_CIDL_SYNTAX_TREE_HPP + +#include "CCF/IDL3/SyntaxTree.hpp" + +#include "CCF/CIDL/SyntaxTree/Composition.hpp" +#include "CCF/CIDL/SyntaxTree/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SyntaxTree + { + using namespace IDL3::SyntaxTree; + } + } +} + +#endif // CCF_CIDL_SYNTAX_TREE_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.cpp new file mode 100644 index 00000000000..2ca82d8dd0d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.cpp @@ -0,0 +1,35 @@ +// file : CCF/CIDL/SyntaxTree/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SyntaxTree/Composition.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace CIDL + { + namespace SyntaxTree + { + // Composition + // + // + namespace + { + TypeInfo + composition_init_ () + { + TypeInfo ti (typeid (Composition)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo composition_ (composition_init_ ()); + } + + TypeInfo const& Composition:: + static_type_info () { return composition_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.hpp new file mode 100644 index 00000000000..4202753137d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Composition.hpp @@ -0,0 +1,93 @@ +// file : CCF/CIDL/SyntaxTree/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SYNTAX_TREE_COMPOSITION_HPP +#define CCF_CIDL_SYNTAX_TREE_COMPOSITION_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SyntaxTree + { + using namespace IDL2::SyntaxTree; + + // + // + // + class Composition : public virtual Scope + { + public: + struct Category + { + enum Value + { + ENTITY, + PROCESS, + SERVICE, + SESSION + }; + + friend std::ostream& + operator<< (std::ostream& o, Value v) + { + if (v == ENTITY) o << "entity"; + else if (v == PROCESS) o << "process"; + else if (v == SERVICE) o << "service"; + else o << "session"; + return o; + } + }; + + public: + virtual + ~Composition () throw () {} + + Composition (SimpleName const& name, + Category::Value category, + ScopePtr const& scope) + : Declaration (name, scope), + Scope (name, scope), + category_ (category) + { + type_info (static_type_info ()); + } + + public: + Category::Value + category () const + { + return category_; + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "composition"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + Category::Value category_; + }; + + typedef + StrictPtr<Composition> + CompositionPtr; + + typedef + DeclarationOrderComparator<CompositionPtr> + CompositionOrderComparator; + } + } +} + +#endif // CCF_CIDL_SYNTAX_TREE_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.cpp b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.cpp new file mode 100644 index 00000000000..3e064402df8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.cpp @@ -0,0 +1,35 @@ +// file : CCF/CIDL/SyntaxTree/HomeExecutor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/SyntaxTree/HomeExecutor.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace CIDL + { + namespace SyntaxTree + { + // HomeExecutor + // + // + namespace + { + TypeInfo + home_executor_init_ () + { + TypeInfo ti (typeid (HomeExecutor)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo home_executor_ (home_executor_init_ ()); + } + + TypeInfo const& HomeExecutor:: + static_type_info () { return home_executor_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.hpp b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.hpp new file mode 100644 index 00000000000..dd0048bb953 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/HomeExecutor.hpp @@ -0,0 +1,77 @@ +// file : CCF/CIDL/SyntaxTree/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_SYNTAX_TREE_HOME_EXECUTOR_HPP +#define CCF_CIDL_SYNTAX_TREE_HOME_EXECUTOR_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" +#include "CCF/IDL3/SyntaxTree/Home.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SyntaxTree + { + using namespace IDL3::SyntaxTree; + + // + // + // + class HomeExecutor : public virtual Scope + { + public: + virtual + ~HomeExecutor () throw () {} + + HomeExecutor (SimpleName const& name, + ScopePtr const& scope, + ScopedName implements, + SimpleName manages) + : Declaration (name, scope), + Scope (name, scope), + implements_ (scope->table (), implements), + manages_ (manages) + { + type_info (static_type_info ()); + } + + public: + HomeDefPtr + implements () const + { + return implements_.resolve (); + } + + SimpleName + manages () const + { + return manages_; + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "home executor"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + HomeDefRef implements_; + SimpleName manages_; + }; + + typedef + StrictPtr<HomeExecutor> + HomeExecutorPtr; + } + } +} + +#endif // CCF_CIDL_SYNTAX_TREE_HOME_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Makefile.alt new file mode 100644 index 00000000000..b41f935d72a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SyntaxTree/Makefile.alt @@ -0,0 +1,18 @@ +# file : CCF/CIDL/SyntaxTree/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := Composition.cpp HomeExecutor.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/CIDL/Token.hpp b/TAO/CIAO/CCF/CCF/CIDL/Token.hpp new file mode 100644 index 00000000000..368511ec670 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Token.hpp @@ -0,0 +1,34 @@ +// file : CCF/CIDL/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_TOKEN_HPP +#define CCF_CIDL_TOKEN_HPP + +#include "CCF/IDL3/Token.hpp" + +namespace CCF +{ + namespace CIDL + { + using IDL3::Token; + using IDL3::TokenPtr; + using IDL3::TokenList; + using IDL3::EndOfStream; + using IDL3::EndOfStreamPtr; + using IDL3::Keyword; + using IDL3::KeywordPtr; + using IDL3::Punctuation; + using IDL3::PunctuationPtr; + using IDL3::Identifier; + using IDL3::IdentifierPtr; + using IDL3::SimpleIdentifier; + using IDL3::SimpleIdentifierPtr; + using IDL3::ScopedIdentifier; + using IDL3::ScopedIdentifierPtr; + using IDL3::StringLiteral; + using IDL3::StringLiteralPtr; + } +} + +#endif // CCF_CIDL_TOKEN_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal.hpp new file mode 100644 index 00000000000..7e58168fce9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal.hpp @@ -0,0 +1,24 @@ +// file : CCF/CIDL/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_TRAVERSAL_HPP +#define CCF_CIDL_TRAVERSAL_HPP + +#include "CCF/IDL3/Traversal.hpp" + +#include "CCF/CIDL/Traversal/Composition.hpp" +#include "CCF/CIDL/Traversal/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + using namespace IDL3::Traversal; + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.cpp new file mode 100644 index 00000000000..d204c31f177 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.cpp @@ -0,0 +1,44 @@ +// file : CCF/CIDL/Traversal/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/Traversal/Composition.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // Composition + // + // + void Composition:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void Composition:: + pre (NodePtr const&) + { + } + + void Composition:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void Composition:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp new file mode 100644 index 00000000000..dcc1b8d70db --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp @@ -0,0 +1,53 @@ +// file : CCF/CIDL/Traversal/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_TRAVERSAL_COMPOSITION_HPP +#define CCF_CIDL_TRAVERSAL_COMPOSITION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/CIDL/SyntaxTree/Composition.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // + // + // + struct Composition : IDL2::Traversal::ScopeTraverser + { + typedef + SyntaxTree::CompositionPtr + NodePtr; + + Composition () + { + map (typeid (SyntaxTree::Composition), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Composition> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.cpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.cpp new file mode 100644 index 00000000000..9919c1a9fd6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.cpp @@ -0,0 +1,44 @@ +// file : CCF/CIDL/Traversal/HomeExecutor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CIDL/Traversal/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // HomeExecutor + // + // + void HomeExecutor:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void HomeExecutor:: + pre (NodePtr const&) + { + } + + void HomeExecutor:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void HomeExecutor:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.hpp new file mode 100644 index 00000000000..04423678250 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/HomeExecutor.hpp @@ -0,0 +1,55 @@ +// file : CCF/CIDL/Traversal/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_CIDL_TRAVERSAL_HOME_EXECUTOR_HPP +#define CCF_CIDL_TRAVERSAL_HOME_EXECUTOR_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/CIDL/SyntaxTree/HomeExecutor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // + // + // + struct HomeExecutor : IDL2::Traversal::ScopeTraverser + { + typedef + SyntaxTree::HomeExecutorPtr + NodePtr; + + HomeExecutor () + { + map (typeid (SyntaxTree::HomeExecutor), this); + } + + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::HomeExecutor> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + + }; + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_HOME_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt new file mode 100644 index 00000000000..1955bc0e988 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt @@ -0,0 +1,22 @@ +# file : CCF/CIDL/Traversal/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := Composition.cpp HomeExecutor.cpp + +CXX_PREPROCESS_FLAGS += -I../../.. \ + -I../../../External/Utility \ + -I../../../External/boost \ + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) + diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp new file mode 100644 index 00000000000..a83acf84d52 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp @@ -0,0 +1,56 @@ +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER +#define CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER + +#include "CCF/CompilerElements/ExH.hpp" + +#include <string> + +namespace Indentation +{ + class Buffer + { + public: + class Exception_ {}; + typedef + ExH::Compound <Exception_, ExH::Logic::DescriptiveException> + Exception; + + class EndOfStream_ {}; + typedef + ExH::Compound <EndOfStream_, Exception> + EndOfStream; + + public: + virtual + ~Buffer () throw () {} + + public: + typedef + std::char_traits<char> + traits_type; + + typedef + traits_type::char_type + char_type; + + typedef + traits_type::char_type + int_type; + + public: + virtual int_type + put (char_type c) throw (Exception, ExH::System::Exception) = 0; + + // Unbuffer flushes internal formatting buffers (if any). + // Note that unbuffer is not exactly flushing since it can + // result in formatting errors and in general can not be + // called at arbitrary points. Natural use case would be + // to call unbuffer at the end of the stream when no more + // data is expected. + // + virtual void + unbuffer () throw (EndOfStream, Exception, ExH::System::Exception) = 0; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp new file mode 100644 index 00000000000..cc77cac30de --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp @@ -0,0 +1,215 @@ +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IDL +#define CCF_CODE_GENERATION_KIT_INDENTATION_IDL + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + class IDL : public Buffer + { + public: + IDL (Buffer& out) + : out_ (out), + indentation_ (0), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~IDL () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + bool defaulting = false; + switch (c) + { + case '\n': + { + hold_.push_back (c); + break; + } + case '{': + { + ensure_new_line (); + output_indentation (); + result = write (c); + ensure_new_line (); + indentation_++; + break; + } + case '}': + { + if (indentation_ > 0) indentation_--; + + // Reduce multiple newlines to one. + while (hold_.size () > 1) + { + Hold::reverse_iterator i = hold_.rbegin (); + if (*i == '\n' && *(i + 1) == '\n') hold_.pop_back (); + else break; + } + + ensure_new_line (); + output_indentation (); + result = write (c); + break; + } + case ';': + { + output_indentation (); + result = write (c); + + if (construct_ != STRING_LITERAL && construct_ != CHAR_LITERAL) + { + ensure_new_line (); + } + break; + } + case '\\': + { + hold_.push_back (c); + break; + } + case '\"': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == STRING_LITERAL) construct_ = OTHER; + else construct_ = STRING_LITERAL; + } + + defaulting = true; + break; + } + case '\'': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == CHAR_LITERAL) construct_ = OTHER; + else construct_ = CHAR_LITERAL; + } + + defaulting = true; + break; + } + default: + { + defaulting = true; + break; + } + } + + if (defaulting) + { + output_indentation (); + result = write (c); + } + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + int_type result; + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + //@@ failed + if (result == traits_type::eof ()) + { + throw EndOfStream ("unable to flush buffer"); + } + + hold_.pop_front (); + } + } + + private: + class Full {}; + + void + ensure_new_line () + { + if (hold_.empty () || hold_.back () != '\n') + { + hold_.push_back ('\n'); + } + } + + + void + output_indentation () throw (Full) + { + if (!hold_.empty () && hold_.back () == '\n') + { + for (unsigned long i = 0; i < indentation_ * spaces_; i++) + { + write (' '); + } + } + } + + int_type + write (char_type c) throw (Full) + { + hold_.push_back (c); + + int_type result; + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer& out_; + unsigned long indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp new file mode 100644 index 00000000000..2688396360e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp @@ -0,0 +1,117 @@ +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER +#define CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER + +#include <ostream> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + class ToStreamBufAdapter : public std::streambuf + { + public: + ToStreamBufAdapter (Buffer& buffer) + : buffer_ (buffer) + { + } + + virtual int_type + overflow (int_type c) + { + return buffer_.put (Buffer::traits_type::to_char_type (c)); + } + + virtual int + sync () + { + return 0; + } + + private: + Buffer& buffer_; + }; + + class FromStreamBufAdapter : public Buffer + { + public: + FromStreamBufAdapter (std::streambuf& buffer) + : buffer_ (buffer) + { + } + + virtual int_type + put (char_type c) throw (Exception, ExH::System::Exception) + { + return buffer_.sputc (traits_type::to_int_type (c)); + } + + virtual void + unbuffer () throw (ExH::System::Exception) + { + try + { + if (buffer_.pubsync () == 0) return; + } + catch (std::ios_base::failure const&) + { + } + + throw Exception ("underlying std::streambuf::sync failed"); + } + + private: + std::streambuf& buffer_; + }; + + template <typename Buffer> + class Implanter + { + public: + Implanter (std::ostream& os) + : os_ (os), + prev_ (os_.rdbuf ()), + from_adapter_ (*prev_), + buffer_ (from_adapter_), + to_adapter_ (buffer_) + { + os_.rdbuf (&to_adapter_); + } + + template <typename Arg0> + Implanter (std::ostream& os, Arg0 a0) + : os_ (os), + prev_ (os_.rdbuf ()), + from_adapter_ (*prev_), + buffer_ (from_adapter_, a0), + to_adapter_ (buffer_) + { + os_.rdbuf (&to_adapter_); + } + + ~Implanter () + { + try + { + buffer_.unbuffer (); + } + catch (...) + { + // there is nothing I can do... + } + + os_.rdbuf (prev_); + } + + private: + std::ostream& os_; + std::streambuf* prev_; + + FromStreamBufAdapter from_adapter_; + + Buffer buffer_; + + ToStreamBufAdapter to_adapter_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/Makefile.alt b/TAO/CIAO/CCF/CCF/CodeGenerationKit/Makefile.alt new file mode 100644 index 00000000000..b0f54b4420e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/Makefile.alt @@ -0,0 +1,23 @@ +# file : CCF/CodeGenerationKit/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.pre.rules) + +cxx_translation_units := CommandLine.cpp \ + CommandLineGrammar.cpp \ + CommandLineParser.cpp + +module_base := CodeGenerationKit +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.post.rules) diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp new file mode 100644 index 00000000000..42679278ae2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp @@ -0,0 +1,96 @@ +// file : CCF/CompilerElements/Context.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_COMPILER_ELEMENTS_CONTEXT_HPP +#define CCF_COMPILER_ELEMENTS_CONTEXT_HPP + +#include <map> +#include <string> +#include <Utility/Hetero/Container.hpp> + +namespace CCF +{ + namespace CompilerElements + { + class Context + { + public: + Context () + { + } + + public: + class NotFound {}; + class Typing {}; + + template <typename T> + T const& + get (std::string key) const throw (NotFound, Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) throw NotFound (); + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + + } + + template <typename T> + T const& + get (std::string key, T const& def) const throw (Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) return def; + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + template <typename T> + void + set (std::string key, T const& value) throw (Typing) + { + try + { + if (!map_.insert (std::pair<std::string, + Utility::Hetero::Container>(key, value)).second) + { + Map::iterator i = map_.find (key); + i->second.template value <T> () = value; + } + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + private: + typedef + std::map<std::string, Utility::Hetero::Container> + Map; + + Map map_; + + private: + // Copy semanic is not supported. + Context (Context const&) throw (); + Context& operator= (Context const&) throw (); + }; + } +} + +#endif // CCF_COMPILER_ELEMENTS_CONTEXT_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.cpp b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.cpp new file mode 100644 index 00000000000..ac49d1c74ae --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.cpp @@ -0,0 +1,47 @@ +// file : CCF/Runtime/DiagnosticStream.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ +// cvs-id : $Id$ + +#include "CCF/Runtime/DiagnosticStream.hpp" + +#include <iostream> + +namespace CCF +{ + /* + namespace Diagnostic + { + Stream dout; + + // + // class Message + // + + Message::~Message () throw () + { + } + + // + // class Stream + // + + Stream::Stream () throw () + { + } + + + Stream::~Stream () throw () + { + } + + Stream& + Stream:: operator << (Message const& msg) + throw (ExH::System::Exception) + { + std::cerr << msg.text () << std::endl; + return *this; + } + } + */ +} diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp new file mode 100644 index 00000000000..6253d61a6df --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp @@ -0,0 +1,191 @@ +// file : CCF/CompilerElements/Diagnostic.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ +// cvs-id : $Id$ + +#ifndef CCF_DIAGNOSTIC_HPP +#define CCF_DIAGNOSTIC_HPP + +#include <string> +#include <sstream> +#include <iostream> + +#include "CCF/CompilerElements/ExH.hpp" + +namespace Diagnostic +{ + // + // + // + class Record : public std::ostringstream + { + public: + + struct Type + { + enum Value + { + INFO, + WARNING, + ERROR + }; + }; + + Record (Type::Value type, + std::string file, + unsigned long line, + std::string description = "") + : std::ostringstream (description), + type_ (type), + file_ (file), + line_ (line) + { + } + + public: + + Type::Value + type () const + { + return type_; + } + + std::string + file () const + { + return file_; + } + + unsigned long line () const + { + return line_; + } + + std::string + description () const + { + return str (); + } + + private: + Type::Value type_; + std::string file_; + unsigned long line_; + }; + + + // + // + // + struct Info : public Record + { + Info (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::INFO, file, line, description) + { + } + }; + + + // + // + // + struct Warning : public Record + { + Warning (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::WARNING, file, line, description) + { + } + }; + + + // + // + // + struct Error : public Record + { + Error (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::ERROR, file, line, description) + { + } + }; + + + // + // + // + class Stream + { + public: + + Stream () + : info_count_ (0), + warning_count_ (0), + error_count_ (0) + { + } + + + Stream& + operator<< (Record const& msg) + { + std::cout << msg.file () << ":" << msg.line () << ": " + << msg.description () << std::endl; + + switch (msg.type ()) + { + case Record::Type::INFO: + { + info_count_++; + break; + } + case Record::Type::WARNING: + { + warning_count_++; + } + case Record::Type::ERROR: + { + error_count_++; + } + } + + return *this; + } + + public: + unsigned long + info_count () + { + return info_count_; + } + + unsigned long + warning_coun () + { + return warning_count_; + } + + unsigned long + error_count () + { + return error_count_; + } + + private: + unsigned long info_count_; + unsigned long warning_count_; + unsigned long error_count_; + + private: + // Copy semanic is not supported. + Stream (Stream const&) throw (); + Stream& operator= (Stream const&) throw (); + }; +} + +#endif // CCF_DIAGNOSTIC_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.cpp b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.cpp new file mode 100644 index 00000000000..63be8349d89 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.cpp @@ -0,0 +1,26 @@ +// file : CCF/CompilerElements/Introspection.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +// +// This is a hack to avoid link dependency on Utility library. +// + +#include "Utility/Introspection/Object.hpp" + +namespace Utility +{ + namespace Introspection + { + namespace + { + TypeInfo object_ (typeid (Object)); + } + + TypeInfo const& Object:: + static_type_info () throw () + { + return object_; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.d b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.d new file mode 100644 index 00000000000..443bd465b55 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.d @@ -0,0 +1,272 @@ +Introspection.d Introspection.o: Introspection.cpp \ + ../../External/Utility/Utility/Introspection/Object.hpp \ + ../../External/Utility/Utility/Introspection/TypeInfo.hpp \ + /usr/local/include/c++/3.3/vector \ + /usr/local/include/c++/3.3/bits/functexcept.h \ + /usr/local/include/c++/3.3/exception_defines.h \ + /usr/local/include/c++/3.3/bits/stl_algobase.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++config.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/local/include/c++/3.3/cstring \ + /usr/local/include/c++/3.3/cstddef \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/local/include/c++/3.3/climits \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/limits.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/local/include/c++/3.3/cstdlib \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/local/include/c++/3.3/new /usr/local/include/c++/3.3/exception \ + /usr/local/include/c++/3.3/iosfwd \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++locale.h \ + /usr/local/include/c++/3.3/clocale /usr/include/locale.h \ + /usr/include/bits/locale.h /usr/local/include/c++/3.3/cctype \ + /usr/include/ctype.h /usr/local/include/c++/3.3/bits/stringfwd.h \ + /usr/local/include/c++/3.3/bits/fpos.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++io.h \ + /usr/local/include/c++/3.3/cstdio \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stdarg.h \ + /usr/include/bits/sys_errlist.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/gthr.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/signal.h \ + /usr/include/bits/initspin.h /usr/include/bits/sigthread.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/environments.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/local/include/c++/3.3/cwchar \ + /usr/local/include/c++/3.3/ctime \ + /usr/local/include/c++/3.3/bits/stl_pair.h \ + /usr/local/include/c++/3.3/bits/type_traits.h \ + /usr/local/include/c++/3.3/bits/stl_iterator_base_types.h \ + /usr/local/include/c++/3.3/bits/stl_iterator_base_funcs.h \ + /usr/local/include/c++/3.3/bits/concept_check.h \ + /usr/local/include/c++/3.3/bits/stl_iterator.h \ + /usr/local/include/c++/3.3/bits/stl_alloc.h \ + /usr/local/include/c++/3.3/bits/stl_threads.h \ + /usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/atomicity.h \ + /usr/local/include/c++/3.3/bits/stl_construct.h \ + /usr/local/include/c++/3.3/bits/stl_uninitialized.h \ + /usr/local/include/c++/3.3/bits/stl_vector.h \ + /usr/local/include/c++/3.3/bits/stl_bvector.h \ + /usr/local/include/c++/3.3/bits/vector.tcc \ + ../../External/Utility/Utility/Introspection/TypeId.hpp \ + /usr/local/include/c++/3.3/typeinfo \ + ../../External/Utility/Utility/Introspection/TypeId.tpp \ + ../../External/Utility/Utility/Introspection/TypeId.ipp \ + ../../External/Utility/Utility/Introspection/TypeInfo.ipp \ + ../../External/Utility/Utility/Introspection/Object.ipp + +../../External/Utility/Utility/Introspection/Object.hpp: + +../../External/Utility/Utility/Introspection/TypeInfo.hpp: + +/usr/local/include/c++/3.3/vector: + +/usr/local/include/c++/3.3/bits/functexcept.h: + +/usr/local/include/c++/3.3/exception_defines.h: + +/usr/local/include/c++/3.3/bits/stl_algobase.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++config.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/gnu/stubs.h: + +/usr/local/include/c++/3.3/cstring: + +/usr/local/include/c++/3.3/cstddef: + +/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stddef.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/local/include/c++/3.3/climits: + +/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/limits.h: + +/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/local/include/c++/3.3/cstdlib: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/wordsize.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/bits/sched.h: + +/usr/include/alloca.h: + +/usr/local/include/c++/3.3/new: + +/usr/local/include/c++/3.3/exception: + +/usr/local/include/c++/3.3/iosfwd: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++locale.h: + +/usr/local/include/c++/3.3/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/local/include/c++/3.3/cctype: + +/usr/include/ctype.h: + +/usr/local/include/c++/3.3/bits/stringfwd.h: + +/usr/local/include/c++/3.3/bits/fpos.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/c++io.h: + +/usr/local/include/c++/3.3/cstdio: + +/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/include/bits/wchar.h: + +/usr/include/gconv.h: + +/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/include/stdarg.h: + +/usr/include/bits/sys_errlist.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/gthr.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/initspin.h: + +/usr/include/bits/sigthread.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/local/include/c++/3.3/cwchar: + +/usr/local/include/c++/3.3/ctime: + +/usr/local/include/c++/3.3/bits/stl_pair.h: + +/usr/local/include/c++/3.3/bits/type_traits.h: + +/usr/local/include/c++/3.3/bits/stl_iterator_base_types.h: + +/usr/local/include/c++/3.3/bits/stl_iterator_base_funcs.h: + +/usr/local/include/c++/3.3/bits/concept_check.h: + +/usr/local/include/c++/3.3/bits/stl_iterator.h: + +/usr/local/include/c++/3.3/bits/stl_alloc.h: + +/usr/local/include/c++/3.3/bits/stl_threads.h: + +/usr/local/include/c++/3.3/i686-pc-linux-gnu/bits/atomicity.h: + +/usr/local/include/c++/3.3/bits/stl_construct.h: + +/usr/local/include/c++/3.3/bits/stl_uninitialized.h: + +/usr/local/include/c++/3.3/bits/stl_vector.h: + +/usr/local/include/c++/3.3/bits/stl_bvector.h: + +/usr/local/include/c++/3.3/bits/vector.tcc: + +../../External/Utility/Utility/Introspection/TypeId.hpp: + +/usr/local/include/c++/3.3/typeinfo: + +../../External/Utility/Utility/Introspection/TypeId.tpp: + +../../External/Utility/Utility/Introspection/TypeId.ipp: + +../../External/Utility/Utility/Introspection/TypeInfo.ipp: + +../../External/Utility/Utility/Introspection/Object.ipp: diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.hpp new file mode 100644 index 00000000000..293e6d2dff9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.hpp @@ -0,0 +1,13 @@ +// file : CCF/CompilerElements/Introspection.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_INTROSPECTION_HPP +#define CCF_RUNTIME_INTROSPECTION_HPP + +#include "Utility/Introspection/Introspection.hpp" + +namespace Introspection = Utility::Introspection; + +#endif // CCF_RUNTIME_INTROSPECTION_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Makefile.alt b/TAO/CIAO/CCF/CCF/CompilerElements/Makefile.alt new file mode 100644 index 00000000000..af1fe95fa10 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Makefile.alt @@ -0,0 +1,21 @@ +# file : CCF/CompilerElements/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.pre.rules) + +cxx_translation_units := Introspection.cpp + +module_base := CompilerElements +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..96b004ab030 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp @@ -0,0 +1,362 @@ +// file : CCF/IDL2/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +#include <iostream> + +namespace CCF +{ + namespace IDL2 + { + LexicalAnalyzer:: + LexicalAnalyzer (TokenStream<char>& is) + : loc_ ("C"), + is_ (is), + after_nl (true), + line_ (0) + { + // Keywords (alphabetic order). + + keyword_table_.insert ("abstract" ); + keyword_table_.insert ("attribute"); + keyword_table_.insert ("factory" ); + keyword_table_.insert ("in" ); + keyword_table_.insert ("include" ); + keyword_table_.insert ("inout" ); + keyword_table_.insert ("interface"); + keyword_table_.insert ("local" ); + keyword_table_.insert ("module" ); + keyword_table_.insert ("out" ); + keyword_table_.insert ("sinclude" ); + keyword_table_.insert ("supports" ); + + punctuation_table_.insert (":"); + punctuation_table_.insert (","); + punctuation_table_.insert ("{"); + punctuation_table_.insert ("}"); + punctuation_table_.insert ("("); + punctuation_table_.insert (")"); + punctuation_table_.insert (";"); + } + + + LexicalAnalyzer::int_type LexicalAnalyzer:: + get () + { + int_type i; + + if (buffer_.empty ()) + { + i = is_.next (); + } + else + { + i = buffer_.front (); + buffer_.pop_front (); + } + + if (after_nl) + { + after_nl = false; + line_++; + } + + if (i == '\n') + { + after_nl = true; + } + + return i; + } + + LexicalAnalyzer::int_type LexicalAnalyzer:: + peek () + { + int_type i; + + if (buffer_.empty ()) + { + i = is_.next (); + buffer_.push_back (i); + } + else + { + i = buffer_.front (); + } + + return i; + } + + LexicalAnalyzer::int_type LexicalAnalyzer:: + peek_more () + { + int_type i; + + if (buffer_.size () < 2) + { + i = is_.next (); + buffer_.push_back (i); + } + else + { + i = buffer_.at (1); + } + + return i; + } + + LexicalAnalyzer::char_type LexicalAnalyzer:: + to_char_type (int_type i) + { + return is_.to_char_type (i); + } + + + TokenPtr LexicalAnalyzer:: + next () + { + while (true) + { + int_type i = get (); + + if (is_.eos(i)) + { + return TokenPtr (new EndOfStream (line_)); + } + + char_type c = to_char_type (i); + + // Handling spaces + if (std::isspace (c, loc_)) continue; + + // Handling C++ comments + if (c == '/' && peek () == '/') + { + cxx_comment (c); + continue; + } + + // Handling C comments + if (c == '/' && peek () == '*') + { + c_comment (c); + continue; + } + + if (std::isalpha (c, loc_) || c == '_' || (c == ':' && peek () == ':')) + { + return identifier (c); + } + + TokenPtr token; + + if (string_literal (c, token)) return token; + + if (punctuation (c, token)) return token; + + + std::cerr << line_ << ": error: unable to derive any token from \'" + << c << "\'" << std::endl; + + //@@ I should return something special here. Perhaps error recovery + // should happen. + return TokenPtr (new EndOfStream (line_)); + } + } + + void LexicalAnalyzer:: + cxx_comment (char_type c) + { + while (c != '\n') + { + int_type i = get (); + + if (is_.eos (i)) + { + std::cerr << "warning: no new line at the end of file" << std::endl; + + //@@ I wonder if it's ok to call get () again after getting eof. + //@@ no, it's not: std::istream throws exception (when enabled) on + // second attempt. + break; + } + c = to_char_type (i); + } + } + + void LexicalAnalyzer:: + c_comment (char_type c) + { + get (); // get '*' + + do + { + int_type i = get (); + + if (is_.eos (i)) + { + std::cerr << "error: end of file before C-style comment finished" + << std::endl; + return; + + //@@ I wonder if it's ok to call get () again after getting eof. + } + c = to_char_type (i); + + //std::cerr << "lexer: c_comment: read character \'" << c << "\'" + // << std::endl; + } + while (c != '*' || peek () != '/'); + + //std::cerr << "lexer: c_comment: finished C-comment \'" << c + // << "\',\'" << to_char_type (peek ()) + // << "\'" << std::endl; + + get (); // get '/' + } + + TokenPtr LexicalAnalyzer:: + identifier (char_type c) + { + std::string lexeme; + + enum + { + SIMPLE, + SCOPED, + OTHER + } type = SIMPLE; + + if (c == ':') + { + get (); + lexeme = "::"; + type = SCOPED; + } + else + { + lexeme += c; + } + + while (true) + { + int_type i = peek (); + + if (is_.eos (i)) + { + std::cerr << "warning: no new line at the end of file" << std::endl; + break; + } + + c = to_char_type (i); + + //std::cerr << "lexer::identifier: peeking on \'" << c + // << "\'; current lexeme \'" << lexeme << "\'" + // << std::endl; + + if (std::isalnum (c, loc_) || c == '_') + { + get (); + lexeme += c; + continue; + } + + if (c == ':' && peek_more () == ':') + { + get (); + get (); + lexeme += "::"; + if (type == SIMPLE) type = OTHER; + continue; + } + + break; + } + + //std::cerr << "lexer: found identifier with lexeme \'" + // << lexeme << "\'" << std::endl; + + if (type == SIMPLE) + { + KeywordTable::const_iterator i = keyword_table_.find (lexeme); + + if (i != keyword_table_.end ()) + { + return TokenPtr (new Keyword (*i, line_)); + } + else + { + return TokenPtr (new SimpleIdentifier (lexeme, line_)); + } + + + // otherwise deafult to Identifier + } + else if (type == SCOPED) + { + return TokenPtr (new ScopedIdentifier (lexeme, line_)); + } + else //type == OTHER + { + return TokenPtr (new Identifier (lexeme, line_)); + } + } + + bool LexicalAnalyzer:: + punctuation (char_type c, TokenPtr& token) + { + PunctuationTable::const_iterator i = punctuation_table_.begin (); + + while (true) + { + for (;i != punctuation_table_.end () && (*i)[0] != c; i++); + + if (i == punctuation_table_.end ()) return false; + + // if it's a two-character punctuation + if (i->size () == 2) + { + if ((*i)[1] != peek ()) + { + // move on to the next candidate + i++; + continue; + } + } + + token = TokenPtr (new Punctuation (*i, line_));; + return true; + } + } + + bool LexicalAnalyzer:: + string_literal (char_type c, TokenPtr& token) + { + if (c != '\"') return false; + + std::string lexeme; + + while (true) + { + int_type i = get (); + + if (is_.eos (i)) + { + std::cerr << "warning: end of file while reading string literal" + << std::endl; + break; + } + + c = to_char_type (i); + + if (c == '\"') break; + else lexeme += c; + } + + token = TokenPtr (new StringLiteral (lexeme, line_)); + return true; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..c335453a595 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp @@ -0,0 +1,106 @@ +// file : CCF/IDL2/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_LEXICAL_ANALYZER_HPP +#define CCF_IDL2_LEXICAL_ANALYZER_HPP + +#include <set> +#include <deque> +#include <locale> +#include <cctype> +#include <string> +#include <istream> + +#include "CCF/CompilerElements/TokenStream.hpp" + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + //@@ Call to get() after eof is illegal. + // + // + + class LexicalAnalyzer : public TokenStream<TokenPtr> + { + public: + virtual + ~LexicalAnalyzer () throw () {} + + public: + LexicalAnalyzer (TokenStream<char>& is); + + virtual TokenPtr + next (); + + protected: + typedef + TokenStream<char>::int_type + int_type; + + typedef + TokenStream<char>::char_type + char_type; + + typedef + TokenStream<char>::traits + traits; + + protected: + virtual int_type + get (); + + virtual int_type + peek (); + + virtual int_type + peek_more (); + + char_type + to_char_type (int_type i); + + virtual void + cxx_comment (char_type c); + + virtual void + c_comment (char_type c); + + virtual TokenPtr + identifier (char_type c); + + virtual bool + string_literal (char_type c, TokenPtr& token); + + virtual bool + punctuation (char_type c, TokenPtr& token); + + protected: + typedef + std::set<std::string> + KeywordTable; + + typedef + std::set<std::string> + PunctuationTable; + + std::locale loc_; + + TokenStream<char>& is_; + + KeywordTable keyword_table_; + PunctuationTable punctuation_table_; + + // line numbering mechanism + bool after_nl; + unsigned long line_; + + // look ahead mechanism + std::deque<int_type> buffer_; + }; + } +} + +#endif // CCF_IDL2_LEXICAL_ANALYZER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/Makefile.alt new file mode 100644 index 00000000000..cbe28cdb132 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Makefile.alt @@ -0,0 +1,19 @@ +# file : CCF/IDL2/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := Makefile.archive +target_directory_list := SyntaxTree Traversal SemanticAction +default_makefile_name := Makefile.alt + +Makefile.archive : SyntaxTree Traversal SemanticAction + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/Makefile.archive b/TAO/CIAO/CCF/CCF/IDL2/Makefile.archive new file mode 100644 index 00000000000..134bf747408 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Makefile.archive @@ -0,0 +1,40 @@ +# file : CCF/IDL2/Makefile.archive +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.pre.rules) + + +cxx_translation_units := LexicalAnalyzer.cpp Parser.cpp + + +translated_units := SyntaxTree/BuiltIn.o \ + SyntaxTree/Elements.o \ + SyntaxTree/Interface.o \ + SyntaxTree/Module.o \ + SyntaxTree/Operation.o \ + SyntaxTree/Translation.o \ + SyntaxTree/ValueType.o + +translated_units += Traversal/BuiltIn.o \ + Traversal/Elements.o \ + Traversal/Interface.o \ + Traversal/Module.o \ + Traversal/Operation.o \ + Traversal/Translation.o + +translated_units += SemanticAction/Operation.o + +module_base := IDL2 +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp b/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp new file mode 100644 index 00000000000..e0fa5534c55 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp @@ -0,0 +1,371 @@ +// file : CCF/IDL2/Parser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Parser.hpp" + +// +// Note: DO NOT run emacs indenter (or any other indentation tool) over +// this file because it will most likely break BNF indentation. +// + +namespace CCF +{ + namespace IDL2 + { + using Parsing::DiagnosticType; + using Parsing::RecoveryMethod; + + Parser:: + ~Parser () + { + } + + Parser:: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f) + : dout_ (dout), + lexer_ (l), + actions_ (f), + + error_handler (context, dout), + + ABSTRACT ("abstract"), + ATTRIBUTE ("attribute"), + FACTORY ("factory"), + IN ("in"), + INCLUDE ("include"), + INOUT ("inout"), + INTERFACE ("interface"), + LOCAL ("local"), + MODULE ("module"), + OUT ("out"), + SINCLUDE ("sinclude"), + SUPPORTS ("supports"), + + COLON (":"), + COMMA (","), + LBRACE ("{"), + RBRACE ("}"), + LPAREN ("("), + RPAREN (")"), + SEMI (";"), + + // Include + // + // + act_include_begin (f.include (), &SemanticAction::Include::begin), + act_include_end (f.include (), &SemanticAction::Include::end), + + // Module + // + // + act_module_begin (f.module (), &SemanticAction::Module::begin), + + act_module_open_scope ( + f.module (), &SemanticAction::Scope::open_scope), + + act_module_close_scope ( + f.module (), &SemanticAction::Scope::close_scope), + + act_module_end (f.module (), &SemanticAction::Module::end), + + + // Interface + // + // + act_abstract_interface_begin ( + f.interface (), &SemanticAction::Interface::begin_abstract), + + act_local_interface_begin ( + f.interface (), &SemanticAction::Interface::begin_local), + + act_unconstrained_interface_begin ( + f.interface (), &SemanticAction::Interface::begin_unconstrained), + + act_interface_inherits ( + f.interface (), &SemanticAction::Interface::inherits), + + act_interface_open_scope ( + f.interface (), &SemanticAction::Scope::open_scope), + + act_interface_close_scope ( + f.interface (), &SemanticAction::Scope::close_scope), + + act_interface_end (f.interface (), &SemanticAction::Interface::end), + + // Attribute + // + // + act_attribute_type ( + f.attribute (), &SemanticAction::Attribute::type), + + act_attribute_name ( + f.attribute (), &SemanticAction::Attribute::name), + + // Operation + // + // + act_operation_begin ( + f.operation (), &SemanticAction::Operation::begin), + + act_operation_parameter ( + this, &Parser::act_operation_parameter_core), + + act_operation_end (f.operation (), &SemanticAction::Operation::end) + + { + language = + guard + ( + *import >> +declaration >> EOS + + )[root_error_handler] + ; + + import = + include_decl + | system_include_decl + ; + + include_decl = + INCLUDE + >> string_literal[act_include_begin] + >> SEMI[act_include_end] + ; + + system_include_decl = + SINCLUDE + >> string_literal + >> SEMI[act_include_end] + ; + + declaration = + abstract_type_decl + | local_type_decl + | module_decl + | unconstrained_interface_decl + | extension + ; + + abstract_type_decl = + ABSTRACT + >> guard + ( + assertion ("interface or valuetype declaration expected") + ( + INTERFACE >> assertion ()(abstract_interface_decl) + ) + )[error_handler] + ; + + local_type_decl = + LOCAL + >> guard + ( + assertion ("interface declaration expected") + ( + INTERFACE >> assertion ()(local_interface_decl) + ) + )[error_handler] + ; + + module_decl = + MODULE + >> guard + ( + assertion ("module name expected") + ( + simple_identifier[act_module_begin] + ) + >> assertion ("\'{\' expected", + f.module (), + &SemanticAction::Module::end) + ( + LBRACE[act_module_open_scope] + ) + >> assertion ("declaration expected", + f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end, + RecoveryMethod::STANDARD, + DiagnosticType::BEFORE) + ( + hood (+declaration) + [ + handler (f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end) + ] + ) + >> assertion ("declaration or \'}\' expected", + f.module (), + &SemanticAction::Module::close_scope, + &SemanticAction::Module::end, + RecoveryMethod::STANDARD, + DiagnosticType::BEFORE) + ( + RBRACE[act_module_close_scope] + ) + >> assertion ("\';\' is missing", + f.module (), + &SemanticAction::Module::end, + RecoveryMethod::NONE) + ( + SEMI[act_module_end] + ) + )[error_handler] + ; + + + // + // interface + // + abstract_interface_decl = + guard + ( + assertion ("interface name expected") + ( + simple_identifier[act_abstract_interface_begin] + ) + >> interface_decl_trailer + + )[error_handler] + ; + + + local_interface_decl = + guard + ( + assertion ("interface name expected") + ( + simple_identifier[act_local_interface_begin] + ) + >> interface_decl_trailer + + )[error_handler] + ; + + + unconstrained_interface_decl = + guard + ( + INTERFACE + >> assertion ("interface name expected") + ( + simple_identifier[act_unconstrained_interface_begin] + ) + >> interface_decl_trailer + + )[error_handler] + ; + + + interface_decl_trailer = + assertion ("\';\', \'{\' or inheritance specification expected", + f.interface (), + &SemanticAction::Interface::end) + ( + SEMI[act_interface_end] + | + ( + !(COLON >> interface_inheritance_spec) + >> LBRACE[act_interface_open_scope] + >> interface_body + >> assertion ("declaration or \'}\' expected", + f.interface (), + &SemanticAction::Interface::close_scope, + &SemanticAction::Interface::end, + RecoveryMethod::STANDARD, + DiagnosticType::BEFORE) + ( + RBRACE[act_interface_close_scope] + ) + >> assertion ("\';\' is missing", + f.interface (), + &SemanticAction::Interface::end, + RecoveryMethod::NONE) + ( + SEMI[act_interface_end] + ) + ) + ) + ; + + + interface_inheritance_spec = + assertion ("interface name expected", + f.interface (), + &SemanticAction::Interface::end) + ( + identifier[act_interface_inherits] + ) + >> *( + COMMA + >> assertion ("interface name expected", + f.interface (), + &SemanticAction::Interface::end) + ( + identifier[act_interface_inherits] + ) + ) + ; + + interface_body = + *( + attribute_decl + | operation_decl + ) + ; + + // + // attribute + // + attribute_decl = + ATTRIBUTE + >> identifier[act_attribute_type] + >> simple_identifier[act_attribute_name] + >> SEMI + ; + + + // + // direction specifier + // + direction_specifier = + IN + | OUT + | INOUT + ; + + + // + // operation + // + operation_decl = + (identifier >> simple_identifier)[act_operation_begin] + >> LPAREN + >> operation_parameter_list + >> RPAREN + >> SEMI[act_operation_end] + ; + + operation_parameter_list = + *( + operation_parameter + >> *(COMMA >> operation_parameter) + ) + ; + + operation_parameter = + ( + direction_specifier + >> identifier + >> simple_identifier + )[act_operation_parameter] + ; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp new file mode 100644 index 00000000000..111f0c776c9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp @@ -0,0 +1,490 @@ +// file : CCF/IDL2/Parser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_PARSER_HPP +#define CCF_IDL2_PARSER_HPP + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" + +#include "CCF/IDL2/SemanticAction.hpp" +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +#include "CCF/IDL2/Parsing/Elements.hpp" +#include "CCF/IDL2/Parsing/Action.hpp" +#include "CCF/IDL2/Parsing/Recovery.hpp" + +namespace CCF +{ + namespace IDL2 + { + using Parsing::ActionExecutor; + using Parsing::NoArgAction; + using Parsing::OneArgAction; + using Parsing::TwoArgAction; + + class Parser + { + public: + virtual + ~Parser (); + + protected: + Diagnostic::Stream& dout_; + LexicalAnalyzer const& lexer_; + SemanticAction::Factory& actions_; + + protected: + typedef + Parsing::Iterator + Iterator; + + // + // Primitives + // + + typedef + Parsing::EndOfStreamParser + EndOfStreamParser; + + typedef + Parsing::KeywordParser + KeywordParser; + + typedef + Parsing::PunctuationParser + PunctuationParser; + + typedef + Parsing::IdentifierParser + IdentifierParser; + + typedef + Parsing::SimpleIdentifierParser + SimpleIdentifierParser; + + typedef + Parsing::StringLiteralParser + StringLiteralParser; + + + typedef + Parsing::RecoveryDescriptor + RecoveryDescriptor; + + typedef + Parsing::Assertion + Assertion; + + typedef + Parsing::RecoveryStatus + RecoveryStatus; + + typedef + Parsing::Guard + Guard; + + //@@ names are not thought out weel for error handling + + struct ErrorHandler + { + ErrorHandler (CompilerElements::Context& context, + Diagnostic::Stream& dout) + : dout_ (dout), + context_ (context) + { + } + + RecoveryStatus + operator() (Parsing::Scanner const& s, Parsing::Error& e) const + { + Iterator i = e.where; + + switch (e.descriptor.diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << e.descriptor.description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + i--; + + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "after \'" << (*i)->lexeme () << "\': " + << e.descriptor.description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + if (e.descriptor.action_one_.get ()) + e.descriptor.action_one_->execute (); + + if (e.descriptor.action_two_.get ()) + e.descriptor.action_two_->execute (); + + switch (e.descriptor.recovery_) + { + case Parsing::RecoveryMethod::STANDARD: + { + unsigned long balance = 0; + + for (Iterator t = e.where; t != s.last; t++) + { + //std::cerr << "error recovery: skipping " << (*t)->lexeme () + // << std::endl; + + if ((*t)->lexeme () == "{") balance++; + else if ((*t)->lexeme () == "}") + { + if (balance > 0) balance--; + else + { + t++; + if ((*t)->lexeme () == ";") t++; + + int length = t - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + if (balance == 0 && (*t)->lexeme () == ";") + { + int length = t - s.first + 1; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + switch (e.descriptor.diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + rec << "after \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + e.descriptor.recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor.diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor.action_one_.reset (); + e.descriptor.action_two_.reset (); + + return RecoveryStatus (RecoveryStatus::rethrow); + } + case Parsing::RecoveryMethod::NONE: + default: + { + int length = e.where - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + case Parsing::RecoveryMethod::BAIL_OUT: + { + e.descriptor.recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor.diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor.action_one_.reset (); + e.descriptor.action_two_.reset (); + + return RecoveryStatus (RecoveryStatus::rethrow); + } + } + } + + Diagnostic::Stream& dout_; + CompilerElements::Context& context_; + }; + + struct RootErrorHandler + { + RecoveryStatus + operator() (Parsing::Scanner const& s, Parsing::Error& e) const + { + return RecoveryStatus (RecoveryStatus::fail); + } + }; + + struct handler + { + template<typename Object> + handler (Object& obj, + void (Object::*action_one)()) + : action_one_ (Parsing::call_thunk (obj, action_one)), + action_two_ (0) + { + } + + template<typename Object> + handler (Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)()) + : action_one_ (Parsing::call_thunk (obj, action_one)), + action_two_ (Parsing::call_thunk (obj, action_two)) + { + } + + handler (handler const& h) + : action_one_ (h.action_one_.get () ? h.action_one_->clone () : 0), + action_two_ (h.action_two_.get () ? h.action_two_->clone () : 0) + { + } + + RecoveryStatus + operator() (Parsing::Scanner const& s, Parsing::Error& e) const + { + assert ( + e.descriptor.diagnostic_ == Parsing::DiagnosticType::NONE && + e.descriptor.recovery_ == Parsing::RecoveryMethod::BAIL_OUT + ); + + if (action_one_.get ()) action_one_->execute (); + if (action_two_.get ()) action_two_->execute (); + + return RecoveryStatus (RecoveryStatus::rethrow); + } + + std::auto_ptr<Parsing::Thunk> action_one_; + std::auto_ptr<Parsing::Thunk> action_two_; + }; + + Guard guard; + Guard hood; + Assertion assertion; + ErrorHandler error_handler; + RootErrorHandler root_error_handler; + + // End of stream parser + EndOfStreamParser EOS; + + // Keyword parsers (alphabetic order). + KeywordParser ABSTRACT; + KeywordParser ATTRIBUTE; + KeywordParser FACTORY; + KeywordParser IN; + KeywordParser INCLUDE; + KeywordParser INOUT; + KeywordParser INTERFACE; + KeywordParser LOCAL; + KeywordParser MODULE; + KeywordParser OUT; + KeywordParser SINCLUDE; + KeywordParser SUPPORTS; + + // Punctuation parsers (alphabetic group order). + PunctuationParser COLON; + PunctuationParser COMMA; + PunctuationParser LBRACE; + PunctuationParser RBRACE; + PunctuationParser LPAREN; + PunctuationParser RPAREN; + PunctuationParser SEMI; + + IdentifierParser identifier; + SimpleIdentifierParser simple_identifier; + StringLiteralParser string_literal; + + + // + // Language + // + + typedef + Parsing::Rule + Rule; + + Rule language; + Rule import; + Rule declaration; + Rule extension; + + Rule include_decl; + Rule system_include_decl; + + Rule module_decl; + + Rule abstract_type_decl; + Rule local_type_decl; + + Rule abstract_interface_decl; + Rule local_interface_decl; + Rule unconstrained_interface_decl; + Rule interface_decl_trailer; + Rule interface_inheritance_spec; + Rule interface_body; + + Rule attribute_decl; + + Rule direction_specifier; + + Rule operation_decl; + Rule operation_parameter_list; + Rule operation_parameter; + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + virtual Rule const& + start() const + { + return language; + } + + protected: + + // + // Semantic actions + // + + typedef + NoArgAction<SemanticAction::Scope> + ScopeAction; + + // + // Include + // + OneArgAction<StringLiteralPtr, SemanticAction::Include> + act_include_begin; + + NoArgAction<SemanticAction::Include> + act_include_end; + + // + // Module + // + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Module> + act_module_begin; + + ScopeAction + act_module_open_scope; + + ScopeAction + act_module_close_scope; + + NoArgAction<SemanticAction::Module> + act_module_end; + + // + // Interface + // + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Interface> + act_abstract_interface_begin; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Interface> + act_local_interface_begin; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Interface> + act_unconstrained_interface_begin; + + OneArgAction<IdentifierPtr, SemanticAction::Interface> + act_interface_inherits; + + ScopeAction + act_interface_open_scope; + + ScopeAction + act_interface_close_scope; + + NoArgAction<SemanticAction::Interface> + act_interface_end; + + // + // Attribute + // + OneArgAction<IdentifierPtr, SemanticAction::Attribute> + act_attribute_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Attribute> + act_attribute_name; + + // + // Operation + // + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::Operation> + act_operation_begin; + + void + act_operation_parameter_core (Iterator begin, + Iterator end) const + { + SemanticAction::Operation::Direction::Value d; + + if((*begin)->lexeme () == "in") + { + d = SemanticAction::Operation::Direction::IN; + } + else if((*begin)->lexeme () == "out") + { + d = SemanticAction::Operation::Direction::OUT; + } + else + { + d = SemanticAction::Operation::Direction::INOUT; + } + + begin++; + + actions_.operation ().parameter ( + d, + ReferenceCounting::strict_cast<Identifier>(*begin), + ReferenceCounting::strict_cast<SimpleIdentifier>(*(begin + 1))); + } + + ActionExecutor<Parser> + act_operation_parameter; + + NoArgAction<SemanticAction::Operation> + act_operation_end; + }; + } +} + +#endif // CCF_IDL2_PARSER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp new file mode 100644 index 00000000000..180f1aefa1d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Action.hpp @@ -0,0 +1,142 @@ +// file : CCF/IDL2/Parsing/Action.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_PARSING_ACTION_HPP +#define CCF_IDL2_PARSING_ACTION_HPP + +#include "CCF/IDL2/Parsing/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + // + // + // + template <typename Obj> + class ActionExecutor + { + public: + + typedef + void (Obj::*SemanticAction)(Iterator, Iterator) const; + + ActionExecutor (Obj const* obj, SemanticAction action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + (obj_->*action_) (begin, end); + } + + private: + Obj const* obj_; + SemanticAction action_; + }; + + + // + // + // + template <typename Obj> + class NoArgAction + { + public: + + typedef + void (Obj::*Action)(); + + NoArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator, Iterator) const + { + (obj_.*action_) (); + } + + private: + Obj& obj_; + Action action_; + }; + + + //@@ Should prbably use Type instead of TypePtr + // + // + // + template <typename TypePtr, typename Obj> + class OneArgAction + { + public: + + typedef + void (Obj::*Action)(TypePtr const&); + + OneArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + if (end - begin != 1 ) + { + //@@ throw + } + + //@@ error handling if the strict_cast fails + (obj_.*action_) ( + ReferenceCounting::strict_cast<typename TypePtr::Type> (*begin)); + } + + private: + Obj& obj_; + Action action_; + }; + + + // + // + // + template <typename Arg1, typename Arg2, typename Obj> + class TwoArgAction + { + public: + + typedef + void (Obj::*Action)(Arg1 const&, Arg2 const&); + + TwoArgAction (Obj& obj, Action action) + : obj_ (obj), action_ (action) + { + } + + void operator () (Iterator begin, Iterator end) const + { + if (end - begin != 2 ) + { + //@@ throw + } + + //@@ error handling if strict_cast fails + (obj_.*action_) ( + ReferenceCounting::strict_cast<typename Arg1::Type> (*begin), + ReferenceCounting::strict_cast<typename Arg2::Type> (*(begin + 1))); + } + + private: + Obj& obj_; + Action action_; + }; + } + } +} + +#endif // CCF_IDL2_PARSING_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp new file mode 100644 index 00000000000..8016f5460f9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp @@ -0,0 +1,151 @@ +// file : CCF/IDL2/Parsing/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_PARSING_ELEMENTS_HPP +#define CCF_IDL2_PARSING_ELEMENTS_HPP + +#include <string> + +#include <boost/spirit.hpp> + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + using namespace boost::spirit; + + typedef + TokenList::iterator + Iterator; + + typedef + scanner<Iterator, scanner_policies<> > + Scanner; + + typedef + rule<Scanner> + Rule; + + + // + // + // + template <typename Type> + struct IdentityParser : public parser <IdentityParser<Type> > + { + typedef + IdentityParser + self_t; + + IdentityParser (std::string lexeme) + : lexeme_ (lexeme) + { + } + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0 && + lexeme_ == t->lexeme ()) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + + private: + std::string lexeme_; + }; + + typedef + IdentityParser<Keyword> + KeywordParser; + + typedef + IdentityParser<Punctuation> + PunctuationParser; + + + // + // + // + template <typename Type> + struct TypeParser : public parser <TypeParser<Type> > + { + typedef + TypeParser + self_t; + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + }; + + typedef + TypeParser<EndOfStream> + EndOfStreamParser; + + typedef + TypeParser<Identifier> + IdentifierParser; + + typedef + TypeParser<SimpleIdentifier> + SimpleIdentifierParser; + + typedef + TypeParser<ScopedIdentifier> + ScopedIdentifierParser; + + typedef + TypeParser<StringLiteral> + StringLiteralParser; + + + // + // + // + inline bool + parse (Iterator const& first_, + Iterator const& last, + Rule const& rule) + { + Iterator first = first_; + Scanner scan(first, last); + match<nil_t> hit = rule.parse(scan); + + bool result = parse_info<Iterator>( + first, hit, hit && (first == last), hit.length()).full; + + return result; + } + } + } +} + +#endif // CCF_IDL2_PARSING_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp new file mode 100644 index 00000000000..6501e23f576 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp @@ -0,0 +1,278 @@ +// file : CCF/IDL2/Parsing/Recovery.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_PARSING_RECOVERY_HPP +#define CCF_IDL2_PARSING_RECOVERY_HPP + +#include <memory> + +#include "CCF/IDL2/Parsing/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + + // + // + // + struct RecoveryMethod + { + enum Value + { + NONE, + STANDARD, + BAIL_OUT + }; + }; + + + // + // + // + struct DiagnosticType + { + enum Value + { + BEFORE, + AFTER, + NONE + }; + }; + + + // + // + // + class Thunk + { + public: + virtual + ~Thunk () {} + + virtual void + execute () = 0; + + virtual Thunk* + clone () const = 0; + }; + + + // + // + // + template<typename Object> + class ThunkImpl : public Thunk + { + public: + typedef void (Object::*Func)(); + + ThunkImpl (Object& obj, Func func) + : obj_(obj), + func_ (func) + { + } + + virtual void + execute () + { + (obj_.*func_)(); + } + + virtual Thunk* + clone () const + { + return new ThunkImpl<Object> (obj_, func_); + } + + private: + Object& obj_; + Func func_; + }; + + // + // + // + template<typename Object> + Thunk* + call_thunk (Object& obj, void (Object::*func)()) + { + return new ThunkImpl<Object> (obj, func); + } + + + // + // + // + struct RecoveryDescriptor + { + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic) + : action_one_ (0), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (call_thunk (obj, action_two)), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + RecoveryDescriptor (RecoveryDescriptor const& rd) + : action_one_ (rd.action_one_.get () ? rd.action_one_->clone () : 0), + action_two_ (rd.action_two_.get () ? rd.action_two_->clone () : 0), + description_ (rd.description_), + recovery_ (rd.recovery_), + diagnostic_ (rd.diagnostic_) + { + } + + + std::auto_ptr<Thunk> action_one_; + std::auto_ptr<Thunk> action_two_; + std::string description_; + RecoveryMethod::Value recovery_; + DiagnosticType::Value diagnostic_; + }; + + + + // + // + // + typedef + parser_error<RecoveryDescriptor, Iterator> + Error; + + + // + // + // + struct Assertion + { + assertion<RecoveryDescriptor> + operator () (RecoveryMethod::Value recovery = RecoveryMethod::NONE) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor ("", recovery, DiagnosticType::NONE)); + } + + assertion<RecoveryDescriptor> + operator () (std::string d, + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor (d, recovery, diagnostic)); + } + + template<typename Object> + assertion<RecoveryDescriptor> + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor (d, + recovery, + diagnostic, + obj, + action_one)); + } + + template<typename Object> + assertion<RecoveryDescriptor> + operator () (Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor ("", + recovery, + DiagnosticType::NONE, + obj, + action_one)); + } + + template<typename Object> + assertion<RecoveryDescriptor> + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor (d, + recovery, + diagnostic, + obj, + action_one, + action_two)); + } + + + template<typename Object> + assertion<RecoveryDescriptor> + operator () (Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return assertion<RecoveryDescriptor> ( + RecoveryDescriptor ("", + recovery, + DiagnosticType::NONE, + obj, + action_one, + action_two)); + } + + }; + + typedef + error_status<> + RecoveryStatus; + + typedef + guard<RecoveryDescriptor> + Guard; + } + } +} + +#endif // CCF_IDL2_PARSING_RECOVERY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp new file mode 100644 index 00000000000..71f77ce9aa6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp @@ -0,0 +1,17 @@ +// file : CCF/IDL2/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL2/SemanticAction/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Module.hpp" +#include "CCF/IDL2/SemanticAction/Operation.hpp" + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +#endif // CCF_IDL2_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp new file mode 100644 index 00000000000..da1114c3644 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Attribute.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Attribute + { + public: + virtual + ~Attribute () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_ATTRIBUTE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..7e876fbfad9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Elements.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Scope + { + public: + virtual + ~Scope () throw () {} + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..bf8159bd31c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp @@ -0,0 +1,49 @@ +// file : CCF/IDL2/SemanticAction/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + class Include; + class Module; + class Interface; + class Attribute; + class Operation; + + // + // + // + class Factory + { + public: + virtual + ~Factory () throw () {} + + virtual Include& + include () = 0; + + virtual Module& + module () = 0; + + virtual Interface& + interface () = 0; + + virtual Attribute& + attribute () = 0; + + virtual Operation& + operation () = 0; + }; + + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp new file mode 100644 index 00000000000..4912e4eb4fe --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp new file mode 100644 index 00000000000..170af461f55 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp @@ -0,0 +1,108 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticAction/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Attribute : public virtual SemanticAction::Attribute + { + public: + virtual + ~Attribute () throw () {} + + Attribute (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + public: + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "attribute " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<TypeDecl> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid attribute declaration" << endl; + cerr << "no type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid attribute declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a type declaration" << endl; + cerr << "using non-type as an attribute type is illegal" + << endl; + } + + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + SimpleName name (id->lexeme ()); + + AttributeDeclPtr a ( + new SyntaxTree::AttributeDecl (name, type_, scope_)); + + scope_->insert (a); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp new file mode 100644 index 00000000000..d4639e2a9ab --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..51013bdceac --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,92 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include <stack> + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +//@@tmp +#include <iostream> +using std::cerr; +using std::endl; + +/* + Design notes: + + (1) I am using stack-based approach to handle cases like this: + + struct A + { + struct B + { + struct C + { + ... + } c; + + } b; + }; + + Even though you can't write the same let's say for interface + I am still using stack approach for consistency and possible + meta-coding. + +*/ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + + // + // + // + template <typename NodeTypePtr> + class ScopeBase : public virtual SemanticAction::Scope + { + protected: + virtual + ~ScopeBase () throw () {} + + ScopeBase (SyntaxTree::ScopePtr& scope) + : scope_ (scope) + { + } + + protected: + void + push (NodeTypePtr const& t) + { + stack_.push (t); + } + + void + pop () + { + stack_.pop (); + } + + NodeTypePtr& + top () + { + return stack_.top (); + } + + protected: + SyntaxTree::ScopePtr& scope_; + std::stack<NodeTypePtr> stack_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..2203152f852 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..b653b404568 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,96 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Factory : public virtual IDL2::SemanticAction::Factory + { + public: + virtual + ~Factory () throw () {} + + + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SyntaxTree::TranslationRegionPtr const& r) + : trace_ (context.get ("idl2::semantic-action::trace", false)), + + scope_ (r->scope ()), + + include_ (trace_, *this, r, scope_), + module_ (trace_, scope_), + interface_ (trace_, scope_), + attribute_ (trace_, scope_), + operation_ (trace_, scope_) + { + } + + virtual SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Module& + module () + { + return module_; + } + + virtual SemanticAction::Interface& + interface () + { + return interface_; + } + + virtual SemanticAction::Attribute& + attribute () + { + return attribute_; + } + + virtual SemanticAction::Operation& + operation () + { + return operation_; + } + + protected: + bool trace_; + + SyntaxTree::ScopePtr scope_; + SyntaxTree::TranslationRegionPtr region_; + + Include include_; + Module module_; + Interface interface_; + Attribute attribute_; + Operation operation_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..46df07935c6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..1615ee918c5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp @@ -0,0 +1,115 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP + +#include <stack> + +#include "CCF/IDL2/SyntaxTree/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Include : public virtual SemanticAction::Include + { + public: + virtual + ~Include () throw () {} + + Include (bool trace, + SemanticAction::Factory& action_factory, + SyntaxTree::TranslationRegionPtr const& region, + SyntaxTree::ScopePtr& scope) + : trace_ (trace), + action_factory_ (action_factory), + scope_ (scope) + { + stack_.push (region); + } + + virtual void + begin (StringLiteralPtr const& sl) + { + if (trace_) cerr << "include \"" << sl << "\"" << endl; + + /* + @@ this code is experimentla and temporarlily disabled + @@ see relevant code in IDL3 for more information + + using namespace SyntaxTree; + + std::ifstream ifs (sl->lexeme ().c_str ()); + if (!ifs.is_open ()) + { + cerr << "error: unable to open included file \'" + << sl << "\'" << endl; + } + + TranslationRegionPtr r ( + new TranslationRegion (sl->lexeme (), + stack_.top ()->table (), + stack_.top ()->create_order ())); + + stack_.top ()->insert (r); + stack_.push (r); + + scope_ = stack_.top ()->scope (); + + //@@ this code is highly experimental + IDL2::LexicalAnalyzer lexer (ifs); + + TokenStream token_stream; + + //@@ bad token comparison + for (TokenPtr token = lexer.next (); + token.in () != lexer.eos.in (); + token = lexer.next ()) + { + token_stream.push_back (token); + } + + if (token_stream.size () == 0) + { + // Empty file + return; + } + + IDL2::Parser parser (lexer, action_factory_); + + bool result = Details::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + */ + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + + stack_.pop (); + scope_ = stack_.top ()->scope (); + } + + public: + bool trace_; + SemanticAction::Factory& action_factory_; + SyntaxTree::ScopePtr& scope_; + std::stack<SyntaxTree::TranslationRegionPtr> stack_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp new file mode 100644 index 00000000000..f1868ef4121 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp new file mode 100644 index 00000000000..02f79ecbd04 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp @@ -0,0 +1,290 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Interface : public virtual SemanticAction::Interface, + public virtual ScopeBase<SyntaxTree::InterfaceDeclPtr> + { + public: + virtual + ~Interface () throw () {} + + Interface (bool trace, + SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::InterfaceDeclPtr> (scope), + trace_ (trace), + name_ ("") + { + } + + virtual void + begin_abstract (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "abstract interface " << id << endl; + + qualifier_ = Qualifier::ABSTRACT; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + + virtual void + begin_local (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "local interface " << id << endl; + + qualifier_ = Qualifier::LOCAL; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + begin_unconstrained (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "unconstrained interface " << id << endl; + + qualifier_ = Qualifier::UNCONSTRAINED; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + inherits (IdentifierPtr const& id) + { + using namespace SyntaxTree; + + if (trace_) cerr << " inherits: " << id << endl; + + Name name (id->lexeme ()); + + struct InheritancePredicate : public DeclarationTable::ResolvePredicate + { + InheritancePredicate (Qualifier::Value q) : q_ (q) {} + + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) throw (IncompatibleType) + { + bool passed = false; + + switch (q_) + { + case Qualifier::UNCONSTRAINED: + { + if (d->is_a<AbstractInterfaceDecl> () || + d->is_a<UnconstrainedInterfaceDecl> ()) passed = true; + + break; + } + case Qualifier::LOCAL: + { + if (d->is_a<LocalInterfaceDecl> () || + d->is_a<AbstractInterfaceDecl> () || + d->is_a<UnconstrainedInterfaceDecl> ()) passed = true; + + break; + } + case Qualifier::ABSTRACT: + { + if (d->is_a<AbstractInterfaceDecl> ()) passed = true; + + break; + } + } + + if (!passed) throw IncompatibleType (d->declaration_class ()); + + return d->dynamic_type<TypeDecl> ()->defined (); + } + + private: + Qualifier::Value q_; + } p (qualifier_); + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + if (inherits_.insert (sn).second == false) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "directly inheriting from interface \'" + << sn << "\' more than once is illegal" << endl; + } + } + catch (InheritancePredicate::IncompatibleType const& e) + { + cerr << "error: invalid inheritance specification" << endl; + + cerr << "inheritance of "; + + switch (qualifier_) + { + case Qualifier::UNCONSTRAINED: + { + cerr << "unconstrained "; + break; + } + case Qualifier::LOCAL: + { + cerr << "local "; + break; + } + case Qualifier::ABSTRACT: + { + cerr << "abstract "; + break; + } + } + + cerr << "interface \'" << name_ <<"\' from " + << e.type << " \'" << name << "\' is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no defined interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "inheritance from forward-declared interface is illegal" + << endl; + } + } + + virtual void + open_scope () + { + if (trace_) cerr << "scope open" << endl; + + using namespace SyntaxTree; + + InterfaceDefPtr def; + + switch (qualifier_) + { + case Qualifier::UNCONSTRAINED: + { + def = new UnconstrainedInterfaceDef (name_, scope_, inherits_); + break; + } + case Qualifier::LOCAL: + { + def = new LocalInterfaceDef (name_, scope_, inherits_); + break; + } + case Qualifier::ABSTRACT: + { + def = new AbstractInterfaceDef (name_, scope_, inherits_); + break; + } + } + + scope_->insert (def); + push (def); + scope_ = def; + + name_ = SimpleName (""); //indicate that we are done + inherits_.clear (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + if (trace_) cerr << "scope close" << endl; + } + + virtual void + end () + { + using namespace SyntaxTree; + + if (trace_) cerr << "end" << endl; + + if (name_ != SimpleName ("")) + { + InterfaceDeclPtr decl; + + switch (qualifier_) + { + case Qualifier::UNCONSTRAINED: + { + decl = new UnconstrainedInterfaceForwardDecl (name_, scope_); + break; + } + case Qualifier::LOCAL: + { + decl = new LocalInterfaceForwardDecl (name_, scope_); + break; + } + case Qualifier::ABSTRACT: + { + decl = new AbstractInterfaceForwardDecl (name_, scope_); + break; + } + } + + scope_->insert (decl); + } + else + { + pop (); + } + } + private: + + struct Qualifier + { + enum Value + { + ABSTRACT, + LOCAL, + UNCONSTRAINED + }; + }; + + bool trace_; + + Qualifier::Value qualifier_; + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedNameSet inherits_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp new file mode 100644 index 00000000000..4b08fe349ed --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp new file mode 100644 index 00000000000..71ccbff3150 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp @@ -0,0 +1,82 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Module : public virtual SemanticAction::Module, + public virtual ScopeBase<SyntaxTree::ModulePtr> + { + public: + virtual + ~Module () throw () {} + + + Module (bool trace, + SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::ModulePtr> (scope), + trace_ (trace) + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "module " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + ModulePtr m (new SyntaxTree::Module (name, scope_)); + + scope_->insert (m); + push (m); + } + + virtual void + open_scope () + { + if (trace_) cerr << "scope open" << endl; + scope_ = top (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + if (trace_) cerr << "scope close" << endl; + } + + virtual void + end () + { + pop (); + if (trace_) cerr << "end" << endl; + } + + private: + bool trace_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp new file mode 100644 index 00000000000..e10ad634c47 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp new file mode 100644 index 00000000000..6f09cf2b5cb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp @@ -0,0 +1,161 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP + +#include "CCF/IDL2/SemanticAction/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Operation : public virtual SemanticAction::Operation + { + public: + + virtual + ~Operation () throw () {} + + Operation (bool trace, + SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current) + { + } + + bool + lookup_type (SyntaxTree::Name const& name, + SyntaxTree::ScopedName& result) + { + using namespace SyntaxTree; + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<TypeDecl> (); + } + } p; + + try + { + result = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + return true; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid operation declaration" << endl; + cerr << "no type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid operation declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a type declaration" << endl; + cerr << "using non-type as operation parameter type " + << " or return type is illegal" + << endl; + } + + return false; + } + + + virtual void + begin (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (trace_) + cerr << "operation " << type_id << " " << name_id << endl; + + using namespace SyntaxTree; + + ScopedName type_name; + + if (lookup_type (Name (type_id->lexeme ()), type_name)) + { + operation_ = OperationDeclPtr ( + new OperationDecl (SimpleName (name_id->lexeme ()), + type_name, + scope_)); + } + } + + + virtual void + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (trace_) + cerr << "parameter " << direction << " " << type_id + << " " << name_id << endl; + + using namespace SyntaxTree; + + ScopedName type_name (""); + + if (lookup_type (Name (type_id->lexeme ()), type_name) && + operation_ != 0) + { + OperationParameter::Direction::Value d = + OperationParameter::Direction::INOUT; + + if (direction == Direction::IN) + { + d = OperationParameter::Direction::IN; + } + else if (direction == Direction::OUT) + { + d = OperationParameter::Direction::OUT; + } + + OperationParameterPtr p ( + new OperationParameter (d, + type_name, + SimpleName (name_id->lexeme ()), + scope_->table ())); + operation_->insert (p); + } + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + if (operation_ != 0) + { + scope_->insert (operation_); + operation_ = SyntaxTree::OperationDeclPtr (); + } + } + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::OperationDeclPtr operation_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp new file mode 100644 index 00000000000..3155fb4c97f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticAction/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Include + { + public: + virtual + ~Include () throw () {} + + virtual void + begin (StringLiteralPtr const& sl) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_INCLUDE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp new file mode 100644 index 00000000000..6de2f9e1bf8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp @@ -0,0 +1,50 @@ +// file : CCF/IDL2/SemanticAction/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Interface : public virtual Scope + { + public: + virtual + ~Interface () throw () {} + + virtual void + begin_abstract (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_local (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_unconstrained (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt new file mode 100644 index 00000000000..c096c4d7178 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt @@ -0,0 +1,19 @@ +# file : CCF/IDL2/SemanticAction/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + + +cxx_translation_units := Operation.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp new file mode 100644 index 00000000000..e74235db9f2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Module.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Module : public virtual Scope + { + public: + virtual + ~Module () throw () {} + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp new file mode 100644 index 00000000000..22e754befee --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.cpp @@ -0,0 +1,28 @@ +// file : CCF/IDL2/SemanticAction/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SemanticAction/Operation.hpp" + +#include <ostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace + { + char* labels[] = {"in", "out", "inout"}; + } + + std::ostream& + + operator<< (std::ostream& o, Operation::Direction::Value d) + { + return o << labels[d]; + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp new file mode 100644 index 00000000000..78815f70892 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp @@ -0,0 +1,54 @@ +// file : CCF/IDL2/SemanticAction/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP + +#include <iosfwd> + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Operation + { + public: + + virtual void + begin (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) = 0; + + struct Direction + { + enum Value + { + IN = 0, + OUT, + INOUT + }; + + friend std::ostream& + operator<< (std::ostream& o, Value d); + }; + + virtual void + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree.hpp new file mode 100644 index 00000000000..9d0fddd3dc3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree.hpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/SyntaxTree.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_HPP +#define CCF_IDL2_SYNTAX_TREE_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/BuiltIn.hpp" +#include "CCF/IDL2/SyntaxTree/Interface.hpp" +#include "CCF/IDL2/SyntaxTree/Module.hpp" +#include "CCF/IDL2/SyntaxTree/Operation.hpp" +#include "CCF/IDL2/SyntaxTree/Translation.hpp" +#include "CCF/IDL2/SyntaxTree/ValueType.hpp" + +#endif // CCF_IDL2_SYNTAX_TREE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.cpp new file mode 100644 index 00000000000..e3eaf20b3b0 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.cpp @@ -0,0 +1,124 @@ +// file : CCF/IDL2/SyntaxTree/BuiltIn.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/BuiltIn.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // BuiltInTypeDef + // + // + namespace + { + TypeInfo + built_in_type_def_init_ () + { + TypeInfo ti (typeid (BuiltInTypeDef)); + ti.add_base (Access::PUBLIC, true, TypeDef::static_type_info ()); + return ti; + } + + TypeInfo built_in_type_def_ (built_in_type_def_init_ ()); + } + + TypeInfo const& BuiltInTypeDef:: + static_type_info () { return built_in_type_def_; } + + + // Void + // + // + namespace + { + TypeInfo + void_init_ () + { + TypeInfo ti (typeid (Void)); + ti.add_base (Access::PUBLIC, + true, + BuiltInTypeDef::static_type_info ()); + return ti; + } + + TypeInfo void_ (void_init_ ()); + } + + TypeInfo const& Void:: + static_type_info () { return void_; } + + + // Long + // + // + namespace + { + TypeInfo + long_init_ () + { + TypeInfo ti (typeid (Long)); + ti.add_base (Access::PUBLIC, + true, + BuiltInTypeDef::static_type_info ()); + return ti; + } + + TypeInfo long_ (long_init_ ()); + } + + TypeInfo const& Long:: + static_type_info () { return long_; } + + + // Boolean + // + // + namespace + { + TypeInfo + boolean_init_ () + { + TypeInfo ti (typeid (Boolean)); + ti.add_base (Access::PUBLIC, + true, + BuiltInTypeDef::static_type_info ()); + return ti; + } + + TypeInfo boolean_ (boolean_init_ ()); + } + + TypeInfo const& Boolean:: + static_type_info () { return boolean_; } + + + // String + // + // + namespace + { + TypeInfo + string_init_ () + { + TypeInfo ti (typeid (String)); + ti.add_base (Access::PUBLIC, + true, + BuiltInTypeDef::static_type_info ()); + return ti; + } + + TypeInfo string_ (string_init_ ()); + } + + TypeInfo const& String:: + static_type_info () { return string_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.hpp new file mode 100644 index 00000000000..b76fd551e52 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/BuiltIn.hpp @@ -0,0 +1,204 @@ +// file : CCF/IDL2/SyntaxTree/BuiltIn.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_BUILT_IN_HPP +#define CCF_IDL2_SYNTAX_TREE_BUILT_IN_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + //@@ I have a potential problem with two-word built-in types + // e.g. unsigned long. Though I don't see anything bad in + // allowing (internally) for names to contain spaces e.g. + // '::unsigned long'. I will also have to teach LexicalAnalyzer + // to parse this stuff properly. + // + + // + // + // + class BuiltInTypeDef : public virtual TypeDef + { + protected: + virtual + ~BuiltInTypeDef () throw () {} + + BuiltInTypeDef (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "built-in type"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<BuiltInTypeDef> + BuiltInTypeDefPtr; + + + // + // + // + class Void : public virtual BuiltInTypeDef + { + public: + virtual + ~Void () throw () {} + + Void (ScopePtr const& scope) + : Declaration (SimpleName ("void"), scope), + TypeDecl (SimpleName ("void"), scope), + TypeDef (SimpleName ("void"), scope), + BuiltInTypeDef (SimpleName ("void"), scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "built-in type void"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<Void> + VoidPtr; + + // + // + // + class Long : public virtual BuiltInTypeDef + { + public: + virtual + ~Long () throw () {} + + Long (ScopePtr const& scope) + : Declaration (SimpleName ("long"), scope), + TypeDecl (SimpleName ("long"), scope), + TypeDef (SimpleName ("long"), scope), + BuiltInTypeDef (SimpleName ("long"), scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "built-in type long"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<Long> + LongPtr; + + // + // + // + class Boolean : public virtual BuiltInTypeDef + { + public: + virtual + ~Boolean () throw () {} + + Boolean (ScopePtr const& scope) + : Declaration (SimpleName ("boolean"), scope), + TypeDecl (SimpleName ("boolean"), scope), + TypeDef (SimpleName ("boolean"), scope), + BuiltInTypeDef (SimpleName ("boolean"), scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "built-in type boolean"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<Boolean> + BooleanPtr; + + + // + // + // + class String : public virtual BuiltInTypeDef + { + public: + virtual + ~String () throw () {} + + String (ScopePtr const& scope) + : Declaration (SimpleName ("string"), scope), + TypeDecl (SimpleName ("string"), scope), + TypeDef (SimpleName ("string"), scope), + BuiltInTypeDef (SimpleName ("string"), scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "built-in type string"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<String> + StringPtr; + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_BUILT_IN_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.cpp new file mode 100644 index 00000000000..98f54e5b269 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.cpp @@ -0,0 +1,391 @@ +// file : CCF/IDL2/SyntaxTree/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // Node + // + // + namespace + { + TypeInfo + node_init_ () + { + TypeInfo ti (typeid (Node)); + // I don't really need this information + // ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); + return ti; + } + + TypeInfo node_ (node_init_ ()); + } + + TypeInfo const& Node:: + static_type_info () { return node_; } + + + // Comma + // + // + namespace + { + TypeInfo + comma_init_ () + { + TypeInfo ti (typeid (Comma)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo comma_ (comma_init_ ()); + } + + TypeInfo const& Comma:: + static_type_info () { return comma_; } + + + // Declaration + // + // + namespace + { + TypeInfo + declaration_init_ () + { + TypeInfo ti (typeid (Declaration)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo declaration_ (declaration_init_ ()); + } + + TypeInfo const& Declaration:: + static_type_info () { return declaration_; } + + Declaration:: + Declaration (SimpleName const& name, ScopePtr const& scope) + : order_ (scope->create_order ()), + name_ (scope->name (), name), + scope_ (scope->table (), + scope->name (), + scope->order ()) // Hint: scope->scope () may throw + { + type_info (static_type_info ()); + } + + Declaration:: + Declaration (ScopedName const& name, + Order const& order, + DeclarationTable const& table) + : order_ (order), + name_ (name), + scope_ (table) // this stuff is faked + { + type_info (static_type_info ()); + } + + ScopedName Declaration:: + name () const + { + return name_; + } + + Order Declaration:: + order () const + { + return order_; + } + + ScopePtr Declaration:: + scope () const throw (NotInScope) + { + return scope_.resolve (); + } + + + // DeclarationTable + // + // + + void DeclarationTable:: + insert (DeclarationPtr d) throw (InvalidArgument, + AlreadyExist, + TypeMismatch) + { + if (d == 0) throw InvalidArgument (); + + IteratorPair pair = lookup (d->name ()); + + if (pair.first != pair.second) + { + // I have some declarations with this name already + if ((*pair.first)->declaration_class () != d->declaration_class ()) + { + throw TypeMismatch (); + } + } + + std::pair<DeclarationSet::iterator, bool> result = + decl_set_.insert (d); + + if (result.second == false) throw AlreadyExist (); + + try + { + if(name_decl_map_[d->name ()].insert (d).second == false) + { + throw AlreadyExist (); + } + } + catch (...) + { + // Leaving table in consistent state + decl_set_.erase (result.first); + throw; + } + } + + DeclarationTable::IteratorPair DeclarationTable:: + lookup (ScopedName const& n) const + { + NameDeclarationMap::const_iterator i = name_decl_map_.find (n); + if (i == name_decl_map_.end ()) + { + return IteratorPair (decl_set_.end (), decl_set_.end ()); + } + else + { + return IteratorPair (i->second.begin (), i->second.end ()); + } + } + + DeclarationTable::Iterator DeclarationTable:: + begin () const + { + return decl_set_.begin (); + } + + DeclarationTable::Iterator DeclarationTable:: + end () const + { + return decl_set_.end (); + } + + ScopedName DeclarationTable:: + resolve (Name const& name, + ScopedName const& from, + Order const& before, + ResolvePredicate& p) const throw (ResolutionFailure) + { + ScopedName result (""); + + // Check if name is already scoped + try + { + result = ScopedName (name); + } + catch (ScopedName::InvalidArgument const&) + { + //seems not + try + { + for (ScopedName base = from;;base = base.scope ()) + { + result = ScopedName (base, name); + + //cerr << "*** resolve: considering: " << result << endl; + + IteratorPair pair = lookup (result); + + if (pair.first != pair.second) + { + // Found something. Now checking the order. Note that the + // first element has the smallest order so it's sufficient + // to check just the first element for now. + if ((*pair.first)->order () < before) + { + break; + } + /* + std::cerr << std::endl + << "before condition failed : " + << (*pair.first)->order () << " (" + << (*pair.first)->name () + << ") expected to be before " + << before << std::endl; */ + } + } + } + catch (ScopedName::AtRoot const&) + { + // didn't find anything + throw NameNotFound (); + } + } + + // Now check predicat + IteratorPair pair = lookup (result); + + if (pair.first == pair.second) throw NameNotFound (); + + for (;pair.first != pair.second; pair.first++) + { + // we should stay before + if (!((*pair.first)->order () < before)) break; + + if (p.test (*pair.first)) return result; + } + + throw PredicateNotMet (); + } + + + // Scope + // + // + namespace + { + TypeInfo + scope_init_ () + { + TypeInfo ti (typeid (Scope)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo scope_ti_ (scope_init_ ()); + } + + TypeInfo const& Scope:: + static_type_info () { return scope_ti_; } + + void Scope:: + insert (DeclarationPtr d) throw (InvalidArgument, AlreadyExist) + { + if (d == 0) throw InvalidArgument (); + + std::pair<DeclarationSet::iterator, bool> result = + content_.insert (d); + + if (result.second == false) throw AlreadyExist (); + + try + { + try + { + table_.insert (d); + } + catch (...) + { + //Keep consistent state + content_.erase (result.first); + throw; + } + } + catch (DeclarationTable::InvalidArgument const&) + { + throw InvalidArgument (); + } + catch (DeclarationTable::AlreadyExist const&) + { + throw AlreadyExist (); + } + } + + Scope::Iterator Scope:: + begin () const + { + return content_.begin (); + } + + Scope::Iterator Scope:: + end () const + { + return content_.end (); + } + + Order Scope:: + create_order () + { + return Order (order (), next_order_++); + } + + Order Scope:: + peek_order () + { + return Order (order (), next_order_); + } + + + // + // TypeDecl + // + namespace + { + TypeInfo + type_decl_init_ () + { + TypeInfo ti (typeid (TypeDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo type_decl_ (type_decl_init_ ()); + } + + TypeInfo const& TypeDecl:: + static_type_info () { return type_decl_; } + + + // TypeForwardDecl + // + // + namespace + { + TypeInfo + type_forward_decl_init_ () + { + TypeInfo ti (typeid (TypeForwardDecl)); + ti.add_base (Access::PUBLIC, true, TypeDecl::static_type_info ()); + return ti; + } + + TypeInfo type_forward_decl_ (type_forward_decl_init_ ()); + } + + TypeInfo const& TypeForwardDecl:: + static_type_info () { return type_forward_decl_; } + + + // TypeDef + // + // + namespace + { + TypeInfo + type_def_init_ () + { + TypeInfo ti (typeid (TypeDef)); + ti.add_base (Access::PUBLIC, true, TypeDecl::static_type_info ()); + return ti; + } + + TypeInfo type_def_ (type_def_init_ ()); + } + + TypeInfo const& TypeDef:: + static_type_info () { return type_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.hpp new file mode 100644 index 00000000000..a6942b4bd6a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.hpp @@ -0,0 +1,949 @@ +// file : CCF/IDL2/SyntaxTree/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_ELEMENTS_HPP +#define CCF_IDL2_SYNTAX_TREE_ELEMENTS_HPP + +#include <vector> +#include <map> +#include <set> +#include <string> + +//@@ this should go to .cpp +#include <iostream> + +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/ReferenceCounting.hpp" +#include "CCF/CompilerElements/Introspection.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + using ReferenceCounting::StrictPtr; + + + // + // Can be scoped or simple. + // + class Name + { + public: + Name () : name_ () {} + + explicit + Name (std::string const& name) + : name_ (name) + { + } + + bool + operator< (Name const& other) const + { + return name_ < other.name_; + } + + bool + operator== (Name const& other) const + { + return name_ == other.name_; + } + + bool + operator!= (Name const& other) const + { + return name_ == other.name_; + } + + + + protected: + std::string name_; + + friend std::ostream& + operator << (std::ostream& o, Name const& name) + { + return o << name.name_; + } + + friend class ScopedName; + }; + + + // + // + // + class SimpleName : public Name + { + public: + SimpleName () : Name () {} + + explicit + SimpleName (std::string const& name) + : Name (name) + { + //@@ need some checking + } + + bool + operator< (SimpleName const& other) const + { + return name_ < other.name_; + } + + bool + operator== (SimpleName const& other) const + { + return name_ == other.name_; + } + + bool + operator!= (SimpleName const& other) const + { + return name_ != other.name_; + } + + private: + std::string + str () const + { + return name_; + } + + friend SimpleName + operator+ (SimpleName const& s1, std::string const& s2) + { + return SimpleName (s1.str () + s2); + } + + friend SimpleName + operator+ (std::string const& s1, SimpleName const& s2) + { + return SimpleName (s1 + s2.str ()); + } + }; + + + // + // + // + class ScopedName : public Name + { + public: + class InconsistentState {}; + class InvalidArgument {}; + + public: + ScopedName () : Name () {} + + explicit + ScopedName (std::string const& name) throw (InvalidArgument) + : Name (name) + { + try + { + check_state (); + } + catch (InconsistentState const&) + { + throw InvalidArgument (); + } + } + + explicit + ScopedName (Name const& name) throw (InvalidArgument) + : Name (name) + { + try + { + check_state (); + } + catch (InconsistentState const&) + { + throw InvalidArgument (); + } + } + + ScopedName (ScopedName const& scope, Name const& name) + throw (InvalidArgument) + : Name (scope.name_ + "::" + name.name_) + { + try + { + check_state (); + } + catch (InconsistentState const&) + { + throw InvalidArgument (); + } + } + + bool + operator< (ScopedName const& other) const + { + return name_ < other.name_; + } + + bool + operator== (ScopedName const& other) const + { + return name_ == other.name_; + } + + bool + operator!= (ScopedName const& other) const + { + return name_ != other.name_; + } + + public: + SimpleName + simple () const + { + std::string::size_type pos = name_.rfind ("::"); + if (pos == std::string::npos) + { + if (name_.empty ()) return SimpleName(""); //file scope name + else throw InconsistentState (); + } + + return SimpleName(std::string (name_.begin () + pos + 2, + name_.end ())); + } + + class AtRoot {}; + + ScopedName + scope () const throw (AtRoot) + { + std::string::size_type pos = name_.rfind ("::"); + if (pos == std::string::npos) + { + throw AtRoot (); + } + + return ScopedName(std::string (name_.begin (), + name_.begin () + pos)); + } + + Name + in_file_scope () const + { + return Name(std::string (name_.begin () + 2, name_.end ())); + } + + + private: + void + check_state () throw (InconsistentState) + { + if (name_.empty ()) return; + + if (name_.length () < 2) throw InconsistentState (); + + if (name_[0] != ':' || name_[1] != ':') throw InconsistentState (); + + //scan the string + for (std::string::const_iterator i = name_.begin (); + i != name_.end (); + i++) + { + if (*i == ':') + { + if (i + 1 == name_.end () || *(i + 1) != ':') + { + throw InconsistentState (); + } + else + { + i++; //skip "::" + } + } + } + } + + }; + + typedef + std::vector<ScopedName> + ScopedNameList; + + typedef + std::set<ScopedName> + ScopedNameSet; + + + // + // + // + class Order + { + public: + Order (Order const& parent, unsigned long index) + : list_ (parent.list_) + { + list_.push_back (index); + } + + explicit + Order (unsigned long index) + : list_ (1, index) + { + } + + public: + bool + operator == (Order const& other) const + { + return list_ == other.list_; + } + + bool + operator != (Order const& other) const + { + return list_ != other.list_; + } + + bool + operator < (Order const& other) const + { + Iterator i = list_.begin (); + Iterator j = other.list_.begin (); + for (; i != list_.end () && j != other.list_.end (); i++, j++) + { + if (*i > *j) + { + return false; + } + else if (*i < *j) + { + return true; + } + } + + if (j != other.list_.end ()) + { + // we are equal so far but other is longer which means it is after + return true; + } + else + { + return false; + } + } + + bool + suborder (Order const& subj) const + { + if (list_.size () >= subj.list_.size ()) return false; + + for (Iterator i = list_.begin (), j = subj.list_.begin (); + i != list_.end (); + i++, j++) + { + if (*i != *j) return false; + } + + return true; + } + + + private: + typedef + std::vector<unsigned long> + OrderList_; + + typedef + OrderList_::const_iterator + Iterator; + + OrderList_ list_; + + friend std::ostream& + operator << (std::ostream& o, Order const& order) + { + for (Order::OrderList_::const_iterator i = order.list_.begin (); + i != order.list_.end (); + i++) + { + if (i != order.list_.begin ()) o << ':'; + o << *i; + } + + return o; + } + }; + + + // + // + // + class Node; + typedef + StrictPtr<Node> + NodePtr; + + class Node : public virtual Introspection::Object, + public virtual ReferenceCounting::DefaultImpl <> + { + protected: + virtual + ~Node () throw () {} + + Node () + { + type_info (static_type_info ()); + } + + // Dynamic typing + public: + + template <typename Type> + bool + is_a () + { + NodePtr self (ReferenceCounting::add_ref (this)); + return ReferenceCounting::strict_cast<Type>(self) != 0; + } + + template <typename Type> + StrictPtr<Type> + dynamic_type () + { + NodePtr self (ReferenceCounting::add_ref (this)); + return ReferenceCounting::strict_cast<Type>(self); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class Comma : public virtual Node + { + public: + virtual + ~Comma () throw () {} + + Comma () + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + typedef + StrictPtr<Comma> + CommaPtr; + + + + // + // Contains scoped name & reference to DeclarationTable. + // Purpose: provides controlled way of cyclic dependencies + // + // Issues: + // + // @@ Better name for DeclarationRef: + // - DeclarationLink + // + + class Declaration; + + typedef + StrictPtr<Declaration> + DeclarationPtr; + + class DeclarationTable; + + template <typename T, typename Ptr = StrictPtr<T> > + class DeclarationRef + { + public: + class NotInitialized {}; + class DeclarationNotFound {}; + class TypeMismatch {}; + class TableMismatch {}; + + + public: + + DeclarationRef (DeclarationPtr decl); + DeclarationRef (DeclarationTable const& table, ScopedName const& name); + DeclarationRef (DeclarationTable const& table, + ScopedName const& name, + Order const& order); + + //This c-tor constructs an uninitialized reference. + DeclarationRef (DeclarationTable const& table); + + // Note that you can only assign DeclarationRef's associated with + // the same DeclarationTable. + // + DeclarationRef& + operator= (DeclarationRef const& other) throw (TableMismatch) + { + if (&table_ != &(other.table_)) throw TableMismatch (); + + name_ = other.name_; + order_ = other.order_; + initialized_ = other.initialized_; + with_order__ = other.with_order_; + + return *this; + } + + operator bool () const + { + return initialized_; + } + + // Returns first declaration that matches. + Ptr + resolve () const + throw (NotInitialized, DeclarationNotFound, TypeMismatch); + + ScopedName + name () const throw (NotInitialized) + { + if (!initialized_) throw NotInitialized (); + return name_; + } + + private: + DeclarationTable const& table_; + ScopedName name_; + Order order_; + bool initialized_; + bool with_order_; + }; + + + // + // Declaration represents any IDL construct that has a scoped name + // + + class Scope; + + typedef + StrictPtr<Scope> + ScopePtr; + + class Declaration : public virtual Node + { + protected: + virtual + ~Declaration () throw () {} + + Declaration (SimpleName const& name, ScopePtr const& scope); + + // This c-tor is here for Declarations that are not in scope + // e.g. FileScope + Declaration (ScopedName const& name, + Order const& order, + DeclarationTable const& table); + + public: + + ScopedName + name () const; + + Order + order () const; + + class NotInScope {}; // don't cross the edge! ;-) + + virtual ScopePtr + scope () const throw (NotInScope); + + // @@Runtime declaration type information. I could have used RTTI but + // I will also need a human-readable representation (e.g. + // "local interface" instead of "IDL2::SyntaxTree::LocalInterface") + // for diagnistic. + public: + virtual std::string + declaration_class () + { + return "declaration"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + Order order_; + ScopedName name_; + DeclarationRef<Scope> scope_; + }; + + typedef + StrictPtr<Declaration> + DeclarationPtr; + + + // + // + // + template <typename T = DeclarationPtr> + struct DeclarationOrderComparator + { + bool operator () (T const& x, T const& y) const + { + return x->order () < y->order (); + } + }; + + template <typename T = DeclarationPtr> + struct DeclarationNameComparator + { + bool operator () (T const& x, T const& y) const + { + return x->name () < y->name (); + } + }; + + typedef + std::set<DeclarationPtr, DeclarationOrderComparator<> > + DeclarationSet; + + + // + // + // + template <typename T = DeclarationRef<Declaration> > + struct DeclarationRefOrderComparator + { + bool operator () (T const& x, T const& y) const + { + return x.resolve ()->order () < y.resolve ()->order (); + } + }; + + template <typename T = DeclarationRef<Declaration> > + struct DeclarationRefNameComparator + { + bool operator () (T const& x, T const& y) const + { + return x.resolve ()->name () < y.resolve ()->name (); + } + }; + + + // + // Mapping of fq-name -> sequence<Declaration> and some other + // useful stuff. + // + class DeclarationTable + { + private: + typedef + std::map<ScopedName, DeclarationSet> + NameDeclarationMap; + + public: + + typedef + DeclarationSet::const_iterator + Iterator; + + typedef + std::pair<Iterator, Iterator> + IteratorPair; + + class InvalidArgument {}; + class AlreadyExist {}; + + class TypeMismatch {}; + + public: + void + insert (DeclarationPtr d) throw (InvalidArgument, + AlreadyExist, + TypeMismatch); + Iterator + begin () const; + + Iterator + end () const; + + // Returns iterator pair. first points to the first element, + // second points to the element after last. + IteratorPair + lookup (ScopedName const& n) const; + + bool + exist (ScopedName const& n) const + { + IteratorPair pair = lookup (n); + return pair.first != pair.second; + } + + + class DeclarationNotFound {}; + + template <typename T> + StrictPtr<T> + lookup (ScopedName const& n) const + throw (DeclarationNotFound, TypeMismatch); + + template <typename T> + StrictPtr<T> + lookup (ScopedName const& n, Order const& o) const + throw (DeclarationNotFound, TypeMismatch); + + class ResolutionFailure {}; + class NameNotFound : public ResolutionFailure {}; + class PredicateNotMet : public ResolutionFailure {}; + + struct ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw (ResolutionFailure) = 0; + }; + + ScopedName + resolve (Name const& name, + ScopedName const& from, + Order const& before, + ResolvePredicate& p) const throw (ResolutionFailure); + + private: + DeclarationSet decl_set_; + NameDeclarationMap name_decl_map_; + }; + + + // + // Scope + // + class Scope : public virtual Declaration + { + public: + typedef + DeclarationSet::const_iterator + Iterator; + + class InvalidArgument {}; + class AlreadyExist {}; + + protected: + virtual + ~Scope () throw () {} + + // This c-tor is here for Declarations that are not in scope + // e.g. FileScope. + Scope (DeclarationTable& table, + ScopedName const& name, + Order const& order) + : Declaration (name, order, table), + table_ (table), + next_order_ (0) + { + type_info (static_type_info ()); + } + + Scope (SimpleName const& name, ScopePtr const& scope) + : Declaration (name, scope), + table_ (scope->table ()), + next_order_ (0) + { + type_info (static_type_info ()); + } + + public: + + // Inject new Declaration into a scope. Relative position of a new + // entity will be determined based on order (order..! order..!). + void + insert (DeclarationPtr d) throw (InvalidArgument, AlreadyExist); + + Iterator + begin () const; + + Iterator + end () const; + + Order + create_order (); + + // Returns order that would be returned by next call to + // create_order (). + Order + peek_order (); + + + public: + + DeclarationTable const& table () const + { + return table_; + } + + DeclarationTable& table () + { + return table_; + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "scope"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + DeclarationSet content_; + DeclarationTable& table_; + unsigned long next_order_; + }; + + + // + // + // + class TypeDecl : public virtual Declaration + { + protected: + virtual + ~TypeDecl () throw () {} + + TypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope) + { + type_info (static_type_info ()); + } + + // Type completeness + public: + virtual bool + defined () const = 0; + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<TypeDecl> + TypeDeclPtr; + + typedef + DeclarationRef<TypeDecl> + TypeDeclRef; + + + // + // + // + class TypeForwardDecl : public virtual TypeDecl + { + protected: + virtual + ~TypeForwardDecl () throw () {} + + TypeForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Type completeness + public: + virtual bool + defined () const + { + return false; + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class TypeDef : public virtual TypeDecl + { + protected: + virtual + ~TypeDef () throw () {} + + TypeDef (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Type completeness + public: + virtual bool + defined () const + { + return true; + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<TypeDef> + TypeDefPtr; + + typedef + DeclarationRef<TypeDef> + TypeDefRef; + } + } +} + +#include "CCF/IDL2/SyntaxTree/Elements.tpp" + +#endif // CCF_IDL2_SYNTAX_TREE_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.tpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.tpp new file mode 100644 index 00000000000..b2e7361b61f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Elements.tpp @@ -0,0 +1,133 @@ +// file : CCF/IDL2/SyntaxTree/Elements.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + // + // DeclarationRef + // + template <typename T, typename Ptr> + DeclarationRef<T, Ptr>:: + DeclarationRef (DeclarationTable const& table, ScopedName const& name) + : table_ (table), + name_ (name), + order_ (0), + initialized_ (true), + with_order_ (false) + { + } + + template <typename T, typename Ptr> + DeclarationRef<T, Ptr>:: + DeclarationRef (DeclarationTable const& table, + ScopedName const& name, + Order const& order) + : table_ (table), + name_ (name), + order_ (order), + initialized_ (true), + with_order_ (true) + { + } + + template <typename T, typename Ptr> + DeclarationRef<T, Ptr>:: + DeclarationRef (DeclarationPtr decl) + : table_ (decl->scope ()->table ()), + name_ (decl->name ()), + order_ (decl->order ()), + initialized_ (true), + with_order_ (true) + { + } + + template <typename T, typename Ptr> + DeclarationRef<T, Ptr>:: + DeclarationRef (DeclarationTable const& table) + : table_ (table), + name_ (""), + order_ (0), + initialized_ (false), + with_order_ (false) + { + } + + template <typename T, typename Ptr> + Ptr DeclarationRef<T, Ptr>:: + resolve () const throw (NotInitialized, DeclarationNotFound, TypeMismatch) + { + if (!initialized_) throw NotInitialized (); + + try + { + //@@ gcc bug + return with_order_ + ? table_.template lookup<T> (name_, order_) + : table_.template lookup<T> (name_); + } + catch (DeclarationTable::TypeMismatch const&) + { + throw TypeMismatch (); + } + catch (DeclarationTable::DeclarationNotFound const&) + { + throw DeclarationNotFound (); + } + } + + + // + // DeclarationTable + // + template <typename T> + StrictPtr<T> DeclarationTable:: + lookup (ScopedName const& n) const + throw (DeclarationNotFound, TypeMismatch) + { + IteratorPair pair = lookup (n); + + if (pair.first == pair.second) throw DeclarationNotFound (); + + for (; pair.first != pair.second; pair.first++) + { + DeclarationPtr d = (*pair.first); + + //@@ gcc bug + StrictPtr<T> p ((*pair.first)->template dynamic_type<T> ()); + + if (p != 0) return p; + } + + throw TypeMismatch (); + } + + + template <typename T> + StrictPtr<T> DeclarationTable:: + lookup (ScopedName const& n, Order const& o) const + throw (DeclarationNotFound, TypeMismatch) + { + IteratorPair pair = lookup (n); + + for (; pair.first != pair.second; pair.first++) + { + if ((*pair.first)->order () != o) continue; + + //@@ gcc bug + StrictPtr<T> p ((*pair.first)->template dynamic_type<T> ()); + + if (p != 0) return p; + + throw TypeMismatch (); + } + + throw DeclarationNotFound (); + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.cpp new file mode 100644 index 00000000000..a5ac0616441 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.cpp @@ -0,0 +1,300 @@ +// file : CCF/IDL2/SyntaxTree/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/Interface.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + // InterfaceDecl + // + // + namespace + { + TypeInfo + interface_decl_init_ () + { + TypeInfo ti (typeid (InterfaceDecl)); + ti.add_base (Access::PUBLIC, true, TypeDecl::static_type_info ()); + return ti; + } + + TypeInfo interface_decl_ (interface_decl_init_ ()); + } + + TypeInfo const& InterfaceDecl:: + static_type_info () { return interface_decl_; } + + + // InterfaceForwardDecl + // + // + namespace + { + TypeInfo + interface_forward_decl_init_ () + { + TypeInfo ti (typeid (InterfaceForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceDecl::static_type_info ()); + + ti.add_base (Access::PUBLIC, + true, + TypeForwardDecl::static_type_info ()); + return ti; + } + + TypeInfo interface_forward_decl_ (interface_forward_decl_init_ ()); + } + + TypeInfo const& InterfaceForwardDecl:: + static_type_info () { return interface_forward_decl_; } + + + // InterfaceDef + // + // + namespace + { + TypeInfo + interface_def_init_ () + { + TypeInfo ti (typeid (InterfaceDef)); + ti.add_base (Access::PUBLIC, + true, + InterfaceDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, TypeDef::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo interface_def_ (interface_def_init_ ()); + } + + TypeInfo const& InterfaceDef:: + static_type_info () { return interface_def_; } + + + // AbstractInterfaceDecl + // + // + namespace + { + TypeInfo + abstract_interface_decl_init_ () + { + TypeInfo ti (typeid (AbstractInterfaceDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo abstract_interface_decl_ (abstract_interface_decl_init_ ()); + } + + TypeInfo const& AbstractInterfaceDecl:: + static_type_info () { return abstract_interface_decl_; } + + + // AbstractInterfaceForwardDecl + // + // + namespace + { + TypeInfo + abstract_interface_forward_decl_init_ () + { + TypeInfo ti (typeid (AbstractInterfaceForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceForwardDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, + true, + AbstractInterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo abstract_interface_forward_decl_ ( + abstract_interface_forward_decl_init_ ()); + } + + TypeInfo const& AbstractInterfaceForwardDecl:: + static_type_info () { return abstract_interface_forward_decl_; } + + + // AbstractInterfaceDef + // + // + namespace + { + TypeInfo + abstract_interface_def_init_ () + { + TypeInfo ti (typeid (AbstractInterfaceDef)); + ti.add_base (Access::PUBLIC, + true, + AbstractInterfaceDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, InterfaceDef::static_type_info ()); + return ti; + } + + TypeInfo abstract_interface_def_ (abstract_interface_def_init_ ()); + } + + TypeInfo const& AbstractInterfaceDef:: + static_type_info () { return abstract_interface_def_; } + + + // LocalInterfaceDecl + // + // + namespace + { + TypeInfo + local_interface_decl_init_ () + { + TypeInfo ti (typeid (LocalInterfaceDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo local_interface_decl_ (local_interface_decl_init_ ()); + } + + TypeInfo const& LocalInterfaceDecl:: + static_type_info () { return local_interface_decl_; } + + + // LocalInterfaceForwardDecl + // + // + namespace + { + TypeInfo + local_interface_forward_decl_init_ () + { + TypeInfo ti (typeid (LocalInterfaceForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceForwardDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, + true, + LocalInterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo local_interface_forward_decl_ ( + local_interface_forward_decl_init_ ()); + } + + TypeInfo const& LocalInterfaceForwardDecl:: + static_type_info () { return local_interface_forward_decl_; } + + + // LocalInterfaceDef + // + // + namespace + { + TypeInfo + local_interface_def_init_ () + { + TypeInfo ti (typeid (LocalInterfaceDef)); + ti.add_base (Access::PUBLIC, + true, + LocalInterfaceDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, InterfaceDef::static_type_info ()); + return ti; + } + + TypeInfo local_interface_def_ (local_interface_def_init_ ()); + } + + TypeInfo const& LocalInterfaceDef:: + static_type_info () { return local_interface_def_; } + + + // UnconstrainedInterfaceDecl + // + // + namespace + { + TypeInfo + unconstrained_interface_decl_init_ () + { + TypeInfo ti (typeid (UnconstrainedInterfaceDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo unconstrained_interface_decl_ ( + unconstrained_interface_decl_init_ ()); + } + + TypeInfo const& UnconstrainedInterfaceDecl:: + static_type_info () { return unconstrained_interface_decl_; } + + + // UnconstrainedInterfaceForwardDecl + // + // + namespace + { + TypeInfo + unconstrained_interface_forward_decl_init_ () + { + TypeInfo ti (typeid (UnconstrainedInterfaceForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + InterfaceForwardDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, + true, + UnconstrainedInterfaceDecl::static_type_info ()); + return ti; + } + + TypeInfo unconstrained_interface_forward_decl_ ( + unconstrained_interface_forward_decl_init_ ()); + } + + TypeInfo const& UnconstrainedInterfaceForwardDecl:: + static_type_info () { return unconstrained_interface_forward_decl_; } + + + // UnconstrainedInterfaceDef + // + // + namespace + { + TypeInfo + unconstrained_interface_def_init_ () + { + TypeInfo ti (typeid (UnconstrainedInterfaceDef)); + ti.add_base (Access::PUBLIC, + true, + UnconstrainedInterfaceDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, InterfaceDef::static_type_info ()); + return ti; + } + + TypeInfo unconstrained_interface_def_ ( + unconstrained_interface_def_init_ ()); + } + + TypeInfo const& UnconstrainedInterfaceDef:: + static_type_info () { return unconstrained_interface_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.hpp new file mode 100644 index 00000000000..7ab5ffa71b6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Interface.hpp @@ -0,0 +1,569 @@ +// file : CCF/IDL2/SyntaxTree/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_INTERFACE_HPP +#define CCF_IDL2_SYNTAX_TREE_INTERFACE_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // + // + // + class InterfaceDecl : public virtual TypeDecl + { + public: + virtual + ~InterfaceDecl () throw () {} + + InterfaceDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<InterfaceDecl> + InterfaceDeclPtr; + + typedef + DeclarationOrderComparator<InterfaceDeclPtr> + InterfaceDeclOrderComparator; + + typedef + std::set<InterfaceDeclPtr, InterfaceDeclOrderComparator> + InterfaceDeclSet; + + typedef + DeclarationRef<InterfaceDecl> + InterfaceDeclRef; + + typedef + DeclarationRefOrderComparator<InterfaceDeclRef> + InterfaceDeclRefOrderComparator; + + typedef + std::set<InterfaceDeclRef, InterfaceDeclRefOrderComparator> + InterfaceDeclRefSet; + + + // + // + // + class InterfaceForwardDecl : public virtual InterfaceDecl, + public virtual TypeForwardDecl + { + public: + virtual + ~InterfaceForwardDecl () throw () {} + + InterfaceForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + TypeForwardDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class InterfaceDef; + + typedef + StrictPtr<InterfaceDef> + InterfaceDefPtr; + + typedef + DeclarationRef<InterfaceDef> + InterfaceDefRef; + + typedef + DeclarationRefNameComparator<InterfaceDefRef> + InterfaceDefRefNameComparator; + + typedef + std::set<InterfaceDefRef, InterfaceDefRefNameComparator> + InterfaceDefRefSetName; + + class InterfaceDef : public virtual InterfaceDecl, + public virtual TypeDef, + public virtual Scope + { + public: + virtual + ~InterfaceDef () throw () {} + + InterfaceDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope) + { + type_info (static_type_info ()); + + for (ScopedNameSet::const_iterator i = inherits.begin (); + i != inherits.end (); + i++) + { + inherits_.insert (InterfaceDefRef (scope->table (), *i)); + } + } + + public: + typedef + InterfaceDefRefSetName::const_iterator + Iterator; + + Iterator + inherits_begin () const + { + return inherits_.begin (); + } + + Iterator + inherits_end () const + { + return inherits_.end (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + InterfaceDefRefSetName inherits_; + }; + + typedef + DeclarationOrderComparator<InterfaceDefPtr> + InterfaceDefOrderComparator; + + typedef + std::set<InterfaceDefPtr, InterfaceDefOrderComparator> + InterfaceDefSet; + + typedef + DeclarationRefOrderComparator<InterfaceDefRef> + InterfaceDefRefOrderComparator; + + typedef + std::set<InterfaceDefRef, InterfaceDefRefOrderComparator> + InterfaceDefRefSet; + + + // + // + // + class AbstractInterfaceDecl : public virtual InterfaceDecl + { + public: + virtual + ~AbstractInterfaceDecl () throw () {} + + // forward-declared unconstrained interface c-tor + AbstractInterfaceDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "abstract interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<AbstractInterfaceDecl> + AbstractInterfaceDeclPtr; + + // + // + // + class AbstractInterfaceForwardDecl : public virtual InterfaceForwardDecl, + public virtual AbstractInterfaceDecl + { + public: + virtual + ~AbstractInterfaceForwardDecl () throw () {} + + // forward-declared unconstrained interface c-tor + AbstractInterfaceForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + TypeForwardDecl (name, scope), + InterfaceForwardDecl (name, scope), + AbstractInterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "abstract interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class AbstractInterfaceDef : public virtual AbstractInterfaceDecl, + public virtual InterfaceDef + { + public: + virtual + ~AbstractInterfaceDef () throw () {} + + AbstractInterfaceDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + AbstractInterfaceDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + InterfaceDef (name, scope, inherits) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "abstract interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<AbstractInterfaceDef> + AbstractInterfaceDefPtr; + + // + // + // + class LocalInterfaceDecl : public virtual InterfaceDecl + { + public: + virtual + ~LocalInterfaceDecl () throw () {} + + LocalInterfaceDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "local interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<LocalInterfaceDecl> + LocalInterfaceDeclPtr; + + + // + // + // + class LocalInterfaceForwardDecl : public virtual InterfaceForwardDecl, + public virtual LocalInterfaceDecl + { + public: + virtual + ~LocalInterfaceForwardDecl () throw () {} + + LocalInterfaceForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + TypeForwardDecl (name, scope), + InterfaceForwardDecl (name, scope), + LocalInterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "local interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class LocalInterfaceDef : public virtual LocalInterfaceDecl, + public virtual InterfaceDef + { + public: + virtual + ~LocalInterfaceDef () throw () {} + + LocalInterfaceDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + LocalInterfaceDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + InterfaceDef (name, scope, inherits) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "local interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<LocalInterfaceDef> + LocalInterfaceDefPtr; + + + // + // + // + class UnconstrainedInterfaceDecl : public virtual InterfaceDecl + { + public: + virtual + ~UnconstrainedInterfaceDecl () throw () {} + + UnconstrainedInterfaceDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "unconstrained interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<UnconstrainedInterfaceDecl> + UnconstrainedInterfaceDeclPtr; + + + typedef + DeclarationOrderComparator<UnconstrainedInterfaceDeclPtr> + UnconstrainedInterfaceDeclOrderComparator; + + typedef + std::set<UnconstrainedInterfaceDeclPtr, + UnconstrainedInterfaceDeclOrderComparator> + UnconstrainedInterfaceDeclSet; + + + // + // + // + class UnconstrainedInterfaceForwardDecl : + public virtual InterfaceForwardDecl, + public virtual UnconstrainedInterfaceDecl + { + public: + virtual + ~UnconstrainedInterfaceForwardDecl () throw () {} + + UnconstrainedInterfaceForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + TypeForwardDecl (name, scope), + InterfaceForwardDecl (name, scope), + UnconstrainedInterfaceDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "unconstrained interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + // + // + // + class UnconstrainedInterfaceDef : + public virtual UnconstrainedInterfaceDecl, + public virtual InterfaceDef + { + public: + virtual + ~UnconstrainedInterfaceDef () throw () {} + + UnconstrainedInterfaceDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + InterfaceDecl (name, scope), + UnconstrainedInterfaceDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + InterfaceDef (name, scope, inherits) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "unconstrained interface"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<UnconstrainedInterfaceDef> + UnconstrainedInterfaceDefPtr; + + + typedef + DeclarationOrderComparator<UnconstrainedInterfaceDefPtr> + UnconstrainedInterfaceDefOrderComparator; + + typedef + std::set<UnconstrainedInterfaceDefPtr, + UnconstrainedInterfaceDefOrderComparator> + UnconstrainedInterfaceDefSet; + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Makefile.alt new file mode 100644 index 00000000000..718a5c08bbd --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Makefile.alt @@ -0,0 +1,24 @@ +# file : CCF/IDL2/SyntaxTree/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := BuiltIn.cpp \ + Elements.cpp \ + Interface.cpp \ + Module.cpp \ + Operation.cpp \ + Translation.cpp \ + ValueType.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.cpp new file mode 100644 index 00000000000..bb94d9d99b4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.cpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SyntaxTree/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/Module.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + // Module + // + // + namespace + { + TypeInfo + module_init_ () + { + TypeInfo ti (typeid (Module)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo module_ (module_init_ ()); + } + + TypeInfo const& Module:: + static_type_info () { return module_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.hpp new file mode 100644 index 00000000000..df58b1813e1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Module.hpp @@ -0,0 +1,52 @@ +// file : CCF/IDL2/SyntaxTree/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_MODULE_HPP +#define CCF_IDL2_SYNTAX_TREE_MODULE_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + // + // Module + // + class Module : public virtual Scope + { + public: + virtual + ~Module () throw () {} + + Module (SimpleName const& name, ScopePtr const& scope) + : Declaration (name, scope), + Scope (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "module"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<Module> + ModulePtr; + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.cpp new file mode 100644 index 00000000000..889d645d2a9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.cpp @@ -0,0 +1,76 @@ +// file : CCF/IDL2/SyntaxTree/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/Operation.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // AttributeDecl + // + // + namespace + { + TypeInfo + attribute_decl_init_ () + { + TypeInfo ti (typeid (AttributeDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo attribute_decl_ (attribute_decl_init_ ()); + } + + TypeInfo const& AttributeDecl:: + static_type_info () { return attribute_decl_; } + + + // OperationParameter + // + // + namespace + { + TypeInfo + operation_parameter_init_ () + { + TypeInfo ti (typeid (OperationParameter)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo operation_parameter_ (operation_parameter_init_ ()); + } + + TypeInfo const& OperationParameter:: + static_type_info () { return operation_parameter_; } + + + // OperationDecl + // + // + namespace + { + TypeInfo + operation_decl_init_ () + { + TypeInfo ti (typeid (OperationDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo operation_decl_ (operation_decl_init_ ()); + } + + TypeInfo const& OperationDecl:: + static_type_info () { return operation_decl_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.hpp new file mode 100644 index 00000000000..27f43b1df02 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Operation.hpp @@ -0,0 +1,216 @@ +// file : CCF/IDL2/SyntaxTree/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_OPERATION_HPP +#define CCF_IDL2_SYNTAX_TREE_OPERATION_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // + // + // + class AttributeDecl : public virtual Declaration + { + public: + virtual + ~AttributeDecl () throw () {} + + AttributeDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "attribute"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + }; + + typedef + StrictPtr<AttributeDecl> + AttributeDeclPtr; + + // + // + // + class OperationParameter : public virtual Node + { + public: + virtual + ~OperationParameter () throw () {} + + struct Direction + { + enum Value + { + IN, + OUT, + INOUT + }; + + friend std::ostream& + operator<< (std::ostream& o, Value d) + { + if (d == IN) o << "in"; + else if (d == OUT) o << "out"; + else o << "inout"; + return o; + } + }; + + OperationParameter (Direction::Value direction, + ScopedName type, + SimpleName name, + DeclarationTable const& table) + : direction_ (direction), + type_ (table, type), + name_ (name) + { + type_info (static_type_info ()); + } + + public: + Direction::Value + direction () + { + return direction_; + } + + TypeDeclPtr + type () + { + return type_.resolve (); + } + + SimpleName + name () + { + return name_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + Direction::Value direction_; + TypeDeclRef type_; + SimpleName name_; + }; + + typedef + StrictPtr<OperationParameter> + OperationParameterPtr; + + typedef + std::vector<OperationParameterPtr> + OperationParameterList; + + + // + // + // + class OperationDecl : public virtual Declaration + { + public: + virtual + ~OperationDecl () throw () {} + + OperationDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + public: + typedef + OperationParameterList::const_iterator + Iterator; + + void + insert (OperationParameterPtr op) + { + //@@ would be nice to have some checking here + // list should probably be a set(by name) + parameter_list_.push_back (op); + } + + Iterator + begin () + { + return parameter_list_.begin (); + } + + Iterator + end () + { + return parameter_list_.end (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "operation"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + OperationParameterList parameter_list_; + }; + + typedef + StrictPtr<OperationDecl> + OperationDeclPtr; + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.cpp new file mode 100644 index 00000000000..7343f7f1315 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.cpp @@ -0,0 +1,239 @@ +// file : CCF/IDL2/SyntaxTree/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/Translation.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // FileScope + // + // + namespace + { + TypeInfo + file_scope_init_ () + { + TypeInfo ti (typeid (FileScope)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo file_scope_ (file_scope_init_ ()); + } + + TypeInfo const& FileScope:: + static_type_info () { return file_scope_; } + + FileScope:: + FileScope (DeclarationTable& table, Order const& order) + : Declaration (ScopedName (""), order, table), + Scope (table, ScopedName (""), order) + { + type_info (static_type_info ()); + } + + + // TranslationRegion + // + // + namespace + { + TypeInfo + translation_region_init_ () + { + TypeInfo ti (typeid (TranslationRegion)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo translation_region_ (translation_region_init_ ()); + } + + TypeInfo const& TranslationRegion:: + static_type_info () { return translation_region_; } + + void TranslationRegion:: + insert (TranslationRegionPtr const& tr) throw (InvalidArgument) + { + if (tr == 0) throw InvalidArgument (); + + region_list_.push_back (tr); + } + + TranslationRegion::Iterator TranslationRegion:: + begin () const + { + return region_list_.begin (); + } + + TranslationRegion::Iterator TranslationRegion:: + end () const + { + return region_list_.end (); + } + + + // IncludeTranslationRegion + // + // + namespace + { + TypeInfo + include_translation_region_init_ () + { + TypeInfo ti (typeid (IncludeTranslationRegion)); + ti.add_base (Access::PUBLIC, + true, + TranslationRegion::static_type_info ()); + return ti; + } + + TypeInfo include_translation_region_ ( + include_translation_region_init_ ()); + } + + TypeInfo const& IncludeTranslationRegion:: + static_type_info () { return include_translation_region_; } + + + // UserIncludeTranslationRegion + // + // + namespace + { + TypeInfo + user_include_translation_region_init_ () + { + TypeInfo ti (typeid (UserIncludeTranslationRegion)); + ti.add_base (Access::PUBLIC, + true, + IncludeTranslationRegion::static_type_info ()); + return ti; + } + + TypeInfo user_include_translation_region_ ( + user_include_translation_region_init_ ()); + } + + TypeInfo const& UserIncludeTranslationRegion:: + static_type_info () { return user_include_translation_region_; } + + + // SysIncludeTranslationRegion + // + // + namespace + { + TypeInfo + sys_include_translation_region_init_ () + { + TypeInfo ti (typeid (SysIncludeTranslationRegion)); + ti.add_base (Access::PUBLIC, + true, + IncludeTranslationRegion::static_type_info ()); + return ti; + } + + TypeInfo sys_include_translation_region_ ( + sys_include_translation_region_init_ ()); + } + + TypeInfo const& SysIncludeTranslationRegion:: + static_type_info () { return sys_include_translation_region_; } + + + // ImpliedIncludeTranslationRegion + // + // + namespace + { + TypeInfo + implied_include_translation_region_init_ () + { + TypeInfo ti (typeid (ImpliedIncludeTranslationRegion)); + ti.add_base (Access::PUBLIC, + true, + IncludeTranslationRegion::static_type_info ()); + return ti; + } + + TypeInfo implied_include_translation_region_ ( + implied_include_translation_region_init_ ()); + } + + TypeInfo const& ImpliedIncludeTranslationRegion:: + static_type_info () { return implied_include_translation_region_; } + + + // PrincipalTranslationRegion + // + // + namespace + { + TypeInfo + principal_translation_region_init_ () + { + TypeInfo ti (typeid (PrincipalTranslationRegion)); + ti.add_base (Access::PUBLIC, + true, + TranslationRegion::static_type_info ()); + return ti; + } + + TypeInfo principal_translation_region_ ( + principal_translation_region_init_ ()); + } + + TypeInfo const& PrincipalTranslationRegion:: + static_type_info () { return principal_translation_region_; } + + + // TranslationUnit + // + // + namespace + { + TypeInfo + translation_unit_init_ () + { + TypeInfo ti (typeid (TranslationUnit)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo translation_unit_ (translation_unit_init_ ()); + } + + TypeInfo const& TranslationUnit:: + static_type_info () { return translation_unit_; } + + void TranslationUnit:: + insert (TranslationRegionPtr const& tr) throw (InvalidArgument) + { + if (tr == 0) throw InvalidArgument (); + + region_list_.push_back (tr); + } + + TranslationUnit::Iterator TranslationUnit:: + begin () const + { + return region_list_.begin (); + } + + TranslationUnit::Iterator TranslationUnit:: + end () const + { + return region_list_.end (); + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.hpp new file mode 100644 index 00000000000..9735613632b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/Translation.hpp @@ -0,0 +1,387 @@ +// file : CCF/IDL2/SyntaxTree/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP +#define CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // + // + // + class FileScope : public virtual Scope + { + public: + virtual + ~FileScope () throw () {} + + FileScope (DeclarationTable& table, Order const& order); + + virtual ScopePtr + scope () const throw (NotInScope) + { + throw NotInScope (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "file scope"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<FileScope> + FileScopePtr; + + typedef + DeclarationOrderComparator<FileScopePtr> + FileScopeOrderComparator; + + typedef + std::set<FileScopePtr, FileScopeOrderComparator> + FileScopeSet; + + + // + // + // + class TranslationRegion; + + typedef + StrictPtr<TranslationRegion> + TranslationRegionPtr; + + typedef + std::vector<TranslationRegionPtr> + TranslationRegionList; + + class TranslationRegion : public virtual Node + { + public: + virtual + ~TranslationRegion () throw () {} + + TranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : order_ (order), + table_ (table), + next_order_ (0), + file_path_ (file_path) + { + type_info (static_type_info ()); + + scope_ = FileScopePtr (new FileScope (table_, Order (order_, 1))); + + //@@ eh! + table.insert (scope_); + } + + public: + DeclarationTable const& + table () const + { + return table_; + } + + DeclarationTable& + table () + { + return table_; + } + + public: + Order + create_order () + { + return Order (Order (order_, 0), next_order_++); + } + + public: + FileScopePtr + scope () + { + return scope_; + } + + public: + virtual fs::path + file_path () const + { + return file_path_; + } + + public: + class InvalidArgument {}; + + void + insert (TranslationRegionPtr const& tr) throw (InvalidArgument); + + typedef + TranslationRegionList::const_iterator + Iterator; + + Iterator + begin () const; + + Iterator + end () const; + + public: + static Introspection::TypeInfo const& + static_type_info (); + + + private: + Order order_; + FileScopePtr scope_; + DeclarationTable& table_; + unsigned long next_order_; + TranslationRegionList region_list_; + fs::path file_path_; + }; + + + // + // + // + class IncludeTranslationRegion : public virtual TranslationRegion + { + public: + virtual + ~IncludeTranslationRegion () throw () {} + + IncludeTranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : TranslationRegion (file_path, table, order) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<IncludeTranslationRegion> + IncludeTranslationRegionPtr; + + + // + // + // + class UserIncludeTranslationRegion : + public virtual IncludeTranslationRegion + { + public: + virtual + ~UserIncludeTranslationRegion () throw () {} + + UserIncludeTranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : TranslationRegion (file_path, table, order), + IncludeTranslationRegion (file_path, table, order) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<UserIncludeTranslationRegion> + UserIncludeTranslationRegionPtr; + + // + // + // + class SysIncludeTranslationRegion : + public virtual IncludeTranslationRegion + { + public: + virtual + ~SysIncludeTranslationRegion () throw () {} + + SysIncludeTranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : TranslationRegion (file_path, table, order), + IncludeTranslationRegion (file_path, table, order) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<SysIncludeTranslationRegion> + SysIncludeTranslationRegionPtr; + + // + // + // + class ImpliedIncludeTranslationRegion : + public virtual IncludeTranslationRegion + { + public: + virtual + ~ImpliedIncludeTranslationRegion () throw () {} + + ImpliedIncludeTranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : TranslationRegion (file_path, table, order), + IncludeTranslationRegion (file_path, table, order) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<ImpliedIncludeTranslationRegion> + ImpliedIncludeTranslationRegionPtr; + + + // + // + // + class PrincipalTranslationRegion : public virtual TranslationRegion + { + public: + virtual + ~PrincipalTranslationRegion () throw () {} + + PrincipalTranslationRegion (fs::path const& file_path, + DeclarationTable& table, + Order const& order) + : TranslationRegion (file_path, table, order) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<PrincipalTranslationRegion> + PrincipalTranslationRegionPtr; + + + // + // + // + class TranslationUnit : public virtual Node + { + public: + virtual + ~TranslationUnit () throw () {} + + TranslationUnit () + : order_ (0), + next_order_ (0) + { + type_info (static_type_info ()); + } + + public: + + DeclarationTable const& + table () const + { + return table_; + } + + DeclarationTable& + table () + { + return table_; + } + + public: + Order + create_order () + { + return Order (order_, next_order_++); + } + + public: + class InvalidArgument {}; + + void + insert (TranslationRegionPtr const& tr) throw (InvalidArgument); + + typedef + TranslationRegionList::const_iterator + Iterator; + + Iterator + begin () const; + + Iterator + end () const; + + + class NotFound {}; + + PrincipalTranslationRegionPtr + principal_translation_region () const throw (NotFound) + { + for (Iterator i = begin (); i != end (); i++) + { + if ((*i)->is_a<PrincipalTranslationRegion> ()) + { + return (*i)->dynamic_type<PrincipalTranslationRegion> (); + } + } + + throw NotFound (); + } + + private: + Order order_; + DeclarationTable table_; + unsigned long next_order_; + TranslationRegionList region_list_; + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<TranslationUnit> + TranslationUnitPtr; + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_TRANSLATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.cpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.cpp new file mode 100644 index 00000000000..ba7ab7dbd58 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.cpp @@ -0,0 +1,86 @@ +// file : CCF/IDL2/SyntaxTree/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/SyntaxTree/ValueType.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // ValueDecl + // + // + namespace + { + TypeInfo + value_decl_init_ () + { + TypeInfo ti (typeid (ValueTypeDecl)); + ti.add_base (Access::PUBLIC, true, TypeDecl::static_type_info ()); + return ti; + } + + TypeInfo value_decl_ (value_decl_init_ ()); + } + + TypeInfo const& ValueTypeDecl:: + static_type_info () { return value_decl_; } + + + // ValueTypeForwardDecl + // + // + namespace + { + TypeInfo + value_forward_decl_init_ () + { + TypeInfo ti (typeid (ValueTypeForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + ValueTypeDecl::static_type_info ()); + + ti.add_base (Access::PUBLIC, + true, + TypeForwardDecl::static_type_info ()); + return ti; + } + + TypeInfo value_forward_decl_ (value_forward_decl_init_ ()); + } + + TypeInfo const& ValueTypeForwardDecl:: + static_type_info () { return value_forward_decl_; } + + + // ValueTypeDef + // + // + namespace + { + TypeInfo + value_def_init_ () + { + TypeInfo ti (typeid (ValueTypeDef)); + ti.add_base (Access::PUBLIC, + true, + ValueTypeDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, TypeDef::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo value_def_ (value_def_init_ ()); + } + + TypeInfo const& ValueTypeDef:: + static_type_info () { return value_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.hpp b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.hpp new file mode 100644 index 00000000000..66ee9714724 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SyntaxTree/ValueType.hpp @@ -0,0 +1,191 @@ +// file : CCF/IDL2/SyntaxTree/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_SYNTAX_TREE_VALUE_TYPE_HPP +#define CCF_IDL2_SYNTAX_TREE_VALUE_TYPE_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SyntaxTree + { + + // + // + // + class ValueTypeDecl : public virtual TypeDecl + { + public: + virtual + ~ValueTypeDecl () throw () {} + + ValueTypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "value"; + } + + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<ValueTypeDecl> + ValueTypeDeclPtr; + + typedef + DeclarationOrderComparator<ValueTypeDeclPtr> + ValueTypeDeclOrderComparator; + + typedef + std::set<ValueTypeDeclPtr, ValueTypeDeclOrderComparator> + ValueTypeDeclSet; + + typedef + DeclarationRef<ValueTypeDecl> + ValueTypeDeclRef; + + typedef + DeclarationRefOrderComparator<ValueTypeDeclRef> + ValueTypeDeclRefOrderComparator; + + typedef + std::set<ValueTypeDeclRef, ValueTypeDeclRefOrderComparator> + ValueTypeDeclRefSet; + + + // + // + // + class ValueTypeForwardDecl : public virtual ValueTypeDecl, + public virtual TypeForwardDecl + { + public: + virtual + ~ValueTypeForwardDecl () throw () {} + + ValueTypeForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + TypeForwardDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "value"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class ValueTypeDef; + + typedef + StrictPtr<ValueTypeDef> + ValueTypeDefPtr; + + typedef + DeclarationRef<ValueTypeDef> + ValueTypeDefRef; + + typedef + DeclarationRefNameComparator<ValueTypeDefRef> + ValueTypeDefRefNameComparator; + + typedef + std::set<ValueTypeDefRef, ValueTypeDefRefNameComparator> + ValueTypeDefRefSetName; + + class ValueTypeDef : public virtual ValueTypeDecl, + public virtual TypeDef, + public virtual Scope + { + public: + virtual + ~ValueTypeDef () throw () {} + + ValueTypeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope) + { + type_info (static_type_info ()); + + for (ScopedNameSet::const_iterator i = inherits.begin (); + i != inherits.end (); + i++) + { + inherits_.insert (ValueTypeDefRef (scope->table (), *i)); + } + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "value"; + } + + public: + static Utility::Introspection::TypeInfo const& + static_type_info (); + + private: + ValueTypeDefRefSetName inherits_; + }; + + typedef + DeclarationOrderComparator<ValueTypeDefPtr> + ValueTypeDefOrderComparator; + + typedef + std::set<ValueTypeDefPtr, ValueTypeDefOrderComparator> + ValueTypeDefSet; + + typedef + DeclarationRefOrderComparator<ValueTypeDefRef> + ValueTypeDefRefOrderComparator; + + typedef + std::set<ValueTypeDefRef, ValueTypeDefRefOrderComparator> + ValueTypeDefRefSet; + + } + } +} + +#endif // CCF_IDL2_SYNTAX_TREE_VALUE_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Token.cpp b/TAO/CIAO/CCF/CCF/IDL2/Token.cpp new file mode 100644 index 00000000000..ac656f87aa4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Token.cpp @@ -0,0 +1,13 @@ +// file : CCF/IDL2/Token.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL2/Token.hpp b/TAO/CIAO/CCF/CCF/IDL2/Token.hpp new file mode 100644 index 00000000000..d558ded6054 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Token.hpp @@ -0,0 +1,189 @@ +// file : CCF/IDL2/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TOKEN_HPP +#define CCF_IDL2_TOKEN_HPP + +#include <vector> +#include <string> +#include <ostream> + +#include "CCF/CompilerElements/ReferenceCounting.hpp" + +namespace CCF +{ + namespace IDL2 + { + // + // + // + class Token : public ReferenceCounting::DefaultImpl <> + { + protected: + Token (std::string lexeme, unsigned long line) + : lexeme_ (lexeme), + line_ (line) + { + } + + public: + virtual ~Token () throw () {} + + public: + std::string + lexeme () const + { + return lexeme_; + } + + unsigned long + line () const + { + return line_; + } + + private: + std::string lexeme_; + unsigned long line_; + }; + + typedef + ReferenceCounting::StrictPtr<Token> + TokenPtr; + + typedef + std::vector<TokenPtr> + TokenList; + + inline std::ostream& + operator<< (std::ostream& o, TokenPtr const& t) + { + if (t != 0) o << t->lexeme (); + return o; + } + + // + // + // + class EndOfStream : public Token + { + public: + EndOfStream (unsigned long line) + : Token ("<end-of-stream>", line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<EndOfStream> + EndOfStreamPtr; + + // + // + // + class Keyword : public Token + { + public: + Keyword (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Keyword> + KeywordPtr; + + + + // + // + // + class Punctuation : public Token + { + public: + Punctuation (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + + virtual + ~Punctuation () throw () {} + }; + + typedef + ReferenceCounting::StrictPtr<Punctuation> + PunctuationPtr; + + + // + // + // + class Identifier : public Token + { + public: + Identifier (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Identifier> + IdentifierPtr; + + + // + // + // + class SimpleIdentifier : public Identifier + { + public: + SimpleIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<SimpleIdentifier> + SimpleIdentifierPtr; + + + // + // + // + class ScopedIdentifier : public Identifier + { + public: + ScopedIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<ScopedIdentifier> + ScopedIdentifierPtr; + + + // + // + // + class StringLiteral : public Token + { + public: + StringLiteral (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<StringLiteral> + StringLiteralPtr; + } +} + +#endif // CCF_IDL2_TOKEN_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal.hpp new file mode 100644 index 00000000000..227f834b176 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal.hpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_HPP +#define CCF_IDL2_TRAVERSAL_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/Traversal/BuiltIn.hpp" +#include "CCF/IDL2/Traversal/Interface.hpp" +#include "CCF/IDL2/Traversal/Module.hpp" +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL2/Traversal/Translation.hpp" + +#endif // CCF_IDL2_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.cpp new file mode 100644 index 00000000000..672470e293c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/BuiltIn.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/BuiltIn.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.hpp new file mode 100644 index 00000000000..9eb02952f82 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/BuiltIn.hpp @@ -0,0 +1,161 @@ +// file : CCF/IDL2/Traversal/BuiltIn.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_BUILT_IN_HPP +#define CCF_IDL2_TRAVERSAL_BUILT_IN_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/BuiltIn.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // + // + // + struct BuiltInTypeDef : Traverser + { + typedef + SyntaxTree::BuiltInTypeDefPtr + NodePtr; + + BuiltInTypeDef () + { + map (typeid (SyntaxTree::BuiltInTypeDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::BuiltInTypeDef> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Void : Traverser + { + typedef + SyntaxTree::VoidPtr + NodePtr; + + Void () + { + map (typeid (SyntaxTree::Void), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Void> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Long : Traverser + { + typedef + SyntaxTree::LongPtr + NodePtr; + + Long () + { + map (typeid (SyntaxTree::Long), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Long> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Boolean : Traverser + { + typedef + SyntaxTree::BooleanPtr + NodePtr; + + Boolean () + { + map (typeid (SyntaxTree::Boolean), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Boolean> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct String : Traverser + { + typedef + SyntaxTree::StringPtr + NodePtr; + + String () + { + map (typeid (SyntaxTree::String), this); + } + + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::String> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_BUILT_IN_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp new file mode 100644 index 00000000000..8683660823b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp @@ -0,0 +1,150 @@ +// file : CCF/IDL2/Traversal/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/Elements.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // Dispatcher + // + // + + struct TypeInfoComparator + { + bool + operator () (TypeInfo const& x, TypeInfo const& y) const + { + return x.type_id () < y.type_id (); + } + }; + + typedef + std::map<TypeInfo, unsigned long, TypeInfoComparator> + LevelMap; + + typedef + std::set<TypeInfo, TypeInfoComparator> + TypeInfoSet; + + unsigned long + compute_levels (TypeInfo const& ti, unsigned long cur, LevelMap& map) + { + unsigned long ret = cur; + + if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur; + + for (TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + unsigned long t = compute_levels (i->type_info (), cur + 1, map); + if (t > ret) ret = t; + } + + return ret; + } + + void + flatten_tree (TypeInfo const& ti, TypeInfoSet& set) + { + set.insert (ti); + + for (TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + flatten_tree (i->type_info (), set); + } + } + + void Dispatcher:: + dispatch (SyntaxTree::NodePtr const& n) + { + LevelMap levels; + + unsigned long max = compute_levels (n->type_info (), 0, levels); + + //cerr << "starting dispatch process for " + // << n->type_info ().type_id () << " with " + // << max << " levels" << endl; + + for (unsigned long l = 0; l < max + 1; l++) + { + TypeInfoSet dispatched; + + for (LevelMap::const_iterator i = levels.begin (); + i != levels.end (); + i++) + { + if (i->second == l) + { + TraversalMap::const_iterator v = + traversal_map_.find (i->first.type_id ()); + + if (v != traversal_map_.end () && !(v->second.suppressed)) + { + //cerr << "dispatching traverser for " + // << n->type_info ().type_id () << " as " + // << i->first.type_id () << endl; + + v->second.traverser->traverse (n); + flatten_tree (i->first, dispatched); + } + } + } + + // Remove traversed types from level map. + for (TypeInfoSet::const_iterator i = dispatched.begin (); + i != dispatched.end (); + i++) + { + levels.erase (*i); + } + } + } + + // Scope + // + // + + void Scope:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void Scope:: + pre (NodePtr const&) + { + } + + void Scope:: + scope (NodePtr const& n) + { + //cerr << "starting traversal of scope " << n->name () << endl; + + delegate_scope (n); + + //cerr << "finishing traversal of scope " << n->name () << endl; + } + + void Scope:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp new file mode 100644 index 00000000000..be61733e792 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp @@ -0,0 +1,356 @@ +// file : CCF/IDL2/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_ELEMENTS_HPP +#define CCF_IDL2_TRAVERSAL_ELEMENTS_HPP + +#include <map> +#include <vector> + +#include "CCF/CompilerElements/Introspection.hpp" + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // + // + // + class TraverserInterface + { + protected: + virtual + ~TraverserInterface () + { + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) = 0; + + friend class Dispatcher; + }; + + + // + // + // + class Dispatcher + { + public: + virtual + ~Dispatcher () + { + } + + virtual void + dispatch (SyntaxTree::NodePtr const& n); + + protected: + + class Ambiguous {}; + + void + map (Introspection::TypeId id, + TraverserInterface* t, + bool suppress_ambiguity = false) + throw (Ambiguous) + { + if (!traversal_map_.insert (std::make_pair (id, t)).second) + { + if (suppress_ambiguity) + { + traversal_map_[id].suppressed = true; + } + else + { + throw Ambiguous (); + } + } + } + + private: + + struct TraverserDescriptor + { + TraverserDescriptor (TraverserInterface* t = 0) + : traverser (t), + suppressed (false) + { + } + + TraverserInterface* traverser; + bool suppressed; + }; + + typedef + std::map<Introspection::TypeId, TraverserDescriptor> + TraversalMap; + + public: + typedef + TraversalMap::const_iterator + Iterator; + + Iterator + begin () const + { + return traversal_map_.begin (); + } + + Iterator + end () const + { + return traversal_map_.end (); + } + + private: + TraversalMap traversal_map_; + }; + + + // + // + // + class Discriminator : public virtual Dispatcher + { + public: + virtual void + add (Dispatcher* d) throw (Ambiguous) + { + for (Iterator i = d->begin (); i != d->end (); i++) + { + map (i->first, i->second.traverser, true); + } + } + }; + + + // + // + // + class Traverser : public TraverserInterface, + public virtual Dispatcher + { + public: + virtual void + add_delegate (Dispatcher* d) + { + delegates_.push_back (d); + } + + protected: + virtual bool + delegate (SyntaxTree::NodePtr const& n) const + { + if (delegates_.empty ()) return false; + + for (DispatcherList::const_iterator i = delegates_.begin (); + i != delegates_.end (); + i++) + { + (*i)->dispatch (n); + } + + return true; + } + + protected: + typedef + std::vector<Dispatcher*> + DispatcherList; + + DispatcherList delegates_; + }; + + + // + // + // + class ScopeTraverser : public Traverser + { + public: + virtual void + add_scope_delegate (Dispatcher* d) + { + scope_delegates_.push_back (d); + } + + protected: + virtual void + delegate_scope (SyntaxTree::ScopePtr const& s) + { + for (SyntaxTree::Scope::Iterator n = s->begin (); + n != s->end (); + n++) + { + dispatch (*n); + + for (DispatcherList::const_iterator i = scope_delegates_.begin (); + i != scope_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + } + } + } + + protected: + DispatcherList scope_delegates_; + }; + + + // + // + // + struct Comma : Traverser + { + typedef + SyntaxTree::CommaPtr + NodePtr; + + Comma () + { + map (typeid (SyntaxTree::Comma), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Comma> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Declaration : Traverser + { + typedef + SyntaxTree::DeclarationPtr + NodePtr; + + Declaration () + { + map (typeid (SyntaxTree::Declaration), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Declaration> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Scope : ScopeTraverser + { + typedef + SyntaxTree::ScopePtr + NodePtr; + + Scope () + { + map (typeid (SyntaxTree::Scope), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Scope> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct TypeDecl : Traverser + { + typedef + SyntaxTree::TypeDeclPtr + NodePtr; + + TypeDecl () + { + map (typeid (SyntaxTree::TypeDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::TypeDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct TypeDef : Traverser + { + typedef + SyntaxTree::TypeDefPtr + NodePtr; + + TypeDef () + { + map (typeid (SyntaxTree::TypeDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::TypeDef> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp new file mode 100644 index 00000000000..9a1e78454cf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp @@ -0,0 +1,155 @@ +// file : CCF/IDL2/Traversal/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // InterfaceDecl + // + // + + + // InterfaceDef + // + // + + void InterfaceDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void InterfaceDef:: + pre (NodePtr const&) + { + } + + void InterfaceDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void InterfaceDef:: + post (NodePtr const&) + { + } + + // AbstractInterfaceDecl + // + // + + // AbstractInterfaceDef + // + // + + void AbstractInterfaceDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void AbstractInterfaceDef:: + pre (NodePtr const&) + { + } + + void AbstractInterfaceDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void AbstractInterfaceDef:: + post (NodePtr const&) + { + } + + // LocalInterfaceDecl + // + // + + // LocalInterfaceDef + // + // + + void LocalInterfaceDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void LocalInterfaceDef:: + pre (NodePtr const&) + { + } + + void LocalInterfaceDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void LocalInterfaceDef:: + post (NodePtr const&) + { + } + + // UnconstrainedInterfaceDecl + // + // + + // UnconstrainedInterfaceDef + // + // + + void UnconstrainedInterfaceDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void UnconstrainedInterfaceDef:: + pre (NodePtr const&) + { + } + + void UnconstrainedInterfaceDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void UnconstrainedInterfaceDef:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp new file mode 100644 index 00000000000..641fae8da7b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp @@ -0,0 +1,269 @@ +// file : CCF/IDL2/Traversal/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_INTERFACE_HPP +#define CCF_IDL2_TRAVERSAL_INTERFACE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // + // + // + struct InterfaceDecl : Traverser + { + typedef + SyntaxTree::InterfaceDeclPtr + NodePtr; + + InterfaceDecl () + { + map (typeid (SyntaxTree::InterfaceDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::InterfaceDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct InterfaceDef : ScopeTraverser + { + typedef + SyntaxTree::InterfaceDefPtr + NodePtr; + + InterfaceDef () + { + map (typeid (SyntaxTree::InterfaceDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::InterfaceDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct AbstractInterfaceDecl : Traverser + { + typedef + SyntaxTree::AbstractInterfaceDeclPtr + NodePtr; + + AbstractInterfaceDecl () + { + map (typeid (SyntaxTree::AbstractInterfaceDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::AbstractInterfaceDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct AbstractInterfaceDef : ScopeTraverser + { + typedef + SyntaxTree::AbstractInterfaceDefPtr + NodePtr; + + AbstractInterfaceDef () + { + map (typeid (SyntaxTree::AbstractInterfaceDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::AbstractInterfaceDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct LocalInterfaceDecl : Traverser + { + typedef + SyntaxTree::LocalInterfaceDeclPtr + NodePtr; + + LocalInterfaceDecl () + { + map (typeid (SyntaxTree::LocalInterfaceDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::LocalInterfaceDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct LocalInterfaceDef : ScopeTraverser + { + typedef + SyntaxTree::LocalInterfaceDefPtr + NodePtr; + + LocalInterfaceDef () + { + map (typeid (SyntaxTree::LocalInterfaceDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::LocalInterfaceDef> ()); + } + + virtual void + traverse (NodePtr const& n); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct UnconstrainedInterfaceDecl : Traverser + { + typedef + SyntaxTree::UnconstrainedInterfaceDeclPtr + NodePtr; + + UnconstrainedInterfaceDecl () + { + map (typeid (SyntaxTree::UnconstrainedInterfaceDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::UnconstrainedInterfaceDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct UnconstrainedInterfaceDef : ScopeTraverser + { + typedef + SyntaxTree::UnconstrainedInterfaceDefPtr + NodePtr; + + UnconstrainedInterfaceDef () + { + map (typeid (SyntaxTree::UnconstrainedInterfaceDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::UnconstrainedInterfaceDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt new file mode 100644 index 00000000000..edf265d9492 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt @@ -0,0 +1,23 @@ +# file : CCF/IDL2/Traversal/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := BuiltIn.cpp \ + Elements.cpp \ + Interface.cpp \ + Module.cpp \ + Operation.cpp \ + Translation.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp new file mode 100644 index 00000000000..e285ad9d225 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp @@ -0,0 +1,46 @@ +// file : CCF/IDL2/Traversal/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // Module + // + // + + void Module:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void Module:: + pre (NodePtr const&) + { + } + + void Module:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void Module:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp new file mode 100644 index 00000000000..c7ff4966931 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp @@ -0,0 +1,53 @@ +// file : CCF/IDL2/Traversal/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_MODULE_HPP +#define CCF_IDL2_TRAVERSAL_MODULE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct Module : ScopeTraverser + { + typedef + SyntaxTree::ModulePtr + NodePtr; + + Module () + { + map (typeid (SyntaxTree::Module), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Module> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp new file mode 100644 index 00000000000..f02bba8675f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp @@ -0,0 +1,148 @@ +// file : CCF/IDL2/Traversal/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // AttributeDecl + // + // + + void AttributeDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void AttributeDecl:: + pre (NodePtr const&) + { + } + + void AttributeDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void AttributeDecl:: + post (NodePtr const&) + { + } + + + // OperationParameter + // + // + + void OperationParameter:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + void OperationParameter:: + pre (NodePtr const&) + { + } + + void OperationParameter:: + type (NodePtr const& n) + { + Dispatcher* d = this; + + switch (n->direction ()) + { + case SyntaxTree::OperationParameter::Direction::IN: + { + if (in_) d = in_; + break; + } + case SyntaxTree::OperationParameter::Direction::OUT: + { + if (out_) d = out_; + break; + } + case SyntaxTree::OperationParameter::Direction::INOUT: + { + if (inout_) d = inout_; + break; + } + } + + d->dispatch (n->type ()); + } + + void OperationParameter:: + post (NodePtr const&) + { + } + + // OperationDecl + // + // + + void OperationDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + name (n); + parameters (n); + post (n); + } + } + + + void OperationDecl:: + pre (NodePtr const&) + { + } + + void OperationDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void OperationDecl:: + name (NodePtr const&) + { + } + + void OperationDecl:: + parameters (NodePtr const& n) + { + parameter_delegate (n); + } + + void OperationDecl:: + post (NodePtr const&) + { + } + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp new file mode 100644 index 00000000000..f2503a376ad --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp @@ -0,0 +1,202 @@ +// file : CCF/IDL2/Traversal/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_OPERATION_HPP +#define CCF_IDL2_TRAVERSAL_OPERATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // + // + // + class OperationTraverser : public Traverser + { + public: + OperationTraverser (Dispatcher* type) + : type_ (type) + { + } + + public: + virtual void + add_parameter_delegate (Dispatcher* d) + { + parameter_delegates_.push_back (d); + } + + protected: + virtual void + parameter_delegate (SyntaxTree::OperationDeclPtr const& op) + { + SyntaxTree::CommaPtr comma (new SyntaxTree::Comma); + + for (SyntaxTree::OperationDecl::Iterator n = op->begin (); + n != op->end (); + n++) + { + bool need_comma = n + 1 != op->end (); + + if (parameter_delegates_.empty ()) + { + dispatch (*n); + if (need_comma) dispatch (comma); + } + else + { + for (DispatcherList::const_iterator i = + parameter_delegates_.begin (); + i != parameter_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + if (need_comma) (*i)->dispatch (comma); + } + } + } + } + + protected: + Dispatcher* type_; + DispatcherList parameter_delegates_; + }; + + + // + // + // + struct AttributeDecl : Traverser + { + typedef + SyntaxTree::AttributeDeclPtr + NodePtr; + + AttributeDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::AttributeDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::AttributeDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct OperationParameter : Traverser + { + typedef + SyntaxTree::OperationParameterPtr + NodePtr; + + OperationParameter (Dispatcher* in, + Dispatcher* out, + Dispatcher* inout) + : in_ (in), out_ (out), inout_ (inout) + { + map (typeid (SyntaxTree::OperationParameter), this); + } + + OperationParameter () + : in_ (0), out_ (0), inout_ (0) + { + map (typeid (SyntaxTree::OperationParameter), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::OperationParameter> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* in_; + Dispatcher* out_; + Dispatcher* inout_; + }; + + + // + // + // + struct OperationDecl : OperationTraverser + { + typedef + SyntaxTree::OperationDeclPtr + NodePtr; + + OperationDecl (Dispatcher* type = 0) + : OperationTraverser (type) + { + map (typeid (SyntaxTree::OperationDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::OperationDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + name (NodePtr const&); + + virtual void + parameters (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp new file mode 100644 index 00000000000..8cfa42efc3f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp @@ -0,0 +1,316 @@ +// file : CCF/IDL2/Traversal/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL2/Traversal/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // FileScope + // + // + + void FileScope:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void FileScope:: + pre (NodePtr const&) + { + } + + void FileScope:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void FileScope:: + post (NodePtr const&) + { + } + + // TranslationRegion + // + // + + void TranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void TranslationRegion:: + pre (NodePtr const&) + { + } + + void TranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void TranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void TranslationRegion:: + post (NodePtr const&) + { + } + + // IncludeTranslationRegion + // + // + + void IncludeTranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void IncludeTranslationRegion:: + pre (NodePtr const&) + { + } + + void IncludeTranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void IncludeTranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void IncludeTranslationRegion:: + post (NodePtr const&) + { + } + + + // UserIncludeTranslationRegion + // + // + + void UserIncludeTranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void UserIncludeTranslationRegion:: + pre (NodePtr const&) + { + } + + void UserIncludeTranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void UserIncludeTranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void UserIncludeTranslationRegion:: + post (NodePtr const&) + { + } + + + // SysIncludeTranslationRegion + // + // + + void SysIncludeTranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void SysIncludeTranslationRegion:: + pre (NodePtr const&) + { + } + + void SysIncludeTranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void SysIncludeTranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void SysIncludeTranslationRegion:: + post (NodePtr const&) + { + } + + // ImpliedIncludeTranslationRegion + // + // + + void ImpliedIncludeTranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void ImpliedIncludeTranslationRegion:: + pre (NodePtr const&) + { + } + + void ImpliedIncludeTranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void ImpliedIncludeTranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void ImpliedIncludeTranslationRegion:: + post (NodePtr const&) + { + } + + + // PrincipalTranslationRegion + // + // + + void PrincipalTranslationRegion:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + scope (n); + post (n); + } + } + + void PrincipalTranslationRegion:: + pre (NodePtr const&) + { + } + + void PrincipalTranslationRegion:: + content (NodePtr const& n) + { + delegate_content (n); + } + + void PrincipalTranslationRegion:: + scope (NodePtr const& n) + { + if (scope_ != 0) scope_->dispatch (n->scope ()); + else dispatch (n->scope ()); + } + + void PrincipalTranslationRegion:: + post (NodePtr const&) + { + } + + // TranslationUnit + // + // + + void TranslationUnit:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + content (n); + post (n); + } + } + + + void TranslationUnit:: + pre (NodePtr const&) + { + } + + void TranslationUnit:: + content (NodePtr const& n) + { + //cerr << "starting traversal of translation unit content" << endl; + delegate_content (n); + //cerr << "finishing traversal of translation unit content" << endl; + } + + void TranslationUnit:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp new file mode 100644 index 00000000000..e6ccf144dcc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp @@ -0,0 +1,402 @@ +// file : CCF/IDL2/Traversal/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL2_TRAVERSAL_TRANSLATION_HPP +#define CCF_IDL2_TRAVERSAL_TRANSLATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + // + // + // + class RegionTraverser : public Traverser + { + public: + virtual void + add_content_delegate (Dispatcher* d) + { + content_delegates_.push_back (d); + } + + protected: + RegionTraverser (Dispatcher* scope) + : scope_ (scope) + { + } + + virtual void + delegate_content (SyntaxTree::TranslationRegionPtr const& tr) + { + for (SyntaxTree::TranslationRegion::Iterator n = tr->begin (); + n != tr->end (); + n++) + { + if (content_delegates_.empty ()) + { + dispatch (*n); + } + else + { + for (DispatcherList::const_iterator i = + content_delegates_.begin (); + i != content_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + } + } + } + } + + protected: + Dispatcher* scope_; + DispatcherList content_delegates_; + }; + + + // + // + // + struct FileScope : ScopeTraverser + { + typedef + SyntaxTree::FileScopePtr + NodePtr; + + FileScope () + { + map (typeid (SyntaxTree::FileScope), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::FileScope> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct TranslationRegion : RegionTraverser + { + typedef + SyntaxTree::TranslationRegionPtr + NodePtr; + + TranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::TranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::TranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct IncludeTranslationRegion : RegionTraverser + { + typedef + SyntaxTree::IncludeTranslationRegionPtr + NodePtr; + + IncludeTranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::IncludeTranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::IncludeTranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct UserIncludeTranslationRegion : RegionTraverser + { + typedef + SyntaxTree::UserIncludeTranslationRegionPtr + NodePtr; + + UserIncludeTranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::UserIncludeTranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse ( + n->dynamic_type<SyntaxTree::UserIncludeTranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct SysIncludeTranslationRegion : RegionTraverser + { + typedef + SyntaxTree::SysIncludeTranslationRegionPtr + NodePtr; + + SysIncludeTranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::SysIncludeTranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse ( + n->dynamic_type<SyntaxTree::SysIncludeTranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct ImpliedIncludeTranslationRegion : RegionTraverser + { + typedef + SyntaxTree::ImpliedIncludeTranslationRegionPtr + NodePtr; + + ImpliedIncludeTranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::ImpliedIncludeTranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse ( + n->dynamic_type<SyntaxTree::ImpliedIncludeTranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct PrincipalTranslationRegion : RegionTraverser + { + typedef + SyntaxTree::PrincipalTranslationRegionPtr + NodePtr; + + PrincipalTranslationRegion (Dispatcher* scope = 0) + : RegionTraverser (scope) + { + map (typeid (SyntaxTree::PrincipalTranslationRegion), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::PrincipalTranslationRegion> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + + + // + // + // + struct TranslationUnit : Traverser + { + typedef + SyntaxTree::TranslationUnitPtr + NodePtr; + + TranslationUnit () + { + map (typeid (SyntaxTree::TranslationUnit), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::TranslationUnit> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + content (NodePtr const&); + + virtual void + post (NodePtr const&); + + public: + virtual void + add_content_delegate (Dispatcher* d) + { + content_delegates_.push_back (d); + } + + protected: + virtual void + delegate_content (NodePtr const& tu) + { + for (SyntaxTree::TranslationRegion::Iterator n = tu->begin (); + n != tu->end (); + n++) + { + if (content_delegates_.empty ()) + { + dispatch (*n); + } + else + { + for (DispatcherList::const_iterator i = + content_delegates_.begin (); + i != content_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + } + } + } + } + + private: + DispatcherList content_delegates_; + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_TRANSLATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..1a9ee064300 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp @@ -0,0 +1,28 @@ +// 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 (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 ("manages" ); + keyword_table_.insert ("provides" ); + keyword_table_.insert ("publishes"); + keyword_table_.insert ("uses" ); + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp b/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..ac663f1ec01 --- /dev/null +++ b/TAO/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 (TokenStream<char>& is); + }; + } +} + +#endif // CCF_IDL3_LEXICAL_ANALYZER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/Makefile.alt new file mode 100644 index 00000000000..4ba66a73423 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Makefile.alt @@ -0,0 +1,20 @@ +# file : CCF/IDL3/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := Makefile.archive +target_directory_list := SyntaxTree Traversal +default_makefile_name := Makefile.alt + +Makefile.archive : SyntaxTree Traversal + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/CCF/IDL3/Makefile.archive b/TAO/CIAO/CCF/CCF/IDL3/Makefile.archive new file mode 100644 index 00000000000..805ee696a9f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Makefile.archive @@ -0,0 +1,32 @@ +# file : CCF/IDL3/Makefile.archive +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.pre.rules) + +cxx_translation_units := LexicalAnalyzer.cpp Parser.cpp + +translated_units := SyntaxTree/Component.o \ + SyntaxTree/EventType.o \ + SyntaxTree/Home.o \ + SyntaxTree/Operation.o + + +translated_units += Traversal/Component.o \ + Traversal/EventType.o \ + Traversal/Home.o \ + Traversal/Operation.o + +module_base := IDL3 +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Archive.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL3/Parser.cpp b/TAO/CIAO/CCF/CCF/IDL3/Parser.cpp new file mode 100644 index 00000000000..a465cf926d2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Parser.cpp @@ -0,0 +1,312 @@ +// 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 + { + 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" ), + MANAGES ("manages" ), + PROVIDES ("provides" ), + PUBLISHES ("publishes"), + USES ("uses" ), + + // Component + // + act_component_begin ( + f.component (), &SemanticAction::Component::begin), + + act_component_inherits ( + f.component (), &SemanticAction::Component::inherits), + + act_component_supports ( + f.component (), &SemanticAction::Component::supports), + + act_component_open_scope ( + f.component (), &SemanticAction::Component::open_scope), + + act_component_close_scope ( + f.component (), &SemanticAction::Component::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_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 ( + f.event_type (), &SemanticAction::EventType::begin), + + act_event_type_inherits ( + f.event_type (), &SemanticAction::EventType::inherits), + + act_event_type_open_scope ( + f.event_type (), &SemanticAction::EventType::open_scope), + + act_event_type_close_scope ( + f.event_type (), &SemanticAction::EventType::close_scope), + + act_event_type_end ( + f.event_type (), &SemanticAction::EventType::end), + + // 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::Home::open_scope), + + act_home_close_scope ( + f.home (), &SemanticAction::Home::close_scope), + + act_home_end ( + f.home (), &SemanticAction::Home::end), + + // HomeFactory + // + act_home_factory_begin ( + f.home_factory (), &SemanticAction::HomeFactory::begin), + + act_home_factory_parameter ( + f.home_factory (), &SemanticAction::HomeFactory::parameter), + + act_home_factory_end ( + f.home_factory (), &SemanticAction::HomeFactory::end) + + { + IDL2::Parser::extension = + component_decl + | eventtype_decl + | home_decl + | extension + ; + + // + // Component + // + component_decl = + component_header + >> + ( + SEMI[act_component_end] + | + ( + !(COLON >> component_inheritance_spec) + >> !(SUPPORTS >> component_support_spec) + >> LBRACE[act_component_open_scope] + >> component_body + >> RBRACE[act_component_close_scope] + >> SEMI[act_component_end] + ) + ) + ; + + component_header = + COMPONENT + >> simple_identifier[act_component_begin] + ; + + component_inheritance_spec = identifier[act_component_inherits] + ; + + component_support_spec = + identifier[act_component_supports] + >> *(COMMA >> identifier[act_component_supports]) + ; + + component_body = + *( provides_decl + | uses_decl + | emits_decl + | publishes_decl + | consumes_decl + | attribute_decl + ) + ; + + // + // Component body elements + // + provides_decl = + PROVIDES + >> identifier[act_provides_type] + >> simple_identifier[act_provides_name] + >> SEMI + ; + + uses_decl = + USES + >> identifier[act_uses_type] + >> simple_identifier[act_uses_name] + >> SEMI + ; + + emits_decl = + EMITS + >> identifier[act_emits_type] + >> simple_identifier[act_emits_name] + >> SEMI + ; + + publishes_decl = + PUBLISHES + >> identifier[act_publishes_type] + >> simple_identifier[act_publishes_name] + >> SEMI + ; + + consumes_decl = + CONSUMES + >> identifier[act_consumes_type] + >> simple_identifier[act_consumes_name] + >> SEMI + ; + + // + // Eventtype + // + eventtype_decl = + eventtype_header + >> + ( + SEMI[act_event_type_end] + | + ( + !(COLON >> eventtype_inheritance_spec) + >> LBRACE[act_event_type_open_scope] +// >> eventtype_body + >> RBRACE[act_event_type_close_scope] + >> SEMI[act_event_type_end] + ) + ) + ; + + eventtype_header = + !(ABSTRACT) + >> EVENTTYPE + >> simple_identifier[act_event_type_begin] + ; + + eventtype_inheritance_spec = + identifier[act_event_type_inherits] + >> *(COMMA >> identifier[act_event_type_inherits]) + ; + + // + // Home + // + home_decl = + home_header + >> !(COLON >> home_inheritance_spec) + >> !(SUPPORTS >> home_support_spec) + >> MANAGES >> home_manage_spec + >> LBRACE[act_home_open_scope] + >> home_body + >> RBRACE[act_home_close_scope] + >> SEMI[act_home_end] + ; + + home_header = HOME >> simple_identifier[act_home_begin] + ; + + home_inheritance_spec = identifier[act_home_inherits] + ; + + home_support_spec = + identifier[act_home_supports] + >> *(COMMA >> identifier[act_home_supports]) + ; + + home_manage_spec = identifier[act_home_manages] + ; + + home_body = + *( + attribute_decl + | operation_decl + | home_factory_decl + ) + ; + + // + // Home factory + // + home_factory_decl = + FACTORY + >> simple_identifier[act_home_factory_begin] + >> LPAREN + >> home_factory_parameter_list + >> RPAREN + >> SEMI[act_home_factory_end] + ; + + home_factory_parameter_list = + *( + home_factory_parameter + >> *(COMMA >> home_factory_parameter) + ) + ; + + home_factory_parameter = + IN + >> (identifier >> simple_identifier)[act_home_factory_parameter] + ; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp b/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp new file mode 100644 index 00000000000..6eabd838cbf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp @@ -0,0 +1,203 @@ +// 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 MANAGES; + KeywordParser PROVIDES; + KeywordParser PUBLISHES; + KeywordParser USES; + + + // + // Language + // + + Rule extension; + + // Component + Rule component_decl; + Rule component_header; + Rule component_inheritance_spec; + Rule component_support_spec; + Rule component_body; + + // Component body elements + Rule provides_decl; + Rule uses_decl; + Rule emits_decl; + Rule publishes_decl; + Rule consumes_decl; + + // Eventtype + Rule eventtype_decl; + Rule eventtype_header; + Rule eventtype_inheritance_spec; + Rule eventtype_body; + + // Home + Rule home_decl; + Rule home_header; + Rule home_inheritance_spec; + Rule home_support_spec; + Rule home_manage_spec; + Rule home_body; + + Rule home_factory_decl; + Rule home_factory_parameter_list; + Rule home_factory_parameter; + + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + protected: + // Component + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Component> + act_component_begin; + + 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 + // + 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; + + OneArgAction<IdentifierPtr, SemanticAction::EventType> + act_event_type_inherits; + + ScopeAction + act_event_type_open_scope; + + ScopeAction + act_event_type_close_scope; + + NoArgAction<SemanticAction::EventType> + act_event_type_end; + + // 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_begin; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::HomeFactory> + act_home_factory_parameter; + + NoArgAction<SemanticAction::HomeFactory> + act_home_factory_end; + + }; + } +} + +#endif // CCF_IDL3_PARSER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction.hpp new file mode 100644 index 00000000000..7b7fc5129ea --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction.hpp @@ -0,0 +1,33 @@ +// 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/Component.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFactory.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" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + using namespace IDL2::SemanticAction; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp new file mode 100644 index 00000000000..7360099d212 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp @@ -0,0 +1,39 @@ +// 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 + { + // + // + // + class Component : public virtual Scope + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp new file mode 100644 index 00000000000..9efedad2d28 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Consumes.hpp @@ -0,0 +1,35 @@ +// 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 + { + // + // + // + class Consumes + { + public: + virtual + ~Consumes () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_CONSUMES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Elements.hpp new file mode 100644 index 00000000000..f0849ee5666 --- /dev/null +++ b/TAO/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/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp new file mode 100644 index 00000000000..ad36fdd6737 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Emits.hpp @@ -0,0 +1,35 @@ +// 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 + { + // + // + // + class Emits + { + public: + virtual + ~Emits () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EMITS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp new file mode 100644 index 00000000000..9457fea407a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp @@ -0,0 +1,36 @@ +// 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 + { + // + // + // + class EventType : public virtual Scope + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp new file mode 100644 index 00000000000..382d01677fa --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Factory.hpp @@ -0,0 +1,63 @@ +// 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 + { + class Component; + class Provides; + class Uses; + class Publishes; + class Emits; + class Consumes; + class EventType; + class Home; + class HomeFactory; + + // + // + // + class Factory : public virtual IDL2::SemanticAction::Factory + { + public: + 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 Home& + home () = 0; + + virtual HomeFactory& + home_factory () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp new file mode 100644 index 00000000000..f415380b807 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Home.hpp @@ -0,0 +1,42 @@ +// 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 + { + // + // + // + class Home : public virtual Scope + { + public: + + 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 + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp new file mode 100644 index 00000000000..ad1d7bb1bd8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/HomeFactory.hpp @@ -0,0 +1,37 @@ +// 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 + { + // + // + // + class HomeFactory + { + public: + + virtual void + begin (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp new file mode 100644 index 00000000000..4edc62243f7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp new file mode 100644 index 00000000000..d3163140f34 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp @@ -0,0 +1,256 @@ +// 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/SemanticAction/Component.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Component : + public virtual SemanticAction::Component, + public virtual ScopeBase<SyntaxTree::ComponentDeclPtr> + { + public: + virtual + ~Component () throw () {} + + + Component (bool trace, SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::ComponentDeclPtr> (scope), + trace_ (trace), + name_ (""), + inherits_ ("") + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "component " << id << endl; + + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + inherits (IdentifierPtr const& id) + { + if (trace_) cerr << "inherits " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct InheritancePredicate : public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + if (type != "component") throw IncompatibleType (type); + + return d->dynamic_type<TypeDecl> ()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + inherits_ = sn; + } + catch (InheritancePredicate::IncompatibleType const& e) + { + cerr << "error: invalid inheritance specification" << endl; + + cerr << "inheritance of "; + cerr << "component \'" << name_ <<"\' from " + << e.type << " \'" << name << "\' is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no defined component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "inheritance from forward-declared component is illegal" + << endl; + } + } + + + virtual void + supports (IdentifierPtr const& id) + { + if (trace_) cerr << "supports " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct SupportsPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + // Spec doesn't say anything about which interfaces + // component can support. + if (type != "unconstrained interface") + throw IncompatibleType (type); + + return d->dynamic_type<TypeDecl> ()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + if (supports_.insert (sn).second == false) + { + cerr << "error: invalid support specification" << endl; + cerr << "directly supporting interface \'" + << sn << "\' more than once is illegal" << endl; + } + } + catch (SupportsPredicate::IncompatibleType const& e) + { + cerr << "error: invalid support specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in component\'s support clause is illegal" + << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no defined interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "supporting forward-declared interface is illegal" + << endl; + } + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + ComponentDefPtr def; + + if (inherits_ == ScopedName ("")) + { + def = ComponentDefPtr (new ComponentDef ( + name_, + scope_, + supports_)); + } + else + { + def = ComponentDefPtr (new ComponentDef ( + name_, + scope_, + inherits_, + supports_)); + } + + scope_->insert (def); + push (def); + scope_ = def; + + name_ = SimpleName (""); //indicate that we are done + inherits_ = ScopedName (""); + supports_.clear (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + + using namespace SyntaxTree; + + if (name_ != SimpleName ("")) + { + ComponentDeclPtr decl (new ComponentForwardDecl (name_, scope_)); + scope_->insert (decl); + } + else + { + pop (); + } + } + private: + bool trace_; + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedName inherits_; + SyntaxTree::ScopedNameSet supports_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp new file mode 100644 index 00000000000..f2cc97f062b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp new file mode 100644 index 00000000000..6abc07b82f9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp @@ -0,0 +1,107 @@ +// 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/SemanticAction/Consumes.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Consumes : public virtual SemanticAction::Consumes + { + public: + virtual + ~Consumes () throw () {} + + Consumes (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "consumes " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<EventTypeDef> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid consumes declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid consumes declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in consumes " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + DeclarationPtr d ( + new SyntaxTree::ConsumesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..9067f42b310 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,24 @@ +// 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/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using IDL2::SemanticAction::Impl::ScopeBase; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp new file mode 100644 index 00000000000..f72d19dd1ef --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp new file mode 100644 index 00000000000..01438cf7616 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp @@ -0,0 +1,107 @@ +// 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/SemanticAction/Emits.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Emits : public virtual SemanticAction::Emits + { + public: + virtual + ~Emits () throw () {} + + Emits (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "emits " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<EventTypeDef> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid emits declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid emits declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in emits " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + DeclarationPtr d ( + new SyntaxTree::EmitsDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp new file mode 100644 index 00000000000..a02c4777964 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp new file mode 100644 index 00000000000..e0ed61a6558 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp @@ -0,0 +1,92 @@ +// 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/SemanticAction/EventType.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class EventType : public virtual SemanticAction::EventType, + public virtual ScopeBase<SyntaxTree::EventTypeDeclPtr> + { + public: + virtual + ~EventType () throw () {} + + EventType (bool trace, SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::EventTypeDeclPtr> (scope), + trace_ (trace), + name_ ("") + { + } + + public: + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "eventtype " << id << endl; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + virtual void + inherits (IdentifierPtr const& id) + { + if (trace_) cerr << "inherits " << id << endl; + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + ConcreteEventTypeDefPtr et( new ConcreteEventTypeDef ( + name_, + scope_, + inherits_)); + scope_->insert (et); + push (et); + scope_ = et; + + name_ = SimpleName (""); //indicate that we are done + inherits_.clear (); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + pop (); + } + + private: + bool trace_; + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedNameSet inherits_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..b60aa1847a8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,19 @@ +// 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 + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..e3f2d7c4dda --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,142 @@ +// 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/Include.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/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Factory : public virtual IDL3::SemanticAction::Factory, + public virtual IDL2::SemanticAction::Impl::Factory + { + public: + virtual + ~Factory () throw () {} + + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SyntaxTree::TranslationRegionPtr const& r) + : IDL2::SemanticAction::Impl::Factory (context, dout, r), + trace_ (context.get ("idl3::semantic-action::trace", false)), + + include_ (trace_, context, dout, *this, r, scope_), + component_ (trace_, scope_), + provides_ (trace_, scope_), + uses_ (trace_, scope_), + publishes_ (trace_, scope_), + emits_ (trace_, scope_), + consumes_ (trace_, scope_), + event_type_ (trace_, scope_), + home_ (trace_, scope_), + home_factory_ (trace_, scope_) + { + } + + public: + + virtual IDL2::SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Component& + component () + { + return component_; + } + + virtual SemanticAction::Provides& + provides () + { + return provides_; + } + + virtual SemanticAction::Uses& + uses () + { + return uses_; + } + + virtual SemanticAction::Publishes& + publishes () + { + return publishes_; + } + + virtual SemanticAction::Emits& + emits () + { + return emits_; + } + + virtual SemanticAction::Consumes& + consumes () + { + return consumes_; + } + + + virtual SemanticAction::EventType& + event_type () + { + return event_type_; + } + + virtual SemanticAction::Home& + home () + { + return home_; + } + + virtual SemanticAction::HomeFactory& + home_factory () + { + return home_factory_; + } + + + private: + + bool trace_; + + Include include_; + + Component component_; + Provides provides_; + Uses uses_; + Publishes publishes_; + Emits emits_; + Consumes consumes_; + EventType event_type_; + Home home_; + HomeFactory home_factory_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp new file mode 100644 index 00000000000..6f10db4c9fb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp new file mode 100644 index 00000000000..3895d251996 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp @@ -0,0 +1,334 @@ +// 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/SemanticAction/Home.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Home : public virtual SemanticAction::Home, + public virtual ScopeBase<SyntaxTree::HomeDefPtr> + { + public: + virtual + ~Home () throw () {} + + Home (bool trace, SyntaxTree::ScopePtr& scope) + : ScopeBase<SyntaxTree::HomeDefPtr> (scope), + trace_ (trace), + name_ (""), + inherits_ (""), + manages_ ("") + + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "home " << id << endl; + name_ = SyntaxTree::SimpleName (id->lexeme ()); + } + + + virtual void + inherits (IdentifierPtr const& id) + { + if (trace_) cerr << "inherits " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct InheritancePredicate : public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + if (type != "home") throw IncompatibleType (type); + + // This is not really necessary since home cannot be + // forward-declared (yet ;-). + return d->dynamic_type<TypeDecl> ()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + inherits_ = sn; + } + catch (InheritancePredicate::IncompatibleType const& e) + { + cerr << "error: invalid inheritance specification" << endl; + + cerr << "inheritance of "; + cerr << "home \'" << name_ <<"\' from " + << e.type << " \'" << name << "\' is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid inheritance specification" << endl; + cerr << "no defined home with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "inheritance from forward-declared home is illegal" + << endl; + } + } + + + virtual void + supports (IdentifierPtr const& id) + { + if (trace_) cerr << "supports " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct SupportsPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + // Spec doesn't say anything about which interfaces + // component can support. + if (type != "unconstrained interface") + throw IncompatibleType (type); + + return d->dynamic_type<TypeDecl> ()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + if (supports_.insert (sn).second == false) + { + cerr << "error: invalid support specification" << endl; + cerr << "directly supporting interface \'" + << sn << "\' more than once is illegal" << endl; + } + } + catch (SupportsPredicate::IncompatibleType const& e) + { + cerr << "error: invalid support specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in home\'s support clause is illegal" + << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid support specification" << endl; + cerr << "no defined interface with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "supporting forward-declared interface is illegal" + << endl; + } + } + + + virtual void + manages (IdentifierPtr const& id) + { + if (trace_) cerr << "manages " << id << endl; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct ManagesPredicate : + public DeclarationTable::ResolvePredicate + { + struct IncompatibleType : + public DeclarationTable::ResolutionFailure + { + IncompatibleType (std::string const& t) : type (t) {} + std::string type; + }; + + virtual bool + test (DeclarationPtr const& d) + throw (IncompatibleType) + { + std::string type = d->declaration_class (); + + if (type != "component") throw IncompatibleType (type); + + return d->dynamic_type<TypeDecl>()->defined (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + manages_ = sn; + } + catch (ManagesPredicate::IncompatibleType const& e) + { + cerr << "error: invalid manages specification" << endl; + + cerr << "specifying " << e.type << " \'" << name + << "\' in home manages clause is illegal" << endl; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid manages specification" << endl; + cerr << "no component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid manages specification" << endl; + cerr << "no defined component with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + cerr << "managing of forward-declared component is illegal" + << endl; + } + } + + virtual void + open_scope () + { + using namespace SyntaxTree; + + HomeDefPtr def (new HomeDef ( + name_, + scope_, + inherits_, + supports_, + manages_)); + + if (inherits_ == ScopedName ("")) + { + def = HomeDefPtr (new HomeDef ( + name_, + scope_, + supports_, + manages_)); + } + else + { + def = HomeDefPtr (new HomeDef ( + name_, + scope_, + inherits_, + supports_, + manages_)); + } + + + scope_->insert (def); + push (def); + scope_ = def; + + name_ = SimpleName (""); //indicate that we are done + inherits_ = ScopedName (""); + supports_.clear (); + manages_ = ScopedName (""); + } + + virtual void + close_scope () + { + scope_ = scope_->scope (); + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + + using namespace SyntaxTree; + + if (name_ != SimpleName ("")) + { + // this is not supported by spec yet + } + else + { + pop (); + } + } + private: + bool trace_; + SyntaxTree::SimpleName name_; + SyntaxTree::ScopedName inherits_; + SyntaxTree::ScopedNameSet supports_; + SyntaxTree::ScopedName manages_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp new file mode 100644 index 00000000000..2549a1f8db9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp new file mode 100644 index 00000000000..ea44f515fc2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp @@ -0,0 +1,127 @@ +// 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/SemanticAction/HomeFactory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class HomeFactory : public virtual SemanticAction::HomeFactory + { + public: + virtual + ~HomeFactory () throw () + { + } + + HomeFactory (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current) + { + } + + virtual void + begin (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << "home factory " << id << endl; + + using namespace SyntaxTree; + + HomeDefPtr home (scope_->dynamic_type<HomeDef> ()); + + if (home == 0) + { + //@@ internal compiler error + } + + ComponentDefPtr component (home->manages ()); + + home_factory_ = HomeFactoryDeclPtr ( + new HomeFactoryDecl (SimpleName (id->lexeme ()), + component->name (), + scope_)); + } + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (trace_) cerr << "parameter " << type_id << " " + << name_id << endl; + + using namespace IDL3::SyntaxTree; + + Name type_name (type_id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<TypeDecl> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + type_name, + scope_->name (), + scope_->peek_order (), + p); + + HomeFactoryParameterPtr p ( + new HomeFactoryParameter (sn, + SimpleName (name_id->lexeme ()), + scope_->table ())); + + home_factory_->insert (p); + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid home factory declaration" << endl; + cerr << "no type with name \'" + << type_name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid home factory declaration" << endl; + cerr << "declaration with name \'" << type_name + << "\' visible from scope \'" << scope_->name () + << "\' is not a type declaration" << endl; + cerr << "using non-type as home factory parameter type is illegal" + << endl; + } + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + scope_->insert (home_factory_); + home_factory_ = SyntaxTree::HomeFactoryDeclPtr (); + } + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::HomeFactoryDeclPtr home_factory_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..59d19593f7d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp @@ -0,0 +1,18 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..a91b9f41b1a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp @@ -0,0 +1,164 @@ +// 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 "CCF/IDL2/SemanticAction/Include.hpp" + +//@@ needed for include handling +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // Note: overriding IDL2 include to allow inclusiion of IDL3 files + // + // + class Include : public virtual IDL2::SemanticAction::Include + { + public: + virtual + ~Include () throw () {} + + Include (bool trace, + CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory, + SyntaxTree::TranslationRegionPtr const& region, + SyntaxTree::ScopePtr& scope) + : trace_ (trace), + context_ (context), + dout_ (dout), + action_factory_ (action_factory), + scope_ (scope) + { + stack_.push (region); + } + + virtual void + begin (StringLiteralPtr const& sl) + { + if (trace_) cerr << "include \"" << sl << "\"" << endl; + + using namespace SyntaxTree; + + try + { + fs::path file_path (sl->lexeme ()); + + if(!include_file_set_.insert (file_path).second) + { + cerr << "warning: skipping already included file \'" + << sl << "\'" << endl; + return; + } + + fs::ifstream ifs; + ifs.exceptions (ios_base::badbit | ios_base::failbit); + ifs.open (file_path); + + //@@ 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 (ios_base::iostate (0)); + + TranslationRegionPtr r (new UserIncludeTranslationRegion ( + file_path, + stack_.top ()->table (), + stack_.top ()->create_order ())); + + stack_.top ()->insert (r); + + stack_.push (r); + context_.set ("file-path", stack_.top ()->file_path ()); + + if (trace_) cerr << "push file scope: old scope " + << scope_->order (); + + scope_ = stack_.top ()->scope (); + + if (trace_) cerr << "; new scope " << scope_->order () << endl; + + //@@ this code is highly experimental + InputStreamAdapter isa (ifs); + Preprocessor pp (isa); + 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 (context_, dout_, lexer, action_factory_); + + IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + } + + if (trace_) cerr << "pop file scope: old scope " + << scope_->order (); + + stack_.pop (); + + scope_ = stack_.top ()->scope (); + context_.set ("file-path", stack_.top ()->file_path ()); + + if (trace_) cerr << "; new scope " << scope_->order () << endl; + } + catch (fs::filesystem_error const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + catch (ios_base::failure const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + } + + virtual void + end () + { + if (trace_) cerr << "end" << endl; + } + + public: + bool trace_; + CompilerElements::Context& context_; + Diagnostic::Stream& dout_; + SemanticAction::Factory& action_factory_; + SyntaxTree::ScopePtr& scope_; + + std::stack<SyntaxTree::TranslationRegionPtr> 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/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp new file mode 100644 index 00000000000..cd4b734b1ce --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp new file mode 100644 index 00000000000..7183d28a2f1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp @@ -0,0 +1,107 @@ +// 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/IDL3/SemanticAction/Provides.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Provides : public virtual SemanticAction::Provides + { + public: + virtual + ~Provides () throw () {} + + Provides (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "provides " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<InterfaceDecl> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid provides declaration" << endl; + cerr << "no interface type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid provides declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not an interface type declaration" << endl; + cerr << "using non-<interface type> in provides " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + DeclarationPtr d ( + new SyntaxTree::ProvidesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp new file mode 100644 index 00000000000..ca584b6f604 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp new file mode 100644 index 00000000000..e4b107fd555 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp @@ -0,0 +1,107 @@ +// 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/SemanticAction/Publishes.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Publishes : public virtual SemanticAction::Publishes + { + public: + virtual + ~Publishes () throw () {} + + Publishes (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "publishes " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<EventTypeDef> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid publishes declaration" << endl; + cerr << "no event type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid publishes declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not a defined event type" << endl; + cerr << "using non-<defined event type> in publishes " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + DeclarationPtr d ( + new SyntaxTree::PublishesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp new file mode 100644 index 00000000000..cd039845b6e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp @@ -0,0 +1,19 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + } + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp new file mode 100644 index 00000000000..3f6a255cb3b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp @@ -0,0 +1,107 @@ +// 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/IDL3/SemanticAction/Uses.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Uses : public virtual SemanticAction::Uses + { + public: + virtual + ~Uses () throw () {} + + Uses (bool trace, SyntaxTree::ScopePtr& current) + : trace_ (trace), + scope_ (current), + type_ ("") + { + } + + virtual void + type (IdentifierPtr const& id) + { + if (trace_) cerr << "uses " << id; + + using namespace SyntaxTree; + + Name name (id->lexeme ()); + + struct Predicate : public DeclarationTable::ResolvePredicate + { + virtual bool + test (DeclarationPtr const& d) throw () + { + return d->is_a<InterfaceDecl> (); + } + } p; + + try + { + ScopedName sn = scope_->table ().resolve ( + name, + scope_->name (), + scope_->peek_order (), + p); + + type_ = sn; + } + catch (DeclarationTable::NameNotFound const&) + { + cerr << "error: invalid uses declaration" << endl; + cerr << "no interface type with name \'" + << name << "\' visible from scope \'" + << scope_->name () << "\'" << endl; + } + catch (DeclarationTable::PredicateNotMet const&) + { + cerr << "error: invalid uses declaration" << endl; + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << scope_->name () + << "\' is not an interface type declaration" << endl; + cerr << "using non-<interface type> in uses " + << "declaration is illegal" << endl; + } + } + + virtual void + name (SimpleIdentifierPtr const& id) + { + if (trace_) cerr << " " << id << endl; + + using namespace SyntaxTree; + + SimpleName name (id->lexeme ()); + + DeclarationPtr d ( + new SyntaxTree::UsesDecl (name, type_, scope_)); + + scope_->insert (d); + + type_ = ScopedName (""); + } + + private: + bool trace_; + SyntaxTree::ScopePtr& scope_; + SyntaxTree::ScopedName type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp new file mode 100644 index 00000000000..56b0cdd5350 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Provides.hpp @@ -0,0 +1,35 @@ +// 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 + { + // + // + // + class Provides + { + public: + virtual + ~Provides () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PROVIDES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp new file mode 100644 index 00000000000..243c9443bf3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Publishes.hpp @@ -0,0 +1,35 @@ +// 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 + { + // + // + // + class Publishes + { + public: + virtual + ~Publishes () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_PUBLISHES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp new file mode 100644 index 00000000000..c535c8a4b05 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Uses.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL3/SemanticAction/Uses.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_USES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_USES_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + // + // + // + class Uses + { + public: + virtual + ~Uses () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_USES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree.hpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree.hpp new file mode 100644 index 00000000000..cbdb4e5e501 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree.hpp @@ -0,0 +1,26 @@ +// file : CCF/IDL3/SyntaxTree.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SYNTAX_TREE_HPP +#define CCF_IDL3_SYNTAX_TREE_HPP + +#include "CCF/IDL2/SyntaxTree.hpp" + +#include "CCF/IDL3/SyntaxTree/Component.hpp" +#include "CCF/IDL3/SyntaxTree/EventType.hpp" +#include "CCF/IDL3/SyntaxTree/Home.hpp" +#include "CCF/IDL3/SyntaxTree/Operation.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + using namespace IDL2::SyntaxTree; + } + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.cpp new file mode 100644 index 00000000000..8705034f4d5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.cpp @@ -0,0 +1,86 @@ +// file : CCF/IDL3/SyntaxTree/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SyntaxTree/Component.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + + // ComponentDecl + // + // + namespace + { + TypeInfo + component_decl_init_ () + { + TypeInfo ti (typeid (ComponentDecl)); + ti.add_base (Access::PUBLIC, true, TypeDecl::static_type_info ()); + return ti; + } + + TypeInfo component_decl_ (component_decl_init_ ()); + } + + TypeInfo const& ComponentDecl:: + static_type_info () { return component_decl_; } + + + // ComponentForwardDecl + // + // + namespace + { + TypeInfo + component_forward_decl_init_ () + { + TypeInfo ti (typeid (ComponentForwardDecl)); + ti.add_base (Access::PUBLIC, + true, + ComponentDecl::static_type_info ()); + + ti.add_base (Access::PUBLIC, + true, + TypeForwardDecl::static_type_info ()); + return ti; + } + + TypeInfo component_forward_decl_ (component_forward_decl_init_ ()); + } + + TypeInfo const& ComponentForwardDecl:: + static_type_info () { return component_forward_decl_; } + + + // ComponentDef + // + // + namespace + { + TypeInfo + component_def_init_ () + { + TypeInfo ti (typeid (ComponentDef)); + ti.add_base (Access::PUBLIC, true, TypeDef::static_type_info ()); + ti.add_base (Access::PUBLIC, + true, + ComponentDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo component_def_ (component_def_init_ ()); + } + + TypeInfo const& ComponentDef:: + static_type_info () { return component_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.hpp new file mode 100644 index 00000000000..4aee1988ee4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Component.hpp @@ -0,0 +1,213 @@ +// file : CCF/IDL3/SyntaxTree/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SYNTAX_TREE_COMPONENT_HPP +#define CCF_IDL3_SYNTAX_TREE_COMPONENT_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Interface.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + + // + // + // + class ComponentDecl : public virtual TypeDecl + { + public: + virtual + ~ComponentDecl () throw () {} + + ComponentDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "component"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<ComponentDecl> + ComponentDeclPtr; + + typedef + DeclarationRef<ComponentDecl> + ComponentDeclRef; + + + // + // + // + class ComponentForwardDecl : public virtual ComponentDecl, + public virtual TypeForwardDecl + { + public: + virtual + ~ComponentForwardDecl () throw () {} + + ComponentForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ComponentDecl (name, scope), + TypeForwardDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "component"; + } + + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + + // + // + // + class ComponentDef; + + typedef + StrictPtr<ComponentDef> + ComponentDefPtr; + + typedef + DeclarationRef<ComponentDef> + ComponentDefRef; + + class ComponentDef : public virtual TypeDef, + public virtual ComponentDecl, + public virtual Scope + { + public: + virtual + ~ComponentDef () throw () {} + + ComponentDef (SimpleName const& name, + ScopePtr const& scope, + ScopedName const& inherits, + ScopedNameSet const& supports) + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + ComponentDecl (name, scope), + Scope (name, scope), + inherits_ (scope->table (), inherits) + { + type_info (static_type_info ()); + copy_supports_list (supports); + } + + ComponentDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& supports) + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + ComponentDecl (name, scope), + Scope (name, scope), + inherits_ (scope->table ()) + { + type_info (static_type_info ()); + copy_supports_list (supports); + } + + private: + void + copy_supports_list (ScopedNameSet const& supports) + { + for (ScopedNameSet::const_iterator i = supports.begin (); + i != supports.end (); + i++) + { + supports_.insert (InterfaceDefRef (scope ()->table (), *i)); + } + } + + + public: + ComponentDefRef + inherits () + { + return inherits_; + } + + + public: + + typedef + InterfaceDefRefSetName::const_iterator + Iterator; + + Iterator + supports_begin () const + { + return supports_.begin (); + } + + Iterator + supports_end () const + { + return supports_.end (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "component"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + ComponentDefRef inherits_; + InterfaceDefRefSetName supports_; + }; + + typedef + DeclarationOrderComparator<ComponentDefPtr> + ComponentDefOrderComparator; + + typedef + std::set<ComponentDefPtr, ComponentDefOrderComparator> + ComponentDefSet; + } + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.cpp new file mode 100644 index 00000000000..d1f0283bf1d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.cpp @@ -0,0 +1,138 @@ +// file : CCF/IDL3/SyntaxTree/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SyntaxTree/EventType.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + + // EventTypeDecl + // + // + namespace + { + TypeInfo + event_type_decl_init_ () + { + TypeInfo ti (typeid (EventTypeDecl)); + ti.add_base (Access::PUBLIC, + true, + ValueTypeDecl::static_type_info ()); + return ti; + } + + TypeInfo event_type_decl_ (event_type_decl_init_ ()); + } + + TypeInfo const& EventTypeDecl:: + static_type_info () { return event_type_decl_; } + + + // EventTypeForwardDecl + // + // + namespace + { + TypeInfo + event_type_forward_decl_init_ () + { + TypeInfo ti (typeid (EventTypeForwardDecl)); + + ti.add_base (Access::PUBLIC, + true, + ValueTypeForwardDecl::static_type_info ()); + + ti.add_base (Access::PUBLIC, + true, + EventTypeDecl::static_type_info ()); + return ti; + } + + TypeInfo event_type_forward_decl_ (event_type_forward_decl_init_ ()); + } + + TypeInfo const& EventTypeForwardDecl:: + static_type_info () { return event_type_forward_decl_; } + + + // EventTypeDef + // + // + namespace + { + TypeInfo + event_type_def_init_ () + { + TypeInfo ti (typeid (EventTypeDef)); + ti.add_base (Access::PUBLIC, + true, + EventTypeDecl::static_type_info ()); + + ti.add_base (Access::PUBLIC, + true, + ValueTypeDef::static_type_info ()); + return ti; + } + + TypeInfo event_type_def_ (event_type_def_init_ ()); + } + + TypeInfo const& EventTypeDef:: + static_type_info () { return event_type_def_; } + + + // ConcreteEventTypeDecl + // + // + namespace + { + TypeInfo + concrete_event_type_decl_init_ () + { + TypeInfo ti (typeid (ConcreteEventTypeDecl)); + ti.add_base (Access::PUBLIC, + true, + EventTypeDecl::static_type_info ()); + return ti; + } + + TypeInfo concrete_event_type_decl_ (concrete_event_type_decl_init_ ()); + } + + TypeInfo const& ConcreteEventTypeDecl:: + static_type_info () { return concrete_event_type_decl_; } + + + // ConcreteEventTypeDef + // + // + namespace + { + TypeInfo + concrete_event_type_def_init_ () + { + TypeInfo ti (typeid (ConcreteEventTypeDef)); + ti.add_base (Access::PUBLIC, + true, + ConcreteEventTypeDecl::static_type_info ()); + ti.add_base (Access::PUBLIC, + true, + EventTypeDef::static_type_info ()); + return ti; + } + + TypeInfo concrete_event_type_def_ (concrete_event_type_def_init_ ()); + } + + TypeInfo const& ConcreteEventTypeDef:: + static_type_info () { return concrete_event_type_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.hpp new file mode 100644 index 00000000000..8f451a02ec1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/EventType.hpp @@ -0,0 +1,217 @@ +// file : CCF/IDL3/SyntaxTree/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SYNTAX_TREE_EVENT_TYPE_HPP +#define CCF_IDL3_SYNTAX_TREE_EVENT_TYPE_HPP + +#include "CCF/IDL2/SyntaxTree/ValueType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + + // + // + // + class EventTypeDecl : public virtual ValueTypeDecl + { + public: + virtual + ~EventTypeDecl () throw () {} + + EventTypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "event type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<EventTypeDecl> + EventTypeDeclPtr; + + + // + // + // + class EventTypeForwardDecl : public virtual ValueTypeForwardDecl, + public virtual EventTypeDecl + { + public: + virtual + ~EventTypeForwardDecl () throw () {} + + EventTypeForwardDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + TypeForwardDecl (name, scope), + ValueTypeForwardDecl (name, scope), + EventTypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "event type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class EventTypeDef : public virtual EventTypeDecl, + public virtual ValueTypeDef + { + public: + virtual + ~EventTypeDef () throw () {} + + EventTypeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + EventTypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + ValueTypeDef (name, scope, inherits) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "event type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class ConcreteEventTypeDecl : public virtual EventTypeDecl + { + public: + virtual + ~ConcreteEventTypeDecl () throw () {} + + ConcreteEventTypeDecl (SimpleName const& name, + ScopePtr const& scope) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + EventTypeDecl (name, scope) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "concrete event type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + + // + // + // + class ConcreteEventTypeDef : public virtual ConcreteEventTypeDecl, + public virtual EventTypeDef + { + public: + virtual + ~ConcreteEventTypeDef () throw () {} + + ConcreteEventTypeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& inherits) + : Declaration (name, scope), + TypeDecl (name, scope), + ValueTypeDecl (name, scope), + EventTypeDecl (name, scope), + ConcreteEventTypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + ValueTypeDef (name, scope, inherits), + EventTypeDef (name, scope, inherits) + { + type_info (static_type_info ()); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "concrete event type"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<ConcreteEventTypeDef> + ConcreteEventTypeDefPtr; + + typedef + DeclarationOrderComparator<ConcreteEventTypeDefPtr> + ConcreteEventTypeDefOrderComparator; + + typedef + std::set<ConcreteEventTypeDefPtr, ConcreteEventTypeDefOrderComparator> + ConcreteEventTypeDefSet; + } + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.cpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.cpp new file mode 100644 index 00000000000..968e1402e5c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL3/SyntaxTree/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SyntaxTree/Home.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + + // HomeDef + // + // + namespace + { + TypeInfo + home_def_init_ () + { + TypeInfo ti (typeid (HomeDef)); + ti.add_base (Access::PUBLIC, true, TypeDef::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo home_def_ (home_def_init_ ()); + } + + TypeInfo const& HomeDef:: + static_type_info () { return home_def_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.hpp new file mode 100644 index 00000000000..882689a7761 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Home.hpp @@ -0,0 +1,146 @@ +// file : CCF/IDL3/SyntaxTree/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SYNTAX_TREE_HOME_HPP +#define CCF_IDL3_SYNTAX_TREE_HOME_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Interface.hpp" +#include "CCF/IDL3/SyntaxTree/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + // According to the spec Home cannot be forward-declared. Did they + // goof again? - you would probably think... + // + + class HomeDef; + + typedef + StrictPtr<HomeDef> + HomeDefPtr; + + typedef + DeclarationRef<HomeDef> + HomeDefRef; + + class HomeDef : public virtual TypeDef, public virtual Scope + { + public: + virtual + ~HomeDef () throw () {} + + HomeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedName const& inherits, + ScopedNameSet const& supports, + ScopedName const& manages) + + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + inherits_ (scope->table (), inherits), + manages_ (scope->table (), manages) + { + type_info (static_type_info ()); + copy_supports_list (supports); + } + + HomeDef (SimpleName const& name, + ScopePtr const& scope, + ScopedNameSet const& supports, + ScopedName const& manages) + + : Declaration (name, scope), + TypeDecl (name, scope), + TypeDef (name, scope), + Scope (name, scope), + inherits_ (scope->table ()), + manages_ (scope->table (), manages) + { + type_info (static_type_info ()); + copy_supports_list (supports); + } + + private: + void + copy_supports_list (ScopedNameSet const& supports) + { + for (ScopedNameSet::const_iterator i = supports.begin (); + i != supports.end (); + i++) + { + supports_.insert (InterfaceDefRef (scope ()->table (), *i)); + } + } + + public: + HomeDefRef + inherits () + { + return inherits_; + } + + public: + typedef + InterfaceDefRefSetName::const_iterator + Iterator; + + Iterator + supports_begin () + { + return supports_.begin (); + } + + Iterator + supports_end () + { + return supports_.end (); + } + + public: + ComponentDefPtr + manages () const + { + return manages_.resolve (); + } + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "home"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + HomeDefRef inherits_; + InterfaceDefRefSetName supports_; + ComponentDefRef manages_; + }; + + typedef + DeclarationOrderComparator<HomeDefPtr> + HomeDefOrderComparator; + + typedef + std::set<HomeDefPtr, HomeDefOrderComparator> + HomeDefSet; + } + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_HOME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Makefile.alt new file mode 100644 index 00000000000..a80968aef54 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Makefile.alt @@ -0,0 +1,21 @@ +# file : CCF/IDL3/SyntaxTree/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := Component.cpp \ + EventType.cpp \ + Home.cpp \ + Operation.cpp + + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.cpp new file mode 100644 index 00000000000..a9a3f9f61a2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.cpp @@ -0,0 +1,161 @@ +// file : CCF/IDL3/SyntaxTree/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/SyntaxTree/Operation.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + // ProvidesDecl + // + // + namespace + { + TypeInfo + provides_decl_init_ () + { + TypeInfo ti (typeid (ProvidesDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo provides_decl_ (provides_decl_init_ ()); + } + + TypeInfo const& ProvidesDecl:: + static_type_info () { return provides_decl_; } + + + // UsesDecl + // + // + namespace + { + TypeInfo + uses_decl_init_ () + { + TypeInfo ti (typeid (UsesDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo uses_decl_ (uses_decl_init_ ()); + } + + TypeInfo const& UsesDecl:: + static_type_info () { return uses_decl_; } + + + // PublishesDecl + // + // + namespace + { + TypeInfo + publishes_decl_init_ () + { + TypeInfo ti (typeid (PublishesDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo publishes_decl_ (publishes_decl_init_ ()); + } + + TypeInfo const& PublishesDecl:: + static_type_info () { return publishes_decl_; } + + + // EmitsDecl + // + // + namespace + { + TypeInfo + emits_decl_init_ () + { + TypeInfo ti (typeid (EmitsDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo emits_decl_ (emits_decl_init_ ()); + } + + TypeInfo const& EmitsDecl:: + static_type_info () { return emits_decl_; } + + + // ConsumesDecl + // + // + namespace + { + TypeInfo + consumes_decl_init_ () + { + TypeInfo ti (typeid (ConsumesDecl)); + ti.add_base (Access::PUBLIC, true, Declaration::static_type_info ()); + return ti; + } + + TypeInfo consumes_decl_ (consumes_decl_init_ ()); + } + + TypeInfo const& ConsumesDecl:: + static_type_info () { return consumes_decl_; } + + + // HomeFactoryParameter + // + // + namespace + { + TypeInfo + home_factory_parameter_init_ () + { + TypeInfo ti (typeid (HomeFactoryParameter)); + ti.add_base (Access::PUBLIC, + true, + OperationParameter::static_type_info ()); + return ti; + } + + TypeInfo home_factory_parameter_ (home_factory_parameter_init_ ()); + } + + TypeInfo const& HomeFactoryParameter:: + static_type_info () { return home_factory_parameter_; } + + + + // HomeFactoryDecl + // + // + namespace + { + TypeInfo + home_factory_decl_init_ () + { + TypeInfo ti (typeid (HomeFactoryDecl)); + ti.add_base (Access::PUBLIC, + true, + OperationDecl::static_type_info ()); + return ti; + } + + TypeInfo home_factory_decl_ (home_factory_decl_init_ ()); + } + + TypeInfo const& HomeFactoryDecl:: + static_type_info () { return home_factory_decl_; } + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.hpp new file mode 100644 index 00000000000..4df39bb7efe --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SyntaxTree/Operation.hpp @@ -0,0 +1,327 @@ +// file : CCF/IDL3/SyntaxTree/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_SYNTAX_TREE_OPERATION_HPP +#define CCF_IDL3_SYNTAX_TREE_OPERATION_HPP + +#include "CCF/IDL2/SyntaxTree/Elements.hpp" +#include "CCF/IDL2/SyntaxTree/Operation.hpp" +#include "CCF/IDL2/SyntaxTree/Interface.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SyntaxTree + { + // Import nodes from IDL2 + using namespace IDL2::SyntaxTree; + + // + // + // + class ProvidesDecl : public virtual Declaration + { + public: + virtual + ~ProvidesDecl () throw () {} + + ProvidesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + type_info (static_type_info ()); + } + + public: + InterfaceDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "provides"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + InterfaceDeclRef type_; + }; + + typedef + StrictPtr<ProvidesDecl> + ProvidesDeclPtr; + + + // + // + // + class UsesDecl : public virtual Declaration + { + public: + virtual + ~UsesDecl () throw () {} + + UsesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "uses"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + }; + + typedef + StrictPtr<UsesDecl> + UsesDeclPtr; + + // + // + // + class PublishesDecl : public virtual Declaration + { + public: + virtual + ~PublishesDecl () throw () {} + + PublishesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "publishes"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + }; + + typedef + StrictPtr<PublishesDecl> + PublishesDeclPtr; + + + // + // + // + class EmitsDecl : public virtual Declaration + { + public: + virtual + ~EmitsDecl () throw () {} + + EmitsDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "emits"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + }; + + typedef + StrictPtr<EmitsDecl> + EmitsDeclPtr; + + + // + // + // + class ConsumesDecl : public virtual Declaration + { + public: + virtual + ~ConsumesDecl () throw () {} + + ConsumesDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + type_ (scope->table (), type) + { + type_info (static_type_info ()); + } + + public: + TypeDeclPtr + type () + { + return type_.resolve (); + } + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "consumes"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + TypeDeclRef type_; + }; + + typedef + StrictPtr<ConsumesDecl> + ConsumesDeclPtr; + + + // + // + // + class HomeFactoryParameter : public virtual OperationParameter + { + public: + virtual + ~HomeFactoryParameter () throw () + { + } + + HomeFactoryParameter (ScopedName type, + SimpleName name, + DeclarationTable const& table) + : OperationParameter (Direction::IN, type, name, table) + { + type_info (static_type_info ()); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<HomeFactoryParameter> + HomeFactoryParameterPtr; + + // + // + // + class HomeFactoryDecl : public virtual OperationDecl + { + public: + virtual + ~HomeFactoryDecl () throw () {} + + HomeFactoryDecl (SimpleName const& name, + ScopedName const& type, + ScopePtr const& scope) + : Declaration (name, scope), + OperationDecl (name, type, scope) + { + type_info (static_type_info ()); + } + + //@@ It would be nice to be able to kind of virtual override + // type () mf from OperationDecl with covariant return type + // technique. + + + // Runtime declaration type information + public: + virtual std::string + declaration_class () + { + return "home factory"; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + }; + + typedef + StrictPtr<HomeFactoryDecl> + HomeFactoryDeclPtr; + } + } +} + +#endif // CCF_IDL3_SYNTAX_TREE_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Token.hpp b/TAO/CIAO/CCF/CCF/IDL3/Token.hpp new file mode 100644 index 00000000000..da2a7be79f4 --- /dev/null +++ b/TAO/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/TAO/CIAO/CCF/CCF/IDL3/Traversal.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal.hpp new file mode 100644 index 00000000000..be64141f04d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal.hpp @@ -0,0 +1,26 @@ +// 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/Component.hpp" +#include "CCF/IDL3/Traversal/EventType.hpp" +#include "CCF/IDL3/Traversal/Home.hpp" +#include "CCF/IDL3/Traversal/Operation.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + using namespace IDL2::Traversal; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp new file mode 100644 index 00000000000..9b8ee9f1693 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp @@ -0,0 +1,50 @@ +// file : CCF/IDL3/Traversal/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/Traversal/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // ComponentDecl + // + // + + + // ComponentDef + // + // + + void ComponentDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void ComponentDef:: + pre (NodePtr const&) + { + } + + void ComponentDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void ComponentDef:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp new file mode 100644 index 00000000000..3207a2396d8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp @@ -0,0 +1,82 @@ +// 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/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL3/SyntaxTree/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + + // + // + // + struct ComponentDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::ComponentDeclPtr + NodePtr; + + ComponentDecl () + { + map (typeid (SyntaxTree::ComponentDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ComponentDecl> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct ComponentDef : IDL2::Traversal::ScopeTraverser + { + typedef + SyntaxTree::ComponentDefPtr + NodePtr; + + ComponentDef () + { + map (typeid (SyntaxTree::ComponentDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ComponentDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp new file mode 100644 index 00000000000..3c3df53a1f6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp @@ -0,0 +1,45 @@ +// file : CCF/IDL3/Traversal/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/Traversal/EventType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // ConcreteEventTypeDef + // + // + + void ConcreteEventTypeDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void ConcreteEventTypeDef:: + pre (NodePtr const&) + { + } + + void ConcreteEventTypeDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void ConcreteEventTypeDef:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp new file mode 100644 index 00000000000..5158838df03 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp @@ -0,0 +1,53 @@ +// 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/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL3/SyntaxTree/EventType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // + // + // + struct ConcreteEventTypeDef : IDL2::Traversal::ScopeTraverser + { + typedef + SyntaxTree::ConcreteEventTypeDefPtr + NodePtr; + + ConcreteEventTypeDef () + { + map (typeid (SyntaxTree::ConcreteEventTypeDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ConcreteEventTypeDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + }; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp new file mode 100644 index 00000000000..47012db092c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp @@ -0,0 +1,44 @@ +// 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 + { + // HomeDef + // + // + void HomeDef:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + scope (n); + post (n); + } + } + + void HomeDef:: + pre (NodePtr const&) + { + } + + void HomeDef:: + scope (NodePtr const& n) + { + delegate_scope (n); + } + + void HomeDef:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp new file mode 100644 index 00000000000..c601e4ea269 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp @@ -0,0 +1,54 @@ +// 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/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL3/SyntaxTree/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // + // + // + struct HomeDef : IDL2::Traversal::ScopeTraverser + { + typedef + SyntaxTree::HomeDefPtr + NodePtr; + + HomeDef () + { + map (typeid (SyntaxTree::HomeDef), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::HomeDef> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + scope (NodePtr const&); + + virtual void + post (NodePtr const&); + + }; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_HOME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Makefile.alt new file mode 100644 index 00000000000..24ec4b4228b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Makefile.alt @@ -0,0 +1,20 @@ +# file : CCF/IDL3/Traversal/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.pre.rules) + +cxx_translation_units := Component.cpp \ + EventType.cpp \ + Home.cpp \ + Operation.cpp + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +$(call include, $(UTILITY_ROOT)/BuildRules/Object.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.cpp new file mode 100644 index 00000000000..b60d63b0742 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.cpp @@ -0,0 +1,229 @@ +// file : CCF/IDL3/Traversal/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/IDL3/Traversal/Operation.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // ProvidesDecl + // + // + + void ProvidesDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void ProvidesDecl:: + pre (NodePtr const&) + { + } + + void ProvidesDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void ProvidesDecl:: + post (NodePtr const&) + { + } + + + // UsesDecl + // + // + + void UsesDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void UsesDecl:: + pre (NodePtr const&) + { + } + + void UsesDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void UsesDecl:: + post (NodePtr const&) + { + } + + + // PublishesDecl + // + // + + void PublishesDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void PublishesDecl:: + pre (NodePtr const&) + { + } + + void PublishesDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void PublishesDecl:: + post (NodePtr const&) + { + } + + + // EmitsDecl + // + // + + void EmitsDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void EmitsDecl:: + pre (NodePtr const&) + { + } + + void EmitsDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void EmitsDecl:: + post (NodePtr const&) + { + } + + + // ConsumesDecl + // + // + + void ConsumesDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + post (n); + } + } + + + void ConsumesDecl:: + pre (NodePtr const&) + { + } + + void ConsumesDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void ConsumesDecl:: + post (NodePtr const&) + { + } + + // HomeFactoryDecl + // + // + + void HomeFactoryDecl:: + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + type (n); + name (n); + parameters (n); + post (n); + } + } + + + void HomeFactoryDecl:: + pre (NodePtr const&) + { + } + + void HomeFactoryDecl:: + type (NodePtr const& n) + { + if (type_ != 0) type_->dispatch (n->type ()); + else dispatch (n->type ()); + } + + void HomeFactoryDecl:: + name (NodePtr const&) + { + } + + void HomeFactoryDecl:: + parameters (NodePtr const& n) + { + parameter_delegate (n); + } + + void HomeFactoryDecl:: + post (NodePtr const&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.hpp new file mode 100644 index 00000000000..1cd71b2eb99 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Operation.hpp @@ -0,0 +1,253 @@ +// file : CCF/IDL3/Traversal/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef CCF_IDL3_TRAVERSAL_OPERATION_HPP +#define CCF_IDL3_TRAVERSAL_OPERATION_HPP + +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL3/SyntaxTree/Operation.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // + // + // + struct ProvidesDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::ProvidesDeclPtr + NodePtr; + + ProvidesDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::ProvidesDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ProvidesDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct UsesDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::UsesDeclPtr + NodePtr; + + UsesDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::UsesDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::UsesDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct PublishesDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::PublishesDeclPtr + NodePtr; + + PublishesDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::PublishesDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::PublishesDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct EmitsDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::EmitsDeclPtr + NodePtr; + + EmitsDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::EmitsDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::EmitsDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct ConsumesDecl : IDL2::Traversal::Traverser + { + typedef + SyntaxTree::ConsumesDeclPtr + NodePtr; + + ConsumesDecl (Dispatcher* type = 0) + : type_ (type) + { + map (typeid (SyntaxTree::ConsumesDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ConsumesDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + + + // + // + // + struct HomeFactoryDecl : IDL2::Traversal::OperationTraverser + { + typedef + SyntaxTree::HomeFactoryDeclPtr + NodePtr; + + HomeFactoryDecl (Dispatcher* type = 0) + : OperationTraverser (type) + { + map (typeid (SyntaxTree::HomeFactoryDecl), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::HomeFactoryDecl> ()); + } + + virtual void + traverse (NodePtr const&); + + virtual void + pre (NodePtr const&); + + virtual void + type (NodePtr const&); + + virtual void + name (NodePtr const&); + + virtual void + parameters (NodePtr const&); + + virtual void + post (NodePtr const&); + + private: + Dispatcher* type_; + }; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/Makefile.alt b/TAO/CIAO/CCF/CCF/Makefile.alt new file mode 100644 index 00000000000..245593c0032 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/Makefile.alt @@ -0,0 +1,17 @@ +# file : CCF/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := .. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := IDL2 IDL3 CIDL CodeGenerationKit +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Config.rules b/TAO/CIAO/CCF/Config.rules new file mode 100644 index 00000000000..f8ed80c9b2d --- /dev/null +++ b/TAO/CIAO/CCF/Config.rules @@ -0,0 +1,8 @@ +# file : Config.rules +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +# Please provide correct values for your site: +# +BOOST_ROOT ?= +UTILITY_ROOT ?= diff --git a/TAO/CIAO/CCF/Documentation/Build.html b/TAO/CIAO/CCF/Documentation/Build.html new file mode 100644 index 00000000000..4be67e9fac1 --- /dev/null +++ b/TAO/CIAO/CCF/Documentation/Build.html @@ -0,0 +1,98 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<!-- + +file : Documentation/Build.html +author : Boris Kolpackov <boris@dre.vanderbilt.edu> +cvs-id : $id$ +--> + +<html> + +<head> + + <title>Building CCF</title> + + <meta name="author" content="Boris Kolpackov"/> + <meta name="keywords" content="build,compile,make,CCF,CORBA,compiler,framework,library"/> + <meta name="description" content="CCF building instructions"/> + <meta http-equiv="Content-Language" content="en"/> + + <style type="text/css"> + body { + font-family : arial,sans-serif; + font-size : 10pt; + } + + h1 { + font-size : 12pt; + } + + </style> + +</head> + +<body> + +<div align="center"> +<table width="700" border="0" cellspacing="0" cellpadding="0"> +<tr> +<td> + +<h1>Note: This document is somewhat outdated</h1> + +<h1>Prerequisites</h1> + +<p> +In order to build CCF you will need a standard-conformant C++ compiler. +Currently you can expect CCF to compile fine with +<a href="http://gcc.gnu.org">GCC</a> and having work-around +patch<sup><a href="#sup-1">1</a></sup> applied with +<a href="http://microsoft.com">MS VC7.1</a>. +<p> + +<p> +CCF uses a number of libraries from <a href="http://boost.org">boost</a>. +So if you don't have it installed yet then you will need to +<a href="http://boost.org/more/download.html">download and build boost</a>. +In particular <code>boost::filesystem</code> and <code>boost::regex</code> +are used by CCF and require building. So if you don't want to build what +you don't need then you may just build those two libraries. +</p> + +<p> +If you are going to use a Makefile build then you will also need +<a href="http://gnu.org/software/make">GNU make</a>. +</p> + +<h1>Building with VC7.1</h1> +<p> +In order to build CCF with VC7.1 you will need to add boost include and +library paths to your search path. After having that done you can open +MSVC solution file in <code>CCF/CCF/</code> and proceed as usual. +</p> + +<h1>Building with Makefiles</h1> +<p> +Before you run <code>make</code> you will need to create a soft link in +<code>CCF/External/</code> with name <code>boost</code> to point to +your boost directory. Also inside the boost distribution you will need +to create directory <code>lib</code> and copy (or soft link) +<code>libboost_filesystem.a</code> and <code>libboost_regex.a</code> into it. +After having all this set you can run <code>make</code> in <code>CCF/</code> +to build all libraries, tests and examples. By default compiler with name +<code>g++</code> will be used. You can change this by setting environment +variable <code>CXX</code> to whatever compiler you prefer. +</p> + +<hr size="1" /> +<a name="sup-1">1.</a> If you got CCF as part of ACE+TAO source code then +all compatibility patches are already applied. + +</td> +</tr> +</table> +</div> +</body> +</html> diff --git a/TAO/CIAO/CCF/Documentation/DesignNotes b/TAO/CIAO/CCF/Documentation/DesignNotes new file mode 100644 index 00000000000..b01fd452762 --- /dev/null +++ b/TAO/CIAO/CCF/Documentation/DesignNotes @@ -0,0 +1,457 @@ + +Intention of this file is to capture and document CIDL complier design +ideas/decisions. + +Conceptual parts of CIDL compiler design +---------------------------------------- + +Option Parser Consists of option parser and option + database. + +C Preprocessor Interfacing Represents mechanism of preprocessing + cidl files. + +IDL Compiler Interfacing Represents mechanism of invoking IDL + compiler. + +Scanner Scanner for preprocessed cidl file. + +Parser CIDL grammar parser. Consists of grammar + and semantic rules. + +Syntax Tree Intermediate representation of cidl file. + Consists of syntax tree nodes itself and + perhaps symbol tables. + +Semantic Analyzer Traverses Syntax Tree and performs + semantic analysis as well as some + semantic expansions. + + +Code Generation Stream Stream to output generated code to. Used + by concrete Code Generators + +Code Generators +{ + + Executor Mapping Generator Generator for local executor mapping. + + Executor Implementation Generator Generator for partial implementation + of local executor mapping. + + Skeleton Thunk Generator Generator for skeleton thunks i.e. + code that implements skeleton and + thunks user-defined functions to + executor mapping. +} + +Compiler driver Establishes order of execution of + different components as part of + compilation process. + + +How everything works together +----------------------------- + +(1) Compiler Driver executes Option Parser to populate Option Database + +(2) Compiler Driver executes C Preprocessor on a supplied cidl file + +(3) Compiler Driver executes Parser which uses Scanner to scan preprocessed + cidl file and generates Syntax Tree by means of semantic rules. + +(4) At this point we have Syntax Tree corresponding to the original cidl + file. Compiler Driver executes Executor Mapping Generator, + Executor Implementation Generator and Skeleton Thunk Generator on + Syntax Tree. + + + +General Design Ideas/Decision +------------- + +[IDEA]: There is an effort to use autoconf/automake in ACE/TAO. Maybe it's + a good idea to start using it with CIDLC? There is one side advantage + of this approach: if we decide to embed GCC CPP then we will have to + use configure (or otherwise ACE-ify the code which doesn't sound like + a right solution). + +[IDEA]: CIDLC is a prototype for a new IDLC, PSDLC and IfR model. Here are + basic concepts: + + - use common IDL grammar, semantic rules and syntax tree nodes + for IDLC, CIDLC, PSDLC and IfR. Possibly have several libraries + for example ast_idl-2.so, ast_idl-3.so, scaner_idl-2.so + scaner_idl-3.so, parser_idl-2.so, parser_idl-3.so. Dependency + graph would look like this: + + + ast_idl-2.so scanner_idl-2.so + | | + |---------------------------------| + | | | + | | | + | parser_idl-2.so | + | | | + ast_idl-3.so | scanner_idl-3.so + | | | + | | | + | | | + ---------parser_idl-3.so--------- + + Same idea applies for CIDL and PSDL. + + + - use the same internal representation (syntax tree) in all + compilers and IfR. This way at some stage if we will need + to make one of the compilers IfR-integrated (import keyword?) + then it will be a much easier task than it's now. This internal + representation may also be usable in typecodes + + @@ boris: not clear to me. + + @@ jeff: A typecode is like a piece of the Syntax Tree with these + exceptions - + + (1) There is no typecode for an IDL module. + + (2) Typecodes for interfaces and valuetypes lack some of the + information in the corresponding Syntax Tree nodes. + + With these exceptions in mind, a typecode can be composed and + traversed in the same manner as a Syntax Tree, perhaps with + different classes than used to compose the ST itself. + + @@ boris: Ok, let me see if I got it right. So when typecode + is kept in parsed state (as opposite to binary) (btw, when + does it happen?) it makes sense to apply the same techniques + (if in fact not the same ST nodes and traversal mechs) as + for XIDL compilation. + +[IDEA]: We should be consistent with the way external compilers that we call + report errors. For now those are CPP and IDLC. + +Option Parser +------------- + +[IDEA]: Use Spirit parser framework to generate option parser. + +[IDEA]: Option Database is probably a singleton. + + @@ jeff: This is a good idea, especially when passing some of the + options to a preprocessor or spawned IDL compier. But I think we + will still need 'state' classes for the front and back ends (to + hold values set by command line options and default values) so + we can keep them decoupled). + + + @@ boris: I understand what you mean. Though I think we will be + able to do with one 'runtime database'. Each 'compiler module' + will be able to populate its 'namespace' with (1) default + values, (2) with module-specific options and (3) arbitrary + runtime information. I will present prototopy design shortly. + + +[IDEA]: It seems we will have to execute at least two external programs + as part of CIDLC execution: CPP and IDLC. Why wouldn't we follow + GCC specs model (gcc -dumpspecs). Here are candidates to be put into + specs: + + - default CPP name and options + - default IDLC name and options + - default file extensions and formats for different mappings + - other ideas? + +[IDEA]: Provide short and long option names (e.g. -o and --output-dir) + for every option (maybe except -I, -D, etc). + + +C Preprocessor Interfacing +-------------------------- + +[IDEA]: Embed/require GCC CPP + +[IDEA]: We need a new model of handling includes in CIDLC (as well as IDLC). + Right now I'm mentally testing a new model (thanks to Carlos for the + comments). Soon I will put the description here. + +[IDEA]: We cannot move cidl file being preprocessed to for example /tmp + as it's currently the case with IDLC. + +[IDEA]: Can we use pipes (ACE Pipes) portably to avoid temporary files? + (Kitty, you had some ideas about that?) + + + +IDL Compiler Interfacing +------------------------ + +[IDEA]: Same as for CPP: Can we use pipes? + + @@ jeff: check with Nanbor on this. I think there may be CCM/CIAO + use cases where we need the intermediate IDL file. + +[IDEA]: Will need a mechanism to pass options to IDLC from CIDLC command + line (would be nice to have this ability for CPP as well). + Something like -x in xterm? Better ideas? + + + +Scanner +------ + +[IDEA]: Use Spirit framework to construct scanner. The resulting sequence + can be sequence of objects? BTW, Spirit parser expects a "forward + iterator"-based scanner. So this basically mean that we may have to + keep the whole sequence in memory. BTW, this is another good reason + to have scanner: if we manage to make scanner a predictable parser + (i.e. no backtracking) then we don't have to keep the whole + preprocessed cidl file in memory. + + + +Parser +------ + +[IDEA]: Use Spirit framework to construct parser. + +[IDEA]: Define IDL grammar as a number of grammar capsules. This way it's + much easier to reuse/inherit even dynamically. Need to elaborate + this idea. + +[IDEA]: Use functors as semantic actions. This way we can specify (via + functor's data member) on which Syntax Tree they are working. + Bad side: semantic rules are defined during grammar construction. + However we can use a modification of the factory method pattern. + Better ideas? + + @@ jeff: I think ST node creation with a factory + is a good idea - another ST implementation could be plugged in, + as long as it uses a factory with the same method names. + + @@ boris: Right. In fact it's our 'improved' way of handling 'BE' + usecases. + + + +Syntax Tree +----------- + +[IDEA]: Use interface repository model as a base for Syntax Tree hierarchy. + +[IDEA]: Currently (in IDLC) symbol lookup is accomplished by AST navigation, + and is probably the biggest single bottleneck in performance. Perhaps + a separate symbol table would be preferable. Also, lookups could be + specialized, e.g., for declaration, for references, and perhaps a + third type for argument-related lookups. + +[NOTE]: If we are to implement symbol tables then we need to think how we + are going to inherit (extend) this tables. + +[NOTE]: Inheritance/supports graphs: these graphs need to be traversed at + several points in the back end. Currently they are rebuilt for each + use, using an n-squared algorithm. We could at least build them only + once for each interface/valuetype, perhaps even with a better + algorithm. It could be integrated into inheritance/supports error + checking at node creation time, which also be streamlined. + + @@ boris: Well, I think we should design our Syntax Tree so that + every interface/valuetype has a list (flat?) of interfaces it + inherits from/supports. + +[IDEA]: We will probably want to use factories to instantiate Syntax Tree + Nodes (STN). This will allow a concrete code generators to alter (i.e. + inherit off and extend) vanilla STNs (i.e. alternative to BE nodes + in current IDLC design). + + +Common Syntax Tree traversal Design Ideas/Decision +-------------------------------------------------- + +[IDEA] If we specify Syntax Tree traversal facility then we will be able + to specify (or even plug dynamically) Syntax Tree traversal agents + that may not only generate something but also annotate or modify + Syntax Tree. We are already using this technique for a number of + features (e.g. AMI, IDL3 extension, what else?) but all these agents + are hardwired inside TAO IDLC. If we have this facility then we will + be able to produce modular and highly extensible design. Notes: + + - Some traversal agents can change Syntax Tree so that it will be + unusable by some later traversal agents. So maybe the more + generic approach would be to produce new Syntax Tree? + + @@ jeff: Yes, say for example that we were using a common ST + representation for the IDL compiler and the IFR. We would not + want to send the extra AMI nodes to the IFR so in that case + simple modification of the ST might not be best. + +[IDEA] Need a generic name for "Syntax Tree Traversal Agents". What about + "Syntax Tree Traverser"? + + +Code Generation Stream +---------------------- + +[IDEA] Use language indentation engines for code generation (like a c-mode + in emacs). The idea is that code like this + + out << "long foo (long arg0, " << endl + << " long arg1) " << endl + << "{ " << endl + << " return arg0 + arg1; " << endl + << "} " << endl; + + will result in a generated code like this: + + namespace N + { + ... + + long foo (long arg0, + long arg1) + { + return arg0 + arg1; + } + + ... + } + + Note that no special actions were taken to ensure proper indentation. + Instead the stream's indentation engine is responsible for that. + The same mech can be used for different languages (e.g. XML). + + +Code Generators +--------------- + +[IDEA] It makes sense to establish a general concept of code generators. + "Executor Mapping Generator", "Executor Implementation Generator" + and "Skeleton Thunk Generator" would be a concrete code generators. + +[IDEA] Expression evaluation: currently the result (not the expression) + is generated, which may not always be necessary. + + @@ boris: I would say may not always be correct + + + However, for purposes of type coercion and other checking (such as + for positive integer values in string, array and sequence bounds) + evaluation must be done internally. + + @@ boris: note that evaluation is needed to only verify that things + are correct. You don't have to (shouldn't?) substitute original + (const) expression with what's been evaluated. + + + @@ jeff: it may be necessary in some cases to append 'f' or 'U' to + a generated number to avoid a C++ compiler warning. + + @@ boris: shouldn't this 'f' and 'U' be in IDL as well? + +[IDEA] I wonder if it's a good idea to use a separate pass over syntax tree + for semantic checking (e.g. type coercion, positive values for + sequence bounds). + + @@ jeff: This may hurt performance a little - more lookups - but it + will improve error reporting. + + @@ boris: As we dicussed earlier this pass could be used to do + 'semantic expansions' (e.g. calculate a flat list of interface's + children, etc). Also I don't think we should worry about speed + very much here (of course I don't say we have to be stupid ;-) + In fact if we are trading better design vs faster compilation + at this stage we should always go for better design. + + +Executor Mapping Generator +-------------------------- + + + +Executor Implementation Generator +-------------------------------- + +[IDEA]: Translate CIDL composition to C++ namespace. + + + +Skeleton Thunk Generator +------------------------ + + + + +Compiler driver +--------------- + + + +Vault +----- + +Some thoughts from Jeff that I are not directly related to CIDLC and are +rather current IDLC design defects: + +* AMI/AMH implied IDL: more can be done in the BE preprocessing pass, + hopefully eliminating a big chunk of the huge volume of AMI/AMH visitor + code. The implied IDL generated for CCM types, for example, leaves almost + nothing extra for the visitors to do. + +* Fwd decl redefinition: forward declaration nodes all initially contain a + heap-allocated dummy full-definition member, later replaced by a copy + of the full definition. This needs to be streamlined. + +* Memory leaks: inconsistent copying/passing policies make it almost + impossible to eliminate the huge number of leaks. The front end will be + more and more reused, and it may be desirable to make it executable as a + function call, in which case it will important to eliminate the leaks. + Perhaps copying of AST nodes can be eliminated with reference counting or + just with careful management, similarly for string identifiers and literals. + Destroy() methods have been put in all the node classes, and are called + recursively from the AST root at destruction time, but they are far from + doing a complete job. + +* Visitor instantiation: the huge visitor factory has already been much + reduced, and the huge enum of context state values is being reduced. + However there will still be an abundance of switch statements at nearly + every instance of visitor creation at scope nesting. We could make better + use of polymorphism to get rid of them. + +* Node narrowing: instead of the impenetrable macros we use now, we + could either generate valuetype-like downcast methods for the (C)IDL + types, or we could just use dynamic_cast. + +* Error reporting: making error messages more informative, and error recovery + could both be a lot better, as they are in most other IDL compilers. If a + recursive descent parser is used (such as Spirit), there is a simple + generic algorithm for error recovery. + + +* FE/BE node classes: if BE node classes are implemented at all, there should + be a complete separation of concerns - BE node classes should contain only + info related to code generation, and FE node classes should contain only + info related to the AST representation. As the front end becomes more + modular and reusable, this will become more and more necessary. + + @@ boris: It doesn't seem we will need two separate and parallel hierarhies. + +* Undefined fwd decls: now that we have dropped support for platforms without + namespaces, the code generated for fwd declarations not defined in the same + translation unit can be much improved, most likely by the elimination of + generated flat-name global methods, and perhaps other improvements as well. + +* Strategized code generation: many places now have either lots of + duplication, or an explosion of branching in a single visitor. Adding code + generation for use cases incrementally may give us an opportunity to + refactor and strategize it better. + +* Node generator: this class does nothing more than call 'new' and pass + unchanged the arguments it gets to the appropriate constructor - it can be + eliminated. + +* Virtual methods: there are many member functions in the IDL compiler that + are needlessly virtual. + +* Misc. leveraging: redesign of mechanisms listed above can have an effect + on other mechanisms, such as the handling of pragma prefix, typeprefix, and + reopened modules. diff --git a/TAO/CIAO/CCF/Documentation/TODO b/TAO/CIAO/CCF/Documentation/TODO new file mode 100644 index 00000000000..b616bced60a --- /dev/null +++ b/TAO/CIAO/CCF/Documentation/TODO @@ -0,0 +1,42 @@ +@@ post-cvs: write build instructions + +@@+ add Elements to IDL3 and CIDL for consistency + +@@+ Should CIDL syntax tree files have 'using namespace IDL2::SyntaxTree;' + directives? + +@@++ Add traversal of inheritance list as done for scope. + +@@+ it's a good idea to include ostream instead of iostream where I only + use ostreams + +@@+++ Currently character stream is scanned completely before parsing. The + better approach would be scanning on demand (1). + +@@+++ IDL2::Parsing::parse () should be eliminated (or terminated if you + like ;-). This item depends on (1) + +@@++ 'using namespace' cleanup + +@@+++ Diagnostic evolution + +@@++ XML indentation buffer + +@@+++ Anonymous types and typedef's model + +@@+++ Intorduction (injection) of names into scope + +@@++++ C Preporcessor integration (wave) + +@@ IDL feature: type id/prefix + +@@ IDL feature: exceptions + +@@ IDL feature: built-in types + +@@ IDL feature: sequences + +@@ IDL feature: struct + +@@ IDL feature: literals and expressions + diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp new file mode 100644 index 00000000000..95aae427d60 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp @@ -0,0 +1,1054 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "ExecutorMappingGenerator.hpp" + +#include <map> +#include <ostream> +#include <fstream> + +#include "CCF/CIDL/SyntaxTree.hpp" +#include "CCF/CIDL/Traversal.hpp" + +#include "CCF/CodeGenerationKit/Regex.hpp" +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +using std::cout; +using std::endl; +using std::string; +using std::make_pair; + +using namespace CCF::CIDL; +using namespace SyntaxTree; + +/* + +@@ bad code: i->scope ()->table () + +*/ + +namespace +{ + class Declarations + { + public: + bool + add (HomeDefPtr const& h) + { + return homes_.insert (h).second; + } + + bool + add (ComponentDefPtr const& c) + { + return components_.insert (c).second; + } + + bool + add (CompositionPtr const& cs, ComponentDefPtr const& cn) + { + return compositions_.insert (make_pair(cs, cn)).second; + } + + bool + add (UnconstrainedInterfaceDeclPtr const& i) + { + return interfaces_.insert (i).second; + } + + public: + bool + find (HomeDefPtr const& h) const + { + return homes_.find (h) != homes_.end (); + } + + bool + find (ComponentDefPtr const& c) const + { + return components_.find (c) != components_.end (); + } + + bool + find (CompositionPtr const& c) const + { + return compositions_.find (c) != compositions_.end (); + } + + bool + find (UnconstrainedInterfaceDeclPtr const& i) const + { + return interfaces_.find (i) != interfaces_.end (); + } + + public: + ComponentDefPtr + resolve (CompositionPtr const& c) const + { + CompositionMap::const_iterator i = compositions_.find (c); + if (i != compositions_.end ()) + { + return i->second; + } + else + { + return ComponentDefPtr (0); + } + } + + public: + bool + contains_suborder (Order const& o) const + { + for (UnconstrainedInterfaceDeclSet::const_iterator i = + interfaces_.begin (); + i != interfaces_.end (); + i++) + { + if (o.suborder ((*i)->order ())) return true; + } + + for (ComponentDefSet::const_iterator i = components_.begin (); + i != components_.end (); + i++) + { + if (o.suborder ((*i)->order ())) return true; + } + + for (HomeDefSet::const_iterator i = homes_.begin (); + i != homes_.end (); + i++) + { + if (o.suborder ((*i)->order ())) return true; + } + + for (CompositionMap::const_iterator i = compositions_.begin (); + i != compositions_.end (); + i++) + { + if (o.suborder (i->first->order ())) return true; + } + + return false; + } + + private: + typedef + std::map <CompositionPtr, ComponentDefPtr, CompositionOrderComparator> + CompositionMap; + + HomeDefSet homes_; + ComponentDefSet components_; + CompositionMap compositions_; + UnconstrainedInterfaceDeclSet interfaces_; + }; + + + // + // + // + class HomeCollector : public Traversal::HomeDef + { + public: + HomeCollector (Declarations& declarations) + : declarations_ (declarations) + { + } + + virtual void + traverse (HomeDefPtr const& h) + { + ScopedName n (h->name ()); + + ScopedName main (n.scope (), "CCM_" + n.simple ()); + ScopedName expl (n.scope (), "CCM_" + n.simple () + "Explicit"); + ScopedName impl (n.scope (), "CCM_" + n.simple () + "Implicit"); + + // Check if mapping has already been provided. + if (h->table ().exist (main) || + h->table ().exist (expl) || + h->table ().exist (impl)) return; + + if(declarations_.add (h)) + { + // Note that I don't go after components that inherited home manages + // because it will be handled by component inheritance tree. + // + if (h->inherits ()) traverse (h->inherits ().resolve ()); + } + } + + private: + Declarations& declarations_; + }; + + // + // + // + class ComponentCollector : public Traversal::ComponentDef + { + public: + ComponentCollector (Declarations& declarations) + : declarations_ (declarations) + { + } + + virtual void + pre (ComponentDefPtr const& c) + { + ScopedName n (c->name ()); + + ScopedName monolith (n.scope (), "CCM_" + n.simple ()); + ScopedName context (n.scope (), "CCM_" + n.simple () + "_Context"); + + // Check if mapping has already been provided. + if (c->table ().exist (context) || + c->table ().exist (monolith)) return; + + if(declarations_.add (c)) + { + if (c->inherits ()) + { + traverse (c->inherits ().resolve ()); + } + } + } + + private: + Declarations& declarations_; + }; + + // + // + // + class InterfaceCollector : public Traversal::UnconstrainedInterfaceDecl + { + public: + InterfaceCollector (Declarations& declarations) + : declarations_ (declarations) + { + } + + virtual void + traverse (UnconstrainedInterfaceDeclPtr const& i) + { + ScopedName orig (i->name ()); + ScopedName mapping (orig.scope (), "CCM_" + orig.simple ()); + + // Check if mapping has already been provided. + if (i->scope ()->table ().exist (mapping)) return; + + // Add to the list if it's not already there. + declarations_.add (i); + } + + private: + Declarations& declarations_; + }; + + + // + // + // + class HomeExecutorCollector : public Traversal::HomeExecutor + { + public: + HomeExecutorCollector (Declarations& declarations, + Traversal::Dispatcher* home_collector, + Traversal::Dispatcher* component_collector) + : declarations_ (declarations), + home_collector_ (home_collector), + component_collector_ (component_collector) + { + } + + virtual void + traverse (HomeExecutorPtr const& he) + { + HomeDefPtr home (he->implements ()); + home_collector_->dispatch (home); + + ComponentDefPtr component (home->manages ()); + component_collector_->dispatch (component); + + CompositionPtr composition ( + he->scope ()->dynamic_type<SyntaxTree::Composition> ()); + declarations_.add (composition, component); + } + + private: + Declarations& declarations_; + + Traversal::Dispatcher* home_collector_; + Traversal::Dispatcher* component_collector_; + }; + + + // + // + // + class TypeNameEmitter : public Traversal::BuiltInTypeDef, + public Traversal::TypeDecl + { + public: + TypeNameEmitter (std::ostream& os_) + : os (os_) + { + } + + virtual void + traverse (BuiltInTypeDefPtr const& t) + { + os << t->name ().simple (); + } + + virtual void + traverse (TypeDeclPtr const& t) + { + os << t->name (); + } + + private: + std::ostream& os; + }; + + + // + // + // + class ComponentEmitter : public Traversal::ComponentDef + { + public: + ComponentEmitter (Declarations const& declarations) + : declarations_ (declarations) + { + } + + virtual void + traverse (ComponentDefPtr const& c) + { + if (declarations_.find (c)) + { + Traversal::ComponentDef::traverse (c); + } + } + + private: + Declarations const& declarations_; + }; + + + // MonolithEmitter generates what spec calls 'Monolithic Component + // Executor'. + // + class MonolithEmitter : public Traversal::ComponentDef, + public Traversal::AttributeDecl, + public Traversal::ProvidesDecl, + public Traversal::ConsumesDecl + { + public: + MonolithEmitter (std::ostream& os_, + Traversal::Dispatcher* type_name_emitter) + : AttributeDecl (type_name_emitter), + os (os_) + { + } + + virtual void + pre (ComponentDefPtr const& c) + { + os << "local interface CCM_" << c->name ().simple () << " : "; + + ComponentDefRef cr = c->inherits (); + + if (cr) + { + os << cr.name ().scope () << "::CCM_" << cr.name ().simple (); + } + else + { + os << "::Components::EnterpriseComponent"; + } + + for (SyntaxTree::ComponentDef::Iterator i = c->supports_begin (); + i != c->supports_end (); + i++) + { + os << ", " << i->name (); + } + + os << "{"; + } + + virtual void + pre (AttributeDeclPtr const& a) + { + os << "attribute "; + } + + virtual void + post (AttributeDeclPtr const& a) + { + os << " " << a->name ().simple () << ";"; + } + + virtual void + traverse (ProvidesDeclPtr const& p) + { + ScopedName n = p->type ()->name (); + + os << n.scope () << "::CCM_" << n.simple () + << " get_" << p->name ().simple () << " ();"; + } + + virtual void + traverse (ConsumesDeclPtr const& p) + { + os << "void push_" << p->name ().simple () << " (" + << "in " << p->type()->name () << " ev);"; + } + + virtual void + post (ComponentDefPtr const& c) + { + os << "};" << endl; + } + + private: + std::ostream& os; + }; + + // ContextEmitter generates component context interface. + // + // + class ContextEmitter : public Traversal::ComponentDef, + public Traversal::UsesDecl, + public Traversal::PublishesDecl, + public Traversal::EmitsDecl + { + public: + ContextEmitter (std::ostream& os_) : os (os_) {} + + virtual void + pre (ComponentDefPtr const& c) + { + os << "local interface CCM_" << c->name ().simple () << "_Context : "; + + ComponentDefRef cr = c->inherits (); + + if (cr) + { + ScopedName name (cr.name ()); + os << name.scope () << "::CCM_" << name.simple () << "_Context"; + } + else + { + os << "::Components::CCMContext"; + } + + os << "{"; + } + + virtual void + traverse (UsesDeclPtr const& d) + { + os << d->type ()->name () + << " get_connection_" << d->name ().simple () << " ();"; + } + + virtual void + traverse (PublishesDeclPtr const& d) + { + os << "void push_" << d->name ().simple () << " (" + << "in " << d->type ()->name () << " ev);"; + } + + virtual void + traverse (EmitsDeclPtr const& d) + { + os << "void push_" << d->name ().simple () << " (" + << "in " << d->type ()->name () << " ev);"; + } + + virtual void + post (ComponentDefPtr const& c) + { + os << "};" << endl; + } + + private: + std::ostream& os; + }; + + + // + // + // + class HomeEmitter : public Traversal::HomeDef + { + public: + HomeEmitter (Declarations const& declarations) + : declarations_ (declarations) + { + } + + virtual void + traverse (HomeDefPtr const& h) + { + if (declarations_.find (h)) + { + Traversal::HomeDef::traverse (h); + } + } + + private: + Declarations const& declarations_; + }; + + // HomeExplicitEmitter generates home explicit interface + // + // + class HomeExplicitEmitter : public Traversal::OperationParameter, + public Traversal::Comma, + public Traversal::HomeFactoryDecl, + public Traversal::OperationDecl, + public Traversal::AttributeDecl, + public Traversal::HomeDef + { + public: + HomeExplicitEmitter (std::ostream& os_, + Traversal::Dispatcher* type_name_emitter) + : OperationParameter (type_name_emitter, + type_name_emitter, + type_name_emitter), + + OperationDecl (type_name_emitter), + AttributeDecl (type_name_emitter), + os (os_) + { + } + + virtual void + pre (HomeDefPtr const& h) + { + os << "local interface CCM_" << h->name ().simple () << "Explicit : "; + + HomeDefRef hr = h->inherits (); + + if (hr) + { + ScopedName name (hr.name ()); + os << name.scope () << "::CCM_" << name.simple () << "Explicit"; + } + else + { + os << "::Components::HomeExecutorBase"; + } + + for (SyntaxTree::HomeDef::Iterator i = h->supports_begin (); + i != h->supports_end (); + i++) + { + os << ", " << i->name (); + } + + os << "{"; + + } + + virtual void + post (HomeDefPtr const& h) + { + os << "};" << endl; + } + + // + // OperationParameter + // + + virtual void + post (OperationParameterPtr const& op) + { + os << " " << op->name (); + } + + virtual void + traverse (CommaPtr const& s) + { + os << ", "; + } + + // + // HomeFactory + // + + virtual void + type (HomeFactoryDeclPtr const& d) + { + os << "::Components::EnterpriseComponent "; + } + + virtual void + name (HomeFactoryDeclPtr const& d) + { + os << d->name ().simple () << " ("; + } + + virtual void + post (HomeFactoryDeclPtr const& d) + { + os << ");"; + } + + // + // Operation + // + + virtual void + name (OperationDeclPtr const& d) + { + os << " " << d->name ().simple () << " ("; + } + + virtual void + pre (OperationParameterPtr const& op) + { + os << op->direction () << " "; + } + + virtual void + post (OperationDeclPtr const& d) + { + os << ");"; + } + + // + // Attribute + // + + virtual void + pre (AttributeDeclPtr const& a) + { + os << "attribute "; + } + + virtual void + post (AttributeDeclPtr const& a) + { + os << " " << a->name ().simple () << ";"; + } + + private: + std::ostream& os; + }; + + + // HomeImplicitEmitter generates home implicit interface + // + // + class HomeImplicitEmitter : public Traversal::HomeDef + { + public: + HomeImplicitEmitter (std::ostream& os_) : os (os_) {} + + virtual void + pre (HomeDefPtr const& h) + { + os << "local interface " << "CCM_" << h->name ().simple () << "Implicit" + << "{" + << "::Components::EnterpriseComponent " + << "create () raises (::Components::CCMException);"; + } + + virtual void + post (HomeDefPtr const& h) + { + os << "};" << endl; + } + + private: + std::ostream& os; + }; + + + // HomeMainEmitter generates home main interface + // + // + class HomeMainEmitter : public Traversal::HomeDef + { + public: + HomeMainEmitter (std::ostream& os_) : os (os_) {} + + virtual void + traverse (HomeDefPtr const& h) + { + SimpleName name = h->name ().simple (); + + os << "local interface CCM_" << name << " : " + << "CCM_" << name << "Explicit, " + << "CCM_" << name << "Implicit" + << "{" + << "};" << endl; + } + + private: + std::ostream& os; + }; + + // + // + // + class IncludeEmitter : public Traversal::PrincipalTranslationRegion, + public Traversal::UserIncludeTranslationRegion, + public Traversal::SysIncludeTranslationRegion, + public Traversal::ImpliedIncludeTranslationRegion + { + public: + IncludeEmitter (std::ostream& os_) : os (os_) {} + + virtual void + traverse (ImpliedIncludeTranslationRegionPtr const& r) + { + os << "#include <" << r->file_path ().string () << ">" << endl; + } + + virtual void + traverse (UserIncludeTranslationRegionPtr const& r) + { + os << "#include \"" << r->file_path ().string () << "\"" << endl; + } + + virtual void + traverse (SysIncludeTranslationRegionPtr const& r) + { + os << "#include <" << r->file_path ().string () << ">" << endl; + } + + private: + std::ostream& os; + }; + + // + // + // + class ModuleEmitter : public Traversal::Module + { + public: + ModuleEmitter (std::ostream& os_, + Declarations const& declarations) + : os (os_), + declarations_ (declarations) + { + } + + public: + + virtual void + traverse (ModulePtr const& m) + { + if (declarations_.contains_suborder (m->order ())) + { + Traversal::Module::traverse (m); + } + } + + virtual void + pre (ModulePtr const& m) + { + os << "module " << m->name ().simple () << "{"; + } + + virtual void + post (ModulePtr const& m) + { + os << "};" << endl; + } + + private: + std::ostream& os; + Declarations const& declarations_; + }; + + // + // + // + class InterfaceEmitter : public Traversal::UnconstrainedInterfaceDecl + { + public: + InterfaceEmitter (std::ostream& os_, + Declarations const& declarations) + : os (os_), + declarations_ (declarations) + { + } + + public: + virtual void + traverse (UnconstrainedInterfaceDeclPtr const& i) + { + if (declarations_.find (i)) + { + os << "local interface CCM_" << i->name ().simple () + << " : " << i->name ().simple () + << "{};" << endl; + } + } + + private: + std::ostream& os; + Declarations const& declarations_; + }; + + // + // + // + class CompositionEmitter : public Traversal::Composition + { + public: + CompositionEmitter (std::ostream& os_, + Declarations const& declarations) + : os (os_), + declarations_ (declarations) + { + } + + public: + + virtual void + traverse (CompositionPtr const& c) + { + if (declarations_.find (c)) + { + Traversal::Composition::traverse (c); + } + } + + virtual void + pre (CompositionPtr const& c) + { + ComponentDefPtr component (declarations_.resolve (c)); + ScopedName name (component->name ()); + + SyntaxTree::Composition::Category::Value category = c->category (); + + os << "module " << c->name ().simple () + << "{"; + + os << "local interface " << name.simple () << "Context : " + << name.scope () << "::CCM_" << name.simple () << "_Context, "; + + switch (category) + { + case SyntaxTree::Composition::Category::ENTITY: + { + os << "::Components::EntityContext"; + break; + } + default: + { + os << "::Components::SessionContext"; + break; + } + } + + os << "{};" << endl; + } + + virtual void + post (CompositionPtr const& c) + { + os << "};" << endl; + } + + private: + std::ostream& os; + Declarations const& declarations_; + }; +} + +void ExecutorMappingGenerator:: +options (CL::Description& d) +{ + d.add_option (CL::OptionDescription ( + "lem-file-suffix", + "suffix", + "Use provided suffix instead of default \'_exec\' " + "when constructing name of local executor mapping file.", + true)); + + d.add_option (CL::OptionDescription ( + "lem-file-regex", + "regex", + "Use provided regular expression when constructing " + "name of local executor mapping file.", + true)); + + d.add_option (CL::OptionDescription ( + "lem-force-all", + "Force generation of local executor mapping for all IDL " + "types including those not used (directly or inderectly) " + "by compositions. This option is useful for generating a " + "common portion of local executor mapping used by more " + "than one component or composition.", + true)); +} + + +void ExecutorMappingGenerator:: +generate (CommandLine const& cl, + TranslationUnitPtr const& u) +{ + fs::path file_path = u->principal_translation_region ()->file_path (); + + fs::ofstream ofs; + + if (!file_path.empty ()) + { + string file_name = file_path.leaf (); + + string suffix = cl.get_value ("lem-file-suffix", "_exec.idl"); + string expr = cl.get_value ( + "lem-file-regex", + "/(\\.(idl|cidl))?$/" + suffix + "/"); + + string lem_file_name = regex::perl_s (file_name, expr); + + fs::path lem_file_path (lem_file_name); + + ofs.open (lem_file_path); + + if (!ofs.is_open ()) + { + cerr << lem_file_name << ": error: unable to open in write mode" + << endl; + return; + } + } + + std::ostream& os = ofs.is_open () ? ofs : std::cout; + + // Set auto-indentation for os + Indentation::Implanter<Indentation::IDL> guard (os); + + Declarations declarations; + + if (cl.get_value ("lem-force-all", false)) + { + InterfaceCollector interface (declarations); + Traversal::ProvidesDecl provides (&interface); + + ComponentCollector component (declarations); + component.add_scope_delegate (&provides); + + HomeCollector home (declarations); + + // Note the trick. interface is of type InterfaceDecl but I only + // want to traverse InterfaceDef's. So I use original InterfaceDef but + // delegate to InterfaceDecl. + // + Traversal::UnconstrainedInterfaceDef interface_def; + interface_def.add_delegate (&interface); + + Traversal::Module module; + module.add_scope_delegate (&home); + module.add_scope_delegate (&component); + module.add_scope_delegate (&interface_def); + + Traversal::FileScope file_scope; + file_scope.add_scope_delegate (&module); + file_scope.add_scope_delegate (&home); + file_scope.add_scope_delegate (&component); + file_scope.add_scope_delegate (&interface_def); + + Traversal::PrincipalTranslationRegion region (&file_scope); + + Traversal::TranslationUnit unit; + unit.add_content_delegate (®ion); + + unit.dispatch (u); + } + else + { + InterfaceCollector interface (declarations); + Traversal::ProvidesDecl provides (&interface); + + ComponentCollector component (declarations); + component.add_scope_delegate (&provides); + + HomeCollector home (declarations); + + HomeExecutorCollector home_executor (declarations, &home, &component); + + Traversal::Composition composition; + composition.add_scope_delegate (&home_executor); + + Traversal::Scope scope; + scope.add_scope_delegate (&composition); + scope.add_scope_delegate (&scope); + + Traversal::Module module; + module.add_scope_delegate (&composition); + + Traversal::FileScope file_scope; + file_scope.add_scope_delegate (&module); + file_scope.add_scope_delegate (&composition); + + Traversal::PrincipalTranslationRegion region (&file_scope); + + Traversal::TranslationUnit unit; + unit.add_content_delegate (®ion); + + unit.dispatch (u); + } + + { + TypeNameEmitter type_name (os); + + MonolithEmitter monolith (os, &type_name); + ContextEmitter context (os); + + ComponentEmitter component (declarations); + component.add_delegate (&monolith); + component.add_delegate (&context); + + HomeImplicitEmitter home_implicit (os); + HomeExplicitEmitter home_explicit (os, &type_name); + HomeMainEmitter home_main (os); + + HomeEmitter home (declarations); + home.add_delegate (&home_implicit); + home.add_delegate (&home_explicit); + home.add_delegate (&home_main); + + InterfaceEmitter interface (os, declarations); + CompositionEmitter composition (os, declarations); + + ModuleEmitter module (os, declarations); + + module.add_scope_delegate (&interface); + module.add_scope_delegate (&component); + module.add_scope_delegate (&home); + module.add_scope_delegate (&composition); + module.add_scope_delegate (&module); + + Traversal::FileScope file_scope; + file_scope.add_scope_delegate (&module); + file_scope.add_scope_delegate (&interface); + file_scope.add_scope_delegate (&component); + file_scope.add_scope_delegate (&home); + file_scope.add_scope_delegate (&composition); + + + Traversal::TranslationRegion region (&file_scope); + + IncludeEmitter include (os); + + Traversal::TranslationUnit unit; + unit.add_content_delegate (&include); + unit.add_content_delegate (®ion); + + unit.dispatch (u); + } +} diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.hpp b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.hpp new file mode 100644 index 00000000000..f9453eb6b07 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.hpp @@ -0,0 +1,27 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#ifndef EXECUTOR_MAPPING_GENERATOR_HPP +#define EXECUTOR_MAPPING_GENERATOR_HPP + +#include "CCF/CodeGenerationKit/CommandLine.hpp" +#include "CCF/CodeGenerationKit/CommandLineDescriptor.hpp" + +//@@ Don't really nee this. just forward declaration of TranslationUnit would +// be enough. +#include "CCF/CIDL/SyntaxTree.hpp" + +class ExecutorMappingGenerator +{ +public: + + void + options (CL::Description& d); + + void + generate (CommandLine const& cl, + CCF::CIDL::SyntaxTree::TranslationUnitPtr const&); +}; + +#endif // EXECUTOR_MAPPING_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/Makefile.alt b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/Makefile.alt new file mode 100644 index 00000000000..68669e19517 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/Makefile.alt @@ -0,0 +1,35 @@ +# file : Example/CIDL/LocalExecutorMapping/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.pre.rules) + +cxx_translation_units := ExecutorMappingGenerator.cpp cidlc.cpp + +module_base := cidlc +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +CXX_LINK_LIBS += -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(root)/CCF/IDL3 \ + -lIDL3 \ + -L$(root)/CCF/CIDL \ + -lCIDL \ + -L$(root)/CCF/CodeGenerationKit \ + -lCodeGenerationKit \ + -L$(root)/CCF/CompilerElements \ + -lCompilerElements \ + -L$(BOOST_ROOT)/lib \ + -lboost_regex \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp new file mode 100644 index 00000000000..06b86a22efb --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp @@ -0,0 +1,245 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/Context.hpp" + +#include "CCF/CodeGenerationKit/CommandLine.hpp" +#include "CCF/CodeGenerationKit/CommandLineParser.hpp" +#include "CCF/CodeGenerationKit/CommandLineDescriptor.hpp" + +#include "CCF/CIDL/LexicalAnalyzer.hpp" +#include "CCF/CIDL/Parser.hpp" +#include "CCF/CIDL/SyntaxTree.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +#include "ExecutorMappingGenerator.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +using namespace CCF; +using namespace CIDL; +using namespace SyntaxTree; + +int main (int argc, char* argv[]) +{ + + try + { + // Parsing command line options and arguments + // + // + CommandLine cl; + + if (!parse (argc, argv, cl)) + { + cerr << "command line syntax error" << endl; + cerr << "try " << argv[0] << " --help for usage information" << endl; + return -1; + } + + ExecutorMappingGenerator lem_gen; + + if (cl.get_value ("help", false) || cl.get_value ("help-html", false)) + { + CL::Description d (argv[0]); + + lem_gen.options (d); + + d.add_option (CL::OptionDescription ( + "trace-semantic-actions", + "Turn on semnatic actions tracing facility.", + true)); + + d.add_option (CL::OptionDescription ( + "preprocess-only", + "Run preprocessor only and output result to stdout.", + true)); + + d.add_option (CL::OptionDescription ( + "help", + "Display usage information and exit.", + true)); + + d.add_option (CL::OptionDescription ( + "help-html", + "Dump usage information in html format and exit.", + true)); + + d.add_argument ("cidl file"); + + if (cl.get_value ("help-html", false)) CL::print_html (cerr, d); + else CL::print_text (cerr, d); + + return 0; + } + + + fs::ifstream ifs; + ifs.exceptions (ios_base::badbit | ios_base::failbit); + + fs::path file_path; + + CommandLine::ArgumentIterator i = cl.argument_begin (); + + if (i != cl.argument_end ()) + { + try + { + file_path = fs::path (*i, fs::native); + ifs.open (file_path); + } + catch (fs::filesystem_error const&) + { + cerr << *i << ": error: unable to open in read mode" << endl; + return -1; + } + catch (std::ios_base::failure const&) + { + cerr << *i << ": error: unable to open in read mode" << endl; + return -1; + } + } + + //@@ 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 (ios_base::iostate (0)); + + std::istream& is = ifs.is_open () ? ifs : std::cin; + + InputStreamAdapter isa (is); + Preprocessor pp (isa); + + if (cl.get_value ("preprocess-only", false)) + { + while (true) + { + Preprocessor::int_type i = pp.next (); + + if (pp.eos (i)) break; + + Preprocessor::char_type c = pp.to_char_type (i); + + std::cout << c ; + } + return 0; + } + + + Diagnostic::Stream diagnostic_stream; + + + 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) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnitPtr unit (new TranslationUnit); + + //----------------------------------------------------------------- + //@@ exeprimental code + + //Create .builtin region + { + TranslationRegionPtr builtin ( + new TranslationRegion (fs::path (".builtin"), + unit->table (), + unit->create_order ())); + unit->insert (builtin); + + // Inject built-in types into the file scope of this + // translation region + + ScopePtr s = builtin->scope (); + + // Note: I know what I am doing here (and if you don't then + // read MExC++#17 again). + + s->insert (BuiltInTypeDefPtr (new Void (s))); + s->insert (BuiltInTypeDefPtr (new Long (s))); + s->insert (BuiltInTypeDefPtr (new Boolean (s))); + s->insert (BuiltInTypeDefPtr (new String (s))); + } + + //Create implied #include <Components.idl> + { + TranslationRegionPtr builtin ( + new ImpliedIncludeTranslationRegion (fs::path ("Components.idl"), + unit->table (), + unit->create_order ())); + unit->insert (builtin); + + ScopePtr fs = builtin->scope (); + ModulePtr m (new Module (SimpleName("Components"), fs)); + fs->insert (m); + + LocalInterfaceDefPtr i ( + new LocalInterfaceDef (SimpleName ("EnterpriseComponent"), + m, + ScopedNameSet ())); + + m->insert (i); + } + + TranslationRegionPtr tr ( + new PrincipalTranslationRegion (file_path, + unit->table (), + unit->create_order ())); + unit->insert (tr); + + + CompilerElements::Context context; + context.set ("file-path", file_path); + + bool trace = cl.get_value ("trace-semantic-actions", false); + + context.set ("idl2::semantic-action::trace", trace); + context.set ("idl3::semantic-action::trace", trace); + context.set ("cidl::semantic-action::trace", trace); + + + SemanticAction::Impl::Factory actions (context, diagnostic_stream, tr); + + //----------------------------------------------------------------- + + Parser parser (context, diagnostic_stream, lexer, actions); + + IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (diagnostic_stream.error_count () != 0) return -1; + + // Generate executor mapping + { + lem_gen.generate (cl, unit); + } + } + catch (Declaration::NotInScope const&) + { + cerr << "exception: " << "Declaration::NotInScope" << endl; + } + catch (...) + { + cerr << "exception: " << "unknow" << endl; + } +} diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0.idl b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0.idl new file mode 100644 index 00000000000..c0d5b6c964b --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0.idl @@ -0,0 +1,11 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/test-0.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +module M +{ + interface I {}; + //local interface CCM_I : I {}; +}; + +eventtype E {}; diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-1.idl b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-1.idl new file mode 100644 index 00000000000..f467b30c054 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-1.idl @@ -0,0 +1,22 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/test-1.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include <Components.idl> +include "test-0.idl"; + +module M1 +{ + interface Blah; + interface Fool {}; + + component C1 + { + provides M::I i; + }; + + home H1 manages C1 + { + attribute M::I i; + }; +}; diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.cidl b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.cidl new file mode 100644 index 00000000000..96c5a60bc71 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.cidl @@ -0,0 +1,18 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/test-2.cidl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "test-2.idl" + +module M3 +{ + composition session Impl + { + home executor HImpl + { + implements M2::H2; + manages CImpl; + }; + }; +}; + diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.idl b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.idl new file mode 100644 index 00000000000..4ee7636eb50 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.idl @@ -0,0 +1,23 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/test-2.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +include "test-1.idl"; + +interface Goof {}; + +module M2 +{ + component C2 : M1::C1 + { + provides Goof g; + }; + + home H2 : M1::H1 manages C2 + { + attribute long l; + attribute M::I i; + void foo (in long l, inout boolean b, out long ol, in M::I i); + factory new (in long l); + }; +}; diff --git a/TAO/CIAO/CCF/Example/CIDL/Makefile.alt b/TAO/CIAO/CCF/Example/CIDL/Makefile.alt new file mode 100644 index 00000000000..c02d28322b8 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/Makefile.alt @@ -0,0 +1,18 @@ +# file : Example/CIDL/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := LocalExecutorMapping +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/Makefile.alt b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/Makefile.alt new file mode 100644 index 00000000000..ba307f859df --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/Makefile.alt @@ -0,0 +1,23 @@ +# file : Example/CodeGnerationKit/Indentation/IDL/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root = ../../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.pre.rules) + +cxx_translation_units := indent_idl.cpp + +module_base := indent_idl +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) + +CXX_LINK_LIBS += -L$(root)/CCF/CodeGenerationKit -lCodeGenerationKit + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/indent_idl.cpp b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/indent_idl.cpp new file mode 100644 index 00000000000..a20cce40f74 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/indent_idl.cpp @@ -0,0 +1,25 @@ +// file : CCF/Example/CodeGenerationKit/Indentation/IDL/indent_idl.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include <iostream> + +using std::cout; +using std::endl; + +int +main () +{ + Indentation::Implanter<Indentation::IDL> guard (cout); + + cout << "const string s = \"Hello \\\"world;\";"; + cout << "const char c1 = \'\\\'\';"; + cout << "const char c2 = \';\';"; + + cout << "interface I {" + << "void foo ();" + << "};"; +} diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/Makefile.alt b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/Makefile.alt new file mode 100644 index 00000000000..2170caf214a --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/Makefile.alt @@ -0,0 +1,18 @@ +# file : Example/CodeGenerationKit/Indentation/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := IDL +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Makefile.alt b/TAO/CIAO/CCF/Example/CodeGenerationKit/Makefile.alt new file mode 100644 index 00000000000..cce15219cea --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Makefile.alt @@ -0,0 +1,17 @@ +# file : Example/CodeGenerationKit/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := ../.. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := Indentation +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Example/Makefile.alt b/TAO/CIAO/CCF/Example/Makefile.alt new file mode 100644 index 00000000000..a151c3b67ec --- /dev/null +++ b/TAO/CIAO/CCF/Example/Makefile.alt @@ -0,0 +1,17 @@ +# file : Example/Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := .. + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := CodeGenerationKit CIDL +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Makefile.alt b/TAO/CIAO/CCF/Makefile.alt new file mode 100644 index 00000000000..07295996822 --- /dev/null +++ b/TAO/CIAO/CCF/Makefile.alt @@ -0,0 +1,17 @@ +# file : Makefile.alt +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $id$ + +root := . + +include $(root)/Bootstrap.rules + +$(call include, $(root)/Config.rules) + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := CCF Example +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Test/IDL2/LexicalAnalyzer/Coverage.idl b/TAO/CIAO/CCF/Test/IDL2/LexicalAnalyzer/Coverage.idl new file mode 100644 index 00000000000..259977d3bbb --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/LexicalAnalyzer/Coverage.idl @@ -0,0 +1,25 @@ +// file : CCF/Test/IDL2/LexicalAnalyzer/Coverage.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +// This file is supposed to cover an IDL2 lexical structure and intended +// for IDL2 lexer regression testing. +// + +abstract interface FA; + +abstract interface A +{ + void foo (in long l, out boolean b, inout FA fa); +}; + +module M +{ + interface I + { + }; +}; + +local interface L : ::A, M::I +{ +}; diff --git a/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/interface.idl b/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/interface.idl new file mode 100644 index 00000000000..96b910cbfa8 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/interface.idl @@ -0,0 +1,41 @@ +// file : CCF/Test/IDL2/Parsing/Recovery/interface.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +interface Base {}; + + +// Interface declaration syntax errors +// +// + +local intrrface L; + +// + +abstract interrface A; + +// + +interface ; + +// + +interface I : {}; + +// + +interface I : Base, {}; + +// + +interface I }; + +// + +interface I {; + +// + +interface I {} + diff --git a/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/module.idl b/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/module.idl new file mode 100644 index 00000000000..57a7876df9b --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Parser/Recovery/module.idl @@ -0,0 +1,38 @@ +// file : CCF/Test/IDL2/Parsing/Recovery/module.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $id$ + +// Module declaration syntax errors +// +// + +// + +module; + +// + +module M; + +// + +module M {; + +// + +module M {} + + +// + +module M { + interface I; +; + +// + +module N +{ + interface I; +} + |