diff options
Diffstat (limited to 'TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp')
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp | 137 |
1 files changed, 123 insertions, 14 deletions
diff --git a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp index a615e2c5ea3..315b69d0e51 100644 --- a/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp +++ b/TAO/CIAO/CCF/CCF/IDL2/SemanticAction/Impl/Typedef.cpp @@ -5,7 +5,10 @@ #include "CCF/IDL2/SemanticAction/Impl/Typedef.hpp" #include "CCF/IDL2/SemanticGraph/Elements.hpp" + +#include "CCF/IDL2/SemanticGraph/Array.hpp" #include "CCF/IDL2/SemanticGraph/Sequence.hpp" +#include "CCF/IDL2/SemanticGraph/String.hpp" #include <iostream> @@ -39,6 +42,7 @@ namespace CCF define_ = false; type_ = 0; + array_type_ = 0; Name name (id->lexeme ()); ScopedName from (ctx.scope ().scoped_name ()); @@ -70,12 +74,13 @@ namespace CCF } void Typedef:: - begin_seq (IdentifierPtr const& id) + begin_unbounded_seq (IdentifierPtr const& id) { - if (ctx.trace ()) cerr << "typedef sequence<" << id << ">" << endl; + if (ctx.trace ()) cerr << "typedef u-sequence<" << id << ">" << endl; define_ = true; type_ = 0; + array_type_ = 0; Name name (id->lexeme ()); ScopedName from (ctx.scope ().scoped_name ()); @@ -87,7 +92,7 @@ namespace CCF Type& t (resolve<Type> (from, name)); UnboundedSequence& s (ctx.tu ().new_node<UnboundedSequence> ()); - ctx.tu ().new_edge<Specialized> (s, t); + ctx.tu ().new_edge<ArgumentsWithType> (t, s); type_ = &s; } @@ -113,29 +118,122 @@ namespace CCF } void Typedef:: - begin_bounded_string () + begin_bounded_seq (IdentifierPtr const& id) { - if (ctx.trace ()) cerr << "typedef string<" << ">" << endl; + if (ctx.trace ()) cerr << "typedef b-sequence<" << id << ">" << endl; - define_ = false; // this should actually be true + define_ = true; + type_ = 0; + array_type_ = 0; - Name name ("::string"); + Name name (id->lexeme ()); ScopedName from (ctx.scope ().scoped_name ()); - type_ = &resolve<Type> (from, name); + try + { + try + { + Type& t (resolve<Type> (from, name)); + + BoundedSequence& s (ctx.tu ().new_node<BoundedSequence> ()); + ctx.tu ().new_edge<ArgumentsWithType> (t, s); + + type_ = &s; + } + catch (Resolve const&) + { + cerr << "error: invalid sequence declaration" << endl; + throw; + } + } + catch (NotFound const&) + { + cerr << "no type with name \'" << name + << "\' visible from scope \'" << from << "\'" << endl; + } + catch (WrongType const&) + { + cerr << "declaration with name \'" << name + << "\' visible from scope \'" << from + << "\' is not a type declaration" << endl; + cerr << "using non-type in sequence specialization is illegal" + << endl; + } + } + + void Typedef:: + begin_bounded_string () + { + if (ctx.trace ()) cerr << "typedef b-string" << endl; + + define_ = true; + type_ = 0; + array_type_ = 0; + + type_ = &ctx.tu ().new_node<BoundedString> (); + bound (); } void Typedef:: begin_bounded_wstring () { - if (ctx.trace ()) cerr << "typedef wstring<" << ">" << endl; + if (ctx.trace ()) cerr << "typedef b-wstring" << endl; - define_ = false; // this should actually be true + define_ = true; + type_ = 0; + array_type_ = 0; - Name name ("::wstring"); - ScopedName from (ctx.scope ().scoped_name ()); + type_ = &ctx.tu ().new_node<BoundedWideString> (); + bound (); + } - type_ = &resolve<Type> (from, name); + void Typedef:: + begin_array () + { + if (ctx.trace ()) cerr << "array" << endl; + + define_ = true; + array_type_ = 0; + + if (type_ == 0) + return; + + if (type_->named_begin () == type_->named_end ()) + { + cerr << "error: anonymous types in array declarations " + << "are not supported" << endl; + + cerr << "use another typedef to name this type" << endl; + + return; + } + + Array& a (ctx.tu ().new_node<Array> ()); + ctx.tu ().new_edge<ArgumentsWithType> (*type_, a); + + array_type_ = &a; + } + + void Typedef:: + bound () + { + if (ctx.trace ()) cerr << "bound" << endl; + + if (ctx.int_exp_size () < 1) + return; + + IntExpression& expr (ctx.int_exp_pop ()); + + if (array_type_ != 0) + { + Specialization& s (dynamic_cast<Specialization&> (*array_type_)); + ctx.tu ().new_edge<ArgumentsWithValue> (expr, s); + } + else if (type_ != 0) + { + Specialization& s (dynamic_cast<Specialization&> (*type_)); + ctx.tu ().new_edge<ArgumentsWithValue> (expr, s); + } } void Typedef:: @@ -149,7 +247,16 @@ namespace CCF { if (lookup (ctx.tu (), ctx.scope (), name) == 0) { - if (type_ != 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_) { @@ -170,6 +277,8 @@ namespace CCF cerr << "error: invalid typedef declaration" << endl; cerr << "error: redeclaration of name " << name << endl; + + array_type_ = 0; } void Typedef:: |