diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-29 22:03:35 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-29 22:03:35 +0000 |
commit | d5bbd865ceb6f4c74d862c5255a053abe9892186 (patch) | |
tree | 63a44b2cae364332db788038361691d40384fee7 | |
parent | 0bb3026c7489e9038a8ab2afb381d88c9d243d75 (diff) | |
download | ATCD-d5bbd865ceb6f4c74d862c5255a053abe9892186.tar.gz |
ChangeLogTag: Fri Jan 29 22:03:03 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
21 files changed, 416 insertions, 275 deletions
diff --git a/modules/TAO/TAO_IDL/ast/ast_finder.cpp b/modules/TAO/TAO_IDL/ast/ast_finder.cpp index 4a3cd25fec0..c85626c5c67 100644 --- a/modules/TAO/TAO_IDL/ast/ast_finder.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_finder.cpp @@ -8,9 +8,9 @@ AST_Finder::AST_Finder (UTL_ScopedName *n) : COMMON_Base (true, false), //@@ Always local, never abstract - AST_Decl (AST_Decl::NT_factory, + AST_Decl (AST_Decl::NT_finder, n), - UTL_Scope (AST_Decl::NT_factory), + UTL_Scope (AST_Decl::NT_finder), AST_Factory (n) { } diff --git a/modules/TAO/TAO_IDL/ast/ast_home.cpp b/modules/TAO/TAO_IDL/ast/ast_home.cpp index 95d39563949..a04c16f56eb 100644 --- a/modules/TAO/TAO_IDL/ast/ast_home.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_home.cpp @@ -5,6 +5,7 @@ #include "ast_valuetype.h" #include "ast_param_holder.h" #include "ast_operation.h" +#include "ast_finder.h" #include "ast_visitor.h" #include "utl_identifier.h" @@ -272,6 +273,114 @@ AST_Home::ast_accept (ast_visitor *visitor) return visitor->visit_home (this); } +AST_Factory * +AST_Home::fe_add_factory (AST_Factory *f) +{ + AST_Decl *d = 0; + + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) + { + idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, + this, + f); + return 0; + } + + // Already defined and cannot be redefined? Or already used? + if ((d = this->lookup_for_add (f, false)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + f, + this, + d); + return 0; + } + + if (this->referenced (d, f->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + f, + this, + d); + return 0; + } + + if (f->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (f, + d); + return 0; + } + } + + // Add it to scope. + this->add_to_scope (f); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (f, + false, + f->local_name ()); + + return f; +} + +AST_Finder * +AST_Home::fe_add_finder (AST_Finder *f) +{ + AST_Decl *d = 0; + + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) + { + idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, + this, + f); + return 0; + } + + // Already defined and cannot be redefined? Or already used? + if ((d = this->lookup_for_add (f, false)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + f, + this, + d); + return 0; + } + + if (this->referenced (d, f->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + f, + this, + d); + return 0; + } + + if (f->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (f, + d); + return 0; + } + } + + // Add it to scope. + this->add_to_scope (f); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (f, + false, + f->local_name ()); + + return f; +} + // Narrowing. IMPL_NARROW_FROM_DECL(AST_Home) diff --git a/modules/TAO/TAO_IDL/ast/ast_redef.cpp b/modules/TAO/TAO_IDL/ast/ast_redef.cpp index 142ef1ec518..2fc3bb464c6 100644 --- a/modules/TAO/TAO_IDL/ast/ast_redef.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_redef.cpp @@ -108,6 +108,7 @@ can_be_redefined (AST_Decl *d) case AST_Decl::NT_op: case AST_Decl::NT_pre_defined: case AST_Decl::NT_factory: + case AST_Decl::NT_finder: case AST_Decl::NT_provides: case AST_Decl::NT_uses: case AST_Decl::NT_publishes: diff --git a/modules/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp b/modules/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp index 5a7eafa22d0..0c9ca968a60 100644 --- a/modules/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_visitor_tmpl_module_inst.cpp @@ -36,7 +36,7 @@ #include "ast_union_branch.h" #include "ast_enum.h" #include "ast_enum_val.h" -#include "ast_factory.h" +#include "ast_finder.h" #include "ast_param_holder.h" #include "ast_expression.h" @@ -58,6 +58,7 @@ ast_visitor_tmpl_module_inst::ast_visitor_tmpl_module_inst ( : ast_visitor (), ctx_ (ctx), for_eventtype_ (false), + for_finder_ (false), ref_only_ (ref_only) { } @@ -1137,8 +1138,18 @@ ast_visitor_tmpl_module_inst::visit_factory (AST_Factory *node) Identifier id (node->local_name ()->get_string ()); UTL_ScopedName sn (&id, 0); - AST_Factory *added_factory = - idl_global->gen ()->create_factory (&sn); + AST_Factory *added_factory = 0; + + if (this->for_finder_) + { + added_factory = + idl_global->gen ()->create_factory (&sn); + } + else + { + added_factory = + idl_global->gen ()->create_finder (&sn); + } idl_global->scopes ().top ()->add_to_scope (added_factory); @@ -1162,13 +1173,17 @@ ast_visitor_tmpl_module_inst::visit_factory (AST_Factory *node) added_factory->be_add_exceptions (reified_exceps); + // In case it was set for this call. + this->for_finder_ = false; + return 0; } int -ast_visitor_tmpl_module_inst::visit_finder (AST_Finder *) +ast_visitor_tmpl_module_inst::visit_finder (AST_Finder *node) { - return 0; + this->for_finder_ = true; + return this->visit_factory (node); } AST_Decl * diff --git a/modules/TAO/TAO_IDL/be/be_finder.cpp b/modules/TAO/TAO_IDL/be/be_finder.cpp index a2323839dbd..76be9d9f37a 100644 --- a/modules/TAO/TAO_IDL/be/be_finder.cpp +++ b/modules/TAO/TAO_IDL/be/be_finder.cpp @@ -23,13 +23,13 @@ be_finder::be_finder (UTL_ScopedName *n) : COMMON_Base (1, 0), //@@ Always local, never abstract - AST_Decl (AST_Decl::NT_factory, + AST_Decl (AST_Decl::NT_finder, n), - UTL_Scope (AST_Decl::NT_factory), + UTL_Scope (AST_Decl::NT_finder), AST_Factory (n), AST_Finder (n), - be_scope (AST_Decl::NT_factory), - be_decl (AST_Decl::NT_factory, + be_scope (AST_Decl::NT_finder), + be_decl (AST_Decl::NT_finder, n), be_factory (n) { diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home.cpp index 6919c23651f..705c90751a1 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_home.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_home.cpp @@ -33,6 +33,8 @@ #include "be_attribute.h" #include "be_home.h" #include "be_component.h" +#include "be_factory.h" +#include "be_finder.h" #include "be_operation.h" #include "be_sequence.h" #include "be_string.h" @@ -42,6 +44,7 @@ #include "be_visitor_operation.h" #include "be_visitor_typecode/typecode_defn.h" #include "be_visitor_typecode/objref_typecode.h" +#include "be_visitor_valuetype/valuetype_init_arglist_ch.h" #include "be_visitor_context.h" #include "be_visitor_home/home_ch.cpp" @@ -51,4 +54,5 @@ #include "be_visitor_home/home_ex_idl.cpp" #include "be_visitor_home/home_exh.cpp" #include "be_visitor_home/home_exs.cpp" +#include "be_visitor_home/factory_svs.cpp" diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home/factory_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home/factory_svs.cpp new file mode 100644 index 00000000000..8bf3bf91ff5 --- /dev/null +++ b/modules/TAO/TAO_IDL/be/be_visitor_home/factory_svs.cpp @@ -0,0 +1,50 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// factory_svs.cpp +// +// = DESCRIPTION +// Visitor generating code for home factores and finders +// in the servant source. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +be_visitor_factory_svs::be_visitor_factory_svs ( + be_visitor_context *ctx, + be_home *h_node, + AST_Component *comp, + bool for_finder) + : be_visitor_scope (ctx), + h_node_ (h_node), + comp_ (comp), + os_ (*ctx->stream ()), + for_finder_ (for_finder), + unused_args_(false) +{ +} + +be_visitor_factory_svs::~be_visitor_factory_svs (void) +{ +} + +int +be_visitor_factory_svs::visit_factory (be_factory *node) +{ + os_ << be_nl << be_nl + << "::" << comp_->name () << "_ptr" << be_nl + << h_node_->original_local_name ()->get_string () + << "_Servant::" << node->local_name (); + + return 0; +} + diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp index b23084daace..8adaf80bc87 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svh.cpp @@ -92,6 +92,37 @@ be_visitor_home_svh::visit_attribute (be_attribute *node) } int +be_visitor_home_svh::visit_factory (be_factory *node) +{ + os_ << be_nl << be_nl + << "virtual ::" << comp_->name () << "_ptr" << be_nl + << node->local_name (); + + // We can reuse this visitor. + be_visitor_valuetype_init_arglist_ch v (this->ctx_); + + if (v.visit_factory (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_svh::") + ACE_TEXT ("visit_factory - ") + ACE_TEXT ("codegen for argument ") + ACE_TEXT ("list failed\n")), + -1); + } + + os_ << ";"; + + return 0; +} + +int +be_visitor_home_svh::visit_finder (be_finder *node) +{ + return this->visit_factory (node); +} + +int be_visitor_home_svh::gen_servant_class (void) { AST_Decl *scope = ScopeAsDecl (node_->defined_in ()); @@ -155,127 +186,26 @@ be_visitor_home_svh::gen_servant_class (void) << "get_primary_key (" << be_idt_nl << "::" << comp_->name () << "_ptr comp);" << be_uidt; } - - this->gen_ops_attrs (); - - this->gen_factories (); - - this->gen_finders (); - - os_ << be_uidt_nl - << "};"; - - return 0; -} - -int -be_visitor_home_svh::gen_ops_attrs (void) -{ - os_ << be_nl << be_nl - << "// All operations and attributes."; - - int status = - node_->traverse_inheritance_graph ( - be_visitor_home_svh::op_attr_decl_helper, - &os_); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svh::") - ACE_TEXT ("gen_ops_attrs - ") - ACE_TEXT ("traverse_inheritance_graph() ") - ACE_TEXT ("failed\n")), - -1); - } - return 0; -} - -int -be_visitor_home_svh::gen_factories (void) -{ - os_ << be_nl << be_nl - << "// Factory operations."; + be_home *h = node_; - return this->gen_factories_r (node_); -} - -int -be_visitor_home_svh::gen_factories_r (AST_Home *node) -{ - if (node == 0) + while (h != 0) { - return 0; - } - - if (this->gen_init_ops_i (node->factories ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svh::") - ACE_TEXT ("gen_factories_r - ") - ACE_TEXT ("gen_init_ops_i() failed\n")), - -1); - } - - AST_Home *base = node->base_home (); - - return this->gen_factories_r (base); -} - -int -be_visitor_home_svh::gen_finders (void) -{ - os_ << be_nl << be_nl - << "// Finder operations."; - - return this->gen_finders_r (node_); -} - -int -be_visitor_home_svh::gen_finders_r (AST_Home *node) -{ - if (node == 0) - { - return 0; - } - - if (this->gen_init_ops_i (node->finders ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svh::") - ACE_TEXT ("gen_finders_r - ") - ACE_TEXT ("gen_init_ops_i() failed\n")), - -1); - } - - AST_Home *base = node->base_home (); - - return this->gen_finders_r (base); -} - -int -be_visitor_home_svh::gen_init_ops_i (AST_Home::INIT_LIST & list) -{ - AST_Operation **op = 0; - - for (AST_Home::INIT_LIST::ITERATOR i = list.begin (); - !i.done (); - i.advance ()) - { - i.next (op); - be_operation *bop = be_operation::narrow_from_decl (*op); - - if (this->visit_operation (bop) == -1) + if (this->visit_scope (h) != 0) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_home_svh::") - ACE_TEXT ("gen_init_ops_i - ") - ACE_TEXT ("visit_operation() failed\n")), + ACE_TEXT ("gen_servant_class - ") + ACE_TEXT ("visit_scope() failed\n")), -1); } + + h = be_home::narrow_from_decl (h->base_home ()); } - + + os_ << be_uidt_nl + << "};"; + return 0; } @@ -292,21 +222,4 @@ be_visitor_home_svh::gen_entrypoint (void) << "const char * ins_name);" << be_uidt; } -int -be_visitor_home_svh::op_attr_decl_helper (be_interface * /* derived */, - be_interface *ancestor, - TAO_OutStream *os) -{ - /// We're in a static method, so we have to instantiate a temporary - /// visitor and context. - be_visitor_context ctx; - ctx.state (TAO_CodeGen::TAO_ROOT_SVH); - ctx.stream (os); - be_visitor_home_svh visitor (&ctx); - - /// Since this visitor overriddes only visit_operation() and - /// visit_attribute(), we can get away with this for the declarations. - return visitor.visit_scope (ancestor); -} - diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp index 7d103f68e6f..6d2b4e11807 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp @@ -5,7 +5,7 @@ // ============================================================================ // // = LIBRARY -// TAO IDL +// TAO_IDL_BE // // = FILENAME // home_svs.cpp @@ -28,7 +28,8 @@ be_visitor_home_svs::be_visitor_home_svs (be_visitor_context *ctx) comp_ (0), os_ (*ctx->stream ()), export_macro_ (be_global->svnt_export_macro ()), - swapping_ (be_global->gen_component_swapping ()) + swapping_ (be_global->gen_component_swapping ()), + for_finder_ (false) { /// All existing CIAO examples set the servant export values in the CIDL /// compiler to equal the IDL compiler's skel export values. Below is a @@ -108,6 +109,36 @@ be_visitor_home_svs::visit_argument (be_argument *node) } int +be_visitor_home_svs::visit_factory (be_factory *node) +{ + be_visitor_factory_svs v (this->ctx_, + node_, + comp_, + this->for_finder_); + + if (v.visit_factory (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_svs::") + ACE_TEXT ("visit_factory - ") + ACE_TEXT ("traversal failed\n")), + -1); + } + + // In case it was set for the call above. + this->for_finder_ = false; + + return 0; +} + +int +be_visitor_home_svs::visit_finder (be_finder *node) +{ + this->for_finder_ = true; + return this->visit_factory (node); +} + +int be_visitor_home_svs::gen_servant_class (void) { AST_Decl *scope = ScopeAsDecl (node_->defined_in ()); @@ -191,7 +222,24 @@ be_visitor_home_svs::gen_servant_class (void) << be_uidt_nl << "}"; } + + be_home *h = node_; + + while (h != 0) + { + if (this->visit_scope (h) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_svs::") + ACE_TEXT ("gen_servant_class - ") + ACE_TEXT ("codegen for scope failed\n")), + -1); + } + + h = be_home::narrow_from_decl (h->base_home ()); + } +/* this->gen_ops_attrs (); os_ << be_nl << be_nl @@ -203,7 +251,7 @@ be_visitor_home_svs::gen_servant_class (void) << "/// Finder operations."; this->gen_finders_r (node_); - +*/ return 0; } diff --git a/modules/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp b/modules/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp index e64a179304c..3896bb95bb8 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp @@ -40,7 +40,7 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) if (node->nmembers () > 0) { - os << be_idt << be_idt_nl; + os << be_idt_nl; // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) @@ -52,8 +52,7 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) -1); } - os << be_uidt_nl - << ")"; + os << ")" << be_uidt; } else { diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_home.h b/modules/TAO/TAO_IDL/be_include/be_visitor_home.h index 9c4d117bdf2..ce1eab2c414 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_home.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_home.h @@ -36,5 +36,6 @@ #include "be_visitor_home/home_ex_idl.h" #include "be_visitor_home/home_exh.h" #include "be_visitor_home/home_exs.h" +#include "be_visitor_home/factory_svs.h" #endif diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_home/factory_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_home/factory_svs.h new file mode 100644 index 00000000000..2b109117e06 --- /dev/null +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_home/factory_svs.h @@ -0,0 +1,55 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// factory_svs.h +// +// = DESCRIPTION +// Concrete visitor for home factory and finder nodes. +// This provides for code generation in the servant source +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef _BE_HOME_FACTORY_SVS_H_ +#define _BE_HOME_FACTORY_SVS_H_ + +class be_visitor_factory_svs : public be_visitor_scope +{ + // + // = TITLE + // be_visitor_factory_svs + // + // = DESCRIPTION + // This is a concrete visitor to generate the servant + // source for a home factory or finder. + // + // +public: + be_visitor_factory_svs (be_visitor_context *ctx, + be_home *h_node, + AST_Component *comp, + bool for_finder); + + ~be_visitor_factory_svs (void); + + virtual int visit_factory (be_factory *node); + +private: + be_home *h_node_; + AST_Component *comp_; + TAO_OutStream &os_; + bool for_finder_; + bool unused_args_; +}; + +#endif /* _BE_HOME_FACTORY_SVS_H_ */ + diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svh.h index af922537a57..049801b7d7e 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svh.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svh.h @@ -40,28 +40,14 @@ public: virtual int visit_home (be_home *node); virtual int visit_operation (be_operation *node); virtual int visit_attribute (be_attribute *node); + virtual int visit_factory (be_factory *node); + virtual int visit_finder (be_finder *node); private: int gen_servant_class (void); - int gen_ops_attrs (void); - - int gen_factories (void); - int gen_factories_r (AST_Home *node); - - int gen_finders (void); - int gen_finders_r (AST_Home *node); - - int gen_init_ops_i (AST_Home::INIT_LIST & list); - void gen_entrypoint (void); - /// Helper method passed to traverse_inheritance_graph(), - /// collects supported operations and attributes. - static int op_attr_decl_helper (be_interface *, - be_interface *, - TAO_OutStream *); - private: be_home *node_; AST_Component *comp_; diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svs.h index c3fbcc394ea..2fe0736ad4d 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svs.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_home/home_svs.h @@ -5,7 +5,7 @@ // ============================================================================ // // = LIBRARY -// TAO IDL +// TAO_IDL_BE // // = FILENAME // home_svs.h @@ -29,7 +29,8 @@ class be_visitor_home_svs : public be_visitor_scope // be_visitor_home_svs // // = DESCRIPTION - // This is a concrete visitor to generate the servant header for component. + // This is a concrete visitor to generate the servant + // source for a comopnent home. // // public: @@ -41,6 +42,8 @@ public: virtual int visit_operation (be_operation *node); virtual int visit_attribute (be_attribute *node); virtual int visit_argument (be_argument *node); + virtual int visit_factory (be_factory *node); + virtual int visit_finder (be_finder *node); private: int gen_servant_class (void); @@ -70,6 +73,7 @@ private: TAO_OutStream &os_; ACE_CString export_macro_; bool swapping_; + bool for_finder_; }; /// Worker class passed to traverse_inheritance_graph(), diff --git a/modules/TAO/TAO_IDL/fe/idl.yy b/modules/TAO/TAO_IDL/fe/idl.yy index 78915cbdbd1..8a19355f22f 100644 --- a/modules/TAO/TAO_IDL/fe/idl.yy +++ b/modules/TAO/TAO_IDL/fe/idl.yy @@ -5870,30 +5870,17 @@ factory_decl : * Create a node representing a factory operation * and add it to the enclosing scope. */ - if (s != 0) - { - AST_Home *h = AST_Home::narrow_from_scope (s); - - o = - idl_global->gen ()->create_operation ( - h->managed_component (), - AST_Operation::OP_noflags, - &n, - false, - false - ); - - h->factories ().enqueue_tail (o); - } + AST_Factory *f = idl_global->gen ()->create_factory (&n); + (void) s->fe_add_factory (f); $2->destroy (); delete $2; $2 = 0; /* - * Push the operation scope onto the scopes stack. + * Push the factory scope onto the scopes stack. */ - idl_global->scopes ().push (o); + idl_global->scopes ().push (f); } init_parameter_list { @@ -5904,24 +5891,18 @@ factory_decl : { // opt_raises UTL_Scope *s = idl_global->scopes ().top_non_null (); - AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); /* - * Add exceptions and context to the operation. + * Add exceptions and context to the factory. */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + if ($6 != 0) { - o = AST_Operation::narrow_from_scope (s); - - if ($6 != 0 && o != 0) - { - (void) o->fe_add_exceptions ($6); - } + (void) s->fe_add_exceptions ($6); } /* - * Done with this operation. Pop its scope from the scopes stack. + * Done with this factory. Pop its scope from the scopes stack. */ idl_global->scopes ().pop (); } @@ -5935,28 +5916,18 @@ finder_decl : UTL_Scope *s = idl_global->scopes ().top_non_null (); UTL_ScopedName n ($2, 0); - AST_Operation *o = 0; + idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); /* - * Create a node representing a finder operation + * Create a node representing a home finder * and add it to the enclosing scope. */ - if (s != 0) - { - AST_Home *h = AST_Home::narrow_from_scope (s); - - o = - idl_global->gen ()->create_operation ( - h->managed_component (), - AST_Operation::OP_noflags, - &n, - false, - false - ); - - h->finders ().enqueue_tail (o); - } + AST_Finder *f = + idl_global->gen ()->create_finder (&n); + + (void) s->fe_add_finder (f); + $2->destroy (); delete $2; @@ -5965,7 +5936,7 @@ finder_decl : /* * Push the operation scope onto the scopes stack. */ - idl_global->scopes ().push (o); + idl_global->scopes ().push (f); } init_parameter_list { @@ -5980,16 +5951,11 @@ finder_decl : idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); /* - * Add exceptions and context to the operation. + * Add exceptions and context to the finder. */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + if ($6 != 0) { - o = AST_Operation::narrow_from_scope (s); - - if ($6 != 0 && o != 0) - { - (void) o->fe_add_exceptions ($6); - } + (void) s->fe_add_exceptions ($6); } /* diff --git a/modules/TAO/TAO_IDL/fe/y.tab.cpp b/modules/TAO/TAO_IDL/fe/y.tab.cpp index 085e84cd935..3f7f52e0175 100644 --- a/modules/TAO/TAO_IDL/fe/y.tab.cpp +++ b/modules/TAO/TAO_IDL/fe/y.tab.cpp @@ -8694,37 +8694,24 @@ tao_yyreduce: UTL_Scope *s = idl_global->scopes ().top_non_null (); UTL_ScopedName n ((tao_yyvsp[(2) - (2)].idval), 0); - AST_Operation *o = 0; + idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); /* - * Create a node representing a factory operation + * Create a node representing a factory * and add it to the enclosing scope. */ - if (s != 0) - { - AST_Home *h = AST_Home::narrow_from_scope (s); - - o = - idl_global->gen ()->create_operation ( - h->managed_component (), - AST_Operation::OP_noflags, - &n, - false, - false - ); - - h->factories ().enqueue_tail (o); - } + AST_Factory *f = idl_global->gen ()->create_factory (&n); + (void) s->fe_add_factory (f); (tao_yyvsp[(2) - (2)].idval)->destroy (); delete (tao_yyvsp[(2) - (2)].idval); (tao_yyvsp[(2) - (2)].idval) = 0; /* - * Push the operation scope onto the scopes stack. + * Push the factory scope onto the scopes stack. */ - idl_global->scopes ().push (o); + idl_global->scopes ().push (f); } break; @@ -8741,24 +8728,18 @@ tao_yyreduce: { // opt_raises UTL_Scope *s = idl_global->scopes ().top_non_null (); - AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); /* - * Add exceptions and context to the operation. + * Add exceptions and context to the factory. */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + if ((tao_yyvsp[(6) - (6)].nlval) != 0) { - o = AST_Operation::narrow_from_scope (s); - - if ((tao_yyvsp[(6) - (6)].nlval) != 0 && o != 0) - { - (void) o->fe_add_exceptions ((tao_yyvsp[(6) - (6)].nlval)); - } + (void) s->fe_add_exceptions ((tao_yyvsp[(6) - (6)].nlval)); } /* - * Done with this operation. Pop its scope from the scopes stack. + * Done with this factory. Pop its scope from the scopes stack. */ idl_global->scopes ().pop (); } @@ -8771,28 +8752,18 @@ tao_yyreduce: UTL_Scope *s = idl_global->scopes ().top_non_null (); UTL_ScopedName n ((tao_yyvsp[(2) - (2)].idval), 0); - AST_Operation *o = 0; + idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); /* - * Create a node representing a finder operation + * Create a node representing a home finder * and add it to the enclosing scope. */ - if (s != 0) - { - AST_Home *h = AST_Home::narrow_from_scope (s); - - o = - idl_global->gen ()->create_operation ( - h->managed_component (), - AST_Operation::OP_noflags, - &n, - false, - false); - - h->finders ().enqueue_tail (o); - } - + AST_Finder *f = + idl_global->gen ()->create_finder (&n); + + (void) s->fe_add_finder (f); + (tao_yyvsp[(2) - (2)].idval)->destroy (); delete (tao_yyvsp[(2) - (2)].idval); (tao_yyvsp[(2) - (2)].idval) = 0; @@ -8800,7 +8771,7 @@ tao_yyreduce: /* * Push the operation scope onto the scopes stack. */ - idl_global->scopes ().push (o); + idl_global->scopes ().push (f); } break; @@ -8817,24 +8788,19 @@ tao_yyreduce: { // opt_raises UTL_Scope *s = idl_global->scopes ().top_non_null (); - AST_Operation *o = 0; + idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); /* - * Add exceptions and context to the operation. + * Add exceptions and context to the finder. */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + if ((tao_yyvsp[(6) - (6)].nlval) != 0) { - o = AST_Operation::narrow_from_scope (s); - - if ((tao_yyvsp[(6) - (6)].nlval) != 0 && o != 0) - { - (void) o->fe_add_exceptions ((tao_yyvsp[(6) - (6)].nlval)); - } + (void) s->fe_add_exceptions ((tao_yyvsp[(6) - (6)].nlval)); } /* - * Done with this operation. Pop its scope from the scopes stack. + * Done with this finder. Pop its scope from the scopes stack. */ idl_global->scopes ().pop (); } diff --git a/modules/TAO/TAO_IDL/include/ast_home.h b/modules/TAO/TAO_IDL/include/ast_home.h index 1dafeaeda0a..43067a1c59e 100644 --- a/modules/TAO/TAO_IDL/include/ast_home.h +++ b/modules/TAO/TAO_IDL/include/ast_home.h @@ -66,6 +66,15 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + +private: + // Scope Management Protocol. + + friend int tao_yyparse (void); + friend class ast_visitor_tmpl_module_inst; + + virtual AST_Factory *fe_add_factory (AST_Factory *f); + virtual AST_Finder *fe_add_finder (AST_Finder *f); private: AST_Home *pd_base_home; diff --git a/modules/TAO/TAO_IDL/include/ast_valuetype.h b/modules/TAO/TAO_IDL/include/ast_valuetype.h index bacd756a3ab..344570c7886 100644 --- a/modules/TAO/TAO_IDL/include/ast_valuetype.h +++ b/modules/TAO/TAO_IDL/include/ast_valuetype.h @@ -6,7 +6,8 @@ #include "ast_interface.h" -class TAO_IDL_FE_Export AST_ValueType : public virtual AST_Interface +class TAO_IDL_FE_Export AST_ValueType + : public virtual AST_Interface { public: AST_ValueType (void); diff --git a/modules/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h b/modules/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h index d41952b17c1..05622a00e85 100644 --- a/modules/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h +++ b/modules/TAO/TAO_IDL/include/ast_visitor_tmpl_module_inst.h @@ -120,6 +120,10 @@ private: // eventtype or a valuetype. bool for_eventtype_; + // Flag to branch in visit_factory() where we create a + // finder or a factory. + bool for_finder_; + // Flag to short_circuit reifying if we are the base class of // ast_visitor_tmpl_module_ref. bool ref_only_; diff --git a/modules/TAO/TAO_IDL/include/utl_scope.h b/modules/TAO/TAO_IDL/include/utl_scope.h index f20104e3811..f9f697010da 100644 --- a/modules/TAO/TAO_IDL/include/utl_scope.h +++ b/modules/TAO/TAO_IDL/include/utl_scope.h @@ -120,6 +120,7 @@ class AST_Typedef; class AST_Array; class AST_Native; class AST_Factory; +class AST_Finder; class AST_PortType; class AST_Provides; class AST_Uses; @@ -423,6 +424,9 @@ protected: virtual AST_Factory *fe_add_factory (AST_Factory *f); + + virtual + AST_Finder *fe_add_finder (AST_Finder *f); virtual AST_ValueBox *fe_add_valuebox (AST_ValueBox *vb); diff --git a/modules/TAO/TAO_IDL/util/utl_scope.cpp b/modules/TAO/TAO_IDL/util/utl_scope.cpp index f4272394f4d..61c2e8cb520 100644 --- a/modules/TAO/TAO_IDL/util/utl_scope.cpp +++ b/modules/TAO/TAO_IDL/util/utl_scope.cpp @@ -741,6 +741,12 @@ UTL_Scope::fe_add_factory (AST_Factory *) return 0; } +AST_Finder * +UTL_Scope::fe_add_finder (AST_Finder *) +{ + return 0; +} + AST_PortType * UTL_Scope::fe_add_porttype (AST_PortType *) { |