diff options
author | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-03-21 14:14:37 +0000 |
---|---|---|
committer | boris <boris@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2005-03-21 14:14:37 +0000 |
commit | 92713e6966818798b34f15f071676f87692dd867 (patch) | |
tree | 792bab86c2148ba81425b21e55ce0d44eb3a9000 | |
parent | b70cde7eae249e2a94dbe4c80792e86554c278c7 (diff) | |
download | ATCD-92713e6966818798b34f15f071676f87692dd867.tar.gz |
ChangeLogTag: Mon Mar 21 16:25:07 2005 Boris Kolpackov <boris@kolpackov.net>
19 files changed, 751 insertions, 94 deletions
diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp b/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp index 75e12e587cd..853351da517 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.cpp @@ -200,6 +200,7 @@ namespace CCF act_member_end ( f.member (), &SemanticAction::Member::end), + // Module // // @@ -361,8 +362,20 @@ namespace CCF f.value_type (), &SemanticAction::ValueType::end), - // ValueTypeMember + // ValueTypeFactory // + act_value_type_factory_name ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::name), + + act_value_type_factory_parameter ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::parameter), + + act_value_type_factory_raises ( + f.value_type_factory (), &SemanticAction::ValueTypeFactory::raises), + + + + // ValueTypeMember // act_value_type_member_begin_private ( f.value_type_member (), @@ -1218,26 +1231,12 @@ namespace CCF ; - // valuetype member - // - // - value_type_member_decl = - ( - PUBLIC[act_value_type_member_begin_public] - | PRIVATE[act_value_type_member_begin_private] - ) - >> identifier[act_value_type_member_type] - >> simple_identifier[act_value_type_member_name] - >> *(COMMA >> simple_identifier[act_value_type_member_name]) - >> SEMI[act_value_type_member_end] - ; - // valuetype factory // // value_type_factory_decl = FACTORY - >> simple_identifier //[act_value_type_factory_name] + >> simple_identifier[act_value_type_factory_name] >> LPAREN >> value_type_factory_parameter_list >> RPAREN @@ -1254,12 +1253,27 @@ namespace CCF value_type_factory_parameter = IN - >> (identifier >> simple_identifier) //[act_value_type_factory_parameter] + >> (identifier >> simple_identifier)[act_value_type_factory_parameter] ; value_type_factory_raises_list = - identifier //[act_value_type_factory_raises] - >> *(COMMA >> identifier) // [act_value_type_factory_raises]) + identifier[act_value_type_factory_raises] + >> *(COMMA >> identifier[act_value_type_factory_raises]) + ; + + + // valuetype member + // + // + value_type_member_decl = + ( + PUBLIC[act_value_type_member_begin_public] + | PRIVATE[act_value_type_member_begin_private] + ) + >> identifier[act_value_type_member_type] + >> simple_identifier[act_value_type_member_name] + >> *(COMMA >> simple_identifier[act_value_type_member_name]) + >> SEMI[act_value_type_member_end] ; } } diff --git a/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp index 8ba6d0e9fcd..bcf1875273f 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/Parser.hpp @@ -472,13 +472,12 @@ namespace CCF Rule value_type_def_trailer; Rule value_type_body; - Rule value_type_member_decl; - Rule value_type_factory_decl; Rule value_type_factory_parameter_list; Rule value_type_factory_parameter; Rule value_type_factory_raises_list; + Rule value_type_member_decl; public: Parser (CompilerElements::Context& context, Diagnostic::Stream& dout, @@ -586,6 +585,7 @@ namespace CCF NoArgAction<SemanticAction::Member> act_member_end; + // Module // // @@ -747,7 +747,6 @@ namespace CCF // ValueType // - // OneArgAction<SimpleIdentifierPtr, SemanticAction::ValueType> act_value_type_begin_abstract_def, act_value_type_begin_abstract_fwd, @@ -767,8 +766,21 @@ namespace CCF act_value_type_end; - // ValueTypeMember + // ValueTypeFactory // + OneArgAction<SimpleIdentifierPtr, SemanticAction::ValueTypeFactory> + act_value_type_factory_name; + + TwoArgAction<IdentifierPtr, + SimpleIdentifierPtr, + SemanticAction::ValueTypeFactory> + act_value_type_factory_parameter; + + OneArgAction<IdentifierPtr, SemanticAction::ValueTypeFactory> + act_value_type_factory_raises; + + + // ValueTypeMember // NoArgAction<SemanticAction::ValueTypeMember> act_value_type_member_begin_private; diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp index d034ec56124..c8a31ac38fc 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction.hpp @@ -23,6 +23,7 @@ #include "CCF/IDL2/SemanticAction/TypeId.hpp" #include "CCF/IDL2/SemanticAction/Union.hpp" #include "CCF/IDL2/SemanticAction/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeFactory.hpp" #include "CCF/IDL2/SemanticAction/ValueTypeMember.hpp" #endif // CCF_IDL2_SEMANTIC_ACTION_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp index c7300dd8604..7a91093f61e 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Factory.hpp @@ -26,6 +26,7 @@ namespace CCF struct TypePrefix; struct Union; struct ValueType; + struct ValueTypeFactory; struct ValueTypeMember; // @@ -81,6 +82,9 @@ namespace CCF virtual ValueType& value_type () = 0; + virtual ValueTypeFactory& + value_type_factory () = 0; + virtual ValueTypeMember& value_type_member () = 0; }; diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp index 3ea4be7201c..1617e0bfae1 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp @@ -38,6 +38,7 @@ namespace CCF type_prefix_ (ctx_), union__ (ctx_), value_type_ (ctx_), + value_type_factory_ (ctx_), value_type_member_ (ctx_) { // Implied translation region with fundamental types. diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp index 56856fa2e79..9c226581d57 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp @@ -29,6 +29,7 @@ #include "CCF/IDL2/SemanticAction/Impl/TypeId.hpp" #include "CCF/IDL2/SemanticAction/Impl/Union.hpp" #include "CCF/IDL2/SemanticAction/Impl/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp" #include "CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp" namespace CCF @@ -135,6 +136,12 @@ namespace CCF return value_type_; } + virtual ValueTypeFactory& + value_type_factory () + { + return value_type_factory_; + } + virtual SemanticAction::ValueTypeMember& value_type_member () { @@ -160,6 +167,7 @@ namespace CCF TypePrefix type_prefix_; Union union__; ValueType value_type_; + ValueTypeFactory value_type_factory_; ValueTypeMember value_type_member_; }; } diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp index 12b8dc5dfaa..054f49ab815 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp @@ -65,7 +65,7 @@ namespace CCF 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; + cerr << "using non-type as a member type is illegal" << endl; } catch (NotComplete const& e) { diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp index 63b0a4d84de..159aa228b4c 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp @@ -109,12 +109,133 @@ namespace CCF inherits (IdentifierPtr const& id) { if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::ValueType& v ( + resolve<SemanticGraph::ValueType> (from, name, Flags::defined)); + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + v); + + + bool abstract (dynamic_cast<AbstractValueType*> (&v) != 0); + + if (dynamic_cast<AbstractValueType*> (&now ()) != 0) + { + // Abstract valuetype may only inherit from abstract ones. + // + if (!abstract) + { + cerr << "abstract valuetype `" << now ().name () + << "\' may not inherit from concrete valuetype `" + << v.scoped_name () << "\'" << endl; + return; + } + } + else + { + // Concrete valuetype may inherit from single concrete + // valutype in which case it should be the first in the + // inheritance list. + // + if (now ().inherits_begin () != now ().inherits_end () && + !abstract) + { + cerr << "concrete valuetype `" << v.scoped_name () + << "\' is not the first in the inheritance list of " + << "valuetype `" << now ().name () << "\'" << endl; + return; + } + } + + ctx.tu ().new_edge<Inherits> (now (), v); + ctx.tu ().new_edge<Extends> (now (), v); + } + catch (Resolve const&) + { + cerr << "error: invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no valuetype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to inherit from the forward-declared valuetype " + << e.name () << endl; + cerr << "inheritance from a forward-declared valuetype is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << "directly inheriting from valuetype \'" << e.name () + << "\' more than once is illegal" << endl; + } } void ValueType:: supports (IdentifierPtr const& id) { if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << "error: invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to support forward-declared interface " + << 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 ValueType:: diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp new file mode 100644 index 00000000000..be0ccecd926 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp @@ -0,0 +1,139 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + ValueTypeFactory:: + ValueTypeFactory (Context& c) + : Base (c) + { + } + + void ValueTypeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + f_ = 0; + + SemanticGraph::ValueType& h ( + dynamic_cast<SemanticGraph::ValueType&>(ctx.scope ())); + + SimpleName name (id->lexeme ()); + + f_ = &ctx.tu ().new_node<SemanticGraph::ValueTypeFactory> (); + + ctx.tu ().new_edge<Returns> (*f_, h); + ctx.tu ().new_edge<Defines> (ctx.scope (), *f_, name); + } + + + void ValueTypeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (f_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> (name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*f_, 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&) + { + 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 ValueTypeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (f_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*f_, e); + } + catch (Resolve const&) + { + cerr << "error: invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + 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/ValueTypeFactory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp new file mode 100644 index 00000000000..949492152e5 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP + +#include "CCF/IDL2/SemanticGraph/ValueType.hpp" +#include "CCF/IDL2/SemanticAction/ValueTypeFactory.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + namespace Impl + { + struct ValueTypeFactory : SemanticAction::ValueTypeFactory, Base + { + ValueTypeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::ValueTypeFactory* f_; + }; + } + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp index 48762d66f69..c6de66ccc1b 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp @@ -30,18 +30,23 @@ namespace CCF void ValueTypeMember:: begin_private () { + if (ctx.trace ()) cerr << "private valuetype member" << endl; + + access_ = SemanticGraph::ValueTypeMember::Access::private_; } void ValueTypeMember:: begin_public () { + if (ctx.trace ()) cerr << "public valuetype member" << endl; + + access_ = SemanticGraph::ValueTypeMember::Access::public_; } void ValueTypeMember:: type (IdentifierPtr const& id) { - /* - if (ctx.trace ()) cerr << "member " << id << endl; + if (ctx.trace ()) cerr << " type: " << id << endl; type_ = 0; @@ -56,7 +61,7 @@ namespace CCF } catch (Resolve const&) { - cerr << "error: invalid member declaration" << endl; + cerr << "error: invalid valuetype member declaration" << endl; throw; } @@ -76,41 +81,56 @@ namespace CCF 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; + cerr << "using non-type as a valuetype member type is illegal" + << endl; } catch (NotComplete const& e) { cerr << "type \'" << e.name () << "\' is not complete" << endl; } - */ } void ValueTypeMember:: name (SimpleIdentifierPtr const& id) { - /* - if (ctx.trace ()) cerr << " " << id << endl; + using namespace SemanticGraph; + + if (ctx.trace ()) cerr << " name: " << id << endl; if (type_) { SimpleName name (id->lexeme ()); - SemanticGraph::Member& m ( - ctx.tu ().new_node<SemanticGraph::Member> ()); + SemanticGraph::ValueTypeMember* m; + + switch (access_) + { + case SemanticGraph::ValueTypeMember::Access::private_: + { + m = &ctx.tu ().new_node<ValueTypePrivateMember> (); + break; + } + case SemanticGraph::ValueTypeMember::Access::public_: + { + m = &ctx.tu ().new_node<ValueTypePublicMember> (); + break; + } + default: + { + abort (); + } + } - ctx.tu ().new_edge<Belongs> (m, *type_); - ctx.tu ().new_edge<Defines> (ctx.scope (), m, name); + ctx.tu ().new_edge<Belongs> (*m, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), *m, name); } - */ } void ValueTypeMember:: end () { - /* if (ctx.trace ()) cerr << "end" << endl; - */ } } } diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp index 093325dc78f..96e575cd35f 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp @@ -5,7 +5,7 @@ #ifndef CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_MEMBER_HPP #define CCF_IDL2_SEMANTIC_ACTION_IMPL_VALUE_TYPE_MEMBER_HPP -#include "CCF/IDL2/SemanticGraph/Elements.hpp" +#include "CCF/IDL2/SemanticGraph/ValueTypeMember.hpp" #include "CCF/IDL2/SemanticAction/ValueTypeMember.hpp" #include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" @@ -37,7 +37,8 @@ namespace CCF end (); private: - //SemanticGraph::Type* type_; + SemanticGraph::ValueTypeMember::Access::Value access_; + SemanticGraph::Type* type_; }; } } diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp new file mode 100644 index 00000000000..4d47407f360 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp @@ -0,0 +1,32 @@ +// file : CCF/IDL2/SemanticAction/ValueTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP +#define CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP + +#include "CCF/IDL2/SemanticAction/Elements.hpp" + +namespace CCF +{ + namespace IDL2 + { + namespace SemanticAction + { + struct ValueTypeFactory + { + virtual void + name (SimpleIdentifierPtr const& id) = 0; + + virtual void + parameter (IdentifierPtr const& type, + SimpleIdentifierPtr const& name) = 0; + + virtual void + raises (IdentifierPtr const& id) = 0; + }; + } + } +} + +#endif // CCF_IDL2_SEMANTIC_ACTION_VALUE_TYPE_FACTORY_HPP diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp index 15a2f0d867c..bdcb4afe023 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticGraph/ValueType.hpp @@ -7,6 +7,7 @@ #include "CCF/IDL2/SemanticGraph/Elements.hpp" #include "CCF/IDL2/SemanticGraph/Operation.hpp" +#include "CCF/IDL2/SemanticGraph/Interface.hpp" // Supports namespace CCF { @@ -20,6 +21,47 @@ namespace CCF class ValueType : public virtual Type, public virtual Scope { + typedef + std::vector <Inherits*> + Inherits_; + + typedef + std::vector <Supports*> + Supports_; + + public: + typedef + Inherits_::const_iterator + InheritsIterator; + + InheritsIterator + inherits_begin () const + { + return inherits_.begin (); + } + + InheritsIterator + inherits_end () const + { + return inherits_.end (); + } + + typedef + Supports_::const_iterator + SupportsIterator; + + SupportsIterator + supports_begin () const + { + return supports_.begin (); + } + + SupportsIterator + supports_end () const + { + return supports_.end (); + } + public: virtual bool complete () const @@ -40,6 +82,27 @@ namespace CCF using Type::add_edge_right; using Scope::add_edge_left; + + void + add_edge_left (Inherits& e) + { + inherits_.push_back (&e); + } + + void + add_edge_right (Inherits&) + { + } + + void + add_edge_left (Supports& e) + { + supports_.push_back (&e); + } + + private: + Inherits_ inherits_; + Supports_ supports_; }; @@ -61,9 +124,6 @@ namespace CCF } }; - // @@ TODO: value type member - // @@ TODO: value type factory - // // // diff --git a/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp index 0ed2fe7a9cc..e5582c4c61b 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp +++ b/TAO/CIAO/CCF/CCF/IDL2/Traversal/ValueType.tpp @@ -10,14 +10,14 @@ namespace CCF { template <typename T> void ValueTypeTemplate<T>:: - traverse (T& i) + traverse (T& v) { - pre (i); - name (i); - inherits (i); - supports (i); - names (i); - post (i); + pre (v); + name (v); + inherits (v); + supports (v); + names (v); + post (v); } template <typename T> @@ -34,26 +34,35 @@ namespace CCF template <typename T> void ValueTypeTemplate<T>:: - inherits (T&, EdgeDispatcherBase&) + inherits (T& v, EdgeDispatcherBase& d) { - //@@ TODO + iterate_and_traverse (v.inherits_begin (), + v.inherits_end (), + d); } template <typename T> void ValueTypeTemplate<T>:: - inherits (T&) + inherits (T& v) { - /* typename T::InheritsIterator - b (i.inherits_begin ()), e (i.inherits_end ()); + b (v.inherits_begin ()), e (v.inherits_end ()); if (b != e) { - inherits_pre (i); - iterate_and_dispatch (b, e, *this, &ValueTypeTemplate::comma, i); - inherits_post (i); + inherits_pre (v); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &ValueTypeTemplate::comma, + v); + inherits_post (v); + } + else + { + inherits_none (v); } - */ } template <typename T> @@ -76,26 +85,35 @@ namespace CCF template <typename T> void ValueTypeTemplate<T>:: - supports (T&, EdgeDispatcherBase&) + supports (T& v, EdgeDispatcherBase& d) { - //@@ TODO + iterate_and_traverse (v.supports_begin (), + v.supports_end (), + d); } template <typename T> void ValueTypeTemplate<T>:: - supports (T&) + supports (T& v) { - /* typename T::SupportsIterator - b (i.supports_begin ()), e (i.supports_end ()); + b (v.supports_begin ()), e (v.supports_end ()); if (b != e) { - supports_pre (i); - iterate_and_dispatch (b, e, *this, &ValueTypeTemplate::comma, i); - supports_post (i); + supports_pre (v); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &ValueTypeTemplate::comma, + v); + supports_post (v); + } + else + { + supports_none (v); } - */ } template <typename T> diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp index 316bd888cbd..653c153cbbf 100644 --- a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp @@ -144,7 +144,7 @@ namespace CCF } catch (NotDefined const& e) { - cerr << "attempt to support from forward-declared component " + cerr << "attempt to support forward-declared interface " << e.name () << endl; cerr << "support of forward-declared interface is illegal" << endl; diff --git a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp index d3aa9275125..4d3b745630c 100644 --- a/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp +++ b/TAO/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp @@ -105,12 +105,133 @@ namespace CCF inherits (IdentifierPtr const& id) { if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::ValueType& v ( + resolve<SemanticGraph::ValueType> (from, name, Flags::defined)); + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + v); + + + bool abstract (dynamic_cast<AbstractValueType*> (&v) != 0); + + if (dynamic_cast<AbstractValueType*> (&now ()) != 0) + { + // Abstract eventtype may only inherit from abstract ones. + // + if (!abstract) + { + cerr << "abstract eventtype `" << now ().name () + << "\' may not inherit from concrete valuetype `" + << v.scoped_name () << "\'" << endl; + return; + } + } + else + { + // Concrete eventtype may inherit from single concrete + // valutype in which case it should be the first in the + // inheritance list. + // + if (now ().inherits_begin () != now ().inherits_end () && + !abstract) + { + cerr << "concrete valuetype `" << v.scoped_name () + << "\' is not the first in the inheritance list of " + << "eventtype `" << now ().name () << "\'" << endl; + return; + } + } + + ctx.tu ().new_edge<Inherits> (now (), v); + ctx.tu ().new_edge<Extends> (now (), v); + } + catch (Resolve const&) + { + cerr << "error: invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no valuetype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to inherit from the forward-declared valuetype " + << e.name () << endl; + cerr << "inheritance from a forward-declared valuetype is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << "directly inheriting from valuetype \'" << e.name () + << "\' more than once is illegal" << endl; + } } void EventType:: supports (IdentifierPtr const& id) { if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << "error: invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << "attempt to support forward-declared interface " + << 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 EventType:: diff --git a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp index 8e7702e28ad..92c985c6176 100644 --- a/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp +++ b/TAO/CIAO/CCF/CCF/IDL3/Traversal/EventType.tpp @@ -10,14 +10,14 @@ namespace CCF { template <typename T> void EventTypeTemplate<T>:: - traverse (T& i) + traverse (T& et) { - pre (i); - name (i); - inherits (i); - supports (i); - names (i); - post (i); + pre (et); + name (et); + inherits (et); + supports (et); + names (et); + post (et); } template <typename T> @@ -34,26 +34,36 @@ namespace CCF template <typename T> void EventTypeTemplate<T>:: - inherits (T&, EdgeDispatcherBase&) + inherits (T& et, EdgeDispatcherBase& d) { - //@@ TODO + iterate_and_traverse (et.inherits_begin (), + et.inherits_end (), + d); + } template <typename T> void EventTypeTemplate<T>:: - inherits (T&) + inherits (T& et) { - /* typename T::InheritsIterator - b (i.inherits_begin ()), e (i.inherits_end ()); + b (et.inherits_begin ()), e (et.inherits_end ()); if (b != e) { - inherits_pre (i); - iterate_and_dispatch (b, e, *this, &EventTypeTemplate::comma, i); - inherits_post (i); + inherits_pre (et); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &EventTypeTemplate::comma, + et); + inherits_post (et); + } + else + { + inherits_none (et); } - */ } template <typename T> @@ -76,26 +86,35 @@ namespace CCF template <typename T> void EventTypeTemplate<T>:: - supports (T&, EdgeDispatcherBase&) + supports (T& et, EdgeDispatcherBase& d) { - //@@ TODO + iterate_and_traverse (et.supports_begin (), + et.supports_end (), + d); } template <typename T> void EventTypeTemplate<T>:: - supports (T&) + supports (T& et) { - /* typename T::SupportsIterator - b (i.supports_begin ()), e (i.supports_end ()); + b (et.supports_begin ()), e (et.supports_end ()); if (b != e) { - supports_pre (i); - iterate_and_dispatch (b, e, *this, &EventTypeTemplate::comma, i); - supports_post (i); + supports_pre (et); + iterate_and_traverse (b, + e, + this->edge_traverser (), + *this, + &EventTypeTemplate::comma, + et); + supports_post (et); + } + else + { + supports_none (et); } - */ } template <typename T> diff --git a/TAO/CIAO/ChangeLog b/TAO/CIAO/ChangeLog index c7de40213b7..ffe94318a86 100644 --- a/TAO/CIAO/ChangeLog +++ b/TAO/CIAO/ChangeLog @@ -1,3 +1,46 @@ +Mon Mar 21 16:25:07 2005 Boris Kolpackov <boris@kolpackov.net> + + * CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.cpp: + * CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeMember.hpp: + + Finished "full support" for valuetype members. It also + adds "full support" for eventtype members since it just + re-uses valuetype's rules. + + + * CCF/CCF/IDL2/Parser.cpp: + * CCF/CCF/IDL2/Parser.hpp: + * CCF/CCF/IDL2/SemanticAction/ValueTypeFactory.hpp: + * CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.cpp: + * CCF/CCF/IDL2/SemanticAction/Impl/ValueTypeFactory.hpp: + * CCF/CCF/IDL2/SemanticAction.hpp: + * CCF/CCF/IDL2/SemanticAction/Factory.hpp: + * CCF/CCF/IDL2/SemanticAction/Impl/Factory.cpp: + * CCF/CCF/IDL2/SemanticAction/Impl/Factory.hpp: + + Added support for valuetype factories. + + + * CCF/CCF/IDL2/SemanticAction/Impl/ValueType.cpp: + * CCF/CCF/IDL2/SemanticGraph/ValueType.hpp: + * CCF/CCF/IDL2/Traversal/ValueType.tpp: + + Implemented support for valuetype inheritance and + support of interfaces. + + + * CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp: + * CCF/CCF/IDL3/Traversal/EventType.tpp: + + Implemented support for eventtype inheritance and + support of interfaces. + + + * CCF/CCF/IDL2/SemanticAction/Impl/Member.cpp: + * CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp: + + Minor cleanups. + Sun Mar 20 21:35:04 2005 Jaiganesh B <jai@dre.vanderbilt.edu> * DAnCE/examples/Swapping/Sender/Sender.mpc: @@ -154,6 +197,7 @@ Sat Mar 19 18:19:34 2005 Will Otte <wotte@dre.vanderbilt.edu> * DAnCE/Config_Handlers/XSCRT/XMLSchema.tpp Completed the merge of xsc_handler_1 into main. + Sat Mar 19 17:29:50 2005 Jaiganesh B <jai@dre.vanderbilt.edu> * DAnCE/RepositoryManager/RepositoryManager_Impl.cpp: |