From e5f7ae0a1020a42c7ac28d7767917b59e478a83f Mon Sep 17 00:00:00 2001 From: parsons Date: Fri, 28 Aug 2009 20:36:25 +0000 Subject: ChangeLogTag: Fri Aug 28 20:30:52 UTC 2009 Jeff Parsons --- modules/TAO/ChangeLog | 22 +++++++++++-- modules/TAO/TAO_IDL/ast/ast_field.cpp | 2 +- modules/TAO/TAO_IDL/ast/ast_generator.cpp | 11 +++++++ modules/TAO/TAO_IDL/ast/ast_template_common.cpp | 19 ++++++++++++ modules/TAO/TAO_IDL/be/be_generator.cpp | 11 +++++++ modules/TAO/TAO_IDL/be_include/be_generator.h | 3 ++ modules/TAO/TAO_IDL/fe/idl.yy | 38 +++++++++++++++++++++-- modules/TAO/TAO_IDL/fe/y.tab.cpp | 38 +++++++++++++++++++++-- modules/TAO/TAO_IDL/include/ast_argument.h | 4 +-- modules/TAO/TAO_IDL/include/ast_field.h | 3 +- modules/TAO/TAO_IDL/include/ast_generator.h | 3 ++ modules/TAO/TAO_IDL/include/ast_template_common.h | 3 ++ 12 files changed, 143 insertions(+), 14 deletions(-) diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog index 02fb275de51..5d3b84aa3ce 100644 --- a/modules/TAO/ChangeLog +++ b/modules/TAO/ChangeLog @@ -1,11 +1,29 @@ +Fri Aug 28 20:30:52 UTC 2009 Jeff Parsons + + * TAO_IDL/ast/ast_field.cpp: + * TAO_IDL/ast/ast_generator.cpp: + * TAO_IDL/ast/ast_template_common.cpp: + * TAO_IDL/be/be_generator.cpp: + * TAO_IDL/be_include/be_generator.h: + * TAO_IDL/fe/idl.yy: + * TAO_IDL/fe/y.tab.cpp: + * TAO_IDL/include/ast_argument.h: + * TAO_IDL/include/ast_field.h: + * TAO_IDL/include/ast_generator.h: + * TAO_IDL/include/ast_template_common.h: + + Added semantic action for an operation parameter type + that is a reference to one of its containing template + interface's template parameters. + Fri Aug 28 16:03:30 UTC 2009 Jeff Parsons * TAO_IDL/ast/ast_decl.cpp: - * TAO_IDL/fe/idl.yy: * TAO_IDL/fe/y.tab.cpp: - * TAO_IDL/include/ast_decl.h: + + Reverted changes to these files in the entry below. Thu Aug 27 16:23:53 UTC 2009 Jeff Parsons diff --git a/modules/TAO/TAO_IDL/ast/ast_field.cpp b/modules/TAO/TAO_IDL/ast/ast_field.cpp index bcdd73b68d1..3bfa64cfede 100644 --- a/modules/TAO/TAO_IDL/ast/ast_field.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_field.cpp @@ -186,7 +186,7 @@ AST_Field::field_type (void) const } AST_Field::Visibility -AST_Field::visibility (void) +AST_Field::visibility (void) const { return this->visibility_; } diff --git a/modules/TAO/TAO_IDL/ast/ast_generator.cpp b/modules/TAO/TAO_IDL/ast/ast_generator.cpp index 57ff5e36610..0a1f2f1f01b 100644 --- a/modules/TAO/TAO_IDL/ast/ast_generator.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_generator.cpp @@ -1123,3 +1123,14 @@ AST_Generator::create_instantiated_connector ( return retval; } +AST_Type * +AST_Generator::create_placeholder (UTL_ScopedName *n) +{ + AST_Type *retval = 0; + ACE_NEW_RETURN (retval, + AST_Type (AST_Decl::NT_type, n), + 0); + + return retval; +} + diff --git a/modules/TAO/TAO_IDL/ast/ast_template_common.cpp b/modules/TAO/TAO_IDL/ast/ast_template_common.cpp index 77998dffd59..cdbd626fe49 100644 --- a/modules/TAO/TAO_IDL/ast/ast_template_common.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_template_common.cpp @@ -140,6 +140,25 @@ AST_Template_Common::match_params (UTL_StrList *param_names) return true; } +bool +AST_Template_Common::find_param (const char *name) +{ + for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*this->template_params_); + !i.done (); + i.advance ()) + { + FE_Utils::T_Param_Info *item = 0; + i.next (item); + + if (item->name_ == name) + { + return true; + } + } + + return false; +} + bool AST_Template_Common::match_param_type (AST_Decl::NodeType my_type, AST_Decl *d) diff --git a/modules/TAO/TAO_IDL/be/be_generator.cpp b/modules/TAO/TAO_IDL/be/be_generator.cpp index 73bbb856754..f79e352c88a 100644 --- a/modules/TAO/TAO_IDL/be/be_generator.cpp +++ b/modules/TAO/TAO_IDL/be/be_generator.cpp @@ -1116,4 +1116,15 @@ be_generator::create_instantiated_connector ( return retval; } +AST_Type * +be_generator::create_placeholder (UTL_ScopedName *n) +{ + be_type *retval = 0; + ACE_NEW_RETURN (retval, + be_type (AST_Decl::NT_type, n), + 0); + + return retval; +} + diff --git a/modules/TAO/TAO_IDL/be_include/be_generator.h b/modules/TAO/TAO_IDL/be_include/be_generator.h index 73f05189e88..f3a7879f628 100644 --- a/modules/TAO/TAO_IDL/be_include/be_generator.h +++ b/modules/TAO/TAO_IDL/be_include/be_generator.h @@ -332,6 +332,9 @@ public: UTL_ScopedName *n, AST_Connector *connector_type, AST_Template_Common::T_ARGLIST *template_args); + + virtual + AST_Type *create_placeholder (UTL_ScopedName *n); }; #endif // _BE_GENERATOR_BE_GENERATOR_HH diff --git a/modules/TAO/TAO_IDL/fe/idl.yy b/modules/TAO/TAO_IDL/fe/idl.yy index 2eb0f82f693..2bcb9bafab2 100644 --- a/modules/TAO/TAO_IDL/fe/idl.yy +++ b/modules/TAO/TAO_IDL/fe/idl.yy @@ -4284,16 +4284,48 @@ param_type_spec // | scoped_name UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; + UTL_ScopedName *n = $1; if (s != 0) { - d = s->lookup_by_name ($1, - true); + d = s->lookup_by_name (n, true); } if (d == 0) { - idl_global->err ()->lookup_error ($1); + bool so_far_so_good = false; + + // We're looking for a template parameter ref, so + // the scoped name would just be a simple identifier. + if (n->length () == 1) + { + AST_Template_Interface *ti = + AST_Template_Interface::narrow_from_scope ( + ScopeAsDecl (s)->defined_in ()); + + if (ti != 0) + { + so_far_so_good = + ti->find_param (n->head ()->get_string ()); + + if (so_far_so_good) + { + d = + idl_global->gen ()->create_placeholder (n); + s->add_to_scope (d); + } + } + } + + if (!so_far_so_good) + { + idl_global->err ()->lookup_error (n); + $1->destroy (); + $1 = 0; + + /* If we don't return here, we'll crash later.*/ + return 1; + } } else { diff --git a/modules/TAO/TAO_IDL/fe/y.tab.cpp b/modules/TAO/TAO_IDL/fe/y.tab.cpp index a6d4674ae79..b59de9358e8 100644 --- a/modules/TAO/TAO_IDL/fe/y.tab.cpp +++ b/modules/TAO/TAO_IDL/fe/y.tab.cpp @@ -6950,16 +6950,48 @@ tao_yyreduce: // | scoped_name UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; + UTL_ScopedName *n = (tao_yyvsp[(1) - (1)].idlist); if (s != 0) { - d = s->lookup_by_name ((tao_yyvsp[(1) - (1)].idlist), - true); + d = s->lookup_by_name (n, true); } if (d == 0) { - idl_global->err ()->lookup_error ((tao_yyvsp[(1) - (1)].idlist)); + bool so_far_so_good = false; + + // We're looking for a template parameter ref, so + // the scoped name would just be a simple identifier. + if (n->length () == 1) + { + AST_Template_Interface *ti = + AST_Template_Interface::narrow_from_scope ( + ScopeAsDecl (s)->defined_in ()); + + if (ti != 0) + { + so_far_so_good = + ti->find_param (n->head ()->get_string ()); + + if (so_far_so_good) + { + d = + idl_global->gen ()->create_placeholder (n); + s->add_to_scope (d); + } + } + } + + if (!so_far_so_good) + { + idl_global->err ()->lookup_error (n); + (tao_yyvsp[(1) - (1)].idlist)->destroy (); + (tao_yyvsp[(1) - (1)].idlist) = 0; + + /* If we don't return here, we'll crash later.*/ + return 1; + } } else { diff --git a/modules/TAO/TAO_IDL/include/ast_argument.h b/modules/TAO/TAO_IDL/include/ast_argument.h index cefeaff42d4..abbf34a0a7b 100644 --- a/modules/TAO/TAO_IDL/include/ast_argument.h +++ b/modules/TAO/TAO_IDL/include/ast_argument.h @@ -113,10 +113,8 @@ public: virtual void destroy (void); private: - // Data. - const Direction pd_direction; - // Argument direction + // Argument direction. }; #endif // _AST_ARGUMENT_AST_ARGUMENT_HH diff --git a/modules/TAO/TAO_IDL/include/ast_field.h b/modules/TAO/TAO_IDL/include/ast_field.h index e03487c0699..25c8155121c 100644 --- a/modules/TAO/TAO_IDL/include/ast_field.h +++ b/modules/TAO/TAO_IDL/include/ast_field.h @@ -109,8 +109,7 @@ public: // Data Accessors. AST_Type *field_type (void) const; - - Visibility visibility (void); + Visibility visibility (void) const; // Are we or do we contain a wstring? virtual int contains_wstring (void); diff --git a/modules/TAO/TAO_IDL/include/ast_generator.h b/modules/TAO/TAO_IDL/include/ast_generator.h index b215eac204b..88d2a6b040a 100644 --- a/modules/TAO/TAO_IDL/include/ast_generator.h +++ b/modules/TAO/TAO_IDL/include/ast_generator.h @@ -422,6 +422,9 @@ public: UTL_ScopedName *n, AST_Connector *connector_type, AST_Template_Common::T_ARGLIST *template_args); + + virtual + AST_Type *create_placeholder (UTL_ScopedName *n); }; #endif // _AST_GENERATOR_AST_GENERATOR_HH diff --git a/modules/TAO/TAO_IDL/include/ast_template_common.h b/modules/TAO/TAO_IDL/include/ast_template_common.h index 7ee122538ae..a7806c78f6b 100644 --- a/modules/TAO/TAO_IDL/include/ast_template_common.h +++ b/modules/TAO/TAO_IDL/include/ast_template_common.h @@ -26,6 +26,9 @@ public: // Called by porttype references in connectors. bool match_params (UTL_StrList *param_names); + // Called when parsing a template interface operation. + bool find_param (const char *name); + protected: AST_Template_Common (AST_Decl::NodeType nt, UTL_ScopedName *n, -- cgit v1.2.1