diff options
352 files changed, 35913 insertions, 0 deletions
diff --git a/TAO/CIAO/CCF/Bootstrap.rules b/TAO/CIAO/CCF/Bootstrap.rules new file mode 100644 index 00000000000..b995b842d45 --- /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.mwc b/TAO/CIAO/CCF/CCF.mwc new file mode 100644 index 00000000000..59477d175f7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF.mwc @@ -0,0 +1,4 @@ +workspace { + CCF + Example +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/CCF/CCF.mwc b/TAO/CIAO/CCF/CCF/CCF.mwc new file mode 100644 index 00000000000..e0fc58d9851 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CCF.mwc @@ -0,0 +1,10 @@ +workspace { + static { + cmdline += -static_only + IDL2/IDL2.mpc + IDL3/IDL3.mpc + CIDL/CIDL.mpc + CodeGenerationKit/CodeGenerationKit.mpc + CompilerElements/CompilerElements.mpc + } +} diff --git a/TAO/CIAO/CCF/CCF/CCF.sln b/TAO/CIAO/CCF/CCF/CCF.sln new file mode 100644 index 00000000000..fea101ce13f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CCF.sln @@ -0,0 +1,53 @@ +Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CompilerElements", "CompilerElements\CompilerElements.vcproj", "{CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CodeGenerationKit", "CodeGenerationKit\CodeGenerationKit.vcproj", "{5F0B01BD-722F-4958-8E02-680588866D7C}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IDL2", "IDL2\IDL2.vcproj", "{78A62970-330F-4FF1-9B0E-74F689A4EA4F}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IDL3", "IDL3\IDL3.vcproj", "{108D07F1-6364-4B51-87DB-AED8BBE6396A}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CIDL", "CIDL\CIDL.vcproj", "{ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}.Debug.ActiveCfg = Debug|Win32
+ {CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}.Debug.Build.0 = Debug|Win32
+ {CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}.Release.ActiveCfg = Release|Win32
+ {CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}.Release.Build.0 = Release|Win32
+ {5F0B01BD-722F-4958-8E02-680588866D7C}.Debug.ActiveCfg = Debug|Win32
+ {5F0B01BD-722F-4958-8E02-680588866D7C}.Debug.Build.0 = Debug|Win32
+ {5F0B01BD-722F-4958-8E02-680588866D7C}.Release.ActiveCfg = Release|Win32
+ {5F0B01BD-722F-4958-8E02-680588866D7C}.Release.Build.0 = Release|Win32
+ {78A62970-330F-4FF1-9B0E-74F689A4EA4F}.Debug.ActiveCfg = Debug|Win32
+ {78A62970-330F-4FF1-9B0E-74F689A4EA4F}.Debug.Build.0 = Debug|Win32
+ {78A62970-330F-4FF1-9B0E-74F689A4EA4F}.Release.ActiveCfg = Release|Win32
+ {78A62970-330F-4FF1-9B0E-74F689A4EA4F}.Release.Build.0 = Release|Win32
+ {108D07F1-6364-4B51-87DB-AED8BBE6396A}.Debug.ActiveCfg = Debug|Win32
+ {108D07F1-6364-4B51-87DB-AED8BBE6396A}.Debug.Build.0 = Debug|Win32
+ {108D07F1-6364-4B51-87DB-AED8BBE6396A}.Release.ActiveCfg = Release|Win32
+ {108D07F1-6364-4B51-87DB-AED8BBE6396A}.Release.Build.0 = Release|Win32
+ {ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}.Debug.ActiveCfg = Debug|Win32
+ {ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}.Debug.Build.0 = Debug|Win32
+ {ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}.Release.ActiveCfg = Release|Win32
+ {ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc b/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc new file mode 100644 index 00000000000..c0685d0c741 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc @@ -0,0 +1,45 @@ +// $Id$ +project { + + staticname = CIDL + + // @@ (diego) This hack is needed because MPC doesn't generate + // static-only projects for gnuace + verbatim(gnuace, top) { + static_libs_only = 1 + } + + includes += ../.. $(UTILITY_ROOT) $(BOOST_ROOT) + + Source_Files { + SemanticAction/Composition.cpp + LexicalAnalyzer.cpp + Parser.cpp + SyntaxTree/Composition.cpp + SyntaxTree/HomeExecutor.cpp + Traversal/Composition.cpp + Traversal/HomeExecutor.cpp + } + + Header_Files { + SemanticAction/Impl/Composition.hpp + SemanticAction/Impl/Elements.hpp + SemanticAction/Impl/Factory.hpp + SemanticAction/Impl/HomeExecutor.hpp + SemanticAction/Composition.hpp + SemanticAction/Elements.hpp + SemanticAction/Factory.hpp + SemanticAction/HomeExecutor.hpp + LexicalAnalyzer.hpp + Parser.hpp + SemanticAction.hpp + SyntaxTree.hpp + Token.hpp + Traversal.hpp + SyntaxTree/Composition.hpp + SyntaxTree/HomeExecutor.hpp + Traversal/Composition.hpp + Traversal/HomeExecutor.hpp + } + +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/CCF/CIDL/CIDL.vcproj b/TAO/CIAO/CCF/CCF/CIDL/CIDL.vcproj new file mode 100644 index 00000000000..73eb6c82776 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/CIDL.vcproj @@ -0,0 +1,337 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="CIDL" + ProjectGUID="{ADCB8816-C2B5-46AE-AC73-0A2FE72386D6}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + Optimization="0" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CIDL.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CIDL.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\LexicalAnalyzer.cpp"> + </File> + <File + RelativePath=".\Parser.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\LexicalAnalyzer.hpp"> + </File> + <File + RelativePath=".\Parser.hpp"> + </File> + <File + RelativePath=".\SemanticAction.hpp"> + </File> + <File + RelativePath=".\SyntaxTree.hpp"> + </File> + <File + RelativePath=".\Token.hpp"> + </File> + <File + RelativePath=".\Traversal.hpp"> + </File> + </Filter> + <Filter + Name="SemanticAction" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Composition.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Composition.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\HomeExecutor.hpp"> + </File> + </Filter> + <Filter + Name="Impl" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Composition.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\HomeExecutor.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Composition.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\HomeExecutor.hpp"> + </File> + </Filter> + </Filter> + </Filter> + <Filter + Name="SyntaxTree" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SyntaxTree\Composition.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SyntaxTree\HomeExecutor.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SyntaxTree\Composition.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\HomeExecutor.hpp"> + </File> + </Filter> + </Filter> + <Filter + Name="Traversal" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\Traversal\Composition.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)3.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)3.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\HomeExecutor.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\Traversal\Composition.hpp"> + </File> + <File + RelativePath=".\Traversal\HomeExecutor.hpp"> + </File> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/CIDL/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..4a73d93397c --- /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..0ffd9b04912 --- /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..8a2e9ec8c5a --- /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 := SemanticGraph Traversal SemanticAction +default_makefile_name := Makefile.alt + +Makefile.archive : SemanticGraph 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..53ac3eed886 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Makefile.archive @@ -0,0 +1,34 @@ +# 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 := SemanticGraph/Composition.o \ + SemanticGraph/Elements.o \ + SemanticGraph/Executor.o + +translated_units += Traversal/Elements.o \ + Traversal/Executor.o + +translated_units += SemanticAction/Composition.o + +translated_units += SemanticAction/Impl/Composition.o \ + SemanticAction/Impl/Factory.o \ + SemanticAction/Impl/HomeExecutor.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..4703e84ae30 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Parser.cpp @@ -0,0 +1,123 @@ +// 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_implements ( + f.home_executor (), &SemanticAction::HomeExecutor::implements), + + act_home_executor_manages ( + f.home_executor (), &SemanticAction::HomeExecutor::manages), + + act_home_executor_end ( + f.home_executor (), &SemanticAction::HomeExecutor::end) + + { + IDL3::Parser::extension = + composition_decl + | extension + ; + + // + // Composition + // + composition_decl = + composition_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 + >> home_executor_home_impl_decl + >> home_executor_executor_decl + >> RBRACE + >> 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..a5695070391 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Parser.hpp @@ -0,0 +1,126 @@ +// 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; + + OneArgAction<IdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_implements; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::HomeExecutor> + act_home_executor_manages; + + NoArgAction<SemanticAction::HomeExecutor> + act_home_executor_end; + }; + } +} + +#endif // CCF_CIDL_PARSER_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp new file mode 100644 index 00000000000..faf75dbc28a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction.hpp @@ -0,0 +1,17 @@ +// file : CCF/CIDL/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_HPP + +#include "CCF/IDL3/SemanticAction.hpp" + +#include "CCF/CIDL/SemanticAction/Elements.hpp" + +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" + +#include "CCF/CIDL/SemanticAction/Factory.hpp" + +#endif // CCF_CIDL_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.cpp new file mode 100644 index 00000000000..02e0e55ce4f --- /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..9d3b111d2ba --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Composition.hpp @@ -0,0 +1,45 @@ +// 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 , 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..83c80bdf56b --- /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..31047b64a85 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Factory.hpp @@ -0,0 +1,35 @@ +// 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" + +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.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..d754b3a2a64 --- /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 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..1c209c1fce1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.cpp @@ -0,0 +1,84 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticAction/Impl/Composition.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Composition:: + ~Composition () throw () + { + } + + Composition:: + Composition (Context& c) + : ScopeBase<SemanticGraph::Composition> (c) + { + } + + void Composition:: + begin (SimpleIdentifierPtr const& id, Category::Value c) + { + if (ctx.trace ()) cerr << "composition " << id << endl; + + if(c == Category::entity) + { + now (ctx.tu ().new_node<EntityComposition> ()); + } + else if (c == Category::process) + { + now (ctx.tu ().new_node<ProcessComposition> ()); + } + else if (c == Category::service) + { + now (ctx.tu ().new_node<ServiceComposition> ()); + } + else + { + now (ctx.tu ().new_node<SessionComposition> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), id->lexeme ()); + } + + void Composition:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Composition:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Composition:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..8fa8466ce85 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Composition.hpp @@ -0,0 +1,50 @@ +// file : CCF/CIDL/SemanticAction/Impl/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Composition.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Composition : + public virtual SemanticAction::Composition, + public virtual ScopeBase<SemanticGraph::Composition> + { + public: + virtual + ~Composition () throw (); + + Composition (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id, Category::Value c); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_COMPOSITION_HPP diff --git a/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..a1f868a8424 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,26 @@ +// 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::Context; + using IDL3::SemanticAction::Impl::Base; + 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..33ac8583dc3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,63 @@ +// file : CCF/CIDL/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Factory:: + ~Factory () throw () + { + } + + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : IDL2::SemanticAction::Impl::Factory (context, dout, tu), + IDL3::SemanticAction::Impl::Factory (context, dout, tu), + + composition_ (ctx_), + home_executor_ (ctx_) + { + //@@ I am still not sure what is the right way to do this. + // Current approach suppresses Components.idl inclusion + // and implicitly defines necessary types. + // + + //@@ this region is inserted after principal which is + // somewhat strange. It doesn't affect anything as + // long as no code is generated for this region. + // + + // Implied translation region with CCM-related types. + // + TranslationRegion& ctr (tu.new_node<TranslationRegion> ()); + tu.new_edge<ContainsImplied> (tu, ctr, ".components"); + + Root& cr (tu.new_node<Root> ()); + tu.new_edge<ContainsRoot> (ctr, cr); + + Module& cm (tu.new_node<Module> ()); + tu.new_edge<Defines> (cr, cm, "Components"); + + tu.new_edge<Defines> ( + cm, tu.new_node<LocalInterface> (), "EnterpriseComponent"); + } + } + } + } +} 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..bd49998c4d5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,58 @@ +// 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, + SemanticGraph::TranslationUnit& tu); + + public: + virtual SemanticAction::Composition& + composition () + { + return composition_; + } + + virtual SemanticAction::HomeExecutor& + home_executor () + { + return home_executor_; + } + + private: + Composition composition_; + HomeExecutor home_executor_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/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..5bb3e47dcf2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp @@ -0,0 +1,116 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeExecutor:: + ~HomeExecutor () throw () + { + } + + HomeExecutor:: + HomeExecutor (Context& c) + : Base (c) + { + } + + void HomeExecutor:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "home executor " << id << endl; + + id_ = id; + he_ = &ctx.tu ().new_node<SemanticGraph::HomeExecutor> (); + } + + void HomeExecutor:: + implements (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "implements " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + c_ = 0; + + try + { + try + { + SemanticGraph::Home& h ( + resolve<SemanticGraph::Home> (from, name, defined)); + + c_ = &dynamic_cast<SemanticGraph::Component&> ( + h.manages ().managee ()); + + ctx.tu ().new_edge<Implements> (*he_, h); + } + catch (Resolve const&) + { + cerr << "error: invalid implements specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no home with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in implements specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to implement forward-declared home " + << e.name () << endl; + cerr << "implementation of forward-declared home is illegal" + << endl; + } + } + + void HomeExecutor:: + manages (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "manages " << id << endl; + + if (c_ != 0) + { + SemanticGraph::ComponentExecutor& ce ( + ctx.tu ().new_node<SemanticGraph::ComponentExecutor> ()); + + ctx.tu ().new_edge<Implements> (ce, *c_); + + ctx.tu ().new_edge<Defines> (ctx.scope (), ce, id->lexeme ()); + ctx.tu ().new_edge<Defines> (ctx.scope (), *he_, id_->lexeme ()); + + ctx.tu ().new_edge<Manages> (*he_, ce); + } + } + + void HomeExecutor:: + end () + { + id_ = 0; + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..592618b02d1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp @@ -0,0 +1,51 @@ +// file : CCF/CIDL/SemanticAction/Impl/HomeExecutor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" +#include "CCF/CIDL/SemanticAction/HomeExecutor.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticAction + { + namespace Impl + { + class HomeExecutor : public virtual SemanticAction::HomeExecutor, + public virtual Base + { + public: + virtual + ~HomeExecutor () throw (); + + HomeExecutor (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + implements (IdentifierPtr const& id); + + virtual void + manages (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SimpleIdentifierPtr id_; + SemanticGraph::HomeExecutor* he_; + SemanticGraph::Component* c_; + }; + } + } + } +} + +#endif // CCF_CIDL_SEMANTIC_ACTION_IMPL_HOME_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Makefile.alt new file mode 100644 index 00000000000..053f63b50f7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Impl/Makefile.alt @@ -0,0 +1,19 @@ +# file : CCF/CIDL/SemanticAction/Impl/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 Factory.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/SemanticAction/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.alt new file mode 100644 index 00000000000..087d5c90527 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.alt @@ -0,0 +1,19 @@ +# 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.object +target_directory_list := Impl +default_makefile_name := Makefile.alt + + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.object b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.object new file mode 100644 index 00000000000..5270d777460 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticAction/Makefile.object @@ -0,0 +1,18 @@ +# file : CCF/CIDL/SemanticAction/Makefile.object +# 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/SemanticGraph.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph.hpp new file mode 100644 index 00000000000..9e4d2006029 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph.hpp @@ -0,0 +1,15 @@ +// file : CCF/CIDL/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL3/SemanticGraph.hpp" + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +#endif // CCF_CIDL_SEMANTIC_GRAPH_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp new file mode 100644 index 00000000000..9e7750d6131 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.cpp @@ -0,0 +1,140 @@ +// file : CCF/CIDL/SemanticGraph/Composition.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // Composition + // + // + Composition::Kind const + Composition::Kind::entity (Composition::Kind::entity_), + Composition::Kind::process (Composition::Kind::process_), + Composition::Kind::service (Composition::Kind::service_), + Composition::Kind::session (Composition::Kind::session_); + + namespace + { + char const* composition_kind_labels_[] = + { + "entity", "process", "service", "session" + }; + } + + Composition::Kind::operator char const* () const + { + return composition_kind_labels_[v_]; + } + + 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_; } + + + // EntityComposition + // + // + namespace + { + TypeInfo + entity_composition_init_ () + { + TypeInfo ti (typeid (EntityComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo entity_composition_ (entity_composition_init_ ()); + } + + TypeInfo const& EntityComposition:: + static_type_info () { return entity_composition_; } + + + // ProcessComposition + // + // + namespace + { + TypeInfo + process_composition_init_ () + { + TypeInfo ti (typeid (ProcessComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo process_composition_ (process_composition_init_ ()); + } + + TypeInfo const& ProcessComposition:: + static_type_info () { return process_composition_; } + + + // ServiceComposition + // + // + namespace + { + TypeInfo + service_composition_init_ () + { + TypeInfo ti (typeid (ServiceComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo service_composition_ (service_composition_init_ ()); + } + + TypeInfo const& ServiceComposition:: + static_type_info () { return service_composition_; } + + + // SessionComposition + // + // + namespace + { + TypeInfo + session_composition_init_ () + { + TypeInfo ti (typeid (SessionComposition)); + ti.add_base ( + Access::PUBLIC, true, Composition::static_type_info ()); + return ti; + } + + TypeInfo session_composition_ (session_composition_init_ ()); + } + + TypeInfo const& SessionComposition:: + static_type_info () { return session_composition_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp new file mode 100644 index 00000000000..59632b110e8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Composition.hpp @@ -0,0 +1,155 @@ +// file : CCF/CIDL/SemanticGraph/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + class Composition : public virtual Scope + { + public: + class Kind + { + public: + static Kind const entity, process, service, session; + + public: + operator char const* () const; + + bool + operator== (Kind d) const + { + return v_ == d.v_; + } + + bool + operator!= (Kind d) const + { + return v_ != d.v_; + } + + private: + enum Value + { + entity_, process_, service_, session_ + } v_; + + Kind (Value v) + : v_ (v) + { + } + }; + + virtual Kind + kind () = 0; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Composition () + { + type_info (static_type_info ()); + } + }; + + class EntityComposition : public virtual Composition + { + public: + virtual Kind + kind () + { + return Kind::entity; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + EntityComposition () + { + type_info (static_type_info ()); + } + }; + + class ProcessComposition : public virtual Composition + { + public: + virtual Kind + kind () + { + return Kind::process; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ProcessComposition () + { + type_info (static_type_info ()); + } + }; + + + class ServiceComposition : public virtual Composition + { + public: + virtual Kind + kind () + { + return Kind::service; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ServiceComposition () + { + type_info (static_type_info ()); + } + }; + + + class SessionComposition : public virtual Composition + { + public: + virtual Kind + kind () + { + return Kind::session; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + SessionComposition () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..33dc90db26d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.cpp @@ -0,0 +1,36 @@ +// file : CCF/CIDL/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Implements + // + // + namespace + { + TypeInfo + implements_init_ () + { + TypeInfo ti (typeid (Implements)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo implements_ (implements_init_ ()); + } + + TypeInfo const& Implements:: + static_type_info () { return implements_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..625221116e7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Elements.hpp @@ -0,0 +1,65 @@ +// file : CCF/CIDL/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using namespace IDL3::SemanticGraph; + + + class Implements : public virtual Edge + { + public: + Type& + implementer () const + { + return *implementer_; + } + + Type& + implementee () const + { + return *implementee_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Implements () + { + type_info (static_type_info ()); + } + + void + set_left_node (Type& n) + { + implementer_ = &n; + } + + void + set_right_node (Type& n) + { + implementee_ = &n; + } + + private: + Type* implementer_; + Type* implementee_; + }; + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp new file mode 100644 index 00000000000..c5d2f607ef7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.cpp @@ -0,0 +1,76 @@ +// file : CCF/CIDL/SemanticGraph/Executor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Executor + // + // + namespace + { + TypeInfo + executor_init_ () + { + TypeInfo ti (typeid (Executor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo executor_ (executor_init_ ()); + } + + TypeInfo const& Executor:: + static_type_info () { return executor_; } + + + // ComponentExecutor + // + // + namespace + { + TypeInfo + component_executorinit_ () + { + TypeInfo ti (typeid (ComponentExecutor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo component_executor (component_executorinit_ ()); + } + + TypeInfo const& ComponentExecutor:: + static_type_info () { return component_executor; } + + + // HomeExecutor + // + // + namespace + { + TypeInfo + home_executorinit_ () + { + TypeInfo ti (typeid (HomeExecutor)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo home_executor (home_executorinit_ ()); + } + + TypeInfo const& HomeExecutor:: + static_type_info () { return home_executor; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp new file mode 100644 index 00000000000..55f0fa0919c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Executor.hpp @@ -0,0 +1,117 @@ +// file : CCF/CIDL/SemanticGraph/Executor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP +#define CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace SemanticGraph + { + // + // + // + class Executor : public virtual Type + { + public: + Implements& + implements () const + { + return *implements_; + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Executor () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Implements& e) + { + implements_ = &e; + } + + private: + Implements* implements_; + }; + + + // + // + // + class ComponentExecutor : public virtual Executor + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ComponentExecutor () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class HomeExecutor : public virtual Executor + { + public: + Manages& + manages () const + { + return *manages_; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeExecutor () + { + type_info (static_type_info ()); + } + + using Executor::add_edge_left; + + void + add_edge_left (Manages& e) + { + manages_ = &e; + } + + private: + Manages* manages_; + }; + + } + } +} + +#endif // CCF_CIDL_SEMANTIC_GRAPH_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Makefile.alt new file mode 100644 index 00000000000..e0168cb4dc8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/SemanticGraph/Makefile.alt @@ -0,0 +1,18 @@ +# file : CCF/CIDL/SemanticGraph/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 Elements.cpp Executor.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..40bd13b252c --- /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..119c813f554 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal.hpp @@ -0,0 +1,15 @@ +// file : CCF/CIDL/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_HPP +#define CCF_CIDL_TRAVERSAL_HPP + +#include "CCF/IDL3/Traversal.hpp" + +#include "CCF/CIDL/Traversal/Elements.hpp" + +#include "CCF/CIDL/Traversal/Composition.hpp" +#include "CCF/CIDL/Traversal/Executor.hpp" + +#endif // CCF_CIDL_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp new file mode 100644 index 00000000000..e93fa976e7e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.hpp @@ -0,0 +1,60 @@ +// file : CCF/CIDL/Traversal/Composition.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_COMPOSITION_HPP +#define CCF_CIDL_TRAVERSAL_COMPOSITION_HPP + +#include "CCF/CIDL/SemanticGraph/Composition.hpp" +#include "CCF/CIDL/Traversal/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + template <typename T> + struct CompositionTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + + typedef + CompositionTemplate <SemanticGraph::Composition> + Composition; + + typedef + CompositionTemplate <SemanticGraph::EntityComposition> + EntityComposition; + + typedef + CompositionTemplate <SemanticGraph::ProcessComposition> + ProcessComposition; + + typedef + CompositionTemplate <SemanticGraph::ServiceComposition> + ServiceComposition; + + + typedef + CompositionTemplate <SemanticGraph::SessionComposition> + SessionComposition; + } + } +} + +#include "CCF/CIDL/Traversal/Composition.tpp" + +#endif // CCF_CIDL_TRAVERSAL_COMPOSITION_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp new file mode 100644 index 00000000000..8a6ff03e496 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Composition.tpp @@ -0,0 +1,41 @@ +// file : CCF/CIDL/Traversal/Composition.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + + template <typename T> + void CompositionTemplate<T>:: + traverse (T& c) + { + pre (c); + name (c); + names (c); + post (c); + } + + template <typename T> + void CompositionTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void CompositionTemplate<T>:: + name (T&) + { + } + + template <typename T> + void CompositionTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.cpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.cpp new file mode 100644 index 00000000000..23e73c8b563 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.cpp @@ -0,0 +1,15 @@ +// file : CCF/CIDL/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/Traversal/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp new file mode 100644 index 00000000000..72ffd2613db --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Elements.hpp @@ -0,0 +1,36 @@ +// file : CCF/CIDL/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_ELEMENTS_HPP +#define CCF_CIDL_TRAVERSAL_ELEMENTS_HPP + +#include "CCF/IDL3/Traversal/Elements.hpp" + +#include "CCF/CIDL/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + using namespace IDL3::Traversal; + + // + // + // + struct Implements : Edge<SemanticGraph::Implements> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.implementee ()); + } + }; + + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp new file mode 100644 index 00000000000..efcb9681d66 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.cpp @@ -0,0 +1,195 @@ +// file : CCF/CIDL/Traversal/Executor.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CIDL/Traversal/Executor.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // Executor + // + // + void Executor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + post (e); + } + + void Executor:: + pre (Type&) + { + } + + void Executor:: + name (Type&) + { + } + + void Executor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void Executor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void Executor:: + implements_pre (Type&) + { + } + + void Executor:: + implements_post (Type&) + { + } + + void Executor:: + post (Type&) + { + } + + + // ComponentExecutor + // + // + void ComponentExecutor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + post (e); + } + + void ComponentExecutor:: + pre (Type&) + { + } + + void ComponentExecutor:: + name (Type&) + { + } + + void ComponentExecutor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void ComponentExecutor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void ComponentExecutor:: + implements_pre (Type&) + { + } + + void ComponentExecutor:: + implements_post (Type&) + { + } + + void ComponentExecutor:: + post (Type&) + { + } + + + + // HomeExecutor + // + // + void HomeExecutor:: + traverse (Type& e) + { + pre (e); + name (e); + implements (e); + manages (e); + post (e); + } + + void HomeExecutor:: + pre (Type&) + { + } + + void HomeExecutor:: + name (Type&) + { + } + + void HomeExecutor:: + implements (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.implements ()); + } + + void HomeExecutor:: + implements (Type& e) + { + implements_pre (e); + implements (e, edge_traverser ()); + implements_post (e); + } + + void HomeExecutor:: + implements_pre (Type&) + { + } + + void HomeExecutor:: + implements_post (Type&) + { + } + + void HomeExecutor:: + manages (Type& e, EdgeDispatcherBase& d) + { + d.traverse (e.manages ()); + } + + void HomeExecutor:: + manages (Type& e) + { + manages_pre (e); + manages (e, edge_traverser ()); + manages_post (e); + } + + void HomeExecutor:: + manages_pre (Type&) + { + } + + void HomeExecutor:: + manages_post (Type&) + { + } + + void HomeExecutor:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp new file mode 100644 index 00000000000..6bb543aee9d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Executor.hpp @@ -0,0 +1,125 @@ +// file : CCF/CIDL/Traversal/Executor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CIDL_TRAVERSAL_EXECUTOR_HPP +#define CCF_CIDL_TRAVERSAL_EXECUTOR_HPP + +#include "CCF/CIDL/SemanticGraph/Executor.hpp" + +#include "CCF/CIDL/Traversal/Elements.hpp" + +namespace CCF +{ + namespace CIDL + { + namespace Traversal + { + // + // + // + struct Executor : Node<SemanticGraph::Executor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct ComponentExecutor : Node<SemanticGraph::ComponentExecutor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct HomeExecutor : Node<SemanticGraph::HomeExecutor> + { + virtual void + traverse (Type& e); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + implements (Type&, EdgeDispatcherBase&); + + virtual void + implements (Type&); + + virtual void + implements_pre (Type&); + + virtual void + implements_post (Type&); + + virtual void + manages (Type&, EdgeDispatcherBase&); + + virtual void + manages (Type&); + + virtual void + manages_pre (Type&); + + virtual void + manages_post (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_CIDL_TRAVERSAL_EXECUTOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt new file mode 100644 index 00000000000..980929c6e88 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/Traversal/Makefile.alt @@ -0,0 +1,19 @@ +# 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 := Elements.cpp Executor.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/CodeGenerationKit/CodeGenerationKit.mpc b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc new file mode 100644 index 00000000000..8fcac9f42dc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc @@ -0,0 +1,30 @@ +// $Id$ +project { + + staticname = CodeGenerationKit + + // @@ (diego) This hack is needed because MPC doesn't generate + // static-only projects for gnuace + verbatim(gnuace, top) { + static_libs_only = 1 + } + + includes += ../.. $(UTILITY_ROOT) $(BOOST_ROOT) + + Source_Files { + CommandLine.cpp + CommandLineGrammar.cpp + CommandLineParser.cpp + } + + Header_Files { + CommandLine.hpp + CommandLineDescriptor.hpp + CommandLineGrammar.hpp + CommandLineParser.hpp + IndentationBuffer.hpp + IndentationIDL.hpp + IndentationImplanter.hpp + Regex.hpp + } +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.vcproj b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.vcproj new file mode 100644 index 00000000000..64b0963a942 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.vcproj @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="CodeGenerationKit" + ProjectGUID="{5F0B01BD-722F-4958-8E02-680588866D7C}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CodeGenerationKit.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CodeGenerationKit.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\CommandLine.cpp"> + </File> + <File + RelativePath=".\CommandLineGrammar.cpp"> + </File> + <File + RelativePath=".\CommandLineParser.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\CommandLine.hpp"> + </File> + <File + RelativePath=".\CommandLineDescriptor.hpp"> + </File> + <File + RelativePath=".\CommandLineGrammar.hpp"> + </File> + <File + RelativePath=".\CommandLineParser.hpp"> + </File> + <File + RelativePath=".\IndentationBuffer.hpp"> + </File> + <File + RelativePath=".\IndentationIDL.hpp"> + </File> + <File + RelativePath=".\IndentationImplanter.hpp"> + </File> + <File + RelativePath=".\IndentationXML.hpp"> + </File> + <File + RelativePath=".\Regex.hpp"> + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp new file mode 100644 index 00000000000..018aea6ffcf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.cpp @@ -0,0 +1,5 @@ +// file : CCF/CodeGenerationKit/CommandLine.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/CommandLine.hpp" diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp new file mode 100644 index 00000000000..4b4ac287224 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLine.hpp @@ -0,0 +1,229 @@ +// file : CCF/CodeGenerationKit/CommandLine.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_HPP +#define COMMAND_LINE_HPP + +#include <algorithm> +#include <vector> +#include <string> + +using namespace std; + +//@@ this stuff needs proper reimplementation + +class CommandLine +{ +public: + + CommandLine () throw () : separator (false) {} + + + // Option constrain checking +public: + + bool + require (std::string option) const throw () + { + return std::find_if (options.begin (), + options.end (), + OptionNamePredicat (option)) != options.end (); + } + + bool + depends (std::string dependant, + std::string principal) const throw () + { + Options::const_iterator begin = options.begin (); + Options::const_iterator end = options.end (); + + if (std::find_if (begin, end, OptionNamePredicat (dependant)) != end) + { + return std::find_if (begin, end, OptionNamePredicat (principal)) != end; + } + else + { + return true; + } + } + + bool + inconsistent (std::string a, + std::string b) const throw () + { + Options::const_iterator begin = options.begin (); + Options::const_iterator end = options.end (); + + if (std::find_if (begin, end, OptionNamePredicat (a)) != end) + { + return std::find_if (begin, end, OptionNamePredicat (b)) == end; + } + else + { + return true; + } + } + + std::string + get_value (std::string name, std::string const& not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end () && !(i->value_.empty ())) + { + return i->value_; + } + else + { + return not_found_value; + } + } + + // @@ the option should probably be searched in reverse order + // + + std::string + get_value (std::string name, char const* not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end () && !(i->value_.empty ())) + { + return i->value_; + } + else + { + return std::string (not_found_value); + } + } + + bool + get_value (std::string name, bool not_found_value) const + { + Options::const_iterator i = std::find_if ( + options.begin (), + options.end (), + OptionNamePredicat (name)); + + if (i != options.end ()) + { + return true; + } + else + { + return not_found_value; + } + } + + + struct Option + { + enum OptionType + { + EQUATIONAL, + COMPOSITE + }; + + Option (OptionType type, + std::string const& name, + std::string const& value) throw () + : type_ (type), + name_ (name), + value_ (value) + { + } + + std::string + name () const + { + return name_; + } + + std::string + value () const + { + return value_; + } + + OptionType type_; + std::string name_; + std::string value_; + }; + + typedef + std::vector<Option> + Options; + + typedef + Options::const_iterator + OptionsIterator; + + OptionsIterator + options_begin () const + { + return options.begin (); + } + + OptionsIterator + options_end () const + { + return options.end (); + } + + // Arguments + // + // + + typedef + std::vector<std::string> + Arguments; + + typedef + Arguments::const_iterator + ArgumentsIterator; + + ArgumentsIterator + arguments_begin () const + { + return arguments.begin (); + } + + ArgumentsIterator + arguments_end () const + { + return arguments.end (); + } + +public: + + struct OptionNamePredicat + { + OptionNamePredicat (std::string const& name) + : name_ (name) + { + } + + bool operator ()(Option const& option) throw () + { + return name_ == option.name_; + } + + private: + std::string const name_; + }; + + std::string command; + Options options; + Arguments arguments; + + bool separator; +}; + +#endif // COMMAND_LINE_HPP diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp new file mode 100644 index 00000000000..42cfcb5051f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineDescriptor.hpp @@ -0,0 +1,263 @@ +// file : CCF/CodeGenerationKit/CommandLineDescriptor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_DESCRIPTOR_H +#define COMMAND_LINE_DESCRIPTOR_H + +#include <string> +#include <vector> +#include <ostream> + +//@@ temporary. should probably be changed to CommandLine +namespace CL +{ + class OptionDescription + { + public: + OptionDescription (std::string name, + std::string description, + bool optional) + : optional_ (optional), + name_ (name), + value_synopsis_ (), + description_ (description) + { + } + + + OptionDescription (std::string name, + std::string value_synopsis, + std::string description, + bool optional) + : optional_ (optional), + name_ (name), + value_synopsis_ (value_synopsis), + description_ (description) + { + } + + public: + bool + optional () const + { + return optional_; + } + + std::string + name () const + { + return name_; + } + + std::string + value_synopsis () const + { + return value_synopsis_; + } + + std::string + description () const + { + return description_; + } + + + private: + bool optional_; + std::string name_; + std::string value_synopsis_; + std::string description_; + }; + + + class Description + { + public: + Description (std::string command) + : command_ (command) + { + } + + private: + typedef + std::vector<OptionDescription> + OptionDescriptionList; + + public: + + std::string + command () const + { + return command_; + } + + + public: + typedef + OptionDescriptionList::const_iterator + OptionIterator; + + OptionIterator + begin_option () const + { + return options_.begin (); + } + + OptionIterator + end_option () const + { + return options_.end (); + } + + void + add_option (OptionDescription const& od) + { + options_.push_back (od); + } + + private: + typedef + std::vector<std::string> + ArgumentDescriptionList; + + public: + typedef + ArgumentDescriptionList::const_iterator + ArgumentIterator; + + ArgumentIterator + begin_argument () const + { + return arguments_.begin (); + } + + ArgumentIterator + end_argument () const + { + return arguments_.end (); + } + + void + add_argument (std::string arg) + { + arguments_.push_back (arg); + } + + private: + + std::string command_; + OptionDescriptionList options_; + ArgumentDescriptionList arguments_; + }; + + inline void + print_text (std::ostream& os, Description const& d) + { + os << d.command (); + + Description::OptionIterator ob = d.begin_option (); + Description::OptionIterator oe = d.end_option (); + + if (ob != oe) + { + os << " { OPTIONS }"; + } + + Description::ArgumentIterator ab = d.begin_argument (); + Description::ArgumentIterator ae = d.end_argument (); + + for (; ab != ae; ab++) + { + os << " <" << *ab << ">"; + } + + os << endl << endl; + + for (; ob != oe; ob++) + { + os << (ob->optional () ? "[--" : "--") + << ob->name () + << (ob->value_synopsis ().empty () ? "" : " ") + << ob->value_synopsis () + << (ob->optional () ? "]" : "") + << endl; + + os << "\t\t" << ob->description () << endl; + } + + } + + + inline void + print_html (std::ostream& os, Description const& d) + { + os << "<html>" << endl + << "<body>" << endl + << "<div align=\"center\">" << endl + << "<table width=\"700\" border=\"0\" cellspacing=\"0\" " + << "cellpadding=\"0\">" << endl + << "<tr>" << endl + << "<td>" << endl; + + os << "<p>" << endl + << "<code>" << endl; + + os << d.command (); + + Description::OptionIterator ob = d.begin_option (); + Description::OptionIterator oe = d.end_option (); + + if (ob != oe) + { + os << " { OPTIONS }"; + } + + Description::ArgumentIterator ab = d.begin_argument (); + Description::ArgumentIterator ae = d.end_argument (); + + for (; ab != ae; ab++) + { + os << " <" << *ab << ">"; + } + + os << endl + << "</code>" << endl + << "</p>" << endl; + + + os << "<dl>" << endl; + + for (; ob != oe; ob++) + { + os << "<dt>" << endl + << "<code>" << endl + << (ob->optional () ? "[--" : "--") + << ob->name () + << (ob->value_synopsis ().empty () ? "" : " ") + << ob->value_synopsis () + << (ob->optional () ? "]" : "") << endl + << "</code>" << endl + << "</dt>" << endl; + + os << "<dd>" << endl + << "<p>" << endl + << ob->description () << endl + << "</p>" << endl + << "</dd>" << endl; + } + + os << "</dl>" << endl; + + os << "</td>" << endl + << "</tr>" << endl + << "</table>" << endl + << "</div>" << endl + << "</body>" << endl + << "</html>" << endl; + + } +} + + +#endif // COMMAND_LINE_DESCRIPTOR_H diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp new file mode 100644 index 00000000000..fc700def53a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.cpp @@ -0,0 +1,5 @@ +// file : CCF/CodeGenerationKit/CommandLineGrammar.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/CommandLineGrammar.hpp" diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp new file mode 100644 index 00000000000..7240186c07c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineGrammar.hpp @@ -0,0 +1,391 @@ +// file : CCF/CodeGenerationKit/CommandLineGrammar.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_GRAMMAR_H +#define COMMAND_LINE_GRAMMAR_H + +#include <vector> +#include <string> + +#include <boost/spirit.hpp> + +#include "CCF/CodeGenerationKit/CommandLine.hpp" + + +using namespace std; +using namespace boost::spirit; + +template <typename S> +struct string_directive : public unary<S, parser<string_directive<S> > > +{ + typedef + string_directive + self_t; + + string_directive (S const& a) + : unary<S, parser<string_directive<S> > > (a) + { + } + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef + typename ScannerT::iterator_t + Iterator; + + typedef + typename ScannerT::value_t + Value; + + typedef + typename Value::const_iterator + ValueIterator; + + Iterator save = scan.first; + + if (!scan.at_end()) + { + // Now go one level deeper + + Value const& v = *scan; + + ValueIterator first = v.begin (); + ValueIterator last = v.end (); + + scanner<ValueIterator, scanner_policies <> > sl_scan(first, last); + + match<nil_t> hit = this->subject ().parse(sl_scan); + + if (static_cast<std::size_t> (hit.length()) == v.length ()) + { + ++scan; + + return scan.create_match(1, nil_t(), save, scan.first); + } + else + { + return scan.no_match(); + } + } + else + { + return scan.no_match(); + } + } +}; + + +template <typename S> +string_directive<S> +string_d (parser<S> const& a) +{ + return string_directive<S>(a.derived()); +} + + +struct CLineGrammar : public grammar<CLineGrammar> +{ + CommandLine& cl_; + + CLineGrammar (CommandLine& cl) throw () : cl_(cl) {} + + + template <typename IteratorT, typename CodeT> + struct SemanticAction + { + SemanticAction (CommandLine& cl) : cl_ (cl), code_ () {} + + void operator()(IteratorT first, IteratorT last) const + { + string str (first, last); + code_.execute (cl_, str); + } + + private: + CommandLine& cl_; + CodeT code_; + }; + + + struct SetCommandName + { + void execute (CommandLine& cl, string const& s) const throw () + { + cl.command = s; + } + }; + + + template <typename IteratorT> + struct SetOptionName + { + SetOptionName (CommandLine& cl, + CommandLine::Option::OptionType type) + : cl_ (cl), type_ (type) + { + } + + void operator()(IteratorT first, IteratorT last) const + { + string s (first, last); + cl_.options.push_back (CommandLine::Option(type_, s, "")); + } + + private: + CommandLine& cl_; + CommandLine::Option::OptionType type_; + }; + + + struct SetOptionValue + { + void execute (CommandLine& cl, string const& s) const throw () + { + CommandLine::Options::reverse_iterator r = cl.options.rbegin (); + + if (r != cl.options.rend () && r->value_ == "") + { + r->value_ = s; + } + else + { + //@@ + //throw + } + } + }; + + struct SetArgument + { + void execute (CommandLine& cl, string const& s) const throw () + { + cl.arguments.push_back (s); + } + }; + + struct SetSeparator + { + void execute (CommandLine& cl, string const& s) const throw () + { + cl.separator = true; + } + }; + + + template <typename ScannerT> + struct definition + { + typedef + typename ScannerT::value_t::const_iterator + SLIterator; + + typedef + scanner<SLIterator, scanner_policies <> > + SLScanner; + + typedef + rule<ScannerT> + Rule; + + typedef + rule<SLScanner> + SLRule; + + + Rule r_argument; + Rule r_arg_list; + + Rule argument; + Rule arg_list; + + SLRule option_prefix; + SLRule e_name; // equational name, i.e. can meet '=' + SLRule c_name; // composite name, i.e. failes if meets '=' + SLRule e_value; // equational value, i.e. can contain leading '-' + SLRule c_value; // composite value, i.e. cannot contain leading '-' + + Rule composite; + Rule equational; + + Rule option_list; + Rule option; + + SLRule command_name; + + Rule command_line; + + // Semantic actions + + typedef + SemanticAction<SLIterator, SetCommandName> + CommandNameHandler; + + typedef + SetOptionName<SLIterator> + OptionNameHandler; + + typedef + SemanticAction<SLIterator, SetOptionValue> + OptionValueHandler; + + typedef + SemanticAction<SLIterator, SetArgument> + ArgumentHandler; + + typedef + SemanticAction<SLIterator, SetSeparator> + SeperatorHandler; + + /* + + <epigraph> + + As many people naively believe command line is + not a space separated array of words. + + -- unknown author. + </epigraph> + + + + NOTE: + + (1) This grammar is space-sensitive. + + (2) Anychar is assumend not to clash with <argv-delim>. Instead + <argv-delim> is assumed to be a next-dimension entitiy. + + + <command-line> ::= <command-name> + [ + [ <argv-delim> <option-list>] + [ + <option-prefix> [<argv-delim> <arg-list>] | + <argv-delim> <r-arg-list> + ] + ] + + <command-name> ::= anychar+ + + <option-list> ::= <option> { <argv-delim> <option> }* + <option> ::= <composite> | <equational> + <composite> ::= <option-prefix> <name> [ <argv-delim><c-value> ] + <equational> ::= <option-prefix> <name> '=' <e-value> + <option-prefix> ::= '-' [ '-' ] + <name> ::= {anychar - '='}+ + <c-value> ::= anychar+ - {<option-prefix> anychar*} + <e-valie> ::= anychar+ + + <arg-list> ::= <argument> { <arg-delim> <argument> }* + <r-arg-list> ::= <r-argument> { <arg-delim> <argument> }* + + <argument> ::= anychar+ + <r-argument> ::= anychar+ - {<option-prefix> anychar*} + + + */ + + + definition(CLineGrammar const& self) + { + command_line = + + string_d (command_name) >> + !option_list >> + !( + ( + string_d + ( + option_prefix[ SeperatorHandler (self.cl_) ] + ) >> !arg_list + ) | r_arg_list + ); + + // command name + + command_name = (+anychar_p)[CommandNameHandler (self.cl_)]; + + // options + + option_list = *(option); + + option = composite | equational; + + composite = + + string_d + ( + option_prefix >> c_name + + ) >> !string_d (c_value); + + equational = string_d (option_prefix >> e_name >> '=' >> e_value); + + option_prefix = lexeme_d[ch_p('-') >> !ch_p('-')]; + + e_name = + + lexeme_d + [ + ( + +( + anychar_p - ('=' | space_p) + ) + + )[ OptionNameHandler (self.cl_, CommandLine::Option::EQUATIONAL) ] + ]; + + c_name = + + lexeme_d + [ + ( + +(anychar_p - space_p) - + + ( + *(anychar_p - '=') >> '=' >> *anychar_p + ) + + )[ OptionNameHandler (self.cl_, CommandLine::Option::COMPOSITE) ] + ]; + + e_value = (+anychar_p)[ OptionValueHandler (self.cl_) ]; + + + c_value = + ( + +anychar_p - ( option_prefix >> *anychar_p ) + + )[ OptionValueHandler (self.cl_) ]; + + + + // arguments + + arg_list = *(argument); + r_arg_list = !(r_argument >> *argument); + + argument = string_d ((+anychar_p)[ ArgumentHandler (self.cl_) ]); + + r_argument = string_d + ( + ( + +anychar_p - (option_prefix >> *anychar_p) + + )[ ArgumentHandler (self.cl_) ] + ); + + } + + rule<ScannerT> const& start() const + { + return command_line; + } + }; +}; + + +#endif // COMMAND_LINE_GRAMMAR_H diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp new file mode 100644 index 00000000000..49e241fc475 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.cpp @@ -0,0 +1,59 @@ +// file : CCF/CodeGenerationKit/CommandLineParser.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/CommandLineParser.hpp" +#include "CCF/CodeGenerationKit/CommandLineGrammar.hpp" + +#include <vector> +#include <string> +#include <iostream> + +using std::cerr; +using std::endl; + +bool parse (int argc, char* argv[], CommandLine& cl) throw () +{ + typedef + std::vector<std::string> + Argv; + + Argv v; + + for (int i = 0; i < argc; i++) + { + v.push_back (argv[i]); + } + + Argv::iterator first = v.begin (); + Argv::iterator last = v.end (); + + scanner<Argv::iterator, scanner_policies <> > scan(first, last); + + CLineGrammar g (cl); + + match<nil_t> hit = g.parse(scan); + + bool result = static_cast<std::size_t>(hit.length()) == v.size (); + + // some semantic analisys + if (!cl.separator) + { + CommandLine::Options::reverse_iterator r = cl.options.rbegin (); + + if (r != cl.options.rend () && + r->value_ != "" && + r->type_ == CommandLine::Option::COMPOSITE) + { + + cerr << "command line: assuming <" << r->value_ + << "> to be a value of option <" << r->name_ + << "> and not the first argument" << endl; + + cerr << "command line: write ... --" << r->name_ << " -- " + << r->value_ << " ... to indicate otherwise" << endl; + } + } + + return result; +} diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp new file mode 100644 index 00000000000..f985b448ae3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CommandLineParser.hpp @@ -0,0 +1,12 @@ +// file : CCF/CodeGenerationKit/CommandLineParser.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef COMMAND_LINE_PARSER_H +#define COMMAND_LINE_PARSER_H + +#include "CCF/CodeGenerationKit/CommandLine.hpp" + +bool parse (int argc, char* argv[], CommandLine& cl) throw (); + +#endif // COMMAND_LINE_PARSER_H diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp new file mode 100644 index 00000000000..75af953c318 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationBuffer.hpp @@ -0,0 +1,60 @@ +// file : CCF/CodeGenerationKit/IndentationBuffer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_BUFFER_HPP + +#include "CCF/CompilerElements/ExH.hpp" + +#include <string> + +namespace Indentation +{ + 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_HPP diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp new file mode 100644 index 00000000000..2772e9ecd2a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationCxx.hpp @@ -0,0 +1,245 @@ +// file : CCF/CodeGenerationKit/IndentationCxx.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_CXX_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_CXX_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + class Cxx : public Buffer + { + public: + Cxx (Buffer& out) + : out_ (out), + indentation_ (0), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~Cxx () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + bool defaulting = false; + 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 (); + + hold_.push_back (c); + + // result = write (c); + + ensure_new_line (); + + break; + } + case ';': + { + // Handling '};' case. + // + if (hold_.size () > 1 && hold_.back () == '\n') + { + bool pop_nl (false); + + for (Hold::reverse_iterator + i (hold_.rbegin ()), e (hold_.rend ()); i != e; ++i) + { + if (*i != '\n') + { + if (*i == '}') pop_nl = true; + break; + } + } + + if (pop_nl) while (hold_.back () == '\n') hold_.pop_back (); + } + + + 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 (traits_type::eof ()); + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer& out_; + unsigned long indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp new file mode 100644 index 00000000000..3f428462745 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp @@ -0,0 +1,219 @@ +// file : CCF/CodeGenerationKit/IndentationIDL.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + 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 (traits_type::eof ()); + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer& out_; + unsigned long indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp new file mode 100644 index 00000000000..8dfc4093bdb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationImplanter.hpp @@ -0,0 +1,121 @@ +// file : CCF/CodeGenerationKit/IndentationImplanter.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER +#define CCF_CODE_GENERATION_KIT_INDENTATION_IMPLANTER + +#include <ostream> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + 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/IndentationXML.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationXML.hpp new file mode 100644 index 00000000000..3caf3daf552 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationXML.hpp @@ -0,0 +1,219 @@ +// file : CCF/CodeGenerationKit/IndentationXML.hpp +// author : Diego Sevilla Ruiz <dsevilla@ditec.um.es> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + class XML : public Buffer + { + public: + XML (Buffer& out) + : out_ (out), + indentation_ (0), + base_indent_ (indentation_), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~XML () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + switch (c) + { + case '\n': + { + flush_buffer (); + + // If we are inside a tag, just output an artificial tab character + if (construct_ == INSIDE_TAG) + { + hold_.push_back (c); + c = traits_type::to_int_type (' '); + + // spaces_ - 1 because at the end the last space will be + // put into the hold_ queue. + for (unsigned long i = 0; i < spaces_ - 1; i++) + hold_.push_back (c); + } + + base_indent_ = indentation_; + + break; + } + + // Case with <?xxx and <!DOCTYPE (for example). + // We still don't handle XML comments + case '?': + case '!': + { + if (construct_ == INSIDE_TAG && hold_.back () == '<') + indentation_--; + + break; + } + + case '<': + { + //@@ This construct must not be INSIDE_TAG + if (construct_ == OTHER) + { + construct_ = INSIDE_TAG; + indentation_++; + } + + break; + } + + case '>': + { + if (construct_ == INSIDE_TAG) + construct_ = OTHER; + + break; + } + + case '/': + { + if (construct_ == INSIDE_TAG) + { + if (hold_.back () == '<') + indentation_ -= 2; + else + indentation_--; + + if (indentation_ < 0) + indentation_ = 0; + } + + break; + } + + case '\"': + { + if (construct_ == INSIDE_TAG) + construct_ = STRING_LITERAL; + else if (construct_ == STRING_LITERAL) + construct_ = INSIDE_TAG; + + break; + } + + } + + hold_.push_back (c); + + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + try + { + flush_buffer (); + } catch (const Full&) + { + throw EndOfStream ("unable to flush buffer"); + } + } + + private: + class Full {}; + + void + flush_buffer () throw (Full) + { + long delta = indentation_ - base_indent_; + + if (delta > 0) + delta = 0; + + while (!hold_.empty ()) + { + int_type c = hold_.front (); + + write (c); + + if (c == '\n') + output_indentation (base_indent_ + delta); + + hold_.pop_front (); + } + } + + void + output_indentation (unsigned long indentation) throw (Full) + { + for (unsigned long i = 0; i < indentation * spaces_; i++) + { + write (' '); + } + } + + int_type + write (int_type c) throw (Full) + { + int_type result; + + result = out_.put (c); + + if (result == traits_type::eof ()) throw Full (); + + return result; + } + + + private: + Buffer& out_; + long indentation_; + unsigned long base_indent_; + unsigned long spaces_; + + enum Construct + { + OTHER, + /* Strings literals can only happen inside tags, like: + * <tag whatever="xxx + */ + STRING_LITERAL, + INSIDE_TAG, + }; + + Construct construct_; + + typedef std::deque<int_type> Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_XML_HPP + +/* + * Local Variables: + * mode: C++ + * c-basic-offset: 2 + * End: + */ diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/Makefile.alt b/TAO/CIAO/CCF/CCF/CodeGenerationKit/Makefile.alt new file mode 100644 index 00000000000..4658bdb4a91 --- /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/CodeGenerationKit/Regex.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/Regex.hpp new file mode 100644 index 00000000000..17f0cd09baa --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/Regex.hpp @@ -0,0 +1,38 @@ +// file : CCF/CodeGenerationKit/Regex.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_REGEX_HPP +#define CCF_RUNTIME_REGEX_HPP + +#include <string> +#include <boost/regex.hpp> + +namespace regex +{ + using boost::regex; + using boost::regex_merge; + + inline std::string + perl_s (std::string src, std::string e, char delimiter = '/') + { + std::string::size_type first = e.find (delimiter); + std::string::size_type middle = e.find (delimiter, first + 1); + std::string::size_type last = e.find (delimiter, middle + 1); + + std::string pattern (e, first + 1, middle - first - 1); + std::string format (e, middle + 1, last - middle - 1); + + //std::cout << pattern << " " << format << std::endl; + + regex expr (pattern); + + return regex_merge ( + src, + expr, + format, + boost::match_default | boost::format_all ); + } +} + +#endif // CCF_RUNTIME_REGEX_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc new file mode 100644 index 00000000000..c9714b62159 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc @@ -0,0 +1,28 @@ +//$Id$ +project { + + staticname = CompilerElements + + // @@ (diego) This hack is needed because MPC doesn't generate + // static-only projects for gnuace + verbatim(gnuace, top) { + static_libs_only = 1 + } + + includes += ../.. $(UTILITY_ROOT) $(BOOST_ROOT) + + Source_Files { + Introspection.cpp + } + + Header_Files { + Context.hpp + Diagnostic.hpp + ExH.hpp + FileSystem.hpp + Introspection.hpp + Preprocessor.hpp + ReferenceCounting.hpp + TokenStream.hpp + } +} diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.vcproj b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.vcproj new file mode 100644 index 00000000000..8d12dab2342 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.vcproj @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="CompilerElements" + ProjectGUID="{CED6ADA4-86E1-4F4A-95A2-7AB986D9E4CC}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4800" + Optimization="0" + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CompilerElements.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4800" + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/CompilerElements.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\Introspection.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\Context.hpp"> + </File> + <File + RelativePath=".\Diagnostic.hpp"> + </File> + <File + RelativePath=".\ExH.hpp"> + </File> + <File + RelativePath=".\FileSystem.hpp"> + </File> + <File + RelativePath=".\Introspection.hpp"> + </File> + <File + RelativePath=".\Preprocessor.hpp"> + </File> + <File + RelativePath=".\ReferenceCounting.hpp"> + </File> + <File + RelativePath=".\TokenStream.hpp"> + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp new file mode 100644 index 00000000000..02a2145c429 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Context.hpp @@ -0,0 +1,102 @@ +// file : CCF/CompilerElements/Context.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_COMPILER_ELEMENTS_CONTEXT_HPP +#define CCF_COMPILER_ELEMENTS_CONTEXT_HPP + +#include <map> +#include <string> +#include <Utility/Hetero/Container.hpp> + +namespace CCF +{ + namespace CompilerElements + { + class Context + { + typedef + std::map<std::string, Utility::Hetero::Container> + Map; + + public: + Context () + { + } + + public: + class NotFound {}; + class Typing {}; + + Map::size_type + count (char const* key) const throw () + { + return map_.count (key) != 0; + } + + template <typename T> + T const& + get (char const* key) const throw (NotFound, Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) throw NotFound (); + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + + } + + template <typename T> + T const& + get (char const* key, T const& def) const throw (Typing) + { + Map::const_iterator i = map_.find (key); + if (i == map_.end ()) return def; + + try + { + return i->second. template value<T> (); + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + template <typename T> + void + set (char const* key, T const& value) throw (Typing) + { + try + { + if (!map_.insert (std::pair<std::string, + Utility::Hetero::Container>(key, value)).second) + { + Map::iterator i = map_.find (key); + i->second.template value <T> () = value; + } + } + catch (Utility::Hetero::Typing const&) + { + throw Typing (); + } + } + + private: + Map map_; + + private: + // Copy semanic is not supported. + Context (Context const&) throw (); + Context& operator= (Context const&) throw (); + }; + } +} + +#endif // CCF_COMPILER_ELEMENTS_CONTEXT_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp new file mode 100644 index 00000000000..eecc527b432 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Diagnostic.hpp @@ -0,0 +1,192 @@ +// file : CCF/CompilerElements/Diagnostic.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_DIAGNOSTIC_HPP +#define CCF_DIAGNOSTIC_HPP + +#include <string> +#include <sstream> +#include <iostream> + +#include "CCF/CompilerElements/ExH.hpp" + +//@@ Should be inside CCF namespace + +namespace Diagnostic +{ + // + // + // + class Record : public std::ostringstream + { + public: + + struct Type + { + enum Value + { + INFO, + WARNING, + ERROR + }; + }; + + Record (Type::Value type, + std::string file, + unsigned long line, + std::string description = "") + : std::ostringstream (description), + type_ (type), + file_ (file), + line_ (line) + { + } + + public: + + Type::Value + type () const + { + return type_; + } + + std::string + file () const + { + return file_; + } + + unsigned long line () const + { + return line_; + } + + std::string + description () const + { + return str (); + } + + private: + Type::Value type_; + std::string file_; + unsigned long line_; + }; + + + // + // + // + struct Info : public Record + { + Info (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::INFO, file, line, description) + { + } + }; + + + // + // + // + struct Warning : public Record + { + Warning (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::WARNING, file, line, description) + { + } + }; + + + // + // + // + struct Error : public Record + { + Error (std::string file, + unsigned long line, + std::string description = "") + : Record (Type::ERROR, file, line, description) + { + } + }; + + + // + // + // + class Stream + { + public: + + Stream () + : info_count_ (0), + warning_count_ (0), + error_count_ (0) + { + } + + + Stream& + operator<< (Record const& msg) + { + std::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/ExH.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/ExH.hpp new file mode 100644 index 00000000000..ad7e1b71950 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/ExH.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/ExH.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_EX_H_H +#define CCF_RUNTIME_EX_H_H + +#include "Utility/ExH/ExH.hpp" + +namespace ExH = Utility::ExH; + +#endif // CCF_RUNTIME_EX_H_H diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp new file mode 100644 index 00000000000..ba9483f04e6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/FileSystem.hpp @@ -0,0 +1,33 @@ +// file : CCF/CompilerElements/FileSystem.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_FILE_SYSTEM_HPP +#define CCF_RUNTIME_FILE_SYSTEM_HPP + +#include <string> + +#include <boost/filesystem/path.hpp> +#include <boost/filesystem/fstream.hpp> +#include <boost/filesystem/exception.hpp> +#include <boost/filesystem/operations.hpp> + +namespace fs +{ + using namespace boost::filesystem; + + inline path + normalize (path const& p) + { + path result; + + for (path::iterator i (p.begin ()), e (p.end ()); i != e; ++i) + { + if (*i != ".") result /= path (*i, native); + } + + return result; + } +} + +#endif // CCF_RUNTIME_FILE_SYSTEM_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.cpp b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.cpp new file mode 100644 index 00000000000..9e625e0272a --- /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.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.hpp new file mode 100644 index 00000000000..898e596fa88 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Introspection.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/Introspection.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_INTROSPECTION_HPP +#define CCF_RUNTIME_INTROSPECTION_HPP + +#include "Utility/Introspection/Introspection.hpp" + +namespace Introspection = Utility::Introspection; + +#endif // CCF_RUNTIME_INTROSPECTION_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/Makefile.alt b/TAO/CIAO/CCF/CCF/CompilerElements/Makefile.alt new file mode 100644 index 00000000000..3626ec1eb28 --- /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/CompilerElements/Preprocessor.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/Preprocessor.hpp new file mode 100644 index 00000000000..f829301caaf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/Preprocessor.hpp @@ -0,0 +1,314 @@ +// file : CCF/CompilerElements/Preprocessor.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_PREPROCESSOR_HPP +#define CCF_PREPROCESSOR_HPP + +#include <locale> +#include <deque> + +#include "CCF/CompilerElements/TokenStream.hpp" + +// tmp +// #include <iostream> + +namespace CCF +{ + //@@ this code is experimental and needs cleaning + class Preprocessor : public TokenStream<char> + { + public: + virtual + ~Preprocessor () {} + + Preprocessor (TokenStream<char>& is) + : state (PREPROCESSING), + loc_ ("C"), + is_ (is) + { + } + + public: + virtual int_type + next () + { + return out_get (); + } + + private: + int_type + underflow () + { + int_type i = in_get (); + + if (eos (i)) + { + return i; + } + + char_type c = to_char_type (i); + + //std::cerr << "next_i: c = " << c << std::endl; + + switch (c) + { + case '\\': return handle_escape (); + case '\"': + { + if (state == STRING_LITERAL) state = PREPROCESSING; + else if (state == PREPROCESSING) state = STRING_LITERAL; + else + { + //@@error + } + break; + } + case '\'': + { + if (state == CHAR_LITERAL) state = PREPROCESSING; + else if (state == PREPROCESSING) state = CHAR_LITERAL; + else + { + //@@error + } + break; + } + case '#': + { + // std::cerr << "see \'#\'; state is " << state << std::endl; + if (state != PREPROCESSING) break; + return handle_preprocessor_token (); + } + } + + return i; + } + + int_type + handle_escape () + { + int_type i = in_get (); + + if (eos (i)) + { + //@@ error + return i; + } + + char_type c = to_char_type (i); + + //@@ '\n' won't work on MS + switch (c) + { + case '\n': return underflow (); //skip it + default: + { + out_buffer_.push_back (i); + return '\\'; + } + } + } + + void + skip_white_space () + { + while (true) + { + int_type i = in_get (); + if (!eos (i)) + { + char_type c = to_char_type (i); + if (std::isspace (c, loc_) && c != '\n') continue; + } + + in_put (i); + break; + } + } + + int_type + handle_preprocessor_token () + { + // std::cerr << "handle_preprocessor_token" << std::endl; + + skip_white_space (); + + std::string lexeme; + + int_type i; + char_type c; + + while (true) + { + i = in_get (); + + if (eos (i)) + { + //@@ error + return i; + } + + c = to_char_type (i); + + if (std::isalnum (c, loc_)) + { + lexeme += c; + continue; + } + break; + } + + if (lexeme == "include") return handle_preprocessor_include (); + else + { + // skip till newline + while (true) + { + if (c == '\n') break; + + i = in_get (); + + if (eos (i)) + { + //@@ error + return i; + } + + c = to_char_type (i); + } + } + + return underflow (); + } + + + int_type + handle_preprocessor_include () + { + //out_put (std::string ("include")); + + skip_white_space (); + + std::string file; + + int_type i = in_get (); + + if (eos (i)) + { + //@@ error + return i; + } + + char_type c = to_char_type (i); + + char_type finilizer; + + if (c == '\"') finilizer = c; + else if (c == '<') finilizer = '>'; + else + { + //@@error + } + + while (true) + { + i = in_get (); + + if (eos (i)) + { + //@@ error + return i; + } + + c = to_char_type (i); + + if (c == finilizer) break; + + file += c; + } + + //@@ it's probably a good idea to skip until the newline + // and perhaps check that all the rest is whitespace. + + if (finilizer == '>') out_put (std::string("sinclude \"")); + else out_put (std::string("include \"")); + + out_put (file); + out_put ("\";"); + + return out_get (); + } + + + private: + + // Buffer manipulation + + int_type + in_get () + { + if (in_buffer_.empty ()) + { + return is_.next (); + } + else + { + int_type i = in_buffer_.front (); + in_buffer_.pop_front (); + return i; + } + } + + void + in_put (int_type c) + { + in_buffer_.push_back (c); + } + + int_type + out_get () + { + if (out_buffer_.empty ()) + { + return underflow (); + } + else + { + int_type i = out_buffer_.front (); + out_buffer_.pop_front (); + return i; + } + } + + void + out_put (std::string const& str) + { + for (std::string::const_iterator i = str.begin (); i != str.end (); i++) + { + out_buffer_.push_back (*i); + } + } + + void + out_put (int_type c) + { + out_buffer_.push_back (c); + } + + private: + enum State + { + PREPROCESSING, + STRING_LITERAL, + CHAR_LITERAL + } state; + + std::locale loc_; + TokenStream<char>& is_; + std::deque<int_type> in_buffer_; + std::deque<int_type> out_buffer_; + }; +} + +#endif //CCF_PREPROCESSOR_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp new file mode 100644 index 00000000000..0c3e0057d59 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/ReferenceCounting.hpp @@ -0,0 +1,12 @@ +// file : CCF/CompilerElements/ReferenceCounting.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_RUNTIME_REFERENCE_COUNTING_H +#define CCF_RUNTIME_REFERENCE_COUNTING_H + +#include "Utility/ReferenceCounting/ReferenceCounting.hpp" + +namespace ReferenceCounting = Utility::ReferenceCounting; + +#endif // CCF_RUNTIME_REFERENCE_COUNTING_H diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp b/TAO/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp new file mode 100644 index 00000000000..0a9f291eec8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/TokenStream.hpp @@ -0,0 +1,76 @@ +// file : CCF/CompilerElements/TokenStream.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TOKEN_STREAM_HPP +#define TOKEN_STREAM_HPP + +#include <string> +#include <istream> + +namespace CCF +{ + template <typename Token> + class TokenStream + { + public: + virtual Token + next () = 0; + }; + + + template <> + class TokenStream<char> + { + public: + typedef + std::char_traits<char> + traits; + + typedef + traits::int_type + int_type; + + typedef + traits::char_type + char_type; + + public: + virtual int_type + next () = 0; + + char_type + to_char_type (int_type i) + { + return traits::to_char_type (i); + } + + bool + eos (int_type i) + { + return i == traits::eof (); + } + }; + + class InputStreamAdapter : public TokenStream<char> + { + public: + InputStreamAdapter (std::istream& is) + : is_ (is) + { + } + + public: + + virtual int_type + next () + { + return is_.get (); + } + + private: + std::istream& is_; + }; +} + +#endif //TOKEN_STREAM_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc b/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc new file mode 100644 index 00000000000..647a541c4bd --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc @@ -0,0 +1,76 @@ +//$Id$ +project { + + staticname = IDL2 + + // @@ (diego) This hack is needed because MPC doesn't generate + // static-only projects for gnuace + verbatim(gnuace, top) { + static_libs_only = 1 + } + + includes += ../.. $(UTILITY_ROOT) $(BOOST_ROOT) + + Source_Files { + LexicalAnalyzer.cpp + Parser.cpp + + SemanticAction/Operation.cpp + SyntaxTree/BuiltIn.cpp + SyntaxTree/Elements.cpp + SyntaxTree/ElementsCtor.cpp + SyntaxTree/Interface.cpp + SyntaxTree/InterfaceCtor.cpp + SyntaxTree/Module.cpp + SyntaxTree/Operation.cpp + SyntaxTree/Translation.cpp + SyntaxTree/TranslationCtor.cpp + SyntaxTree/ValueType.cpp + SyntaxTree/ValueTypeCtor.cpp + Traversal/BuiltIn.cpp + Traversal/Elements.cpp + Traversal/Interface.cpp + Traversal/Module.cpp + Traversal/Operation.cpp + Traversal/Translation.cpp + } + + Header_Files { + Parsing/Action.hpp + Parsing/Elements.hpp + Parsing/Recovery.hpp + LexicalAnalyzer.hpp + Parser.hpp + SemanticAction.hpp + SyntaxTree.hpp + Token.hpp + Traversal.hpp + SemanticAction/Impl/Attribute.hpp + SemanticAction/Impl/Elements.hpp + SemanticAction/Impl/Factory.hpp + SemanticAction/Impl/Include.hpp + SemanticAction/Impl/Interface.hpp + SemanticAction/Impl/Module.hpp + SemanticAction/Impl/Operation.hpp + SemanticAction/Attribute.hpp + SemanticAction/Elements.hpp + SemanticAction/Factory.hpp + SemanticAction/Include.hpp + SemanticAction/Interface.hpp + SemanticAction/Module.hpp + SemanticAction/Operation.hpp + SyntaxTree/BuiltIn.hpp + SyntaxTree/Elements.hpp + SyntaxTree/Interface.hpp + SyntaxTree/Module.hpp + SyntaxTree/Operation.hpp + SyntaxTree/Translation.hpp + SyntaxTree/ValueType.hpp + Traversal/BuiltIn.hpp + Traversal/Elements.hpp + Traversal/Interface.hpp + Traversal/Module.hpp + Traversal/Operation.hpp + Traversal/Translation.hpp + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/IDL2.vcproj b/TAO/CIAO/CCF/CCF/IDL2/IDL2.vcproj new file mode 100644 index 00000000000..8af0f2191c5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/IDL2.vcproj @@ -0,0 +1,758 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="IDL2" + ProjectGUID="{78A62970-330F-4FF1-9B0E-74F689A4EA4F}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + Optimization="0" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL2.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL2.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\LexicalAnalyzer.cpp"> + </File> + <File + RelativePath=".\Parser.cpp"> + </File> + <File + RelativePath=".\Token.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\LexicalAnalyzer.hpp"> + </File> + <File + RelativePath=".\Parser.hpp"> + </File> + <File + RelativePath=".\SemanticAction.hpp"> + </File> + <File + RelativePath=".\SyntaxTree.hpp"> + </File> + <File + RelativePath=".\Token.hpp"> + </File> + <File + RelativePath=".\Traversal.hpp"> + </File> + </Filter> + <Filter + Name="SyntaxTree" + Filter=""> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"> + <File + RelativePath=".\SyntaxTree\BuiltIn.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Elements.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\ElementsCtor.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Interface.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\InterfaceCtor.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Member.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Module.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Operation.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Sequence.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Struct.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SyntaxTree\Translation.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\TranslationCtor.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\Typedef.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\TypeId.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\ValueType.cpp"> + </File> + <File + RelativePath=".\SyntaxTree\ValueTypeCtor.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd"> + <File + RelativePath=".\SyntaxTree\BuiltIn.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Elements.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Interface.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Member.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Module.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Operation.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Sequence.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Struct.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Translation.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Typedef.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\TypeId.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\ValueType.hpp"> + </File> + </Filter> + </Filter> + <Filter + Name="Parsing" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\Parsing\Action.hpp"> + </File> + <File + RelativePath=".\Parsing\Elements.hpp"> + </File> + <File + RelativePath=".\Parsing\Recovery.hpp"> + </File> + </Filter> + </Filter> + <Filter + Name="Traversal" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\Traversal\BuiltIn.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Elements.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Interface.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Member.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Module.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Operation.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Sequence.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Struct.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Translation.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Typedef.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\TypeId.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\Traversal\BuiltIn.hpp"> + </File> + <File + RelativePath=".\Traversal\Elements.hpp"> + </File> + <File + RelativePath=".\Traversal\Interface.hpp"> + </File> + <File + RelativePath=".\Traversal\Member.hpp"> + </File> + <File + RelativePath=".\Traversal\Module.hpp"> + </File> + <File + RelativePath=".\Traversal\Operation.hpp"> + </File> + <File + RelativePath=".\Traversal\Sequence.hpp"> + </File> + <File + RelativePath=".\Traversal\Struct.hpp"> + </File> + <File + RelativePath=".\Traversal\Translation.hpp"> + </File> + <File + RelativePath=".\Traversal\Typedef.hpp"> + </File> + <File + RelativePath=".\Traversal\TypeId.hpp"> + </File> + </Filter> + </Filter> + <Filter + Name="SemanticAction" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Operation.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Attribute.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Include.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Interface.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Member.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Module.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Operation.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Struct.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Typedef.hpp"> + </File> + <File + RelativePath=".\SemanticAction\TypeId.hpp"> + </File> + </Filter> + <Filter + Name="Impl" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Attribute.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Elements.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Include.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Interface.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Member.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Module.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Operation.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)3.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)3.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Struct.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Typedef.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\TypeId.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Attribute.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Include.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Interface.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Member.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Module.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Operation.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Struct.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Typedef.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\TypeId.hpp"> + </File> + </Filter> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..5cd711eb83e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.cpp @@ -0,0 +1,1019 @@ +// file : CCF/IDL2/LexicalAnalyzer.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/LexicalAnalyzer.hpp" + +#include <stdlib.h> // strtol +#include <iostream> + +using std::cerr; +using std::endl; +using std::string; +using std::pair; +using std::size_t; + +namespace CCF +{ + namespace IDL2 + { + LexicalAnalyzer:: + LexicalAnalyzer (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 ("const" ); + keyword_table_.insert ("exception" ); + 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 ("raises" ); + keyword_table_.insert ("sequence" ); + keyword_table_.insert ("sinclude" ); + keyword_table_.insert ("struct" ); + keyword_table_.insert ("supports" ); + keyword_table_.insert ("typedef" ); + keyword_table_.insert ("typeid" ); + keyword_table_.insert ("typeprefix"); + + // Identifiers (alphabetic order). + // + // Note: if you are planning to hack something up + // in the code below, first make sure you understand + // how everything works! + // + + IdentifierTreeNode end; + + identifier_tree_["Object" ] = end; + identifier_tree_["ValueBase"] = end; + identifier_tree_["any" ] = end; + identifier_tree_["boolean" ] = end; + identifier_tree_["char" ] = end; + identifier_tree_["double" ] = end; + identifier_tree_["float" ] = end; + + IdentifierTreeNode long_; + long_["" ] = end; + long_["double"] = end; + long_["long" ] = end; + + identifier_tree_["long" ] = long_; + identifier_tree_["octet" ] = end; + identifier_tree_["short" ] = end; + identifier_tree_["string" ] = end; + + IdentifierTreeNode unsigned_long_; + unsigned_long_["" ] = end; + unsigned_long_["long"] = end; + + IdentifierTreeNode unsigned_; + unsigned_["long" ] = unsigned_long_; + unsigned_["short" ] = end; + + identifier_tree_["unsigned" ] = unsigned_; + identifier_tree_["void" ] = end; + identifier_tree_["wchar" ] = end; + identifier_tree_["wstring" ] = end; + + // punctuation (pair-matched). + // + punctuation_table_.insert (":"); + punctuation_table_.insert (","); + punctuation_table_.insert ("{"); + punctuation_table_.insert ("}"); + punctuation_table_.insert ("("); + punctuation_table_.insert (")"); + punctuation_table_.insert ("<"); + punctuation_table_.insert (">"); + punctuation_table_.insert (";"); + + // operators + // + operator_table_.insert ("+"); // add + operator_table_.insert ("&"); // and + operator_table_.insert ("~"); // com + operator_table_.insert ("/"); // div + operator_table_.insert ("="); // eq + operator_table_.insert ("<<"); // lsh + operator_table_.insert ("*"); // mul + operator_table_.insert ("|"); // or + operator_table_.insert ("%"); // rem + operator_table_.insert ("-"); // sub + operator_table_.insert (">>"); // rsh + operator_table_.insert ("^"); // xor + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + get_from_stream () + { + int_type i = is_.next (); + + if (after_nl) + { + after_nl = false; + line_++; + } + + if (i == '\n') after_nl = true; + + return Char (i, line_); + } + + + LexicalAnalyzer::Char LexicalAnalyzer:: + get () + { + if (!buffer_.empty ()) + { + Char c = buffer_.front (); + buffer_.pop_front (); + return c; + } + else + { + return get_from_stream (); + } + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + peek () + { + if (buffer_.empty ()) + { + buffer_.push_back (get_from_stream ()); + } + + return buffer_.front (); + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + peek_more () + { + if (buffer_.size () < 2) + { + buffer_.push_back (get_from_stream ()); + } + + return buffer_.at (1); + } + + void LexicalAnalyzer:: + ret (Char const& c) + { + buffer_.push_front (c); + } + + TokenPtr LexicalAnalyzer:: + next () + { + while (true) // Recovery loop. + { + Char c = skip_space (get ()); + + if (c.is_eof ()) return TokenPtr (new EndOfStream (c.line ())); + + TokenPtr token; + + if (character_literal (c, token)) return token; + + if (string_literal (c, token)) return token; + + if (integer_literal (c, token)) return token; + + if (operator_ (c, token)) return token; + + if (punctuation (c, token)) return token; + + // Check for identifier last because it can be triggered by + // wide string prefix (L"..."). + // + if (c.is_alpha (loc_) || c == '_' || (c == ':' && peek () == ':')) + { + return identifier (c); + } + + cerr << c.line () << ": error: unable to derive any token " + << "from \'" << c.char_ () << "\'" << endl; + + + //Do some primitive error recovery. + // + while (c != ';') + { + c = skip_space (get ()); + if (c.is_eof ()) return TokenPtr (new EndOfStream (c.line ())); + } + } + } + + LexicalAnalyzer::Char LexicalAnalyzer:: + skip_space (Char c) + { + bool first (true); + + while (true) + { + if (!first) c = get (); + else first = false; + + if (c.is_eof ()) return c; + + // Handling spaces + if (c.is_space (loc_)) continue; + + // Handling C++ comments + if (c == '/' && peek () == '/') + { + cxx_comment (c); + continue; + } + + // Handling C comments + if (c == '/' && peek () == '*') + { + c_comment (c); + continue; + } + + return c; + } + } + + + void LexicalAnalyzer:: + cxx_comment (Char c) + { + while (c != '\n') + { + c = get (); + + if (c.is_eof ()) + { + cerr << "warning: no new line at the end of file" + << endl; + + //@@ I wonder if it's ok to call get () again after getting eof. + //@@ no, it's not: istream throws exception (when enabled) on + // second attempt. + break; + } + } + } + + void LexicalAnalyzer:: + c_comment (Char c) + { + get (); // get '*' + + do + { + c = get (); + + if (c.is_eof ()) + { + cerr << "error: end of file before C-style comment finished" + << endl; + return; + + //@@ I wonder if it's ok to call get () again after getting eof. + // No, it is not. + } + + //cerr << "lexer: c_comment: read character \'" << c << "\'" + // << endl; + } + while (c != '*' || peek () != '/'); + + //cerr << "lexer: c_comment: finished C-comment \'" << c + // << "\',\'" << to_char_type (peek ()) + // << "\'" << endl; + + get (); // get '/' + } + + + bool LexicalAnalyzer:: + read_simple_identifier (string& lexeme, CharBuffer& buf) + { + Char c = skip_space (get ()); + + buf.push_back (c); + + if (c.is_eof ()) return false; + + if (c.is_alpha (loc_) || c == '_') + { + lexeme += c.char_ (); + + while (true) + { + c = peek (); + + if (c.is_eof ()) + { + cerr << "warning: no new line at the end of file" + << endl; + break; + } + + if (c.is_alnum (loc_) || c == '_') + { + buf.push_back (get ()); + lexeme += c.char_ (); + continue; + } + + break; + } + + return true; + } + + return false; + } + + + bool LexicalAnalyzer:: + traverse_identifier_tree (string& lexeme, + IdentifierTreeNode const& node) + { + if (node.map_.empty ()) return true; + + CharBuffer buf; + string part; + + if (read_simple_identifier (part, buf)) + { + IdentifierTreeNode::PrefixMap::const_iterator i ( + node.map_.find (part)); + + if (i != node.map_.end ()) + { + if (traverse_identifier_tree (part, i->second)) + { + lexeme += " " + part; + return true; + } + } + } + + // Return characters to the buffer in case we couldn't + // match anything. + + for(;!buf.empty (); buf.pop_back ()) ret (buf.back ()); + + // Check is the node.map_ contains empty key which indicates + // that what we've got is good enough. + // + return node.map_.find ("") != node.map_.end (); + } + + + TokenPtr LexicalAnalyzer:: + identifier (Char first) + { + Char c (first); + + string lexeme; + + enum + { + SIMPLE, + SCOPED, + OTHER + } type = SIMPLE; + + if (c == ':') + { + if((c = get ()) != ':') + { + cerr << "error: " << c.line () << ": \':\' expected." + << endl; + + return TokenPtr (new EndOfStream (c.line ())); + //@@ error handling is lame for lexical analyzer. + } + + lexeme = "::"; + type = SCOPED; + c = get (); + } + + // First caracter of an identifier. + // + if (c.is_eof ()) + { + cerr << "error: invalid identifier" << endl; + return TokenPtr (new EndOfStream (c.line ())); + } + + if (c.is_alpha (loc_) || c == '_') + { + lexeme += c.char_ (); + } + else + { + cerr << "error: invalid identifier" << endl; + return TokenPtr (new EndOfStream (c.line ())); + } + + while (true) + { + c = peek (); + + if (c.is_eof ()) + { + cerr << "warning: no new line at the end of file" + << endl; + break; + } + + // cerr << "lexer::identifier: peeking on \'" << c.char_ () + // << "\'; current lexeme \'" << lexeme << "\'" + // << endl; + + if (c.is_alnum (loc_) || c == '_') + { + get (); + lexeme += c.char_ (); + continue; + } + + if (c == ':' && peek_more () == ':') + { + get (); + get (); + lexeme += "::"; + if (type == SIMPLE) type = OTHER; + continue; + } + + break; + } + + //cerr << "lexer: found identifier with lexeme \'" + // << lexeme << "\'" << endl; + + if (type == SIMPLE) + { + // Check if it's a keyword. + { + KeywordTable::const_iterator i (keyword_table_.find (lexeme)); + + if (i != keyword_table_.end ()) + { + return TokenPtr (new Keyword (*i, first.line ())); + } + } + + // Check if it is a reserved identifier. + // + + { + IdentifierTreeNode::PrefixMap::const_iterator i ( + identifier_tree_.map_.find (lexeme)); + + if (i != identifier_tree_.map_.end ()) + { + if (traverse_identifier_tree (lexeme, i->second)) + { + return TokenPtr ( + new SimpleIdentifier (lexeme, first.line ())); + } + else + { + //@@ error + } + } + } + + // Check if it is a boolean literal. + // + if (lexeme == "TRUE" || lexeme == "FALSE") + { + return TokenPtr (new BooleanLiteral (lexeme, line_)); + } + + // Default to SimpleIdentifier. + // + return TokenPtr (new SimpleIdentifier (lexeme, line_)); + } + else if (type == SCOPED) + { + return TokenPtr (new ScopedIdentifier (lexeme, first.line ())); + } + else //type == OTHER + { + return TokenPtr (new Identifier (lexeme, first.line ())); + } + } + + bool LexicalAnalyzer:: + punctuation (Char 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 (i->size () == 2) // two-character punctuation + { + Char pc (peek ()); + + if (!pc.is_eof () && (*i)[1] == pc) + { + get (); + } + else + { + // Move on to the next candidate. + // + ++i; + continue; + } + } + + token = TokenPtr (new Punctuation (*i, c.line ()));; + return true; + } + } + + bool LexicalAnalyzer:: + operator_ (Char c, TokenPtr& token) + { + OperatorTable::const_iterator i = operator_table_.begin (); + + while (true) + { + for (;i != operator_table_.end () && (*i)[0] != c; ++i); + + if (i == operator_table_.end ()) return false; + + if (i->size () == 2) // two-character operator + { + Char pc (peek ()); + + if (!pc.is_eof () && (*i)[1] == pc) + { + get (); + } + else + { + // Move on to the next candidate. + // + ++i; + continue; + } + } + + token = TokenPtr (new Operator (*i, c.line ()));; + return true; + } + } + + pair<char, size_t> LexicalAnalyzer:: + scan_char (char const* s) throw (Format) + { + if (*s == '\0') + { + throw Format (); + } + else if (*s != '\\') + { + return pair<char, size_t> (*s, 1); + } + else + { + // Expected size is 2. + // + pair<char, size_t> r ('\0', 2); + + switch (*++s) + { + case 'n': + r.first = '\n'; + break; + + case 't': + r.first = '\t'; + break; + + case 'v': + r.first = '\v'; + break; + + case 'b': + r.first = '\b'; + break; + + case 'r': + r.first = '\r'; + break; + + case 'f': + r.first = '\f'; + break; + + case 'a': + r.first = '\a'; + break; + + case '\\': + r.first = '\\'; + break; + + case '?': + r.first = '\?'; + break; + + case '\'': + r.first = '\''; + break; + + case '"': + r.first = '\"'; + break; + + case 'x': + { + // hex + + char c = *++s; + + //@@ should use is_hex_digit + // + if((c >= '0' && c <= '9') || + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')) + { + // Maximum 2 digits. + // + string holder (s, 2); + + char* end; + + // Cannot fail. -1 < v < 256. + // + long v (strtol(holder.c_str (), &end, 16)); + + r.first = static_cast<char> (v); + r.second = 2 + end - holder.c_str (); + } + else + { + throw Format (); + } + break; + } + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + // Maximum 3 digits. + // + string holder (s, 3); + + char* end; + + // Cannot fail. + // + long v (strtol(holder.c_str (), &end, 8)); + + if (v < 0 || v > 255) throw Format (); + + r.first = static_cast<char> (v); + r.second = 1 + end - holder.c_str (); + + break; + } + default: + { + throw Format (); + } + } + + return r; + + } + } + + string LexicalAnalyzer:: + scan_string (string const& s) throw (Format) + { + string r; + + char const* p = s.c_str (); + + while (*p != '\0') + { + pair<char, size_t> c (scan_char (p)); + + if (c.first == '\0') throw Format (); + + r += c.first; + p += c.second; + } + + return r; + } + + + bool LexicalAnalyzer:: + character_literal (Char c, TokenPtr& token) + { + if (c != '\'') return false; + + string lexeme; + + Char prev (c); + + while (true) + { + Char c = get (); + + if (c.is_eof ()) + { + cerr << "error: end of file while reading character literal" + << endl; + break; + } + + if (c == '\'' && prev != '\\') break; + + lexeme += c.char_ (); + prev = c; + } + + try + { + pair<char, size_t> r (scan_char (lexeme.c_str ())); + if (r.second != lexeme.size ()) throw Format (); + + token = TokenPtr (new CharacterLiteral (r.first, lexeme, c.line ())); + return true; + } + catch (Format const& e) + { + cerr << "error: invalid character literal format" << endl; + return false; + } + } + + bool LexicalAnalyzer:: + string_literal (Char c, TokenPtr& token) + { + if (c != '\"') return false; + + string lexeme; + string value; + + try + { + while (true) + { + string r (string_literal_trailer ()); + value += scan_string (r); + lexeme += '\"' + r + '\"'; + + // Check if there are more strings. + // + + Char c = skip_space (get ()); + + if (c != '\"') + { + ret (c); // put it back + break; + } + + + // Add single space as string separator. + // + lexeme += " "; + } + + // cerr << "string literal: <" << lexeme << ">/<" << value << ">" + // << endl; + + token = TokenPtr (new StringLiteral (value, lexeme, c.line ())); + return true; + } + catch (Format const&) + { + cerr << "error: invalid string literal format" << endl; + return false; + } + } + + string LexicalAnalyzer:: + string_literal_trailer () + { + string r; + + Char prev ('\"', 0); + + while (true) + { + Char c = get (); + + if (c.is_eof ()) + { + cerr << "error: end of file while reading string literal" << endl; + break; + } + + if (c == '\"' && prev != '\\') break; + + r += c.char_ (); + prev = c; + } + + return r; + } + + unsigned long long LexicalAnalyzer:: + scan_integer (string const& s, unsigned short base) + throw (Format, Boundary) + { + unsigned long long const max (~0ULL); + + unsigned long long bound (max / base); + + char const* p (s.c_str ()); + + // Skip leading 0 if any. + // + while (*p != '\0' && *p == '0') ++p; + + unsigned long long result (0); + + while(*p != '\0') + { + unsigned short digit; + + //@@ I am using Char here just because I need + // manipulation functions. That's very bad. + // + Char c (Char (*p).to_upper (loc_)); + + if (c.is_dec_digit (loc_)) + { + digit = c.char_ () - '0'; + } + else if (c.is_hex_digit (loc_)) + { + digit = c.char_ () - 'A' + 10; + } + else + { + throw Format (); + } + + if (digit > base) throw Format (); + + if (result > bound) + { + // cerr << "boundary: base: " << base << "; bound: " << std::hex + // << bound << "; result: " << std::hex << result << endl; + + throw Boundary (); + } + + + result *= base; + result += digit; + + ++p; + } + + return result; + } + + //@@ need to return unparsed characters for recovery (like in + // integer_literal). + // + bool LexicalAnalyzer:: + integer_literal (Char first, TokenPtr& token) + { + try + { + Char c (first); + + if (!c.is_dec_digit (loc_)) return false; + + ret (c); // Temporary return the character. + + string lexeme, number; + + unsigned short base (10); // assume 10 + + // Determine base and get rid of its identifications. + // + // + if (c == '0') + { + lexeme += c.char_ (); + + get (); + + Char pc (peek ()); + + if (!pc.is_eof ()) + { + if (pc == 'x' || pc == 'X') + { + base = 16; + lexeme += get ().char_ (); + + c = peek (); + } + else + { + base = 8; + if (!pc.is_oct_digit (loc_)) + { + number += c.char_ (); // this is needed to handle single 0 + } + + c = pc; + } + } + else + { + number += c.char_ (); // this is needed to handle single 0 + } + } + + while (true) + { + // Make sure c is a legal character. + // + + if (c.is_eof ()) break; + + if (base == 8 && !c.is_oct_digit (loc_)) + { + break; + } + else if (base == 10 && !c.is_dec_digit (loc_)) + { + break; + } + else if (!c.is_hex_digit (loc_)) + { + break; + } + + get (); + + lexeme += c.char_ (); + number += c.char_ (); + + c = peek (); + } + + if (number.empty ()) throw Format (); + + unsigned long long value (scan_integer (number, base)); + + //cerr << "integer literal: <" << lexeme << ">/<" << number << ">/<" + // << value << ">" << endl; + + token = TokenPtr (new IntegerLiteral (value, lexeme, first.line ())); + return true; + } + catch (Format const&) + { + cerr << "error: invalid integer literal format" << endl; + return false; + } + catch (Boundary const&) + { + cerr << "error: integer literal is too big" << endl; + return false; + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp new file mode 100644 index 00000000000..c5026369b5a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/LexicalAnalyzer.hpp @@ -0,0 +1,293 @@ +// file : CCF/IDL2/LexicalAnalyzer.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_LEXICAL_ANALYZER_HPP +#define CCF_IDL2_LEXICAL_ANALYZER_HPP + +#include <set> +#include <map> +#include <deque> +#include <locale> +#include <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; + + struct Char + { + Char (int_type c, unsigned long line = 0) + : c_ (c), line_ (line) + { + } + + public: + bool + is_eof () const + { + return !traits::not_eof (c_); + } + + bool + is_alpha (std::locale const& l) const + { + return std::isalpha (char_ (), l); + } + + bool + is_oct_digit (std::locale const& l) const + { + char_type c (char_ ()); + + return std::isdigit (c, l) && c != '8' && c != '9'; + } + + bool + is_dec_digit (std::locale const& l) const + { + return std::isdigit (char_ (), l); + } + + bool + is_hex_digit (std::locale const& l) const + { + return std::isxdigit (char_ (), l); + } + + bool + is_alnum (std::locale const& l) const + { + return std::isalnum (char_ (), l); + } + + bool + is_space (std::locale const& l) const + { + return std::isspace (char_ (), l); + } + + Char + to_upper (std::locale const& l) const + { + return Char (std::toupper (char_ (), l), line_); + } + + public: + char_type + char_ () const + { + return traits::to_char_type (c_); + } + + unsigned long + line () const + { + return line_; + } + + public: + friend bool + operator== (Char const& a, Char const& b) + { + return a.is_eof () && b.is_eof () || a.char_ () == b.char_ (); + } + + friend bool + operator== (Char const& a, char b) + { + return !a.is_eof () && a.char_ () == b; + } + + friend bool + operator== (char a, Char const& b) + { + return b == a; + } + + friend bool + operator!= (Char const& a, Char const& b) + { + return !(a.is_eof () && b.is_eof () || a.char_ () == b.char_ ()); + } + + friend bool + operator!= (Char const& a, char b) + { + return a.is_eof () || a.char_ () != b; + } + + friend bool + operator!= (char a, Char const& b) + { + return b != a; + } + + private: + int_type c_; + unsigned long line_; + }; + + + protected: + virtual Char + get (); + + virtual Char + peek (); + + virtual Char + peek_more (); + + virtual void + ret (Char const& c); + + /* + char_type + to_char_type (int_type i); + */ + + virtual void + cxx_comment (Char c); + + virtual void + c_comment (Char c); + + virtual Char + skip_space (Char c); + + virtual TokenPtr + identifier (Char c); + + virtual bool + punctuation (Char c, TokenPtr& token); + + virtual bool + operator_ (Char c, TokenPtr& token); + + virtual bool + character_literal (Char c, TokenPtr& token); + + virtual bool + string_literal (Char c, TokenPtr& token); + + virtual std::string + string_literal_trailer (); + + virtual bool + integer_literal (Char c, TokenPtr& token); + + class Format {}; + class Boundary {}; + + std::pair<char, std::size_t> + scan_char (char const* s) throw (Format); + + std::string + scan_string (std::string const& s) throw (Format); + + unsigned long long + scan_integer (std::string const& s, unsigned short base) + throw (Format, Boundary); + + protected: + typedef + std::set<std::string> + KeywordTable; + + struct IdentifierTreeNode + { + typedef + std::map<std::string, IdentifierTreeNode> + PrefixMap; + + IdentifierTreeNode& + operator[] (char const* key) + { + return map_[key]; + } + + PrefixMap map_; + }; + + typedef + std::set<std::string> + PunctuationTable; + + typedef + std::set<std::string> + OperatorTable; + + typedef + std::deque<Char> + CharBuffer; + + protected: + + Char + get_from_stream (); + + bool + read_simple_identifier (std::string& lexeme, CharBuffer& buf); + + bool + traverse_identifier_tree (std::string& lexeme, + IdentifierTreeNode const& node); + + protected: + std::locale loc_; + + TokenStream<char>& is_; + + KeywordTable keyword_table_; + IdentifierTreeNode identifier_tree_; + PunctuationTable punctuation_table_; + OperatorTable operator_table_; + + // line numbering mechanism + bool after_nl; + unsigned long line_; + + // look ahead mechanism + + CharBuffer 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..a70fefc2396 --- /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 := SemanticGraph Traversal SemanticAction +default_makefile_name := Makefile.alt + +Makefile.archive : SemanticGraph 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..b8026bdb5f1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Makefile.archive @@ -0,0 +1,69 @@ +# 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 := SemanticGraph/Attribute.o \ + SemanticGraph/Elements.o \ + SemanticGraph/Exception.o \ + SemanticGraph/Fundamental.o \ + SemanticGraph/Interface.o \ + SemanticGraph/Literals.o \ + SemanticGraph/Member.o \ + SemanticGraph/Module.o \ + SemanticGraph/Name.o \ + SemanticGraph/Operation.o \ + SemanticGraph/Sequence.o \ + SemanticGraph/Struct.o \ + SemanticGraph/Translation.o \ + SemanticGraph/TypeId.o \ + SemanticGraph/ValueType.o + + +translated_units += Traversal/Attribute.o \ + Traversal/Elements.o \ + Traversal/Exception.o \ + Traversal/Fundamental.o \ + Traversal/Interface.o \ + Traversal/Member.o \ + Traversal/Module.o \ + Traversal/Operation.o \ + Traversal/Sequence.o \ + Traversal/Struct.o \ + Traversal/Translation.o \ + Traversal/TypeId.o \ + Traversal/ValueType.o + +translated_units += SemanticAction/Operation.o + +translated_units += SemanticAction/Impl/Attribute.o \ + SemanticAction/Impl/Elements.o \ + SemanticAction/Impl/Exception.o \ + SemanticAction/Impl/Factory.o \ + SemanticAction/Impl/Include.o \ + SemanticAction/Impl/Interface.o \ + SemanticAction/Impl/Member.o \ + SemanticAction/Impl/Module.o \ + SemanticAction/Impl/Operation.o \ + SemanticAction/Impl/Struct.o \ + SemanticAction/Impl/TypeId.o \ + SemanticAction/Impl/Typedef.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..e846071de7b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp @@ -0,0 +1,828 @@ +// 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" ), + CONST ("const" ), + EXCEPTION ("exception" ), + FACTORY ("factory" ), + IN ("in" ), + INCLUDE ("include" ), + INOUT ("inout" ), + INTERFACE ("interface" ), + LOCAL ("local" ), + MODULE ("module" ), + OUT ("out" ), + RAISES ("raises" ), + SEQUENCE ("sequence" ), + SINCLUDE ("sinclude" ), + STRUCT ("struct" ), + SUPPORTS ("supports" ), + TYPEDEF ("typedef" ), + TYPEID ("typeid" ), + TYPEPREFIX ("typeprefix" ), + + COLON (":"), + COMMA (","), + LBRACE ("{"), + RBRACE ("}"), + LPAREN ("("), + RPAREN (")"), + LT ("<"), + GT (">"), + SEMI (";"), + + + ADD ("+"), + AND ("&"), + COM ("~"), + DIV ("/"), + EQ ("="), + LSH ("<<"), + MUL ("*"), + OR ("|"), + REM ("%"), + SUB ("-"), + RSH (">>"), + XOR ("^"), + + + // Attribute + // + // + act_attribute_type ( + f.attribute (), &SemanticAction::Attribute::type), + + act_attribute_name ( + f.attribute (), &SemanticAction::Attribute::name), + + + // Exception + // + // + act_exception_begin ( + f.exception (), &SemanticAction::Exception::begin), + + act_exception_open_scope ( + f.exception (), &SemanticAction::Scope::open_scope), + + act_exception_close_scope ( + f.exception (), &SemanticAction::Scope::close_scope), + + act_exception_end ( + f.exception (), &SemanticAction::Exception::end), + + + // Include + // + // + act_include_begin (f.include (), &SemanticAction::Include::begin), + act_include_end (f.include (), &SemanticAction::Include::end), + + act_system_include_begin ( + f.system_include (), &SemanticAction::SystemInclude::begin), + + act_system_include_end ( + f.system_include (), &SemanticAction::SystemInclude::end), + + // Interface + // + // + act_abstract_interface_begin_def ( + f.interface (), &SemanticAction::Interface::begin_abstract_def), + + act_abstract_interface_begin_fwd ( + f.interface (), &SemanticAction::Interface::begin_abstract_fwd), + + act_local_interface_begin_def ( + f.interface (), &SemanticAction::Interface::begin_local_def), + + act_local_interface_begin_fwd ( + f.interface (), &SemanticAction::Interface::begin_local_fwd), + + act_unconstrained_interface_begin_def ( + f.interface (), + &SemanticAction::Interface::begin_unconstrained_def), + + act_unconstrained_interface_begin_fwd ( + f.interface (), + &SemanticAction::Interface::begin_unconstrained_fwd), + + act_interface_inherits ( + f.interface (), &SemanticAction::Interface::inherits), + + act_interface_open_scope ( + f.interface (), &SemanticAction::Scope::open_scope), + + act_interface_close_scope ( + f.interface (), &SemanticAction::Scope::close_scope), + + act_interface_end (f.interface (), &SemanticAction::Interface::end), + + + // Member + // + // + act_member_type ( + f.member (), &SemanticAction::Member::type), + + act_member_name ( + f.member (), &SemanticAction::Member::name), + + + // 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), + + + // Operation + // + // + act_operation_type ( + f.operation (), &SemanticAction::Operation::type), + + act_operation_name ( + f.operation (), &SemanticAction::Operation::name), + + act_operation_parameter ( + this, &Parser::act_operation_parameter_core), + + act_operation_raises ( + f.operation (), &SemanticAction::Operation::raises), + + + // Struct + // + // + act_struct_begin_def ( + f.struct_ (), &SemanticAction::Struct::begin_def), + + act_struct_begin_fwd ( + f.struct_ (), &SemanticAction::Struct::begin_fwd), + + act_struct_open_scope ( + f.struct_ (), &SemanticAction::Scope::open_scope), + + act_struct_close_scope ( + f.struct_ (), &SemanticAction::Scope::close_scope), + + act_struct_end (f.struct_ (), &SemanticAction::Struct::end), + + + // Typedef + // + // + act_typedef_begin ( + f.typedef_ (), &SemanticAction::Typedef::begin), + + act_typedef_begin_seq ( + f.typedef_ (), &SemanticAction::Typedef::begin_seq), + + act_typedef_declarator ( + f.typedef_ (), &SemanticAction::Typedef::declarator), + + act_typedef_end ( + f.typedef_ (), &SemanticAction::Typedef::end), + + + // TypeId + // + // + act_type_id_begin (f.type_id (), &SemanticAction::TypeId::begin), + act_type_id_end (f.type_id (), &SemanticAction::TypeId::end), + + + // TypePrefix + // + // + act_type_prefix_begin (f.type_prefix (), + &SemanticAction::TypePrefix::begin), + + act_type_prefix_end (f.type_prefix (), + &SemanticAction::TypePrefix::end) + { + language = + guard + ( + *import >> +declaration >> EOS + + )[root_error_handler] + ; + + + /* + language = + guard + ( + +(*import >> (+declaration)) >> EOS + ) + ; + */ + + import = + include_decl + | system_include_decl + ; + + include_decl = + INCLUDE + >> string_literal[act_include_begin] + >> SEMI[act_include_end] + ; + + system_include_decl = + SINCLUDE + >> string_literal[act_system_include_begin] + >> SEMI[act_system_include_end] + ; + + declaration = + abstract_type_decl + | const_decl + | exception_decl + | extension + | local_type_decl + | module_decl + | struct_decl + | typedef_ + | type_id + | type_prefix + | unconstrained_interface_decl + ; + + type_id = + TYPEID + >> ( + identifier + >> string_literal + )[act_type_id_begin] + >> SEMI[act_type_id_end] + ; + + type_prefix = + TYPEPREFIX + >> ( + identifier + >> string_literal + )[act_type_prefix_begin] + >> SEMI[act_type_prefix_end] + ; + + 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] + ; + + // const + // + // + const_decl = + CONST + >> identifier + >> simple_identifier + >> EQ + >> const_expr + >> SEMI + ; + + + // const expression + // + // + + const_expr = + boolean_const_expr + | character_const_expr + | integer_const_expr + | string_const_expr + ; + + boolean_const_expr = boolean_literal; + + character_const_expr = character_literal; + + //@@ I may have recognision problem on unary operators or + // even worse on LPAREN. + // + + integer_const_expr = integer_or_expr; + + integer_or_expr = + integer_xor_expr + >> *(OR >> integer_xor_expr) + ; + + integer_xor_expr = + integer_and_expr + >> *(XOR >> integer_and_expr) + ; + + + integer_and_expr = + integer_shift_expr + >> *(AND >> integer_shift_expr) + ; + + integer_shift_expr = + integer_add_expr + >> *( + (RSH >> integer_add_expr) + | (LSH >> integer_add_expr) + ) + ; + + integer_add_expr = + integer_mul_expr + >> *( + (ADD >> integer_mul_expr) + | (SUB >> integer_mul_expr) + ) + ; + + integer_mul_expr = + integer_unary_expr + >> *( + (MUL >> integer_unary_expr) + | (DIV >> integer_unary_expr) + | (REM >> integer_unary_expr) + ) + ; + + integer_unary_expr = + integer_primary_expr + | ADD >> integer_primary_expr + | SUB >> integer_primary_expr + | COM >> integer_primary_expr + ; + + integer_primary_expr = + identifier + | integer_literal + | LPAREN >> integer_const_expr >> RPAREN + ; + + string_const_expr = string_literal; + + // interface + // + // + abstract_interface_decl = + guard + ( + ( + simple_identifier + >> SEMI + )[act_abstract_interface_begin_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_abstract_interface_begin_def] + + >> interface_inheritance_spec + >> LBRACE[act_interface_open_scope] + >> interface_def_trailer + ) + | + ( + ( + simple_identifier + >> LBRACE + )[act_abstract_interface_begin_def][act_interface_open_scope] + + >> interface_def_trailer + ) + )[error_handler] + ; + + + local_interface_decl = + guard + ( + ( + simple_identifier + >> SEMI + )[act_local_interface_begin_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_local_interface_begin_def] + + >> interface_inheritance_spec + >> LBRACE[act_interface_open_scope] + >> interface_def_trailer + ) + | + ( + ( + simple_identifier + >> LBRACE + )[act_local_interface_begin_def][act_interface_open_scope] + + >> interface_def_trailer + ) + )[error_handler] + ; + + + unconstrained_interface_decl = + guard + ( + INTERFACE + >> ( + ( + simple_identifier + >> SEMI + )[act_unconstrained_interface_begin_fwd][act_interface_end] + | + ( + ( + simple_identifier + >> COLON + )[act_unconstrained_interface_begin_def] + + >> interface_inheritance_spec + >> LBRACE[act_interface_open_scope] + >> interface_def_trailer + ) + | + ( + ( + simple_identifier + >> LBRACE + )[act_unconstrained_interface_begin_def][act_interface_open_scope] + + >> interface_def_trailer + ) + ) + )[error_handler] + ; + + + interface_def_trailer = + 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_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 + ; + + + // exception + // + // + exception_decl = + EXCEPTION + >> simple_identifier[act_exception_begin] + >> LBRACE[act_exception_open_scope] + >> exception_body + >> RBRACE[act_exception_close_scope] + >> SEMI[act_exception_end] + ; + + exception_body = + *member_decl + ; + + + // direction specifier + // + // + direction_specifier = + IN + | OUT + | INOUT + ; + + + // member + // + // + member_decl = + identifier[act_member_type] + >> member_declarator_list + >> SEMI + ; + + + member_declarator_list = + identifier[act_member_name] + >> *( + COMMA + >> identifier[act_member_name] + ) + ; + + + // operation + // + // + operation_decl = + identifier[act_operation_type] + >> simple_identifier[act_operation_name] + >> LPAREN + >> operation_parameter_list + >> RPAREN + >> !(RAISES >> LPAREN >> operation_raises_list >> RPAREN) + >> SEMI + ; + + operation_parameter_list = + *( + operation_parameter + >> *(COMMA >> operation_parameter) + ) + ; + + operation_parameter = + ( + direction_specifier + >> identifier + >> simple_identifier + )[act_operation_parameter] + ; + + operation_raises_list = + identifier[act_operation_raises] + >> *(COMMA >> identifier[act_operation_raises]) + ; + + + // struct + // + // + struct_decl = + guard + ( + STRUCT + >> ( + ( + simple_identifier + >> SEMI + )[act_struct_begin_fwd][act_struct_end] + | + ( + ( + simple_identifier + >> LBRACE + )[act_struct_begin_def][act_struct_open_scope] + >> struct_def_trailer + ) + ) + )[error_handler] + ; + + /* + struct_decl = + STRUCT + >> simple_identifier + >> LBRACE + >> struct_body + >> RBRACE + >> SEMI + ; + */ + + + struct_def_trailer = + struct_body + >> assertion ("member or \'}\' expected", + f.struct_ (), + &SemanticAction::Struct::close_scope, + &SemanticAction::Struct::end, + RecoveryMethod::STANDARD, + DiagnosticType::BEFORE) + ( + RBRACE[act_struct_close_scope] + ) + >> assertion ("\';\' is missing", + f.struct_ (), + &SemanticAction::Struct::end, + RecoveryMethod::NONE) + ( + SEMI[act_struct_end] + ) + ; + + + struct_body = + +member_decl + ; + + + // typedef + // + // + + typedef_ = + TYPEDEF + >> typedef_type_spec + >> typedef_declarator_list + >> SEMI[act_typedef_end] + ; + + typedef_type_spec = + identifier[act_typedef_begin] + | SEQUENCE >> LT >> identifier[act_typedef_begin_seq] >> GT + ; + + typedef_declarator_list = + identifier[act_typedef_declarator] + >> *( + COMMA + >> identifier[act_typedef_declarator] + ) + ; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp new file mode 100644 index 00000000000..2ccb0275c85 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp @@ -0,0 +1,647 @@ +// 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::OperatorParser + OperatorParser; + + typedef + Parsing::IdentifierParser + IdentifierParser; + + typedef + Parsing::SimpleIdentifierParser + SimpleIdentifierParser; + + + typedef + Parsing::RecoveryDescriptor + RecoveryDescriptor; + + typedef + Parsing::Assertion + Assertion; + + typedef + Parsing::RecoveryStatus + RecoveryStatus; + + typedef + Parsing::Guard + Guard; + + //@@ names are not thought out weel for error handling + + struct ErrorHandler + { + ErrorHandler (CompilerElements::Context& context, + Diagnostic::Stream& dout) + : dout_ (dout), + context_ (context) + { + } + + RecoveryStatus + operator() (Parsing::Scanner const& s, Parsing::Error e) const + { + Iterator i = e.where; + + switch (e.descriptor->diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << e.descriptor->description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + i--; + + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "after \'" << (*i)->lexeme () << "\': " + << e.descriptor->description_; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + if (e.descriptor->action_one_.get ()) + e.descriptor->action_one_->execute (); + + if (e.descriptor->action_two_.get ()) + e.descriptor->action_two_->execute (); + + switch (e.descriptor->recovery_) + { + case Parsing::RecoveryMethod::STANDARD: + { + unsigned long balance = 0; + + for (Iterator t = e.where; t != s.last; t++) + { + //std::cerr << "error recovery: skipping " << (*t)->lexeme () + // << std::endl; + + if ((*t)->lexeme () == "{") balance++; + else if ((*t)->lexeme () == "}") + { + if (balance > 0) balance--; + else + { + t++; + if ((*t)->lexeme () == ";") t++; + + int length = t - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + if (balance == 0 && (*t)->lexeme () == ";") + { + int length = t - s.first + 1; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + } + + switch (e.descriptor->diagnostic_) + { + case Parsing::DiagnosticType::BEFORE: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + + rec << "before \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::AFTER: + { + Diagnostic::Error rec ( + context_.get<fs::path> ("file-path").native_file_string (), + (*i)->line ()); + rec << "after \'" << (*i)->lexeme () << "\': " + << "unable to recover from previous error: bailing out"; + + dout_ << rec; + break; + } + case Parsing::DiagnosticType::NONE: + { + } + } + + e.descriptor->recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor->diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor->action_one_.reset (); + e.descriptor->action_two_.reset (); + + // return RecoveryStatus (RecoveryStatus::rethrow); + throw e; + } + case Parsing::RecoveryMethod::NONE: + default: + { + int length = e.where - s.first; + s.first += length; + return RecoveryStatus (RecoveryStatus::accept, length); + } + case Parsing::RecoveryMethod::BAIL_OUT: + { + e.descriptor->recovery_ = Parsing::RecoveryMethod::BAIL_OUT; + e.descriptor->diagnostic_ = Parsing::DiagnosticType::NONE; + + e.descriptor->action_one_.reset (); + e.descriptor->action_two_.reset (); + + // return RecoveryStatus (RecoveryStatus::rethrow); + throw e; + } + } + } + + Diagnostic::Stream& dout_; + CompilerElements::Context& context_; + }; + + struct RootErrorHandler + { + RecoveryStatus + operator() (Parsing::Scanner const& 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); + throw e; + } + + std::auto_ptr<Parsing::Thunk> action_one_; + std::auto_ptr<Parsing::Thunk> action_two_; + }; + + Guard guard; + Guard hood; + Assertion assertion; + ErrorHandler error_handler; + RootErrorHandler root_error_handler; + + // End of stream parser + EndOfStreamParser EOS; + + // Keyword parsers (alphabetic order). + KeywordParser ABSTRACT; + KeywordParser ATTRIBUTE; + KeywordParser CONST; + KeywordParser EXCEPTION; + KeywordParser FACTORY; + KeywordParser IN; + KeywordParser INCLUDE; + KeywordParser INOUT; + KeywordParser INTERFACE; + KeywordParser LOCAL; + KeywordParser MODULE; + KeywordParser OUT; + KeywordParser RAISES; + KeywordParser SEQUENCE; + KeywordParser SINCLUDE; + KeywordParser STRUCT; + KeywordParser SUPPORTS; + KeywordParser TYPEDEF; + KeywordParser TYPEID; + KeywordParser TYPEPREFIX; + + // Punctuation parsers (alphabetic group order). + PunctuationParser COLON; + PunctuationParser COMMA; + PunctuationParser LBRACE; + PunctuationParser RBRACE; + PunctuationParser LPAREN; + PunctuationParser RPAREN; + PunctuationParser LT; + PunctuationParser GT; + PunctuationParser SEMI; + + OperatorParser ADD; + OperatorParser AND; + OperatorParser COM; + OperatorParser DIV; + OperatorParser EQ; + OperatorParser LSH; + OperatorParser MUL; + OperatorParser OR; + OperatorParser REM; + OperatorParser SUB; + OperatorParser RSH; + OperatorParser XOR; + + + IdentifierParser identifier; + SimpleIdentifierParser simple_identifier; + + Parsing::BooleanLiteralParser boolean_literal; + Parsing::CharacterLiteralParser character_literal; + Parsing::IntegerLiteralParser integer_literal; + Parsing::StringLiteralParser string_literal; + + // + // Language + // + typedef + Parsing::Rule + Rule; + + Rule language; + Rule import; + Rule declaration; + Rule extension; + + Rule include_decl; + Rule system_include_decl; + + Rule module_decl; + + Rule const_decl; + Rule const_expr; + + Rule boolean_const_expr; + Rule character_const_expr; + Rule integer_const_expr; + + Rule integer_or_expr; + Rule integer_xor_expr; + Rule integer_and_expr; + Rule integer_shift_expr; + Rule integer_add_expr; + Rule integer_mul_expr; + Rule integer_unary_expr; + Rule integer_primary_expr; + + Rule string_const_expr; + + Rule abstract_type_decl; + Rule local_type_decl; + + Rule abstract_interface_decl; + Rule local_interface_decl; + Rule unconstrained_interface_decl; + Rule interface_def_trailer; + Rule interface_inheritance_spec; + Rule interface_body; + + Rule attribute_decl; + + Rule exception_decl; + Rule exception_body; + + Rule direction_specifier; + + Rule member_decl; + Rule member_declarator_list; + + Rule operation_decl; + Rule operation_parameter_list; + Rule operation_parameter; + Rule operation_raises_list; + + Rule struct_decl; + Rule struct_def_trailer; + Rule struct_body; + + Rule typedef_; + Rule typedef_type_spec; + Rule typedef_declarator_list; + + Rule type_id; + Rule type_prefix; + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + virtual Rule const& + start() const + { + return language; + } + + protected: + + // + // Semantic actions + // + typedef + NoArgAction<SemanticAction::Scope> + ScopeAction; + + + // Attribute + // + // + OneArgAction<IdentifierPtr, SemanticAction::Attribute> + act_attribute_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Attribute> + act_attribute_name; + + // Exception + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Exception> + act_exception_begin; + + ScopeAction + act_exception_open_scope; + + ScopeAction + act_exception_close_scope; + + NoArgAction<SemanticAction::Exception> + act_exception_end; + + // Include + // + // + OneArgAction<StringLiteralPtr, SemanticAction::Include> + act_include_begin; + + NoArgAction<SemanticAction::Include> + act_include_end; + + OneArgAction<StringLiteralPtr, SemanticAction::SystemInclude> + act_system_include_begin; + + NoArgAction<SemanticAction::SystemInclude> + act_system_include_end; + + + // Interface + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Interface> + act_abstract_interface_begin_def, + act_abstract_interface_begin_fwd, + act_local_interface_begin_def, + act_local_interface_begin_fwd, + act_unconstrained_interface_begin_def, + act_unconstrained_interface_begin_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::Interface> + act_interface_inherits; + + ScopeAction + act_interface_open_scope; + + ScopeAction + act_interface_close_scope; + + NoArgAction<SemanticAction::Interface> + act_interface_end; + + + // Member + // + // + OneArgAction<IdentifierPtr, SemanticAction::Member> + act_member_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Member> + act_member_name; + + + // Module + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Module> + act_module_begin; + + ScopeAction + act_module_open_scope; + + ScopeAction + act_module_close_scope; + + NoArgAction<SemanticAction::Module> + act_module_end; + + + // Operation + // + // + + OneArgAction<IdentifierPtr, SemanticAction::Operation> + act_operation_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Operation> + act_operation_name; + + 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; + + OneArgAction<IdentifierPtr, SemanticAction::Operation> + act_operation_raises; + + + // Struct + // + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Struct> + act_struct_begin_def; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Struct> + act_struct_begin_fwd; + + ScopeAction + act_struct_open_scope; + + ScopeAction + act_struct_close_scope; + + NoArgAction<SemanticAction::Struct> + act_struct_end; + + + // Typedef + // + // + OneArgAction<IdentifierPtr, SemanticAction::Typedef> + act_typedef_begin; + + OneArgAction<IdentifierPtr, SemanticAction::Typedef> + act_typedef_begin_seq; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Typedef> + act_typedef_declarator; + + NoArgAction<SemanticAction::Typedef> + act_typedef_end; + + + // TypeId + // + // + TwoArgAction<IdentifierPtr, + StringLiteralPtr, + SemanticAction::TypeId> + act_type_id_begin; + + NoArgAction<SemanticAction::TypeId> + act_type_id_end; + + + // TypePrefix + // + // + TwoArgAction<IdentifierPtr, + StringLiteralPtr, + SemanticAction::TypePrefix> + act_type_prefix_begin; + + NoArgAction<SemanticAction::TypePrefix> + act_type_prefix_end; + }; + } +} + +#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..2737abafb58 --- /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..88e091d8845 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Elements.hpp @@ -0,0 +1,168 @@ +// file : CCF/IDL2/Parsing/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSING_ELEMENTS_HPP +#define CCF_IDL2_PARSING_ELEMENTS_HPP + +#include <string> + +#include <boost/spirit.hpp> + +#include "CCF/IDL2/Token.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + using namespace boost::spirit; + + typedef + TokenList::iterator + Iterator; + + typedef + scanner<Iterator, scanner_policies<> > + Scanner; + + typedef + rule<Scanner> + Rule; + + + // + // + // + template <typename Type> + struct IdentityParser : public parser <IdentityParser<Type> > + { + typedef + IdentityParser + self_t; + + IdentityParser (std::string lexeme) + : lexeme_ (lexeme) + { + } + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0 && + lexeme_ == t->lexeme ()) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + + private: + std::string lexeme_; + }; + + typedef + IdentityParser<Keyword> + KeywordParser; + + typedef + IdentityParser<Punctuation> + PunctuationParser; + + typedef + IdentityParser<Operator> + OperatorParser; + + // + // + // + template <typename Type> + struct TypeParser : public parser <TypeParser<Type> > + { + typedef + TypeParser + self_t; + + typename parser_result<self_t, Scanner>::type + parse(Scanner const& scan) const + { + if (!scan.at_end()) + { + TokenPtr t = *scan; + + if(ReferenceCounting::strict_cast<Type> (t) != 0) + { + Iterator save(scan.first); + ++scan; + return scan.create_match(1, t, save, scan.first); + } + } + return scan.no_match(); + } + }; + + typedef + TypeParser<EndOfStream> + EndOfStreamParser; + + typedef + TypeParser<Identifier> + IdentifierParser; + + typedef + TypeParser<SimpleIdentifier> + SimpleIdentifierParser; + + typedef + TypeParser<ScopedIdentifier> + ScopedIdentifierParser; + + // Literal parsers. + // + + typedef + TypeParser<BooleanLiteral> + BooleanLiteralParser; + + typedef + TypeParser<CharacterLiteral> + CharacterLiteralParser; + + typedef + TypeParser<IntegerLiteral> + IntegerLiteralParser; + + typedef + TypeParser<StringLiteral> + StringLiteralParser; + + // + // + // + inline bool + parse (Iterator const& first_, + Iterator const& last, + Rule const& rule) + { + Iterator first = first_; + Scanner scan(first, last); + match<nil_t> hit = rule.parse(scan); + + bool result = parse_info<Iterator>( + first, hit, hit && (first == last), hit.length()).full; + + return result; + } + } + } +} + +#endif // CCF_IDL2_PARSING_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp new file mode 100644 index 00000000000..82ae9be30c5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Parsing/Recovery.hpp @@ -0,0 +1,288 @@ +// file : CCF/IDL2/Parsing/Recovery.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_PARSING_RECOVERY_HPP +#define CCF_IDL2_PARSING_RECOVERY_HPP + +#include <memory> + +#include "CCF/CompilerElements/ReferenceCounting.hpp" +#include "CCF/IDL2/Parsing/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Parsing + { + + // + // + // + struct RecoveryMethod + { + enum Value + { + NONE, + STANDARD, + BAIL_OUT + }; + }; + + + // + // + // + struct DiagnosticType + { + enum Value + { + BEFORE, + AFTER, + NONE + }; + }; + + + // + // + // + class Thunk + { + public: + virtual + ~Thunk () {} + + virtual void + execute () = 0; + + virtual Thunk* + clone () const = 0; + }; + + + // + // + // + template<typename Object> + class ThunkImpl : public Thunk + { + public: + typedef void (Object::*Func)(); + + ThunkImpl (Object& obj, Func func) + : obj_(obj), + func_ (func) + { + } + + virtual void + execute () + { + (obj_.*func_)(); + } + + virtual Thunk* + clone () const + { + return new ThunkImpl<Object> (obj_, func_); + } + + private: + Object& obj_; + Func func_; + }; + + // + // + // + template<typename Object> + Thunk* + call_thunk (Object& obj, void (Object::*func)()) + { + return new ThunkImpl<Object> (obj, func); + } + + + // + // + // + struct RecoveryDescriptor : + public virtual ReferenceCounting::DefaultImpl <> + { + virtual ~RecoveryDescriptor () throw () {} + + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic) + : action_one_ (0), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (0), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + template<typename Object> + RecoveryDescriptor (std::string d, + RecoveryMethod::Value recovery, + DiagnosticType::Value diagnostic, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)()) + : action_one_ (call_thunk (obj, action_one)), + action_two_ (call_thunk (obj, action_two)), + description_ (d), + recovery_ (recovery), + diagnostic_ (diagnostic) + { + } + + RecoveryDescriptor (RecoveryDescriptor const& rd) + : action_one_ (rd.action_one_.get () ? rd.action_one_->clone () : 0), + action_two_ (rd.action_two_.get () ? rd.action_two_->clone () : 0), + description_ (rd.description_), + recovery_ (rd.recovery_), + diagnostic_ (rd.diagnostic_) + { + } + + + std::auto_ptr<Thunk> action_one_; + std::auto_ptr<Thunk> action_two_; + std::string description_; + RecoveryMethod::Value recovery_; + DiagnosticType::Value diagnostic_; + }; + + typedef + ReferenceCounting::StrictPtr<RecoveryDescriptor> + RecoveryDescriptorPtr; + + + // I have to use a pointer to RecoveryDescriptor instead of + // just RecoveryDescriptor to subvert constness of descriptor + // member in spirit::parser_error. + // + // + + typedef + parser_error<RecoveryDescriptorPtr, Iterator> + Error; + + + // + // + // + struct Assertion + { + typedef + assertion<RecoveryDescriptorPtr> + AssertionImpl; + + AssertionImpl + operator () (RecoveryMethod::Value recovery = RecoveryMethod::NONE) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ("", recovery, DiagnosticType::NONE))); + } + + AssertionImpl + operator () (std::string d, + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor (d, recovery, diagnostic))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, recovery, diagnostic, obj, action_one))); + } + + template<typename Object> + AssertionImpl + operator () (Object& obj, + void (Object::*action_one)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + "", recovery, DiagnosticType::NONE, obj, action_one))); + } + + template<typename Object> + AssertionImpl + operator () (std::string d, + Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::STANDARD, + DiagnosticType::Value diagnostic = DiagnosticType::AFTER) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ( + d, recovery, diagnostic, obj, action_one, action_two))); + } + + + template<typename Object> + AssertionImpl + operator () (Object& obj, + void (Object::*action_one)(), + void (Object::*action_two)(), + RecoveryMethod::Value recovery = RecoveryMethod::BAIL_OUT) + { + return AssertionImpl ( + RecoveryDescriptorPtr ( + new RecoveryDescriptor ("", + recovery, + DiagnosticType::NONE, + obj, + action_one, + action_two))); + } + + }; + + typedef + error_status<> + RecoveryStatus; + + typedef + guard<RecoveryDescriptorPtr> + Guard; + } + } +} + +#endif // CCF_IDL2_PARSING_RECOVERY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp new file mode 100644 index 00000000000..5c5cc551216 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp @@ -0,0 +1,22 @@ +// 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/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL2/SemanticAction/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Member.hpp" +#include "CCF/IDL2/SemanticAction/Module.hpp" +#include "CCF/IDL2/SemanticAction/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/TypeId.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..3fd8a8a196f --- /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..3d53d703595 --- /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/Exception.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.cpp new file mode 100644 index 00000000000..e34dd9e01fc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/SemanticAction/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp new file mode 100644 index 00000000000..20bea8c0669 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Exception.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/SemanticAction/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + class Exception : public virtual Scope + { + public: + virtual + ~Exception () 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_EXCEPTION_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..e671c57755a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp @@ -0,0 +1,77 @@ +// 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 Attribute; + class Exception; + class Include; + class Interface; + class Member; + class Module; + class Operation; + class Struct; + class SystemInclude; + class Typedef; + class TypeId; + class TypePrefix; + + // + // + // + class Factory + { + public: + virtual + ~Factory () throw () {} + + virtual Attribute& + attribute () = 0; + + virtual SemanticAction::Exception& + exception () = 0; + + virtual Include& + include () = 0; + + virtual Interface& + interface () = 0; + + virtual Member& + member () = 0; + + virtual Module& + module () = 0; + + virtual Operation& + operation () = 0; + + virtual Struct& + struct_ () = 0; + + virtual SystemInclude& + system_include () = 0; + + virtual Typedef& + typedef_ () = 0; + + virtual TypeId& + type_id () = 0; + + virtual TypePrefix& + type_prefix () = 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..bc54a06acc2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.cpp @@ -0,0 +1,90 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Attribute:: + ~Attribute () throw () + { + } + + Attribute:: + Attribute (Context& c) + : Base (c) + { + } + + void Attribute:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "attribute " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name, complete); + } + catch (Resolve const&) + { + cerr << "error: invalid attribute declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an attribute type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Attribute:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + SemanticGraph::Attribute& a ( + ctx.tu ().new_node<SemanticGraph::Attribute> ()); + + ctx.tu ().new_edge<Belongs> (a, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), a, id->lexeme ()); + } + } + } + } + } +} 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..f3e06941b6d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Attribute.hpp @@ -0,0 +1,45 @@ +// file : CCF/IDL2/SemanticAction/Impl/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Attribute : public virtual SemanticAction::Attribute, + public Base + { + public: + // @@ remove all these d-tors. + // + virtual + ~Attribute () throw (); + + Attribute (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Type* 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..ffec220d177 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.cpp @@ -0,0 +1,133 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace +{ + bool trace (false); +} + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // @@ Need pointer iterator adapter. + + using namespace SemanticGraph; + using SemanticGraph::Scope; + + Nameables + resolve (TranslationUnit& tu, + ScopedName const& from, + Name const& name) throw (NotFound) + { + + if (trace) cerr << "resolve: starting resolution process for \'" + << name << "\' from \'" << from << "\'" << endl; + + Nameables r; + + // Check if name is already scoped. + // + if (name.scoped ()) + { + r = tu.lookup (ScopedName (name)); + } + else + { + // Obtain all nodes corresponding to this scope name. + // + + for (ScopedName next (from);;) + { + Nameables scopes (tu.lookup (next)); + + // Lookup the name in each scope. + // + for (Nameables::const_iterator + i (scopes.begin ()), end (scopes.end ()); + i != end; ++i) + { + if (Scope* s = dynamic_cast<Scope*> (*i)) + { + s->lookup (name, r); + } + } + + if (r.begin () != r.end () || next.simple ()) + { + // Found something -or- at the root scope. + // + break; + } + + next = ScopedName (next.begin (), next.end () - 1); + } + } + + if (r.begin () == r.end ()) + { + if (trace) cerr << "resolve: resolution process for \'" + << name << "\' from \'" << from << "\' failed." + << endl; + + throw NotFound (); + } + else + { + if (trace) cerr << "resolve: resolution process for \'" + << name << "\' from \'" << from << "\' succeeded:" + << endl; + + for (Nameables::const_iterator i (r.begin ()), end (r.end ()); + i != end; ++i) + { + if (trace) cerr << "\t\'" << (**i).scoped_name () << "\'" + << endl; + } + } + + return r; + } + + + // Lookup *all* scopes for a simple name + // + // + Nameable* + lookup (SemanticGraph::TranslationUnit& tu, + SemanticGraph::Scope& in, + SemanticGraph::SimpleName const& name) throw (NotUnique) + { + Nameables r; + + Nameables scopes (tu.lookup (in.scoped_name ())); + + for (Nameables::const_iterator + i (scopes.begin ()), end (scopes.end ()); + i != end; ++i) + { + dynamic_cast<Scope&> (**i).lookup (name, r); + } + + if (r.size () > 1) throw NotUnique (); + + if (r.empty ()) return 0; + + return *(r.begin ()); + } + } + } + } +} diff --git a/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..46fa82504cf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,267 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include <stack> + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +/* + Design notes: + + (1) I am using stack-based approach to handle cases like this: + + struct A + { + struct B + { + struct C + { + ... + } c; + + } b; + }; + + Even though you can't write the same let's say for interface + I am still using stack approach for consistency and possible + meta-coding. + +*/ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Context + { + public: + Context (bool trace, + SemanticGraph::TranslationUnit& tu) + : trace_ (trace), + tu_ (tu) + { + } + + bool + trace () + { + return trace_; + } + + SemanticGraph::TranslationUnit& + tu () const + { + return tu_; + } + + SemanticGraph::Scope& + scope () const + { + return *scope_; + } + + void + scope (SemanticGraph::Scope& scope) + { + scope_ = &scope; + } + + SemanticGraph::TranslationRegion& + region () const + { + return *region_; + } + + void + region (SemanticGraph::TranslationRegion& r) + { + region_ = &r; + } + + private: + bool trace_; + SemanticGraph::TranslationUnit& tu_; + SemanticGraph::TranslationRegion* region_; + SemanticGraph::Scope* scope_; + + private: + Context (Context const&); + void operator= (Context const&); + }; + + + class Base + { + protected: + virtual + ~Base () throw () {} + + Base (Context& c) + : ctx (c) + { + } + + protected: + + class Resolve {}; + + template <typename Id> + struct ExceptionTemplate : Resolve + { + explicit + ExceptionTemplate (SemanticGraph::ScopedName name) + : name_ (name) + { + } + + SemanticGraph::ScopedName + name () const + { + return name_; + } + + private: + SemanticGraph::ScopedName name_; + }; + + + struct NotFound : Resolve {}; + + class WrongType_ {}; + typedef ExceptionTemplate<WrongType_> WrongType; + + class NotUnique : Resolve {}; + + class NotDefined_ {}; + typedef ExceptionTemplate<NotDefined_> NotDefined; + + class NotComplete_ {}; + typedef ExceptionTemplate<NotComplete_> NotComplete; + + enum Flags + { + none = 0x00, + complete = 0x01, + defined = 0x02 + }; + + template <typename T> + T& + resolve (SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name, + Flags flags = none) + throw (NotFound, NotUnique, WrongType, NotDefined, NotComplete); + + + class AlreadyInherited_ {}; + typedef ExceptionTemplate<AlreadyInherited_> AlreadyInherited; + + class AlreadySupported_ {}; + typedef ExceptionTemplate<AlreadySupported_> AlreadySupported; + + template<typename I> + void + check_inheritance (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadyInherited); + + template<typename I> + void + check_support (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadySupported); + + protected: + Context& ctx; + }; + + // + // + // + template <typename T> + class ScopeBase : public virtual SemanticAction::Scope, + public Base + { + protected: + virtual + ~ScopeBase () throw () {} + + ScopeBase (Context& c) + : Base (c) + { + } + + protected: + T& + now () const + { + return *now_; + } + + void + now (T& t) + { + now_ = &t; + } + + void + push (SemanticGraph::Scope& t) + { + stack_.push (&t); + } + + void + pop () + { + stack_.pop (); + } + + SemanticGraph::Scope& + top () + { + return *stack_.top (); + } + + private: + T* now_; + std::stack<SemanticGraph::Scope*> stack_; + }; + + // + // + // + + class NotFound {}; + class NotUnique {}; + + SemanticGraph::Nameables + resolve (SemanticGraph::TranslationUnit& tu, + SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name) throw (NotFound); + + + + + SemanticGraph::Nameable* + lookup (SemanticGraph::TranslationUnit& tu, + SemanticGraph::Scope& in, + SemanticGraph::SimpleName const& name) throw (NotUnique); + } + } + } +} + +#include "CCF/IDL2/SemanticAction/Impl/Elements.tpp" + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp new file mode 100644 index 00000000000..d4dd0bbeeb9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Elements.tpp @@ -0,0 +1,95 @@ +// file : CCF/IDL2/SemanticAction/Impl/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + template <typename T> + T& Base:: + resolve (SemanticGraph::ScopedName const& from, + SemanticGraph::Name const& name, + Flags flags) + throw (NotFound, NotUnique, WrongType, NotDefined, NotComplete) + { + using namespace SemanticGraph; + + try + { + ScopedName from (ctx.scope ().scoped_name ()); + Nameables nodes (Impl::resolve (ctx.tu (), from, name)); + + + if (nodes.size () != 1) throw NotUnique (); + + Nameable& node (**(nodes.begin ())); + + try + { + T& t (dynamic_cast<T&> (node)); + + if (flags & defined) + { + if (!t.defined ()) throw NotDefined (node.scoped_name ()); + } + + if (flags & complete) + { + SemanticGraph::Type& type ( + dynamic_cast<SemanticGraph::Type&> (t)); + + if (!type.complete ()) + { + throw NotComplete (node.scoped_name ()); + } + } + + return t; + } + catch (std::bad_cast const&) + { + throw WrongType (node.scoped_name ()); + } + } + catch (Impl::NotFound const&) + { + throw NotFound (); + } + } + + template<typename I> + void Base:: + check_inheritance (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadyInherited) + { + for (;begin != end; ++begin) + { + if ((**begin).inheritee () == t) + { + throw AlreadyInherited (t.scoped_name ()); + } + } + } + + template<typename I> + void Base:: + check_support (I begin, I end, SemanticGraph::Nameable& t) + throw (AlreadySupported) + { + for (;begin != end; ++begin) + { + if ((**begin).supportee () == t) + { + throw AlreadySupported (t.scoped_name ()); + } + } + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp new file mode 100644 index 00000000000..f8e89569ee1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.cpp @@ -0,0 +1,74 @@ +// file : CCF/IDL2/SemanticAction/Impl/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Exception.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Exception:: + ~Exception () throw () + { + } + + Exception:: + Exception (Context& c) + : ScopeBase<SemanticGraph::Exception> (c) + { + } + + void Exception:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "exception " << id << endl; + + SimpleName name (id->lexeme ()); + + //@@ Need to check for redeclaration of the name. Can not + // do that because I don't have mechanism for throwing + // exception from SA. + // + now (ctx.tu ().new_node<SemanticGraph::Exception> ()); + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Exception:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Exception:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Exception:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp new file mode 100644 index 00000000000..25da9cf99fa --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Exception.hpp @@ -0,0 +1,46 @@ +// file : CCF/IDL2/SemanticAction/Impl/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Exception : public virtual SemanticAction::Exception, + public virtual ScopeBase<SemanticGraph::Exception> + { + public: + virtual + ~Exception () throw (); + + Exception (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_EXCEPTION_HPP diff --git a/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..bcf2ef600ad --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,84 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Factory:: + ~Factory () throw () + { + } + + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : ctx_ (context.get ("trace-semantic-action", false), tu), + + attribute_ (ctx_), + exception_ (ctx_), + include_ (ctx_), + interface_ (ctx_), + member_ (ctx_), + module_ (ctx_), + operation_ (ctx_), + struct__ (ctx_), + system_include_ (ctx_), + typedef__ (ctx_), + type_id_ (ctx_), + type_prefix_ (ctx_) + { + // Implied translation region with fundamental types. + // + TranslationRegion& ftr (tu.new_node<TranslationRegion> ()); + tu.new_edge<ContainsImplied> (tu, ftr, ".fundamental"); + + Root& fr (tu.new_node<Root> ()); + tu.new_edge<ContainsRoot> (ftr, fr); + + tu.new_edge<Defines> (fr, tu.new_node<Object> (), "Object"); + tu.new_edge<Defines> (fr, tu.new_node<ValueBase> (), "ValueBase"); + tu.new_edge<Defines> (fr, tu.new_node<Any> (), "any"); + tu.new_edge<Defines> (fr, tu.new_node<Boolean> (), "boolean"); + tu.new_edge<Defines> (fr, tu.new_node<Char> (), "char"); + tu.new_edge<Defines> (fr, tu.new_node<Double> (), "double"); + tu.new_edge<Defines> (fr, tu.new_node<Float> (), "float"); + tu.new_edge<Defines> (fr, tu.new_node<Long> (), "long"); + tu.new_edge<Defines> (fr, tu.new_node<LongDouble> (), "long double"); + tu.new_edge<Defines> (fr, tu.new_node<LongLong> (), "long long"); + tu.new_edge<Defines> (fr, tu.new_node<Octet> (), "octet"); + tu.new_edge<Defines> (fr, tu.new_node<Short> (), "short"); + tu.new_edge<Defines> (fr, tu.new_node<String> (), "string"); + tu.new_edge<Defines> (fr, tu.new_node<UnsignedLong> (), "unsigned long"); + tu.new_edge<Defines> (fr, tu.new_node<UnsignedLongLong> (), "unsigned long long"); + tu.new_edge<Defines> (fr, tu.new_node<UnsignedShort> (), "unsigned short"); + tu.new_edge<Defines> (fr, tu.new_node<Void> (), "void"); + tu.new_edge<Defines> (fr, tu.new_node<Wchar> (), "wchar"); + tu.new_edge<Defines> (fr, tu.new_node<Wstring> (), "wstring"); + + TranslationRegion& principal (tu.new_node<TranslationRegion> ()); + tu.new_edge<ContainsPrincipal> (tu, principal); + + Root& root (tu.new_node<Root> ()); + tu.new_edge<ContainsRoot> (principal, root); + + ctx_.region (principal); + ctx_.scope (root); + } + } + } + } +} 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..666717a21a5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,144 @@ +// file : CCF/IDL2/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/CompilerElements/Diagnostic.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +#include "CCF/IDL2/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +//@@ It would be nice to move this includes into .cpp +// +#include "CCF/IDL2/SemanticAction/Impl/Attribute.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Exception.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Member.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/Impl/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + //@@ rename sustem/user include to quote/bracket + // + // + class Factory : public virtual IDL2::SemanticAction::Factory + { + public: + virtual + ~Factory () throw (); + + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + virtual SemanticAction::Attribute& + attribute () + { + return attribute_; + } + + virtual SemanticAction::Exception& + exception () + { + return exception_; + } + + virtual SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Interface& + interface () + { + return interface_; + } + + virtual SemanticAction::Member& + member () + { + return member_; + } + + virtual SemanticAction::Module& + module () + { + return module_; + } + + virtual SemanticAction::Operation& + operation () + { + return operation_; + } + + virtual SemanticAction::Struct& + struct_ () + { + return struct__; + } + + virtual SemanticAction::SystemInclude& + system_include () + { + return system_include_; + } + + virtual SemanticAction::Typedef& + typedef_ () + { + return typedef__; + } + + virtual SemanticAction::TypeId& + type_id () + { + return type_id_; + } + + virtual SemanticAction::TypePrefix& + type_prefix () + { + return type_prefix_; + } + + protected: + Context ctx_; + + private: + Attribute attribute_; + Exception exception_; + Include include_; + Interface interface_; + Member member_; + Module module_; + Operation operation_; + Struct struct__; + SystemInclude system_include_; + Typedef typedef__; + TypeId type_id_; + TypePrefix type_prefix_; + }; + } + } + } +} + +#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..6b450608029 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.cpp @@ -0,0 +1,82 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Include.hpp" + +// #include "CCF/IDL2/SemanticGraph/Translation.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // @@ This is left unimplemented for now. Later code from + // IDL3 should be copied here. + // + // + + // Include + // + // + Include:: + ~Include () throw () + { + } + + Include:: + Include (Context& c) + : ctx (c) + { + } + + void Include:: + begin (StringLiteralPtr const& sl) + { + if (ctx.trace ()) cerr << "include " << sl << endl; + } + + void Include:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + // SystemInclude + // + // + SystemInclude:: + ~SystemInclude () throw () + { + } + + SystemInclude:: + SystemInclude (Context& c) + : ctx (c) + { + } + + void SystemInclude:: + begin (StringLiteralPtr const& sl) + { + if (ctx.trace ()) cerr << "include <" << sl->lexeme () << ">" + << endl; + } + + void SystemInclude:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} 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..738154880e4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Include.hpp @@ -0,0 +1,66 @@ +// file : CCF/IDL2/SemanticAction/Impl/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INCLUDE_HPP + + +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Include : public virtual SemanticAction::Include + { + public: + virtual + ~Include () throw (); + + Include (Context& c); + + virtual void + begin (StringLiteralPtr const& sl); + + virtual void + end (); + + private: + Context& ctx; + }; + + // + // + // + class SystemInclude : public virtual SemanticAction::SystemInclude + { + public: + virtual + ~SystemInclude () throw (); + + SystemInclude (Context& c); + + virtual void + begin (StringLiteralPtr const& sl); + + virtual void + end (); + + private: + Context& ctx; + }; + } + } + } +} + +#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..d6d42807ce5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.cpp @@ -0,0 +1,247 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Interface.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Interface:: + ~Interface () throw () {} + + Interface:: + Interface (Context& c) + : ScopeBase<SemanticGraph::Interface> (c) + { + } + + void Interface:: + begin_abstract_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract interface def " << id << endl; + + qualifier_ = Qualifier::abstract; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractInterface> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_abstract_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "abstract interface fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractInterface> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + begin_local_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "local interface def " << id << endl; + + qualifier_ = Qualifier::local; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<LocalInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<LocalInterface> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_local_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "local interface fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<LocalInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<LocalInterface> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + begin_unconstrained_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "unconstrained interface def " << id + << endl; + + qualifier_ = Qualifier::unconstrained; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<UnconstrainedInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<UnconstrainedInterface> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Interface:: + begin_unconstrained_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "unconstrained interface fwd " << id + << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<UnconstrainedInterface&>(*s)); + } + else + { + now (ctx.tu ().new_node<UnconstrainedInterface> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Interface:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, defined)); + + switch (qualifier_) + { + case Qualifier::abstract: + { + if (dynamic_cast<AbstractInterface*> (&i)) break; + + throw WrongType (i.scoped_name ()); + } + case Qualifier::unconstrained: + { + if (dynamic_cast<UnconstrainedInterface*> (&i) || + dynamic_cast<AbstractInterface*> (&i)) break; + + throw WrongType (i.scoped_name ()); + } + default: break; + } + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + i); + + ctx.tu ().new_edge<Inherits> (now (), i); + } + catch (Resolve const&) + { + cerr << "error: invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to inherit from forward-declared interface " + << e.name () << endl; + cerr << "inheritance from forward-declared interface is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << "directly inheriting from interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void Interface:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Interface:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Interface:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..535eb54a84d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Interface.hpp @@ -0,0 +1,73 @@ +// file : CCF/IDL2/SemanticAction/Impl/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Interface.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Interface : public virtual SemanticAction::Interface, + public virtual ScopeBase<SemanticGraph::Interface> + { + public: + virtual + ~Interface () throw (); + + Interface (Context& c); + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id); + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_local_def (SimpleIdentifierPtr const& id); + + virtual void + begin_local_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_unconstrained_def (SimpleIdentifierPtr const& id); + + virtual void + begin_unconstrained_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + + private: + struct Qualifier + { + enum Value { abstract, local, unconstrained }; + }; + + Qualifier::Value qualifier_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Makefile.alt new file mode 100644 index 00000000000..6f75d4f2076 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Makefile.alt @@ -0,0 +1,31 @@ +# file : CCF/IDL2/SemanticAction/Impl/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) + +# Factory.cpp + +cxx_translation_units := Attribute.cpp \ + Exception.cpp \ + Elements.cpp \ + Factory.cpp \ + Include.cpp \ + Interface.cpp \ + Member.cpp \ + Module.cpp \ + Operation.cpp \ + Struct.cpp \ + TypeId.cpp \ + Typedef.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/Impl/Member.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp new file mode 100644 index 00000000000..2f17b34a170 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp @@ -0,0 +1,93 @@ +// file : CCF/IDL2/SemanticAction/Impl/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Member.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Member:: + ~Member () throw () + { + } + + Member:: + Member (Context& c) + : Base (c) + { + } + + void Member:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "member " << id << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name, complete); + } + catch (Resolve const&) + { + cerr << "error: invalid member declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an member type is illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + + void Member:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + SimpleName name (id->lexeme ()); + + SemanticGraph::Member& m ( + ctx.tu ().new_node<SemanticGraph::Member> ()); + + ctx.tu ().new_edge<Belongs> (m, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), m, name); + } + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp new file mode 100644 index 00000000000..5928b574fbc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.hpp @@ -0,0 +1,45 @@ +// file : CCF/IDL2/SemanticAction/Impl/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/Member.hpp" +#include "CCF/IDL2/SemanticAction/Member.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +using namespace std; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Member : public virtual SemanticAction::Member, + public Base + { + public: + virtual + ~Member () throw (); + + Member (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Type* type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_MEMBER_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..450d12dd8c7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.cpp @@ -0,0 +1,68 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Module.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Module:: + ~Module () throw () + { + } + + Module:: + Module (Context& c) + : ScopeBase<SemanticGraph::Module> (c) + { + } + + void Module:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "module " << id << endl; + + now (ctx.tu ().new_node<SemanticGraph::Module> ()); + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), id->lexeme ()); + } + + void Module:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Module:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Module:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..e2d3d4d68a8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Module.hpp @@ -0,0 +1,46 @@ +// file : CCF/IDL2/SemanticAction/Impl/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP + +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticAction/Module.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Module : public virtual SemanticAction::Module, + public virtual ScopeBase<SemanticGraph::Module> + { + public: + virtual + ~Module () throw (); + + Module (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_MODULE_HPP diff --git a/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..742870b179d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.cpp @@ -0,0 +1,207 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Operation.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Operation:: + ~Operation () throw () + { + } + + Operation:: + Operation (Context& c) + : Base (c) + { + } + + void Operation:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "operation " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name, complete); + } + catch (Resolve const&) + { + cerr << "error: invalid operation declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an operation return type is illegal" + << endl; + } + catch (NotComplete const& e) + { + cerr << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void Operation:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + op_ = 0; + + if (type_) + { + SimpleName name (id->lexeme ()); + + SemanticGraph::Operation& o ( + ctx.tu ().new_node<SemanticGraph::Operation> ()); + + ctx.tu ().new_edge<Returns> (o, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), o, name); + + op_ = &o; + } + } + + + void Operation:: + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter " << direction << " " + << type_id << " " << name_id << endl; + + if (op_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, complete)); + + Parameter* p; + + switch (direction) + { + case Direction::in: + { + p = &ctx.tu ().new_node<InParameter> (name_id->lexeme ()); + break; + } + case Direction::out: + { + p = &ctx.tu ().new_node<OutParameter> (name_id->lexeme ()); + break; + } + case Direction::inout: + { + p = &ctx.tu ().new_node<InOutParameter> (name_id->lexeme ()); + break; + } + } + + ctx.tu ().new_edge<Belongs> (*p, t); + ctx.tu ().new_edge<Receives> (*op_, *p); + } + catch (Resolve const&) + { + cerr << "error: invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an operation parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + + void Operation:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (op_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*op_, e); + } + catch (Resolve const&) + { + cerr << "error: invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + cerr << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} 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..2fae39df979 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Operation.hpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticAction/Impl/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Operation.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Operation : public virtual SemanticAction::Operation, + public Base + { + public: + virtual + ~Operation () throw (); + + Operation (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (Direction::Value direction, + IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::Type* type_; + SemanticGraph::Operation* op_; + }; + + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp new file mode 100644 index 00000000000..ffd6a9f4eb1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.cpp @@ -0,0 +1,102 @@ +// file : CCF/IDL2/SemanticAction/Impl/Struct.cpp +// author : Jeff Parsons <j.parsons@vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Struct.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Struct:: + ~Struct () throw () + { + } + + Struct:: + Struct (Context& c) + : ScopeBase<SemanticGraph::Struct> (c) + { + } + + // @@ I need a mechanism for propagating exceptions from + // semantic actions to the parser in order to stop + // semantic action invocation. + // + + void Struct:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "struct def" << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Struct&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Struct> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Struct:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "struct fwd" << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Struct&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Struct> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Struct:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Struct:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Struct:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp new file mode 100644 index 00000000000..a7341300029 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Struct.hpp @@ -0,0 +1,49 @@ +// file : CCF/IDL2/SemanticAction/Impl/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP + +#include "CCF/IDL2/SemanticGraph/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Struct.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Struct : public virtual SemanticAction::Struct, + public virtual ScopeBase<SemanticGraph::Struct> + { + public: + virtual + ~Struct () throw (); + + Struct (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_STRUCT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp new file mode 100644 index 00000000000..d50a910a58b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.cpp @@ -0,0 +1,142 @@ +// file : CCF/IDL2/SemanticAction/Impl/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/TypeId.hpp" + +// These inclusions are needed to ensure that typeprefix is applied to a +// suitable declaration. + +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + // TypeId + // + // + TypeId:: + ~TypeId () throw () + { + } + + TypeId:: + TypeId (Context& c) + : ctx (c) + { + } + + void TypeId:: + begin (IdentifierPtr const& d, StringLiteralPtr const& id) + { + if (ctx.trace ()) cerr << "typeid " << d << " " << id << endl; + + Name name (d->lexeme ()); + SemanticGraph::StringLiteral tid (id->value ()); + + try + { + ScopedName from (ctx.scope ().scoped_name ()); + Nameables nodes (resolve (ctx.tu (), from, name)); + + ScopedName full ((**(nodes.begin ())).scoped_name ()); + + SemanticGraph::TypeId& ti ( + ctx.tu ().new_node<SemanticGraph::TypeId> (full, tid)); + + ctx.tu ().new_edge<Defines> (ctx.scope (), ti, "typeid"); + } + catch (NotFound const&) + { + cerr << "error: invalid typeid declaration" << endl; + cerr << "no declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + } + + void TypeId:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + + // TypePrefix + // + // + TypePrefix:: + ~TypePrefix () throw () + { + } + + TypePrefix:: + TypePrefix (Context& c) + : ctx (c) + { + } + + void TypePrefix:: + begin (IdentifierPtr const& d, StringLiteralPtr const& prefix) + { + if (ctx.trace ()) cerr << "typeprefix " << d << " " << prefix + << endl; + + Name name (d->lexeme ()); + SemanticGraph::StringLiteral tprefix (prefix->value ()); + + try + { + ScopedName from (ctx.scope ().scoped_name ()); + Nameables nodes (resolve (ctx.tu (), from, name)); + + Nameable& node (**(nodes.begin ())); + + dynamic_cast<SemanticGraph::Scope&> (node); + + ScopedName full (node.scoped_name ()); + + SemanticGraph::TypePrefix& tp ( + ctx.tu ().new_node<SemanticGraph::TypePrefix> (full, tprefix)); + + ctx.tu ().new_edge<Defines> (ctx.scope (), tp, "typeprefix"); + } + catch (NotFound const&) + { + cerr << "error: invalid typeprefix declaration" << endl; + cerr << "no declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + catch (std::bad_cast const&) + { + cerr << "error: invalid typeprefix declaration" << endl; + cerr << "no suitable declaration with name \'" + << name << "\' visible from scope \'" + << ctx.scope ().scoped_name () << "\'" << endl; + } + } + + void TypePrefix:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp new file mode 100644 index 00000000000..92902cf2413 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/TypeId.hpp @@ -0,0 +1,67 @@ +// file : CCF/IDL2/SemanticAction/Impl/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" +#include "CCF/IDL2/SemanticAction/TypeId.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class TypeId : public virtual SemanticAction::TypeId + { + public: + virtual + ~TypeId () throw (); + + TypeId (Context& c); + + virtual void + begin (IdentifierPtr const& d, StringLiteralPtr const& id); + + virtual void + end (); + + private: + Context& ctx; + }; + + + // + // + // + class TypePrefix : public virtual SemanticAction::TypePrefix + { + public: + virtual + ~TypePrefix () throw (); + + TypePrefix (Context& c); + + virtual void + begin (IdentifierPtr const& d, StringLiteralPtr const& prefix); + + virtual void + end (); + + private: + Context& ctx; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPE_ID_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp new file mode 100644 index 00000000000..8fd0fa3f254 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp @@ -0,0 +1,138 @@ +// file : CCF/IDL2/SemanticAction/Impl/Typedef.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/Typedef.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +//@@ names used in smantic actions are inconsistent +// e.g. begin () vs name (), etc +// + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Typedef:: + ~Typedef () throw () + { + } + + Typedef:: + Typedef (Context& c) + : Base (c) + { + } + + void Typedef:: + begin (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "typedef " << id << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<Type> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid typedef declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type in typedef is illegal" << endl; + } + } + + void Typedef:: + begin_seq (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "typedef sequence<" << id << ">" << endl; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name)); + + UnboundedSequence& s (ctx.tu ().new_node<UnboundedSequence> ()); + ctx.tu ().new_edge<Specialized> (s, t); + + type_ = &s; + } + catch (Resolve const&) + { + cerr << "error: invalid sequence declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type in sequence specialization is illegal" + << endl; + } + } + + void Typedef:: + declarator (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_ != 0) + { + SimpleName name (id->lexeme ()); + ctx.tu ().new_edge<Aliases> (ctx.scope (), *type_, name); + } + } + + void Typedef:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp new file mode 100644 index 00000000000..ea3816680dc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.hpp @@ -0,0 +1,49 @@ +// file : CCF/IDL2/SemanticAction/Impl/Typedef.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Typedef.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + class Typedef : public virtual SemanticAction::Typedef, + public Base + { + public: + virtual + ~Typedef () throw (); + + Typedef (Context& c); + + virtual void + begin (IdentifierPtr const& id); + + virtual void + begin_seq (IdentifierPtr const& id); + + virtual void + declarator (SimpleIdentifierPtr const& id); + + virtual void + end (); + + private: + SemanticGraph::Type* type_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_TYPEDEF_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..8e93021d0d1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Include.hpp @@ -0,0 +1,48 @@ +// 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; + }; + + class SystemInclude + { + public: + virtual + ~SystemInclude () 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..8dc28735151 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Interface.hpp @@ -0,0 +1,59 @@ +// 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_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_local_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_local_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_unconstrained_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_unconstrained_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt new file mode 100644 index 00000000000..c3491a34b5e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.alt @@ -0,0 +1,17 @@ +# 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/Recursion.pre.rules) + +target_makefile_list := Makefile.object +target_directory_list := Impl +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.object b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.object new file mode 100644 index 00000000000..c2dba69157c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Makefile.object @@ -0,0 +1,19 @@ +# file : CCF/IDL2/SemanticAction/Makefile.object +# 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/Member.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Member.hpp new file mode 100644 index 00000000000..44d98d9cc99 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Member.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL2/SemanticAction/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + class Member + { + public: + virtual + ~Member () throw () {} + + virtual void + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_MEMBER_HPP 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..ef6613a5748 --- /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..5b6190d1b4a --- /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..221a7f762b5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Operation.hpp @@ -0,0 +1,55 @@ +// 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 + type (IdentifierPtr const& id) = 0; + + virtual void + name (SimpleIdentifierPtr const& 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 + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp new file mode 100644 index 00000000000..74f4f37dc06 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Struct.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Struct.hpp +// author : Jeff Parsons <j.parsons@vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + class Struct : public virtual Scope + { + public: + virtual + ~Struct () throw () {} + + virtual void + begin_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + open_scope () = 0; + + virtual void + close_scope () = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_STRUCT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp new file mode 100644 index 00000000000..83836ef5fc8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/TypeId.hpp @@ -0,0 +1,51 @@ +// file : CCF/IDL2/SemanticAction/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class TypeId + { + public: + virtual + ~TypeId () throw () {} + + virtual void + begin (IdentifierPtr const& name, StringLiteralPtr const& id) = 0; + + virtual void + end () = 0; + }; + + // + // + // + class TypePrefix + { + public: + virtual + ~TypePrefix () throw () {} + + virtual void + begin (IdentifierPtr const& name, StringLiteralPtr const& prefix) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_TYPE_ID_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp new file mode 100644 index 00000000000..d4214f6d9ea --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Typedef.hpp @@ -0,0 +1,41 @@ +// file : CCF/IDL2/SemanticAction/Typedef.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP +#define CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + // + // + // + class Typedef + { + public: + virtual + ~Typedef () throw () {} + + virtual void + begin (IdentifierPtr const& id) = 0; + + virtual void + begin_seq (IdentifierPtr const& id) = 0; + + virtual void + declarator (SimpleIdentifierPtr const& id) = 0; + + virtual void + end () = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_TYPEDEF_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp new file mode 100644 index 00000000000..8ceb56b61f8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph.hpp @@ -0,0 +1,25 @@ +// file : CCF/IDL2/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL2/SemanticGraph/Literals.hpp" +#include "CCF/IDL2/SemanticGraph/Member.hpp" +#include "CCF/IDL2/SemanticGraph/Module.hpp" +#include "CCF/IDL2/SemanticGraph/Name.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" +#include "CCF/IDL2/SemanticGraph/Struct.hpp" +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp new file mode 100644 index 00000000000..83505aae29f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/SemanticGraph/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Attribute + // + // + namespace + { + TypeInfo + attribute_init_ () + { + TypeInfo ti (typeid (Attribute)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo attribute_ (attribute_init_ ()); + } + + TypeInfo const& Attribute:: + static_type_info () { return attribute_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp new file mode 100644 index 00000000000..c180683a4f9 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Attribute.hpp @@ -0,0 +1,127 @@ +// file : CCF/IDL2/SemanticGraph/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Attribute : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Attribute () + { + type_info (static_type_info ()); + } + }; + + + class ReadAttribute; + + class GetRaises : public virtual Edge + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + GetRaises () + { + type_info (static_type_info ()); + } + }; + + + class ReadAttribute : public virtual Attribute + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ReadAttribute () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class SetRaises : public virtual Edge + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + SetRaises () + { + type_info (static_type_info ()); + } + }; + + + class WriteAttribute : public virtual Attribute + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + WriteAttribute () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ReadWriteAttribute : public virtual ReadAttribute, + public virtual WriteAttribute + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ReadWriteAttribute () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ATTRIBUTE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..fbec2cd82a2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.cpp @@ -0,0 +1,445 @@ +// file : CCF/IDL2/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +//@@ move this stuff into namespace +using Introspection::TypeInfo; +using Introspection::Access; + +//@@ tmp +#include <iostream> +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Edge + // + // + Edge:: + ~Edge () + { + } + + Edge:: + Edge () + { + type_info (static_type_info ()); + } + + namespace + { + TypeInfo + edge_init_ () + { + TypeInfo ti (typeid (Edge)); + // I don't really need this information + // ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); + return ti; + } + + TypeInfo edge_ (edge_init_ ()); + } + + TypeInfo const& Edge:: + static_type_info () { return edge_; } + + + // Node + // + // + Node:: + ~Node () + { + } + + Node:: + Node () + { + type_info (static_type_info ()); + } + + namespace + { + TypeInfo + node_init_ () + { + TypeInfo ti (typeid (Node)); + // I don't really need this information + // ti.add_base (Access::PUBLIC, true, Object::static_type_info ()); + return ti; + } + + TypeInfo node_ (node_init_ ()); + } + + TypeInfo const& Node:: + static_type_info () { return node_; } + + + // Names + // + // + namespace + { + TypeInfo + names_init_ () + { + TypeInfo ti (typeid (Names)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo names_ (names_init_ ()); + } + + TypeInfo const& Names:: + static_type_info () { return names_; } + + + // Defines + // + // + namespace + { + TypeInfo + defines_init_ () + { + TypeInfo ti (typeid (Defines)); + ti.add_base ( + Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo defines_ (defines_init_ ()); + } + + TypeInfo const& Defines:: + static_type_info () { return defines_; } + + + // Mentions + // + // + namespace + { + TypeInfo + mentions_init_ () + { + TypeInfo ti (typeid (Mentions)); + ti.add_base (Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo mentions_ (mentions_init_ ()); + } + + TypeInfo const& Mentions:: + static_type_info () { return mentions_; } + + + // Aliases + // + // + namespace + { + TypeInfo + aliases_init_ () + { + TypeInfo ti (typeid (Aliases)); + ti.add_base ( + Access::PUBLIC, true, Names::static_type_info ()); + return ti; + } + + TypeInfo aliases_ (aliases_init_ ()); + } + + TypeInfo const& Aliases:: + static_type_info () { return aliases_; } + + + // Nameable + // + // + + SimpleName Nameable:: + name () const + { + // The first entry should either be Mentions or Defines + // and it is the 'primary' name of the nameable entity. + // + return named_[0]->name (); + } + + ScopedName Nameable:: + scoped_name () const + { + // In general, scope that named us is named, in turn, + // by somebody else. + // + return ScopedName (named_[0]->scope ().scoped_name (), name ()); + } + + namespace + { + TypeInfo + nameable_init_ () + { + TypeInfo ti (typeid (Nameable)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo nameable_ (nameable_init_ ()); + } + + TypeInfo const& Nameable:: + static_type_info () { return nameable_; } + + + // Scope + // + // + + Nameables Scope:: + lookup (Name const& name) + { + Nameables r; + lookup (name, r); + return r; + } + + void Scope:: + lookup (Name const& name, Nameables& result) + { + SimpleName first (*name.begin ()); + + NamesIteratorPair pair (find (first)); + + if (name.simple ()) // last name + { + for (NamesIterator n (pair.first); n != pair.second; ++n) + { + result.insert (&((**n).named ())); + } + } + else + { + Name rest (name.begin () + 1, name.end ()); + + for (NamesIterator n (pair.first); n != pair.second; ++n) + { + Nameable& node ((**n).named ()); + if (Scope* s = dynamic_cast<Scope*> (&node)) + { + s->lookup (rest, result); + } + } + } + } + + namespace + { + TypeInfo + scope_init_ () + { + TypeInfo ti (typeid (Scope)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo scope_ (scope_init_ ()); + } + + TypeInfo const& Scope:: + static_type_info () { return scope_; } + + + // Type + // + // + namespace + { + TypeInfo + type_init_ () + { + TypeInfo ti (typeid (Type)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_ (type_init_ ()); + } + + TypeInfo const& Type:: + static_type_info () { return type_; } + + + // Instance + // + // + namespace + { + TypeInfo + instance_init_ () + { + TypeInfo ti (typeid (Instance)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo instance_ (instance_init_ ()); + } + + TypeInfo const& Instance:: + static_type_info () { return instance_; } + + + // Belongs + // + // + namespace + { + TypeInfo + belongs_init_ () + { + TypeInfo ti (typeid (Belongs)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo belongs_ (belongs_init_ ()); + } + + TypeInfo const& Belongs:: + static_type_info () { return belongs_; } + + + // TypeTemplateSpecialization + // + // + namespace + { + TypeInfo + type_template_specialization_init_ () + { + TypeInfo ti (typeid (TypeTemplateSpecialization)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo type_template_specialization_ ( + type_template_specialization_init_ ()); + } + + TypeInfo const& TypeTemplateSpecialization:: + static_type_info () { return type_template_specialization_; } + + + // Specialized + // + // + namespace + { + TypeInfo + specialized_init_ () + { + TypeInfo ti (typeid (Specialized)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo specialized_ (specialized_init_ ()); + } + + TypeInfo const& Specialized:: + static_type_info () { return specialized_; } + + + // IsA + // + // + namespace + { + TypeInfo + is_a_init_ () + { + TypeInfo ti (typeid (IsA)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo is_a_ (is_a_init_ ()); + } + + TypeInfo const& IsA:: + static_type_info () { return is_a_; } + + + // Inherits + // + // + namespace + { + TypeInfo + inherits_init_ () + { + TypeInfo ti (typeid (Inherits)); + ti.add_base (Access::PUBLIC, true, IsA::static_type_info ()); + return ti; + } + + TypeInfo inherits_ (inherits_init_ ()); + } + + TypeInfo const& Inherits:: + static_type_info () { return inherits_; } + + // Contains + // + // + namespace + { + TypeInfo + contains_init_ () + { + TypeInfo ti (typeid (Contains)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo contains_ (contains_init_ ()); + } + + TypeInfo const& Contains:: + static_type_info () { return contains_; } + + + // Container + // + // + namespace + { + TypeInfo + container_init_ () + { + TypeInfo ti (typeid (Container)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo container_ (container_init_ ()); + } + + TypeInfo const& Container:: + static_type_info () { return container_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..7c24343fd44 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.hpp @@ -0,0 +1,758 @@ +// file : CCF/IDL2/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include <set> +#include <vector> + +#include "Graph.hpp" + +#include "CCF/CompilerElements/Introspection.hpp" +#include "CCF/CompilerElements/Context.hpp" + +#include "CCF/IDL2/SemanticGraph/Name.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + using Element::Graph; + + class Node; + class Edge; + + + // Node & Edge + // + // + class Edge : public virtual Introspection::Object + { + public: + CompilerElements::Context const& + context () const + { + return context_; + } + + CompilerElements::Context& + context () + { + return context_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + virtual + ~Edge (); + + Edge (); + + private: + CompilerElements::Context context_; + }; + + inline bool + operator== (Edge const& x, Edge const& y) + { + return &x == &y; + } + + class Node : public virtual Introspection::Object + { + public: + CompilerElements::Context const& + context () const + { + return context_; + } + + CompilerElements::Context& + context () + { + return context_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + virtual + ~Node (); + + Node (); + + private: + CompilerElements::Context context_; + }; + + inline bool + operator== (Node const& x, Node const& y) + { + return &x == &y; + } + + + // + // + // + class Scope; + class Nameable; + + class Names : public virtual Edge + { + public: + SimpleName + name () const + { + return name_; + } + + Scope& + scope () const + { + return *scope_; + } + + Nameable& + named () const + { + return *named_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Names (SimpleName const& name) + : name_ (name) + { + type_info (static_type_info ()); + } + + void + set_left_node (Scope& n) + { + scope_ = &n; + } + + void + set_right_node (Nameable& n) + { + named_ = &n; + } + + private: + Scope* scope_; + Nameable* named_; + SimpleName name_; + }; + + class Defines : public virtual Names + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Defines (SimpleName const& name) + : Names (name) + { + type_info (static_type_info ()); + } + }; + + + class Mentions : public virtual Names + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Mentions (SimpleName const& name) + : Names (name) + { + type_info (static_type_info ()); + } + }; + + + class Aliases : public virtual Names + { + public: + SimpleName + synonym () const + { + return name (); + } + + ScopedName + eponym () const + { + return ScopedName ("@@"); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Aliases (SimpleName const& synonym) + : Names (synonym) + + { + type_info (static_type_info ()); + } + }; + + + class Nameable : public virtual Node + { + public: + virtual SimpleName + name () const; + + virtual ScopedName + scoped_name () const; + + bool + defined () const + { + return defined_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Nameable () + : defined_ (false) + { + type_info (static_type_info ()); + } + + void + add_edge_right (Defines& e) + { + defined_ = true; + named_.push_back (&e); + } + + void + add_edge_right (Names& e) + { + named_.push_back (&e); + } + + private: + typedef + std::vector<Names*> + Named_; + + Named_ named_; + + bool defined_; + }; + + typedef + std::set<Nameable*> + Nameables; + + class Scope : public virtual Nameable + { + private: + typedef + std::vector<Names*> + Names_; + + typedef + std::map<SimpleName, Names_> + NamesMap_; + + public: + typedef + Names_::const_iterator + NamesIterator; + + typedef + std::pair <NamesIterator, NamesIterator> + NamesIteratorPair; + + NamesIterator + names_begin () const + { + return names_.begin (); + } + + NamesIterator + names_end () const + { + return names_.end (); + } + + NamesIteratorPair + find (SimpleName const& name) const + { + NamesMap_::const_iterator i (names_map_.find (name)); + if (i == names_map_.end ()) + { + return NamesIteratorPair (names_.end (), names_.end ()); + } + else + { + return NamesIteratorPair (i->second.begin (), i->second.end ()); + } + } + + Nameables + lookup (Name const& name); + + void + lookup (Name const& name, Nameables& result); + + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Scope () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Names& e) + { + names_.push_back (&e); + names_map_[e.name ()].push_back (&e); + } + + private: + Names_ names_; + NamesMap_ names_map_; + }; + + + + // + // + // + class Belongs; + class Specialized; + + //@@ I can make an alias Classifies for Belongs? + // + + class Type : public virtual Nameable + { + public: + virtual bool + complete () const = 0; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Type () + { + type_info (static_type_info ()); + } + + using Nameable::add_edge_right; + + void + add_edge_right (Belongs& e) + { + slassifies_.push_back (&e); + } + + void + add_edge_right (Specialized& e) + { + } + + //@@ this is a bunch of experimantal sink functions + // that allow extensions (see Executor stuff in CIDL + // for example). This code should eventually migrate + // to Node if it is found really useful. + // + + void + add_edge_left (Edge& e) + { + } + + void + add_edge_right (Edge& e) + { + } + + private: + typedef + std::vector<Belongs*> + Classifies_; + + Classifies_ slassifies_; + }; + + + class Instance : public virtual Node + { + public: + Belongs& + belongs () + { + return *belongs_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Instance () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Belongs& e) + { + belongs_ = &e; + } + + private: + Belongs* belongs_; + }; + + + class Belongs : public virtual Edge + { + public: + Instance& + instance () + { + return *instance_; + } + + Type& + type () + { + return *type_; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Belongs () + { + type_info (static_type_info ()); + } + + void + set_left_node (Instance& n) + { + instance_ = &n; + } + + void + set_right_node (Type& n) + { + type_ = &n; + } + + private: + Instance* instance_; + Type* type_; + }; + + + //@@ Maybe rename it to just Specialization + // + class TypeTemplateSpecialization : public virtual Type + { + public: + Specialized& + specialized () const + { + return *specialized_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TypeTemplateSpecialization () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Specialized& e) + { + specialized_ = &e; + } + + private: + Specialized* specialized_; + }; + + + + class Specialized : public virtual Edge + { + public: + TypeTemplateSpecialization& + specialization () + { + return *specialization_; + } + + //@@ add const everywhere. + // + Type& + type () const + { + return *type_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Specialized () + { + type_info (static_type_info ()); + } + + void + set_left_node (TypeTemplateSpecialization& n) + { + specialization_ = &n; + } + + void + set_right_node (Type& n) + { + type_ = &n; + } + + private: + TypeTemplateSpecialization* specialization_; + Type* type_; + }; + + + // + // + // + class IsA : public virtual Edge + { + public: + virtual Type& + subject () + { + return *subject_; + } + + virtual Type& + object () + { + return *object_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + IsA () + { + type_info (static_type_info ()); + } + + void + set_left_node (Type& n) + { + subject_ = &n; + } + + void + set_right_node (Type& n) + { + object_ = &n; + } + + private: + Type* subject_; + Type* object_; + }; + + + // + // + // + class Inherits : public virtual IsA + { + public: + virtual Type& + inheritor () + { + return subject (); + } + + virtual Type& + inheritee () + { + return object (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Inherits () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + + class Container; + + class Contains : public virtual Edge + { + public: + Node& + element () + { + return *element_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Contains () + { + type_info (static_type_info ()); + } + + void + set_left_node (Container& n) + { + container_ = &n; + } + + void + set_right_node (Node& n) + { + element_ = &n; + } + + private: + Container* container_; + Node* element_; + }; + + + class Container : public virtual Node + { + typedef + std::vector<Contains*> + Contains_; + + public: + typedef + Contains_::const_iterator + ContainsIterator; + + ContainsIterator + contains_begin () const + { + return contains_.begin (); + } + + ContainsIterator + contains_end () const + { + return contains_.end (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Container () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Contains& e) + { + contains_.push_back (&e); + } + + private: + Contains_ contains_; + }; + } + } +} + +#include "CCF/IDL2/SemanticGraph/Elements.tpp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp new file mode 100644 index 00000000000..a3a1615fe85 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Elements.tpp @@ -0,0 +1,14 @@ +// file : CCF/IDL2/SemanticGraph/Elements.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp new file mode 100644 index 00000000000..4fb88b06d5d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/SemanticGraph/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Exception + // + // + namespace + { + TypeInfo + exception_init_ () + { + TypeInfo ti (typeid (Exception)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo exception_ (exception_init_ ()); + } + + TypeInfo const& Exception:: + static_type_info () { return exception_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp new file mode 100644 index 00000000000..4c1cd5f7a6e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Exception.hpp @@ -0,0 +1,50 @@ +// file : CCF/IDL2/SemanticGraph/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Raises; + + class Exception : public virtual Type, public virtual Scope + { + public: + virtual bool + complete () const + { + return defined (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Exception () + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_right (Raises& e) + { + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_EXCEPTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp new file mode 100644 index 00000000000..82ac36ab182 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp @@ -0,0 +1,438 @@ +// file : CCF/IDL2/SemanticGraph/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + + // FundamentalType + // + // + namespace + { + TypeInfo + fundamental_type_init_ () + { + TypeInfo ti (typeid (FundamentalType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo fundamental_type_ (fundamental_type_init_ ()); + } + + TypeInfo const& FundamentalType:: + static_type_info () { return fundamental_type_; } + + + // Object + // + // + namespace + { + TypeInfo + object_init_ () + { + TypeInfo ti (typeid (Object)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo object_ (object_init_ ()); + } + + TypeInfo const& Object:: + static_type_info () { return object_; } + + + // ValueBase + // + // + namespace + { + TypeInfo + value_base_init_ () + { + TypeInfo ti (typeid (ValueBase)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo value_base_ (value_base_init_ ()); + } + + TypeInfo const& ValueBase:: + static_type_info () { return value_base_; } + + + // Any + // + // + namespace + { + TypeInfo + any_init_ () + { + TypeInfo ti (typeid (Any)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo any_ (any_init_ ()); + } + + TypeInfo const& Any:: + static_type_info () { return any_; } + + + // Boolean + // + // + namespace + { + TypeInfo + boolean_init_ () + { + TypeInfo ti (typeid (Boolean)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo boolean_ (boolean_init_ ()); + } + + TypeInfo const& Boolean:: + static_type_info () { return boolean_; } + + + // Char + // + // + namespace + { + TypeInfo + char_init_ () + { + TypeInfo ti (typeid (Char)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo char_ (char_init_ ()); + } + + TypeInfo const& Char:: + static_type_info () { return char_; } + + + // Double + // + // + namespace + { + TypeInfo + double_init_ () + { + TypeInfo ti (typeid (Double)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo double_ (double_init_ ()); + } + + TypeInfo const& Double:: + static_type_info () { return double_; } + + + // Float + // + // + namespace + { + TypeInfo + float_init_ () + { + TypeInfo ti (typeid (Float)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo float_ (float_init_ ()); + } + + TypeInfo const& Float:: + static_type_info () { return float_; } + + + // Long + // + // + namespace + { + TypeInfo + long_init_ () + { + TypeInfo ti (typeid (Long)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_ (long_init_ ()); + } + + TypeInfo const& Long:: + static_type_info () { return long_; } + + + // LongDouble + // + // + namespace + { + TypeInfo + long_double_init_ () + { + TypeInfo ti (typeid (LongDouble)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_double_ (long_double_init_ ()); + } + + TypeInfo const& LongDouble:: + static_type_info () { return long_double_; } + + + // LongLong + // + // + namespace + { + TypeInfo + long_long_init_ () + { + TypeInfo ti (typeid (LongLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo long_long_ (long_long_init_ ()); + } + + TypeInfo const& LongLong:: + static_type_info () { return long_long_; } + + + // Octet + // + // + namespace + { + TypeInfo + octet_init_ () + { + TypeInfo ti (typeid (Octet)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo octet_ (octet_init_ ()); + } + + TypeInfo const& Octet:: + static_type_info () { return octet_; } + + + // Short + // + // + namespace + { + TypeInfo + short_init_ () + { + TypeInfo ti (typeid (Short)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo short_ (short_init_ ()); + } + + TypeInfo const& Short:: + static_type_info () { return short_; } + + + // String + // + // + namespace + { + TypeInfo + string_init_ () + { + TypeInfo ti (typeid (String)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo string_ (string_init_ ()); + } + + TypeInfo const& String:: + static_type_info () { return string_; } + + + // UnsignedLong + // + // + namespace + { + TypeInfo + unsigned_long_init_ () + { + TypeInfo ti (typeid (UnsignedLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_long_ (unsigned_long_init_ ()); + } + + TypeInfo const& UnsignedLong:: + static_type_info () { return unsigned_long_; } + + + // UnsignedLongLong + // + // + namespace + { + TypeInfo + unsigned_long_long_init_ () + { + TypeInfo ti (typeid (UnsignedLongLong)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_long_long_ (unsigned_long_long_init_ ()); + } + + TypeInfo const& UnsignedLongLong:: + static_type_info () { return unsigned_long_long_; } + + + // UnsignedShort + // + // + namespace + { + TypeInfo + unsigned_short_init_ () + { + TypeInfo ti (typeid (UnsignedShort)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo unsigned_short_ (unsigned_short_init_ ()); + } + + TypeInfo const& UnsignedShort:: + static_type_info () { return unsigned_short_; } + + + // Void + // + // + namespace + { + TypeInfo + void_init_ () + { + TypeInfo ti (typeid (Void)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo void_ (void_init_ ()); + } + + TypeInfo const& Void:: + static_type_info () { return void_; } + + + // Wchar + // + // + namespace + { + TypeInfo + wchar_init_ () + { + TypeInfo ti (typeid (Wchar)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo wchar_ (wchar_init_ ()); + } + + TypeInfo const& Wchar:: + static_type_info () { return wchar_; } + + + // Wstring + // + // + namespace + { + TypeInfo + wstring_init_ () + { + TypeInfo ti (typeid (Wstring)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo wstring_ (wstring_init_ ()); + } + + TypeInfo const& Wstring:: + static_type_info () { return wstring_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 new file mode 100644 index 00000000000..1289bcd0387 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 @@ -0,0 +1,98 @@ +divert(-1) + +# file : CCF/IDL2/SemanticGraph/Fundamental.cpp.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +include(`Fundamental.m4') + +define(`fundamental_type', + `fundamental_type_impl(`make_class_name(`$1')', `make_var_name(`$1')')') + + +define(`fundamental_type_impl', ` + + // $1 + // + // + namespace + { + TypeInfo + $2_init_ () + { + TypeInfo ti (typeid ($1)); + ti.add_base ( + Access::PUBLIC, true, FundamentalType::static_type_info ()); + return ti; + } + + TypeInfo $2_ ($2_init_ ()); + } + + TypeInfo const& $1:: + static_type_info () { return $2_; }') + +divert(0)dnl +dnl +dnl +dnl +// file : CCF/IDL2/SemanticGraph/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +using namespace Introspection; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + + // FundamentalType + // + // + namespace + { + TypeInfo + fundamental_type_init_ () + { + TypeInfo ti (typeid (FundamentalType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + return ti; + } + + TypeInfo fundamental_type_ (fundamental_type_init_ ()); + } + + TypeInfo const& FundamentalType:: + static_type_info () { return fundamental_type_; } +dnl +fundamental_type(`object') +fundamental_type(`value base') +fundamental_type(`any') +fundamental_type(`boolean') +fundamental_type(`char') +fundamental_type(`double') +fundamental_type(`float') +fundamental_type(`long') +fundamental_type(`long double') +fundamental_type(`long long') +fundamental_type(`octet') +fundamental_type(`short') +fundamental_type(`string') +fundamental_type(`unsigned long') +fundamental_type(`unsigned long long') +fundamental_type(`unsigned short') +fundamental_type(`void') +fundamental_type(`wchar') +fundamental_type(`wstring') +dnl + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp new file mode 100644 index 00000000000..774b7c18910 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp @@ -0,0 +1,405 @@ +// file : CCF/IDL2/SemanticGraph/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // @@ Object & ValueBase should be of interface & valuetype types? + // + // + class FundamentalType : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + FundamentalType () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Object : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Object () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ValueBase : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueBase () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Any : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Any () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Boolean : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Boolean () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Char : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Char () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Double : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Double () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Float : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Float () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Long : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Long () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LongDouble : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LongDouble () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LongLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LongLong () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Octet : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Octet () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Short : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Short () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class String : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + String () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedLong () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedLongLong : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedLongLong () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnsignedShort : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnsignedShort () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Void : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Void () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Wchar : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Wchar () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Wstring : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Wstring () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 new file mode 100644 index 00000000000..b0b3734a349 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 @@ -0,0 +1,98 @@ +divert(-1) + +# file : CCF/IDL2/SemanticGraph/Fundamental.hpp.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +include(`Fundamental.m4') + +define(`fundamental_type', `fundamental_type_impl(`make_class_name(`$1')', `$1')') + +define(`fundamental_type_impl', ` + + // + // + // + class $1 : public virtual FundamentalType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + $1 () + { + type_info (static_type_info ()); + } + };') +divert(0)dnl +dnl +dnl +dnl +// file : CCF/IDL2/SemanticGraph/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Note, that this file is automatically generated! +// + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // @@ Object & ValueBase should be of interface & valuetype types? + // + // + class FundamentalType : public virtual Type + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + FundamentalType () + { + type_info (static_type_info ()); + } + }; +dnl +fundamental_type(`Object') +fundamental_type(`ValueBase') +fundamental_type(`any') +fundamental_type(`boolean') +fundamental_type(`char') +fundamental_type(`double') +fundamental_type(`float') +fundamental_type(`long') +fundamental_type(`long double') +fundamental_type(`long long') +fundamental_type(`octet') +fundamental_type(`short') +fundamental_type(`string') +fundamental_type(`unsigned long') +fundamental_type(`unsigned long long') +fundamental_type(`unsigned short') +fundamental_type(`void') +fundamental_type(`wchar') +fundamental_type(`wstring') +dnl + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_FUNDAMENTAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 new file mode 100644 index 00000000000..5aaab71bd76 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Fundamental.m4 @@ -0,0 +1,17 @@ +# file : CCF/IDL2/SemanticGraph/Fundamental.m4 +# author : Boris Kolpackov <boris@dre.vanderbilt.edu> +# cvs-id : $Id$ + +define(`upcase', `translit(`$*', `a-z', `A-Z')') + + +define(`capitalize_word', + `regexp(`$1', `^\(.\)\(.*\)', `upcase(`\1')`\2'')') + + +define(`capitalize', + `patsubst(`$1', `\w+', `capitalize_word(`\&')')') + +define(`make_class_name', `patsubst(capitalize(`$1'), ` ')') + +define(`make_var_name', `patsubst(`$1', ` ', `_')') diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp new file mode 100644 index 00000000000..0b23a9f3cb5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.hpp @@ -0,0 +1,73 @@ +// file : CCF/IDL2/SemanticGraph/Graph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef ELEMENT_GRAPH_HPP +#define ELEMENT_GRAPH_HPP + +#include <map> +#include <set> +#include <vector> +#include <string> +#include <memory> + +#include <iostream> + +namespace Element +{ + template <typename N, typename E> + class Graph + { + public: + ~Graph (); + + public: + template <typename T> + T& + new_node (); + + template <typename T, typename A0> + T& + new_node (A0 const& a0); + + template <typename T, typename A0, typename A1> + T& + new_node (A0 const& a0, A1 const& a1); + + void + delete_node (N const& n); + + public: + template <typename T, typename X, typename Y> + T& + new_edge (X& left, Y& right); + + template <typename T, typename X, typename Y, + typename A0> + T& + new_edge (X& left, Y& right, A0 const& a0); + + template <typename T, typename X, typename Y, + typename A0, + typename A1> + T& + new_edge (X& left, Y& right, A0 const& a0, A1 const& a1); + + void + delete_edge (E const& e); + + protected: + typedef N* NodePtr; + typedef E* EdgePtr; + + typedef std::set<NodePtr> Nodes_; + typedef std::set<EdgePtr> Edges_; + + Nodes_ nodes_; + Edges_ edges_; + }; +} + +#include "Graph.tpp" + +#endif // ELEMENT_GRAPH_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp new file mode 100644 index 00000000000..a52394b1604 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Graph.tpp @@ -0,0 +1,158 @@ +// file : CCF/IDL2/SemanticGraph/Graph.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace Element +{ + // Graph + // + // + + + template <typename N, typename E> + template <typename T> + T& Graph<N, E>:: + new_node () + { + T* n (new T); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + template <typename T, typename A0> + T& Graph<N, E>:: + new_node (A0 const& a0) + { + T* n (new T (a0)); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + template <typename T, typename A0, typename A1> + T& Graph<N, E>:: + new_node (A0 const& a0, A1 const& a1) + { + T* n (new T (a0, a1)); //@@ auto + nodes_.insert (n); + return *n; + } + + + template <typename N, typename E> + void Graph<N, E>:: + delete_node (N const& nr) + { + N* n (&nr); + + for (E* e (n->remove_edge_ ()); e != 0; e = n->remove_edge_ ()) + { + // One endpoint of the edge has removed this edge from + // its edge set. Now handle the other endpoint. + // + if (e->left_ () == n) e->right_ ()->remove_edge_ (e); + else e->left_ ()->remove_edge_ (e); + + // Delete the edge. + // + edges_.erase (e); + + delete e; //@@ auto + } + + nodes_.erase (n); + + delete n; //@@ auto + } + + + template <typename N, typename E> + template <typename T, typename X, typename Y> + T& Graph<N, E>:: + new_edge (X& left, Y& right) + { + T* e (new T); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + template <typename T, typename X, typename Y, + typename A0> + T& Graph<N, E>:: + new_edge (X& left, Y& right, A0 const& a0) + { + T* e (new T (a0)); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + template <typename T, typename X, typename Y, + typename A0, + typename A1> + T& Graph<N, E>:: + new_edge (X& left, Y& right, A0 const& a0, A1 const& a1) + { + T* e (new T (a0, a1)); //@@ auto + + e->set_left_node (left); + e->set_right_node (right); + + left.add_edge_left (*e); + right.add_edge_right (*e); + + edges_.insert (e); + + return *e; + } + + template <typename N, typename E> + void Graph<N, E>:: + delete_edge (E const& er) + { + E* e (&er); + + e->left_ ()->remove_edge_ (e); + e->right_ ()->remove_edge_ (e); + + edges_.erase (e); + + delete e; //@@ auto + } + + + template <typename N, typename E> + Graph<N, E>:: + ~Graph () + { + //@@ auto + + for (typename Edges_::iterator i (edges_.begin ()), end (edges_.end ()); + i != end; + ++i) delete *i; + + for (typename Nodes_::iterator i (nodes_.begin ()), end (nodes_.end ()); + i != end; + ++i) delete *i; + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp new file mode 100644 index 00000000000..034879f78f3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.cpp @@ -0,0 +1,117 @@ +// file : CCF/IDL2/SemanticGraph/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Interface + // + // + namespace + { + TypeInfo + interface_init_ () + { + TypeInfo ti (typeid (Interface)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo interface_ (interface_init_ ()); + } + + TypeInfo const& Interface:: + static_type_info () { return interface_; } + + + // Supports + // + // + namespace + { + TypeInfo + supports_init_ () + { + TypeInfo ti (typeid (Supports)); + ti.add_base (Access::PUBLIC, true, IsA::static_type_info ()); + return ti; + } + + TypeInfo supports_ (supports_init_ ()); + } + + TypeInfo const& Supports:: + static_type_info () { return supports_; } + + + // AbstractInterface + // + // + namespace + { + TypeInfo + abstract_interface_init_ () + { + TypeInfo ti (typeid (AbstractInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo abstract_interface_ (abstract_interface_init_ ()); + } + + TypeInfo const& AbstractInterface:: + static_type_info () { return abstract_interface_; } + + + // LocalInterface + // + // + namespace + { + TypeInfo + local_interface_init_ () + { + TypeInfo ti (typeid (LocalInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo local_interface_ (local_interface_init_ ()); + } + + TypeInfo const& LocalInterface:: + static_type_info () { return local_interface_; } + + + // UnconstrainedInterface + // + // + namespace + { + TypeInfo + unconstrained_interface_init_ () + { + TypeInfo ti (typeid (UnconstrainedInterface)); + ti.add_base (Access::PUBLIC, true, Interface::static_type_info ()); + return ti; + } + + TypeInfo unconstrained_interface_ (unconstrained_interface_init_ ()); + } + + TypeInfo const& UnconstrainedInterface:: + static_type_info () { return unconstrained_interface_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp new file mode 100644 index 00000000000..e720473a788 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Interface.hpp @@ -0,0 +1,176 @@ +// file : CCF/IDL2/SemanticGraph/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Interface : public virtual Type, public virtual Scope + { + //@@ Should I create Inheritable type? + // + typedef + std::vector <Inherits*> + Inherits_; + + public: + typedef + Inherits_::const_iterator + InheritsIterator; + + InheritsIterator + inherits_begin () const + { + return inherits_.begin (); + } + + InheritsIterator + inherits_end () const + { + return inherits_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Interface () + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_.push_back (&e); + } + + void + add_edge_right (Inherits& e) + { + } + + private: + Inherits_ inherits_; + }; + + + // + // + // + class Supports : public virtual IsA + { + public: + virtual Type& + supporter () + { + return subject (); + } + + virtual Type& + supportee () + { + return object (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Supports () + { + type_info (static_type_info ()); + } + + void + set_right_node (Interface& n) + { + IsA::set_right_node (n); + } + }; + + + // + // + // + class AbstractInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractInterface () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class LocalInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + LocalInterface () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class UnconstrainedInterface : public virtual Interface + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnconstrainedInterface () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp new file mode 100644 index 00000000000..7d7e5e3137b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.cpp @@ -0,0 +1,25 @@ +// file : CCF/IDL2/SemanticGraph/Literals.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Literals.hpp" + +#include <ostream> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // StringLiteral + // + // + std::ostream& + operator<< (std::ostream& o, StringLiteral const& lit) + { + return o << '\"' << lit.literal () << '\"'; + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp new file mode 100644 index 00000000000..2276339b9c3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Literals.hpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticGraph/Literals.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP + +#include <string> +#include <iosfwd> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class StringLiteral + { + public: + StringLiteral (std::string const& literal) + : literal_ (literal) + { + } + + std::string + literal () const + { + return literal_; + } + + private: + std::string literal_; + }; + + inline bool + operator== (StringLiteral const& a, StringLiteral const& b) + { + return a.literal () == b.literal (); + } + + inline bool + operator!= (StringLiteral const& a, StringLiteral const& b) + { + return a.literal () != b.literal (); + } + + std::ostream& + operator<< (std::ostream& o, StringLiteral const& lit); + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_LITERALS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Makefile.alt new file mode 100644 index 00000000000..db82f7169c0 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Makefile.alt @@ -0,0 +1,32 @@ +# file : CCF/IDL2/SemanticGraph/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 := Attribute.cpp \ + Elements.cpp \ + Exception.cpp \ + Fundamental.cpp \ + Interface.cpp \ + Literals.cpp \ + Member.cpp \ + Module.cpp \ + Name.cpp \ + Operation.cpp \ + Sequence.cpp \ + Struct.cpp \ + Translation.cpp \ + TypeId.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/SemanticGraph/Member.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.cpp new file mode 100644 index 00000000000..01031322b2a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/SemanticGraph/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Member + // + // + namespace + { + TypeInfo + member_init_ () + { + TypeInfo ti (typeid (Member)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo member_ (member_init_ ()); + } + + TypeInfo const& Member:: + static_type_info () { return member_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp new file mode 100644 index 00000000000..434d2e54bdf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Member.hpp @@ -0,0 +1,35 @@ +// file : CCF/IDL2/SemanticGraph/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Member : public virtual Nameable, + public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Member () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_MEMBER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp new file mode 100644 index 00000000000..8e8bc25f5cc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.cpp @@ -0,0 +1,36 @@ +// file : CCF/IDL2/SemanticGraph/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Module.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // 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/SemanticGraph/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.hpp new file mode 100644 index 00000000000..0a3a6831e29 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Module.hpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/SemanticGraph/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Module : public virtual Scope + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Module () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp new file mode 100644 index 00000000000..38db7e94a3b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.cpp @@ -0,0 +1,214 @@ +// file : CCF/IDL2/SemanticGraph/Name.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Name.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + + // SimpleName + // + // + + SimpleName:: + SimpleName (char const* name) throw (InvalidName) + : name_ (name) + { + if (name_.find (':') != std::string::npos) throw InvalidName (); + } + + SimpleName:: + SimpleName (std::string const& name) throw (InvalidName) + : name_ (name) + { + if (name_.find (':') != std::string::npos) throw InvalidName (); + } + + SimpleName + operator+ (SimpleName const& name, std::string const& str) + { + return SimpleName (name.str () + str); + } + + SimpleName + operator+ (std::string const& str, SimpleName const& name) + { + return SimpleName (str + name.str ()); + } + + std::ostream& + operator << (std::ostream& o, SimpleName const& name) + { + return o << name.str (); + } + + // Name + // + // + Name:: + Name (SimpleName const& name) + : name_cache_ (name.str ()) + { + name_.push_back (name); + } + + Name:: + Name (char const* name) throw (InvalidName) + : name_cache_ (name) + { + init (); + } + + Name:: + Name (std::string const& name) throw (InvalidName) + : name_cache_ (name) + { + init (); + } + + void Name:: + init () throw (InvalidName) + { + // cerr << "parsing name \'" << name_cache_ << "\' {"<< endl; + + for (std::string::size_type + pos (0), next (name_cache_.find ("::", pos));; + next = name_cache_.find ("::", pos)) + { + std::string simple_name ( + name_cache_, + pos, + next == std::string::npos ? next : next - pos); + + // cerr << "\t\'" << simple_name << '\'' << endl; + + if (simple_name.empty () && !name_.empty ()) + { + // Empty name (file-scope) is only valid when + // it is first. + // + throw InvalidName (); + } + + name_.push_back (SimpleName (simple_name)); + + if (next == std::string::npos) break; + + pos = next + 2; + } + + // cerr << "parsing name }" << name_cache_ << endl; + + if (name_.empty ()) throw InvalidName (); + } + + + Name:: + Name (Iterator begin, Iterator end) throw (InvalidName) + { + for (Iterator i (begin); i != end; ++i) + { + name_cache_ += (i != begin ? "::" : "") + i->str (); + name_.push_back (*i); + } + + if (name_.empty ()) throw InvalidName (); + } + + bool Name:: + scoped () const + { + return name_[0] == SimpleName (""); + } + + bool Name:: + simple () const + { + return name_.size () == 1; + } + + std::ostream& + operator << (std::ostream& o, Name const& name) + { + return o << name.str (); + } + + // ScopedName + // + // + + ScopedName:: + ScopedName (char const* name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (std::string const& name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (Iterator begin, Iterator end) throw (InvalidName) + : Name (begin, end) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (Name const& name) throw (InvalidName) + : Name (name) + { + if (!scoped ()) throw InvalidName (); + } + + ScopedName:: + ScopedName (ScopedName const& scope, Name const& name) + throw (InvalidName) + : Name (scope.str () + "::" + name.str ()) + { + if (!scoped ()) throw InvalidName (); + } + + SimpleName ScopedName:: + simple_name () const + { + return *(end () - 1); + } + + ScopedName ScopedName:: + scope_name () const throw (FileScope) + { + Iterator end (end () - 1); + + if (begin () == end) throw FileScope (); + + return ScopedName (begin (), end); + } + + /* + Name ScopedName:: + in_file_scope () const throw (FileScope) + { + if (name_.empty ()) throw FileScope (); + + return Name(std::string (name_.begin () + 2, name_.end ())); + } + + */ + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp new file mode 100644 index 00000000000..c262f426fac --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Name.hpp @@ -0,0 +1,186 @@ +// file : CCF/IDL2/SemanticGraph/Name.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP + +#include <vector> +#include <string> +#include <iosfwd> + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + //@@ better names for names: SimpleName, ScopedName, FullName + // + // + + class InvalidName {}; + + class SimpleName + { + public: + SimpleName (char const* name) throw (InvalidName); + SimpleName (std::string const& name) throw (InvalidName); + + public: + bool + operator< (SimpleName const& other) const + { + return name_ < other.name_; + } + + bool + operator== (SimpleName const& other) const + { + return name_ == other.name_; + } + + bool + operator!= (SimpleName const& other) const + { + return name_ != other.name_; + } + + public: + std::string + str () const + { + return name_; + } + + private: + std::string name_; + }; + + SimpleName + operator+ (SimpleName const& name, std::string const& str); + + SimpleName + operator+ (std::string const& str, SimpleName const& name); + + std::ostream& + operator << (std::ostream& o, SimpleName const& name); + + // + // + // + class Name + { + typedef + std::vector<SimpleName> + Name_; + + public: + Name (SimpleName const& name); + + Name (char const* name) throw (InvalidName); + Name (std::string const& name) throw (InvalidName); + + typedef + Name_::const_iterator + Iterator; + + Name (Iterator begin, Iterator end) throw (InvalidName); + + public: + bool + operator< (Name const& other) const + { + return name_cache_ < other.name_cache_; + } + + bool + operator== (Name const& other) const + { + return name_cache_ == other.name_cache_; + } + + bool + operator!= (Name const& other) const + { + return name_cache_ != other.name_cache_; + } + + public: + Iterator + begin () const + { + return name_.begin (); + } + + Iterator + end () const + { + return name_.end (); + } + + public: + bool + scoped () const; + + bool + simple () const; + + public: + std::string + str () const + { + return name_cache_; + } + + private: + void + init () throw (InvalidName); + + private: + Name_ name_; + std::string name_cache_; + }; + + std::ostream& + operator << (std::ostream& o, Name const& name); + + + // Should always start with "::". Can be just "::" which + // means it's a file-scope. + // + // + class ScopedName : public Name + { + public: + ScopedName (char const* name) throw (InvalidName); + + ScopedName (std::string const& name) throw (InvalidName); + + ScopedName (Iterator begin, Iterator end) throw (InvalidName); + + explicit + ScopedName (Name const& name) throw (InvalidName); + + ScopedName (ScopedName const& scope, Name const& name) + throw (InvalidName); + + public: + SimpleName + simple_name () const; + + class FileScope {}; + + ScopedName + scope_name () const throw (FileScope); + + /* + Name + in_file_scope () const throw (FileScope); + */ + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_NAME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp new file mode 100644 index 00000000000..4be7d134b4e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.cpp @@ -0,0 +1,193 @@ +// file : CCF/IDL2/SemanticGraph/Operation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Receives + // + // + namespace + { + TypeInfo + receives_init_ () + { + TypeInfo ti (typeid (Receives)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo receives_ (receives_init_ ()); + } + + TypeInfo const& Receives:: + static_type_info () { return receives_; } + + + // Returns + // + // + namespace + { + TypeInfo + returns_init_ () + { + TypeInfo ti (typeid (Returns)); + ti.add_base (Access::PUBLIC, true, Belongs::static_type_info ()); + return ti; + } + + TypeInfo returns_ (returns_init_ ()); + } + + TypeInfo const& Returns:: + static_type_info () { return returns_; } + + + // Raises + // + // + namespace + { + TypeInfo + raises_init_ () + { + TypeInfo ti (typeid (Raises)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo raises_ (raises_init_ ()); + } + + TypeInfo const& Raises:: + static_type_info () { return raises_; } + + + + // Parameter + // + // + Parameter::Direction const + Parameter::Direction::in (Parameter::Direction::in_), + Parameter::Direction::out (Parameter::Direction::out_), + Parameter::Direction::inout (Parameter::Direction::inout_); + + namespace + { + char const* direction_labels_[] = {"in", "out", "inout"}; + } + + Parameter::Direction::operator char const* () const + { + return direction_labels_[v_]; + } + + namespace + { + TypeInfo + parameter_init_ () + { + TypeInfo ti (typeid (Parameter)); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo parameter_ (parameter_init_ ()); + } + + TypeInfo const& Parameter:: + static_type_info () { return parameter_; } + + + // InParameter + // + // + namespace + { + TypeInfo + in_parameter_init_ () + { + TypeInfo ti (typeid (InParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo in_parameter_ (in_parameter_init_ ()); + } + + TypeInfo const& InParameter:: + static_type_info () { return in_parameter_; } + + + // OutParameter + // + // + namespace + { + TypeInfo + out_parameter_init_ () + { + TypeInfo ti (typeid (OutParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo out_parameter_ (out_parameter_init_ ()); + } + + TypeInfo const& OutParameter:: + static_type_info () { return out_parameter_; } + + + // InOutParameter + // + // + namespace + { + TypeInfo + in_out_parameter_init_ () + { + TypeInfo ti (typeid (InOutParameter)); + ti.add_base (Access::PUBLIC, true, Parameter::static_type_info ()); + return ti; + } + + TypeInfo in_out_parameter_ (in_out_parameter_init_ ()); + } + + TypeInfo const& InOutParameter:: + static_type_info () { return in_out_parameter_; } + + + // Operation + // + // + namespace + { + TypeInfo + operation_init_ () + { + TypeInfo ti (typeid (Operation)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo operation_ (operation_init_ ()); + } + + TypeInfo const& Operation:: + static_type_info () { return operation_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp new file mode 100644 index 00000000000..aa801ea7a4e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Operation.hpp @@ -0,0 +1,362 @@ +// file : CCF/IDL2/SemanticGraph/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP + +#include <string> + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Exception.hpp" +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Operation; + class Parameter; + + // Operation receives parameter + // + // + class Receives : public virtual Edge + { + public: + Operation& + operation () + { + return *operation_; + } + + Parameter& + parameter () + { + return *parameter_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Receives () + { + type_info (static_type_info ()); + } + + void + set_left_node (Operation& n) + { + operation_ = &n; + } + + void + set_right_node (Parameter& n) + { + parameter_ = &n; + } + + private: + Operation* operation_; + Parameter* parameter_; + }; + + + // Operation returns + // + // + class Returns : public virtual Belongs + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Returns () + { + type_info (static_type_info ()); + } + }; + + + // Raises + // + // + class Raises : public virtual Edge + { + public: + Operation& + operation () + { + return *operation_; + } + + Exception& + exception () + { + return *exception_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Raises () + { + type_info (static_type_info ()); + } + + void + set_left_node (Operation& n) + { + operation_ = &n; + } + + void + set_right_node (Exception& n) + { + exception_ = &n; + } + + private: + Operation* operation_; + Exception* exception_; + }; + + + // + // + // + class Parameter : public virtual Instance + { + public: + class Direction + { + public: + static Direction const in, out, inout; + + public: + operator char const* () const; + + bool + operator== (Direction d) const + { + return v_ == d.v_; + } + + bool + operator!= (Direction d) const + { + return v_ != d.v_; + } + + private: + enum Value + { + in_, out_, inout_ + } v_; + + Direction (Value v) + : v_ (v) + { + } + }; + + std::string + name () const + { + return name_; + } + + virtual Direction + direction () const = 0; + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Parameter (std::string const& name) + : name_ (name) + { + type_info (static_type_info ()); + } + + void + add_edge_right (Receives& e) + { + } + + private: + std::string name_; + }; + + + class InParameter : public virtual Parameter + { + public: + virtual Direction + direction () const + { + return Direction::in; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + InParameter (std::string const& name) + : Parameter (name) + { + type_info (static_type_info ()); + } + }; + + class OutParameter : public virtual Parameter + { + public: + virtual Direction + direction () const + { + return Direction::out; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + OutParameter (std::string const& name) + : Parameter (name) + { + type_info (static_type_info ()); + } + }; + + class InOutParameter : public virtual Parameter + { + public: + virtual Direction + direction () const + { + return Direction::inout; + } + + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + InOutParameter (std::string const& name) + : Parameter (name) + { + type_info (static_type_info ()); + } + }; + + + // @@ How am I going to make Instance & Returns work together? + // + // + class Operation : public virtual Nameable, public virtual Instance + { + typedef + std::vector<Receives*> + Receives_; + + typedef + std::vector<Raises*> + Raises_; + + public: + typedef + Receives_::const_iterator + ReceivesIterator; + + ReceivesIterator + receives_begin () const + { + return receives_.begin (); + } + + ReceivesIterator + receives_end () const + { + return receives_.end (); + } + + typedef + Raises_::const_iterator + RaisesIterator; + + RaisesIterator + raises_begin () const + { + return raises_.begin (); + } + + RaisesIterator + raises_end () const + { + return raises_.end (); + } + + Returns& + returns () + { + return dynamic_cast<Returns&> (belongs ()); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Operation () + { + type_info (static_type_info ()); + } + + void + add_edge_left (Receives& e) + { + receives_.push_back (&e); + } + + void + add_edge_left (Raises& e) + { + raises_.push_back (&e); + } + + void + add_edge_left (Returns& e) + { + Instance::add_edge_left (e); + } + + private: + Receives_ receives_; + Raises_ raises_; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp new file mode 100644 index 00000000000..50eb6aba1fb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.cpp @@ -0,0 +1,58 @@ +// file : CCF/IDL2/SemanticGraph/Sequence.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // Sequence + // + // + namespace + { + TypeInfo + sequence_init_ () + { + TypeInfo ti (typeid (Sequence)); + ti.add_base (Access::PUBLIC, + true, + TypeTemplateSpecialization::static_type_info ()); + return ti; + } + + TypeInfo sequence_ (sequence_init_ ()); + } + + TypeInfo const& Sequence:: + static_type_info () { return sequence_; } + + + // UnboundedSequence + // + // + namespace + { + TypeInfo + unbounded_sequence_init_ () + { + TypeInfo ti (typeid (UnboundedSequence)); + ti.add_base (Access::PUBLIC, true, Sequence::static_type_info ()); + return ti; + } + + TypeInfo unbounded_sequence_ (unbounded_sequence_init_ ()); + } + + TypeInfo const& UnboundedSequence:: + static_type_info () { return unbounded_sequence_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp new file mode 100644 index 00000000000..aa4b563b356 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Sequence.hpp @@ -0,0 +1,65 @@ +// file : CCF/IDL2/SemanticGraph/Sequence.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP + + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class Sequence : public virtual TypeTemplateSpecialization + { + public: + virtual bool + complete () const + { + return specialized ().type ().complete (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Sequence () + { + type_info (static_type_info ()); + } + + using TypeTemplateSpecialization::add_edge_right; + }; + + + // + // + // + class UnboundedSequence : public virtual Sequence + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + UnboundedSequence () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_SEQUENCE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp new file mode 100644 index 00000000000..af5e0fe0014 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/SemanticGraph/Struct.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Struct.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Struct + // + // + namespace + { + TypeInfo + struct_init_ () + { + TypeInfo ti (typeid (Struct)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo struct_ (struct_init_ ()); + } + + TypeInfo const& Struct:: + static_type_info () { return struct_; } + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp new file mode 100644 index 00000000000..fd6762e83b3 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Struct.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL2/SemanticGraph/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Struct : public virtual Type, public virtual Scope + { + public: + virtual bool + complete () const + { + return defined (); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Struct () + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_STRUCT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp new file mode 100644 index 00000000000..d16f0ba9e7c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.cpp @@ -0,0 +1,255 @@ +// file : CCF/IDL2/SemanticGraph/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // ContainsPrincipal + // + // + namespace + { + TypeInfo + contains_principal_init_ () + { + TypeInfo ti (typeid (ContainsPrincipal)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_principal_ (contains_principal_init_ ()); + } + + TypeInfo const& ContainsPrincipal:: + static_type_info () { return contains_principal_; } + + + // ContainsImplied + // + // + namespace + { + TypeInfo + contains_implied_init_ () + { + TypeInfo ti (typeid (ContainsImplied)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_implied_ (contains_implied_init_ ()); + } + + TypeInfo const& ContainsImplied:: + static_type_info () { return contains_implied_; } + + + // ContainsRoot + // + // + namespace + { + TypeInfo + contains_root_init_ () + { + TypeInfo ti (typeid (ContainsRoot)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo contains_root_ (contains_root_init_ ()); + } + + TypeInfo const& ContainsRoot:: + static_type_info () { return contains_root_; } + + + // Includes + // + // + namespace + { + TypeInfo + includes_init_ () + { + TypeInfo ti (typeid (Includes)); + ti.add_base (Access::PUBLIC, true, Contains::static_type_info ()); + return ti; + } + + TypeInfo includes_ (includes_init_ ()); + } + + TypeInfo const& Includes:: + static_type_info () { return includes_; } + + + // QuoteIncludes + // + // + namespace + { + TypeInfo + quote_includes_init_ () + { + TypeInfo ti (typeid (QuoteIncludes)); + ti.add_base (Access::PUBLIC, true, Includes::static_type_info ()); + return ti; + } + + TypeInfo quote_includes_ (quote_includes_init_ ()); + } + + TypeInfo const& QuoteIncludes:: + static_type_info () { return quote_includes_; } + + + + // BracketIncludes + // + // + namespace + { + TypeInfo + bracket_includes_init_ () + { + TypeInfo ti (typeid (BracketIncludes)); + ti.add_base (Access::PUBLIC, true, Includes::static_type_info ()); + return ti; + } + + TypeInfo bracket_includes_ (bracket_includes_init_ ()); + } + + TypeInfo const& BracketIncludes:: + static_type_info () { return bracket_includes_; } + + + // Root + // + // + namespace + { + TypeInfo + root_init_ () + { + TypeInfo ti (typeid (Root)); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo root_ (root_init_ ()); + } + + TypeInfo const& Root:: + static_type_info () { return root_; } + + + // TranslationRegion + // + // + + Nameables TranslationRegion:: + lookup (ScopedName const& name) + { + Nameables r; + lookup (name, r); + return r; + } + + void TranslationRegion:: + lookup (ScopedName const& name, Nameables& result) + { + bool root (name.simple ()); + + Name rest (name.begin () + (root ? 0 : 1), name.end ()); + + for (ContainsIterator i (contains_begin ()), end (contains_end ()); + i != end; ++i) + { + Node& node ((**i).element ()); + + if (Root* r = dynamic_cast<Root*> (&node)) + { + if (root) + { + result.insert (&dynamic_cast<Root&> (node)); + } + else + { + r->lookup (rest, result); + } + } + else + { + dynamic_cast<TranslationRegion&> (node).lookup (name, result); + } + } + } + + + namespace + { + TypeInfo + translation_region_init_ () + { + TypeInfo ti (typeid (TranslationRegion)); + ti.add_base (Access::PUBLIC, true, Container::static_type_info ()); + return ti; + } + + TypeInfo translation_region_ (translation_region_init_ ()); + } + + TypeInfo const& TranslationRegion:: + static_type_info () { return translation_region_; } + + + // TranslationUnit + // + // + + Nameables TranslationUnit:: + lookup (ScopedName const& name) + { + Nameables r; + + for (ContainsIterator i (contains_begin ()), end (contains_end ()); + i != end; ++i) + { + TranslationRegion& tr ( + dynamic_cast<TranslationRegion&>((**i).element ())); + + tr.lookup (name, r); + } + + return r; + } + + namespace + { + TypeInfo + translation_unit_init_ () + { + TypeInfo ti (typeid (TranslationUnit)); + ti.add_base (Access::PUBLIC, true, Container::static_type_info ()); + return ti; + } + + TypeInfo translation_unit_ (translation_unit_init_ ()); + } + + TypeInfo const& TranslationUnit:: + static_type_info () { return translation_unit_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp new file mode 100644 index 00000000000..0fd7bbf4739 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.hpp @@ -0,0 +1,287 @@ +// file : CCF/IDL2/SemanticGraph/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP + +#include <vector> +#include <string> + +#include "CCF/CompilerElements/FileSystem.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + class Root; + class TranslationRegion; + class TranslationUnit; + + + // + // + // + class ContainsPrincipal : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsPrincipal () + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationUnit& n); + + void + set_right_node (TranslationRegion& n); + }; + + + // + // + // + class ContainsImplied : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsImplied (std::string const& name = "") + : name_ (name) + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationUnit& n); + + void + set_right_node (TranslationRegion& n); + + private: + std::string name_; + }; + + + // + // + // + class ContainsRoot : public virtual Contains + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ContainsRoot () + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationRegion& n); + + void + set_right_node (Root& n); + }; + + // + // + // + class Includes : public virtual Contains + { + public: + fs::path + file () const + { + return file_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Includes (fs::path const& file) + : file_ (file) + { + type_info (static_type_info ()); + } + + void + set_left_node (TranslationRegion& n); + + void + set_right_node (TranslationRegion& n); + + private: + fs::path file_; + }; + + + // + // + // + class QuoteIncludes : public virtual Includes + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + QuoteIncludes (fs::path const& file) + : Includes (file) + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class BracketIncludes : public virtual Includes + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + BracketIncludes (fs::path const& file) + : Includes (file) + { + type_info (static_type_info ()); + } + }; + + + //@@ Root somewhat breaks Nameable interface. + // Maybe, for consistency, I should make TR to name + // Root? + // + class Root : public virtual Scope + { + public: + virtual SimpleName + name () const + { + return SimpleName (""); + } + + virtual ScopedName + scoped_name () const + { + return ScopedName (""); + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Root () + { + type_info (static_type_info ()); + } + + void + add_edge_right (Contains& e) + { + // TranslationRegion contains Root + } + }; + + + // + // + // + class TranslationRegion : public virtual Container + { + public: + Nameables + lookup (ScopedName const& name); + + void + lookup (ScopedName const& name, Nameables& result); + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TranslationRegion () + { + type_info (static_type_info ()); + } + + void + add_edge_right (Contains& e) + { + } + }; + + + class TranslationUnit : public virtual Container, + public Graph<Node, Edge> + { + public: + TranslationUnit () + { + type_info (static_type_info ()); + } + + Nameables + lookup (ScopedName const& name); + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + void + add_edge_left (ContainsPrincipal& e) + { + Container::add_edge_left (e); + } + + void + add_edge_left (ContainsImplied& e) + { + Container::add_edge_left (e); + } + + private: + TranslationUnit (TranslationUnit const&); + void operator= (TranslationUnit const&); + }; + } + } +} + +#include "CCF/IDL2/SemanticGraph/Translation.ipp" + +#endif // CCF_IDL2_SEMANTIC_GRAPH_TRANSLATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp new file mode 100644 index 00000000000..8168cd87762 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/Translation.ipp @@ -0,0 +1,73 @@ +// file : CCF/IDL2/SemanticGraph/Translation.ipp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // ContainsPrincipal + // + // + inline void ContainsPrincipal:: + set_left_node (TranslationUnit& n) + { + Contains::set_left_node (n); + } + + inline void ContainsPrincipal:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + + // ContainsImplied + // + // + inline void ContainsImplied:: + set_left_node (TranslationUnit& n) + { + Contains::set_left_node (n); + } + + inline void ContainsImplied:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + + // ContainsRoot + // + // + inline void ContainsRoot:: + set_left_node (TranslationRegion& n) + { + Contains::set_left_node (n); + } + + inline void ContainsRoot:: + set_right_node (Root& n) + { + Contains::set_right_node (n); + } + + + // Includes + // + // + inline void Includes:: + set_left_node (TranslationRegion& n) + { + Contains::set_left_node (n); + } + + inline void Includes:: + set_right_node (TranslationRegion& n) + { + Contains::set_right_node (n); + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp new file mode 100644 index 00000000000..091f5aaebe2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.cpp @@ -0,0 +1,56 @@ +// file : CCF/IDL2/SemanticGraph/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // TypeId + // + // + namespace + { + TypeInfo + type_id_init_ () + { + TypeInfo ti (typeid (TypeId)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_id_ (type_id_init_ ()); + } + + TypeInfo const& TypeId:: + static_type_info () { return type_id_; } + + + // TypePrefix + // + // + namespace + { + TypeInfo + type_prefix_init_ () + { + TypeInfo ti (typeid (TypePrefix)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + return ti; + } + + TypeInfo type_prefix_ (type_prefix_init_ ()); + } + + TypeInfo const& TypePrefix:: + static_type_info () { return type_prefix_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp new file mode 100644 index 00000000000..db02aae6edf --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/TypeId.hpp @@ -0,0 +1,96 @@ +// file : CCF/IDL2/SemanticGraph/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Literals.hpp" + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class TypeId : public virtual Nameable + { + public: + //@@ declaration is a bad name. + // + ScopedName + declaration () const + { + return name_; + } + + StringLiteral + id () const + { + return id_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TypeId (ScopedName const& name, StringLiteral const& id) + : name_ (name), + id_ (id) + { + type_info (static_type_info ()); + } + + private: + ScopedName name_; + StringLiteral id_; + }; + + + // + // + // + class TypePrefix : public virtual Nameable + { + public: + ScopedName + declaration () const + { + return name_; + } + + StringLiteral + prefix () const + { + return prefix_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + TypePrefix (ScopedName const& name, StringLiteral const& prefix) + : name_ (name), + prefix_ (prefix) + { + type_info (static_type_info ()); + } + + private: + ScopedName name_; + StringLiteral prefix_; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_TYPE_ID_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp new file mode 100644 index 00000000000..f0d5f56d117 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.cpp @@ -0,0 +1,77 @@ +// file : CCF/IDL2/SemanticGraph/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" + +using Introspection::TypeInfo; +using Introspection::Access; + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // ValueType + // + // + namespace + { + TypeInfo + value_type_init_ () + { + TypeInfo ti (typeid (ValueType)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo value_type_ (value_type_init_ ()); + } + + TypeInfo const& ValueType:: + static_type_info () { return value_type_; } + + + // AbstractValueType + // + // + namespace + { + TypeInfo + abstract_value_type_init_ () + { + TypeInfo ti (typeid (AbstractValueType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo abstract_value_type_ (abstract_value_type_init_ ()); + } + + TypeInfo const& AbstractValueType:: + static_type_info () { return abstract_value_type_; } + + + // ConcreteValueType + // + // + namespace + { + TypeInfo + concrete_value_type_init_ () + { + TypeInfo ti (typeid (ConcreteValueType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo concrete_value_type_ (concrete_value_type_init_ ()); + } + + TypeInfo const& ConcreteValueType:: + static_type_info () { return concrete_value_type_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp new file mode 100644 index 00000000000..aba2f2183e8 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp @@ -0,0 +1,88 @@ +// file : CCF/IDL2/SemanticGraph/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_HPP +#define CCF_IDL2_SEMANTIC_GRAPH_VALUE_TYPE_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticGraph + { + // + // + // + class ValueType : public virtual Type, + public virtual Scope + { + public: + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ValueType () + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + }; + + + // + // + // + class AbstractValueType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractValueType () + { + type_info (static_type_info ()); + } + }; + + // @@ value type member + // @@ value type factory + // + + // + // + // + class ConcreteValueType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ConcreteValueType () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_GRAPH_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..a251329a2d8 --- /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..158c7754226 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Token.hpp @@ -0,0 +1,348 @@ +// file : CCF/IDL2/Token.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TOKEN_HPP +#define CCF_IDL2_TOKEN_HPP + +#include <vector> +#include <string> +#include <ostream> + +#include "CCF/CompilerElements/ReferenceCounting.hpp" + +namespace CCF +{ + namespace IDL2 + { + // + // + // + class Token : public ReferenceCounting::DefaultImpl <> + { + protected: + Token (std::string lexeme, unsigned long line) + : lexeme_ (lexeme), + line_ (line) + { + } + + public: + virtual + ~Token () throw () {} + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + + public: + std::string + lexeme () const + { + return lexeme_; + } + + unsigned long + line () const + { + return line_; + } + + private: + std::string lexeme_; + unsigned long line_; + }; + + typedef + ReferenceCounting::StrictPtr<Token> + TokenPtr; + + typedef + std::vector<TokenPtr> + TokenList; + + inline std::ostream& + operator<< (std::ostream& o, TokenPtr const& t) + { + if (t != 0) t->print (o); + 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 Operator : public Token + { + public: + Operator (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + + virtual + ~Operator () throw () {} + }; + + typedef + ReferenceCounting::StrictPtr<Operator> + OperatorPtr; + + + // + // + // + class Identifier : public Token + { + public: + Identifier (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Identifier> + IdentifierPtr; + + + // + // + // + class SimpleIdentifier : public Identifier + { + public: + SimpleIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<SimpleIdentifier> + SimpleIdentifierPtr; + + + // + // + // + class ScopedIdentifier : public Identifier + { + public: + ScopedIdentifier (std::string lexeme, unsigned long line) + : Identifier (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<ScopedIdentifier> + ScopedIdentifierPtr; + + + // + // + // + class Literal : public Token + { + public: + Literal (std::string lexeme, unsigned long line) + : Token (lexeme, line) + { + } + }; + + typedef + ReferenceCounting::StrictPtr<Literal> + LiteralPtr; + + + // + // + // + class BooleanLiteral : public Literal + { + public: + BooleanLiteral (std::string lexeme, unsigned long line) + : Literal (lexeme, line) + { + } + + bool + value () const + { + return lexeme () == "TRUE"; + } + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + }; + + typedef + ReferenceCounting::StrictPtr<BooleanLiteral> + BooleanLiteralPtr; + + + // + // + // + class CharacterLiteral : public Literal + { + public: + CharacterLiteral (char c, std::string lexeme, unsigned long line) + : Literal (lexeme, line), c_ (c) + { + } + + char + value () const + { + return c_; + } + + virtual void + print (std::ostream& o) + { + //@@ todo + o << lexeme (); + } + + private: + char c_; + }; + + typedef + ReferenceCounting::StrictPtr<CharacterLiteral> + CharacterLiteralPtr; + + + // + // + // + class IntegerLiteral : public Literal + { + public: + IntegerLiteral (unsigned long long value, + std::string lexeme, + unsigned long line) + : Literal (lexeme, line), value_ (value) + { + } + + unsigned long long + value () const + { + return value_; + } + + virtual void + print (std::ostream& o) + { + o << lexeme (); + } + + private: + unsigned long long value_; + }; + + typedef + ReferenceCounting::StrictPtr<IntegerLiteral> + IntegerLiteralPtr; + + + // + // + // + class StringLiteral : public Literal + { + public: + virtual + ~StringLiteral () throw () {} + + StringLiteral (std::string const& value, + std::string const& lexeme, + unsigned long line) + : Literal (lexeme, line), value_ (value) + { + } + + std::string + value () const + { + return value_; + } + + virtual void + print (std::ostream& o) + { + //@@ todo + o << lexeme (); + } + + private: + std::string value_; + }; + + typedef + ReferenceCounting::StrictPtr<StringLiteral> + StringLiteralPtr; + } +} + +#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..3dc9eff7e06 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal.hpp @@ -0,0 +1,24 @@ +// 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/Attribute.hpp" +#include "CCF/IDL2/Traversal/Exception.hpp" +#include "CCF/IDL2/Traversal/Fundamental.hpp" +#include "CCF/IDL2/Traversal/Interface.hpp" +#include "CCF/IDL2/Traversal/Member.hpp" +#include "CCF/IDL2/Traversal/Module.hpp" +#include "CCF/IDL2/Traversal/Operation.hpp" +#include "CCF/IDL2/Traversal/Struct.hpp" +#include "CCF/IDL2/Traversal/Sequence.hpp" +#include "CCF/IDL2/Traversal/Struct.hpp" +#include "CCF/IDL2/Traversal/Translation.hpp" +#include "CCF/IDL2/Traversal/TypeId.hpp" +#include "CCF/IDL2/Traversal/ValueType.hpp" + +#endif // CCF_IDL2_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp new file mode 100644 index 00000000000..c94270c4061 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.cpp @@ -0,0 +1,54 @@ +// file : CCF/IDL2/Traversal/Attribute.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Attribute + // + // + + void Attribute:: + traverse (Type& a) + { + pre (a); + belongs (a); + name (a); + post (a); + } + + void Attribute:: + pre (Type&) + { + } + + void Attribute:: + belongs (Type& a, EdgeDispatcherBase& d) + { + d.traverse (a.belongs ()); + } + + void Attribute:: + belongs (Type& a) + { + belongs (a, edge_traverser ()); + } + + void Attribute:: + name (Type&) + { + } + + void Attribute:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp new file mode 100644 index 00000000000..1519c077ee4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Attribute.hpp @@ -0,0 +1,135 @@ +// file : CCF/IDL2/Traversal/Attribute.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ATTRIBUTE_HPP +#define CCF_IDL2_TRAVERSAL_ATTRIBUTE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Attribute.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct Attribute : Node<SemanticGraph::Attribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + + /* + + This is just a concept. Any comments? + + // + // + // + struct ReadAttribute : Node<SemanticGraph::ReadAttribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + get_raises (Type&, EdgeDispatcherBase&); + + virtual void + get_raises (Type&); + + virtual void + get_raises_pre (Type&); + + virtual void + get_raises_post (Type&); + + virtual void + post (Type&); + }; + + + // + // + // + struct ReadWriteAttribute : Node<SemanticGraph::ReadWriteAttribute> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + get_raises (Type&, EdgeDispatcherBase&); + + virtual void + get_raises (Type&); + + virtual void + get_raises_pre (Type&); + + virtual void + get_raises_post (Type&); + + virtual void + set_raises (Type&, EdgeDispatcherBase&); + + virtual void + set_raises (Type&); + + virtual void + set_raises_pre (Type&); + + virtual void + set_raises_post (Type&); + + virtual void + post (Type&); + }; + + */ + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_ATTRIBUTE_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..c7a24089a42 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp new file mode 100644 index 00000000000..9339447de4d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.hpp @@ -0,0 +1,453 @@ +// file : CCF/IDL2/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_ELEMENTS_HPP +#define CCF_IDL2_TRAVERSAL_ELEMENTS_HPP + +#include <map> +#include <set> + +#include "CCF/CompilerElements/Introspection.hpp" + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +//@@ tmp +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + //@@ revise with the knowledge that derivation is not + // access controlled. + // + + // + // + // + template<typename T> + class Traverser + { + protected: + virtual + ~Traverser (); + + virtual void + trampoline (T& n) = 0; + + template <typename> + friend class Dispatcher; + }; + + + // + // + // + template <typename T> + class Dispatcher + { + public: + virtual + ~Dispatcher (); + + virtual void + traverse (T& n); + + void + map (Introspection::TypeId id, Traverser<T>& t) + { + Traversers& traversers (traversal_map_[id]); + traversers.push_back (&t); + } + + public: + typedef + std::vector<Traverser<T>*> + Traversers; + + typedef + std::map<Introspection::TypeId, Traversers> + TraversalMap; + + //@@ This stuff is not used. + // + typedef + typename TraversalMap::const_iterator + Iterator; + + Iterator + begin () const + { + return traversal_map_.begin (); + } + + Iterator + end () const + { + return traversal_map_.end (); + } + + private: + struct TypeInfoComparator + { + bool + operator () (Introspection::TypeInfo const& x, + Introspection::TypeInfo const& y) const + { + return x.type_id () < y.type_id (); + } + }; + + typedef + std::map<Introspection::TypeInfo, unsigned long, TypeInfoComparator> + LevelMap; + + typedef + std::set<Introspection::TypeInfo, TypeInfoComparator> + TypeInfoSet; + + static unsigned long + compute_levels (Introspection::TypeInfo const& ti, + unsigned long cur, + LevelMap& map); + + static void + flatten_tree (Introspection::TypeInfo const& ti, TypeInfoSet& set); + + private: + TraversalMap traversal_map_; + }; + + + // + // + // + typedef + Dispatcher<SemanticGraph::Node> + NodeDispatcherBase; + + typedef + Dispatcher<SemanticGraph::Edge> + EdgeDispatcherBase; + + + // + // + // + class NodeDispatcher : public virtual NodeDispatcherBase + { + public: + void + edge_traverser (EdgeDispatcherBase& d) + { + //@@ this should be done in Dispatcher in merge() function? + // + for (EdgeDispatcherBase::Iterator i (d.begin ()), end (d.end ()); + i != end; ++i) + { + for (EdgeDispatcherBase::Traversers::const_iterator + t (i->second.begin ()), end (i->second.end ()); + t != end; ++t) + { + dispatcher_.map (i->first, **t); + } + } + } + + protected: + template <typename I> + void + iterate_and_traverse (I begin, I end, EdgeDispatcherBase& d) + { + for (; begin != end; ++begin) + { + d.traverse (**begin); + } + } + + template <typename I, typename X, typename A> + void + iterate_and_traverse (I begin, + I end, + EdgeDispatcherBase& d, + X& x, + void (X::*f)(A&), + A& a) + { + for (I i (begin); i != end;) + { + d.traverse (**i); + + if (++i != end) (x.*f) (a); + } + } + + EdgeDispatcherBase& + edge_traverser () + { + return dispatcher_; + } + + protected: + EdgeDispatcherBase dispatcher_; + }; + + + class EdgeDispatcher : public virtual EdgeDispatcherBase + { + public: + void + node_traverser (NodeDispatcherBase& d) + { + for (NodeDispatcherBase::Iterator i (d.begin ()), end (d.end ()); + i != end; ++i) + { + for (NodeDispatcherBase::Traversers::const_iterator + t (i->second.begin ()), end (i->second.end ()); + t != end; ++t) + { + dispatcher_.map (i->first, **t); + } + } + } + + protected: + NodeDispatcherBase& + node_traverser () + { + return dispatcher_; + } + + protected: + NodeDispatcherBase dispatcher_; + }; + + + // + // + // + template <typename T> + struct Node : Traverser<SemanticGraph::Node>, virtual NodeDispatcher + { + typedef + T + Type; + + Node () + { + map (typeid (Type), *this); + } + + virtual void + trampoline (SemanticGraph::Node& n) + { + //cerr << "trampoline for " << &n << " to type " + // << typeid (Type).name () << endl; + + traverse (dynamic_cast<Type&> (n)); + } + + virtual void + traverse (Type&) = 0; + }; + + + template <typename T> + struct Edge : Traverser <SemanticGraph::Edge>, virtual EdgeDispatcher + { + typedef + T + Type; + + Edge () + { + map (typeid (Type), *this); + } + + virtual void + trampoline (SemanticGraph::Edge& e) + { + traverse (dynamic_cast<Type&> (e)); + } + + + virtual void + traverse (Type& e) = 0; + }; + + // Edges + // + // + struct Names : Edge<SemanticGraph::Names> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + struct Defines : Edge<SemanticGraph::Defines> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + struct Mentions : Edge<SemanticGraph::Mentions> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.named ()); + } + }; + + + + struct Aliases : Edge<SemanticGraph::Aliases> + { + virtual void + traverse (Type& a) + { + pre (a); + type (a); + name (a); + post (a); + } + + virtual void + pre (Type& e) + { + } + + virtual void + type (Type& e) + { + node_traverser ().traverse (e.named ()); + } + + virtual void + name (Type& e) + { + } + + virtual void + post (Type& e) + { + } + }; + + + struct Belongs : Edge<SemanticGraph::Belongs> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.type ()); + } + }; + + + struct Specialized : Edge<SemanticGraph::Specialized> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.type ()); + } + }; + + + struct Inherits : Edge<SemanticGraph::Inherits> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.inheritee ()); + } + }; + + + struct Contains : Edge<SemanticGraph::Contains> + { + }; + + + // Nodes + // + // + struct Nameable : Node<SemanticGraph::Nameable> + { + }; + + + template <typename T> + struct ScopeTemplate : Node<T> + { + public: + virtual void + traverse (T& s) + { + names (s); + } + + virtual void + names (T& s) + { + names_pre (s); + names (s, edge_traverser ()); + names_post (s); + } + + virtual void + names (T& s, EdgeDispatcherBase& d) + { + iterate_and_traverse (s.names_begin (), s.names_end (), d); + } + + virtual void + names_pre (T&) + { + } + + virtual void + names_post (T&) + { + } + }; + + + // + // + // + typedef + ScopeTemplate<SemanticGraph::Scope> + Scope; + + + // + // + // + struct Type : Node<SemanticGraph::Type> + { + virtual void + traverse (SemanticGraph::Type&) = 0; + }; + } + } +} + +#include "CCF/IDL2/Traversal/Elements.tpp" + +#endif // CCF_IDL2_TRAVERSAL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp new file mode 100644 index 00000000000..60cace27f69 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Elements.tpp @@ -0,0 +1,128 @@ +// file : CCF/IDL2/Traversal/Elements.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Traverser + // + // + + template<typename T> + Traverser<T>:: + ~Traverser () + { + } + + // Dispatcher + // + // + + template <typename T> + Dispatcher<T>:: + ~Dispatcher () + { + } + + template <typename T> + void Dispatcher<T>:: + traverse (T& n) + { + LevelMap levels; + + unsigned long max = compute_levels (n.type_info (), 0, levels); + + + //cerr << "starting dispatch process for " + // << n.type_info ().type_id () << " with " + // << max << " levels" << endl; + + for (unsigned long l = 0; l < max + 1; ++l) + { + TypeInfoSet dispatched; + + for (typename LevelMap::const_iterator + i (levels.begin ()), e (levels.end ()); + i != e; ++i) + { + if (i->second == l) + { + typename TraversalMap::const_iterator v ( + traversal_map_.find (i->first.type_id ())); + + if (v != traversal_map_.end ()) + { + //cerr << "dispatching traversers for " + // << n.type_info ().type_id () << " as " + // << i->first.type_id () << endl; + + Traversers const& traversers (v->second); + for (typename Traversers::const_iterator + ti (traversers.begin ()), te (traversers.end ()); + ti != te; ++ti) + { + (*ti)->trampoline (n); + } + + flatten_tree (i->first, dispatched); + } + } + } + + // Remove traversed types from level map. + // + for (typename TypeInfoSet::const_iterator i = dispatched.begin (); + i != dispatched.end (); + ++i) + { + levels.erase (*i); + } + } + } + + template <typename T> + unsigned long Dispatcher<T>:: + compute_levels (Introspection::TypeInfo const& ti, + unsigned long cur, + LevelMap& map) + { + unsigned long ret = cur; + + if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur; + + for (Introspection::TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + unsigned long t = compute_levels (i->type_info (), cur + 1, map); + if (t > ret) ret = t; + } + + return ret; + } + + template <typename T> + void Dispatcher<T>:: + flatten_tree (Introspection::TypeInfo const& ti, TypeInfoSet& set) + { + set.insert (ti); + + for (Introspection::TypeInfo::BaseIterator i = ti.begin_base (); + i != ti.end_base (); + i++) + { + flatten_tree (i->type_info (), set); + } + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp new file mode 100644 index 00000000000..21e41784c71 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/Traversal/Exception.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Exception:: + traverse (Type& s) + { + pre (s); + name (s); + names (s); + post (s); + } + + void Exception:: + pre (Type&) + { + } + + void Exception:: + name (Type&) + { + } + + void Exception:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp new file mode 100644 index 00000000000..23eda73f1a7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Exception.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL2/Traversal/Exception.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_EXCEPTION_HPP +#define CCF_IDL2_TRAVERSAL_EXCEPTION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Exception.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Exception : ScopeTemplate<SemanticGraph::Exception> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_EXCEPTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp new file mode 100644 index 00000000000..4dd6760cebe --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/Fundamental.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp new file mode 100644 index 00000000000..4c93301ad88 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Fundamental.hpp @@ -0,0 +1,102 @@ +// file : CCF/IDL2/Traversal/Fundamental.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP +#define CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Fundamental.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + typedef + Node<SemanticGraph::FundamentalType> + FundamentalType; + + + typedef + Node<SemanticGraph::Object> + Object; + + typedef + Node<SemanticGraph::ValueBase> + ValueBase; + + typedef + Node<SemanticGraph::Any> + Any; + + typedef + Node<SemanticGraph::Boolean> + Boolean; + + typedef + Node<SemanticGraph::Char> + Char; + + typedef + Node<SemanticGraph::Double> + Double; + + typedef + Node<SemanticGraph::Float> + Float; + + typedef + Node<SemanticGraph::Long> + Long; + + typedef + Node<SemanticGraph::LongDouble> + LongDouble; + + typedef + Node<SemanticGraph::LongLong> + LongLong; + + typedef + Node<SemanticGraph::Octet> + Octet; + + typedef + Node<SemanticGraph::Short> + Short; + + typedef + Node<SemanticGraph::String> + String; + + typedef + Node<SemanticGraph::UnsignedLong> + UnsignedLong; + + typedef + Node<SemanticGraph::UnsignedLongLong> + UnsignedLongLong; + + typedef + Node<SemanticGraph::UnsignedShort> + UnsignedShort; + + typedef + Node<SemanticGraph::Void> + Void; + + typedef + Node<SemanticGraph::Wchar> + Wchar; + + typedef + Node<SemanticGraph::Wstring> + Wstring; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_FUNDAMENTAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp new file mode 100644 index 00000000000..fb6cbf9686c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/Interface.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp new file mode 100644 index 00000000000..64bce204efc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.hpp @@ -0,0 +1,84 @@ +// file : CCF/IDL2/Traversal/Interface.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_INTERFACE_HPP +#define CCF_IDL2_TRAVERSAL_INTERFACE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Supports : Edge<SemanticGraph::Supports> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.supportee ()); + } + }; + + template <typename T> + struct InterfaceTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + inherits (T&, EdgeDispatcherBase& d); + + virtual void + inherits (T&); + + virtual void + inherits_pre (T&); + + virtual void + inherits_post (T&); + + virtual void + inherits_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + + typedef + InterfaceTemplate<SemanticGraph::Interface> + Interface; + + + typedef + InterfaceTemplate<SemanticGraph::AbstractInterface> + AbstractInterface; + + typedef + InterfaceTemplate<SemanticGraph::LocalInterface> + LocalInterface; + + typedef + InterfaceTemplate<SemanticGraph::UnconstrainedInterface> + UnconstrainedInterface; + } + } +} + +#include "CCF/IDL2/Traversal/Interface.tpp" + +#endif // CCF_IDL2_TRAVERSAL_INTERFACE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp new file mode 100644 index 00000000000..f9c667e2360 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Interface.tpp @@ -0,0 +1,102 @@ +// file : CCF/IDL2/Traversal/Interface.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // @@ Use Type& shortcut consistently. + // + + template <typename T> + void InterfaceTemplate<T>:: + traverse (T& i) + { + pre (i); + name (i); + inherits (i); + names (i); + post (i); + } + + template <typename T> + void InterfaceTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + name (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits (T& i, EdgeDispatcherBase& d) + { + iterate_and_traverse (i.inherits_begin (), + i.inherits_end (), + d); + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits (T& i) + { + typename T::InheritsIterator + b (i.inherits_begin ()), e (i.inherits_end ()); + + if (b != e) + { + inherits_pre (i); + iterate_and_traverse (b, + e, + edge_traverser (), + *this, + &InterfaceTemplate::comma, + i); + inherits_post (i); + } + else + { + inherits_none (i); + } + + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_pre (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_post (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + inherits_none (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + post (T&) + { + } + + template <typename T> + void InterfaceTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt new file mode 100644 index 00000000000..1febb5e02e2 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Makefile.alt @@ -0,0 +1,30 @@ +# 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 := Attribute.cpp \ + Elements.cpp \ + Exception.cpp \ + Fundamental.cpp \ + Interface.cpp \ + Member.cpp \ + Module.cpp \ + Operation.cpp \ + Sequence.cpp \ + Struct.cpp \ + Translation.cpp \ + TypeId.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/Traversal/Member.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Member.cpp new file mode 100644 index 00000000000..01299a0b00c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Member.cpp @@ -0,0 +1,50 @@ +// file : CCF/IDL2/Traversal/Member.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Member:: + traverse (Type& m) + { + pre (m); + belongs (m); + name (m); + post (m); + } + + void Member:: + pre (Type&) + { + } + + void Member:: + belongs (Type& m, EdgeDispatcherBase& d) + { + d.traverse (m.belongs ()); + } + + void Member:: + belongs (Type& m) + { + belongs (m, edge_traverser ()); + } + + void Member:: + name (Type&) + { + } + + void Member:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp new file mode 100644 index 00000000000..a0f05e6f33f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Member.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/Traversal/Member.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_MEMBER_HPP +#define CCF_IDL2_TRAVERSAL_MEMBER_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Member.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Member : Node<SemanticGraph::Member> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + belongs (Type&, EdgeDispatcherBase&); + + virtual void + belongs (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_MEMBER_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp new file mode 100644 index 00000000000..62f5d70aa9c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.cpp @@ -0,0 +1,15 @@ +// file : CCF/IDL2/Traversal/Module.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp new file mode 100644 index 00000000000..994c40dd590 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Module.hpp @@ -0,0 +1,48 @@ +// file : CCF/IDL2/Traversal/Module.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_MODULE_HPP +#define CCF_IDL2_TRAVERSAL_MODULE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Module.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Module : ScopeTemplate<SemanticGraph::Module> + { + virtual void + traverse (Type& m) + { + pre (m); + name (m); + names (m); + post (m); + } + + virtual void + pre (Type&) + { + } + + virtual void + name (Type&) + { + } + + virtual void + post (Type&) + { + } + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_MODULE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp new file mode 100644 index 00000000000..09a793ded58 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.cpp @@ -0,0 +1,128 @@ +// 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 + { + // Operation + // + // + void Operation:: + traverse (Type& o) + { + pre (o); + returns (o); + name (o); + receives (o); + raises (o); + post (o); + } + + void Operation:: + pre (Type&) + { + } + + void Operation:: + returns (Type& o, EdgeDispatcherBase& d) + { + d.traverse (o.returns ()); + } + + void Operation:: + returns (Type& o) + { + returns (o, edge_traverser ()); + } + + void Operation:: + name (Type&) + { + } + + void Operation:: + receives (Type& o, EdgeDispatcherBase& d) + { + iterate_and_traverse (o.receives_begin (), o.receives_end (), d); + } + + void Operation:: + receives (Type& o) + { + receives_pre (o); + iterate_and_traverse (o.receives_begin (), + o.receives_end (), + edge_traverser (), + *this, + &Operation::comma, + o); + receives_post (o); + } + + void Operation:: + receives_pre (Type&) + { + } + + void Operation:: + receives_post (Type&) + { + } + + void Operation:: + raises (Type& o, EdgeDispatcherBase& d) + { + iterate_and_traverse (o.raises_begin (), o.raises_end (), d); + } + + void Operation:: + raises (Type& o) + { + Type::RaisesIterator b (o.raises_begin ()), e (o.raises_end ()); + + if (b != e) + { + raises_pre (o); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &Operation::comma, o); + raises_post (o); + } + else + { + raises_none (o); + } + } + + void Operation:: + raises_pre (Type&) + { + } + + void Operation:: + raises_post (Type&) + { + } + + void Operation:: + raises_none (Type&) + { + } + + void Operation:: + post (Type&) + { + } + + void Operation:: + comma (Type&) + { + } + } + } +} 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..79bddb62b66 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.hpp @@ -0,0 +1,154 @@ +// file : CCF/IDL2/Traversal/Operation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_OPERATION_HPP +#define CCF_IDL2_TRAVERSAL_OPERATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/Operation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // + // + // + struct Receives : Edge<SemanticGraph::Receives> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.parameter ()); + } + }; + + + // + // + // + struct Returns : Edge<SemanticGraph::Returns> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.type ()); + } + }; + + // + // + // + struct Raises : Edge<SemanticGraph::Raises> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.exception ()); + } + }; + + // + // + // + template<typename T> + struct ParameterTemplate : Node<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + belongs (T&, EdgeDispatcherBase&); + + virtual void + belongs (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + typedef + ParameterTemplate<SemanticGraph::Parameter> + Parameter; + + typedef + ParameterTemplate<SemanticGraph::InParameter> + InParameter; + + typedef + ParameterTemplate<SemanticGraph::InOutParameter> + InOutParameter; + + typedef + ParameterTemplate<SemanticGraph::OutParameter> + OutParameter; + + // + // + // + struct Operation : Node<SemanticGraph::Operation> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + returns (Type&, EdgeDispatcherBase&); + + virtual void + returns (Type&); + + virtual void + name (Type&); + + virtual void + receives (Type&, EdgeDispatcherBase&); + + virtual void + receives (Type&); + + virtual void + receives_pre (Type&); + + virtual void + receives_post (Type&); + + virtual void + raises (Type&, EdgeDispatcherBase&); + + virtual void + raises (Type&); + + virtual void + raises_pre (Type&); + + virtual void + raises_post (Type&); + + virtual void + raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + } + } +} + +#include "CCF/IDL2/Traversal/Operation.tpp" + +#endif // CCF_IDL2_TRAVERSAL_OPERATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp new file mode 100644 index 00000000000..fe41b777f1b --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Operation.tpp @@ -0,0 +1,57 @@ +// file : CCF/IDL2/Traversal/Operation.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // ParameterTemplate + // + // + template<typename T> + void ParameterTemplate<T>:: + traverse (T& p) + { + pre (p); + belongs (p); + name (p); + post (p); + } + + template<typename T> + void ParameterTemplate<T>:: + pre (T&) + { + } + + template<typename T> + void ParameterTemplate<T>:: + belongs (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template<typename T> + void ParameterTemplate<T>:: + belongs (T& p) + { + belongs (p, edge_traverser ()); + } + + template<typename T> + void ParameterTemplate<T>:: + name (T&) + { + } + + template<typename T> + void ParameterTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp new file mode 100644 index 00000000000..bc06e04a8fe --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.cpp @@ -0,0 +1,51 @@ +// file : CCF/IDL2/Traversal/Sequence.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Sequence.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + + void UnboundedSequence:: + traverse (Type& us) + { + pre (us); + specialized (us); + name (us); + post (us); + } + + void UnboundedSequence:: + pre (Type&) + { + } + + void UnboundedSequence:: + specialized (Type& us, EdgeDispatcherBase& d) + { + d.traverse (us.specialized ()); + } + + void UnboundedSequence:: + specialized (Type& us) + { + specialized (us, edge_traverser ()); + } + + void UnboundedSequence:: + name (Type&) + { + } + + void UnboundedSequence:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp new file mode 100644 index 00000000000..14a44aa68f0 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Sequence.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/Traversal/Sequence.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_SEQUENCE_HPP +#define CCF_IDL2_TRAVERSAL_SEQUENCE_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Sequence.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct UnboundedSequence : Node<SemanticGraph::UnboundedSequence> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + specialized (Type&, EdgeDispatcherBase&); + + virtual void + specialized (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_SEQUENCE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp new file mode 100644 index 00000000000..c9e4a23ee0d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL2/Traversal/Struct.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Struct.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + void Struct:: + traverse (Type& s) + { + pre (s); + name (s); + names (s); + post (s); + } + + void Struct:: + pre (Type&) + { + } + + void Struct:: + name (Type&) + { + } + + void Struct:: + post (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp new file mode 100644 index 00000000000..c3a215064b7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Struct.hpp @@ -0,0 +1,36 @@ +// file : CCF/IDL2/Traversal/Struct.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_STRUCT_HPP +#define CCF_IDL2_TRAVERSAL_STRUCT_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Struct.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + struct Struct : ScopeTemplate<SemanticGraph::Struct> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + post (Type&); + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_STRUCT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp new file mode 100644 index 00000000000..e3fcd58e272 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL2/Traversal/Translation.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // TranslationRegion + // + // + void TranslationRegion:: + traverse (SemanticGraph::TranslationRegion& r) + { + iterate_and_traverse (r.contains_begin (), + r.contains_end (), + edge_traverser ()); + } + + + // TranslationUnit + // + // + void TranslationUnit:: + traverse (SemanticGraph::TranslationUnit& u) + { + iterate_and_traverse (u.contains_begin (), + u.contains_end (), + edge_traverser ()); + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp new file mode 100644 index 00000000000..7fc3f58c5d4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/Translation.hpp @@ -0,0 +1,107 @@ +// file : CCF/IDL2/Traversal/Translation.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_TRANSLATION_HPP +#define CCF_IDL2_TRAVERSAL_TRANSLATION_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Some edges. + // + // + struct ContainsPrincipal : Edge<SemanticGraph::ContainsPrincipal> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct ContainsImplied : Edge<SemanticGraph::ContainsImplied> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct ContainsRoot : Edge<SemanticGraph::ContainsRoot> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct Includes : Edge<SemanticGraph::Includes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct QuoteIncludes : Edge<SemanticGraph::QuoteIncludes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + struct BracketIncludes : Edge<SemanticGraph::BracketIncludes> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.element ()); + } + }; + + + // + // + // + typedef + ScopeTemplate <SemanticGraph::Root> + Root; + + + // + // + // + struct TranslationRegion : Node<SemanticGraph::TranslationRegion> + { + virtual void + traverse (SemanticGraph::TranslationRegion&); + }; + + + // + // + // + struct TranslationUnit : Node<SemanticGraph::TranslationUnit> + { + virtual void + traverse (SemanticGraph::TranslationUnit&); + }; + + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_TRANSLATION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp new file mode 100644 index 00000000000..1e42505b5d7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/TypeId.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp new file mode 100644 index 00000000000..eb917dd69cb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/TypeId.hpp @@ -0,0 +1,34 @@ +// file : CCF/IDL2/Traversal/TypeId.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_TYPE_ID_HPP +#define CCF_IDL2_TRAVERSAL_TYPE_ID_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/TypeId.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + // Typeid and typeprefix are two idiotic constructs of IDL. + // They normally should not result in any directly generated + // code so only minimal (and most generic) support is provided. + // + + struct TypeId : Node<SemanticGraph::TypeId> + { + }; + + struct TypePrefix : Node<SemanticGraph::TypePrefix> + { + }; + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_TYPE_ID_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp new file mode 100644 index 00000000000..298ce90f759 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.cpp @@ -0,0 +1,16 @@ +// file : CCF/IDL2/Traversal/ValueType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/Traversal/ValueType.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp new file mode 100644 index 00000000000..f9d8264383d --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.hpp @@ -0,0 +1,18 @@ +// file : CCF/IDL2/Traversal/ValueType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP +#define CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP + +namespace CCF +{ + namespace IDL2 + { + namespace Traversal + { + } + } +} + +#endif // CCF_IDL2_TRAVERSAL_VALUE_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc b/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc new file mode 100644 index 00000000000..27e6e522200 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc @@ -0,0 +1,67 @@ +// $Id$ +project { + + staticname = IDL3 + + // @@ (diego) This hack is needed because MPC doesn't generate + // static-only projects for gnuace + verbatim(gnuace, top) { + static_libs_only = 1 + } + + includes += ../.. $(UTILITY_ROOT) $(BOOST_ROOT) + + Source_Files { + LexicalAnalyzer.cpp + Parser.cpp + SyntaxTree/Component.cpp + SyntaxTree/EventType.cpp + SyntaxTree/Home.cpp + SyntaxTree/Operation.cpp + Traversal/Component.cpp + Traversal/EventType.cpp + Traversal/Home.cpp + Traversal/Operation.cpp + } + + Header_Files { + SemanticAction/Impl/Component.hpp + SemanticAction/Impl/Consumes.hpp + SemanticAction/Impl/Elements.hpp + SemanticAction/Impl/Emits.hpp + SemanticAction/Impl/EventType.hpp + SemanticAction/Impl/Factory.hpp + SemanticAction/Impl/Home.hpp + SemanticAction/Impl/HomeFactory.hpp + SemanticAction/Impl/Include.hpp + SemanticAction/Impl/Provides.hpp + SemanticAction/Impl/Publishes.hpp + SemanticAction/Impl/Uses.hpp + SemanticAction/Component.hpp + SemanticAction/Consumes.hpp + SemanticAction/Elements.hpp + SemanticAction/Emits.hpp + SemanticAction/EventType.hpp + SemanticAction/Factory.hpp + SemanticAction/Home.hpp + SemanticAction/HomeFactory.hpp + SemanticAction/Provides.hpp + SemanticAction/Publishes.hpp + SemanticAction/Uses.hpp + LexicalAnalyzer.hpp + Parser.hpp + SemanticAction.hpp + SyntaxTree.hpp + Token.hpp + Traversal.hpp + SyntaxTree/Component.hpp + SyntaxTree/EventType.hpp + SyntaxTree/Home.hpp + SyntaxTree/Operation.hpp + Traversal/Component.hpp + Traversal/EventType.hpp + Traversal/Home.hpp + Traversal/Operation.hpp + } + +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj b/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj new file mode 100644 index 00000000000..830c457d898 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3.vcproj @@ -0,0 +1,557 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="7.10" + Name="IDL3" + ProjectGUID="{108D07F1-6364-4B51-87DB-AED8BBE6396A}" + Keyword="Win32Proj"> + <Platforms> + <Platform + Name="Win32"/> + </Platforms> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Debug" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + Optimization="0" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;_DEBUG;_LIB" + MinimalRebuild="TRUE" + BasicRuntimeChecks="3" + RuntimeLibrary="5" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="4"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL3.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(ProjectDir)" + IntermediateDirectory="$(ProjectDir)/Release" + ConfigurationType="4" + CharacterSet="2"> + <Tool + Name="VCCLCompilerTool" + AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355" + AdditionalIncludeDirectories="../.." + PreprocessorDefinitions="WIN32;NDEBUG;_LIB" + RuntimeLibrary="4" + DisableLanguageExtensions="FALSE" + ForceConformanceInForLoopScope="TRUE" + RuntimeTypeInfo="TRUE" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="FALSE" + DebugInformationFormat="3"/> + <Tool + Name="VCCustomBuildTool"/> + <Tool + Name="VCLibrarianTool" + OutputFile="$(OutDir)/IDL3.lib"/> + <Tool + Name="VCMIDLTool"/> + <Tool + Name="VCPostBuildEventTool"/> + <Tool + Name="VCPreBuildEventTool"/> + <Tool + Name="VCPreLinkEventTool"/> + <Tool + Name="VCResourceCompilerTool"/> + <Tool + Name="VCWebServiceProxyGeneratorTool"/> + <Tool + Name="VCXMLDataGeneratorTool"/> + <Tool + Name="VCManagedWrapperGeneratorTool"/> + <Tool + Name="VCAuxiliaryManagedWrapperGeneratorTool"/> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + <File + RelativePath=".\LexicalAnalyzer.cpp"> + </File> + <File + RelativePath=".\Parser.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> + <File + RelativePath=".\LexicalAnalyzer.hpp"> + </File> + <File + RelativePath=".\Parser.hpp"> + </File> + <File + RelativePath=".\SemanticAction.hpp"> + </File> + <File + RelativePath=".\SyntaxTree.hpp"> + </File> + <File + RelativePath=".\Token.hpp"> + </File> + <File + RelativePath=".\Traversal.hpp"> + </File> + </Filter> + <Filter + Name="SemanticAction" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Component.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Consumes.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Emits.hpp"> + </File> + <File + RelativePath=".\SemanticAction\EventType.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Home.hpp"> + </File> + <File + RelativePath=".\SemanticAction\HomeFactory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Provides.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Publishes.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Uses.hpp"> + </File> + </Filter> + <Filter + Name="Impl" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Component.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Consumes.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Emits.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\EventType.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Home.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\HomeFactory.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Include.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Provides.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Publishes.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SemanticAction\Impl\Uses.cpp"> + <FileConfiguration + Name="Debug|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + ExcludedFromBuild="TRUE"> + <Tool + Name="VCCLCompilerTool"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SemanticAction\Impl\Component.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Consumes.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Elements.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Emits.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\EventType.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Factory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Home.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\HomeFactory.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Include.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Provides.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Publishes.hpp"> + </File> + <File + RelativePath=".\SemanticAction\Impl\Uses.hpp"> + </File> + </Filter> + </Filter> + </Filter> + <Filter + Name="SyntaxTree" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\SyntaxTree\Component.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SyntaxTree\EventType.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SyntaxTree\Home.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\SyntaxTree\Operation.cpp"> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\SyntaxTree\Component.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\EventType.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Home.hpp"> + </File> + <File + RelativePath=".\SyntaxTree\Operation.hpp"> + </File> + </Filter> + </Filter> + <Filter + Name="Traversal" + Filter=""> + <Filter + Name="Source Files" + Filter=""> + <File + RelativePath=".\Traversal\Component.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\EventType.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Home.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)2.obj"/> + </FileConfiguration> + </File> + <File + RelativePath=".\Traversal\Operation.cpp"> + <FileConfiguration + Name="Debug|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32"> + <Tool + Name="VCCLCompilerTool" + ObjectFile="$(IntDir)/$(InputName)1.obj"/> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter=""> + <File + RelativePath=".\Traversal\Component.hpp"> + </File> + <File + RelativePath=".\Traversal\EventType.hpp"> + </File> + <File + RelativePath=".\Traversal\Home.hpp"> + </File> + <File + RelativePath=".\Traversal\Operation.hpp"> + </File> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp b/TAO/CIAO/CCF/CCF/IDL3/LexicalAnalyzer.cpp new file mode 100644 index 00000000000..333c7560d04 --- /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..d72cc6b11b4 --- /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..f0b683828a1 --- /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 := SemanticGraph SemanticAction Traversal +default_makefile_name := Makefile.alt + +Makefile.archive : SemanticGraph SemanticAction 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..177bb50136f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Makefile.archive @@ -0,0 +1,42 @@ +# 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 := SemanticGraph/Component.o \ + SemanticGraph/Elements.o \ + SemanticGraph/EventType.o \ + SemanticGraph/Home.o + +translated_units += SemanticAction/Impl/Component.o \ + SemanticAction/Impl/Consumes.o \ + SemanticAction/Impl/Emits.o \ + SemanticAction/Impl/EventType.o \ + SemanticAction/Impl/Factory.o \ + SemanticAction/Impl/Home.o \ + SemanticAction/Impl/HomeFactory.o \ + SemanticAction/Impl/Include.o \ + SemanticAction/Impl/Provides.o \ + SemanticAction/Impl/Publishes.o \ + SemanticAction/Impl/Uses.o + +translated_units += Traversal/Component.o \ + Traversal/EventType.o \ + Traversal/Home.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..663d7fc8bed --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Parser.cpp @@ -0,0 +1,366 @@ +// 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_def ( + f.component (), &SemanticAction::Component::begin_def), + + act_component_begin_fwd ( + f.component (), &SemanticAction::Component::begin_fwd), + + act_component_inherits ( + f.component (), &SemanticAction::Component::inherits), + + act_component_supports ( + f.component (), &SemanticAction::Component::supports), + + act_component_open_scope ( + f.component (), &SemanticAction::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_concrete_def ( + f.event_type (), &SemanticAction::EventType::begin_concrete_def), + + act_event_type_begin_concrete_fwd ( + f.event_type (), &SemanticAction::EventType::begin_concrete_fwd), + + act_event_type_inherits ( + f.event_type (), &SemanticAction::EventType::inherits), + + act_event_type_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_name ( + f.home_factory (), &SemanticAction::HomeFactory::name), + + act_home_factory_parameter ( + f.home_factory (), &SemanticAction::HomeFactory::parameter), + + act_home_factory_raises ( + f.home_factory (), &SemanticAction::HomeFactory::raises) + + { + IDL2::Parser::extension = + component_decl + | eventtype_decl + | home_decl + | extension + ; + + // + // Component + // + + component_decl = + COMPONENT + >> ( + ( + simple_identifier + >> SEMI + )[act_component_begin_fwd][act_component_end] + | + ( + ( + simple_identifier + >> COLON + )[act_component_begin_def] + >> component_inheritance_spec + >> !(SUPPORTS >> component_support_spec) + >> LBRACE[act_component_open_scope] + >> component_def_trailer + ) + | + ( + ( + simple_identifier + >> SUPPORTS + )[act_component_begin_def] + >> component_support_spec + >> LBRACE[act_component_open_scope] + >> component_def_trailer + ) + | + ( + ( + simple_identifier + >> LBRACE + )[act_component_begin_def][act_component_open_scope] + >> component_def_trailer + ) + + ) + ; + + component_def_trailer = + component_body + >> RBRACE[act_component_close_scope] + >> SEMI[act_component_end] + ; + + 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 + >> ( + ( + simple_identifier + >> SEMI[act_event_type_begin_concrete_fwd][act_event_type_end] + ) + | + ( + ( + simple_identifier + >> COLON + )[act_event_type_begin_concrete_def] + >> eventtype_inheritance_spec + >> LBRACE[act_event_type_open_scope] + >> eventtype_def_trailer + ) + | + ( + ( + simple_identifier + >> LBRACE + )[act_event_type_begin_concrete_def][act_event_type_open_scope] + >> eventtype_def_trailer + ) + ) + ; + + + eventtype_def_trailer = +// eventtype_body + RBRACE[act_event_type_close_scope] + >> SEMI[act_event_type_end] + ; + + //@@ inconsistent usage of eventype/event_type. + // + + 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_name] + >> LPAREN + >> home_factory_parameter_list + >> RPAREN + >> !(RAISES >> LPAREN >> home_factory_raises_list >> RPAREN) + >> SEMI + ; + + home_factory_parameter_list = + *( + home_factory_parameter + >> *(COMMA >> home_factory_parameter) + ) + ; + + home_factory_parameter = + IN + >> (identifier >> simple_identifier)[act_home_factory_parameter] + ; + + home_factory_raises_list = + identifier[act_home_factory_raises] + >> *(COMMA >> identifier[act_home_factory_raises]) + ; + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp b/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp new file mode 100644 index 00000000000..ce4b1b0a0fc --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Parser.hpp @@ -0,0 +1,204 @@ +// 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_def_trailer; + 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_def_trailer; + 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; + Rule home_factory_raises_list; + + + public: + Parser (CompilerElements::Context& context, + Diagnostic::Stream& dout, + LexicalAnalyzer const& l, + SemanticAction::Factory& f); + + protected: + // Component + // + OneArgAction<SimpleIdentifierPtr, SemanticAction::Component> + act_component_begin_def, act_component_begin_fwd; + + OneArgAction<IdentifierPtr, SemanticAction::Component> + act_component_inherits; + + OneArgAction<IdentifierPtr, SemanticAction::Component> + act_component_supports; + + ScopeAction + act_component_open_scope; + + ScopeAction + act_component_close_scope; + + NoArgAction<SemanticAction::Component> + act_component_end; + + // Provides + // + OneArgAction<IdentifierPtr, SemanticAction::Provides> + act_provides_type; + + OneArgAction<SimpleIdentifierPtr, SemanticAction::Provides> + act_provides_name; + + // Uses + // + 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_concrete_def, act_event_type_begin_concrete_fwd; + + 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_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::HomeFactory> + act_home_factory_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::HomeFactory> + act_home_factory_raises; + + }; + } +} + +#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..f5ea0a1509c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction.hpp @@ -0,0 +1,24 @@ +// file : CCF/IDL3/SemanticAction.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_HPP +#define CCF_IDL3_SEMANTIC_ACTION_HPP + +#include "CCF/IDL2/SemanticAction.hpp" + +#include "CCF/IDL3/SemanticAction/Elements.hpp" + +#include "CCF/IDL3/SemanticAction/Component.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/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" + +#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..7d0c8b0020a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Component.hpp @@ -0,0 +1,41 @@ +// 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_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_fwd (SimpleIdentifierPtr const& id) = 0; + + virtual void + inherits (IdentifierPtr const& id) = 0; + + virtual void + supports (IdentifierPtr const& id) = 0; + + virtual void + 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..b6a136ca49b --- /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..7637a0c473c --- /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..10fade5ec04 --- /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..bf9ffc93a5c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/EventType.hpp @@ -0,0 +1,38 @@ +// 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_concrete_def (SimpleIdentifierPtr const& id) = 0; + + virtual void + begin_concrete_fwd (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..34feee84ccf --- /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..782e84bb565 --- /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..2f64a4e3c6b --- /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 + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_HOME_FACTORY_HPP diff --git a/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..f812d55f316 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp @@ -0,0 +1,189 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Component:: + ~Component () throw () + { + } + + Component:: + Component (Context& c) + : ScopeBase<SemanticGraph::Component> (c) + { + } + + void Component:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Component:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Component:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + ctx.tu ().new_edge<Inherits> ( + now (), + resolve<SemanticGraph::Component> (from, name, defined)); + } + catch (Resolve const&) + { + cerr << "error: invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to inherit from forward-declared component " + << e.name () << endl; + cerr << "inheritance from forward-declared component is illegal" + << endl; + } + } + + void Component:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + } + catch (Resolve const&) + { + cerr << "error: invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to support from forward-declared component " + << e.name () << endl; + cerr << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + //@@ Implementation of *_scope is the same for all cases. + // + void Component:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Component:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Component:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..238cda2cb2f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp @@ -0,0 +1,55 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Component : public virtual SemanticAction::Component, + public virtual ScopeBase<SemanticGraph::Component> + { + public: + virtual + ~Component () throw (); + + Component (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP diff --git a/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..c220a571c84 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp @@ -0,0 +1,87 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Consumes:: + ~Consumes () throw () + { + } + + Consumes:: + Consumes (Context& c) + : Base (c) + { + } + + void Consumes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "consumes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid consumes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + cerr << "using non-eventtype in consumes declaration is illegal" + << endl; + } + } + + void Consumes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Consumer& c (ctx.tu ().new_node<Consumer> ()); + + ctx.tu ().new_edge<Belongs> (c, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), c, id->lexeme ()); + } + } + } + } + } +} 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..c047dec2753 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Consumes : public virtual SemanticAction::Consumes, + public Base + { + public: + virtual + ~Consumes () throw (); + + Consumes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP diff --git a/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..9adec23d1c5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,29 @@ +// 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::Context; + using IDL2::SemanticAction::Impl::Base; + using IDL2::SemanticAction::Impl::ScopeBase; + + using IDL2::SemanticAction::Impl::lookup; + + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/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..7f9711a113f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp @@ -0,0 +1,87 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Emits:: + ~Emits () throw () + { + } + + Emits:: + Emits (Context& c) + : Base (c) + { + } + + void Emits:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "emits " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid emits declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + cerr << "using non-eventtype in emits declaration is illegal" + << endl; + } + } + + void Emits:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Emitter& e (ctx.tu ().new_node<Emitter> ()); + + ctx.tu ().new_edge<Belongs> (e, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), e, id->lexeme ()); + } + } + } + } + } +} 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..65580d6bc41 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Emits : public virtual SemanticAction::Emits, + public Base + { + public: + virtual + ~Emits () throw (); + + Emits (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP diff --git a/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..faf36555923 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp @@ -0,0 +1,104 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + EventType:: + ~EventType () throw () + { + } + + EventType:: + EventType (Context& c) + : ScopeBase<SemanticGraph::EventType> (c) + { + } + + void EventType:: + begin_concrete_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete eventtype def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void EventType:: + begin_concrete_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete eventtype fwd" << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ()); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void EventType:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + } + + void EventType:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void EventType:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void EventType:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + } + } + } +} diff --git a/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..f3676561e54 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp @@ -0,0 +1,55 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class EventType : public virtual SemanticAction::EventType, + public virtual ScopeBase<SemanticGraph::EventType> + { + public: + virtual + ~EventType () throw (); + + EventType (Context& c); + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP diff --git a/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..bc5a0f7b624 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,41 @@ +// file : CCF/IDL3/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + + Factory:: + ~Factory () throw () {} + + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : IDL2::SemanticAction::Impl::Factory (context, dout, tu), + + component_ (ctx_), + consumes_ (ctx_), + emits_ (ctx_), + event_type_ (ctx_), + home_ (ctx_), + home_factory_ (ctx_), + include_ (ctx_, context, dout, *this), + provides_ (ctx_), + publishes_ (ctx_), + system_include_ (ctx_, context, dout, *this), + uses_ (ctx_) + { + } + } + } + } +} 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..7fd2cbcb871 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,133 @@ +// 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 (); + + //@@ there is no more separate tracing options + // + + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + public: + virtual SemanticAction::Consumes& + consumes () + { + return consumes_; + } + + virtual SemanticAction::Component& + component () + { + return component_; + } + + virtual SemanticAction::Emits& + emits () + { + return emits_; + } + + + virtual SemanticAction::EventType& + event_type () + { + return event_type_; + } + + virtual SemanticAction::Home& + home () + { + return home_; + } + + virtual SemanticAction::HomeFactory& + home_factory () + { + return home_factory_; + } + + + virtual IDL2::SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Provides& + provides () + { + return provides_; + } + + virtual SemanticAction::Publishes& + publishes () + { + return publishes_; + } + + virtual IDL2::SemanticAction::SystemInclude& + system_include () + { + return system_include_; + } + + virtual SemanticAction::Uses& + uses () + { + return uses_; + } + + private: + + Component component_; + Consumes consumes_; + Emits emits_; + EventType event_type_; + Home home_; + HomeFactory home_factory_; + Include include_; + Provides provides_; + Publishes publishes_; + SystemInclude system_include_; + Uses uses_; + }; + } + } + } +} + +#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..f06be80b428 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp @@ -0,0 +1,212 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Home:: + ~Home () throw () + { + } + + Home:: + Home (Context& c) + : ScopeBase<SemanticGraph::Home> (c) + { + } + + void Home:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "home " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Home&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Home> ()); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + + void Home:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + ctx.tu ().new_edge<Inherits> ( + now (), + resolve<SemanticGraph::Home> (from, name, defined)); + } + catch (Resolve const&) + { + cerr << "error: invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no home with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to inherit from forward-declared home " + << e.name () << endl; + cerr << "inheritance from forward-declared home is illegal" + << endl; + } + } + + + void Home:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + } + catch (Resolve const&) + { + cerr << "error: invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to support from forward-declared component " + << e.name () << endl; + cerr << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + + void Home:: + manages (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "manages " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + ctx.tu ().new_edge<Manages> ( + now (), + resolve<SemanticGraph::Component> (from, name, defined)); + } + catch (Resolve const&) + { + cerr << "error: invalid manages specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "incompatible type in manages specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to manage forward-declared component " + << e.name () << endl; + cerr << "management of forward-declared component is illegal" + << endl; + } + } + + void Home:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Home:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Home:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/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..fae16eef5cb --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp @@ -0,0 +1,58 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class Home : public virtual SemanticAction::Home, + public virtual ScopeBase<SemanticGraph::Home> + { + public: + virtual + ~Home () throw (); + + Home (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + manages (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP diff --git a/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..62311451c5e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp @@ -0,0 +1,148 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeFactory:: + ~HomeFactory () throw () + { + } + + HomeFactory:: + HomeFactory (Context& c) + : Base (c) + { + } + + void HomeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + hf_ = 0; + + SemanticGraph::Home& h ( + dynamic_cast<SemanticGraph::Home&>(ctx.scope ())); + + SemanticGraph::Component& c ( + dynamic_cast<SemanticGraph::Component&>(h.manages ().managee ())); + + SimpleName name (id->lexeme ()); + + hf_ = &ctx.tu ().new_node<SemanticGraph::HomeFactory> (); + + ctx.tu ().new_edge<Returns> (*hf_, c); + ctx.tu ().new_edge<Defines> (ctx.scope (), *hf_, name); + } + + + void HomeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (hf_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> (name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*hf_, p); + } + catch (Resolve const&) + { + cerr << "error: invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void HomeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (hf_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*hf_, e); + } + catch (Resolve const&) + { + cerr << "error: invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + cerr << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} 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..75dc95cfda6 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp @@ -0,0 +1,50 @@ +// 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/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL3/SemanticAction/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // + // + // + class HomeFactory : public virtual SemanticAction::HomeFactory, + public Base + { + public: + virtual + ~HomeFactory () throw (); + + HomeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::HomeFactory* hf_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP diff --git a/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..7c1c98a2728 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp @@ -0,0 +1,272 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/Parser.hpp" + +#include <vector> +#include <string> +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + // IncludeImpl + // + // + IncludeImpl:: + ~IncludeImpl () throw () + { + } + + IncludeImpl:: + IncludeImpl (Context& c, + CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory, + Type type) + : ctx (c), + context_ (context), + dout_ (dout), + action_factory_ (action_factory), + type_ (type) + { + abs_path_stack_.push ( + fs::normalize ( + fs::complete (context_.get<fs::path> ("file-path")))); + } + + void IncludeImpl:: + begin_impl (StringLiteralPtr const& sl) + { + std::string prefix; + + if (type_ == user) + { + prefix = std::string ("include") + " \"" + sl->value () + "\""; + } + else + { + prefix = std::string ("include") + " <" + sl->value () + ">"; + } + + if (ctx.trace ()) cerr << prefix << endl; + + try + { + fs::ifstream ifs; + ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); + + fs::path include_path (sl->value ()); + fs::path complete_path (include_path); + + if (ctx.trace ()) cerr << prefix << ": staring resolution." + << endl; + + if (complete_path.is_complete ()) + { + complete_path = fs::normalize (complete_path); + + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + } + else + { + bool found (false); + + if (type_ == user) + { + fs::path rel_path (abs_path_stack_.top ().branch_path ()); + + complete_path = fs::normalize (rel_path / include_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + typedef std::vector<fs::path> SearchPaths; + + SearchPaths const& search_paths ( + context_.get<SearchPaths> ("include-search-paths")); + + for (SearchPaths::const_iterator + i (search_paths.begin ()), + e (search_paths.end ()); i != e && !found; ++i) + { + complete_path = *i / include_path; + + if (!complete_path.is_complete ()) + { + complete_path = complete (complete_path); + } + + complete_path = fs::normalize (complete_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + cerr << sl << ": error: file not found." << endl; + return; + } + } + } + + if (ctx.trace ()) cerr << prefix << ": resolved to " + << complete_path.string () << endl; + + //@@ for some reason ifs throws exception if I don't reset it + // to original state. It probably has something to do with + // call to get after eof. + // + ifs.exceptions (std::ios_base::iostate (0)); + + TranslationRegion& r (ctx.tu() .new_node<TranslationRegion> ()); + + if (type_ == user) + { + ctx.tu ().new_edge<QuoteIncludes> ( + ctx.region (), r, include_path); + } + else + { + ctx.tu ().new_edge<BracketIncludes> ( + ctx.region (), r, include_path); + } + + // Set new current region. + // + stack_.push (&ctx.region ()); + ctx.region (r); + + // Create Root scope for new region. + // + Root& root (ctx.tu ().new_node<Root> ()); + ctx.tu ().new_edge<ContainsRoot> (r, root); + ctx.scope (root); + + // Store previous relative path and current absolute. + // + rel_path_stack_.push (context_.get<fs::path> ("file-path")); + context_.set("file-path", include_path); + + abs_path_stack_.push (complete_path); + + + // Parse the file. + // + // + + //@@ 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 ()); + } + + // Restore paths + // + abs_path_stack_.pop (); + + context_.set("file-path", rel_path_stack_.top ()); + rel_path_stack_.pop (); + + + // Restore region. + // + ctx.region (*stack_.top ()); + stack_.pop (); + + // Create new Root scope. + // + { + Root& root (ctx.tu ().new_node<Root> ()); + ctx.tu ().new_edge<ContainsRoot> (ctx.region (), root); + ctx.scope (root); + } + } + catch (fs::filesystem_error const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + catch (std::ios_base::failure const&) + { + cerr << sl << ": error: unable to open in read mode" << endl; + } + } + + void IncludeImpl:: + end_impl () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + bool IncludeImpl:: + handle_already_included (fs::path const& path, + StringLiteralPtr const& sl) + { + if(!include_file_set_.insert (path).second) + { + cerr << "warning: skipping already included file " << sl + << endl; + return true; + } + return false; + } + } + } + } +} 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..0bc4a631986 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp @@ -0,0 +1,167 @@ +// 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 <stack> +#include <set> + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL3/SemanticAction/Elements.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // Note: overriding IDL2 include to allow inclusion of IDL3 files + // + // + class IncludeImpl + { + protected: + virtual + ~IncludeImpl () throw (); + + enum Type + { + system, + user + }; + + IncludeImpl (Context& c, + CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory, + Type type); + + virtual void + begin_impl (StringLiteralPtr const& sl); + + virtual void + end_impl (); + + private: + bool + handle_already_included (fs::path const& path, + StringLiteralPtr const& sl); + private: + Context& ctx; + + CompilerElements::Context& context_; + Diagnostic::Stream& dout_; + SemanticAction::Factory& action_factory_; + + Type type_; + + std::stack<SemanticGraph::TranslationRegion*> stack_; + std::stack<fs::path> abs_path_stack_, rel_path_stack_; + + struct FilePathComparator + { + bool operator () (fs::path const& x, fs::path const& y) const + { + return x.string () < y.string (); + } + }; + + std::set<fs::path, FilePathComparator> include_file_set_; + }; + + + // + // + // + struct Include : virtual IDL2::SemanticAction::Include, IncludeImpl + { + virtual + ~Include () throw () + { + } + + Include (Context& c, + CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory) + : IncludeImpl (c, + context, + dout, + action_factory, + IncludeImpl::user) + { + } + + virtual void + begin (StringLiteralPtr const& sl) + { + begin_impl (sl); + } + + virtual void + end () + { + end_impl (); + } + }; + + // + // + // + struct SystemInclude : virtual IDL2::SemanticAction::SystemInclude, + IncludeImpl + { + virtual + ~SystemInclude () throw () + { + } + + SystemInclude (Context& c, + CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory) + : IncludeImpl (c, + context, + dout, + action_factory, + IncludeImpl::system) + { + } + + virtual void + begin (StringLiteralPtr const& sl) + { + //@@ This is a really dirty hack. Need to think of + // a mechanism to address this issue. + // + if (sl->value () != "Components.idl") + { + begin_impl (sl); + } + } + + virtual void + end () + { + end_impl (); + } + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Makefile.alt new file mode 100644 index 00000000000..86e6bca9548 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Makefile.alt @@ -0,0 +1,31 @@ +# file : CCF/IDL3/SemanticAction/Impl/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) + +# Factory.cpp + +cxx_translation_units := Component.cpp \ + Consumes.cpp \ + Elements.cpp \ + Emits.cpp \ + EventType.cpp \ + Factory.cpp \ + Home.cpp \ + HomeFactory.cpp \ + Include.cpp \ + Provides.cpp \ + Publishes.cpp \ + Uses.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/SemanticAction/Impl/Provides.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp new file mode 100644 index 00000000000..f5b5b083d16 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp @@ -0,0 +1,87 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Provides:: + ~Provides () throw () + { + } + + Provides:: + Provides (Context& c) + : Base (c) + { + } + + void Provides:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "provides " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid provides declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + cerr << "using non-interface type in provides declaration is " + << "illegal" << endl; + } + } + + void Provides:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Provider& p (ctx.tu ().new_node<Provider> ()); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} 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..e818b049cc5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Provides : public virtual SemanticAction::Provides, + public Base + { + public: + virtual + ~Provides () throw (); + + Provides (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP diff --git a/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..227836ea8ec --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp @@ -0,0 +1,87 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Publishes:: + ~Publishes () throw () + { + } + + Publishes:: + Publishes (Context& c) + : Base (c) + { + } + + void Publishes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "publishes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid publishes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + cerr << "using non-eventtype in publishes declaration is illegal" + << endl; + } + } + + void Publishes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Publisher& p (ctx.tu ().new_node<Publisher> ()); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} 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..bf19b938d54 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Publishes : public virtual SemanticAction::Publishes, + public Base + { + public: + virtual + ~Publishes () throw (); + + Publishes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP diff --git a/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..ee51de66c36 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp @@ -0,0 +1,87 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Uses:: + ~Uses () throw () + { + } + + Uses:: + Uses (Context& c) + : Base (c) + { + } + + void Uses:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "uses " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << "error: invalid uses declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const& e) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + cerr << "using non-interface type in uses declaration is " + << "illegal" << endl; + } + } + + void Uses:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + User& u (ctx.tu ().new_node<User> ()); + + ctx.tu ().new_edge<Belongs> (u, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), u, id->lexeme ()); + } + } + } + } + } +} 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..54c2884767f --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Uses.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + class Uses : public virtual SemanticAction::Uses, + public Base + { + public: + virtual + ~Uses () throw (); + + Uses (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Makefile.alt new file mode 100644 index 00000000000..0e79c8593b1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Makefile.alt @@ -0,0 +1,17 @@ +# file : CCF/IDL3/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/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := Impl +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) 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..e32fcdab84e --- /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..1ce9898ffe5 --- /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..867d6495c55 --- /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/SemanticGraph.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp new file mode 100644 index 00000000000..9192ca3b04c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph.hpp @@ -0,0 +1,16 @@ +// file : CCF/IDL3/SemanticGraph.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_HPP + +#include "CCF/IDL2/SemanticGraph.hpp" + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +#endif // CCF_IDL3_SEMANTIC_GRAPH_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp new file mode 100644 index 00000000000..04840089c69 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.cpp @@ -0,0 +1,143 @@ +// file : CCF/IDL3/SemanticGraph/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticGraph/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Provider + // + // + namespace + { + TypeInfo + provider_init_ () + { + TypeInfo ti (typeid (Provider)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo provider_ (provider_init_ ()); + } + + TypeInfo const& Provider:: + static_type_info () { return provider_; } + + + // User + // + // + namespace + { + TypeInfo + user_init_ () + { + TypeInfo ti (typeid (User)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo user_ (user_init_ ()); + } + + TypeInfo const& User:: + static_type_info () { return user_; } + + + // Publisher + // + // + namespace + { + TypeInfo + publisher_init_ () + { + TypeInfo ti (typeid (Publisher)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo publisher_ (publisher_init_ ()); + } + + TypeInfo const& Publisher:: + static_type_info () { return publisher_; } + + + // Emitter + // + // + namespace + { + TypeInfo + emitter_init_ () + { + TypeInfo ti (typeid (Emitter)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo emitter_ (emitter_init_ ()); + } + + TypeInfo const& Emitter:: + static_type_info () { return emitter_; } + + + // Consumer + // + // + namespace + { + TypeInfo + consumer_init_ () + { + TypeInfo ti (typeid (Consumer)); + ti.add_base (Access::PUBLIC, true, Nameable::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Instance::static_type_info ()); + return ti; + } + + TypeInfo consumer_ (consumer_init_ ()); + } + + TypeInfo const& Consumer:: + static_type_info () { return consumer_; } + + + // Component + // + // + namespace + { + TypeInfo + component_init_ () + { + TypeInfo ti (typeid (Component)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo component_ (component_init_ ()); + } + + TypeInfo const& Component:: + static_type_info () { return component_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp new file mode 100644 index 00000000000..09e2409417e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Component.hpp @@ -0,0 +1,195 @@ +// file : CCF/IDL3/SemanticGraph/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class Provider : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Provider () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class User : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + User () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Publisher : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Publisher () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Emitter : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Emitter () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Consumer : public virtual Nameable, public virtual Instance + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Consumer () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class Component : public virtual Type, public virtual Scope + { + typedef + std::vector <Supports*> + Supports_; + + public: + Inherits* + inherits () + { + return inherits_; + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Component () + : inherits_ (0) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_ = &e; + } + + void + add_edge_right (Inherits& e) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + void + add_edge_right (Manages& e) + { + } + + private: + Inherits* inherits_; + Supports_ supports_; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp new file mode 100644 index 00000000000..84fef39d7d0 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.cpp @@ -0,0 +1,37 @@ +// file : CCF/IDL3/SemanticGraph/Elements.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Manages + // + // + namespace + { + TypeInfo + manages_init_ () + { + TypeInfo ti (typeid (Manages)); + ti.add_base (Access::PUBLIC, true, Edge::static_type_info ()); + return ti; + } + + TypeInfo manages_ (manages_init_ ()); + } + + TypeInfo const& Manages:: + static_type_info () { return manages_; } + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp new file mode 100644 index 00000000000..b6577b6ff2e --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Elements.hpp @@ -0,0 +1,67 @@ +// file : CCF/IDL3/SemanticGraph/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP + +#include "CCF/IDL2/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using namespace CCF::IDL2::SemanticGraph; + + // + // + // + class Manages : public virtual Edge + { + public: + Node& + manager () const + { + return *manager_; + } + + Node& + managee () const + { + return *managee_; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Manages () + { + type_info (static_type_info ()); + } + + void + set_left_node (Node& n) + { + manager_ = &n; + } + + void + set_right_node (Node& n) + { + managee_ = &n; + } + + private: + Node* manager_; + Node* managee_; + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp new file mode 100644 index 00000000000..024069800c7 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.cpp @@ -0,0 +1,81 @@ +// file : CCF/IDL3/SemanticGraph/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + + // EventType + // + // + namespace + { + TypeInfo + event_type_init_ () + { + TypeInfo ti (typeid (EventType)); + ti.add_base (Access::PUBLIC, true, ValueType::static_type_info ()); + return ti; + } + + TypeInfo event_type_ (event_type_init_ ()); + } + + TypeInfo const& EventType:: + static_type_info () { return event_type_; } + + + // AbstractEventType + // + // + namespace + { + TypeInfo + abstract_event_type_init_ () + { + TypeInfo ti (typeid (AbstractEventType)); + ti.add_base (Access::PUBLIC, true, EventType::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, AbstractValueType::static_type_info ()); + return ti; + } + + TypeInfo abstract_event_type_ (abstract_event_type_init_ ()); + } + + TypeInfo const& AbstractEventType:: + static_type_info () { return abstract_event_type_; } + + + // ConcreteEventType + // + // + namespace + { + TypeInfo + concrete_event_type_init_ () + { + TypeInfo ti (typeid (ConcreteEventType)); + ti.add_base (Access::PUBLIC, true, EventType::static_type_info ()); + ti.add_base ( + Access::PUBLIC, true, ConcreteValueType::static_type_info ()); + return ti; + } + + TypeInfo concrete_event_type_ (concrete_event_type_init_ ()); + } + + TypeInfo const& ConcreteEventType:: + static_type_info () { return concrete_event_type_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp new file mode 100644 index 00000000000..d2c352fda80 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/EventType.hpp @@ -0,0 +1,78 @@ +// file : CCF/IDL3/SemanticGraph/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class EventType : public virtual ValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + EventType () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class AbstractEventType : public virtual EventType, + public virtual AbstractValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + AbstractEventType () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class ConcreteEventType : public virtual EventType, + public virtual ConcreteValueType + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + ConcreteEventType () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp new file mode 100644 index 00000000000..e423cec35b5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.cpp @@ -0,0 +1,77 @@ +// file : CCF/IDL3/SemanticGraph/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + using Introspection::TypeInfo; + using Introspection::Access; + + // Home + // + // + namespace + { + TypeInfo + home_init_ () + { + TypeInfo ti (typeid (Home)); + ti.add_base (Access::PUBLIC, true, Type::static_type_info ()); + ti.add_base (Access::PUBLIC, true, Scope::static_type_info ()); + return ti; + } + + TypeInfo home_ (home_init_ ()); + } + + TypeInfo const& Home:: + static_type_info () { return home_; } + + + // HomeFactory + // + // + namespace + { + TypeInfo + home_factory_init_ () + { + TypeInfo ti (typeid (HomeFactory)); + ti.add_base (Access::PUBLIC, true, Operation::static_type_info ()); + return ti; + } + + TypeInfo home_factory_ (home_factory_init_ ()); + } + + TypeInfo const& HomeFactory:: + static_type_info () { return home_factory_; } + + + // HomeFinder + // + // + namespace + { + TypeInfo + home_finder_init_ () + { + TypeInfo ti (typeid (HomeFinder)); + ti.add_base (Access::PUBLIC, true, Operation::static_type_info ()); + return ti; + } + + TypeInfo home_finder_ (home_finder_init_ ()); + } + + TypeInfo const& HomeFinder:: + static_type_info () { return home_finder_; } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp new file mode 100644 index 00000000000..27b98bcdbd1 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Home.hpp @@ -0,0 +1,147 @@ +// file : CCF/IDL3/SemanticGraph/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP +#define CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP + +#include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" +#include "CCF/IDL3/SemanticGraph/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticGraph + { + // + // + // + class Home : public virtual Type, public virtual Scope + { + typedef + std::vector <Supports*> + Supports_; + + public: + Manages& + manages () + { + return *manages_; + } + + Inherits* + inherits () + { + return inherits_; + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + + virtual bool + complete () const + { + return true; + } + + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + Home () + : inherits_ (0) + { + type_info (static_type_info ()); + } + + using Type::add_edge_right; + using Scope::add_edge_left; + + void + add_edge_left (Manages& e) + { + manages_ = &e; + } + + void + add_edge_left (Inherits& e) + { + inherits_ = &e; + } + + void + add_edge_right (Inherits& e) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + private: + Manages* manages_; + Inherits* inherits_; + Supports_ supports_; + }; + + + // + // + // + class HomeFactory : public virtual Operation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeFactory () + { + type_info (static_type_info ()); + } + }; + + + // + // + // + class HomeFinder : public virtual Operation + { + public: + static Introspection::TypeInfo const& + static_type_info (); + + protected: + friend class Graph<Node, Edge>; + + HomeFinder () + { + type_info (static_type_info ()); + } + }; + } + } +} + +#endif // CCF_IDL3_SEMANTIC_GRAPH_HOME_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Makefile.alt b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Makefile.alt new file mode 100644 index 00000000000..6a08fb4cc84 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticGraph/Makefile.alt @@ -0,0 +1,21 @@ +# file : CCF/IDL3/SemanticGraph/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 \ + Elements.cpp \ + EventType.cpp \ + Home.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/Token.hpp b/TAO/CIAO/CCF/CCF/IDL3/Token.hpp new file mode 100644 index 00000000000..4a18aae6f13 --- /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..aa83bd51156 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal.hpp @@ -0,0 +1,16 @@ +// file : CCF/IDL3/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_HPP +#define CCF_IDL3_TRAVERSAL_HPP + +#include "CCF/IDL2/Traversal.hpp" + +#include "CCF/IDL3/Traversal/Elements.hpp" + +#include "CCF/IDL3/Traversal/Component.hpp" +#include "CCF/IDL3/Traversal/EventType.hpp" +#include "CCF/IDL3/Traversal/Home.hpp" + +#endif // CCF_IDL3_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp new file mode 100644 index 00000000000..1519650415c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.cpp @@ -0,0 +1,128 @@ +// file : CCF/IDL3/Traversal/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" + +#include "CCF/IDL3/Traversal/Component.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // Component + // + // + void Component:: + traverse (Type& c) + { + pre (c); + name (c); + inherits (c); + supports (c); + names (c); + post (c); + } + + void Component:: + pre (Type&) + { + } + + void Component:: + name (Type&) + { + } + + void Component:: + inherits (Type& c, EdgeDispatcherBase& d) + { + if (SemanticGraph::Inherits* inh = c.inherits ()) + { + d.traverse (*inh); + } + } + + void Component:: + inherits (Type& c) + { + if (SemanticGraph::Inherits* inh = c.inherits ()) + { + inherits_pre (c); + edge_traverser ().traverse (*inh); + inherits_post (c); + } + else + { + inherits_none (c); + } + } + + void Component:: + inherits_pre (Type&) + { + } + + void Component:: + inherits_post (Type&) + { + } + + void Component:: + inherits_none (Type&) + { + } + + void Component:: + supports (Type& c, EdgeDispatcherBase& d) + { + iterate_and_traverse (c.supports_begin (), c.supports_end (), d); + } + + void Component:: + supports (Type& c) + { + Type::SupportsIterator b (c.supports_begin ()), e (c.supports_end ()); + + if (b != e) + { + supports_pre (c); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &Component::comma, c); + supports_post (c); + } + else + { + supports_none (c); + } + } + + void Component:: + supports_pre (Type&) + { + } + + void Component:: + supports_post (Type&) + { + } + + void Component:: + supports_none (Type&) + { + } + + void Component:: + post (Type&) + { + } + + void Component:: + comma (Type&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp new file mode 100644 index 00000000000..58f60acfdfe --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.hpp @@ -0,0 +1,259 @@ +// file : CCF/IDL3/Traversal/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_COMPONENT_HPP +#define CCF_IDL3_TRAVERSAL_COMPONENT_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + struct PortTemplate : Node<T> + { + virtual void + traverse (T&); + }; + + template <typename T> + struct PortAccessorTemplate : Node<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + returns (T&, EdgeDispatcherBase&); + + virtual void + returns (T&); + + virtual void + name (T&); + + virtual void + receives (T&, EdgeDispatcherBase&); + + virtual void + receives (T&); + + virtual void + receives_pre (T&); + + virtual void + receives_post (T&); + + virtual void + raises (T&, EdgeDispatcherBase&); + + virtual void + raises (T&); + + virtual void + raises_pre (T&); + + virtual void + raises_post (T&); + + virtual void + post (T&); + }; + + template <typename T> + struct PortGetTemplate : PortAccessorTemplate<T> + { + virtual void + returns (T&); + }; + + template <typename T> + struct PortSetTemplate : PortAccessorTemplate<T> + { + virtual void + receives (T&); + }; + + template <typename T> + struct PortDataTemplate : Node<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + belongs (T&, EdgeDispatcherBase&); + + virtual void + belongs (T&); + + virtual void + name (T&); + + virtual void + post (T&); + }; + + // + // + // + typedef + PortTemplate<SemanticGraph::Provider> + Provider; + + typedef + PortGetTemplate<SemanticGraph::Provider> + ProviderGet; + + typedef + PortSetTemplate<SemanticGraph::Provider> + ProviderSet; + + typedef + PortDataTemplate<SemanticGraph::Provider> + ProviderData; + + // + // + // + typedef + PortTemplate<SemanticGraph::User> + User; + + typedef + PortGetTemplate<SemanticGraph::User> + UserGet; + + typedef + PortSetTemplate<SemanticGraph::User> + UserSet; + + typedef + PortDataTemplate<SemanticGraph::User> + UserData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::Publisher> + Publisher; + + typedef + PortGetTemplate<SemanticGraph::Publisher> + PublisherGet; + + typedef + PortSetTemplate<SemanticGraph::Publisher> + PublisherSet; + + typedef + PortDataTemplate<SemanticGraph::Publisher> + PublisherData; + + // + // + // + typedef + PortTemplate<SemanticGraph::Emitter> + Emitter; + + typedef + PortGetTemplate<SemanticGraph::Emitter> + EmitterGet; + + typedef + PortSetTemplate<SemanticGraph::Emitter> + EmitterSet; + + typedef + PortDataTemplate<SemanticGraph::Emitter> + EmitterData; + + + // + // + // + typedef + PortTemplate<SemanticGraph::Consumer> + Consumer; + + typedef + PortGetTemplate<SemanticGraph::Consumer> + ConsumerGet; + + typedef + PortSetTemplate<SemanticGraph::Consumer> + ConsumerSet; + + typedef + PortDataTemplate<SemanticGraph::Consumer> + ConsumerData; + + // + // + // + struct Component : ScopeTemplate<SemanticGraph::Component> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&, EdgeDispatcherBase&); + + virtual void + inherits (Type&); + + virtual void + inherits_pre (Type&); + + virtual void + inherits_post (Type&); + + virtual void + inherits_none (Type&); + + virtual void + supports (Type&, EdgeDispatcherBase&); + + virtual void + supports (Type&); + + virtual void + supports_pre (Type&); + + virtual void + supports_post (Type&); + + virtual void + supports_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + } + } +} + +#include "CCF/IDL3/Traversal/Component.tpp" + +#endif // CCF_IDL3_TRAVERSAL_COMPONENT_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp new file mode 100644 index 00000000000..b6d96da7d0a --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Component.tpp @@ -0,0 +1,195 @@ +// file : CCF/IDL3/Traversal/Component.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // + // + // + template <typename T> + void PortTemplate<T>:: + traverse (T& p) + { + edge_traverser ().traverse (p.belongs ()); + } + + + // PortAccessorTemplate + // + // + template <typename T> + void PortAccessorTemplate<T>:: + traverse (T& p) + { + pre (p); + returns (p); + name (p); + receives (p); + raises (p); + post (p); + } + + template <typename T> + void PortAccessorTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + returns (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template <typename T> + void PortAccessorTemplate<T>:: + returns (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + name (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives (T& p, EdgeDispatcherBase& d) + { + // @@ Still thinking about the way of making + // fake parameter. + // + d.traverse (p.belongs ()); + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives (T& p) + { + receives_pre (p); + receives_post (p); + + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives_pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + receives_post (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises (T&, EdgeDispatcherBase&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises (T& p) + { + raises_pre (p); + raises_post (p); + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises_pre (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + raises_post (T&) + { + } + + template <typename T> + void PortAccessorTemplate<T>:: + post (T&) + { + } + + // PortGetTemplate + // + // + template <typename T> + void PortGetTemplate<T>:: + returns (T& p) + { + PortAccessorTemplate<T>::returns (p, edge_traverser ()); + } + + + // PortSetTemplate + // + // + template <typename T> + void PortSetTemplate<T>:: + receives (T& p) + { + receives_pre (p); + PortAccessorTemplate<T>::receives (p, edge_traverser ()); + receives_post (p); + } + + + // PortDataTemplate + // + // + template <typename T> + void PortDataTemplate<T>:: + traverse (T& p) + { + pre (p); + belongs (p); + name (p); + post (p); + } + + template <typename T> + void PortDataTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void PortDataTemplate<T>:: + belongs (T& p, EdgeDispatcherBase& d) + { + d.traverse (p.belongs ()); + } + + template <typename T> + void PortDataTemplate<T>:: + belongs (T& p) + { + belongs (p, edge_traverser ()); + } + + template <typename T> + void PortDataTemplate<T>:: + name (T&) + { + } + + template <typename T> + void PortDataTemplate<T>:: + post (T&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp new file mode 100644 index 00000000000..b92c5cf70fd --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Elements.hpp @@ -0,0 +1,21 @@ +// file : CCF/IDL3/Traversal/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_ELEMENTS_HPP +#define CCF_IDL3_TRAVERSAL_ELEMENTS_HPP + +#include "CCF/IDL2/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + using namespace IDL2::Traversal; + } + } +} + +#endif // CCF_IDL3_TRAVERSAL_ELEMENTS_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp new file mode 100644 index 00000000000..4461c95ef18 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.cpp @@ -0,0 +1,15 @@ +// 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 + { + } + } +} 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..4eab9a361ad --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.hpp @@ -0,0 +1,84 @@ +// file : CCF/IDL3/Traversal/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP +#define CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + struct EventTypeTemplate : ScopeTemplate<T> + { + virtual void + traverse (T&); + + virtual void + pre (T&); + + virtual void + name (T&); + + virtual void + inherits (T&, EdgeDispatcherBase&); + + virtual void + inherits (T&); + + virtual void + inherits_pre (T&); + + virtual void + inherits_post (T&); + + virtual void + inherits_none (T&); + + virtual void + supports (T&, EdgeDispatcherBase&); + + virtual void + supports (T&); + + virtual void + supports_pre (T&); + + virtual void + supports_post (T&); + + virtual void + supports_none (T&); + + virtual void + post (T&); + + virtual void + comma (T&); + }; + + + typedef + EventTypeTemplate<SemanticGraph::EventType> + EventType; + + typedef + EventTypeTemplate<SemanticGraph::AbstractEventType> + AbstractEventType; + + typedef + EventTypeTemplate<SemanticGraph::ConcreteEventType> + ConcreteEventType; + } + } +} + +#include "CCF/IDL3/Traversal/EventType.tpp" + +#endif // CCF_IDL3_TRAVERSAL_EVENT_TYPE_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp new file mode 100644 index 00000000000..b2be8ad507c --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp @@ -0,0 +1,132 @@ +// file : CCF/IDL3/Traversal/EventType.tpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + template <typename T> + void EventTypeTemplate<T>:: + traverse (T& i) + { + pre (i); + name (i); + inherits (i); + supports (i); + names (i); + post (i); + } + + template <typename T> + void EventTypeTemplate<T>:: + pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + name (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits (T& i, EdgeDispatcherBase&) + { + //@@ TODO + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits (T& i) + { + /* + typename T::InheritsIterator + b (i.inherits_begin ()), e (i.inherits_end ()); + + if (b != e) + { + inherits_pre (i); + iterate_and_dispatch (b, e, *this, &EventTypeTemplate::comma, i); + inherits_post (i); + } + */ + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + inherits_none (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports (T& i, EdgeDispatcherBase&) + { + //@@ TODO + } + + template <typename T> + void EventTypeTemplate<T>:: + supports (T& i) + { + /* + typename T::SupportsIterator + b (i.supports_begin ()), e (i.supports_end ()); + + if (b != e) + { + supports_pre (i); + iterate_and_dispatch (b, e, *this, &EventTypeTemplate::comma, i); + supports_post (i); + } + */ + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_pre (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + supports_none (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + post (T&) + { + } + + template <typename T> + void EventTypeTemplate<T>:: + comma (T&) + { + } + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp new file mode 100644 index 00000000000..2cc7ac87524 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.cpp @@ -0,0 +1,381 @@ +// file : CCF/IDL3/Traversal/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/Traversal/Home.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + // Home + // + // + void Home:: + traverse (Type& h) + { + pre (h); + name (h); + inherits (h); + supports (h); + manages (h); + names (h); + post (h); + } + + void Home:: + pre (Type&) + { + } + + void Home:: + name (Type&) + { + } + + void Home:: + inherits (Type& h, EdgeDispatcherBase& d) + { + if (SemanticGraph::Inherits* inh = h.inherits ()) + { + d.traverse (*inh); + } + } + + void Home:: + inherits (Type& h) + { + if (SemanticGraph::Inherits* inh = h.inherits ()) + { + inherits_pre (h); + edge_traverser ().traverse (*inh); + inherits_post (h); + } + else + { + inherits_none (h); + } + } + + void Home:: + inherits_pre (Type&) + { + } + + void Home:: + inherits_post (Type&) + { + } + + void Home:: + inherits_none (Type&) + { + } + + void Home:: + supports (Type& h, EdgeDispatcherBase& d) + { + iterate_and_traverse (h.supports_begin (), h.supports_end (), d); + } + + void Home:: + supports (Type& h) + { + Type::SupportsIterator b (h.supports_begin ()), e (h.supports_end ()); + + if (b != e) + { + supports_pre (h); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &Home::comma, h); + supports_post (h); + } + else + { + supports_none (h); + } + } + + void Home:: + supports_pre (Type&) + { + } + + void Home:: + supports_post (Type&) + { + } + + void Home:: + supports_none (Type&) + { + } + + void Home:: + manages (Type& h, EdgeDispatcherBase& d) + { + d.traverse (h.manages ()); + } + + void Home:: + manages (Type& h) + { + manages_pre (h); + manages (h, edge_traverser ()); + manages_post (h); + } + + void Home:: + manages_pre (Type&) + { + } + + void Home:: + manages_post (Type&) + { + } + + void Home:: + post (Type&) + { + } + + void Home:: + comma (Type&) + { + } + + + // HomeFactory + // + // + void HomeFactory:: + traverse (Type& hf) + { + pre (hf); + returns (hf); + name (hf); + receives (hf); + raises (hf); + post (hf); + } + + void HomeFactory:: + pre (Type&) + { + } + + void HomeFactory:: + returns (Type& hf, EdgeDispatcherBase& d) + { + d.traverse (hf.returns ()); + } + + void HomeFactory:: + returns (Type& hf) + { + returns (hf, edge_traverser ()); + } + + void HomeFactory:: + name (Type&) + { + } + + void HomeFactory:: + receives (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.receives_begin (), hf.receives_end (), d); + } + + void HomeFactory:: + receives (Type& hf) + { + receives_pre (hf); + iterate_and_traverse (hf.receives_begin (), + hf.receives_end (), + edge_traverser (), + *this, + &HomeFactory::comma, + hf); + receives_post (hf); + } + + void HomeFactory:: + receives_pre (Type&) + { + } + + void HomeFactory:: + receives_post (Type&) + { + } + + void HomeFactory:: + raises (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.raises_begin (), hf.raises_end (), d); + } + + void HomeFactory:: + raises (Type& hf) + { + Type::RaisesIterator b (hf.raises_begin ()), e (hf.raises_end ()); + + if (b != e) + { + raises_pre (hf); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &HomeFactory::comma, hf); + raises_post (hf); + } + else + { + raises_none (hf); + } + } + + void HomeFactory:: + raises_pre (Type&) + { + } + + void HomeFactory:: + raises_post (Type&) + { + } + + void HomeFactory:: + raises_none (Type&) + { + } + + void HomeFactory:: + post (Type&) + { + } + + void HomeFactory:: + comma (Type&) + { + } + + // HomeFinder + // + // + void HomeFinder:: + traverse (Type& hf) + { + pre (hf); + returns (hf); + name (hf); + receives (hf); + raises (hf); + post (hf); + } + + void HomeFinder:: + pre (Type&) + { + } + + void HomeFinder:: + returns (Type& hf, EdgeDispatcherBase& d) + { + d.traverse (hf.returns ()); + } + + void HomeFinder:: + returns (Type& hf) + { + returns (hf, edge_traverser ()); + } + + void HomeFinder:: + name (Type&) + { + } + + void HomeFinder:: + receives (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.receives_begin (), hf.receives_end (), d); + } + + void HomeFinder:: + receives (Type& hf) + { + receives_pre (hf); + iterate_and_traverse (hf.receives_begin (), + hf.receives_end (), + edge_traverser (), + *this, + &HomeFinder::comma, + hf); + receives_post (hf); + } + + void HomeFinder:: + receives_pre (Type&) + { + } + + void HomeFinder:: + receives_post (Type&) + { + } + + void HomeFinder:: + raises (Type& hf, EdgeDispatcherBase& d) + { + iterate_and_traverse (hf.raises_begin (), hf.raises_end (), d); + } + + void HomeFinder:: + raises (Type& hf) + { + Type::RaisesIterator b (hf.raises_begin ()), e (hf.raises_end ()); + + if (b != e) + { + raises_pre (hf); + iterate_and_traverse ( + b, e, edge_traverser (), *this, &HomeFinder::comma, hf); + raises_post (hf); + } + else + { + raises_none (hf); + } + } + + void HomeFinder:: + raises_pre (Type&) + { + } + + void HomeFinder:: + raises_post (Type&) + { + } + + void HomeFinder:: + raises_none (Type&) + { + } + + void HomeFinder:: + post (Type&) + { + } + + void HomeFinder:: + comma (Type&) + { + } + + } + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp new file mode 100644 index 00000000000..7d77cc2adaa --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Home.hpp @@ -0,0 +1,207 @@ +// file : CCF/IDL3/Traversal/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_TRAVERSAL_HOME_HPP +#define CCF_IDL3_TRAVERSAL_HOME_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" + +#include "CCF/IDL3/Traversal/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace Traversal + { + + // + // + // + struct Manages : Edge<SemanticGraph::Manages> + { + virtual void + traverse (Type& e) + { + node_traverser ().traverse (e.managee ()); + } + }; + + // + // + // + struct Home : ScopeTemplate<SemanticGraph::Home> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + name (Type&); + + virtual void + inherits (Type&, EdgeDispatcherBase&); + + virtual void + inherits (Type&); + + virtual void + inherits_pre (Type&); + + virtual void + inherits_post (Type&); + + virtual void + inherits_none (Type&); + + virtual void + supports (Type&, EdgeDispatcherBase&); + + virtual void + supports (Type&); + + virtual void + supports_pre (Type&); + + virtual void + supports_post (Type&); + + virtual void + supports_none (Type&); + + virtual void + manages (Type&, EdgeDispatcherBase&); + + virtual void + manages (Type&); + + virtual void + manages_pre (Type&); + + virtual void + manages_post (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + + + // + // + // + struct HomeFactory : Node<SemanticGraph::HomeFactory> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + returns (Type&, EdgeDispatcherBase&); + + virtual void + returns (Type&); + + virtual void + name (Type&); + + virtual void + receives (Type&, EdgeDispatcherBase&); + + virtual void + receives (Type&); + + virtual void + receives_pre (Type&); + + virtual void + receives_post (Type&); + + virtual void + raises (Type&, EdgeDispatcherBase&); + + virtual void + raises (Type&); + + virtual void + raises_pre (Type&); + + virtual void + raises_post (Type&); + + virtual void + raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + + + // + // + // + struct HomeFinder : Node<SemanticGraph::HomeFinder> + { + virtual void + traverse (Type&); + + virtual void + pre (Type&); + + virtual void + returns (Type&, EdgeDispatcherBase&); + + virtual void + returns (Type&); + + virtual void + name (Type&); + + virtual void + receives (Type&, EdgeDispatcherBase&); + + virtual void + receives (Type&); + + virtual void + receives_pre (Type&); + + virtual void + receives_post (Type&); + + virtual void + raises (Type&, EdgeDispatcherBase&); + + virtual void + raises (Type&); + + virtual void + raises_pre (Type&); + + virtual void + raises_post (Type&); + + virtual void + raises_none (Type&); + + virtual void + post (Type&); + + virtual void + comma (Type&); + }; + } + } +} + +#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..0b8d65ca663 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/Makefile.alt @@ -0,0 +1,17 @@ +# 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 + +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/Makefile.alt b/TAO/CIAO/CCF/CCF/Makefile.alt new file mode 100644 index 00000000000..1516cbc040c --- /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 CompilerElements +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..e54a1fde256 --- /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..d3d3cbdcc27 --- /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..b81778b5ba4 --- /dev/null +++ b/TAO/CIAO/CCF/Documentation/DesignNotes @@ -0,0 +1,459 @@ + +Note: this file is somewhat outdated + +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..f7ebf9f6deb --- /dev/null +++ b/TAO/CIAO/CCF/Documentation/TODO @@ -0,0 +1,115 @@ +Legend: + +@@ signifies a to-be-done item + +%% signifies a done item (should be cleaned-up periodically) + +@% signifies a partially-done item + +++ signifies difficulty of an item (the more pluses the more difficult) + +------------------------------------------------------------------------ + +@@ Make CCF buildable with MPC. + +@@ Write proper build instructions. + +@@ Seem to me some of the declaration_class implementations are redundant. + +@% Need to do something with this ctor initialization mess. + +@@ Can I use C++ templates instead of m4 in BuiltIn stuff? + +@@ Typedef.hpp TypeId.hpp: naming inconsistency. + +@@ Need ICE mechanism (search for abort ()) + +@@ Need evolution of semantic action error handling/reporting. + +@@+ 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. + +@@ TypeId::declaration returns ScopedName which is not very consistent + since scoped name in general case denotes a bunch of declarations. + Same for TypePrefix. + +%% Perhaps add reference to declaration table to every SyntaxTree::Node + (and not just scopes). + +@@ Replace all i++ with ++i. + +@@ It seems that SyntaxTree::Node origin in terms of file:line should be + preserved for subsequent diagnostic implemented as separate paths + (see repository id generator for example). + +@@ Rename TypeId/TypePrefix to TypeIdDecl/TypePrefixDecl + +@@++++ Diagnostic evolution + +@%++ XML indentation buffer + +@%+++ Anonymous types and typedef's model (2) + +@@+++ Introduction (injection) of names into scope + +@@++++ C Preprocessor integration (wave) + +%% IDL feature: type id/prefix + +%% IDL feature: exception declaration + +%% IDL feature: built-in types + +%% IDL feature: struct + +--- + +@% IDL feature: literals and constant expression (3) + +@% IDL feature: constant declaration; depends on 3 + +@% IDL feature: sequences; depends on 2,3 (left: bounded seq) + +@% IDL feature: oprations (completion) (left: oneway) + +@% IDL feature: attribute (completion) (left: exception spec) + +@% IDL feature: factories/finders (completion) (left: finder) + +@@ IDL feature: enum + +@@ IDL feature: valuetype (4) + +@% IDL feature: event (completion); do after (4) + +--- + +@@ Preprocessor fix + +@@ Interconnect parsing rules so that typedef is possible in interface, + etc. Also will need to fix generators. Home can have operations etc. + +@@ Maybe do something with diagnostic + +--- + +@@ IDL feature: array; depends on 2,3 + +@@ IDL feature: union + +@@ IDL feature: fixed; depends on 2,3 diff --git a/TAO/CIAO/CCF/Example/CIDL/CIDL.mwc b/TAO/CIAO/CCF/Example/CIDL/CIDL.mwc new file mode 100644 index 00000000000..dfd5c05859e --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/CIDL.mwc @@ -0,0 +1,3 @@ +workspace { + LocalExecutorMapping +}
\ No newline at end of file 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..8c33a8312f4 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp @@ -0,0 +1,1663 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "ExecutorMappingGenerator.hpp" + +#include <set> +#include <ostream> +#include <fstream> + +#include "CCF/CIDL/SemanticGraph.hpp" +#include "CCF/CIDL/Traversal.hpp" + +#include "CCF/CodeGenerationKit/Regex.hpp" +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +using std::string; +using std::ostream; +using std::endl; + + +using namespace CCF::CIDL; +using namespace CCF::CIDL::SemanticGraph; + +namespace +{ + class Context + { + public: + Context (TranslationUnit& tu) + : tu_ (tu) + { + } + + TranslationUnit& + tu () const + { + return tu_; + } + + public: + bool + add (Home& h) + { + return homes_.insert (&h).second; + } + + bool + add (Component& c) + { + return components_.insert (&c).second; + } + + bool + add (UnconstrainedInterface& i) + { + return interfaces_.insert (&i).second; + } + + bool + add (Composition& c) + { + return compositions_.insert (&c).second; + } + + public: + bool + find (Home& h) const + { + return homes_.find (&h) != homes_.end (); + } + + bool + find (Component& c) const + { + return components_.find (&c) != components_.end (); + } + + bool + find (UnconstrainedInterface& i) const + { + return interfaces_.find (&i) != interfaces_.end (); + } + + bool + find (Composition& c) const + { + return compositions_.find (&c) != compositions_.end (); + } + + private: + typedef std::set<Home*> Homes; + typedef std::set<Component*> Components; + typedef std::set<UnconstrainedInterface*> Interfaces; + typedef std::set<Composition*> Compositions; + + TranslationUnit& tu_; + + Homes homes_; + Components components_; + Interfaces interfaces_; + Compositions compositions_; + }; + + class Traverser + { + protected: + Traverser (Context& c) + : ctx (c) + { + } + + Context& ctx; + }; + + struct Collector : Traverser + { + protected: + Collector (Context& c) + : Traverser (c) + { + } + + bool + exist (ScopedName const& name) + { + return !ctx.tu ().lookup (name).empty (); + } + }; + + // + // + // + struct ComponentCollector : Traversal::Component, Collector + { + ComponentCollector (Context& c) + : Collector (c) + { + } + + virtual void + traverse (Type& c) + { + SimpleName name (c.name ()); + ScopedName scope (c.scoped_name ().scope_name ()); + + ScopedName monolith (scope, "CCM_" + name); + ScopedName context (scope, "CCM_" + name + "_Context"); + + // Check if mapping has already been provided. + // + if (exist (context) || exist (monolith)) return; + + if(ctx.add (c)) + { + // Collect inherited components and provides interfaces. + // + Traversal::Component::traverse (c); + } + } + }; + + + // + // + // + struct HomeCollector : Traversal::Home, Collector + { + HomeCollector (Context& c) + : Collector (c) + { + } + + virtual void + traverse (Type& h) + { + SimpleName name (h.name ()); + ScopedName scope (h.scoped_name ().scope_name ()); + + ScopedName main (scope, "CCM_" + name); + ScopedName expl (scope, "CCM_" + name + "Explicit"); + ScopedName impl (scope, "CCM_" + name + "Implicit"); + + // Check if mapping has already been provided. + // + if (exist (main) || exist (expl) || exist (impl)) return; + + if(ctx.add (h)) + { + // Note that I don't go after components that inherited home manages + // because it will be handled by component inheritance tree. + // + Traversal::Home::traverse (h); + } + } + }; + + + // + // + // + struct InterfaceCollector : Traversal::UnconstrainedInterface, Collector + { + InterfaceCollector (Context& c) + : Collector (c) + { + } + + virtual void + traverse (Type& i) + { + SimpleName name (i.name ()); + ScopedName scope (i.scoped_name ().scope_name ()); + + ScopedName mapping (scope, "CCM_" + name); + + // Check if mapping has already been provided. + // + if (exist (mapping)) return; + + // Add to the list if it's not already there. + // + ctx.add (i); + } + }; + + struct CompositionCollector : Traversal::Composition, Collector + { + CompositionCollector (Context& c) + : Collector (c) + { + } + + virtual void + traverse (Type& c) + { + // Add to the list if it's not already there. + // + if (ctx.add (c)) + { + Traversal::Composition::traverse (c); + } + } + }; + + struct Emitter : Traverser + { + protected: + Emitter (Context& c, ostream& os_) + : Traverser (c), os (os_) + { + } + + protected: + ostream& os; + }; + + + // + // + // + struct TypeNameEmitter : Traversal::FundamentalType, + Traversal::Type, + Emitter + { + TypeNameEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (SemanticGraph::FundamentalType& t) + { + os << t.name (); + } + + virtual void + traverse (SemanticGraph::Type& t) + { + os << t.scoped_name (); + } + }; + + + struct NameMangler : Traversal::Nameable, Emitter + { + NameMangler (Context& c, + ostream& os, + string const& prefix, + string const& suffix = "") + : Emitter (c, os), prefix_ (prefix), suffix_ (suffix) + { + } + + virtual void + traverse (Type& t) + { + ScopedName n (t.scoped_name ()); + os << n.scope_name () << "::" << prefix_ << n.simple_name () << suffix_; + } + + private: + string prefix_, suffix_; + }; + + + // + // + // + struct ComponentEmitter : Traversal::Component, Emitter + { + protected: + ComponentEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (Type& c) + { + if (ctx.find (c)) + { + Component::traverse (c); + } + } + }; + + + // MonolithEmitter generates what spec calls 'Monolithic Component + // Executor'. + // + struct MonolithEmitter : ComponentEmitter + { + MonolithEmitter (Context& c, ostream& os) + : ComponentEmitter (c, os), + monolith_name_emitter (c, os, "CCM_"), + attribute (c, os), + consumer (c, os), + provider (c, os), + type_name_emitter (c, os) + { + edge_traverser (inherits); + edge_traverser (defines); + + inherits.node_traverser (monolith_name_emitter); + + defines.node_traverser (attribute); + defines.node_traverser (consumer); + defines.node_traverser (provider); + + attribute.edge_traverser (belongs); + consumer.edge_traverser (belongs); + provider.edge_traverser (provider_belongs); + + belongs.node_traverser (type_name_emitter); + provider_belongs.node_traverser (monolith_name_emitter); + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& c) + { + os << "CCM_" << c.name (); + } + + virtual void + inherits_pre (Type&) + { + os << " : "; + } + + virtual void + inherits_none (Type&) + { + os << " : ::Components::EnterpriseComponent"; + } + + virtual void + supports_pre (Type&) + { + os << ", "; + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + + virtual void + comma (Type&) + { + os << ", "; + } + + private: + struct Attribute : Traversal::Attribute, Emitter + { + Attribute (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + pre (Type& ) + { + os << "attribute "; + } + + virtual void + name (Type& a) + { + os << " " << a.name (); + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + + struct Consumer : Traversal::ConsumerSet, Emitter + { + Consumer (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + returns (Type&) + { + os << "void"; + } + + virtual void + name (Type& c) + { + os << " push_" << c.name (); + } + + virtual void + receives_pre (Type&) + { + os << " (in "; + } + + virtual void + receives_post (Type&) + { + os << " e)"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + + struct Provider : Traversal::ProviderGet, Emitter + { + Provider (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + name (Type& c) + { + os << " get_" << c.name (); + } + + virtual void + receives_pre (Type&) + { + os << " ("; + } + + virtual void + receives_post (Type&) + { + os << ")"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + Traversal::Inherits inherits; + Traversal::Defines defines; + + NameMangler monolith_name_emitter; + + Attribute attribute; + Consumer consumer; + Provider provider; + + Traversal::Belongs belongs; + Traversal::Belongs provider_belongs; + + TypeNameEmitter type_name_emitter; + }; + + + // ContextEmitter generates component context interface. + // + // + struct ContextPortEmitter : Traversal::UserGet, + Traversal::PublisherSet, + Traversal::EmitterSet, + Emitter + { + ContextPortEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + + // User. + // + virtual void + name (SemanticGraph::User& u) + { + os << " get_connection_" << u.name (); + } + + virtual void + receives_pre (SemanticGraph::User&) + { + os << " ("; + } + + virtual void + receives_post (SemanticGraph::User&) + { + os << ")"; + } + + virtual void + post (SemanticGraph::User&) + { + os << ";"; + } + + + // Publisher. + // + virtual void + returns (SemanticGraph::Publisher&) + { + os << "void"; + } + + virtual void + name (SemanticGraph::Publisher& p) + { + os << " push_" << p.name (); + } + + virtual void + receives_pre (SemanticGraph::Publisher&) + { + os << " (in "; + } + + virtual void + receives_post (SemanticGraph::Publisher&) + { + os << " e)"; + } + + virtual void + post (SemanticGraph::Publisher&) + { + os << ";"; + } + + + // Emitter. + // + virtual void + returns (SemanticGraph::Emitter&) + { + os << "void"; + } + + virtual void + name (SemanticGraph::Emitter& e) + { + os << " push_" << e.name (); + } + + virtual void + receives_pre (SemanticGraph::Emitter&) + { + os << " (in "; + } + + virtual void + receives_post (SemanticGraph::Emitter&) + { + os << " e)"; + } + + virtual void + post (SemanticGraph::Emitter&) + { + os << ";"; + } + }; + + + struct ContextEmitter : ComponentEmitter + { + ContextEmitter (Context& c, ostream& os) + : ComponentEmitter (c, os), name_emitter (c, os, "CCM_", "_Context") + { + edge_traverser (inherits); + inherits.node_traverser (name_emitter); + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& c) + { + os << "CCM_" << c.name () << "_Context"; + } + + virtual void + inherits_pre (Type&) + { + os << " : "; + } + + virtual void + inherits_none (Type&) + { + //@@ This should be ::Components::CCMContext when we start using + // proper mapping. + // + os << " : ::Components::SessionContext"; + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + + private: + Traversal::Inherits inherits; + NameMangler name_emitter; + }; + + + // + // + // + struct HomeEmitter : Traversal::Home, Emitter + { + HomeEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (Type& h) + { + if (ctx.find (h)) + { + Home::traverse (h); + } + } + }; + + + // HomeExplicitEmitter generates home explicit interface + // + // + struct ExplicitPortEmitter : Traversal::Attribute, + Traversal::Operation, + Traversal::HomeFactory, + Emitter + { + ExplicitPortEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + // Attribute. + // + + virtual void + pre (SemanticGraph::Attribute&) + { + os << "attribute "; + } + + virtual void + name (SemanticGraph::Attribute& a) + { + os << " " << a.name (); + } + + virtual void + post (SemanticGraph::Attribute&) + { + os << ";"; + } + + + // Operation. + // + + virtual void + name (SemanticGraph::Operation& o) + { + os << " " << o.name (); + } + + virtual void + receives_pre (SemanticGraph::Operation&) + { + os << " ("; + } + + virtual void + receives_post (SemanticGraph::Operation&) + { + os << ")"; + } + + virtual void + raises_pre (SemanticGraph::Operation&) + { + os << " raises ("; + } + + virtual void + raises_post (SemanticGraph::Operation&) + { + os << ")"; + } + + virtual void + post (SemanticGraph::Operation&) + { + os << ";"; + } + + virtual void + comma (SemanticGraph::Operation&) + { + os << ", "; + } + + + // HomeFactory. + // + + virtual void + returns (SemanticGraph::HomeFactory&) + { + os << "::Components::EnterpriseComponent "; + } + + virtual void + name (SemanticGraph::HomeFactory& hf) + { + os << " " << hf.name (); + } + + virtual void + receives_pre (SemanticGraph::HomeFactory&) + { + os << " ("; + } + + virtual void + receives_post (SemanticGraph::HomeFactory&) + { + os << ")"; + } + + virtual void + raises_pre (SemanticGraph::HomeFactory&) + { + os << " raises ("; + } + + virtual void + raises_post (SemanticGraph::HomeFactory&) + { + os << ")"; + } + + virtual void + post (SemanticGraph::HomeFactory&) + { + os << ";"; + } + + virtual void + comma (SemanticGraph::HomeFactory&) + { + os << ", "; + } + }; + + struct ParameterEmitter : Traversal::Parameter, public Emitter + { + ParameterEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + pre (Type& p) + { + os << p.direction () << " "; + } + + virtual void + name (Type& p) + { + os << " " << p.name (); + } + }; + + struct HomeExplicitEmitter : HomeEmitter + { + HomeExplicitEmitter (Context& c, ostream& os) + : HomeEmitter (c, os), name_emitter (c, os, "CCM_", "Explicit") + { + edge_traverser (inherits); + inherits.node_traverser (name_emitter); + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& h) + { + os << "CCM_" << h.name () << "Explicit"; + } + + virtual void + inherits_pre (Type&) + { + os << " : "; + } + + virtual void + inherits_none (Type&) + { + os << " : ::Components::HomeExecutorBase"; + } + + virtual void + supports_pre (Type&) + { + os << ", "; + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + + virtual void + comma (Type&) + { + os << ", "; + } + + private: + Traversal::Inherits inherits; + NameMangler name_emitter; + }; + + + // HomeImplicitEmitter generates home implicit interface + // + // + struct HomeImplicitEmitter : HomeEmitter + { + HomeImplicitEmitter (Context& c, ostream& os) + : HomeEmitter (c, os) + { + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& h) + { + os << "CCM_" << h.name () << "Implicit"; + } + + virtual void + names (Type& h) + { + os<< "{" + << "::Components::EnterpriseComponent " + << "create () raises (::Components::CCMException);" + << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + + // HomeMainEmitter generates home main interface + // + // + struct HomeMainEmitter : HomeEmitter + { + HomeMainEmitter (Context& c, ostream& os) + : HomeEmitter (c, os) + { + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& h) + { + os << "CCM_" << h.name (); + } + + virtual void + inherits (Type& h) + { + os << " : " + << "CCM_" << h.name () << "Explicit, " + << "CCM_" << h.name () << "Implicit"; + } + + virtual void + names (Type&) + { + os << "{}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + // + // + // + struct ModuleEmitter : Traversal::Module, Emitter + { + ModuleEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (Type& m) + { + if (has_elements (m)) + { + Traversal::Module::traverse (m); + } + } + + virtual void + pre (Type&) + { + os << "module "; + } + + virtual void + name (Type& m) + { + os << m.name (); + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + + private: + + template <typename T> + struct Finder : T, Traverser + { + Finder (Context& c, bool& r) + : Traverser (c), r_ (r) + { + } + + virtual void + traverse (typename T::Type& t) + { + if (ctx.find (t)) r_ = true; + } + + private: + bool& r_; + }; + + bool + has_elements (Type& m) + { + bool r; + + Traversal::Module module; + Traversal::Defines defines; + + module.edge_traverser (defines); + + Finder<Traversal::Composition> composition (ctx, r); + Finder<Traversal::UnconstrainedInterface> interface (ctx, r); + Finder<Traversal::Component> component (ctx, r); + Finder<Traversal::Home> home (ctx, r); + + defines.node_traverser (module); + defines.node_traverser (composition); + defines.node_traverser (interface); + defines.node_traverser (component); + defines.node_traverser (home); + + module.traverse (m); + + return r; + } + }; + + // + // + // + struct InterfaceEmitter : Traversal::UnconstrainedInterface, Emitter + { + InterfaceEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (Type& i) + { + if (ctx.find (i)) + { + Traversal::UnconstrainedInterface::traverse (i); + } + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& i) + { + os << "CCM_" << i.name (); + } + + virtual void + inherits (Type& i) + { + os << " : " << i.name (); + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + + // + // + // + struct CompositionEmitter : Traversal::Composition, Emitter + { + CompositionEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (Type& c) + { + if (ctx.find (c)) + { + Traversal::Composition::traverse (c); + } + } + + virtual void + pre (Type&) + { + os << "module "; + } + + virtual void + name (Type& m) + { + os << m.name (); + } + + virtual void + names_pre (Type&) + { + os << "{"; + } + + virtual void + names_post (Type&) + { + os << "}"; + } + + virtual void + post (Type&) + { + os << ";"; + } + }; + + + struct ComponentExecutorEmitter : Traversal::ComponentExecutor, Emitter + { + ComponentExecutorEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + pre (Type&) + { + os << "local interface "; + } + + virtual void + name (Type& i) + { + //@@ need to check if spec prescribes this name. + // + os << i.name () << "Context"; + } + + virtual void + manages (Type& i) + { + /* + 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; + } + */ + } + + virtual void + post (Type&) + { + os << "{};"; + } + }; + + + // + // + // + struct IncludesEmitter : Traversal::QuoteIncludes, + Traversal::BracketIncludes, + Emitter + { + IncludesEmitter (Context& c, ostream& os) + : Emitter (c, os) + { + } + + virtual void + traverse (SemanticGraph::QuoteIncludes& qi) + { + os << "#include \"" << qi.file ().string () << "\"" << endl; + } + + virtual void + traverse (SemanticGraph::BracketIncludes& bi) + { + os << "#include <" << bi.file ().string () << ">" << endl; + } + }; +} + +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, TranslationUnit& tu, fs::path 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, std::ios_base::out); + + if (!ofs.is_open ()) + { + cerr << lem_file_name << ": error: unable to open in write mode" + << endl; + return; + } + } + + ostream& os = ofs.is_open () + ? static_cast<ostream&> (ofs) + : static_cast<ostream&> (std::cout); + + // Set auto-indentation for os + Indentation::Implanter<Indentation::IDL> guard (os); + + Context ctx (tu); + + if (cl.get_value ("lem-force-all", false)) + { + /* + InterfaceCollector iface (declarations); + Traversal::ProvidesDecl provides (&iface); + + 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 (&iface); + + 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 + { + Traversal::TranslationUnit unit; + + // Layer 1 + // + Traversal::ContainsPrincipal contains_principal; + + unit.edge_traverser (contains_principal); + + //-- + Traversal::TranslationRegion region; + + contains_principal.node_traverser (region); + + + // Layer 2 + // + Traversal::ContainsRoot contains_root; + Traversal::Includes includes; + + region.edge_traverser (contains_root); + region.edge_traverser (includes); + + //-- + Traversal::Root root; + + contains_root.node_traverser (root); + includes.node_traverser (region); + + + // Layer 3 + // + Traversal::Defines defines; + root.edge_traverser (defines); + + //-- + Traversal::Module module; + CompositionCollector composition (ctx); + + defines.node_traverser (module); + defines.node_traverser (composition); + + + // Layer 4 + // + Traversal::Defines composition_defines; + + module.edge_traverser (defines); + composition.edge_traverser (composition_defines); + + //-- + Traversal::ComponentExecutor component_executor; + Traversal::HomeExecutor home_executor; + + composition_defines.node_traverser (component_executor); + composition_defines.node_traverser (home_executor); + + // Layer 5 + // + Traversal::Implements component_executor_implements; + Traversal::Implements home_executor_implements; + + component_executor.edge_traverser (component_executor_implements); + home_executor.edge_traverser (home_executor_implements); + + //-- + ComponentCollector component (ctx); + HomeCollector home (ctx); + + component_executor_implements.node_traverser (component); + home_executor_implements.node_traverser (home); + + + // Layer 6 + // + Traversal::Defines component_defines; + Traversal::Inherits component_inherits; + Traversal::Inherits home_inherits; + + component.edge_traverser (component_defines); + component.edge_traverser (component_inherits); + home.edge_traverser (home_inherits); + + //-- + + Traversal::Provider provider; + + component_defines.node_traverser (provider); + component_inherits.node_traverser (component); + home_inherits.node_traverser (home); + + + // Layer 7 + // + Traversal::Belongs provider_belongs; + provider.edge_traverser (provider_belongs); + + // + InterfaceCollector interface (ctx); + + provider_belongs.node_traverser (interface); + + + // end + + unit.traverse (tu); + } + + { + Traversal::TranslationUnit unit; + + // Layer 1 + // + Traversal::ContainsPrincipal contains_principal; + + unit.edge_traverser (contains_principal); + + //-- + Traversal::TranslationRegion principal_region; + + contains_principal.node_traverser (principal_region); + + + // Layer 2 + // + Traversal::TranslationRegion included_region; + + // Inclusion handling is somewhat tricky because we want + // to print only top-level #include's. + // + + Traversal::ContainsRoot contains_root; + Traversal::QuoteIncludes quote_includes; + Traversal::BracketIncludes bracket_includes; + IncludesEmitter includes_emitter (ctx, os); + + + principal_region.edge_traverser (includes_emitter); + principal_region.edge_traverser (quote_includes); + principal_region.edge_traverser (bracket_includes); + principal_region.edge_traverser (contains_root); + + included_region.edge_traverser (quote_includes); + included_region.edge_traverser (bracket_includes); + included_region.edge_traverser (contains_root); + + + //-- + Traversal::Root root; + + contains_root.node_traverser (root); + quote_includes.node_traverser (included_region); + bracket_includes.node_traverser (included_region); + + + // Layer 3 + // + Traversal::Defines defines; + root.edge_traverser (defines); + + //-- + ModuleEmitter module (ctx, os); + + CompositionEmitter composition (ctx, os); + + InterfaceEmitter interface (ctx, os); + + MonolithEmitter component_monolith (ctx, os); + ContextEmitter component_context (ctx, os); + + HomeImplicitEmitter home_implicit (ctx, os); + HomeExplicitEmitter home_explicit (ctx, os); + HomeMainEmitter home_main (ctx, os); + + defines.node_traverser (module); + + defines.node_traverser (composition); + + defines.node_traverser (interface); + + defines.node_traverser (component_monolith); + defines.node_traverser (component_context); + + defines.node_traverser (home_implicit); + defines.node_traverser (home_explicit); + defines.node_traverser (home_main); + + // Layer 4 + // + + Traversal::Supports supports; + + Traversal::Defines composition_defines; + + Traversal::Defines component_context_defines; + + Traversal::Defines home_explicit_defines; + + module.edge_traverser (defines); + + composition.edge_traverser (composition_defines); + + component_monolith.edge_traverser (supports); + component_context.edge_traverser (component_context_defines); + + home_explicit.edge_traverser (supports); + home_explicit.edge_traverser (home_explicit_defines); + + //-- + TypeNameEmitter type (ctx, os); + ComponentExecutorEmitter component_executor (ctx, os); + + ContextPortEmitter port_context (ctx, os); + ExplicitPortEmitter port_explicit (ctx, os); + + supports.node_traverser (type); + + composition_defines.node_traverser (component_executor); + + component_context_defines.node_traverser (port_context); + + home_explicit_defines.node_traverser (port_explicit); + + + // Layer 5 + // + Traversal::Belongs belongs; + Traversal::Receives receives; + Traversal::Raises raises; + + port_context.edge_traverser (belongs); + port_explicit.edge_traverser (belongs); + port_explicit.edge_traverser (raises); + + port_explicit.edge_traverser (receives); + + //-- + ParameterEmitter parameter (ctx, os); + + belongs.node_traverser (type); + receives.node_traverser (parameter); + raises.node_traverser (type); + + // Layer 6 + // + parameter.edge_traverser (belongs); + + + // end + + //@@ this hack is needed to support special Components.idl + // handling. + // + os << "#include <Components.idl>" << endl; + + unit.traverse (tu); + } +} 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..e542ff23097 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/ExecutorMappingGenerator.hpp @@ -0,0 +1,34 @@ +// 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/CompilerElements/FileSystem.hpp" + +#include "CCF/CodeGenerationKit/CommandLine.hpp" +#include "CCF/CodeGenerationKit/CommandLineDescriptor.hpp" + +//@@ SemanticGraphFwd could be useful here. +// +#include "CCF/CIDL/SemanticGraph.hpp" + +class ExecutorMappingGenerator +{ +public: + + //@@ should be static? + void + options (CL::Description& d); + + //@@ maybe I should introduce constant and non-constant + // traversal. + // + void + generate (CommandLine const& cl, + CCF::CIDL::SemanticGraph::TranslationUnit&, + fs::path file); +}; + +#endif // EXECUTOR_MAPPING_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.mpc b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.mpc new file mode 100644 index 00000000000..5869b112ec7 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.mpc @@ -0,0 +1,16 @@ +project { + exename = cidlc + includes += ../../../CCF $(UTILITY_ROOT) $(BOOST_ROOT) + libpaths += ../../..CCF/CCF/IDL2 ../../../CCF/CCF/IDL3 ../../../CCF/CCF/CIDL ../../../CCF/CCF/CodeGenerationKit $(UTILITY_ROOT)/Utility/Introspection $(BOOST_ROOT) + libs += IDL2 IDL3 CIDL CodeGenerationKit Introspection boost_regex boost_filesystem +// lit_libs += libboost_regex libboost_filesystem + + Source_Files { + ExecutorMappingGenerator.cpp + cidlc.cpp + } + + Header_Files { + ExecutorMappingGenerator.hpp + } +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.vcproj b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.vcproj new file mode 100644 index 00000000000..fd5b7e1c009 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/LocalExecutorMapping.vcproj @@ -0,0 +1,147 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="LocalExecutorMapping"
+ ProjectGUID="{787D727E-24B5-4791-87A3-3235EAD4FEFF}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ProjectDir)"
+ IntermediateDirectory="$(ProjectDir)/Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ DisableLanguageExtensions="FALSE"
+ ForceConformanceInForLoopScope="TRUE"
+ RuntimeTypeInfo="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="CompilerElements.lib CodeGenerationKit.lib IDL2.lib IDL3.lib CIDL.lib libboost_filesystem_debug.lib libboost_regex_debug.lib"
+ OutputFile="$(OutDir)/cidlc.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="../../../CCF/CompilerElements;../../../CCF/CodeGenerationKit;../../../CCF/IDL2;../../../CCF/IDL3;../../../CCF/CIDL"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/LocalExecutorMapping.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ProjectDir)"
+ IntermediateDirectory="$(ProjectDir)/Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4290 /wd4800 /wd4250 /wd4355"
+ AdditionalIncludeDirectories="../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ DisableLanguageExtensions="FALSE"
+ ForceConformanceInForLoopScope="TRUE"
+ RuntimeTypeInfo="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="CompilerElements.lib CodeGenerationKit.lib IDL2.lib IDL3.lib CIDL.lib"
+ OutputFile="$(OutDir)/cidlc.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../CCF/CompilerElements;../../../CCF/CodeGenerationKit;../../../CCF/IDL2;../../../CCF/IDL3;../../../CCF/CIDL"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\cidlc.cpp">
+ </File>
+ <File
+ RelativePath=".\ExecutorMappingGenerator.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath=".\ExecutorMappingGenerator.hpp">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
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..ce842ab8bf1 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/Makefile.alt @@ -0,0 +1,38 @@ +# 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 := cidlc.cpp ExecutorMappingGenerator.cpp + +module_base := cidlc +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/CIDL \ + -lCIDL \ + -L$(root)/CCF/IDL3 \ + -lIDL3 \ + -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(root)/CCF/CodeGenerationKit \ + -lCodeGenerationKit \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -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..a2477142214 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp @@ -0,0 +1,225 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/cidlc.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <vector> +#include <iostream> + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.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/SemanticGraph.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +#include "ExecutorMappingGenerator.hpp" + +using std::cerr; +using std::endl; + +using namespace CCF::CIDL; +using namespace SemanticGraph; + +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::ArgumentsIterator i = cl.arguments_begin (); + + if (i != cl.arguments_end ()) + { + try + { + file_path = fs::path (*i, fs::native); + ifs.open (file_path, std::ios_base::in); + } + 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 () + ? static_cast<std::istream&> (ifs) + : static_cast<std::istream&> (std::cin); + + CCF::InputStreamAdapter isa (is); + CCF::Preprocessor pp (isa); + + if (cl.get_value ("preprocess-only", false)) + { + while (true) + { + CCF::Preprocessor::int_type i = pp.next (); + + if (pp.eos (i)) break; + + CCF::Preprocessor::char_type c = pp.to_char_type (i); + + std::cout << c; + } + return 0; + } + + //} + + Diagnostic::Stream dout; + + LexicalAnalyzer lexer (pp); + + TokenList token_stream; + + //@@ bad token comparison + for (TokenPtr token = lexer.next ();; token = lexer.next ()) + { + // cerr << token << endl; + token_stream.push_back (token); + if (ReferenceCounting::strict_cast<EndOfStream> (token) != 0) break; + } + + if (token_stream.size () < 2) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnit tu; + + // Initialize compilation context. + // + CCF::CompilerElements::Context context; + context.set ("file-path", file_path); + context.set ("trace-semantic-action", + cl.get_value ("trace-semantic-actions", false)); + + + // Extract include search paths. + // + + std::vector<fs::path> include_paths; + + for (CommandLine::OptionsIterator + i (cl.options_begin ()), e (cl.options_end ()); i != e; ++i) + { + if (i->name () == "I") + { + include_paths.push_back (fs::path (i->value (), fs::native)); + } + else if (i->name ()[0] == 'I') + { + std::string opt (i->name ()); + std::string path (opt.begin () + 1, opt.end ()); + include_paths.push_back (fs::path (path, fs::native)); + } + } + + context.set ("include-search-paths", include_paths); + + // Instantiate semantic actions factory. + // + SemanticAction::Impl::Factory actions (context, dout, tu); + + Parser parser (context, dout, lexer, actions); + + //@@ should be able to use CIDL here. Or better yet get rid of this + // function completely. + // + CCF::IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (dout.error_count () != 0) return -1; + + + // Generate executor mapping. + // + lem_gen.generate (cl, tu, file_path); + + } + catch (std::bad_cast const&) + { + cerr << "bad cast exception" << endl; + } + catch (InvalidName const&) + { + cerr << "invalid name exception" << endl; + } + catch (...) + { + cerr << "caught unknown exception" << endl; + return -1; + } +} 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..73ba9b4276d --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0.idl @@ -0,0 +1,14 @@ +// file : CCF/Example/CIDL/LocalExecutorMapping/test-0.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +module M +{ + interface I {}; + + typedef I Internal; + + //local interface CCM_I : I {}; +}; + +eventtype E {}; diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0_exec.idl.orig b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0_exec.idl.orig new file mode 100644 index 00000000000..87f2b7e1720 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-0_exec.idl.orig @@ -0,0 +1,12 @@ +#include <Components.idl> +module M +{ + local interface CCM_Internal : Internal + { + }; + + local interface CCM_I : I + { + }; +}; + 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..c3d2d8f54c3 --- /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-1_exec.idl.orig b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-1_exec.idl.orig new file mode 100644 index 00000000000..020ea383bbd --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-1_exec.idl.orig @@ -0,0 +1,39 @@ +#include <Components.idl> +#include "test-0.idl" +module M +{ + local interface CCM_I : I + { + }; +}; + +module M1 +{ + local interface CCM_Fool : Fool + { + }; + + local interface CCM_C1 : ::Components::EnterpriseComponent + { + ::M::CCM_I get_i (); + }; + + local interface CCM_C1_Context : ::Components::SessionContext + { + }; + + local interface CCM_H1Implicit + { + ::Components::EnterpriseComponent create () raises (::Components::CCMException); + }; + + local interface CCM_H1Explicit : ::Components::HomeExecutorBase + { + attribute ::M::I i; + }; + + local interface CCM_H1 : CCM_H1Explicit, CCM_H1Implicit + { + }; +}; + 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..34e635a9b43 --- /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..2f964027f35 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2.idl @@ -0,0 +1,63 @@ +// 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 +{ + + interface I {}; + interface J {}; + + eventtype E {}; + + component C2 : M1::C1 supports I, J + { + provides Goof pg; + uses Goof ug; + + publishes E pe; + emits E me; + consumes E ce; + }; + + typedef sequence<octet> OctetSeq; + + struct S + { + long l; + OctetSeq octet_seq; + }; + + typedef sequence<S> S_Seq; + + exception Ex1 + { + string descr; + }; + + exception Ex2 + { + }; + + home H2 : M1::H1 supports I, J manages C2 + { + attribute long l; + attribute M::I ai; + attribute OctetSeq seq; + attribute S_Seq a_s_seq; + + void + foo (in long l, + inout boolean b, + out long ol, + in M::I i, + out unsigned long long ull, + inout S_Seq s_seq) raises (Ex1, Ex2); + + factory new (in long l, in OctetSeq s) raises (Ex2, Ex1); + }; +}; diff --git a/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2_exec.idl.orig b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2_exec.idl.orig new file mode 100644 index 00000000000..8d487896b4d --- /dev/null +++ b/TAO/CIAO/CCF/Example/CIDL/LocalExecutorMapping/test-2_exec.idl.orig @@ -0,0 +1,71 @@ +#include <Components.idl> +#include "test-2.idl" +module M +{ + local interface CCM_I : I + { + }; +}; +module M1 +{ + local interface CCM_C1 : ::Components::EnterpriseComponent + { + ::M::CCM_I get_i (); + }; + local interface CCM_C1_Context : ::Components::SessionContext + { + }; + local interface CCM_H1Implicit + { + ::Components::EnterpriseComponent create () raises (::Components::CCMException); + }; + local interface CCM_H1Explicit : ::Components::HomeExecutorBase + { + attribute ::M::I i; + }; + local interface CCM_H1 : CCM_H1Explicit, CCM_H1Implicit + { + }; +}; +local interface CCM_Goof : Goof +{ +}; +module M2 +{ + local interface CCM_C2 : ::M1::CCM_C1, ::M2::I, ::M2::J + { + ::CCM_Goof get_pg (); + void push_ce (in ::M2::E e); + }; + local interface CCM_C2_Context : ::M1::CCM_C1_Context + { + ::Goof get_connection_ug (); + void push_pe (in ::M2::E e); + void push_me (in ::M2::E e); + }; + local interface CCM_H2Implicit + { + ::Components::EnterpriseComponent create () raises (::Components::CCMException); + }; + local interface CCM_H2Explicit : ::M1::CCM_H1Explicit, ::M2::I, ::M2::J + { + attribute long l; + attribute ::M::I ai; + attribute ::M2::OctetSeq seq; + attribute ::M2::S_Seq a_s_seq; + void foo (in long l, inout boolean b, out long ol, in ::M::I i, out unsigned long long ull, inout ::M2::S_Seq s_seq) raises (::M2::Ex1, ::M2::Ex2); + ::Components::EnterpriseComponent new (in long l, in ::M2::OctetSeq s) raises (::M2::Ex2, ::M2::Ex1); + }; + local interface CCM_H2 : CCM_H2Explicit, CCM_H2Implicit + { + }; +}; +module M3 +{ + module Impl + { + local interface CImplContext + { + }; + }; +}; diff --git a/TAO/CIAO/CCF/Example/CIDL/Makefile.alt b/TAO/CIAO/CCF/Example/CIDL/Makefile.alt new file mode 100644 index 00000000000..a7ad5cf2faa --- /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/CodeGenerationKit.mwc b/TAO/CIAO/CCF/Example/CodeGenerationKit/CodeGenerationKit.mwc new file mode 100644 index 00000000000..f9f1f1d97e3 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/CodeGenerationKit.mwc @@ -0,0 +1,3 @@ +workspace { + Indentation +} diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.mpc b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.mpc new file mode 100644 index 00000000000..4cf67e380bd --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.mpc @@ -0,0 +1,14 @@ +// $Id$ +project { + + exename = indent_idl + + includes += ../../../.. $(UTILITY_ROOT) + libpaths += ../../../../CCF/CodeGenerationKit + libs += CodeGenerationKit + + Source_Files { + indent_idl.cpp + } + +} diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.vcproj b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.vcproj new file mode 100644 index 00000000000..44c02783f11 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/IDL/IDL.vcproj @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="IDL"
+ ProjectGUID="{605906FB-9A4C-411B-B98C-992D33CB0E46}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ProjectDir)"
+ IntermediateDirectory="$(ProjectDir)/Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4290"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ ForceConformanceInForLoopScope="TRUE"
+ RuntimeTypeInfo="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/idl_indent.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/IDL.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ProjectDir)"
+ IntermediateDirectory="$(ProjectDir)/Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4290"
+ AdditionalIncludeDirectories="../../../../"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/idl_indent.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath=".\indent_idl.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
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..2d4e14a3a9e --- /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..ce0c5eb103c --- /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/Indentation.mwc b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/Indentation.mwc new file mode 100644 index 00000000000..1db9da7f6bc --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/Indentation.mwc @@ -0,0 +1,3 @@ +workspace { + IDL +} 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..0f09fe7a11b --- /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/Indentation/XML/Makefile.alt b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/Makefile.alt new file mode 100644 index 00000000000..bec22a66b07 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/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_xml.cpp + +module_base := indent_xml +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/XML/XML.mpc b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/XML.mpc new file mode 100644 index 00000000000..f35b5987090 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/XML.mpc @@ -0,0 +1,14 @@ +// $Id$ +project { + + exename = indent_xml + + includes += ../../../.. $(UTILITY_ROOT) + libpaths += ../../../../CCF/CodeGenerationKit + libs += CodeGenerationKit + + Source_Files { + indent_xml.cpp + } + +} diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/indent_xml.cpp b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/indent_xml.cpp new file mode 100644 index 00000000000..b65389ca306 --- /dev/null +++ b/TAO/CIAO/CCF/Example/CodeGenerationKit/Indentation/XML/indent_xml.cpp @@ -0,0 +1,32 @@ +// file : CCF/Example/CodeGenerationKit/Indentation/IDL/indent_idl.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CodeGenerationKit/IndentationXML.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include <iostream> + +using std::cout; +using std::endl; + +int +main () +{ + Indentation::Implanter<Indentation::XML> guard (cout); + + cout << "<?xml version=\"1.0\"?>" << endl; + cout << "<!DOCTYPE corbacomponent SYSYEM \"corbacomponent.dtd\">" << endl << endl; + + cout << "<atag>whatever</atag>" << endl; + + cout << "<open>" << endl; + cout << "<openother>" << endl; + cout << "<openother \nlabel=\"<<<<<<<<<>><>\">" << endl; + cout << "text" << endl; + cout << "<taginitself/>" << endl; + cout << "</openother>" << endl; + cout << "</openother>" << endl; + cout << "</open>" << endl; + +} diff --git a/TAO/CIAO/CCF/Example/CodeGenerationKit/Makefile.alt b/TAO/CIAO/CCF/Example/CodeGenerationKit/Makefile.alt new file mode 100644 index 00000000000..07708e72d55 --- /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/ComponentDeploymentDescriptor/Makefile.alt b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Makefile.alt new file mode 100644 index 00000000000..fe4f51206e1 --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Makefile.alt @@ -0,0 +1,26 @@ +# file : CCF/Example/ComponentDeploymentDescriptor/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 := SyntaxTree.cpp Traversal.cpp cdd.cpp + +module_base := cdd +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) + +CXX_LINK_LIBS += -L$(root)/CCF/CodeGenerationKit \ + -lCodeGenerationKit \ + -L$(root)/CCF/CompilerElements \ + -lCompilerElements + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp new file mode 100644 index 00000000000..0a7a3ae6bf2 --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp @@ -0,0 +1,113 @@ +// file : CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "SyntaxTree.hpp" + +using namespace Introspection; + +namespace CDD +{ + 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_; } + + + // PortInstance + // + // + namespace + { + TypeInfo + port_instance_init_ () + { + TypeInfo ti (typeid (PortInstance)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo port_instance_ (port_instance_init_ ()); + } + + TypeInfo const& PortInstance:: + static_type_info () { return port_instance_; } + + + // ComponentInstance + // + // + namespace + { + TypeInfo + component_instance_init_ () + { + TypeInfo ti (typeid (ComponentInstance)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo component_instance_ (component_instance_init_ ()); + } + + TypeInfo const& ComponentInstance:: + static_type_info () { return component_instance_; } + + + // Connection + // + // + namespace + { + TypeInfo + connection_init_ () + { + TypeInfo ti (typeid (Connection)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo connection_ (connection_init_ ()); + } + + TypeInfo const& Connection:: + static_type_info () { return connection_; } + + + // Descriptor + // + // + namespace + { + TypeInfo + descriptor_init_ () + { + TypeInfo ti (typeid (Descriptor)); + ti.add_base (Access::PUBLIC, true, Node::static_type_info ()); + return ti; + } + + TypeInfo descriptor_ (descriptor_init_ ()); + } + + TypeInfo const& Descriptor:: + static_type_info () { return descriptor_; } + } +} diff --git a/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp new file mode 100644 index 00000000000..3739826b27d --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp @@ -0,0 +1,286 @@ +// file : CCF/Example/ComponentDeploymentDescriptor/SyntaxTree.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CDD_SYNTAX_TREE_HPP +#define CDD_SYNTAX_TREE_HPP + +#include <set> +#include <vector> +#include <string> + + +#include "CCF/CompilerElements/ReferenceCounting.hpp" +#include "CCF/CompilerElements/Introspection.hpp" + +namespace CDD +{ + namespace SyntaxTree + { + using ReferenceCounting::StrictPtr; + + // + // + // + 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 ()); + } + + public: + 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 (); + }; + + typedef + std::vector<NodePtr> + NodeList; + + + // + // + // + class PortInstance : public virtual Node + { + public: + + virtual + ~PortInstance () throw () {} + + PortInstance (std::string name) + : name_ (name) + { + type_info (static_type_info ()); + } + + public: + std::string + name () const + { + return name_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + std::string name_; + }; + + typedef + StrictPtr<PortInstance> + PortInstancePtr; + + template <typename T> + struct NameComparator + { + bool + operator () (T const& x, T const& y) const + { + return x->name () < y->name (); + } + }; + + typedef + std::set<PortInstancePtr, NameComparator<PortInstancePtr> > + PortInstanceSet; + + + // + // + // + class ComponentInstance : public virtual Node + { + public: + typedef + PortInstanceSet::const_iterator + Iterator; + + public: + + virtual + ~ComponentInstance () throw () {} + + ComponentInstance (std::string name, + std::string type) + : name_ (name), + type_ (type) + { + type_info (static_type_info ()); + } + + public: + + std::string + name () const + { + return name_; + } + + std::string + type () const + { + return type_; + } + + public: + class AlreadyExist {}; + + void + insert (PortInstancePtr const& d) throw (AlreadyExist) + { + if (!ports_.insert (d).second) throw AlreadyExist (); + } + + Iterator + begin () const + { + return ports_.begin (); + } + + + Iterator + end () const + { + return ports_.end (); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + std::string name_; + std::string type_; + + PortInstanceSet ports_; + }; + + typedef + StrictPtr<ComponentInstance> + ComponentInstancePtr; + + + // + // + // + class Connection : public virtual Node + { + public: + virtual + ~Connection () throw () {} + + Connection (PortInstancePtr const& left, + PortInstancePtr const& right) + : left_ (left), + right_ (right) + { + type_info (static_type_info ()); + } + + public: + + PortInstancePtr + left () const + { + return left_; + } + + PortInstancePtr + right () const + { + return right_; + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + PortInstancePtr left_; + PortInstancePtr right_; + }; + + typedef + StrictPtr<Connection> + ConnectionPtr; + + + // + // + // + class Descriptor : public virtual Node + { + public: + typedef + NodeList::const_iterator + Iterator; + + public: + virtual + ~Descriptor () throw () {} + + Descriptor () + { + type_info (static_type_info ()); + } + + public: + void + insert (NodePtr const& n) + { + nodes_.push_back (n); + } + + Iterator + begin () const + { + return nodes_.begin (); + } + + + Iterator + end () const + { + return nodes_.end (); + } + + public: + static Introspection::TypeInfo const& + static_type_info (); + + private: + NodeList nodes_; + }; + + typedef + StrictPtr<Descriptor> + DescriptorPtr; + } +} + + +#endif // CDD_SYNTAX_TREE_HPP diff --git a/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp new file mode 100644 index 00000000000..8f6a20649bc --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp @@ -0,0 +1,112 @@ +// file : CCF/Example/ComponentDeploymentDescriptor/Traversal.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Traversal.hpp" + +using namespace Introspection; + +namespace CDD +{ + 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); + } + } + } + } +} diff --git a/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp new file mode 100644 index 00000000000..2b6697abae9 --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp @@ -0,0 +1,386 @@ +// file : CCF/Example/ComponentDeploymentDescriptor/Traversal.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CDD_TRAVERSAL_HPP +#define CDD_TRAVERSAL_HPP + +#include <map> +#include <vector> + +#include "CCF/CompilerElements/Introspection.hpp" + +#include "SyntaxTree.hpp" + +namespace CDD +{ + 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_; + }; + + + // + // + // + struct PortInstance : Traverser + { + typedef + SyntaxTree::PortInstancePtr + NodePtr; + + PortInstance () + { + map (typeid (SyntaxTree::PortInstance), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::PortInstance> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct ComponentInstance : Traverser + { + public: + + virtual void + add_port_delegate (Dispatcher* d) + { + port_delegates_.push_back (d); + } + + public: + typedef + SyntaxTree::ComponentInstancePtr + NodePtr; + + ComponentInstance () + { + map (typeid (SyntaxTree::ComponentInstance), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::ComponentInstance> ()); + } + + virtual void + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + ports (n); + post (n); + } + } + + virtual void + pre (NodePtr const&) + { + } + + virtual void + ports (NodePtr const& n) + { + delegate_port (n); + } + + virtual void + post (NodePtr const&) + { + } + + protected: + virtual void + delegate_port (NodePtr const& s) + { + for (SyntaxTree::ComponentInstance::Iterator n = s->begin (); + n != s->end (); + n++) + { + dispatch (*n); + + for (DispatcherList::const_iterator i = port_delegates_.begin (); + i != port_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + } + } + } + + protected: + DispatcherList port_delegates_; + }; + + + // + // + // + struct Connection : Traverser + { + typedef + SyntaxTree::ConnectionPtr + NodePtr; + + Connection () + { + map (typeid (SyntaxTree::Connection), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Connection> ()); + } + + virtual void + traverse (NodePtr const& n) + { + delegate (n); + } + }; + + + // + // + // + struct Descriptor : Traverser + { + public: + + virtual void + add_node_delegate (Dispatcher* d) + { + node_delegates_.push_back (d); + } + + public: + typedef + SyntaxTree::DescriptorPtr + NodePtr; + + Descriptor () + { + map (typeid (SyntaxTree::Descriptor), this); + } + + virtual void + traverse (SyntaxTree::NodePtr const& n) + { + traverse (n->dynamic_type<SyntaxTree::Descriptor> ()); + } + + virtual void + traverse (NodePtr const& n) + { + if (!delegate (n)) + { + pre (n); + ports (n); + post (n); + } + } + + virtual void + pre (NodePtr const&) + { + } + + virtual void + ports (NodePtr const& n) + { + delegate_node (n); + } + + virtual void + post (NodePtr const&) + { + } + + protected: + virtual void + delegate_node (NodePtr const& s) + { + for (SyntaxTree::Descriptor::Iterator n = s->begin (); + n != s->end (); + n++) + { + dispatch (*n); + + for (DispatcherList::const_iterator i = node_delegates_.begin (); + i != node_delegates_.end (); + i++) + { + (*i)->dispatch (*n); + } + } + } + + protected: + DispatcherList node_delegates_; + }; + } +} + +#endif // CDD_TRAVERSAL_HPP diff --git a/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp new file mode 100644 index 00000000000..737260014bc --- /dev/null +++ b/TAO/CIAO/CCF/Example/ComponentDeploymentDescriptor/cdd.cpp @@ -0,0 +1,144 @@ +// file : CCF/Example/ComponentDeploymentDescriptor/cdd.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +#include "CCF/CodeGenerationKit/IndentationXML.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include "SyntaxTree.hpp" +#include "Traversal.hpp" + +using std::cout; +using std::cerr; +using std::endl; + +using namespace CDD; + +/* +struct CI_Emitter : public virtual Traversal::ComponentInstance +{ + virtual void + pre (NodePtr const& n) + { + cout << "component instance " << n->name () << " of type " + << n->type () << endl << "{" << endl; + + } + + virtual void + post (NodePtr const& n) + { + cout << "}" << endl; + } + +}; + +struct PI_Emitter : public virtual Traversal::PortInstance +{ + virtual void + traverse (NodePtr const& n) + { + cout << " port " << n->name () << ";" << endl; + } +}; + +struct C_Emitter : public virtual Traversal::Connection +{ + virtual void + traverse (NodePtr const& n) + { + cout << "connection " << n->left ()->name () + << "<--->" << n->right ()->name () << ";" << endl; + } +}; + +*/ + + +struct CI_Emitter : public virtual Traversal::ComponentInstance +{ + virtual void + pre (NodePtr const& n) + { + cout << "<ComponentInstance name=\"" << n->name () << "\" type=\"" + << n->type () << "\" >" << endl; + + } + + virtual void + post (NodePtr const& n) + { + cout << "</ComponentInstance>" << endl << endl; + } + +}; + +struct PI_Emitter : public virtual Traversal::PortInstance +{ + virtual void + traverse (NodePtr const& n) + { + cout << "<Port name=\"" << n->name () << "\" />" << endl; + } +}; + +struct C_Emitter : public virtual Traversal::Connection +{ + virtual void + traverse (NodePtr const& n) + { + cout << "<Connection left=\"" << n->left ()->name () << "\" " + << "right=\"" << n->right ()->name () << "\" />" << endl; + } +}; + + +int +main () +{ + using namespace SyntaxTree; + + try + { + // Construct tree + + DescriptorPtr d (new Descriptor); + + PortInstancePtr ap (new PortInstance ("ap")); + ComponentInstancePtr a (new ComponentInstance ("a", "A")); + a->insert (ap); + d->insert (a); + + PortInstancePtr bp (new PortInstance ("bp")); + ComponentInstancePtr b (new ComponentInstance ("b", "B")); + b->insert (bp); + d->insert (b); + + ConnectionPtr c (new Connection (ap, bp)); + d->insert (c); + + // Construct Traverser + + Traversal::Descriptor dt; + + CI_Emitter cie; + PI_Emitter pie; + cie.add_port_delegate (&pie); + + C_Emitter ce; + + dt.add_node_delegate (&cie); + dt.add_node_delegate (&ce); + + // Set auto-indentation for cout + Indentation::Implanter<Indentation::XML> guard (cout); + + dt.traverse (d); + } + catch (...) + { + cerr << "caught something" << endl; + } +} diff --git a/TAO/CIAO/CCF/Example/Example.mwc b/TAO/CIAO/CCF/Example/Example.mwc new file mode 100644 index 00000000000..9114d3f7f08 --- /dev/null +++ b/TAO/CIAO/CCF/Example/Example.mwc @@ -0,0 +1,4 @@ +workspace { + CIDL + CodeGenerationKit +}
\ No newline at end of file diff --git a/TAO/CIAO/CCF/Example/Example.sln b/TAO/CIAO/CCF/Example/Example.sln new file mode 100644 index 00000000000..a829474c1cb --- /dev/null +++ b/TAO/CIAO/CCF/Example/Example.sln @@ -0,0 +1,29 @@ +Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LocalExecutorMapping", "CIDL\LocalExecutorMapping\LocalExecutorMapping.vcproj", "{787D727E-24B5-4791-87A3-3235EAD4FEFF}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IDL", "CodeGenerationKit\Indentation\IDL\IDL.vcproj", "{605906FB-9A4C-411B-B98C-992D33CB0E46}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {787D727E-24B5-4791-87A3-3235EAD4FEFF}.Debug.ActiveCfg = Debug|Win32
+ {787D727E-24B5-4791-87A3-3235EAD4FEFF}.Debug.Build.0 = Debug|Win32
+ {787D727E-24B5-4791-87A3-3235EAD4FEFF}.Release.ActiveCfg = Release|Win32
+ {787D727E-24B5-4791-87A3-3235EAD4FEFF}.Release.Build.0 = Release|Win32
+ {605906FB-9A4C-411B-B98C-992D33CB0E46}.Debug.ActiveCfg = Debug|Win32
+ {605906FB-9A4C-411B-B98C-992D33CB0E46}.Debug.Build.0 = Debug|Win32
+ {605906FB-9A4C-411B-B98C-992D33CB0E46}.Release.ActiveCfg = Release|Win32
+ {605906FB-9A4C-411B-B98C-992D33CB0E46}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.cpp b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.cpp new file mode 100644 index 00000000000..6645b7f0b67 --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.cpp @@ -0,0 +1,32 @@ +// file : Example/IDL2/CxxMapping/Generator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Generator.hpp" +#include "GeneratorImpl.hpp" + +namespace IDL2 +{ + Generator:: + ~Generator () + { + } + + Generator:: + Generator () + : pimpl_ (new GeneratorImpl), impl_ (*pimpl_) + { + } + + Generator:: + Generator (GeneratorImpl& gi) + : pimpl_ (), impl_ (gi) + { + } + + void Generator:: + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu) + { + impl_.generate (tu); + } +} diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.hpp b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.hpp new file mode 100644 index 00000000000..4e231267dae --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Generator.hpp @@ -0,0 +1,34 @@ +// file : Example/IDL2/CxxMapping/Generator.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_HPP +#define EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_HPP + +#include <memory> + +#include "CCF/IDL2/SemanticGraph.hpp" + +namespace IDL2 +{ + class GeneratorImpl; + + class Generator + { + public: + ~Generator (); + Generator (); + + void + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu); + + protected: + Generator (GeneratorImpl&); + + protected: + std::auto_ptr<GeneratorImpl> pimpl_; + GeneratorImpl& impl_; + }; +} + +#endif // EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/GeneratorImpl.hpp b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/GeneratorImpl.hpp new file mode 100644 index 00000000000..f5e6edc3e77 --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/GeneratorImpl.hpp @@ -0,0 +1,533 @@ +// file : Example/IDL2/CxxMapping/GeneratorImpl.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_IMPL_HPP +#define EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_IMPL_HPP + +#include <iostream> + +#include "CCF/CodeGenerationKit/IndentationCxx.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include "CCF/IDL2/SemanticGraph.hpp" +#include "CCF/IDL2/Traversal.hpp" + +namespace IDL2 +{ + using namespace CCF::IDL2; + + using std::cout; + using std::endl; + + struct Inhibitor + { + virtual void + operator() () const = 0; + }; + + template <typename O, typename S, typename T> + class InhibitorTemplate : public Inhibitor + { + public: + typedef void (O::*F) (S&, T&); + + InhibitorTemplate (O& o, F f, S& s, T& t) + : o_ (o), f_ (f), s_ (s), t_ (t) + { + } + + virtual void + operator() () const + { + (o_.*f_)(s_, t_); + } + + private: + O& o_; + F f_; + S& s_; + T& t_; + }; + + template <typename O, + typename S, + typename T = Traversal::EdgeDispatcherBase> + class Factory + { + public: + typedef void (O::*F) (S&, T&); + + Factory (O& o, F f, T& t) + : o_ (o), f_ (f), t_ (t) + { + } + + InhibitorTemplate<O, S, T> + operator() (S& s) const + { + return InhibitorTemplate<O, S, T> (o_, f_, s, t_); + } + + private: + O& o_; + F f_; + T& t_; + }; + + std::ostream& + operator<< (std::ostream& os, Inhibitor const& p) + { + p (); + return os; + } + + class GeneratorImpl + { + protected: + // Layer 1 + // + + // Layer 2 + // + + //-- + + // Layer 3 + // + + //-- + + struct InterfaceHdr : Traversal::UnconstrainedInterface + { + virtual void + pre (Type&) + { + cout << "class "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + inherits_none (Type&) + { + cout << " : public virtual CORBA::Impl::Stub"; + } + + virtual void + names_pre (Type&) + { + cout << "{" + << "public:" << endl; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + + struct Module : Traversal::Module + { + virtual void + pre (Type& m) + { + cout << "namespace " << m.name (); + } + + virtual void + names_pre (Type& m) + { + cout << "{"; + } + + virtual void + names_post (Type& m) + { + cout << "}"; + } + }; + + struct TypeName : Traversal::Nameable, + Traversal::FundamentalType + { + virtual void + traverse (SemanticGraph::Nameable& n) + { + cout << n.scoped_name (); + } + + virtual void + traverse (SemanticGraph::FundamentalType& ft) + { + cout << ft.name (); + } + }; + + // Layer 4 + // + + //-- + + + struct OperationHdr : Traversal::Operation + { + virtual void + name (Type& o) + { + cout << " " << o.name (); + } + + virtual void + receives_pre (Type&) + { + cout << " ("; + } + + virtual void + receives_post (Type&) + { + cout << ")"; + } + + virtual void + raises_pre (Type&) + { + cout << " throw ("; + } + + virtual void + raises_post (Type&) + { + cout << ")"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct OperationImpl : Traversal::Operation + { + OperationImpl () + : marshal (*this, &OperationImpl::receives, marshal_), + unmarshal (*this, &OperationImpl::receives, unmarshal_), + ret_type (*this, &OperationImpl::returns, ret_type_), + cast_type (*this, &OperationImpl::returns, cast_type_) + { + } + + virtual void + name (Type& o) + { + cout << " " + << o.scoped_name ().scope_name ().simple_name () + << "::" << o.name (); + } + + virtual void + receives_pre (Type&) + { + cout << " ("; + } + + virtual void + receives_post (Type&) + { + cout << ")"; + } + + virtual void + raises_pre (Type&) + { + cout << " throw ("; + } + + virtual void + raises_post (Type&) + { + cout << ")"; + } + + virtual void + post (Type& o) + { + cout << "{" + << "OCDRStream os;" + << "static_cast<void> (os" << marshal (o) << ");" + << "ICDRStream is (Stub::make_call (\"" + << o.name () << "\", os));" + << ret_type (o) << " _retval;" + << "is >> _retval" << unmarshal (o) << ";" + << "return " << "static_cast<" << cast_type (o) << "> (_retval);" + << "}"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + + struct MarshalParameter : Traversal::Receives, + Traversal::InParameter, + Traversal::InOutParameter + { + MarshalParameter () + { + node_traverser (*this); + } + + virtual void + traverse (SemanticGraph::InParameter& p) + { + cout << " << " << p.name (); + } + + virtual void + traverse (SemanticGraph::InOutParameter& p) + { + cout << " << " << p.name (); + } + } marshal_; + + Factory<OperationImpl, Type> marshal; + + struct UnmarshalParameter : Traversal::Receives, + Traversal::InOutParameter, + Traversal::OutParameter + { + UnmarshalParameter () + { + node_traverser (*this); + } + + virtual void + traverse (SemanticGraph::InOutParameter& p) + { + cout << " >> " << p.name (); + } + + virtual void + traverse (SemanticGraph::OutParameter& p) + { + cout << " >> " << p.name (); + } + } unmarshal_; + + Factory<OperationImpl, Type> unmarshal; + + + struct ReturnType : Traversal::Belongs, Traversal::Void, TypeName + { + ReturnType () + { + node_traverser (*this); + } + + virtual void + traverse (SemanticGraph::Void&) + { + // Void is a type for which do-nothing operator>> (ICDRStream&) + // is provided. Its main purpose is to make C++ type handling + // more regular and thus allow more streamlined code generation. + // + cout << "Void"; + } + } ret_type_; + + Factory<OperationImpl, Type> ret_type; + + struct CastType : Traversal::Belongs, TypeName + { + CastType () + { + node_traverser (*this); + } + } cast_type_; + + Factory<OperationImpl, Type> cast_type; + }; + + // Layer 5 + // + + //-- + + struct Parameter : Traversal::Parameter + { + virtual void + name (Type& p) + { + cout << " " << p.name (); + } + }; + + public: + + GeneratorImpl () + { + // Layer 1 + // + unit.edge_traverser (contains_principal); + + //-- + + contains_principal.node_traverser (region); + + // Layer 2 + // + region.edge_traverser (contains_root); + + //-- + + contains_root.node_traverser (root); + + // Layer 3 + // + root.edge_traverser (defines); + + //-- + defines.node_traverser (interface_hdr); + defines.node_traverser (interface_impl); + defines.node_traverser (module); + + // Layer 4 + // + module.edge_traverser (defines); + + interface_hdr.edge_traverser (inherits); + interface_hdr.edge_traverser (interface_hdr_defines); + + interface_impl.edge_traverser (interface_impl_defines); + + //-- + inherits.node_traverser (type_name); + + interface_hdr_defines.node_traverser (operation_hdr); + interface_impl_defines.node_traverser (operation_impl); + + // Layer 5 + // + + operation_hdr.edge_traverser (receives); + operation_hdr.edge_traverser (returns); + + operation_impl.edge_traverser (receives); + operation_impl.edge_traverser (returns); + + //-- + + receives.node_traverser (parameter); + returns.node_traverser (type_name); + + // Layer 6 + // + parameter.edge_traverser (belongs); + + //-- + + belongs.node_traverser (type_name); + + } + + protected: + Traversal::TranslationUnit unit; + + // Layer 1 + // + Traversal::ContainsPrincipal contains_principal; + + //-- + + Traversal::TranslationRegion region; + + // Layer 2 + // + Traversal::ContainsRoot contains_root; + + //-- + + Traversal::Root root; + + // Layer 3 + // + Traversal::Defines defines; + + //-- + InterfaceHdr interface_hdr; + Traversal::UnconstrainedInterface interface_impl; + + Module module; + + TypeName type_name; + + // Layer 4 + // + Traversal::Inherits inherits; + Traversal::Defines interface_hdr_defines; + Traversal::Defines interface_impl_defines; + + //-- + OperationHdr operation_hdr; + OperationImpl operation_impl; + + // Layer 5 + // + Traversal::Receives receives; + Traversal::Returns returns; + + //-- + + Parameter parameter; + + // Layer 6 + // + Traversal::Belongs belongs; + + public: + void + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu) + { + // Plug automatic IDL indenter. + // + Indentation::Implanter<Indentation::Cxx> guard (cout); + + unit.traverse (tu); + } + }; +} + +#endif // EXAMPLE_IDL2_CXX_MAPPING_GENERATOR_IMPL_HPP diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Makefile.alt b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Makefile.alt new file mode 100644 index 00000000000..a629a1f7298 --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/Makefile.alt @@ -0,0 +1,31 @@ +# file : Example/IDL2/CxxMapping/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 := driver.cpp Generator.cpp + +module_base := driver +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/driver.cpp b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/driver.cpp new file mode 100644 index 00000000000..72700da941b --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/driver.cpp @@ -0,0 +1,95 @@ +// file : Example/IDL2/CxxMapping/driver.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL2/LexicalAnalyzer.hpp" +#include "CCF/IDL2/Parser.hpp" +#include "CCF/IDL2/SemanticGraph.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + +#include "Generator.hpp" + +using std::cerr; +using std::cout; +using std::endl; + +using namespace CCF::IDL2; +using namespace CCF::IDL2::SemanticGraph; + +//@@ code repetition in driver. +// + +int +main () +{ + try + { + Diagnostic::Stream dout; + + fs::path file_path ("stdout"); + + CCF::InputStreamAdapter isa (std::cin); + CCF::Preprocessor pp (isa); + + 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 () < 2) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnit tu; + + // Compilation context. + // + CCF::CompilerElements::Context context; + context.set ("file-path", file_path); + context.set ("trace-semantic-action", false); + + + SemanticAction::Impl::Factory actions (context, dout, tu); + + Parser parser (context, dout, lexer, actions); + + Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (dout.error_count () != 0) return -1; + + IDL2::Generator g; + + g.generate (tu); + } + catch (std::bad_cast const&) + { + cerr << "bad cast exception" << endl; + } + catch (InvalidName const&) + { + cerr << "invalid name exception" << endl; + } + catch (...) + { + cerr << "caught unknown exception" << endl; + return -1; + } +} diff --git a/TAO/CIAO/CCF/Example/IDL2/CxxMapping/test.idl b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/test.idl new file mode 100644 index 00000000000..82e44440c58 --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/CxxMapping/test.idl @@ -0,0 +1,12 @@ +// file : Example/IDL2/CxxMapping/test.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +module M +{ + interface I + { + long foo (in string s, inout boolean b, out long l); + void bar (); + }; +}; diff --git a/TAO/CIAO/CCF/Example/IDL2/Makefile.alt b/TAO/CIAO/CCF/Example/IDL2/Makefile.alt new file mode 100644 index 00000000000..5e4afe7c185 --- /dev/null +++ b/TAO/CIAO/CCF/Example/IDL2/Makefile.alt @@ -0,0 +1,18 @@ +# file : Example/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 := +target_directory_list := CxxMapping +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..3e5d048ce70 --- /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 IDL2 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..a8ac2abe612 --- /dev/null +++ b/TAO/CIAO/CCF/Makefile.alt @@ -0,0 +1,20 @@ +# 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 Test Example +default_makefile_name := Makefile.alt + +Test : CCF +Example : Test + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp b/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp new file mode 100644 index 00000000000..278278b3360 --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.cpp @@ -0,0 +1,32 @@ +// file : Test/CIDL/Compiler/Generator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Generator.hpp" +#include "GeneratorImpl.hpp" + +namespace CIDL +{ + Generator:: + ~Generator () + { + } + + Generator:: + Generator () + : pimpl_ (new GeneratorImpl), impl_ (*pimpl_) + { + } + + Generator:: + Generator (GeneratorImpl& gi) + : pimpl_ (), impl_ (gi) + { + } + + void Generator:: + generate (CCF::IDL3::SemanticGraph::TranslationUnit& tu) + { + impl_.generate (tu); + } +} diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp b/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp new file mode 100644 index 00000000000..3876195469d --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/Generator.hpp @@ -0,0 +1,34 @@ +// file : Test/CIDL/Compiler/Generator.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_CIDL_COMPILER_GENERATOR_HPP +#define TEST_CIDL_COMPILER_GENERATOR_HPP + +#include <memory> + +#include "CCF/CIDL/SemanticGraph.hpp" + +namespace CIDL +{ + class GeneratorImpl; + + class Generator + { + public: + ~Generator (); + Generator (); + + void + generate (CCF::CIDL::SemanticGraph::TranslationUnit& tu); + + protected: + Generator (GeneratorImpl&); + + protected: + std::auto_ptr<GeneratorImpl> pimpl_; + GeneratorImpl& impl_; + }; +} + +#endif // TEST_CIDL_COMPILER_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp b/TAO/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp new file mode 100644 index 00000000000..6829fa2bb2b --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/GeneratorImpl.hpp @@ -0,0 +1,227 @@ +// file : Test/CIDL/Compiler/GeneratorImpl.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP +#define TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP + +#include <iostream> + +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include "CCF/CIDL/SemanticGraph.hpp" +#include "CCF/CIDL/Traversal.hpp" + +#include "../../IDL3/Compiler/GeneratorImpl.hpp" + +namespace CIDL +{ + using namespace CCF::CIDL; + + using std::cout; + using std::endl; + + class GeneratorImpl : public IDL3::GeneratorImpl + { + protected: + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + + struct Composition : Traversal::Composition + { + virtual void + pre (Type& c) + { + cout << "composition " << c.kind () << " "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + }; + + + struct HomeExecutor : Traversal::HomeExecutor + { + virtual void + pre (Type&) + { + cout << "home executor "; + } + + virtual void + name (Type& he) + { + cout << he.name () << "{"; + } + + virtual void + implements_pre (Type&) + { + cout << "implements "; + } + + virtual void + implements_post (Type&) + { + cout << ";"; + } + + virtual void + manages_pre (Type&) + { + cout << "manages "; + } + + virtual void + manages_post (Type&) + { + cout << ";"; + } + + virtual void + post (Type& he) + { + cout << "};"; + } + }; + + + // Layer 4 + // + + //-- + + // Layer 5 + // + + //-- + + struct SimpleName : Traversal::Nameable + { + virtual void + traverse (Type& n) + { + cout << n.name (); + } + }; + + public: + + GeneratorImpl () + { + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + + defines.node_traverser (composition); + + // Layer 4 + // + + composition.edge_traverser (composition_defines); + + //-- + + composition_defines.node_traverser (home_executor); + + // Layer 5 + // + home_executor.edge_traverser (home_executor_implements); + home_executor.edge_traverser (home_executor_manages); + + //-- + + home_executor_implements.node_traverser (type_name); + home_executor_manages.node_traverser (simple_name); + + // Layer 6 + // + + } + + protected: + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + + Composition composition; + + // Layer 4 + // + + Traversal::Defines composition_defines; + + //-- + + HomeExecutor home_executor; + + // Layer 5 + // + Traversal::Implements home_executor_implements; + Traversal::Manages home_executor_manages; + + //-- + + SimpleName simple_name; + + // Layer 6 + // + + public: + void + generate (CCF::CIDL::SemanticGraph::TranslationUnit& tu) + { + // Plug automatic IDL indenter. + // + Indentation::Implanter<Indentation::IDL> guard (cout); + + unit.traverse (tu); + } + }; +} + +#endif // TEST_CIDL_COMPILER_GENERATOR_IMPL_HPP diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/Makefile.alt b/TAO/CIAO/CCF/Test/CIDL/Compiler/Makefile.alt new file mode 100644 index 00000000000..a4edc5af913 --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/Makefile.alt @@ -0,0 +1,35 @@ +# file : Test/IDL3/Compiler/driver/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 := driver.cpp Generator.cpp + +module_base := driver +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/CIDL \ + -lCIDL \ + -L$(root)/CCF/IDL3 \ + -lIDL3 \ + -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/driver.cpp b/TAO/CIAO/CCF/Test/CIDL/Compiler/driver.cpp new file mode 100644 index 00000000000..cd03d281820 --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/driver.cpp @@ -0,0 +1,96 @@ +// file : Test/CIDL/Compiler/driver.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/CIDL/LexicalAnalyzer.hpp" +#include "CCF/CIDL/Parser.hpp" +#include "CCF/CIDL/SemanticGraph.hpp" +#include "CCF/CIDL/SemanticAction/Impl/Factory.hpp" + +#include "Generator.hpp" + +#include <iostream> + +using std::cerr; +using std::cout; +using std::endl; + +using namespace CCF::CIDL; +using namespace SemanticGraph; + +int +main () +{ + try + { + Diagnostic::Stream dout; + + fs::path file_path ("stdout"); + + CCF::InputStreamAdapter isa (std::cin); + CCF::Preprocessor pp (isa); + + 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 () < 2) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnit tu; + + // Compilation context. + // + CCF::CompilerElements::Context context; + context.set ("file-path", file_path); + context.set ("trace-semantic-action", false); + + + SemanticAction::Impl::Factory actions (context, dout, tu); + + Parser parser (context, dout, lexer, actions); + + //@@ should be able to use IDL3 here. Or better yet get rid of this + // function completely. + // + CCF::IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (dout.error_count () != 0) return -1; + + CIDL::Generator g; + + g.generate (tu); + + } + catch (std::bad_cast const&) + { + cerr << "bad cast exception" << endl; + } + catch (InvalidName const&) + { + cerr << "invalid name exception" << endl; + } + catch (...) + { + cerr << "caught unknown exception" << endl; + return -1; + } +} diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig b/TAO/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig new file mode 100644 index 00000000000..6ba766db738 --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/result.cidl.orig @@ -0,0 +1,14 @@ +component C +{ +}; +home H manages ::C +{ +}; +composition session SC +{ + home executor H_Exec + { + implements ::H; + manages C_Exec; + }; +}; diff --git a/TAO/CIAO/CCF/Test/CIDL/Compiler/test.cidl b/TAO/CIAO/CCF/Test/CIDL/Compiler/test.cidl new file mode 100644 index 00000000000..349712a18df --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Compiler/test.cidl @@ -0,0 +1,21 @@ +// file : CCF/Test/CIDL/Compiler/test.cidl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +component C +{ +}; + +home H manages C +{ +}; + +composition session SC +{ + home executor H_Exec + { + implements H; + manages C_Exec; + }; +}; + diff --git a/TAO/CIAO/CCF/Test/CIDL/Makefile.alt b/TAO/CIAO/CCF/Test/CIDL/Makefile.alt new file mode 100644 index 00000000000..2f6df8d549c --- /dev/null +++ b/TAO/CIAO/CCF/Test/CIDL/Makefile.alt @@ -0,0 +1,19 @@ +# file : Test/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 := Compiler +default_makefile_name := Makefile.alt + + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt new file mode 100644 index 00000000000..ac86d6e10ac --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/Makefile.alt @@ -0,0 +1,33 @@ +# file : Test/IDL2/Compiler/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 := driver.cpp + +translated_units += ../Traversal/Recreate/Generator.o + +module_base := driver +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp b/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp new file mode 100644 index 00000000000..16f8fce9656 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/driver.cpp @@ -0,0 +1,93 @@ +// file : Test/IDL2/Compiler/driver.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL2/LexicalAnalyzer.hpp" +#include "CCF/IDL2/Parser.hpp" +#include "CCF/IDL2/SemanticGraph.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + +#include "../Traversal/Recreate/Generator.hpp" + +#include <iostream> + +using std::cerr; +using std::cout; +using std::endl; + +using namespace CCF::IDL2; +using namespace CCF::IDL2::SemanticGraph; + +int +main () +{ + try + { + Diagnostic::Stream dout; + + fs::path file_path ("stdout"); + + CCF::InputStreamAdapter isa (std::cin); + CCF::Preprocessor pp (isa); + + 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 () < 2) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnit tu; + + // Compilation context. + // + CCF::CompilerElements::Context context; + context.set ("file-path", file_path); + context.set ("trace-semantic-action", false); + + + SemanticAction::Impl::Factory actions (context, dout, tu); + + Parser parser (context, dout, lexer, actions); + + Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (dout.error_count () != 0) return -1; + + IDL2::Generator g; + + g.generate (tu); + + } + catch (std::bad_cast const&) + { + cerr << "bad cast exception" << endl; + } + catch (InvalidName const&) + { + cerr << "invalid name exception" << endl; + } + catch (...) + { + cerr << "caught unknown exception" << endl; + return -1; + } +} diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig b/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig new file mode 100644 index 00000000000..a29258b9e6f --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/result.idl.orig @@ -0,0 +1,88 @@ +module AttributeTest +{ + interface I + { + attribute long a; + attribute string foo; + }; +}; +module InterfaceTest +{ + abstract interface AI; + local interface LI; + interface I; + abstract interface AI + { + }; + interface I : ::InterfaceTest::AI + { + }; + local interface LI : ::InterfaceTest::I, ::InterfaceTest::AI + { + }; +}; +module MemberTest +{ + typedef long Id; + struct S + { + long id; + string foo; + string bar; + string baz; + }; +}; +module ModuleTest +{ + module M + { + module N + { + typedef long L; + }; + }; + module M + { + typedef long L; + }; + module N + { + typedef long L; + }; +}; +module OperationTest +{ + interface I + { + long f (in string a, out long b, inout octet c); + }; +}; +module Sequence +{ + typedef sequence<octet> OctetSeq; + typedef sequence<octet> RawSeq; + typedef sequence<string> StringSeq; + typedef sequence<string> StrSeq; +}; +module StructTest +{ + struct S; + struct S + { + long m; + }; +}; +module TypeidTest +{ + interface I; + typeid ::TypeidTest::I "Foo"; + typeprefix ::TypeidTest "Bar"; +}; +module TypedefTest +{ + interface I; + typedef ::TypedefTest::I J; + interface I + { + }; +}; diff --git a/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl b/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl new file mode 100644 index 00000000000..1d18e7118fe --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Compiler/test.idl @@ -0,0 +1,151 @@ +// file : CCF/Test/IDL2/Compiler/test.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Attribute +// +// +module AttributeTest +{ + interface I + { + attribute long a; + attribute string foo; + }; +}; + +// Interface +// +// +module InterfaceTest +{ + abstract interface AI; + local interface LI; + interface I; + + abstract interface AI + { + }; + + interface I : AI + { + }; + + local interface LI : I, AI + { + }; +}; + +// Member +// +// +module MemberTest +{ + typedef long Id; + + struct S + { + Id id; + string foo, bar, baz; + }; +}; + +// Module +// +// +module ModuleTest +{ + module M + { + module N + { + typedef long L; + }; + }; + + module M + { + typedef N::L L; + }; + + module N + { + typedef M::N::L L; + }; +}; + + +// Operation +// +// +module OperationTest +{ + interface I + { + long f (in string a, out long b, inout octet c); + }; +}; + + +// Sequence +// +// +module Sequence +{ + typedef sequence<octet> OctetSeq; + + typedef OctetSeq RawSeq; + + typedef sequence<string> StringSeq, StrSeq; +}; + + +// Struct +// +// +module StructTest +{ + struct S; + + struct S + { + long m; // Struct cannot be empty. + }; + +}; + +// Typeid +// +// +module TypeidTest +{ + interface I; + + typeid I "Foo"; + typeprefix TypeidTest "Bar"; +}; + + +// Typedef +// +// + +module TypedefTest +{ + interface I; + + typedef I J; + + interface I + { + /* + struct S + { + long l; + }; + + J::S op (); + */ + }; +}; + 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..dc1aa225336 --- /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/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/Makefile.alt new file mode 100644 index 00000000000..35a4e82e525 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Makefile.alt @@ -0,0 +1,24 @@ +# file : Test/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 := +target_directory_list := Compiler \ + SemanticGraph \ + Traversal + +default_makefile_name := Makefile.alt + +Traversal : SemanticGraph +Compiler : Traversal + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + 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..22a99ffadf2 --- /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..edfd868809b --- /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; +} + diff --git a/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.cpp b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.cpp new file mode 100644 index 00000000000..202a3e6fcd5 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.cpp @@ -0,0 +1,165 @@ +// file : Test/IDL2/SemanticGraph/HandBuilt/Builder.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +#include "Builder.hpp" + +using namespace CCF::IDL2::SemanticGraph; + +//@@ tmp +using std::cerr; +using std::endl; + +TranslationUnit* Builder:: +build () +{ + /* + 0 + 1 #include "../foo/quote.idl" + 2 #include <ui/bracket.idl> + 3 + 4 module M + 5 { + 6 + 7 interface I; + 8 + 9 typedef I J; + 10 + 11 interface I + 12 { + 13 void f (in long id, out string name); + 14 + 15 attribute long a; + 16 }; + 17 + 18 interface Q : J {}; + 19 + 20 typeid I "Foo"; + 21 typeprefix M "Bar"; + 22 + 23 struct S + 24 { + 25 long member; + 26 }; + 27 + 28 typedef sequence<long> LongSeq; + 29 + 30 }; + 31 + 32 + */ + + //@@ names can be spcified without explicit construction. + // + + TranslationUnit& tu (*(new TranslationUnit)); + + + // 0: Implied translation region with fundamental types. + // + // + TranslationRegion& fundamental (tu.new_node<TranslationRegion> ()); + tu.new_edge<ContainsImplied> (tu, fundamental, ".fundamental"); + + Root& fundamental_root (tu.new_node<Root> ()); + tu.new_edge<ContainsRoot> (fundamental, fundamental_root); + + Void& void_ (tu.new_node<Void> ()); + tu.new_edge<Defines> (fundamental_root, void_, SimpleName ("void")); + + Long& long_ (tu.new_node<Long> ()); + tu.new_edge<Defines> (fundamental_root, long_, SimpleName ("long")); + + String& string_ (tu.new_node<String> ()); + tu.new_edge<Defines> (fundamental_root, string_, SimpleName ("string")); + + // Principal translation region. + // + TranslationRegion& principal (tu.new_node<TranslationRegion> ()); + tu.new_edge<ContainsPrincipal> (tu, principal); + + // 1: Quote included translation region. + // + TranslationRegion& quote_included (tu.new_node<TranslationRegion> ()); + tu.new_edge<QuoteIncludes> (principal, quote_included, "../foo/quote.idl"); + + // 2: Bracket included translation region. + // + TranslationRegion& braket_included (tu.new_node<TranslationRegion> ()); + tu.new_edge<BracketIncludes> (principal, braket_included, "ui/bracket.idl"); + + Root& root (tu.new_node<Root> ()); + tu.new_edge<ContainsRoot> (principal, root); + + // 4-5: + // + Module& m (tu.new_node<Module> ()); + tu.new_edge<Defines> (root, m, SimpleName ("M")); + + // 7-11: + // + UnconstrainedInterface& i (tu.new_node<UnconstrainedInterface> ()); + tu.new_edge<Mentions> (m, i, SimpleName ("I")); + tu.new_edge<Aliases> (m, i, SimpleName ("J")); + tu.new_edge<Defines> (m, i, SimpleName ("I")); + + // 13: + // + Operation& f (tu.new_node<Operation> ()); + tu.new_edge<Returns> (f, void_); + + Parameter& id (tu.new_node<InParameter> ("id")); + tu.new_edge<Belongs> (id, long_); + tu.new_edge<Receives> (f, id); + + Parameter& name (tu.new_node<OutParameter> ("name")); + tu.new_edge<Belongs> (name, string_); + tu.new_edge<Receives> (f, name); + + tu.new_edge<Defines> (i, f, SimpleName ("f")); + + // 15: + // + Attribute& a (tu.new_node<Attribute> ()); + tu.new_edge<Belongs> (a, long_); + tu.new_edge<Defines> (i, a, SimpleName ("a")); + + // 18: + // + UnconstrainedInterface& q (tu.new_node<UnconstrainedInterface> ()); + tu.new_edge<Inherits> (q, i); + tu.new_edge<Defines> (m, q, SimpleName ("Q")); + + // 20: + // + TypeId& ti (tu.new_node<TypeId> ( + ScopedName ("::M::I"), StringLiteral ("Foo"))); + tu.new_edge<Defines> (m, ti, SimpleName ("typeid")); + + // 21: + // + TypePrefix& tp (tu.new_node<TypePrefix> ( + ScopedName ("::M"), StringLiteral ("Bar"))); + tu.new_edge<Defines> (m, tp, SimpleName ("typeprefix")); + + // 23-24: + // + Struct& s (tu.new_node<Struct> ()); + tu.new_edge<Defines> (m, s, SimpleName ("S")); + + // 25: + // + Member& member (tu.new_node<Member> ()); + tu.new_edge<Belongs> (member, long_); + tu.new_edge<Defines> (s, member, SimpleName ("member")); + + // 28: + // + UnboundedSequence& long_seq (tu.new_node<UnboundedSequence> ()); + tu.new_edge<Specialized> (long_seq, long_); + tu.new_edge<Aliases> (m, long_seq, SimpleName ("LongSeq")); + + return &tu; +} diff --git a/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.hpp b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.hpp new file mode 100644 index 00000000000..794c56547d2 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Builder.hpp @@ -0,0 +1,17 @@ +// file : Test/IDL2/SemanticGraph/HandBuilt/Builder.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_IDL2_SEMANTIC_GRAPH_BUILDER_HPP +#define TEST_IDL2_SEMANTIC_GRAPH_BUILDER_HPP + +#include "CCF/IDL2/SemanticGraph.hpp" + +class Builder +{ +public: + CCF::IDL2::SemanticGraph::TranslationUnit* + build (); +}; + +#endif // TEST_IDL2_SEMANTIC_GRAPH_BUILDER_HPP diff --git a/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Makefile.alt new file mode 100644 index 00000000000..ff31afbd311 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/Makefile.alt @@ -0,0 +1,29 @@ +# file : Test/IDL2/SemanticGraph/HandBuilt/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 := hand_built.cpp Builder.cpp + +module_base := hand_built +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/CompilerElements \ + -lCompilerElements \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/hand_built.cpp b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/hand_built.cpp new file mode 100644 index 00000000000..3640282cfe3 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/HandBuilt/hand_built.cpp @@ -0,0 +1,16 @@ +// file : Test/IDL2/SemanticGraph/HandBuilt/hand_built.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Builder.hpp" + +using namespace CCF::IDL2; + +int +main () +{ + Builder b; + SemanticGraph::TranslationUnit& tu (*b.build ()); + + delete &tu; +} diff --git a/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/Makefile.alt new file mode 100644 index 00000000000..34ecdacbc97 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/SemanticGraph/Makefile.alt @@ -0,0 +1,18 @@ +# file : Test/IDL2/SemanticGraph/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 := HandBuilt +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/Traversal/Makefile.alt new file mode 100644 index 00000000000..af61a8f0159 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Makefile.alt @@ -0,0 +1,18 @@ +# file : Test/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/Recursion.pre.rules) + +target_makefile_list := +target_directory_list := Recreate +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.cpp b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.cpp new file mode 100644 index 00000000000..8aa3e895b9d --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.cpp @@ -0,0 +1,32 @@ +// file : Test/IDL2/Traversal/Recreate/Generator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Generator.hpp" +#include "GeneratorImpl.hpp" + +namespace IDL2 +{ + Generator:: + ~Generator () + { + } + + Generator:: + Generator () + : pimpl_ (new GeneratorImpl), impl_ (*pimpl_) + { + } + + Generator:: + Generator (GeneratorImpl& gi) + : pimpl_ (), impl_ (gi) + { + } + + void Generator:: + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu) + { + impl_.generate (tu); + } +} diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.hpp b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.hpp new file mode 100644 index 00000000000..b0387317ad5 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Generator.hpp @@ -0,0 +1,34 @@ +// file : Test/IDL2/Traversal/Recreate/Generator.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_HPP +#define TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_HPP + +#include <memory> + +#include "CCF/IDL2/SemanticGraph.hpp" + +namespace IDL2 +{ + class GeneratorImpl; + + class Generator + { + public: + ~Generator (); + Generator (); + + void + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu); + + protected: + Generator (GeneratorImpl&); + + protected: + std::auto_ptr<GeneratorImpl> pimpl_; + GeneratorImpl& impl_; + }; +} + +#endif // TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/GeneratorImpl.hpp b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/GeneratorImpl.hpp new file mode 100644 index 00000000000..9c231b769c6 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/GeneratorImpl.hpp @@ -0,0 +1,655 @@ +// file : Test/IDL2/Traversal/Recreate/GeneratorImpl.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_IMPL_HPP +#define TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_IMPL_HPP + +#include <iostream> + +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include "CCF/IDL2/SemanticGraph.hpp" +#include "CCF/IDL2/Traversal.hpp" + +namespace IDL2 +{ + using namespace CCF::IDL2; + + using std::cout; + using std::endl; + + class GeneratorImpl + { + protected: + // Layer 1 + // + + // Layer 2 + // + struct BracketIncludes : Traversal::BracketIncludes + { + virtual void + traverse (Type& qi) + { + cout << "include <" << qi.file ().string () << ">" << endl; + } + }; + + struct QuoteIncludes : Traversal::QuoteIncludes + { + virtual void + traverse (Type& qi) + { + cout << "include \"" << qi.file ().string () << "\"" << endl; + } + }; + + //-- + + // Layer 3 + // + + struct Aliases : Traversal::Aliases + { + virtual void + pre (Type&) + { + cout << "typedef "; + } + + virtual void + name (Type& a) + { + cout << " " << a.name (); + } + + virtual void + post (Type&) + { + cout << ";"; + } + }; + + //-- + + struct AbstractInterfaceFwd : Traversal::AbstractInterface + { + virtual void + traverse (Type& i) + { + cout << "abstract interface " << i.name () << ";"; + } + }; + + struct LocalInterfaceFwd : Traversal::LocalInterface + { + virtual void + traverse (Type& i) + { + cout << "local interface " << i.name () << ";"; + } + }; + + struct UnconstrainedInterfaceFwd : Traversal::UnconstrainedInterface + { + virtual void + traverse (Type& i) + { + cout << "interface " << i.name () << ";"; + } + }; + + struct StructFwd : Traversal::Struct + { + virtual void + traverse (Type& i) + { + cout << "struct " << i.name () << ";"; + } + }; + + + struct AbstractInterface : Traversal::AbstractInterface + { + virtual void + pre (Type&) + { + cout << "abstract interface "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct LocalInterface : Traversal::LocalInterface + { + virtual void + pre (Type&) + { + cout << "local interface "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct UnconstrainedInterface : Traversal::UnconstrainedInterface + { + virtual void + pre (Type&) + { + cout << "interface "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + + struct Module : Traversal::Module + { + virtual void + pre (Type& m) + { + cout << "module " << m.name (); + } + + virtual void + names_pre (Type& m) + { + cout << "{"; + } + + virtual void + names_post (Type& m) + { + cout << "}"; + } + + virtual void + post (Type& m) + { + cout << ";"; + } + }; + + struct Struct : Traversal::Struct + { + virtual void + pre (Type&) + { + cout << "struct "; + } + + virtual void + name (Type& s) + { + cout << s.name (); + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + }; + + + struct TypeId : Traversal::TypeId + { + virtual void + traverse (Type& ti) + { + cout << "typeid " << ti.declaration () << " " << ti.id () << ";"; + } + }; + + + struct TypePrefix : Traversal::TypePrefix + { + virtual void + traverse (Type& ti) + { + cout << "typeprefix " << ti.declaration () << " " + << ti.prefix () << ";"; + } + }; + + struct TypeName : Traversal::Nameable, + Traversal::FundamentalType + { + virtual void + traverse (SemanticGraph::Nameable& n) + { + cout << n.scoped_name (); + } + + virtual void + traverse (SemanticGraph::FundamentalType& ft) + { + cout << ft.name (); + } + }; + + struct UnboundedSequence : Traversal::UnboundedSequence + { + virtual void + pre (Type&) + { + cout << "sequence<"; + } + + virtual void + post (Type&) + { + cout << ">"; + } + }; + + // Layer 4 + // + + //-- + + struct Operation : Traversal::Operation + { + virtual void + name (Type& o) + { + cout << " " << o.name (); + } + + virtual void + receives_pre (Type&) + { + cout << " ("; + } + + virtual void + receives_post (Type&) + { + cout << ")"; + } + + virtual void + raises_pre (Type&) + { + cout << " raises ("; + } + + virtual void + raises_post (Type&) + { + cout << ")"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct Attribute : Traversal::Attribute + { + virtual void + pre (Type&) + { + cout << "attribute "; + } + + virtual void + name (Type& a) + { + cout << " " << a.name (); + } + + virtual void + post (Type&) + { + cout << ";"; + } + + }; + + struct Member : Traversal::Member + { + virtual void + name (Type& m) + { + cout << " " << m.name (); + } + + virtual void + post (Type&) + { + cout << ";"; + } + }; + + // Layer 5 + // + + //-- + + struct Parameter : Traversal::Parameter + { + virtual void + pre (Type& p) + { + cout << p.direction () << " "; + } + + virtual void + name (Type& p) + { + cout << " " << p.name (); + } + }; + + public: + + GeneratorImpl () + { + // Layer 1 + // + unit.edge_traverser (contains_principal); + + //-- + + contains_principal.node_traverser (region); + + // Layer 2 + // + region.edge_traverser (quote_includes); + region.edge_traverser (bracket_includes); + region.edge_traverser (contains_root); + + //-- + + contains_root.node_traverser (root); + + // Layer 3 + // + root.edge_traverser (mentions); + root.edge_traverser (defines); + root.edge_traverser (aliases); + + //-- + + mentions.node_traverser (abstract_interface_fwd); + mentions.node_traverser (local_interface_fwd); + mentions.node_traverser (unconstrained_interface_fwd); + mentions.node_traverser (struct_fwd); + + defines.node_traverser (abstract_interface); + defines.node_traverser (local_interface); + defines.node_traverser (unconstrained_interface); + defines.node_traverser (module); + defines.node_traverser (struct_); + defines.node_traverser (type_id); + defines.node_traverser (type_prefix); + + aliases.node_traverser (type_name); + aliases.node_traverser (unbounded_sequence); + + // Layer 4 + // + module.edge_traverser (mentions); + module.edge_traverser (defines); + module.edge_traverser (aliases); + + abstract_interface.edge_traverser (inherits); + local_interface.edge_traverser (inherits); + unconstrained_interface.edge_traverser (inherits); + + abstract_interface.edge_traverser (interface_defines); + local_interface.edge_traverser (interface_defines); + unconstrained_interface.edge_traverser (interface_defines); + + struct_.edge_traverser (struct_defines); + + unbounded_sequence.edge_traverser (specialized); + + //-- + + inherits.node_traverser (type_name); + + interface_defines.node_traverser (operation); + interface_defines.node_traverser (attribute); + + struct_defines.node_traverser (member); + + specialized.node_traverser (type_name); + + // Layer 5 + // + + operation.edge_traverser (receives); + operation.edge_traverser (returns); + + attribute.edge_traverser (belongs); + + member.edge_traverser (belongs); + + //-- + + receives.node_traverser (parameter); + returns.node_traverser (type_name); + belongs.node_traverser (type_name); + + // Layer 6 + // + parameter.edge_traverser (belongs); + + } + + protected: + Traversal::TranslationUnit unit; + + // Layer 1 + // + Traversal::ContainsPrincipal contains_principal; + + //-- + + Traversal::TranslationRegion region; + + // Layer 2 + // + BracketIncludes bracket_includes; + QuoteIncludes quote_includes; + Traversal::ContainsRoot contains_root; + + //-- + + Traversal::Root root; + + // Layer 3 + // + Traversal::Mentions mentions; + Traversal::Defines defines; + Aliases aliases; + + //-- + + AbstractInterfaceFwd abstract_interface_fwd; + LocalInterfaceFwd local_interface_fwd; + UnconstrainedInterfaceFwd unconstrained_interface_fwd; + + StructFwd struct_fwd; + + AbstractInterface abstract_interface; + LocalInterface local_interface; + UnconstrainedInterface unconstrained_interface; + + Module module; + + Struct struct_; + + TypeId type_id; + TypePrefix type_prefix; + + TypeName type_name; + + UnboundedSequence unbounded_sequence; + + // Layer 4 + // + Traversal::Inherits inherits; + Traversal::Defines interface_defines; + Traversal::Defines struct_defines; + Traversal::Specialized specialized; + + //-- + + Operation operation; + Attribute attribute; + Member member; + + // Layer 5 + // + Traversal::Receives receives; + Traversal::Returns returns; + Traversal::Belongs belongs; + + //-- + + Parameter parameter; + + // Layer 6 + // + + public: + void + generate (CCF::IDL2::SemanticGraph::TranslationUnit& tu) + { + // Plug automatic IDL indenter. + // + Indentation::Implanter<Indentation::IDL> guard (cout); + + unit.traverse (tu); + } + }; +} + +#endif // TEST_IDL2_TRAVERSAL_RECREATE_GENERATOR_IMPL_HPP diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Makefile.alt b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Makefile.alt new file mode 100644 index 00000000000..a29e1a2a5d0 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/Makefile.alt @@ -0,0 +1,33 @@ +# file : Test/IDL2/Traversal/Recreate/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 := recreate.cpp Generator.cpp + +translated_units += ../../SemanticGraph/HandBuilt/Builder.o + +module_base := recreate +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/recreate.cpp b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/recreate.cpp new file mode 100644 index 00000000000..560040bbcb0 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL2/Traversal/Recreate/recreate.cpp @@ -0,0 +1,24 @@ +// file : Test/IDL2/Traversal/Recreate/recreate.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include <iostream> + +#include "CCF/IDL2/SemanticGraph.hpp" + +#include "../../SemanticGraph/HandBuilt/Builder.hpp" + +#include "Generator.hpp" + +int +main () +{ + Builder b; + CCF::IDL2::SemanticGraph::TranslationUnit& tu (*b.build ()); + + IDL2::Generator g; + + g.generate (tu); + + delete &tu; +} diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.cpp b/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.cpp new file mode 100644 index 00000000000..06310ecd4b8 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.cpp @@ -0,0 +1,32 @@ +// file : Test/IDL3/Compiler/Generator.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "Generator.hpp" +#include "GeneratorImpl.hpp" + +namespace IDL3 +{ + Generator:: + ~Generator () + { + } + + Generator:: + Generator () + : pimpl_ (new GeneratorImpl), impl_ (*pimpl_) + { + } + + Generator:: + Generator (GeneratorImpl& gi) + : pimpl_ (), impl_ (gi) + { + } + + void Generator:: + generate (CCF::IDL3::SemanticGraph::TranslationUnit& tu) + { + impl_.generate (tu); + } +} diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.hpp b/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.hpp new file mode 100644 index 00000000000..667e1d3c69f --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/Generator.hpp @@ -0,0 +1,34 @@ +// file : Test/IDL3/Compiler/Generator.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_IDL3_COMPILER_GENERATOR_HPP +#define TEST_IDL3_COMPILER_GENERATOR_HPP + +#include <memory> + +#include "CCF/IDL3/SemanticGraph.hpp" + +namespace IDL3 +{ + class GeneratorImpl; + + class Generator + { + public: + ~Generator (); + Generator (); + + void + generate (CCF::IDL3::SemanticGraph::TranslationUnit& tu); + + protected: + Generator (GeneratorImpl&); + + protected: + std::auto_ptr<GeneratorImpl> pimpl_; + GeneratorImpl& impl_; + }; +} + +#endif // TEST_IDL3_COMPILER_GENERATOR_HPP diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/GeneratorImpl.hpp b/TAO/CIAO/CCF/Test/IDL3/Compiler/GeneratorImpl.hpp new file mode 100644 index 00000000000..5125e62d580 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/GeneratorImpl.hpp @@ -0,0 +1,616 @@ +// file : Test/IDL3/Compiler/GeneratorImpl.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef TEST_IDL3_COMPILER_GENERATOR_IMPL_HPP +#define TEST_IDL3_COMPILER_GENERATOR_IMPL_HPP + +#include <iostream> + +#include "CCF/CodeGenerationKit/IndentationIDL.hpp" +#include "CCF/CodeGenerationKit/IndentationImplanter.hpp" + +#include "CCF/IDL3/SemanticGraph.hpp" +#include "CCF/IDL3/Traversal.hpp" + +#include "../../IDL2/Traversal/Recreate/GeneratorImpl.hpp" + +namespace IDL3 +{ + using namespace CCF::IDL3; + + using std::cout; + using std::endl; + + class GeneratorImpl : public IDL2::GeneratorImpl + { + protected: + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + struct ComponentFwd : Traversal::Component + { + virtual void + traverse (Type& i) + { + cout << "component " << i.name () << ";"; + } + }; + + struct Component : Traversal::Component + { + virtual void + pre (Type&) + { + cout << "component "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + supports_pre (Type&) + { + cout << " supports "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + + struct Home : Traversal::Home + { + virtual void + pre (Type&) + { + cout << "home "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + supports_pre (Type&) + { + cout << " supports "; + } + + virtual void + manages_pre (Type&) + { + cout << " manages "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct AbstractEventType : Traversal::AbstractEventType + { + virtual void + pre (Type&) + { + cout << "abstract eventtype "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + supports_pre (Type&) + { + cout << " supports "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + struct ConcreteEventType : Traversal::ConcreteEventType + { + virtual void + pre (Type&) + { + cout << "eventtype "; + } + + virtual void + name (Type& i) + { + cout << i.name (); + } + + virtual void + inherits_pre (Type&) + { + cout << " : "; + } + + virtual void + supports_pre (Type&) + { + cout << " supports "; + } + + virtual void + names_pre (Type&) + { + cout << "{"; + } + + virtual void + names_post (Type&) + { + cout << "}"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + // Layer 4 + // + + struct Provider : Traversal::ProviderData + { + virtual void + pre (Type&) + { + cout << "provides "; + } + + virtual void + name (Type& e) + { + cout << " " << e.name (); + } + + virtual void + post (Type& e) + { + cout << ";"; + } + }; + + struct User : Traversal::UserData + { + virtual void + pre (Type&) + { + cout << "uses "; + } + + virtual void + name (Type& e) + { + cout << " " << e.name (); + } + + virtual void + post (Type& e) + { + cout << ";"; + } + }; + + struct Publisher : Traversal::PublisherData + { + virtual void + pre (Type&) + { + cout << "publishes "; + } + + virtual void + name (Type& e) + { + cout << " " << e.name (); + } + + virtual void + post (Type& e) + { + cout << ";"; + } + }; + + struct Emitter : Traversal::EmitterData + { + virtual void + pre (Type&) + { + cout << "emits "; + } + + virtual void + name (Type& e) + { + cout << " " << e.name (); + } + + virtual void + post (Type& e) + { + cout << ";"; + } + }; + + struct Consumer : Traversal::ConsumerData + { + virtual void + pre (Type&) + { + cout << "consumes "; + } + + virtual void + name (Type& e) + { + cout << " " << e.name (); + } + + virtual void + post (Type& e) + { + cout << ";"; + } + }; + + //-- + + struct HomeFactory : Traversal::HomeFactory + { + virtual void + returns (Type&) + { + cout << "factory "; + } + + virtual void + name (Type& hf) + { + cout << hf.name (); + } + + virtual void + receives_pre (Type&) + { + cout << " ("; + } + + virtual void + receives_post (Type&) + { + cout << ")"; + } + + virtual void + raises_pre (Type&) + { + cout << " raises ("; + } + + virtual void + raises_post (Type&) + { + cout << ")"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + + struct HomeFinder : Traversal::HomeFinder + { + virtual void + returns (Type&) + { + cout << "finder "; + } + + virtual void + name (Type& hf) + { + cout << hf.name (); + } + + virtual void + receives_pre (Type&) + { + cout << " ("; + } + + virtual void + receives_post (Type&) + { + cout << ")"; + } + + virtual void + raises_pre (Type&) + { + cout << " raises ("; + } + + virtual void + raises_post (Type&) + { + cout << ")"; + } + + virtual void + post (Type&) + { + cout << ";"; + } + + virtual void + comma (Type&) + { + cout << ", "; + } + }; + + // Layer 5 + // + + //-- + + public: + + GeneratorImpl () + { + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + + mentions.node_traverser (component_fwd); + + defines.node_traverser (component); + + defines.node_traverser (home); + + defines.node_traverser (abstract_event_type); + defines.node_traverser (concrete_event_type); + + // Layer 4 + // + + component.edge_traverser (inherits); + component.edge_traverser (supports); + component.edge_traverser (component_defines); + + home.edge_traverser (inherits); + home.edge_traverser (supports); + home.edge_traverser (manages); + home.edge_traverser (home_defines); + + //@@ eventtype can define the whole bunch of stuff + // just like valuetype. + // + abstract_event_type.edge_traverser (inherits); + concrete_event_type.edge_traverser (inherits); + + //-- + + supports.node_traverser (type_name); + + component_defines.node_traverser (attribute); + component_defines.node_traverser (provider); + component_defines.node_traverser (user); + component_defines.node_traverser (publisher); + component_defines.node_traverser (emitter); + component_defines.node_traverser (consumer); + + manages.node_traverser (type_name); + + //@@ home can define the whole bunch of stuff just like + // interface & valuetype. + + home_defines.node_traverser (home_factory); + home_defines.node_traverser (home_finder); + + // Layer 5 + // + + provider.edge_traverser (belongs); + user.edge_traverser (belongs); + publisher.edge_traverser (belongs); + emitter.edge_traverser (belongs); + consumer.edge_traverser (belongs); + + home_factory.edge_traverser (receives); + home_finder.edge_traverser (receives); + + //-- + + // Layer 6 + // + + } + + protected: + // Layer 1 + // + + // Layer 2 + // + + // Layer 3 + // + + //-- + + ComponentFwd component_fwd; + + Component component; + + Home home; + + AbstractEventType abstract_event_type; + ConcreteEventType concrete_event_type; + + + // Layer 4 + // + Traversal::Supports supports; + Traversal::Defines component_defines; + + Traversal::Manages manages; + Traversal::Defines home_defines; + + //-- + + Provider provider; + User user; + Publisher publisher; + Emitter emitter; + Consumer consumer; + + HomeFactory home_factory; + HomeFinder home_finder; + + // Layer 5 + // + + // Layer 6 + // + + public: + void + generate (CCF::IDL3::SemanticGraph::TranslationUnit& tu) + { + // Plug automatic IDL indenter. + // + Indentation::Implanter<Indentation::IDL> guard (cout); + + unit.traverse (tu); + } + }; +} + +#endif // TEST_IDL3_COMPILER_GENERATOR_IMPL_HPP diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/Makefile.alt b/TAO/CIAO/CCF/Test/IDL3/Compiler/Makefile.alt new file mode 100644 index 00000000000..53f99350be1 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/Makefile.alt @@ -0,0 +1,33 @@ +# file : Test/IDL3/Compiler/driver/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 := driver.cpp Generator.cpp + +module_base := driver +module_prefix := +module_suffix := + +CXX_PREPROCESS_FLAGS += -I$(root) -I$(UTILITY_ROOT) -I$(BOOST_ROOT) + +# -L$(root)/CCF/CompilerElements \ +# -lCompilerElements \ + +CXX_LINK_LIBS += -L$(root)/CCF/IDL3 \ + -lIDL3 \ + -L$(root)/CCF/IDL2 \ + -lIDL2 \ + -L$(UTILITY_ROOT)/Utility/Introspection \ + -lIntrospection \ + -L$(BOOST_ROOT)/lib \ + -lboost_filesystem + +$(call include, $(UTILITY_ROOT)/BuildRules/Executable.post.rules) diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/driver.cpp b/TAO/CIAO/CCF/Test/IDL3/Compiler/driver.cpp new file mode 100644 index 00000000000..e861d68f3d4 --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/driver.cpp @@ -0,0 +1,96 @@ +// file : Test/IDL3/Compiler/driver.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/FileSystem.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/Parser.hpp" +#include "CCF/IDL3/SemanticGraph.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +#include "Generator.hpp" + +#include <iostream> + +using std::cerr; +using std::cout; +using std::endl; + +using namespace CCF::IDL3; +using namespace SemanticGraph; + +int +main () +{ + try + { + Diagnostic::Stream dout; + + fs::path file_path ("stdout"); + + CCF::InputStreamAdapter isa (std::cin); + CCF::Preprocessor pp (isa); + + 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 () < 2) + { + cerr << "no tokens produced so nothing to parse" << endl; + return 0; + } + + TranslationUnit tu; + + // Compilation context. + // + CCF::CompilerElements::Context context; + context.set ("file-path", file_path); + context.set ("trace-semantic-action", false); + + + SemanticAction::Impl::Factory actions (context, dout, tu); + + Parser parser (context, dout, lexer, actions); + + //@@ should be able to use IDL3 here. Or better yet get rid of this + // function completely. + // + CCF::IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + + if (dout.error_count () != 0) return -1; + + IDL3::Generator g; + + g.generate (tu); + + } + catch (std::bad_cast const&) + { + cerr << "bad cast exception" << endl; + } + catch (InvalidName const&) + { + cerr << "invalid name exception" << endl; + } + catch (...) + { + cerr << "caught unknown exception" << endl; + return -1; + } +} diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/result.idl.orig b/TAO/CIAO/CCF/Test/IDL3/Compiler/result.idl.orig new file mode 100644 index 00000000000..730e7c103cb --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/result.idl.orig @@ -0,0 +1,103 @@ +module ComponentTest +{ + component A; + component B + { + }; + interface I + { + }; + interface J + { + }; + component A : ::ComponentTest::B supports ::ComponentTest::I, ::ComponentTest::J + { + }; +}; +module ConsumesTest +{ + eventtype E + { + }; + component C + { + consumes ::ConsumesTest::E e; + }; +}; +module EmitsTest +{ + eventtype E + { + }; + component C + { + emits ::EmitsTest::E e; + }; +}; +module EventTypeTest +{ + eventtype E + { + }; +}; +module HomeTest +{ + interface I + { + }; + interface J + { + }; + component A + { + }; + home AH manages ::HomeTest::A + { + }; + component B + { + }; + home BH : ::HomeTest::AH supports ::HomeTest::I, ::HomeTest::J manages ::HomeTest::B + { + }; +}; +module HomeFactoryTest +{ + component A + { + }; + home AH manages ::HomeFactoryTest::A + { + factory new (in long size); + }; +}; +module ProvidesTest +{ + interface I + { + }; + component C + { + provides ::ProvidesTest::I i; + }; +}; +module PublishesTest +{ + eventtype E + { + }; + component C + { + publishes ::PublishesTest::E e; + }; +}; +module UsesTest +{ + interface I + { + }; + component C + { + uses ::UsesTest::I i; + }; +}; diff --git a/TAO/CIAO/CCF/Test/IDL3/Compiler/test.idl b/TAO/CIAO/CCF/Test/IDL3/Compiler/test.idl new file mode 100644 index 00000000000..e85e86a610d --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Compiler/test.idl @@ -0,0 +1,166 @@ +// file : CCF/Test/IDL3/Compiler/test.idl +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +// Component +// +// + +module ComponentTest +{ + component A; + + component B + { + }; + + interface I + { + }; + + interface J + { + }; + + component A : B supports I, J + { + }; +}; + + +// Consumes +// +// +module ConsumesTest +{ + eventtype E + { + }; + + component C + { + consumes E e; + }; +}; + + +// Emits +// +// +module EmitsTest +{ + eventtype E + { + }; + + component C + { + emits E e; + }; +}; + + +// EventType (incomplete) +// +// +module EventTypeTest +{ + eventtype E + { + }; +}; + + +// Home +// +// +module HomeTest +{ + interface I + { + }; + + interface J + { + }; + + component A + { + }; + + home AH manages A + { + }; + + component B + { + }; + + home BH : AH supports I, J manages B + { + }; +}; + + +// HomeFactory +// +// +module HomeFactoryTest +{ + component A + { + }; + + home AH manages A + { + factory new (in long size); + }; +}; + + +// Provides +// +// +module ProvidesTest +{ + interface I + { + }; + + component C + { + provides I i; + }; +}; + + +// Publishes +// +// +module PublishesTest +{ + eventtype E + { + }; + + component C + { + publishes E e; + }; +}; + + +// Uses +// +// +module UsesTest +{ + interface I + { + }; + + component C + { + uses I i; + }; +}; diff --git a/TAO/CIAO/CCF/Test/IDL3/Makefile.alt b/TAO/CIAO/CCF/Test/IDL3/Makefile.alt new file mode 100644 index 00000000000..912494533ac --- /dev/null +++ b/TAO/CIAO/CCF/Test/IDL3/Makefile.alt @@ -0,0 +1,19 @@ +# file : Test/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 := +target_directory_list := Compiler +default_makefile_name := Makefile.alt + + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) + diff --git a/TAO/CIAO/CCF/Test/Makefile.alt b/TAO/CIAO/CCF/Test/Makefile.alt new file mode 100644 index 00000000000..58c106f9899 --- /dev/null +++ b/TAO/CIAO/CCF/Test/Makefile.alt @@ -0,0 +1,17 @@ +# file : Test/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 +default_makefile_name := Makefile.alt + +$(call include, $(UTILITY_ROOT)/BuildRules/Recursion.post.rules) diff --git a/TAO/CIAO/CCF/Version b/TAO/CIAO/CCF/Version new file mode 100644 index 00000000000..227cea21564 --- /dev/null +++ b/TAO/CIAO/CCF/Version @@ -0,0 +1 @@ +2.0.0 diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index af85abdccfe..31c10812d95 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,9 @@ +Mon Dec 22 16:26:21 2003 Boris Kolpackov <boris@dre.vanderbilt.edu> + + * CCF: + + Added new version of CCF. + Mon Dec 22 15:35:19 2003 Boris Kolpackov <boris@dre.vanderbilt.edu> * CCF: |