diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-04 19:23:56 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-04 19:23:56 +0000 |
commit | 13b57fee80ac1a2b0a44b899799370af9799f7d6 (patch) | |
tree | 69347e5e80e4aaed183656b5211647452998b8bc | |
parent | 21812bcc63b961373af1e9f0ed505980b1e8cf09 (diff) | |
download | ATCD-13b57fee80ac1a2b0a44b899799370af9799f7d6.tar.gz |
ChangeLogTag: Fri Dec 4 19:23:17 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r-- | modules/TAO/ChangeLog | 24 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/ast/ast_expression.cpp | 6 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/ast/ast_generator.cpp | 6 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/ast/ast_param_holder.cpp | 12 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/ast/ast_sequence.cpp | 26 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/be/be_generator.cpp | 6 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/be/be_param_holder.cpp | 6 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/be_include/be_generator.h | 3 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/be_include/be_param_holder.h | 3 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/fe_declarator.cpp | 21 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/idl.yy | 56 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/y.tab.cpp | 71 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/include/ast_expression.h | 5 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/include/ast_generator.h | 3 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/include/ast_param_holder.h | 10 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/util/utl_err.cpp | 2 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/util/utl_scope.cpp | 2 |
17 files changed, 196 insertions, 66 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog index 16acc0568f2..3c4958f60f2 100644 --- a/modules/TAO/ChangeLog +++ b/modules/TAO/ChangeLog @@ -1,3 +1,27 @@ +Fri Dec 4 19:23:17 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/include/ast_generator.h: + * TAO_IDL/include/ast_param_holder.h: + * TAO_IDL/include/ast_expression.h: + * TAO_IDL/be/be_param_holder.cpp: + * TAO_IDL/be/be_generator.cpp: + * TAO_IDL/ast/ast_expression.cpp: + * TAO_IDL/ast/ast_sequence.cpp: + * TAO_IDL/ast/ast_generator.cpp: + * TAO_IDL/ast/ast_param_holder.cpp: + * TAO_IDL/be_include/be_param_holder.h: + * TAO_IDL/be_include/be_generator.h: + * TAO_IDL/fe/y.tab.cpp: + * TAO_IDL/fe/idl.yy: + * TAO_IDL/fe/fe_declarator.cpp: + * TAO_IDL/util/utl_err.cpp: + * TAO_IDL/util/utl_scope.cpp: + + Support for template parameter as sequence + bound, and additional error checking for + template parameter as const type, sequence + type and sequence bound. + Thu Dec 3 20:39:05 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/include/ast_expression.h: diff --git a/modules/TAO/TAO_IDL/ast/ast_expression.cpp b/modules/TAO/TAO_IDL/ast/ast_expression.cpp index 310213152c1..1bcf63a87a6 100644 --- a/modules/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_expression.cpp @@ -3005,10 +3005,10 @@ AST_Expression::get_tdef (void) const return this->tdef; } -bool -AST_Expression::is_param_holder (void) const +AST_Param_Holder * +AST_Expression::param_holder (void) const { - return (this->param_holder_ != 0); + return this->param_holder_; } // Helper functions for expression dumpers. diff --git a/modules/TAO/TAO_IDL/ast/ast_generator.cpp b/modules/TAO/TAO_IDL/ast/ast_generator.cpp index caad32c22a6..6aef739eea0 100644 --- a/modules/TAO/TAO_IDL/ast/ast_generator.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_generator.cpp @@ -1098,11 +1098,13 @@ AST_Generator::create_template_module_ref ( AST_Param_Holder * AST_Generator::create_param_holder ( - UTL_ScopedName *parameter_name) + UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info) { AST_Param_Holder *retval = 0; ACE_NEW_RETURN (retval, - AST_Param_Holder (parameter_name), + AST_Param_Holder (parameter_name, + info), 0); return retval; diff --git a/modules/TAO/TAO_IDL/ast/ast_param_holder.cpp b/modules/TAO/TAO_IDL/ast/ast_param_holder.cpp index b6a33a744b2..2d06d074bea 100644 --- a/modules/TAO/TAO_IDL/ast/ast_param_holder.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_param_holder.cpp @@ -4,13 +4,15 @@ #include "utl_identifier.h" -AST_Param_Holder::AST_Param_Holder (UTL_ScopedName *parameter_name) +AST_Param_Holder::AST_Param_Holder (UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info) : COMMON_Base (false, false), AST_Decl (AST_Decl::NT_param_holder, parameter_name), AST_Type (AST_Decl::NT_param_holder, - parameter_name) + parameter_name), + info_ (info) { } @@ -18,6 +20,12 @@ AST_Param_Holder::~AST_Param_Holder (void) { } +FE_Utils::T_Param_Info const * +AST_Param_Holder::info (void) const +{ + return this->info_; +} + void AST_Param_Holder::destroy (void) { diff --git a/modules/TAO/TAO_IDL/ast/ast_sequence.cpp b/modules/TAO/TAO_IDL/ast/ast_sequence.cpp index bbe2a9276e3..6b9980d8bdb 100644 --- a/modules/TAO/TAO_IDL/ast/ast_sequence.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_sequence.cpp @@ -116,14 +116,18 @@ AST_Sequence::AST_Sequence (AST_Expression *ms, owns_base_type_ (false) { // Check if we are bounded or unbounded. An expression value of 0 means - // unbounded. - if (ms->ev ()->u.ulval == 0) + // unbounded. If our bound is a template parameter, skip the + // check altogether, this node will trigger no code generation. + if (ms->param_holder () == 0) { - this->unbounded_ = true; - } - else - { - this->unbounded_ = false; + if (ms->ev ()->u.ulval == 0) + { + this->unbounded_ = true; + } + else + { + this->unbounded_ = false; + } } // A sequence data type is always VARIABLE. @@ -131,10 +135,10 @@ AST_Sequence::AST_Sequence (AST_Expression *ms, AST_Decl::NodeType nt = bt->node_type (); - if (AST_Decl::NT_array == nt || AST_Decl::NT_sequence == nt) - { - this->owns_base_type_ = true; - } + this->owns_base_type_ = + nt == AST_Decl::NT_array + || nt == AST_Decl::NT_sequence + || nt == AST_Decl::NT_param_holder; } AST_Sequence::~AST_Sequence (void) diff --git a/modules/TAO/TAO_IDL/be/be_generator.cpp b/modules/TAO/TAO_IDL/be/be_generator.cpp index cae66a0381f..0438c321252 100644 --- a/modules/TAO/TAO_IDL/be/be_generator.cpp +++ b/modules/TAO/TAO_IDL/be/be_generator.cpp @@ -1091,11 +1091,13 @@ be_generator::create_template_module_ref ( AST_Param_Holder * be_generator::create_param_holder ( - UTL_ScopedName *parameter_name) + UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info) { be_param_holder *retval = 0; ACE_NEW_RETURN (retval, - be_param_holder (parameter_name), + be_param_holder (parameter_name, + info), 0); return retval; diff --git a/modules/TAO/TAO_IDL/be/be_param_holder.cpp b/modules/TAO/TAO_IDL/be/be_param_holder.cpp index b6c064456c6..7f097ad7225 100644 --- a/modules/TAO/TAO_IDL/be/be_param_holder.cpp +++ b/modules/TAO/TAO_IDL/be/be_param_holder.cpp @@ -19,14 +19,16 @@ #include "be_param_holder.h" -be_param_holder::be_param_holder (UTL_ScopedName *parameter_name) +be_param_holder::be_param_holder (UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info) : COMMON_Base (false, false), AST_Decl (AST_Decl::NT_param_holder, parameter_name), AST_Type (AST_Decl::NT_param_holder, parameter_name), - AST_Param_Holder (parameter_name), + AST_Param_Holder (parameter_name, + info), be_decl (AST_Decl::NT_param_holder, parameter_name), be_type (AST_Decl::NT_param_holder, diff --git a/modules/TAO/TAO_IDL/be_include/be_generator.h b/modules/TAO/TAO_IDL/be_include/be_generator.h index 49d876e0c8f..d1a8ed4d67a 100644 --- a/modules/TAO/TAO_IDL/be_include/be_generator.h +++ b/modules/TAO/TAO_IDL/be_include/be_generator.h @@ -322,7 +322,8 @@ public: virtual AST_Param_Holder *create_param_holder ( - UTL_ScopedName *parameter_name); + UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info); }; #endif // _BE_GENERATOR_BE_GENERATOR_HH diff --git a/modules/TAO/TAO_IDL/be_include/be_param_holder.h b/modules/TAO/TAO_IDL/be_include/be_param_holder.h index 498e502b890..3090f00a347 100644 --- a/modules/TAO/TAO_IDL/be_include/be_param_holder.h +++ b/modules/TAO/TAO_IDL/be_include/be_param_holder.h @@ -29,7 +29,8 @@ class be_param_holder : public virtual AST_Param_Holder, public virtual be_type { public: - be_param_holder (UTL_ScopedName *parameter_name); + be_param_holder (UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info); virtual ~be_param_holder (void); diff --git a/modules/TAO/TAO_IDL/fe/fe_declarator.cpp b/modules/TAO/TAO_IDL/fe/fe_declarator.cpp index 10b6bbf2b2d..324f2dd4628 100644 --- a/modules/TAO/TAO_IDL/fe/fe_declarator.cpp +++ b/modules/TAO/TAO_IDL/fe/fe_declarator.cpp @@ -65,16 +65,15 @@ trademarks or registered trademarks of Sun Microsystems, Inc. */ #include "fe_declarator.h" + #include "ast_array.h" -#include "ast_type.h" +#include "ast_param_holder.h" + #include "utl_err.h" #include "global_extern.h" #include "nr_extern.h" -#include "ace/config-all.h" -ACE_RCSID (fe, - fe_declarator, - "$Id$") +#include "ace/config-all.h" FE_Declarator::FE_Declarator (UTL_ScopedName *n, DeclaratorType dt, @@ -97,6 +96,18 @@ FE_Declarator::compose (AST_Decl *d) idl_global->err ()->not_a_type (d); return 0; } + else if (ct->node_type () == AST_Decl::NT_param_holder) + { + AST_Param_Holder *ph = + AST_Param_Holder::narrow_from_decl (ct); + + // Every other template parameter kind is legal. + if (ph->info ()->type_ == AST_Decl::NT_const) + { + idl_global->err ()->not_a_type (d); + return 0; + } + } AST_Decl::NodeType nt = d->node_type (); diff --git a/modules/TAO/TAO_IDL/fe/idl.yy b/modules/TAO/TAO_IDL/fe/idl.yy index b2b66574b04..7810ba4214d 100644 --- a/modules/TAO/TAO_IDL/fe/idl.yy +++ b/modules/TAO/TAO_IDL/fe/idl.yy @@ -90,7 +90,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_component.h" #include "ast_component_fwd.h" #include "ast_home.h" -#include "ast_template_interface.h" #include "ast_porttype.h" #include "ast_connector.h" #include "ast_uses.h" @@ -105,6 +104,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_string.h" #include "ast_factory.h" #include "ast_exception.h" +#include "ast_param_holder.h" + #include "fe_declarator.h" #include "fe_interface_header.h" #include "fe_template_interface_header.h" @@ -113,6 +114,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "fe_component_header.h" #include "fe_home_header.h" #include "fe_utils.h" + #include "utl_identifier.h" #include "utl_err.h" #include "utl_string.h" @@ -121,6 +123,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "utl_exprlist.h" #include "utl_labellist.h" #include "utl_decllist.h" + #include "global_extern.h" #include "nr_extern.h" @@ -1760,8 +1763,8 @@ const_dcl : */ if ($9 != 0 && s != 0) { - bool param_holder = - $9->is_param_holder (); + AST_Param_Holder *param_holder = + $9->param_holder (); AST_Expression::AST_ExprValue *result = $9->check_and_coerce ($3, @@ -1770,7 +1773,7 @@ const_dcl : // If the expression is a template parameter place // holder, 'result' will be 0, but it's ok. - if (result == 0 && ! param_holder) + if (result == 0 && param_holder == 0) { idl_global->err ()->coercion_error ($9, $3); @@ -1780,20 +1783,33 @@ const_dcl : } else { - c = - idl_global->gen ()->create_constant ( - $3, - $9, - &n - ); - (void) s->fe_add_constant (c); - delete result; - result = 0; + AST_Expression::ExprType et = + $3; + + if (param_holder != 0 + && et != param_holder->info ()->const_type_) + { + idl_global->err ()->mismatched_template_param ( + param_holder->info ()->name_.c_str ()); + } + else + { + c = + idl_global->gen ()->create_constant ( + $3, + $9, + &n); + + (void) s->fe_add_constant (c); + } } $5->destroy (); delete $5; $5 = 0; + + delete result; + result = 0; } } ; @@ -3509,21 +3525,29 @@ sequence_type_spec * Create a node representing a sequence */ AST_Expression::AST_ExprValue *ev = 0; + AST_Param_Holder *param_holder = 0; if ($4 != 0) { + param_holder = + $4->param_holder (); + ev = $4->coerce (AST_Expression::EV_ulong); } - if (0 == $4 || 0 == ev) + // If the expression corresponds to a template parameter, + // it's ok for the coercion to fail at this point. We check + // for a type mismatch below. + if (0 == $4 + || (0 == ev && 0 == param_holder)) { idl_global->err ()->coercion_error ($4, AST_Expression::EV_ulong); - $$ = 0; + $<dcval>$ = 0; } else if (0 == $1) { - $$ = 0; + $<dcval>$ = 0; } else { diff --git a/modules/TAO/TAO_IDL/fe/y.tab.cpp b/modules/TAO/TAO_IDL/fe/y.tab.cpp index 81485e71f83..417f99f80ed 100644 --- a/modules/TAO/TAO_IDL/fe/y.tab.cpp +++ b/modules/TAO/TAO_IDL/fe/y.tab.cpp @@ -260,7 +260,6 @@ #include "ast_component.h" #include "ast_component_fwd.h" #include "ast_home.h" -#include "ast_template_interface.h" #include "ast_porttype.h" #include "ast_connector.h" #include "ast_uses.h" @@ -275,6 +274,8 @@ #include "ast_string.h" #include "ast_factory.h" #include "ast_exception.h" +#include "ast_param_holder.h" + #include "fe_declarator.h" #include "fe_interface_header.h" #include "fe_template_interface_header.h" @@ -283,6 +284,7 @@ #include "fe_component_header.h" #include "fe_home_header.h" #include "fe_utils.h" + #include "utl_identifier.h" #include "utl_err.h" #include "utl_string.h" @@ -291,6 +293,7 @@ #include "utl_exprlist.h" #include "utl_labellist.h" #include "utl_decllist.h" + #include "global_extern.h" #include "nr_extern.h" @@ -4201,8 +4204,8 @@ tao_yyreduce: */ if ((tao_yyvsp[(9) - (9)].exval) != 0 && s != 0) { - bool param_holder = - (tao_yyvsp[(9) - (9)].exval)->is_param_holder (); + AST_Param_Holder *param_holder = + (tao_yyvsp[(9) - (9)].exval)->param_holder (); AST_Expression::AST_ExprValue *result = (tao_yyvsp[(9) - (9)].exval)->check_and_coerce ((tao_yyvsp[(3) - (9)].etval), @@ -4211,7 +4214,7 @@ tao_yyreduce: // If the expression is a template parameter place // holder, 'result' will be 0, but it's ok. - if (result == 0 && ! param_holder) + if (result == 0 && param_holder == 0) { idl_global->err ()->coercion_error ((tao_yyvsp[(9) - (9)].exval), (tao_yyvsp[(3) - (9)].etval)); @@ -4221,20 +4224,33 @@ tao_yyreduce: } else { - c = - idl_global->gen ()->create_constant ( - (tao_yyvsp[(3) - (9)].etval), - (tao_yyvsp[(9) - (9)].exval), - &n - ); - (void) s->fe_add_constant (c); - delete result; - result = 0; + AST_Expression::ExprType et = + (tao_yyvsp[(3) - (9)].etval); + + if (param_holder != 0 + && et != param_holder->info ()->const_type_) + { + idl_global->err ()->mismatched_template_param ( + param_holder->info ()->name_.c_str ()); + } + else + { + c = + idl_global->gen ()->create_constant ( + (tao_yyvsp[(3) - (9)].etval), + (tao_yyvsp[(9) - (9)].exval), + &n); + + (void) s->fe_add_constant (c); + } } (tao_yyvsp[(5) - (9)].idval)->destroy (); delete (tao_yyvsp[(5) - (9)].idval); (tao_yyvsp[(5) - (9)].idval) = 0; + + delete result; + result = 0; } } break; @@ -6078,13 +6094,21 @@ tao_yyreduce: * Create a node representing a sequence */ AST_Expression::AST_ExprValue *ev = 0; + AST_Param_Holder *param_holder = 0; if ((tao_yyvsp[(4) - (6)].exval) != 0) { + param_holder = + (tao_yyvsp[(4) - (6)].exval)->param_holder (); + ev = (tao_yyvsp[(4) - (6)].exval)->coerce (AST_Expression::EV_ulong); } - if (0 == (tao_yyvsp[(4) - (6)].exval) || 0 == ev) + // If the expression corresponds to a template parameter, + // it's ok for the coercion to fail at this point. We check + // for a type mismatch below. + if (0 == (tao_yyvsp[(4) - (6)].exval) + || (0 == ev && 0 == param_holder)) { idl_global->err ()->coercion_error ((tao_yyvsp[(4) - (6)].exval), AST_Expression::EV_ulong); @@ -6104,6 +6128,25 @@ tao_yyreduce: } else { + if (param_holder != 0) + { + AST_Expression::ExprType et = + param_holder->info ()->const_type_; + + // If the bound expression represents a + // template parameter, it must be a const + // and of type unsigned long. + if (et != AST_Expression::EV_ulong) + { + idl_global->err ()->mismatched_template_param ( + param_holder->info ()->name_.c_str ()); + + delete ev; + ev = 0; + return 1; + } + } + Identifier id ("sequence"); UTL_ScopedName sn (&id, 0); diff --git a/modules/TAO/TAO_IDL/include/ast_expression.h b/modules/TAO/TAO_IDL/include/ast_expression.h index 8ae76e608ce..b3cc116b91e 100644 --- a/modules/TAO/TAO_IDL/include/ast_expression.h +++ b/modules/TAO/TAO_IDL/include/ast_expression.h @@ -285,9 +285,8 @@ public: // Accessor for the member. AST_Decl *get_tdef (void) const; - // We don't need to access this member, just determine if is - // 0 or not. - bool is_param_holder (void) const; + // Accessor for the member. + AST_Param_Holder *param_holder (void) const; protected: // Evaluate different sets of operators. diff --git a/modules/TAO/TAO_IDL/include/ast_generator.h b/modules/TAO/TAO_IDL/include/ast_generator.h index ca75187fba1..1bb293db967 100644 --- a/modules/TAO/TAO_IDL/include/ast_generator.h +++ b/modules/TAO/TAO_IDL/include/ast_generator.h @@ -412,7 +412,8 @@ public: virtual AST_Param_Holder *create_param_holder ( - UTL_ScopedName *parameter_name); + UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info); }; #endif // _AST_GENERATOR_AST_GENERATOR_HH diff --git a/modules/TAO/TAO_IDL/include/ast_param_holder.h b/modules/TAO/TAO_IDL/include/ast_param_holder.h index 81eaa744d49..bdf06c7580f 100644 --- a/modules/TAO/TAO_IDL/include/ast_param_holder.h +++ b/modules/TAO/TAO_IDL/include/ast_param_holder.h @@ -6,13 +6,18 @@ #include "ast_type.h" +#include "fe_utils.h" + class TAO_IDL_FE_Export AST_Param_Holder : public virtual AST_Type { public: - AST_Param_Holder (UTL_ScopedName *parameter_name); + AST_Param_Holder (UTL_ScopedName *parameter_name, + FE_Utils::T_Param_Info *info); virtual ~AST_Param_Holder (void); + + FE_Utils::T_Param_Info const *info (void) const; // Narrowing. DEF_NARROW_FROM_DECL (AST_Param_Holder); @@ -25,6 +30,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + +private: + FE_Utils::T_Param_Info *info_; }; #endif // AST_PARAM_HOLDER_H
\ No newline at end of file diff --git a/modules/TAO/TAO_IDL/util/utl_err.cpp b/modules/TAO/TAO_IDL/util/utl_err.cpp index 9ef9e756557..343b32c0f56 100644 --- a/modules/TAO/TAO_IDL/util/utl_err.cpp +++ b/modules/TAO/TAO_IDL/util/utl_err.cpp @@ -224,7 +224,7 @@ error_string (UTL_Error::ErrorCode c) case UTL_Error::EIDL_ILLEGAL_PRIMARY_KEY: return "illegal primary key"; case UTL_Error::EIDL_MISMATCHED_T_PARAM: - return "mismatched parameter in template reference or instantiation"; + return "mismatched template parameter"; case UTL_Error::EIDL_DUPLICATE_T_PARAM: return "duplicate template parameter id"; case UTL_Error::EIDL_T_ARG_LENGTH: diff --git a/modules/TAO/TAO_IDL/util/utl_scope.cpp b/modules/TAO/TAO_IDL/util/utl_scope.cpp index 3deeb6c9d4a..c4d438facb2 100644 --- a/modules/TAO/TAO_IDL/util/utl_scope.cpp +++ b/modules/TAO/TAO_IDL/util/utl_scope.cpp @@ -594,7 +594,7 @@ UTL_Scope::match_param ( if (param->name_ == name) { retval = - idl_global->gen ()->create_param_holder (e); + idl_global->gen ()->create_param_holder (e, param); break; } |