diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2010-01-28 07:57:56 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2010-01-28 07:57:56 +0000 |
commit | 6760510bc53d7b9947fd75cad78a2798457035d9 (patch) | |
tree | f589e292ae52efb294d8bc7530cd1cb3c0ed8426 /TAO | |
parent | f9c1b9f189fdfec0ea53d6e41a2e57d04e2282d6 (diff) | |
download | ATCD-6760510bc53d7b9947fd75cad78a2798457035d9.tar.gz |
Thu Jan 28 07:54:30 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl>
Merged revision 88742-88757 from idl3_plus_backend2 to svn head. This
gives us templated modules for the small parts we need for dds4ccm
Wed Jan 27 22:19:17 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
* TAO_IDL/be/be_decl.cpp:
* TAO_IDL/be/be_visitor_component/facet_exs.cpp:
* TAO_IDL/be/be_visitor_component/facet_exh.cpp:
* TAO_IDL/be_include/be_decl.h:
Added check to ensure that a facet interface gets generated
only once in the executor header and source files. This fix
closes [BUGID:3817]. Thanks to Abdul Sowayan <sowayan@gmail.com>
for reporting the bug.
* TAO_IDL/fe/y.tab.cpp:
* TAO_IDL/fe/idl.yy:
Cosmetic changes.
Wed Jan 27 20:08:48 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
* TAO_IDL/include/ast_union.h:
* TAO_IDL/include/ast_visitor_tmpl_module_inst.h:
* TAO_IDL/include/utl_labellist.h:
* TAO_IDL/include/ast_union_branch.h:
* TAO_IDL/include/utl_scope.h:
* TAO_IDL/be/be_union_label.cpp:
* TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp:
* TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp:
* TAO_IDL/ast/ast_visitor_reifying.cpp:
* TAO_IDL/ast/ast_enum.cpp:
* TAO_IDL/ast/ast_union_branch.cpp:
* TAO_IDL/util/utl_labellist.cpp:
* TAO_IDL/util/utl_exceptlist.cpp:
* TAO_IDL/util/utl_idlist.cpp:
* TAO_IDL/util/utl_scope.cpp:
Added support for unions and enums in the scope of a
template module.
Diffstat (limited to 'TAO')
22 files changed, 414 insertions, 164 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index bd0a08efdfc..744a53384ca 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,46 @@ +Thu Jan 28 07:54:30 UTC 2010 Johnny Willemsen <jwillemsen@remedy.nl> + + Merged revision 88742-88757 from idl3_plus_backend2 to svn head. This + gives us templated modules for the small parts we need for dds4ccm + + Wed Jan 27 22:19:17 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/be/be_decl.cpp: + * TAO_IDL/be/be_visitor_component/facet_exs.cpp: + * TAO_IDL/be/be_visitor_component/facet_exh.cpp: + * TAO_IDL/be_include/be_decl.h: + + Added check to ensure that a facet interface gets generated + only once in the executor header and source files. This fix + closes [BUGID:3817]. Thanks to Abdul Sowayan <sowayan@gmail.com> + for reporting the bug. + + * TAO_IDL/fe/y.tab.cpp: + * TAO_IDL/fe/idl.yy: + + Cosmetic changes. + + Wed Jan 27 20:08:48 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/include/ast_union.h: + * TAO_IDL/include/ast_visitor_tmpl_module_inst.h: + * TAO_IDL/include/utl_labellist.h: + * TAO_IDL/include/ast_union_branch.h: + * TAO_IDL/include/utl_scope.h: + * TAO_IDL/be/be_union_label.cpp: + * TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp: + * TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp: + * TAO_IDL/ast/ast_visitor_reifying.cpp: + * TAO_IDL/ast/ast_enum.cpp: + * TAO_IDL/ast/ast_union_branch.cpp: + * TAO_IDL/util/utl_labellist.cpp: + * TAO_IDL/util/utl_exceptlist.cpp: + * TAO_IDL/util/utl_idlist.cpp: + * TAO_IDL/util/utl_scope.cpp: + + Added support for unions and enums in the scope of a + template module. + Wed Jan 27 22:55:24 UTC 2010 Adam Mitz <mitza@ociweb.com> * TAO_IDL/util/utl_global.cpp(add_dcps_data_type): diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 7acf84649da..679f2278f78 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -317,7 +317,10 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t) t->local_name ()); if (t1 == 0) - return 0; // Prevent dereferencing null pointer in nested calls. + { + // Prevent dereferencing null pointer in nested calls. + return 0; + } // Add it to enclosing scope. idl_global->scopes ().next_to_top ()->fe_add_enum_val (t1); diff --git a/TAO/TAO_IDL/ast/ast_union_branch.cpp b/TAO/TAO_IDL/ast/ast_union_branch.cpp index d62d2557e71..5203c4a023e 100644 --- a/TAO/TAO_IDL/ast/ast_union_branch.cpp +++ b/TAO/TAO_IDL/ast/ast_union_branch.cpp @@ -77,8 +77,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_visitor.h" #include "utl_labellist.h" -ACE_RCSID(ast, ast_union_branch, "$Id$") - AST_UnionBranch::AST_UnionBranch (void) : COMMON_Base (), AST_Decl (), @@ -139,7 +137,11 @@ AST_UnionBranch::destroy (void) this->AST_Field::destroy (); } -// Data accessors. +UTL_LabelList * +AST_UnionBranch::labels (void) const +{ + return this->pd_ll; +} AST_UnionLabel * AST_UnionBranch::label (unsigned long index) diff --git a/TAO/TAO_IDL/ast/ast_visitor_reifying.cpp b/TAO/TAO_IDL/ast/ast_visitor_reifying.cpp index 05db49591b2..b97f0cca10b 100644 --- a/TAO/TAO_IDL/ast/ast_visitor_reifying.cpp +++ b/TAO/TAO_IDL/ast/ast_visitor_reifying.cpp @@ -509,7 +509,7 @@ ast_visitor_reifying::visit_param_holder (AST_Param_Holder *node) FE_Utils::T_Param_Info *item = 0; iter.next (item); - if (item == node->info ()) + if (item->name_ == node->info ()->name_) { AST_Decl **ret_ptr = 0; diff --git a/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp b/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp index efea22610ec..849be641c71 100644 --- a/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp +++ b/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp @@ -33,6 +33,9 @@ #include "ast_typedef.h" #include "ast_constant.h" #include "ast_union.h" +#include "ast_union_branch.h" +#include "ast_enum.h" +#include "ast_enum_val.h" #include "ast_factory.h" #include "ast_param_holder.h" #include "ast_expression.h" @@ -42,6 +45,7 @@ #include "utl_namelist.h" #include "utl_identifier.h" #include "utl_exceptlist.h" +#include "utl_labellist.h" #include "fe_obv_header.h" #include "fe_home_header.h" @@ -49,10 +53,12 @@ #include "nr_extern.h" ast_visitor_tmpl_module_inst::ast_visitor_tmpl_module_inst ( - ast_visitor_context *ctx) + ast_visitor_context *ctx, + bool ref_only) : ast_visitor (), ctx_ (ctx), - for_eventtype_ (false) + for_eventtype_ (false), + ref_only_ (ref_only) { } @@ -515,14 +521,63 @@ ast_visitor_tmpl_module_inst::visit_expression (AST_Expression *) } int -ast_visitor_tmpl_module_inst::visit_enum (AST_Enum *) +ast_visitor_tmpl_module_inst::visit_enum (AST_Enum *node) { + UTL_ScopedName sn (node->local_name (), 0); + + AST_Enum *added_enum = + idl_global->gen ()->create_enum (&sn, + node->is_local (), + node->is_abstract ()); + + idl_global->scopes ().top ()->add_to_scope (added_enum); + + idl_global->scopes ().push (added_enum); + + if (this->visit_scope (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ast_visitor_tmpl_module_inst::") + ACE_TEXT ("visit_enum - ") + ACE_TEXT ("visit_scope failed\n")), + -1); + } + + idl_global->scopes ().pop (); + return 0; } int -ast_visitor_tmpl_module_inst::visit_union (AST_Union *) +ast_visitor_tmpl_module_inst::visit_union (AST_Union *node) { + UTL_ScopedName sn (node->local_name (), 0); + + AST_Union *added_union = + idl_global->gen ()->create_union (node->disc_type (), + &sn, + node->is_local (), + node->is_abstract ()); + + idl_global->scopes ().top ()->add_to_scope (added_union); + + // Update our scope stack. + idl_global->scopes ().push (added_union); + + if (this->visit_scope (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ast_visitor_tmpl_module_inst::") + ACE_TEXT ("visit_union - ") + ACE_TEXT ("visit_scope() failed\n")), + -1); + } + + // Through with this scope. + idl_global->scopes ().pop (); + + int dummy = added_union->member_count (); + return 0; } @@ -533,8 +588,28 @@ ast_visitor_tmpl_module_inst::visit_union_fwd (AST_UnionFwd *) } int -ast_visitor_tmpl_module_inst::visit_union_branch (AST_UnionBranch *) +ast_visitor_tmpl_module_inst::visit_union_branch (AST_UnionBranch *node) { + AST_Type *ft = + AST_Type::narrow_from_decl ( + this->reify_type (node->field_type ())); + + UTL_ScopedName sn (node->local_name (), 0); + + // The union branch owns its label list so we have to copy it. + UTL_LabelList *ll = node->labels ()->copy (); + + AST_UnionBranch *added_branch = + idl_global->gen ()->create_union_branch (ll, ft, &sn); + + // fe_add_union_branch() does necessary things besides calling + // add_to_scope() so we need to reuse it. + + AST_Union *u = + AST_Union::narrow_from_scope (idl_global->scopes ().top ()); + + u->fe_add_union_branch (added_branch); + return 0; } @@ -545,8 +620,17 @@ ast_visitor_tmpl_module_inst::visit_union_label (AST_UnionLabel *) } int -ast_visitor_tmpl_module_inst::visit_enum_val (AST_EnumVal *) +ast_visitor_tmpl_module_inst::visit_enum_val (AST_EnumVal *node) { + UTL_ScopedName sn (node->local_name (), 0); + + AST_EnumVal *added_enum_val = + idl_global->gen ()->create_enum_val ( + node->constant_value ()->ev ()->u.ulval, + &sn); + + idl_global->scopes ().top ()->add_to_scope (added_enum_val); + return 0; } @@ -1089,6 +1173,25 @@ ast_visitor_tmpl_module_inst::reify_type (AST_Decl *d) return 0; } + if (this->ref_only_) + { + // If d is a param holder, the lookup will return a heap + // allocation, which we need since this node's destination + // owns param holders. + if (d->node_type () == AST_Decl::NT_param_holder) + { + const char *s = d->full_name (); + return + idl_global->scopes ().top ()->lookup_by_name ( + d->name (), + true); + } + else + { + return d; + } + } + ast_visitor_reifying rv (this->ctx_); if (d->ast_accept (&rv) != 0) diff --git a/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp b/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp index 5a34132e705..172f4d6fcc3 100644 --- a/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp +++ b/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_ref.cpp @@ -20,7 +20,7 @@ ast_visitor_tmpl_module_ref::ast_visitor_tmpl_module_ref ( ast_visitor_context *ctx) - : ast_visitor_tmpl_module_inst (ctx) + : ast_visitor_tmpl_module_inst (ctx, true) { } @@ -38,7 +38,7 @@ ast_visitor_tmpl_module_ref::visit_template_module_ref ( // processes the implied IDL. It's a bit inefficient to have // the implied IDL in both the template module and its // instantiations, but otherwise the lookup issues are - // extremely complicated. This approach allows + // extremely complicated. This approach allows // lookup_by_name_local() to just skip over the alias and // match the module of the same name occurring later in the // template module scope. From that vantage point, the @@ -47,17 +47,15 @@ ast_visitor_tmpl_module_ref::visit_template_module_ref ( // module scope (see ast_visitor_reifying::check_and_store() // and ast_visitor_reifying::template_module_rel_name()). UTL_ScopedName sn (node->local_name (), 0); - + AST_Module *added_module = idl_global->gen ()->create_module (idl_global->scopes (). top (), &sn); - + idl_global->scopes ().top ()->add_to_scope (added_module); - -// AST_Decl *d = ScopeAsDecl (idl_global->scopes ().top ()); - + idl_global->scopes ().push (added_module); - + // Visit the scope of referenced template module. No need to // update the template parameter list since its param list has // to be a subset of the one we're in. @@ -69,9 +67,9 @@ ast_visitor_tmpl_module_ref::visit_template_module_ref ( ACE_TEXT ("visit_scope failed\n")), -1); } - + idl_global->scopes ().pop (); - + return 0; } diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index 0d835ab4587..df0ce31d2c7 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -48,10 +48,6 @@ #include "ace/Log_Msg.h" #include "ace/String_Base.h" -ACE_RCSID (be, - be_decl, - "$Id$") - // Default Constructor be_decl::be_decl (void) : COMMON_Base (), @@ -101,7 +97,9 @@ be_decl::be_decl (void) ccm_pre_proc_gen_ (false), ex_idl_facet_gen_ (false), svnt_hdr_facet_gen_ (false), - svnt_src_facet_gen_ (false) + svnt_src_facet_gen_ (false), + exec_hdr_facet_gen_ (false), + exec_src_facet_gen_ (false) { } @@ -153,7 +151,12 @@ be_decl::be_decl (AST_Decl::NodeType type, srv_outarg_pragma_inst_gen_ (false), srv_retarg_tmpl_class_gen_ (false), srv_retarg_pragma_inst_gen_ (false), - ccm_pre_proc_gen_ (false) + ccm_pre_proc_gen_ (false), + ex_idl_facet_gen_ (false), + svnt_hdr_facet_gen_ (false), + svnt_src_facet_gen_ (false), + exec_hdr_facet_gen_ (false), + exec_src_facet_gen_ (false) { } @@ -633,6 +636,18 @@ be_decl::svnt_src_facet_gen (void) return this->svnt_src_facet_gen_; } +bool +be_decl::exec_hdr_facet_gen (void) +{ + return this->exec_hdr_facet_gen_; +} + +bool +be_decl::exec_src_facet_gen (void) +{ + return this->exec_src_facet_gen_; +} + // Set the flag indicating that code generation is done. void be_decl::cli_hdr_gen (bool val) @@ -905,6 +920,18 @@ be_decl::svnt_src_facet_gen (bool val) this->svnt_src_facet_gen_ = val; } +void +be_decl::exec_hdr_facet_gen (bool val) +{ + this->exec_hdr_facet_gen_ = val; +} + +void +be_decl::exec_src_facet_gen (bool val) +{ + this->exec_src_facet_gen_ = val; +} + //========================================== int diff --git a/TAO/TAO_IDL/be/be_union_label.cpp b/TAO/TAO_IDL/be/be_union_label.cpp index 27084ad740f..0707dfd59dd 100644 --- a/TAO/TAO_IDL/be/be_union_label.cpp +++ b/TAO/TAO_IDL/be/be_union_label.cpp @@ -5,10 +5,6 @@ #include "be_union_label.h" #include "be_visitor.h" -ACE_RCSID (be, - be_union_label, - "$Id$") - be_union_label::be_union_label (void) : AST_UnionLabel () { diff --git a/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp b/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp index 5a38a9c7332..366ea23a8af 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp @@ -37,6 +37,11 @@ int be_visitor_facet_exh::visit_provides (be_provides *node) { be_type *impl = node->provides_type (); + + if (impl->exec_hdr_facet_gen ()) + { + return 0; + } // We don't want a '_cxx_' prefix here. const char *lname = @@ -49,6 +54,11 @@ be_visitor_facet_exh::visit_provides (be_provides *node) const char *global = (sname_str == "" ? "" : "::"); os_ << be_nl + << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ + << be_nl; + + os_ << be_nl << "class " << export_macro_.c_str () << " " << lname << "_exec_i" << be_idt_nl << ": public virtual " << global << sname << "::CCM_" @@ -87,6 +97,8 @@ be_visitor_facet_exh::visit_provides (be_provides *node) os_ << be_uidt_nl << "};" << be_nl; + + impl->exec_hdr_facet_gen (true); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp b/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp index 7e097ed3302..f17c7bd3654 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp @@ -73,6 +73,11 @@ be_visitor_facet_exs::visit_provides (be_provides *node) { be_type *impl = node->provides_type (); + if (impl->exec_src_facet_gen ()) + { + return 0; + } + // We don't want any '_cxx_' prefix here. const char *lname = impl->original_local_name ()->get_string (); @@ -130,6 +135,8 @@ be_visitor_facet_exs::visit_provides (be_provides *node) } } + impl->exec_src_facet_gen (true); + return 0; } diff --git a/TAO/TAO_IDL/be_include/be_decl.h b/TAO/TAO_IDL/be_include/be_decl.h index 194fc347963..ddf1063d235 100644 --- a/TAO/TAO_IDL/be_include/be_decl.h +++ b/TAO/TAO_IDL/be_include/be_decl.h @@ -122,6 +122,8 @@ public: bool ex_idl_facet_gen (void); bool svnt_hdr_facet_gen (void); bool svnt_src_facet_gen (void); + bool exec_hdr_facet_gen (void); + bool exec_src_facet_gen (void); // Set the flag indicating that code generation is done. void cli_hdr_gen (bool); @@ -171,6 +173,8 @@ public: void ex_idl_facet_gen (bool); void svnt_hdr_facet_gen (bool); void svnt_src_facet_gen (bool); + void exec_hdr_facet_gen (bool); + void exec_src_facet_gen (bool); // Narrowing @@ -230,6 +234,8 @@ private: bool ex_idl_facet_gen_; bool svnt_hdr_facet_gen_; bool svnt_src_facet_gen_; + bool exec_hdr_facet_gen_; + bool exec_src_facet_gen_; }; #endif // if !defined diff --git a/TAO/TAO_IDL/fe/idl.yy b/TAO/TAO_IDL/fe/idl.yy index 123843b684c..a979f815d3f 100644 --- a/TAO/TAO_IDL/fe/idl.yy +++ b/TAO/TAO_IDL/fe/idl.yy @@ -5871,16 +5871,18 @@ factory_decl : */ if (s != 0) { - AST_Home *home = AST_Home::narrow_from_scope (s); + AST_Home *h = AST_Home::narrow_from_scope (s); + o = idl_global->gen ()->create_operation ( - home->managed_component (), + h->managed_component (), AST_Operation::OP_noflags, &n, false, false ); - home->factories ().enqueue_tail (o); + + h->factories ().enqueue_tail (o); } $2->destroy (); @@ -5941,16 +5943,18 @@ finder_decl : */ if (s != 0) { - AST_Home *home = AST_Home::narrow_from_scope (s); + AST_Home *h = AST_Home::narrow_from_scope (s); + o = idl_global->gen ()->create_operation ( - home->managed_component (), + h->managed_component (), AST_Operation::OP_noflags, &n, false, false ); - home->finders ().enqueue_tail (o); + + h->finders ().enqueue_tail (o); } $2->destroy (); diff --git a/TAO/TAO_IDL/fe/y.tab.cpp b/TAO/TAO_IDL/fe/y.tab.cpp index cb47096fc4c..bdd00020072 100644 --- a/TAO/TAO_IDL/fe/y.tab.cpp +++ b/TAO/TAO_IDL/fe/y.tab.cpp @@ -8702,16 +8702,18 @@ tao_yyreduce: */ if (s != 0) { - AST_Home *home = AST_Home::narrow_from_scope (s); + AST_Home *h = AST_Home::narrow_from_scope (s); + o = idl_global->gen ()->create_operation ( - home->managed_component (), + h->managed_component (), AST_Operation::OP_noflags, &n, false, false ); - home->factories ().enqueue_tail (o); + + h->factories ().enqueue_tail (o); } (tao_yyvsp[(2) - (2)].idval)->destroy (); @@ -8777,16 +8779,17 @@ tao_yyreduce: */ if (s != 0) { - AST_Home *home = AST_Home::narrow_from_scope (s); + AST_Home *h = AST_Home::narrow_from_scope (s); + o = idl_global->gen ()->create_operation ( - home->managed_component (), - AST_Operation::OP_noflags, - &n, - false, - false - ); - home->finders ().enqueue_tail (o); + h->managed_component (), + AST_Operation::OP_noflags, + &n, + false, + false); + + h->finders ().enqueue_tail (o); } (tao_yyvsp[(2) - (2)].idval)->destroy (); diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h index e4d02136405..ca030315a1f 100644 --- a/TAO/TAO_IDL/include/ast_union.h +++ b/TAO/TAO_IDL/include/ast_union.h @@ -175,6 +175,8 @@ private: AST_UnionBranch *lookup_enum (AST_UnionBranch *b); friend int tao_yyparse (void); + friend class ast_visitor_tmpl_module_inst; + // Scope Management Protocol. virtual AST_Union *fe_add_union (AST_Union *u); diff --git a/TAO/TAO_IDL/include/ast_union_branch.h b/TAO/TAO_IDL/include/ast_union_branch.h index 64242af69f0..ef4a2f4ea22 100644 --- a/TAO/TAO_IDL/include/ast_union_branch.h +++ b/TAO/TAO_IDL/include/ast_union_branch.h @@ -92,12 +92,13 @@ public: virtual ~AST_UnionBranch (void); - // Data Accessors. + UTL_LabelList *labels (void) const; + AST_UnionLabel *label (unsigned long index = 0); unsigned long label_list_length (void); - // Called if our labels are enum values - adds them the + // Called if our labels are enum values - adds them to the // enclosing scope's name_referenced list. void add_labels (AST_Union *u); @@ -122,10 +123,8 @@ public: virtual void destroy (void); private: - // Data. - - UTL_LabelList *pd_ll; // list of labels. + UTL_LabelList *pd_ll; }; #endif // _AST_UNION_BRANCH_AST_UNION_BRAN_HH diff --git a/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h b/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h index 8864f3b641a..49992a55099 100644 --- a/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h +++ b/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h @@ -43,7 +43,8 @@ class ast_visitor_tmpl_module_inst : public ast_visitor // instantiation or alias of a template module. // public: - ast_visitor_tmpl_module_inst (ast_visitor_context *ctx); + ast_visitor_tmpl_module_inst (ast_visitor_context *ctx, + bool ref_only = false); virtual ~ast_visitor_tmpl_module_inst (void); @@ -118,6 +119,10 @@ private: // Flag to branch in visit_valuetype() where we create an // eventtype or a valuetype. bool for_eventtype_; + + // Flag to short_circuit reifying if we are the base class of + // ast_visitor_tmpl_module_ref. + bool ref_only_; }; #endif // TAO_AST_VISITOR_TMPL_MODULE_INST_H diff --git a/TAO/TAO_IDL/include/utl_labellist.h b/TAO/TAO_IDL/include/utl_labellist.h index 299cadfe0d2..1c365b59cfb 100644 --- a/TAO/TAO_IDL/include/utl_labellist.h +++ b/TAO/TAO_IDL/include/utl_labellist.h @@ -88,6 +88,9 @@ public: // Get list item. AST_UnionLabel *head (void); + // Override of base class method. + virtual UTL_LabelList *copy (void); + // Cleanup. virtual void destroy (void); @@ -96,7 +99,7 @@ private: }; // Active iterator for UTL_LabelList. -class UTL_LabellistActiveIterator : public UTL_ListActiveIterator +class UTL_LabellistActiveIterator : public UTL_ListActiveIterator { public: UTL_LabellistActiveIterator (UTL_LabelList *source); diff --git a/TAO/TAO_IDL/include/utl_scope.h b/TAO/TAO_IDL/include/utl_scope.h index ec602b71375..3dd7943b7ab 100644 --- a/TAO/TAO_IDL/include/utl_scope.h +++ b/TAO/TAO_IDL/include/utl_scope.h @@ -262,6 +262,12 @@ public: // How many entries are used? virtual unsigned long nmembers (void); + // If the Identifier string (from the scoped name which has been + // already determined to be of length 1) matches a param, + // create and return a param holder AST node, otherwise + // return 0. + static AST_Param_Holder *match_param (UTL_ScopedName *e); + // Add to decls. Node represents a local declaration // The new decl e is inserted after ex if ex is not 0. // This one is public because the case of a reopened @@ -338,14 +344,6 @@ protected: // Set the appropriate *_seen_ flag if we are seeing a spec-defined // sequence of a basic type. - AST_Param_Holder *match_param ( - UTL_ScopedName *e, - FE_Utils::T_PARAMLIST_INFO const *params); - // If the Identifier string (from the scoped name which has been - // already determined to be of length 1) matches a param, - // create and return a param holder AST node, otherwise - // return 0. - protected: // Data. diff --git a/TAO/TAO_IDL/util/utl_exceptlist.cpp b/TAO/TAO_IDL/util/utl_exceptlist.cpp index e0b04978be7..1f79b79409d 100644 --- a/TAO/TAO_IDL/util/utl_exceptlist.cpp +++ b/TAO/TAO_IDL/util/utl_exceptlist.cpp @@ -114,14 +114,15 @@ UTL_ExceptList::copy (void) { UTL_ExceptList *retval = 0; ACE_NEW_RETURN (retval, - UTL_ExceptList ( - this->pd_car_data, - this->tail () != 0 - ? (UTL_ExceptList *) this->tail ()->copy () - : 0 - ), + UTL_ExceptList (this->pd_car_data, + 0), 0); + if (this->tail () != 0) + { + retval->nconc ((UTL_ExceptList *) this->tail ()->copy ()); + } + return retval; } diff --git a/TAO/TAO_IDL/util/utl_idlist.cpp b/TAO/TAO_IDL/util/utl_idlist.cpp index 6404e7adf88..17007053795 100644 --- a/TAO/TAO_IDL/util/utl_idlist.cpp +++ b/TAO/TAO_IDL/util/utl_idlist.cpp @@ -90,25 +90,19 @@ UTL_IdList::UTL_IdList (Identifier *s, // Public operations -// Copy a list. +// Copy an IdList. UTL_IdList * UTL_IdList::copy (void) { UTL_IdList *retval = 0; + ACE_NEW_RETURN (retval, + UTL_IdList (this->head ()->copy (), + 0), + 0); - if (this->tail () == 0) - { - ACE_NEW_RETURN (retval, - UTL_IdList (this->head ()->copy (), - 0), - 0); - } - else + if (this->tail () != 0) { - ACE_NEW_RETURN (retval, - UTL_IdList (this->head ()->copy (), - (UTL_IdList *) this->tail ()->copy ()), - 0); + retval->nconc ((UTL_IdList *) this->tail ()->copy ()); } return retval; diff --git a/TAO/TAO_IDL/util/utl_labellist.cpp b/TAO/TAO_IDL/util/utl_labellist.cpp index 199917a5dd9..87a9c834bfc 100644 --- a/TAO/TAO_IDL/util/utl_labellist.cpp +++ b/TAO/TAO_IDL/util/utl_labellist.cpp @@ -74,15 +74,17 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "utl_labellist.h" #include "ast_union_label.h" +#include "ast_expression.h" +#include "ast_generator.h" -ACE_RCSID (util, - utl_labellist, - "$Id$") +#include "global_extern.h" + +#include "ace/OS_Memory.h" UTL_LabelList::UTL_LabelList (AST_UnionLabel *s, UTL_LabelList *cdr) - : UTL_List(cdr), - pd_car_data(s) + : UTL_List (cdr), + pd_car_data (s) { } @@ -93,6 +95,35 @@ UTL_LabelList::head (void) return this->pd_car_data; } +// Copy a label list. +UTL_LabelList * +UTL_LabelList::copy (void) +{ + AST_Expression *val = this->pd_car_data->label_val (); + + AST_Expression *val_copy = 0; + ACE_NEW_RETURN (val_copy, + AST_Expression (val, val->ev ()->et), + 0); + + AST_UnionLabel *label_copy = + idl_global->gen ()->create_union_label (this->pd_car_data->label_kind (), + val_copy); + + UTL_LabelList *retval = 0; + ACE_NEW_RETURN (retval, + UTL_LabelList (label_copy, + 0), + 0); + + if (this->tail () != 0) + { + retval->nconc ((UTL_LabelList *) this->tail ()->copy ()); + } + + return retval; +} + void UTL_LabelList::destroy (void) { @@ -108,16 +139,15 @@ UTL_LabellistActiveIterator::UTL_LabellistActiveIterator (UTL_LabelList *s) { } - // Get current item. AST_UnionLabel * UTL_LabellistActiveIterator::item (void) { - if (source == 0) + if (this->source == 0) { return 0; } - return ((UTL_LabelList *) source)->head (); + return (dynamic_cast<UTL_LabelList *> (this->source))->head (); } diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp index d9d868c7f12..ec5dabfb5e2 100644 --- a/TAO/TAO_IDL/util/utl_scope.cpp +++ b/TAO/TAO_IDL/util/utl_scope.cpp @@ -180,20 +180,12 @@ iter_lookup_by_name_local (AST_Decl *d, d = td->base_type (); } - + if (d == 0) { return 0; } -/* - AST_Template_Module_Ref *tmr = - AST_Template_Module_Ref::narrow_from_decl (d); - if (tmr != 0) - { - d = tmr->ref (); - } -*/ // Try to convert the AST_Decl to a UTL_Scope. UTL_Scope *sc = DeclAsScope (d); @@ -214,15 +206,19 @@ iter_lookup_by_name_local (AST_Decl *d, return 0; } + UTL_ScopedName *sn = (UTL_ScopedName *) e->tail (); if (result == 0) { - return 0; + if (sn == 0) + { + result = UTL_Scope::match_param (e); + } + + return result; } else { - UTL_ScopedName *sn = (UTL_ScopedName *) e->tail (); - if (sn == 0) { // We're done. @@ -583,33 +579,6 @@ UTL_Scope::check_for_predef_seq (AST_Decl *d) } } -AST_Param_Holder * -UTL_Scope::match_param ( - UTL_ScopedName *e, - FE_Utils::T_PARAMLIST_INFO const *params) -{ - const char *name = e->first_component ()->get_string (); - AST_Param_Holder *retval = 0; - - for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*params); - !i.done (); - i.advance ()) - { - FE_Utils::T_Param_Info *param = 0; - i.next (param); - - if (param->name_ == name) - { - retval = - idl_global->gen ()->create_param_holder (e, param); - - break; - } - } - - return retval; -} - // Public operations. // Scope Management Protocol. @@ -849,10 +818,12 @@ UTL_Scope::add_argument (AST_Argument *a) AST_Union * UTL_Scope::add_union (AST_Union *u) { - if (u != 0) + if (u == 0) { - u->set_added (true); + return 0; } + + u->set_added (true); return u; } @@ -891,20 +862,24 @@ UTL_Scope::add_union_branch (AST_UnionBranch *u) AST_Structure * UTL_Scope::add_structure (AST_Structure *s) { - if (s != 0) + if (s == 0) { - s->set_added (true); + return 0; } + + s->set_added (true); return s; } AST_StructureFwd * UTL_Scope::add_structure_fwd (AST_StructureFwd *s) { - if (s != 0) + if (s == 0) { - s->set_added (true); + return 0; } + + s->set_added (true); return s; } @@ -931,20 +906,24 @@ UTL_Scope::add_field (AST_Field *f) AST_Enum * UTL_Scope::add_enum (AST_Enum *e) { - if (e != 0) + if (e == 0) { - e->set_added (true); + return 0; } + + e->set_added (true); return e; } AST_EnumVal * UTL_Scope::add_enum_val (AST_EnumVal *e) { - if (e != 0) + if (e == 0) { - e->set_added (true); + return 0; } + + e->set_added (true); return e; } @@ -1682,14 +1661,16 @@ UTL_Scope::lookup_primitive_type (AST_Expression::ExprType et) // Look through inherited list. Overridden in AST_Interface. AST_Decl * -UTL_Scope::look_in_inherited (UTL_ScopedName *, bool) +UTL_Scope::look_in_inherited (UTL_ScopedName *, + bool ) { return 0; } // Look through supported interface list. Overridden where necessary. AST_Decl * -UTL_Scope::look_in_supported (UTL_ScopedName *, bool) +UTL_Scope::look_in_supported (UTL_ScopedName *, + bool) { return 0; } @@ -1842,23 +1823,18 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, { return 0; } - - // If this call returns a non-zero value, we are in the scope - // of a template module. - FE_Utils::T_PARAMLIST_INFO const *params = - idl_global->current_params (); - - if (e->length () == 1 && params != 0) + + if (e->length () == 1) { AST_Param_Holder *param_holder = - this->match_param (e, params); - + UTL_Scope::match_param (e); + // Since we are inside the scope of a template module, any // single-segment scoped name that matches a template // parameter name has to be a reference to that parameter, // so we return the created placeholder. If there's no // match, 0 is returned, and we proceed with the regular - // lookup. + // lookup. if (param_holder != 0) { return param_holder; @@ -1980,41 +1956,41 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, idl_global->filename ()->get_string (), idl_global->lineno (), d->full_name ())); - + const bool same_file = (0 == ACE_OS::strcmp ( idl_global->filename ()->get_string (), d->file_name ().c_str ()) ); - + if (!same_file) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%C "), d->file_name ().c_str () )); } - + ACE_ERROR (( LM_ERROR, ACE_TEXT ("line %d but hidden by local \""), d->line () )); - + if (ScopeAsDecl (this)->full_name ()[0]) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("::%C"), ScopeAsDecl (this)->full_name () )); } - + ACE_ERROR ((LM_ERROR, ACE_TEXT ("::%C\""), e->head ()->get_string () )); - + const bool same_file_again = (same_file && 0 == ACE_OS::strcmp ( idl_global->filename ()->get_string (), first_one_found->file_name ().c_str ()) ); - + if (!same_file_again) { ACE_ERROR (( @@ -2027,7 +2003,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, { ACE_ERROR ((LM_ERROR, ACE_TEXT (" at ") )); } - + ACE_ERROR ((LM_ERROR, ACE_TEXT ("line %d ?\n"), first_one_found->line () )); @@ -2133,7 +2109,7 @@ UTL_Scope::add_to_referenced (AST_Decl *e, AST_Decl *ex) { UTL_Scope *s = 0; - AST_Decl **tmp = 0; + AST_Decl **tmp; AST_Interface *itf = 0; long oreferenced_allocated; long i; @@ -2261,7 +2237,8 @@ UTL_Scope::add_to_name_referenced (Identifier *id) } void -UTL_Scope::replace_referenced (AST_Decl *old_decl, AST_Decl *new_decl) +UTL_Scope::replace_referenced (AST_Decl *old_decl, + AST_Decl *new_decl) { for (int i = 0; i < this->pd_referenced_used; i++) { @@ -2276,7 +2253,8 @@ UTL_Scope::replace_referenced (AST_Decl *old_decl, AST_Decl *new_decl) void -UTL_Scope::replace_scope (AST_Decl *old_decl, AST_Decl *new_decl) +UTL_Scope::replace_scope (AST_Decl *old_decl, + AST_Decl *new_decl) { for (int i = 0; i < pd_decls_used; i++) { @@ -2292,7 +2270,8 @@ UTL_Scope::replace_scope (AST_Decl *old_decl, AST_Decl *new_decl) // Add a node to set of nodes declared in this scope. void -UTL_Scope::add_to_scope (AST_Decl *e, AST_Decl *ex) +UTL_Scope::add_to_scope (AST_Decl *e, + AST_Decl *ex) { if (e == 0) { @@ -2651,6 +2630,41 @@ UTL_Scope::nmembers (void) return this->pd_decls_used; } +AST_Param_Holder * +UTL_Scope::match_param (UTL_ScopedName *e) +{ + // If this call returns a zero value, we are not in the scope + // of a template module. + FE_Utils::T_PARAMLIST_INFO const *params = + idl_global->current_params (); + + if (params == 0) + { + return 0; + } + + const char *name = e->first_component ()->get_string (); + AST_Param_Holder *retval = 0; + + for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*params); + !i.done (); + i.advance ()) + { + FE_Utils::T_Param_Info *param = 0; + i.next (param); + + if (param->name_ == name) + { + retval = + idl_global->gen ()->create_param_holder (e, param); + + break; + } + } + + return retval; +} + void UTL_Scope::destroy (void) { @@ -2717,7 +2731,7 @@ UTL_ScopeActiveIterator::UTL_ScopeActiveIterator ( void UTL_ScopeActiveIterator::next (void) { - ++this->il; + this->il++; } // Get current item. |