diff options
Diffstat (limited to 'modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl')
27 files changed, 2691 insertions, 0 deletions
diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp new file mode 100644 index 00000000000..68cec9313ae --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.cpp @@ -0,0 +1,202 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Component:: + Component (Context& c) + : ScopeBase<SemanticGraph::Component> (c) + { + } + + void Component:: + begin_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void Component:: + begin_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "component fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Component&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Component> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void Component:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Component& c ( + resolve<SemanticGraph::Component> (from, name, Flags::defined)); + + ctx.tu ().new_edge<Inherits> (now (), c); + ctx.tu ().new_edge<Extends> (now (), c); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from forward-declared component is illegal" + << endl; + } + } + + void Component:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + //@@ Implementation of *_scope is the same for all cases. + // + void Component:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Component:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Component:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp new file mode 100644 index 00000000000..768799784e8 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Component.hpp @@ -0,0 +1,51 @@ +// file : CCF/IDL3/SemanticAction/Impl/Component.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Component : SemanticAction::Component, + ScopeBase<SemanticGraph::Component> + { + Component (Context& c); + + virtual void + begin_def (SimpleIdentifierPtr const& id); + + virtual void + begin_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_COMPONENT_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp new file mode 100644 index 00000000000..56dd0ef3b0a --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.cpp @@ -0,0 +1,88 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Consumes:: + Consumes (Context& c) + : Base (c) + { + } + + void Consumes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "consumes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid consumes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in consumes declaration is illegal" + << endl; + } + } + + void Consumes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Consumer& c (ctx.tu ().new_node<Consumer> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (c, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), c, id->lexeme ()); + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp new file mode 100644 index 00000000000..65214fb90eb --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Consumes.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Consumes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Consumes : SemanticAction::Consumes, Base + { + Consumes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_CONSUMES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp new file mode 100644 index 00000000000..c52ff827fa5 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Elements.hpp @@ -0,0 +1,30 @@ +// file : CCF/IDL3/SemanticAction/Impl/Elements.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP + +#include "CCF/IDL3/SemanticAction/Elements.hpp" +#include "CCF/IDL2/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using IDL2::SemanticAction::Impl::Context; + using IDL2::SemanticAction::Impl::Base; + using IDL2::SemanticAction::Impl::ScopeBase; + + using IDL2::SemanticAction::Impl::lookup; + + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_ELEMENTS_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp new file mode 100644 index 00000000000..6f49a05016c --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.cpp @@ -0,0 +1,88 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Emits:: + Emits (Context& c) + : Base (c) + { + } + + void Emits:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "emits " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid emits declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in emits declaration is illegal" + << endl; + } + } + + void Emits:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Emitter& e (ctx.tu ().new_node<Emitter> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (e, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), e, id->lexeme ()); + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp new file mode 100644 index 00000000000..30c0f254756 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Emits.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Emits.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Emits.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Emits : SemanticAction::Emits, Base + { + Emits (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EMITS_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp new file mode 100644 index 00000000000..f68eda81cae --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.cpp @@ -0,0 +1,293 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + EventType:: + EventType (Context& c) + : ScopeBase<SemanticGraph::EventType> (c) + { + } + + void EventType:: + begin_abstract_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "abstract eventtype def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void EventType:: + begin_abstract_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "abstract eventtype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<AbstractEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<AbstractEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void EventType:: + begin_concrete_def (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "concrete eventtype def " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + void EventType:: + begin_concrete_fwd (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "concrete eventtype fwd " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<ConcreteEventType&>(*s)); + } + else + { + now (ctx.tu ().new_node<ConcreteEventType> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); + } + + void EventType:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::ValueType& v ( + resolve<SemanticGraph::ValueType> (from, name, Flags::defined)); + + check_inheritance (now ().inherits_begin (), + now ().inherits_end (), + v); + + + bool abstract (dynamic_cast<AbstractValueType*> (&v) != 0); + + if (dynamic_cast<AbstractValueType*> (&now ()) != 0) + { + // Abstract eventtype may only inherit from abstract ones. + // + if (!abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "abstract eventtype `" << now ().name () + << "\' may not inherit from concrete valuetype `" + << v.scoped_name () << "\'" << endl; + return; + } + } + else + { + // Concrete eventtype may inherit from single concrete + // valutype in which case it should be the first in the + // inheritance list. + // + if (now ().inherits_begin () != now ().inherits_end () && + !abstract) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "concrete valuetype `" << v.scoped_name () + << "\' is not the first in the inheritance list of " + << "eventtype `" << now ().name () << "\'" << endl; + return; + } + } + + ctx.tu ().new_edge<Inherits> (now (), v); + ctx.tu ().new_edge<Extends> (now (), v); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no valuetype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from the forward-declared valuetype " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from a forward-declared valuetype is illegal" + << endl; + } + catch (AlreadyInherited const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly inheriting from valuetype \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void EventType:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support forward-declared interface " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + void EventType:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void EventType:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void EventType:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp new file mode 100644 index 00000000000..f82502be83c --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventType.hpp @@ -0,0 +1,57 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventType.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct EventType : SemanticAction::EventType, + ScopeBase<SemanticGraph::EventType> + { + EventType (Context& c); + + virtual void + begin_abstract_def (SimpleIdentifierPtr const& id); + + virtual void + begin_abstract_fwd (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_def (SimpleIdentifierPtr const& id); + + virtual void + begin_concrete_fwd (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp new file mode 100644 index 00000000000..8e8544815c0 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp @@ -0,0 +1,152 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventTypeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + EventTypeFactory:: + EventTypeFactory (Context& c) + : Base (c) + { + } + + void EventTypeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + f_ = 0; + + SemanticGraph::EventType& h ( + dynamic_cast<SemanticGraph::EventType&>(ctx.scope ())); + + SimpleName name (id->lexeme ()); + + f_ = &ctx.tu ().new_node<SemanticGraph::EventTypeFactory> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*f_, h); + ctx.tu ().new_edge<Defines> (ctx.scope (), *f_, name); + } + + + void EventTypeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (f_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*f_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void EventTypeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (f_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*f_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp new file mode 100644 index 00000000000..1489651b7c8 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/EventTypeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct EventTypeFactory : SemanticAction::EventTypeFactory, Base + { + EventTypeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::EventTypeFactory* f_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_EVENT_TYPE_FACTORY_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp new file mode 100644 index 00000000000..233d931b97e --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.cpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Factory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Factory.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + Factory:: + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu) + : IDL2::SemanticAction::Impl::Factory (context, dout, tu), + + component_ (ctx_), + consumes_ (ctx_), + emits_ (ctx_), + event_type_ (ctx_), + event_type_factory_ (ctx_), + home_ (ctx_), + home_factory_ (ctx_), + home_finder_ (ctx_), + include_ (ctx_, dout, *this), + provides_ (ctx_), + publishes_ (ctx_), + uses_ (ctx_) + { + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp new file mode 100644 index 00000000000..fc6b80a9a6b --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Factory.hpp @@ -0,0 +1,134 @@ +// file : CCF/IDL3/SemanticAction/Impl/Factory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP + +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +#include "CCF/IDL2/SemanticAction/Impl/Factory.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Emits.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Consumes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Impl/EventTypeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Factory : virtual IDL3::SemanticAction::Factory, + virtual IDL2::SemanticAction::Impl::Factory + { + Factory (CompilerElements::Context& context, + Diagnostic::Stream& dout, + SemanticGraph::TranslationUnit& tu); + + virtual SemanticAction::Consumes& + consumes () + { + return consumes_; + } + + virtual SemanticAction::Component& + component () + { + return component_; + } + + virtual SemanticAction::Emits& + emits () + { + return emits_; + } + + + virtual SemanticAction::EventType& + event_type () + { + return event_type_; + } + + virtual EventTypeFactory& + event_type_factory () + { + return event_type_factory_; + } + + + virtual SemanticAction::Home& + home () + { + return home_; + } + + virtual SemanticAction::HomeFactory& + home_factory () + { + return home_factory_; + } + + virtual SemanticAction::HomeFinder& + home_finder () + { + return home_finder_; + } + + virtual IDL2::SemanticAction::Include& + include () + { + return include_; + } + + virtual SemanticAction::Provides& + provides () + { + return provides_; + } + + virtual SemanticAction::Publishes& + publishes () + { + return publishes_; + } + + virtual SemanticAction::Uses& + uses () + { + return uses_; + } + + private: + + Component component_; + Consumes consumes_; + Emits emits_; + EventType event_type_; + EventTypeFactory event_type_factory_; + Home home_; + HomeFactory home_factory_; + HomeFinder home_finder_; + Include include_; + Provides provides_; + Publishes publishes_; + Uses uses_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_FACTORY_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp new file mode 100644 index 00000000000..d6be4cf9c72 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.cpp @@ -0,0 +1,230 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Home.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Home:: + Home (Context& c) + : ScopeBase<SemanticGraph::Home> (c) + { + } + + void Home:: + begin (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "home " << id << endl; + + SimpleName name (id->lexeme ()); + + if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) + { + now (dynamic_cast<SemanticGraph::Home&>(*s)); + } + else + { + now (ctx.tu ().new_node<SemanticGraph::Home> ( + ctx.file (), id->line ())); + } + + ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); + } + + + void Home:: + inherits (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "inherits " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Home& h ( + resolve<SemanticGraph::Home> (from, name, Flags::defined)); + + ctx.tu ().new_edge<Inherits> (now (), h); + ctx.tu ().new_edge<Extends> (now (), h); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid inheritance specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no home with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in inheritance specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to inherit from forward-declared home " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "inheritance from forward-declared home is illegal" + << endl; + } + } + + + void Home:: + supports (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "supports " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Interface& i ( + resolve<SemanticGraph::Interface> (from, name, Flags::defined)); + + check_support (now ().supports_begin (), + now ().supports_end (), + i); + + ctx.tu ().new_edge<Supports> (now (), i); + ctx.tu ().new_edge<Extends> (now (), i); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid supports specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in supports specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to support from forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "support of forward-declared interface is illegal" + << endl; + } + catch (AlreadySupported const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "directly supporting interface \'" << e.name () + << "\' more than once is illegal" << endl; + } + } + + + void Home:: + manages (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "manages " << id << endl; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + ctx.tu ().new_edge<Manages> ( + now (), + resolve<SemanticGraph::Component> (from, name, Flags::defined)); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid manages specification" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no component with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "incompatible type in manages specification" << endl; + } + catch (NotDefined const& e) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "attempt to manage forward-declared component " + << e.name () << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "management of forward-declared component is illegal" + << endl; + } + } + + void Home:: + open_scope () + { + if (ctx.trace ()) cerr << "scope open" << endl; + + push (ctx.scope ()); + ctx.scope (now ()); + } + + void Home:: + close_scope () + { + ctx.scope (top ()); + pop (); + + if (ctx.trace ()) cerr << "scope close" << endl; + } + + void Home:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp new file mode 100644 index 00000000000..459f78c89db --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Home.hpp @@ -0,0 +1,50 @@ +// file : CCF/IDL3/SemanticAction/Impl/Home.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/Home.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Home : SemanticAction::Home, ScopeBase<SemanticGraph::Home> + { + Home (Context& c); + + virtual void + begin (SimpleIdentifierPtr const& id); + + virtual void + inherits (IdentifierPtr const& id); + + virtual void + supports (IdentifierPtr const& id); + + virtual void + manages (IdentifierPtr const& id); + + virtual void + open_scope (); + + virtual void + close_scope (); + + virtual void + end (); + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp new file mode 100644 index 00000000000..b47e0b13410 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp @@ -0,0 +1,155 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeFactory:: + HomeFactory (Context& c) + : Base (c) + { + } + + void HomeFactory:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + hf_ = 0; + + SemanticGraph::Home& h ( + dynamic_cast<SemanticGraph::Home&>(ctx.scope ())); + + SemanticGraph::Component& c ( + dynamic_cast<SemanticGraph::Component&>(h.manages ().managee ())); + + SimpleName name (id->lexeme ()); + + hf_ = &ctx.tu ().new_node<SemanticGraph::HomeFactory> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*hf_, c); + ctx.tu ().new_edge<Defines> (ctx.scope (), *hf_, name); + } + + + void HomeFactory:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (hf_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*hf_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as an factory parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void HomeFactory:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (hf_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*hf_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp new file mode 100644 index 00000000000..1e6eccfb443 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFactory.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFactory.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct HomeFactory : SemanticAction::HomeFactory, Base + { + HomeFactory (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::HomeFactory* hf_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FACTORY_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp new file mode 100644 index 00000000000..89fe20f36f4 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp @@ -0,0 +1,155 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFinder.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + HomeFinder:: + HomeFinder (Context& c) + : Base (c) + { + } + + void HomeFinder:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + hf_ = 0; + + SemanticGraph::Home& h ( + dynamic_cast<SemanticGraph::Home&>(ctx.scope ())); + + SemanticGraph::Component& c ( + dynamic_cast<SemanticGraph::Component&>(h.manages ().managee ())); + + SimpleName name (id->lexeme ()); + + hf_ = &ctx.tu ().new_node<SemanticGraph::HomeFinder> ( + ctx.file (), id->line ()); + + ctx.tu ().new_edge<Returns> (*hf_, c); + ctx.tu ().new_edge<Defines> (ctx.scope (), *hf_, name); + } + + + void HomeFinder:: + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id) + { + if (ctx.trace ()) cerr << "parameter in " << " " + << type_id << " " << name_id << endl; + + if (hf_ == 0) return; + + Name name (type_id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + Type& t (resolve<Type> (from, name, Flags::complete)); + + Parameter& p ( + ctx.tu ().new_node<InParameter> ( + ctx.file (), name_id->line (), name_id->lexeme ())); + + ctx.tu ().new_edge<Belongs> (p, t); + ctx.tu ().new_edge<Receives> (*hf_, p); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "invalid parameter declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "using non-type as a finder parameter type is " + << "illegal" << endl; + } + catch (NotComplete const& e) + { + cerr << ctx.file () << ":" << type_id->line () << ": error: " + << "type \'" << e.name () << "\' is not complete" << endl; + } + } + + void HomeFinder:: + raises (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "raises " << id << endl; + + if (hf_ == 0) return; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + SemanticGraph::Exception& e ( + resolve<SemanticGraph::Exception> (from, name)); + + ctx.tu ().new_edge<Raises> (*hf_, e); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid raises declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no exception with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an exception declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-exception type in raises declaration is " + << "illegal" << endl; + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp new file mode 100644 index 00000000000..0467eeda3ec --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp @@ -0,0 +1,43 @@ +// file : CCF/IDL3/SemanticAction/Impl/HomeFinder.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP + +#include "CCF/IDL3/SemanticGraph/Home.hpp" +#include "CCF/IDL3/SemanticAction/HomeFinder.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + + struct HomeFinder : SemanticAction::HomeFinder, Base + { + HomeFinder (Context& c); + + virtual void + name (SimpleIdentifierPtr const& id); + + virtual void + parameter (IdentifierPtr const& type_id, + SimpleIdentifierPtr const& name_id); + + virtual void + raises (IdentifierPtr const& id); + + private: + SemanticGraph::HomeFinder* hf_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_HOME_FINDER_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp new file mode 100644 index 00000000000..3e4b42a5267 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.cpp @@ -0,0 +1,284 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticAction/Impl/Include.hpp" + +#include "CCF/CompilerElements/TokenStream.hpp" +#include "CCF/CompilerElements/Preprocessor.hpp" + +#include "CCF/IDL3/LexicalAnalyzer.hpp" +#include "CCF/IDL3/Parser.hpp" + +#include <vector> +#include <string> +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Include:: + Include (Context& c, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory) + : Base (c), + dout_ (dout), + action_factory_ (action_factory) + { + abs_path_stack_.push ( + fs::normalize ( + fs::complete ( + ctx.parsing_context ().get<fs::path> ("file-path")))); + } + + void Include:: + quote (StringLiteralPtr const& sl) + { + impl (sl, quote_); + } + + void Include:: + bracket (StringLiteralPtr const& sl) + { + impl (sl, bracket_); + } + + + void Include:: + end () + { + if (ctx.trace ()) cerr << "end" << endl; + } + + void Include:: + impl (StringLiteralPtr const& sl, Type_ type) + { + CompilerElements::Context& pctx (ctx.parsing_context ()); + + std::string prefix; + + if (type == quote_) + { + prefix = std::string ("include") + " \"" + sl->value () + "\""; + } + else + { + prefix = std::string ("include") + " <" + sl->value () + ">"; + } + + if (ctx.trace ()) cerr << prefix << endl; + + try + { + fs::ifstream ifs; + ifs.exceptions (std::ios_base::badbit | std::ios_base::failbit); + + fs::path include_path (sl->value ()); + fs::path complete_path (include_path); + + if (ctx.trace ()) cerr << prefix << ": staring resolution." + << endl; + + if (complete_path.is_complete ()) + { + complete_path = fs::normalize (complete_path); + + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + } + else + { + bool found (false); + + if (type == quote_) + { + fs::path rel_path (abs_path_stack_.top ().branch_path ()); + + complete_path = fs::normalize (rel_path / include_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + typedef std::vector<fs::path> SearchPaths; + + SearchPaths const& search_paths ( + pctx.get<SearchPaths> ("include-search-paths")); + + for (SearchPaths::const_iterator + i (search_paths.begin ()), + e (search_paths.end ()); i != e && !found; ++i) + { + complete_path = *i / include_path; + + if (!complete_path.is_complete ()) + { + complete_path = complete (complete_path); + } + + complete_path = fs::normalize (complete_path); + + if (ctx.trace ()) cerr << prefix << ": considering " + << complete_path.string () << endl; + + if (fs::exists (complete_path)) + { + if (handle_already_included (complete_path, sl)) return; + ifs.open (complete_path, std::ios_base::in); + found = true; + } + } + + if (!found) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': file not found" << endl; + return; + } + } + } + + if (ctx.trace ()) cerr << prefix << ": resolved to " + << complete_path.string () << endl; + + //@@ for some reason ifs throws exception if I don't reset it + // to original state. It probably has something to do with + // call to get after eof. + // + ifs.exceptions (std::ios_base::iostate (0)); + + TranslationRegion& r ( + ctx.tu ().new_node<TranslationRegion> (include_path, 0)); + + if (type == quote_) + { + ctx.tu ().new_edge<QuoteIncludes> ( + ctx.region (), r, include_path); + } + else + { + ctx.tu ().new_edge<BracketIncludes> ( + ctx.region (), r, include_path); + } + + // Set new current region. + // + stack_.push (&ctx.region ()); + ctx.region (r); + + // Create Root scope for new region. + // + Root& root (ctx.tu ().new_node<Root> (include_path, 0)); + ctx.tu ().new_edge<ContainsRoot> (r, root); + ctx.scope (root); + + // Store previous relative path and current absolute. + // + rel_path_stack_.push (pctx.get<fs::path> ("file-path")); + pctx.set("file-path", include_path); + + abs_path_stack_.push (complete_path); + + + // Parse the file. + // + // + + //@@ this code is highly experimental + CompilerElements::InputStreamAdapter isa (ifs); + + CompilerElements::CPP::Symbols const& symbols ( + pctx.get<CompilerElements::CPP::Symbols> ("cpp-symbols")); + CompilerElements::CPP::Preprocessor pp (isa, symbols); + + IDL3::LexicalAnalyzer lexer (pp); + + TokenList token_stream; + + //@@ bad token comparison + for (TokenPtr token = lexer.next ();; token = lexer.next ()) + { + token_stream.push_back (token); + if (ReferenceCounting::strict_cast<EndOfStream> (token) != 0) + break; + } + + if (token_stream.size () > 1) + { + IDL3::Parser parser (pctx, dout_, lexer, action_factory_); + + IDL2::Parsing::parse (token_stream.begin (), + token_stream.end (), + parser.start ()); + } + + // Restore paths + // + abs_path_stack_.pop (); + + pctx.set("file-path", rel_path_stack_.top ()); + rel_path_stack_.pop (); + + + // Restore region. + // + ctx.region (*stack_.top ()); + stack_.pop (); + + // Create new Root scope. + // + { + Root& root (ctx.tu ().new_node<Root> (ctx.file (), 0)); + ctx.tu ().new_edge<ContainsRoot> (ctx.region (), root); + ctx.scope (root); + } + } + catch (fs::filesystem_error const&) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': unable to open in read mode" << endl; + } + catch (std::ios_base::failure const&) + { + cerr << ctx.file () << ":" << sl->line () << ": error: " + << "'" << sl << "': unable to open in read mode" << endl; + } + } + + bool Include:: + handle_already_included (fs::path const& path, + StringLiteralPtr const&) + { + if(!include_file_set_.insert (path).second) + { + // cerr << "warning: skipping already included file " << sl + // << endl; + return true; + } + return false; + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp new file mode 100644 index 00000000000..9c699fe20ba --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Include.hpp @@ -0,0 +1,84 @@ +// file : CCF/IDL3/SemanticAction/Impl/Include.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP + +#include <set> +#include <stack> + +#include "CCF/CompilerElements/Context.hpp" +#include "CCF/CompilerElements/Diagnostic.hpp" + +#include "CCF/IDL2/SemanticGraph/Translation.hpp" +#include "CCF/IDL3/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticAction/Include.hpp" +#include "CCF/IDL3/SemanticAction/Factory.hpp" + +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + // Note: overriding IDL2 include to allow inclusion of IDL3 files. + // + // + struct Include : IDL2::SemanticAction::Include, Base + { + public: + Include (Context& c, + Diagnostic::Stream& dout, + SemanticAction::Factory& action_factory); + + virtual void + quote (StringLiteralPtr const& sl); + + virtual void + bracket (StringLiteralPtr const& sl); + + virtual void + end (); + + private: + enum Type_ + { + quote_, + bracket_ + }; + + virtual void + impl (StringLiteralPtr const& sl, Type_ type); + + bool + handle_already_included (fs::path const& path, + StringLiteralPtr const& sl); + private: + Diagnostic::Stream& dout_; + SemanticAction::Factory& action_factory_; + + std::stack<SemanticGraph::TranslationRegion*> stack_; + std::stack<fs::path> abs_path_stack_, rel_path_stack_; + + struct FilePathComparator + { + bool operator () (fs::path const& x, fs::path const& y) const + { + return x.string () < y.string (); + } + }; + + std::set<fs::path, FilePathComparator> include_file_set_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_INCLUDE_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp new file mode 100644 index 00000000000..4bfc9818c65 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.cpp @@ -0,0 +1,89 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Provides.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Provides:: + Provides (Context& c) + : Base (c) + { + } + + void Provides:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "provides " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid provides declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an interface declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-interface type in provides declaration is " + << "illegal" << endl; + } + } + + void Provides:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Provider& p ( + ctx.tu ().new_node<Provider> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp new file mode 100644 index 00000000000..14dff782045 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Provides.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Provides.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Provides.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Provides : SemanticAction::Provides, Base + { + Provides (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PROVIDES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp new file mode 100644 index 00000000000..01ccd4a2347 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.cpp @@ -0,0 +1,89 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Publishes.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Publishes:: + Publishes (Context& c) + : Base (c) + { + } + + void Publishes:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) cerr << "publishes " << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<EventType> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid publishes declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no eventtype with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an eventtype declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-eventtype in publishes declaration is illegal" + << endl; + } + } + + void Publishes:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + Publisher& p ( + ctx.tu ().new_node<Publisher> ( + ctx.file (), id->line ())); + + ctx.tu ().new_edge<Belongs> (p, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), p, id->lexeme ()); + } + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp new file mode 100644 index 00000000000..584704acd66 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Publishes.hpp @@ -0,0 +1,38 @@ +// file : CCF/IDL3/SemanticAction/Impl/Publishes.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP + +#include "CCF/IDL3/SemanticGraph/EventType.hpp" +#include "CCF/IDL3/SemanticAction/Publishes.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Publishes : SemanticAction::Publishes, Base + { + Publishes (Context& c); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + SemanticGraph::EventType* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_PUBLISHES_HPP diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp new file mode 100644 index 00000000000..ce32f39dea0 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.cpp @@ -0,0 +1,101 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.cpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#include "CCF/IDL3/SemanticGraph/Component.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Uses.hpp" + +#include <iostream> + +using std::cerr; +using std::endl; + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + using namespace SemanticGraph; + + Uses:: + Uses (Context& c) + : Base (c), multiple_ (false) + { + } + + void Uses:: + multiple () + { + multiple_ = true; + } + + void Uses:: + type (IdentifierPtr const& id) + { + if (ctx.trace ()) + cerr << "uses " << (multiple_ ? "multiple ": "") << id; + + type_ = 0; + + Name name (id->lexeme ()); + ScopedName from (ctx.scope ().scoped_name ()); + + try + { + try + { + type_ = &resolve<SemanticGraph::Interface> (from, name); + } + catch (Resolve const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "invalid uses declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "no interface with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << ctx.file () << ":" << id->line () << ": error: " + << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not an interface declaration" << endl; + + cerr << ctx.file () << ":" << id->line () << ": error: " + << "using non-interface type in uses declaration is " + << "illegal" << endl; + } + } + + void Uses:: + name (SimpleIdentifierPtr const& id) + { + if (ctx.trace ()) cerr << " " << id << endl; + + if (type_) + { + User* u; + + if (multiple_) + u = &ctx.tu ().new_node<MultiUser> (ctx.file (), id->line ()); + else + u = &ctx.tu ().new_node<SingleUser> (ctx.file (), id->line ()); + + ctx.tu ().new_edge<Belongs> (*u, *type_); + ctx.tu ().new_edge<Defines> (ctx.scope (), *u, id->lexeme ()); + } + + multiple_ = false; + } + } + } + } +} diff --git a/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp new file mode 100644 index 00000000000..bf7331ad172 --- /dev/null +++ b/modules/CIAO/CCF/CCF/IDL3/SemanticAction/Impl/Uses.hpp @@ -0,0 +1,42 @@ +// file : CCF/IDL3/SemanticAction/Impl/Uses.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP +#define CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP + +#include "CCF/IDL2/SemanticGraph/Interface.hpp" +#include "CCF/IDL3/SemanticAction/Uses.hpp" +#include "CCF/IDL3/SemanticAction/Impl/Elements.hpp" + +namespace CCF +{ + namespace IDL3 + { + namespace SemanticAction + { + namespace Impl + { + struct Uses : SemanticAction::Uses, Base + { + Uses (Context& c); + + virtual void + multiple (); + + virtual void + type (IdentifierPtr const& id); + + virtual void + name (SimpleIdentifierPtr const& id); + + private: + bool multiple_; + SemanticGraph::Interface* type_; + }; + } + } + } +} + +#endif // CCF_IDL3_SEMANTIC_ACTION_IMPL_USES_HPP |