void Composition:: begin (SimpleIdentifierPtr const& id, Category::Value c) { if (ctx.trace ()) cerr << "composition " << id << endl; if(c == Category::entity) { now (ctx.tu ().new_node<EntityComposition> ( ctx.file (), id->line ())); } else if (c == Category::process) { now (ctx.tu ().new_node<ProcessComposition> ( ctx.file (), id->line ())); } else if (c == Category::service) { now (ctx.tu ().new_node<ServiceComposition> ( ctx.file (), id->line ())); } else { now (ctx.tu ().new_node<SessionComposition> ( ctx.file (), id->line ())); } ctx.tu ().new_edge<Defines> (ctx.scope (), now (), id->lexeme ()); }
void Operation:: name (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << " " << id << endl; if (one_way_) { if (dynamic_cast<Void*> (type_) == 0) { cerr << ctx.file () << ":" << id->line () << ": error: " << "invalid operation declaration" << endl; cerr << ctx.file () << ":" << id->line () << ": error: " << "oneway operation should have void as a return type" << endl; } op_ = &ctx.tu ().new_node<OneWayOperation> ( ctx.file (), id->line ()); } else op_ = &ctx.tu ().new_node<TwoWayOperation> ( ctx.file (), id->line ()); SimpleName name (id->lexeme ()); ctx.tu ().new_edge<Defines> (ctx.scope (), *op_, name); if (type_) { ctx.tu ().new_edge<Returns> (*op_, *type_); } }
void Typedef:: declarator (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << " " << id << endl; SimpleName name (id->lexeme ()); try { if (lookup (ctx.tu (), ctx.scope (), name) == 0) { if (array_type_ != 0) { assert (define_); ctx.tu ().new_edge<Defines> (ctx.scope (), *array_type_, name); define_ = false; array_type_ = 0; } else if (type_ != 0) { if (define_) { ctx.tu ().new_edge<Defines> (ctx.scope (), *type_, name); define_ = false; } else { ctx.tu ().new_edge<Aliases> (ctx.scope (), *type_, name); } } return; } } catch (NotUnique const& ) { } cerr << ctx.file () << ":" << id->line () << ": error: " << "invalid typedef declaration" << endl; cerr << ctx.file () << ":" << id->line () << ": error: " << "redeclaration of name " << name << endl; array_type_ = 0; }
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 Native:: name (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "native " << id << endl; SimpleName name (id->lexeme ()); SemanticGraph::Native& n ( ctx.tu ().new_node<SemanticGraph::Native> ( ctx.file (), id->line ())); ctx.tu ().new_edge<Defines> (ctx.scope (), n, name); }
void Enum:: begin (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "enum " << id << endl; type_ = 0; SimpleName name (id->lexeme ()); type_ = &ctx.tu ().new_node<SemanticGraph::Enum> ( ctx.file (), id->line ()); ctx.tu ().new_edge<Defines> (ctx.scope (), *type_, name); }
void ValueTypeMember:: name (SimpleIdentifierPtr const& id) { using namespace SemanticGraph; if (ctx.trace ()) cerr << " name: " << id << endl; if (type_) { SimpleName name (id->lexeme ()); SemanticGraph::ValueTypeMember* m; switch (access_) { case SemanticGraph::ValueTypeMember::Access::private_: { m = &ctx.tu ().new_node<ValueTypePrivateMember> ( ctx.file (), id->line ()); break; } case SemanticGraph::ValueTypeMember::Access::public_: { m = &ctx.tu ().new_node<ValueTypePublicMember> ( ctx.file (), id->line ()); break; } default: { abort (); } } ctx.tu ().new_edge<Belongs> (*m, *type_); ctx.tu ().new_edge<Defines> (ctx.scope (), *m, name); } }
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 ()); } }
void Member:: name (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << " " << id << endl; if (type_) { SimpleName name (id->lexeme ()); SemanticGraph::Member& m ( ctx.tu ().new_node<SemanticGraph::Member> ( ctx.file (), id->line ())); ctx.tu ().new_edge<Belongs> (m, *type_); ctx.tu ().new_edge<Defines> (ctx.scope (), m, name); } }
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 Interface:: begin_local_fwd (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "local interface fwd " << id << endl; SimpleName name (id->lexeme ()); if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) { now (dynamic_cast<LocalInterface&>(*s)); } else { now (ctx.tu ().new_node<LocalInterface> ( ctx.file (), id->line ())); } ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); }
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 Union:: begin_fwd (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "union fwd " << id << endl; SimpleName name (id->lexeme ()); if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) { now (dynamic_cast<SemanticGraph::Union&>(*s)); } else { now (ctx.tu ().new_node<SemanticGraph::Union> ( ctx.file (), id->line ())); } ctx.tu ().new_edge<Mentions> (ctx.scope (), now (), name); }
void Enum:: enumerator (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "enumerator " << id << endl; //@@ Need to check for redeclaration of the name. // SimpleName name (id->lexeme ()); if (type_ != 0) { Enumerator& e ( ctx.tu ().new_node<Enumerator> ( ctx.file (), id->line ())); ctx.tu ().new_edge<Belongs> (e, *type_); ctx.tu ().new_edge<Defines> (ctx.scope (), e, name); } }
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 Interface:: begin_unconstrained_def (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "unconstrained interface def " << id << endl; qualifier_ = Qualifier::unconstrained; SimpleName name (id->lexeme ()); if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) { now (dynamic_cast<UnconstrainedInterface&>(*s)); } else { now (ctx.tu ().new_node<UnconstrainedInterface> ( ctx.file (), id->line ())); } ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); }
void Interface:: begin_abstract_def (SimpleIdentifierPtr const& id) { if (ctx.trace ()) cerr << "abstract interface def " << id << endl; qualifier_ = Qualifier::abstract; SimpleName name (id->lexeme ()); //@@ Not handling NotUnique exception. // if (Nameable* s = lookup (ctx.tu (), ctx.scope (), name)) { now (dynamic_cast<AbstractInterface&>(*s)); } else { now (ctx.tu ().new_node<AbstractInterface> ( ctx.file (), id->line ())); } ctx.tu ().new_edge<Defines> (ctx.scope (), now (), name); }
void Operation:: parameter (Direction::Value direction, IdentifierPtr const& type_id, SimpleIdentifierPtr const& name_id) { if (ctx.trace ()) cerr << "parameter " << direction << " " << type_id << " " << name_id << endl; Name name (type_id->lexeme ()); ScopedName from (ctx.scope ().scoped_name ()); struct NotIn : Resolve {}; try { try { if (one_way_ && direction != Direction::in) throw NotIn (); Type& t (resolve<Type> (from, name, Flags::complete)); Parameter* p (0); switch (direction) { case Direction::in: { p = &ctx.tu ().new_node<InParameter> ( ctx.file (), name_id->line (), name_id->lexeme ()); break; } case Direction::out: { p = &ctx.tu ().new_node<OutParameter> ( ctx.file (), name_id->line (), name_id->lexeme ()); break; } case Direction::inout: { p = &ctx.tu ().new_node<InOutParameter> ( ctx.file (), name_id->line (), name_id->lexeme ()); break; } } ctx.tu ().new_edge<Belongs> (*p, t); ctx.tu ().new_edge<Receives> (*op_, *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 operation parameter type is " << "illegal" << endl; } catch (NotComplete const& e) { cerr << ctx.file () << ":" << type_id->line () << ": error: " << "type \'" << e.name () << "\' is not complete" << endl; } catch (NotIn const&) { cerr << ctx.file () << ":" << type_id->line () << ": error: " << "parameter of oneway operation should have \'in\' " << "direction" << endl; } }