diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-13 15:12:04 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-13 15:12:04 +0000 |
commit | 89b62b7c4623432f086bebcd8e41f0cad9bde0ad (patch) | |
tree | aa65d2eaef0097fbc312356a157d1047e3bf6497 | |
parent | eafd4a70907f5978332a601e4d970aa61a019a1e (diff) | |
download | ATCD-89b62b7c4623432f086bebcd8e41f0cad9bde0ad.tar.gz |
ChangeLogTag: Fri Oct 13 10:06:03 2000 Jeff Parsons <parsons@cs.wustl.edu>
61 files changed, 667 insertions, 173 deletions
diff --git a/TAO/TAO_IDL/Makefile.FE b/TAO/TAO_IDL/Makefile.FE index c7fdabf11b5..50f8dfae9fa 100644 --- a/TAO/TAO_IDL/Makefile.FE +++ b/TAO/TAO_IDL/Makefile.FE @@ -59,6 +59,7 @@ FILES = fe/fe_declarator \ ast/ast_generator \ ast/ast_redef \ ast/ast_recursive \ + ast/ast_visitor \ util/utl_scope \ util/utl_stack \ util/utl_string \ diff --git a/TAO/TAO_IDL/TAO_IDL_FE.bor b/TAO/TAO_IDL/TAO_IDL_FE.bor index b3c8933ba7f..2f13aabbd64 100644 --- a/TAO/TAO_IDL/TAO_IDL_FE.bor +++ b/TAO/TAO_IDL/TAO_IDL_FE.bor @@ -35,6 +35,7 @@ OBJFILES = \ $(OBJDIR)\ast_union.obj \ $(OBJDIR)\ast_union_branch.obj \ $(OBJDIR)\ast_union_label.obj \ + $(OBJDIR)\ast_visitor.obj \ $(OBJDIR)\fe_declarator.obj \ $(OBJDIR)\fe_extern.obj \ $(OBJDIR)\fe_global.obj \ diff --git a/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp b/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp index 50e8dab175f..3be74a7604f 100644 --- a/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp +++ b/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp @@ -220,6 +220,10 @@ SOURCE=.\ast\ast_union_label.cpp # End Source File
# Begin Source File
+SOURCE=.\ast\ast_visitor.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\fe\fe_declarator.cpp
# End Source File
# Begin Source File
@@ -440,6 +444,10 @@ SOURCE=.\include\ast_union_label.h # End Source File
# Begin Source File
+SOURCE=.\include\ast_visitor.h
+# End Source File
+# Begin Source File
+
SOURCE=.\include\fe_declarator.h
# End Source File
# Begin Source File
diff --git a/TAO/TAO_IDL/TAO_IDL_FE_LIB.dsp b/TAO/TAO_IDL/TAO_IDL_FE_LIB.dsp index d03603374b3..ea12e89ff83 100644 --- a/TAO/TAO_IDL/TAO_IDL_FE_LIB.dsp +++ b/TAO/TAO_IDL/TAO_IDL_FE_LIB.dsp @@ -213,6 +213,10 @@ SOURCE=.\ast\ast_union_label.cpp # End Source File
# Begin Source File
+SOURCE=.\ast\ast_visitor.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\fe\fe_declarator.cpp
# End Source File
# Begin Source File
@@ -433,6 +437,10 @@ SOURCE=.\include\ast_union_label.h # End Source File
# Begin Source File
+SOURCE=.\include\ast_visitor.h
+# End Source File
+# Begin Source File
+
SOURCE=.\include\fe_declarator.h
# End Source File
# Begin Source File
diff --git a/TAO/TAO_IDL/ast/Makefile.am b/TAO/TAO_IDL/ast/Makefile.am index 9c9fde91f28..2be4f1bcb08 100644 --- a/TAO/TAO_IDL/ast/Makefile.am +++ b/TAO/TAO_IDL/ast/Makefile.am @@ -47,7 +47,8 @@ libast_la_SOURCES = \ ast_typedef.cpp \ ast_union.cpp \ ast_union_branch.cpp \ - ast_union_label.cpp + ast_union_label.cpp \ + ast_visitor.cpp ## Clean up some additional files/directories possibly created during diff --git a/TAO/TAO_IDL/ast/ast_argument.cpp b/TAO/TAO_IDL/ast/ast_argument.cpp index a6ef166b083..f46d42b6a0e 100644 --- a/TAO/TAO_IDL/ast/ast_argument.cpp +++ b/TAO/TAO_IDL/ast/ast_argument.cpp @@ -97,7 +97,7 @@ direction_to_string (AST_Argument::Direction d) // Constructor(s) and destructor. AST_Argument::AST_Argument (void) - : pd_direction(dir_IN) + : pd_direction (dir_IN) { } @@ -126,10 +126,16 @@ AST_Argument::~AST_Argument (void) void AST_Argument::dump (ostream &o) { - o << direction_to_string(pd_direction) << " "; + o << direction_to_string (pd_direction) << " "; AST_Field::dump (o); } +int +AST_Argument::accept (ast_visitor *visitor) +{ + return visitor->visit_argument (this); +} + // Data accessors. AST_Argument::Direction diff --git a/TAO/TAO_IDL/ast/ast_array.cpp b/TAO/TAO_IDL/ast/ast_array.cpp index 00a31c1fd39..1187fa924d3 100644 --- a/TAO/TAO_IDL/ast/ast_array.cpp +++ b/TAO/TAO_IDL/ast/ast_array.cpp @@ -157,6 +157,12 @@ AST_Array::dump (ostream &o) } } +int +AST_Array::accept (ast_visitor *visitor) +{ + return visitor->visit_array (this); +} + // Data accessors. unsigned long AST_Array::n_dims (void) diff --git a/TAO/TAO_IDL/ast/ast_attribute.cpp b/TAO/TAO_IDL/ast/ast_attribute.cpp index e286db5b9f7..4e8309987d6 100644 --- a/TAO/TAO_IDL/ast/ast_attribute.cpp +++ b/TAO/TAO_IDL/ast/ast_attribute.cpp @@ -115,6 +115,12 @@ AST_Attribute::dump (ostream &o) AST_Field::dump (o); } +int +AST_Attribute::accept (ast_visitor *visitor) +{ + return visitor->visit_attribute (this); +} + // Data accessors. idl_bool diff --git a/TAO/TAO_IDL/ast/ast_constant.cpp b/TAO/TAO_IDL/ast/ast_constant.cpp index 4065b039c2a..7d39892f2f7 100644 --- a/TAO/TAO_IDL/ast/ast_constant.cpp +++ b/TAO/TAO_IDL/ast/ast_constant.cpp @@ -182,6 +182,12 @@ AST_Constant::dump (ostream &o) this->pd_constant_value->dump (o); } +int +AST_Constant::accept (ast_visitor *visitor) +{ + return visitor->visit_constant (this); +} + // Data accessors. AST_Expression * diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index 0805239996e..b0af22025c0 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -549,6 +549,12 @@ AST_Decl::dump (ostream &o) this->pd_local_name->dump (o); } +int +AST_Decl::accept (ast_visitor *visitor) +{ + return visitor->visit_decl (this); +} + void AST_Decl::destroy (void) { diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index a448762a1a2..d3260cea951 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -328,6 +328,12 @@ AST_Enum::dump (ostream &o) o << "}"; } +int +AST_Enum::accept (ast_visitor *visitor) +{ + return visitor->visit_enum (this); +} + void AST_Enum::destroy (void) { diff --git a/TAO/TAO_IDL/ast/ast_enum_val.cpp b/TAO/TAO_IDL/ast/ast_enum_val.cpp index 862b3c25ccc..ad4b68a6639 100644 --- a/TAO/TAO_IDL/ast/ast_enum_val.cpp +++ b/TAO/TAO_IDL/ast/ast_enum_val.cpp @@ -105,6 +105,12 @@ AST_EnumVal::dump (ostream &o) AST_Constant::dump (o); } +int +AST_EnumVal::accept (ast_visitor *visitor) +{ + return visitor->visit_enum_val (this); +} + // Narrowing methods. IMPL_NARROW_METHODS1(AST_EnumVal, AST_Constant) IMPL_NARROW_FROM_DECL(AST_EnumVal) diff --git a/TAO/TAO_IDL/ast/ast_exception.cpp b/TAO/TAO_IDL/ast/ast_exception.cpp index 6b32011f401..b7b40d00fc7 100644 --- a/TAO/TAO_IDL/ast/ast_exception.cpp +++ b/TAO/TAO_IDL/ast/ast_exception.cpp @@ -411,6 +411,12 @@ AST_Exception::dump (ostream &o) o << "}"; } +int +AST_Exception::accept (ast_visitor *visitor) +{ + return visitor->visit_exception (this); +} + // Narrowing methods. IMPL_NARROW_METHODS1(AST_Exception, AST_Structure) IMPL_NARROW_FROM_DECL(AST_Exception) diff --git a/TAO/TAO_IDL/ast/ast_expression.cpp b/TAO/TAO_IDL/ast/ast_expression.cpp index 4819b86837e..fba71f85760 100644 --- a/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/TAO/TAO_IDL/ast/ast_expression.cpp @@ -2496,6 +2496,12 @@ AST_Expression::dump (ostream &o) } } +int +AST_Expression::accept (ast_visitor *visitor) +{ + return visitor->visit_expression (this); +} + // Data accessors. UTL_Scope * diff --git a/TAO/TAO_IDL/ast/ast_field.cpp b/TAO/TAO_IDL/ast/ast_field.cpp index 5f5e07e7118..5a3345854a4 100644 --- a/TAO/TAO_IDL/ast/ast_field.cpp +++ b/TAO/TAO_IDL/ast/ast_field.cpp @@ -142,6 +142,12 @@ AST_Field::dump (ostream &o) this->local_name ()->dump (o); } +int +AST_Field::accept (ast_visitor *visitor) +{ + return visitor->visit_field (this); +} + // Data accessors. AST_Type * diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index ae3cb7d8e42..0447cdf1b5f 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -1178,6 +1178,19 @@ AST_Interface::destroy (void) { } +int +AST_Interface::accept (ast_visitor *visitor) +{ + if (this->is_valuetype_) + { + return visitor->visit_valuetype (this); + } + else + { + return visitor->visit_interface (this); + } +} + // Narrowing methods. IMPL_NARROW_METHODS2(AST_Interface, AST_Type, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Interface) diff --git a/TAO/TAO_IDL/ast/ast_interface_fwd.cpp b/TAO/TAO_IDL/ast/ast_interface_fwd.cpp index 5bec2141413..22895cdc395 100644 --- a/TAO/TAO_IDL/ast/ast_interface_fwd.cpp +++ b/TAO/TAO_IDL/ast/ast_interface_fwd.cpp @@ -154,6 +154,19 @@ AST_InterfaceFwd::dump (ostream &o) this->local_name ()->dump (o); } +int +AST_InterfaceFwd::accept (ast_visitor *visitor) +{ + if (this->is_valuetype ()) + { + return visitor->visit_valuetype_fwd (this); + } + else + { + return visitor->visit_interface_fwd (this); + } +} + // Data accessors. AST_Interface * diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp index 2ee23293c0a..46a37de33e2 100644 --- a/TAO/TAO_IDL/ast/ast_module.cpp +++ b/TAO/TAO_IDL/ast/ast_module.cpp @@ -926,6 +926,12 @@ AST_Module::destroy (void) { } +int +AST_Module::accept (ast_visitor *visitor) +{ + return visitor->visit_module (this); +} + // Narrowing methods IMPL_NARROW_METHODS2(AST_Module, AST_Decl, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Module) diff --git a/TAO/TAO_IDL/ast/ast_native.cpp b/TAO/TAO_IDL/ast/ast_native.cpp index 9a9a79700f8..6cc45f79e16 100644 --- a/TAO/TAO_IDL/ast/ast_native.cpp +++ b/TAO/TAO_IDL/ast/ast_native.cpp @@ -34,6 +34,12 @@ AST_Native::dump (ostream &o) AST_Decl::dump (o); } +int +AST_Native::accept (ast_visitor *visitor) +{ + return visitor->visit_native (this); +} + // Narrowing. IMPL_NARROW_METHODS1(AST_Native, AST_Type) IMPL_NARROW_FROM_DECL(AST_Native) diff --git a/TAO/TAO_IDL/ast/ast_operation.cpp b/TAO/TAO_IDL/ast/ast_operation.cpp index 6172e8edbe7..f1a8255c9d7 100644 --- a/TAO/TAO_IDL/ast/ast_operation.cpp +++ b/TAO/TAO_IDL/ast/ast_operation.cpp @@ -473,6 +473,12 @@ AST_Operation::dump (ostream &o) } } +int +AST_Operation::accept (ast_visitor *visitor) +{ + return visitor->visit_operation (this); +} + // Data accessors AST_Type * diff --git a/TAO/TAO_IDL/ast/ast_predefined_type.cpp b/TAO/TAO_IDL/ast/ast_predefined_type.cpp index 6b5c0ec3e56..309eabd9bcc 100644 --- a/TAO/TAO_IDL/ast/ast_predefined_type.cpp +++ b/TAO/TAO_IDL/ast/ast_predefined_type.cpp @@ -105,6 +105,12 @@ AST_PredefinedType::dump (ostream &o) AST_Decl::dump (o); } +int +AST_PredefinedType::accept (ast_visitor *visitor) +{ + return visitor->visit_predefined_type (this); +} + // Data accessors. AST_PredefinedType::PredefinedType diff --git a/TAO/TAO_IDL/ast/ast_root.cpp b/TAO/TAO_IDL/ast/ast_root.cpp index d22eeec7325..eff1ec686bc 100644 --- a/TAO/TAO_IDL/ast/ast_root.cpp +++ b/TAO/TAO_IDL/ast/ast_root.cpp @@ -187,6 +187,12 @@ AST_Root::dump (ostream &o) UTL_Scope::dump (o); } +int +AST_Root::accept (ast_visitor *visitor) +{ + return visitor->visit_root (this); +} + // Narrowing methods. IMPL_NARROW_METHODS1(AST_Root, AST_Module) IMPL_NARROW_FROM_DECL(AST_Root) diff --git a/TAO/TAO_IDL/ast/ast_sequence.cpp b/TAO/TAO_IDL/ast/ast_sequence.cpp index 203621866a8..a39df332a20 100644 --- a/TAO/TAO_IDL/ast/ast_sequence.cpp +++ b/TAO/TAO_IDL/ast/ast_sequence.cpp @@ -166,6 +166,12 @@ AST_Sequence::dump (ostream &o) o << ">"; } +int +AST_Sequence::accept (ast_visitor *visitor) +{ + return visitor->visit_sequence (this); +} + // Data accessors. AST_Expression * diff --git a/TAO/TAO_IDL/ast/ast_string.cpp b/TAO/TAO_IDL/ast/ast_string.cpp index 5066feec75c..673484a05d8 100644 --- a/TAO/TAO_IDL/ast/ast_string.cpp +++ b/TAO/TAO_IDL/ast/ast_string.cpp @@ -129,6 +129,12 @@ AST_String::dump(ostream &o) o << ">"; } +int +AST_String::accept (ast_visitor *visitor) +{ + return visitor->visit_string (this); +} + // Data accessors. AST_Expression * diff --git a/TAO/TAO_IDL/ast/ast_structure.cpp b/TAO/TAO_IDL/ast/ast_structure.cpp index 08ddbc1cc7a..8bb53fa2d95 100644 --- a/TAO/TAO_IDL/ast/ast_structure.cpp +++ b/TAO/TAO_IDL/ast/ast_structure.cpp @@ -514,6 +514,12 @@ AST_Structure::dump (ostream &o) o << "}"; } +int +AST_Structure::accept (ast_visitor *visitor) +{ + return visitor->visit_structure (this); +} + void AST_Structure::destroy (void) { diff --git a/TAO/TAO_IDL/ast/ast_type.cpp b/TAO/TAO_IDL/ast/ast_type.cpp index 6d8dbb9e8b1..390fe5bd956 100644 --- a/TAO/TAO_IDL/ast/ast_type.cpp +++ b/TAO/TAO_IDL/ast/ast_type.cpp @@ -99,6 +99,12 @@ AST_Type::in_recursion (AST_Type *) return 0; } -// Narrowing +int +AST_Type::accept (ast_visitor *visitor) +{ + return visitor->visit_type (this); +} + +// Narrowing. IMPL_NARROW_METHODS1(AST_Type, AST_Decl) IMPL_NARROW_FROM_DECL(AST_Type) diff --git a/TAO/TAO_IDL/ast/ast_typedef.cpp b/TAO/TAO_IDL/ast/ast_typedef.cpp index 6f8dae68dba..400f0ea79ec 100644 --- a/TAO/TAO_IDL/ast/ast_typedef.cpp +++ b/TAO/TAO_IDL/ast/ast_typedef.cpp @@ -120,6 +120,12 @@ AST_Typedef::dump (ostream &o) this->local_name ()->dump (o); } +int +AST_Typedef::accept (ast_visitor *visitor) +{ + return visitor->visit_typedef (this); +} + // Data accessors. AST_Type * diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp index cfbde6f9805..4af408c8a99 100644 --- a/TAO/TAO_IDL/ast/ast_union.cpp +++ b/TAO/TAO_IDL/ast/ast_union.cpp @@ -729,6 +729,12 @@ AST_Union::dump (ostream &o) o << "}"; } +int +AST_Union::accept (ast_visitor *visitor) +{ + return visitor->visit_union (this); +} + // Data accessors. AST_ConcreteType * diff --git a/TAO/TAO_IDL/ast/ast_union_branch.cpp b/TAO/TAO_IDL/ast/ast_union_branch.cpp index 92e28fb179f..0e00c71013e 100644 --- a/TAO/TAO_IDL/ast/ast_union_branch.cpp +++ b/TAO/TAO_IDL/ast/ast_union_branch.cpp @@ -116,6 +116,12 @@ AST_UnionBranch::dump (ostream &o) AST_Field::dump (o); } +int +AST_UnionBranch::accept (ast_visitor *visitor) +{ + return visitor->visit_union_branch (this); +} + // Data accessors. AST_UnionLabel * diff --git a/TAO/TAO_IDL/ast/ast_union_label.cpp b/TAO/TAO_IDL/ast/ast_union_label.cpp index 1ab3e7252a4..5f39fc22e4c 100644 --- a/TAO/TAO_IDL/ast/ast_union_label.cpp +++ b/TAO/TAO_IDL/ast/ast_union_label.cpp @@ -113,6 +113,12 @@ AST_UnionLabel::dump (ostream &o) } } +int +AST_UnionLabel::accept (ast_visitor *visitor) +{ + return visitor->visit_union_label (this); +} + // Data accessors. AST_UnionLabel::UnionLabel diff --git a/TAO/TAO_IDL/ast/ast_visitor.cpp b/TAO/TAO_IDL/ast/ast_visitor.cpp new file mode 100644 index 00000000000..37eacf4542f --- /dev/null +++ b/TAO/TAO_IDL/ast/ast_visitor.cpp @@ -0,0 +1,14 @@ +// $Id$ + +#include "ast_visitor.h" +#include "ace/ACE.h" + +ACE_RCSID(ast, ast_visitor, "$Id$") + +ast_visitor::ast_visitor (void) +{ +} + +ast_visitor::~ast_visitor (void) +{ +} diff --git a/TAO/TAO_IDL/be/be_argument.cpp b/TAO/TAO_IDL/be/be_argument.cpp index c7645038263..0cadc03fefc 100644 --- a/TAO/TAO_IDL/be/be_argument.cpp +++ b/TAO/TAO_IDL/be/be_argument.cpp @@ -54,6 +54,6 @@ be_argument::accept (be_visitor *visitor) return visitor->visit_argument (this); } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS2 (be_argument, AST_Argument, be_decl) IMPL_NARROW_FROM_DECL (be_argument) diff --git a/TAO/TAO_IDL/include/ast.h b/TAO/TAO_IDL/include/ast.h index dd8116e5816..9e5d14b1de3 100644 --- a/TAO/TAO_IDL/include/ast.h +++ b/TAO/TAO_IDL/include/ast.h @@ -86,6 +86,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. # pragma warning (disable : 4250) #endif /* _MSC_VER */ +#include "ast_visitor.h" // abstract class ast_visitor + #include "utl_scoped_name.h" // Define UTL_ScopedName #include "ast_decl.h" // class AST_Decl diff --git a/TAO/TAO_IDL/include/ast_argument.h b/TAO/TAO_IDL/include/ast_argument.h index 7556eae350a..25613425500 100644 --- a/TAO/TAO_IDL/include/ast_argument.h +++ b/TAO/TAO_IDL/include/ast_argument.h @@ -109,6 +109,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_array.h b/TAO/TAO_IDL/include/ast_array.h index 16a2ec42794..d96d4973313 100644 --- a/TAO/TAO_IDL/include/ast_array.h +++ b/TAO/TAO_IDL/include/ast_array.h @@ -70,7 +70,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // Representation of array declaration: // An array is a combination of a list of dimensions and a base type -class TAO_IDL_FE_Export AST_Array : public virtual AST_ConcreteType { +class TAO_IDL_FE_Export AST_Array : public virtual AST_ConcreteType +{ public: // Operations. @@ -106,6 +107,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_attribute.h b/TAO/TAO_IDL/include/ast_attribute.h index 3c1fd213ca2..b82d0d4c1ea 100644 --- a/TAO/TAO_IDL/include/ast_attribute.h +++ b/TAO/TAO_IDL/include/ast_attribute.h @@ -99,6 +99,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_constant.h b/TAO/TAO_IDL/include/ast_constant.h index b59ab4be8f4..1531df1de85 100644 --- a/TAO/TAO_IDL/include/ast_constant.h +++ b/TAO/TAO_IDL/include/ast_constant.h @@ -111,6 +111,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. AST_Expression *pd_constant_value; diff --git a/TAO/TAO_IDL/include/ast_decl.h b/TAO/TAO_IDL/include/ast_decl.h index 66f6c7a7fc5..ecc0584f5b2 100644 --- a/TAO/TAO_IDL/include/ast_decl.h +++ b/TAO/TAO_IDL/include/ast_decl.h @@ -234,6 +234,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + // Cleanup method. virtual void destroy (void); diff --git a/TAO/TAO_IDL/include/ast_enum.h b/TAO/TAO_IDL/include/ast_enum.h index 3aeb1971b52..b15b3d802b7 100644 --- a/TAO/TAO_IDL/include/ast_enum.h +++ b/TAO/TAO_IDL/include/ast_enum.h @@ -112,6 +112,9 @@ public: // Cleanup function. virtual void destroy (void); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: friend int tao_yyparse (void); diff --git a/TAO/TAO_IDL/include/ast_enum_val.h b/TAO/TAO_IDL/include/ast_enum_val.h index 4fdb844c440..656ec9fb0f5 100644 --- a/TAO/TAO_IDL/include/ast_enum_val.h +++ b/TAO/TAO_IDL/include/ast_enum_val.h @@ -92,6 +92,9 @@ public: // AST Dumping. virtual void dump (ostream &); + + // Visiting. + virtual int accept (ast_visitor *visitor); }; #endif // _AST_ENUM_VAL_AST_ENUM_VAL_HH diff --git a/TAO/TAO_IDL/include/ast_exception.h b/TAO/TAO_IDL/include/ast_exception.h index ce22104d985..69285fb7c4a 100644 --- a/TAO/TAO_IDL/include/ast_exception.h +++ b/TAO/TAO_IDL/include/ast_exception.h @@ -99,6 +99,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: friend int tao_yyparse (void); diff --git a/TAO/TAO_IDL/include/ast_expression.h b/TAO/TAO_IDL/include/ast_expression.h index f1ed7c3edf8..77ce526d418 100644 --- a/TAO/TAO_IDL/include/ast_expression.h +++ b/TAO/TAO_IDL/include/ast_expression.h @@ -231,6 +231,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + // Other operations. // Evaluation and value coercion. diff --git a/TAO/TAO_IDL/include/ast_field.h b/TAO/TAO_IDL/include/ast_field.h index c85684b5761..a1479f5b2d6 100644 --- a/TAO/TAO_IDL/include/ast_field.h +++ b/TAO/TAO_IDL/include/ast_field.h @@ -121,6 +121,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_interface.h b/TAO/TAO_IDL/include/ast_interface.h index 2ea8cda35a2..ec092b98a27 100644 --- a/TAO/TAO_IDL/include/ast_interface.h +++ b/TAO/TAO_IDL/include/ast_interface.h @@ -157,6 +157,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + protected: idl_bool is_valuetype_; diff --git a/TAO/TAO_IDL/include/ast_interface_fwd.h b/TAO/TAO_IDL/include/ast_interface_fwd.h index a5d850a9151..55fefdb3720 100644 --- a/TAO/TAO_IDL/include/ast_interface_fwd.h +++ b/TAO/TAO_IDL/include/ast_interface_fwd.h @@ -101,6 +101,9 @@ public: // AST Dumping. virtual void dump (ostream &); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_module.h b/TAO/TAO_IDL/include/ast_module.h index 7b8959b053c..6cda84a5e0d 100644 --- a/TAO/TAO_IDL/include/ast_module.h +++ b/TAO/TAO_IDL/include/ast_module.h @@ -121,6 +121,9 @@ public: // Cleanup function. virtual void destroy (void); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: friend void fe_populate (AST_Module *m); friend int tao_yyparse (void); diff --git a/TAO/TAO_IDL/include/ast_native.h b/TAO/TAO_IDL/include/ast_native.h index efd5d54f112..af32b97df5a 100644 --- a/TAO/TAO_IDL/include/ast_native.h +++ b/TAO/TAO_IDL/include/ast_native.h @@ -29,6 +29,9 @@ public: // AST Dumping. virtual void dump(ostream &o); + + // Visiting. + virtual int accept (ast_visitor *visitor); }; #endif /* AST_NATIVE_H */ diff --git a/TAO/TAO_IDL/include/ast_operation.h b/TAO/TAO_IDL/include/ast_operation.h index eef588426f7..674b23db587 100644 --- a/TAO/TAO_IDL/include/ast_operation.h +++ b/TAO/TAO_IDL/include/ast_operation.h @@ -135,6 +135,9 @@ public: // Cleanup function. virtual void destroy (void); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_predefined_type.h b/TAO/TAO_IDL/include/ast_predefined_type.h index 444d42e51a3..b1ed0714455 100644 --- a/TAO/TAO_IDL/include/ast_predefined_type.h +++ b/TAO/TAO_IDL/include/ast_predefined_type.h @@ -117,6 +117,9 @@ public: // AST Dumping virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_root.h b/TAO/TAO_IDL/include/ast_root.h index 5376afa638c..4cae6a9d43b 100644 --- a/TAO/TAO_IDL/include/ast_root.h +++ b/TAO/TAO_IDL/include/ast_root.h @@ -90,6 +90,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: friend class FE_Declarator; friend int tao_yyparse (void); diff --git a/TAO/TAO_IDL/include/ast_sequence.h b/TAO/TAO_IDL/include/ast_sequence.h index 3cea1dc3c36..457ad2b76c3 100644 --- a/TAO/TAO_IDL/include/ast_sequence.h +++ b/TAO/TAO_IDL/include/ast_sequence.h @@ -104,6 +104,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. AST_Expression *pd_max_size; diff --git a/TAO/TAO_IDL/include/ast_string.h b/TAO/TAO_IDL/include/ast_string.h index 4b7c475ee28..512b3921c78 100644 --- a/TAO/TAO_IDL/include/ast_string.h +++ b/TAO/TAO_IDL/include/ast_string.h @@ -96,6 +96,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_structure.h b/TAO/TAO_IDL/include/ast_structure.h index ceac23811eb..d79f31f0de9 100644 --- a/TAO/TAO_IDL/include/ast_structure.h +++ b/TAO/TAO_IDL/include/ast_structure.h @@ -120,6 +120,9 @@ public: // Cleanup function. virtual void destroy (void); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: friend int tao_yyparse (void); // Scope Management Protocol. diff --git a/TAO/TAO_IDL/include/ast_type.h b/TAO/TAO_IDL/include/ast_type.h index 323407aa322..03a4d54dd9b 100644 --- a/TAO/TAO_IDL/include/ast_type.h +++ b/TAO/TAO_IDL/include/ast_type.h @@ -100,6 +100,9 @@ public: // Narrowing. DEF_NARROW_METHODS1(AST_Type, AST_Decl); DEF_NARROW_FROM_DECL(AST_Type); + + // Visiting. + virtual int accept (ast_visitor *visitor); }; #endif // _AST_TYPE_AST_TYPE_HH diff --git a/TAO/TAO_IDL/include/ast_typedef.h b/TAO/TAO_IDL/include/ast_typedef.h index ef3d6d396ce..b997a0c588d 100644 --- a/TAO/TAO_IDL/include/ast_typedef.h +++ b/TAO/TAO_IDL/include/ast_typedef.h @@ -96,6 +96,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h index 89d58eed971..f886161532b 100644 --- a/TAO/TAO_IDL/include/ast_union.h +++ b/TAO/TAO_IDL/include/ast_union.h @@ -111,6 +111,9 @@ public: // AST Dumping. virtual void dump (ostream &); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_union_branch.h b/TAO/TAO_IDL/include/ast_union_branch.h index 46956cd97c8..c386f4ef247 100644 --- a/TAO/TAO_IDL/include/ast_union_branch.h +++ b/TAO/TAO_IDL/include/ast_union_branch.h @@ -97,6 +97,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_union_label.h b/TAO/TAO_IDL/include/ast_union_label.h index 21971c596a5..8dc8f465de9 100644 --- a/TAO/TAO_IDL/include/ast_union_label.h +++ b/TAO/TAO_IDL/include/ast_union_label.h @@ -97,6 +97,9 @@ public: // AST Dumping. virtual void dump (ostream &o); + // Visiting. + virtual int accept (ast_visitor *visitor); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_visitor.h b/TAO/TAO_IDL/include/ast_visitor.h new file mode 100644 index 00000000000..6bc5bceff3c --- /dev/null +++ b/TAO/TAO_IDL/include/ast_visitor.h @@ -0,0 +1,167 @@ +// $Id$ + +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_FE_DLL +// +// = FILENAME +// ast_visitor.h +// +// = DESCRIPTION +// The abstract AST visitor base class. +// +// = AUTHOR +// Jeff Parsons <parsons@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_IDL_FE_DLL_AST_VISITOR_H +#define TAO_IDL_FE_DLL_AST_VISITOR_H + +#include "TAO_IDL_FE_Export.h" + +class AST_Decl; +class UTL_Scope; +class AST_Type; +class AST_PredefinedType; +class AST_Module; +class AST_Interface; +class AST_InterfaceFwd; + +#ifdef IDL_HAS_VALUETYPE +// These classes don't exist now, but they may someday. +// class AST_Valuetype; +// class AST_ValuetypeFwd; +#endif /* IDL_HAS_VALUETYPE */ + +class AST_Structure; +class AST_Exception; +class AST_Expression; +class AST_Enum; +class AST_Operation; +class AST_Field; +class AST_Argument; +class AST_Attribute; +class AST_Union; +class AST_UnionBranch; +class AST_UnionLabel; +class AST_Constant; +class AST_EnumVal; +class AST_Array; +class AST_Sequence; +class AST_String; +class AST_Typedef; +class AST_Root; +class AST_Native; + +class TAO_IDL_FE_Export ast_visitor +{ + // + // = TITLE + // ast_visitor. + // + // = DESCRIPTION + // To implement BE processing we use the "Visitor Pattern", this + // is the abstract "Visitor". This class is the abstract base class + // for visitors that traverse the AST_<node> classes. Other abstract + // classes for C++ code generation, Java code generation, or IfR + // administration, for example, can be derived from this class and + // be the root of their own subtree of specialized visitor classes. + // +public: + ast_visitor (void); + // Constructor. + + virtual ~ast_visitor (void); + // Destructor. + + virtual int visit_decl (AST_Decl *d) = 0; + // Visit a decl node. + + virtual int visit_scope (UTL_Scope *node) = 0; + // Visit the scope + + virtual int visit_type (AST_Type *node) = 0; + // Visit the type. + + virtual int visit_predefined_type (AST_PredefinedType *node) = 0; + // Visit the predefined type. + + virtual int visit_module (AST_Module *node) = 0; + // Visit module. + + virtual int visit_interface (AST_Interface *node) = 0; + // Visit interface. + + virtual int visit_interface_fwd (AST_InterfaceFwd *node) = 0; + // Visit interface_fwd + +#ifdef IDL_HAS_VALUETYPE + virtual int visit_valuetype (AST_Interface *node) = 0; + // Visit valuetype. + + virtual int visit_valuetype_fwd (AST_InterfaceFwd *node) = 0; + // Visit valuetype_fwd +#endif /* IDL_HAS_VALUETYPE */ + + virtual int visit_structure (AST_Structure *node) = 0; + // Visit a structure. + + virtual int visit_exception (AST_Exception *node) = 0; + // Visit exception + + virtual int visit_expression (AST_Expression *node) = 0; + // Visit expression. + + virtual int visit_enum (AST_Enum *node) = 0; + // Visit an enum. + + virtual int visit_operation (AST_Operation *node) = 0; + // Visit an operation. + + virtual int visit_field (AST_Field *node) = 0; + // Visit a field. + + virtual int visit_argument (AST_Argument *node) = 0; + // Visit argument. + + virtual int visit_attribute (AST_Attribute *node) = 0; + // Visit an attribute. + + virtual int visit_union (AST_Union *node) = 0; + // Visit union. + + virtual int visit_union_branch (AST_UnionBranch *node) = 0; + // Visit union branch. + + virtual int visit_union_label (AST_UnionLabel *node) = 0; + // Visit union label. + + virtual int visit_constant (AST_Constant *node) = 0; + // Visit a constant. + + virtual int visit_enum_val (AST_EnumVal *node) = 0; + // Visit enum val. + + virtual int visit_array (AST_Array *node) = 0; + // Visit an array. + + virtual int visit_sequence (AST_Sequence *node) = 0; + // Visit a sequence. + + virtual int visit_string (AST_String *node) = 0; + // Visit a string. + + virtual int visit_typedef (AST_Typedef *node) = 0; + // Visit a typedef. + + virtual int visit_root (AST_Root *node) = 0; + // Visit a root. + + virtual int visit_native (AST_Native *node) = 0; + // Visit a native. +}; + +#endif /* TAO_IDL_FE_DLL_AST_VISITOR_H */ diff --git a/TAO/TAO_IDL/include/utl_scope.h b/TAO/TAO_IDL/include/utl_scope.h index 757ffcd2d33..c4b3930dddb 100644 --- a/TAO/TAO_IDL/include/utl_scope.h +++ b/TAO/TAO_IDL/include/utl_scope.h @@ -62,13 +62,11 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _UTL_SCOPE_UTL_SCOPE_HH #define _UTL_SCOPE_UTL_SCOPE_HH -// UTL_Scope - Provide scoping mechanism -// // This is the base class for name scoping. Each entity which can // be directly contained in a naming scope has an add() function // defined for it. The functions defined on the base scoping class @@ -83,243 +81,285 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // the responsibility of those functions then to call the add() // function defined in the parent "AST_" class. -/* -** DEPENDENCIES: ast_decl.hh, utl_scoped_name.hh -** -** USE: Included from ast.hh -*/ +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "ast_decl.h" +#include "ast_expression.h" +#include "utl_scoped_name.h" -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "ast_decl.h" -#include "ast_expression.h" -#include "utl_scoped_name.h" - -// This is for AIX w/IBM C++ +// This is for AIX w/IBM C++. class Identifier; -// Forward declaration of active iterator for UTL_Scope +// Forward declaration of active iterator for UTL_Scope. class UTL_ScopeActiveIterator; class TAO_IDL_FE_Export UTL_Scope : public virtual COMMON_Base { public: - // Enum to denote the kind of iteration desired + // Enum to denote the kind of iteration desired. enum ScopeIterationKind { - IK_both // Iterate through both decls and local types - , IK_decls // Iterate only through decls - , IK_localtypes // Iterate only through local types + IK_both // Iterate through both decls and local types. + , IK_decls // Iterate only through decls. + , IK_localtypes // Iterate only through local types. }; - // Operations - - // Constructor(s) - UTL_Scope(); - UTL_Scope(AST_Decl::NodeType nt); - virtual ~UTL_Scope() {} - - // Scope Management Protocol - virtual AST_PredefinedType *add_predefined_type(AST_PredefinedType *t); - virtual AST_Module *add_module(AST_Module *m); - virtual AST_Interface *add_interface(AST_Interface *i); - virtual AST_InterfaceFwd *add_interface_fwd(AST_InterfaceFwd *i); - virtual AST_Constant *add_constant(AST_Constant *c); - virtual AST_Exception *add_exception(AST_Exception *e); - virtual AST_Attribute *add_attribute(AST_Attribute *a); - virtual AST_Operation *add_operation(AST_Operation *o); - virtual AST_Argument *add_argument(AST_Argument *a); - virtual AST_Union *add_union(AST_Union *u); - virtual AST_UnionBranch *add_union_branch(AST_UnionBranch *b); - virtual AST_Structure *add_structure(AST_Structure *s); - virtual AST_Field *add_field(AST_Field *f); - virtual AST_Enum *add_enum(AST_Enum *e); - virtual AST_EnumVal *add_enum_val(AST_EnumVal *v); - virtual AST_Typedef *add_typedef(AST_Typedef *t); - virtual UTL_StrList *add_context(UTL_StrList *c); - virtual UTL_NameList *add_exceptions(UTL_NameList *e); - virtual AST_Sequence *add_sequence(AST_Sequence *s); - virtual AST_String *add_string(AST_String *s); - virtual AST_Array *add_array(AST_Array *a); - virtual AST_Native *add_native (AST_Native *n); - - // Call back end add_XXX functions for this scope - virtual AST_Decl *call_add(); - - // Data Accessors - AST_Decl::NodeType scope_node_type() + // Operations. + + // Constructor(s). + UTL_Scope (void); + UTL_Scope (AST_Decl::NodeType nt); + + // Destructor. + virtual ~UTL_Scope (void); + + // Scope Management Protocol. + virtual AST_PredefinedType *add_predefined_type (AST_PredefinedType *t); + + virtual AST_Module *add_module (AST_Module *m); + + virtual AST_Interface *add_interface (AST_Interface *i); + + virtual AST_InterfaceFwd *add_interface_fwd (AST_InterfaceFwd *i); + + virtual AST_Constant *add_constant (AST_Constant *c); + + virtual AST_Exception *add_exception (AST_Exception *e); + + virtual AST_Attribute *add_attribute (AST_Attribute *a); + + virtual AST_Operation *add_operation (AST_Operation *o); + + virtual AST_Argument *add_argument (AST_Argument *a); + + virtual AST_Union *add_union (AST_Union *u); + + virtual AST_UnionBranch *add_union_branch (AST_UnionBranch *b); + + virtual AST_Structure *add_structure (AST_Structure *s); + + virtual AST_Field *add_field (AST_Field *f); + + virtual AST_Enum *add_enum (AST_Enum *e); + + virtual AST_EnumVal *add_enum_val (AST_EnumVal *v); + + virtual AST_Typedef *add_typedef (AST_Typedef *t); + + virtual UTL_StrList *add_context (UTL_StrList *c); + + virtual UTL_NameList *add_exceptions (UTL_NameList *e); + + virtual AST_Sequence *add_sequence (AST_Sequence *s); + + virtual AST_String *add_string (AST_String *s); + + virtual AST_Array *add_array (AST_Array *a); + + virtual AST_Native *add_native (AST_Native *n); + + // Call back end add_XXX functions for this scope. + virtual AST_Decl *call_add (void); + + // Data Accessors. + AST_Decl::NodeType scope_node_type (void) { return pd_scope_node_type; } - // Narrowing + // Narrowing. DEF_NARROW_METHODS0(UTL_Scope); DEF_NARROW_FROM_SCOPE(UTL_Scope); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); - // Other Operations + // Other Operations. // Name Lookup Mechanism - virtual AST_Decl *lookup_by_name(UTL_ScopedName *, - idl_bool treat_as_ref, - idl_bool in_parent = 1); + virtual AST_Decl *lookup_by_name (UTL_ScopedName *, + idl_bool treat_as_ref, + idl_bool in_parent = 1); - // Look up the Identifier * specified only in the local scope - virtual AST_Decl *lookup_by_name_local(Identifier *, - long index); + // Look up the Identifier * specified only in the local scope. + virtual AST_Decl *lookup_by_name_local (Identifier *, + long index); - // Look up a predefined type by its ExprType - virtual AST_Decl - *lookup_primitive_type(AST_Expression::ExprType); + // Look up a predefined type by its ExprType. + virtual AST_Decl *lookup_primitive_type (AST_Expression::ExprType); // How many entries are used? - virtual unsigned long nmembers(); + virtual unsigned long nmembers (void); // 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 // module necessitates a call to this from // be_generator::create_module(). - void add_to_scope(AST_Decl *e, - AST_Decl *ex = 0); + void add_to_scope (AST_Decl *e, + AST_Decl *ex = 0); // Cleanup function. virtual void destroy (void); + // Visiting. + virtual int accept (ast_visitor *visitor); + protected: // UTL_Scope protected addition protocol. This protocol is // used from sub-classes of UTL_Scope to insert nodes directly // into the specified node table (either decls or local_types) // Additionally, UTL_Scope also maintains a record of what nodes - // defined elsewhere were referenced in this scope + // defined elsewhere were referenced in this scope. // Add to referenced nodes set. // If ex is not 0 'e' will be inserted at the position // after ex, which is already in the list. - void add_to_referenced(AST_Decl *e, - idl_bool recursive, - Identifier *id, - AST_Decl *ex = 0); + void add_to_referenced (AST_Decl *e, + idl_bool recursive, + Identifier *id, + AST_Decl *ex = 0); - // Add to local types. Node represents a local manifest type - void add_to_local_types(AST_Decl *e); + // Add to local types. Node represents a local manifest type. + void add_to_local_types (AST_Decl *e); - // Replace old_decl with new_decl + // Replace old_decl with new_decl. void replace_scope (AST_Decl *old_decl, AST_Decl *new_decl); - // Replace old_decl with new_decl + // Replace old_decl with new_decl. void replace_referenced (AST_Decl *old_decl, AST_Decl *new_decl); // Has this node been referenced here already? - idl_bool referenced(AST_Decl *e, - Identifier *id = 0); + idl_bool referenced (AST_Decl *e, + Identifier *id = 0); // Look up a scoped name in the inherited interfaces of an - // interface - virtual AST_Decl *look_in_inherited(UTL_ScopedName *, - idl_bool treat_as_ref); + // interface. + virtual AST_Decl *look_in_inherited (UTL_ScopedName *, + idl_bool treat_as_ref); protected: - // Operations + // Operations. - // Lookup based on the local name - virtual AST_Decl *lookup_for_add(AST_Decl *d, - idl_bool treat_as_ref); + // Lookup based on the local name. + virtual AST_Decl *lookup_for_add (AST_Decl *d, + idl_bool treat_as_ref); private: - // Data + // Data. // What type is this node? This is a cache of the information // in AST_Decl - const AST_Decl::NodeType pd_scope_node_type; + const AST_Decl::NodeType pd_scope_node_type; - // Storage for declarations in this scope: - AST_Decl **pd_decls; // Store declarations - long pd_decls_allocated; // How many allocated? - long pd_decls_used; // How many used? + // Storage for declarations in this scope. + AST_Decl **pd_decls; // Store declarations + long pd_decls_allocated; // How many allocated? + long pd_decls_used; // How many used? - // Storage for local manifest types in this scope: - AST_Decl **pd_local_types; // Store types - long pd_locals_allocated; // How many allocated? - long pd_locals_used; // How many used? + // Storage for local manifest types in this scope. + AST_Decl **pd_local_types; // Store types + long pd_locals_allocated; // How many allocated? + long pd_locals_used; // How many used? - // Storage for referenced nodes in this scope: - AST_Decl **pd_referenced; // Store references - long pd_referenced_allocated;// How many allocated? - long pd_referenced_used; // How many used? + // Storage for referenced nodes in this scope. + AST_Decl **pd_referenced; // Store references + long pd_referenced_allocated; // How many allocated? + long pd_referenced_used; // How many used? // Storage for identifiers used in this scope. CORBA 2.3 introduced // stricter rules for clashes during name resolution, and the information // in pd_referenced is not enough to catch them all. - Identifier **pd_name_referenced; // Store name references - long pd_name_referenced_allocated; // How many allocated? - long pd_name_referenced_used; // How many used? + Identifier **pd_name_referenced; // Store name references + long pd_name_referenced_allocated; // How many allocated? + long pd_name_referenced_used; // How many used? // Friend class UTL_ScopeActiveIterator defines active iterator for // UTL_Scope. Definition follows below. - friend class UTL_ScopeActiveIterator; + friend class UTL_ScopeActiveIterator; private: - friend int tao_yyparse(); + friend int tao_yyparse (void); friend class AST_Enum; - // Scope Management Protocol - virtual AST_PredefinedType *fe_add_predefined_type(AST_PredefinedType *t); - virtual AST_Module *fe_add_module(AST_Module *m); - virtual AST_Interface *fe_add_interface(AST_Interface *i); - virtual AST_InterfaceFwd *fe_add_interface_fwd(AST_InterfaceFwd *i); - virtual AST_Constant *fe_add_constant(AST_Constant *c); - virtual AST_Exception *fe_add_exception(AST_Exception *e); - virtual AST_Attribute *fe_add_attribute(AST_Attribute *a); - virtual AST_Operation *fe_add_operation(AST_Operation *o); - virtual AST_Argument *fe_add_argument(AST_Argument *a); - virtual AST_Union *fe_add_union(AST_Union *u); - virtual AST_UnionBranch *fe_add_union_branch(AST_UnionBranch *b); - virtual AST_Structure *fe_add_structure(AST_Structure *s); - virtual AST_Field *fe_add_field(AST_Field *f); - virtual AST_Enum *fe_add_enum(AST_Enum *e); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); - virtual AST_Typedef *fe_add_typedef(AST_Typedef *t); - virtual UTL_StrList *fe_add_context(UTL_StrList *c); - virtual UTL_NameList *fe_add_exceptions(UTL_NameList *e); - virtual AST_Sequence *fe_add_sequence(AST_Sequence *s); - virtual AST_String *fe_add_string(AST_String *s); - virtual AST_Array *fe_add_array(AST_Array *a); - virtual AST_Native *fe_add_native (AST_Native *n); + // Scope Management Protocol. + virtual AST_PredefinedType *fe_add_predefined_type (AST_PredefinedType *t); + + virtual AST_Module *fe_add_module (AST_Module *m); + + virtual AST_Interface *fe_add_interface (AST_Interface *i); + + virtual AST_InterfaceFwd *fe_add_interface_fwd (AST_InterfaceFwd *i); + + virtual AST_Constant *fe_add_constant (AST_Constant *c); + + virtual AST_Exception *fe_add_exception (AST_Exception *e); + + virtual AST_Attribute *fe_add_attribute (AST_Attribute *a); + + virtual AST_Operation *fe_add_operation (AST_Operation *o); + + virtual AST_Argument *fe_add_argument (AST_Argument *a); + + virtual AST_Union *fe_add_union (AST_Union *u); + + virtual AST_UnionBranch *fe_add_union_branch (AST_UnionBranch *b); + + virtual AST_Structure *fe_add_structure (AST_Structure *s); + + virtual AST_Field *fe_add_field (AST_Field *f); + + virtual AST_Enum *fe_add_enum (AST_Enum *e); + + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); + + virtual AST_Typedef *fe_add_typedef (AST_Typedef *t); + + virtual UTL_StrList *fe_add_context (UTL_StrList *c); + + virtual UTL_NameList *fe_add_exceptions (UTL_NameList *e); + + virtual AST_Sequence *fe_add_sequence (AST_Sequence *s); + + virtual AST_String *fe_add_string (AST_String *s); + + virtual AST_Array *fe_add_array (AST_Array *a); + + virtual AST_Native *fe_add_native (AST_Native *n); }; // Active iterator for a UTL_Scope node class TAO_IDL_FE_Export UTL_ScopeActiveIterator { public: - // Operations + // Operations. - // Constructor(s) - UTL_ScopeActiveIterator(UTL_Scope *s, UTL_Scope::ScopeIterationKind ik); + // Constructor. + UTL_ScopeActiveIterator (UTL_Scope *s, + UTL_Scope::ScopeIterationKind ik); - // Advance to next item - virtual void next(); + // Advance to next item. + virtual void next (void); - // Get current item - virtual AST_Decl *item(); + // Get current item. + virtual AST_Decl *item (void); // Have we iterated over entire scope? - virtual idl_bool is_done(); + virtual idl_bool is_done (void); // What kind of iterator is this? - virtual UTL_Scope::ScopeIterationKind iteration_kind(); + virtual UTL_Scope::ScopeIterationKind iteration_kind (void); // What stage are we in with this iterator? - virtual UTL_Scope::ScopeIterationKind iteration_stage(); + virtual UTL_Scope::ScopeIterationKind iteration_stage (void); private: - // Data - UTL_Scope *iter_source; // Scope to iterate over + // Data. + + UTL_Scope *iter_source; // Scope to iterate over UTL_Scope::ScopeIterationKind ik; // What kind of iteration UTL_Scope::ScopeIterationKind stage; // What stage - long il; // What location in stage + long il; // What location in stage }; #endif // _UTL_SCOPE_UTL_SCOPE_HH diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp index f95903f7a47..877de3ae1e8 100644 --- a/TAO/TAO_IDL/util/utl_scope.cpp +++ b/TAO/TAO_IDL/util/utl_scope.cpp @@ -205,7 +205,7 @@ iter_lookup_by_name_local (AST_Decl *d, } } -// Constructors +// Constructors. UTL_Scope::UTL_Scope (void) : pd_scope_node_type (AST_Decl::NT_module), @@ -241,7 +241,12 @@ UTL_Scope::UTL_Scope (AST_Decl::NodeType nt) { } -// Private operations +// Destructor. +UTL_Scope::~UTL_Scope (void) +{ +} + +// Private operations. static AST_Decl * add_type (AST_Type *type) @@ -316,13 +321,13 @@ UTL_Scope::lookup_for_add (AST_Decl *d, 0); } -// Public operations +// Public operations. // Narrowing IMPL_NARROW_METHODS0(UTL_Scope) IMPL_NARROW_FROM_SCOPE(UTL_Scope) -// Scope Management Protocol +// Scope Management Protocol. // // All members of the protocol defined in UTL_Scope simply return the node // and don't do a thing. These members are simply dummies to retain @@ -417,7 +422,7 @@ UTL_Scope::add_attribute (AST_Attribute *a) { if (a == 0) { - return NULL; + return 0; } a->set_added (I_TRUE); @@ -643,7 +648,7 @@ UTL_Scope::add_native (AST_Native *n) return n; } -// Protected Front End Scope Management Protocol +// Protected Front End Scope Management Protocol. // // All members of the protocol defined in UTL_Scope simply return NULL // and don't do a thing. This ensures that runtime errors will discover @@ -893,7 +898,7 @@ UTL_Scope::call_add (void) // Private lookup mechanism. -// Lookup the node for a primitive (built in) type +// Lookup the node for a primitive (built in) type. AST_Decl * UTL_Scope::lookup_primitive_type (AST_Expression::ExprType et) { @@ -1010,8 +1015,8 @@ UTL_Scope::look_in_inherited (UTL_ScopedName *e, AST_Decl *d = 0; AST_Decl *d_before = 0; AST_Interface *i = AST_Interface::narrow_from_scope (this); - AST_Interface **is; - long nis; + AST_Interface **is = 0; + long nis = -1; // This scope is not an interface. if (i == 0) @@ -1027,7 +1032,7 @@ UTL_Scope::look_in_inherited (UTL_ScopedName *e, return 0; } - //OK, loop through inherited interfaces. + // OK, loop through inherited interfaces. // (Don't leave the inheritance hierarchy, no module or global ...) // Find all and report ambiguous results as error. @@ -1036,11 +1041,12 @@ UTL_Scope::look_in_inherited (UTL_ScopedName *e, { d = (*is)->lookup_by_name (e, treat_as_ref, - 0 /* not in_parent */); + 0 /* not in parent */); if (d != 0) { if (d_before == 0) - { // First result found. + { + // First result found. d_before = d; } else @@ -1168,7 +1174,7 @@ UTL_Scope::lookup_by_name_local (Identifier *e, } } -// Implements lookup by name for scoped names +// Implements lookup by name for scoped names. AST_Decl * UTL_Scope::lookup_by_name (UTL_ScopedName *e, idl_bool treat_as_ref, @@ -1177,7 +1183,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, AST_Decl *d = 0; UTL_Scope *t = 0; - // Empty name? error + // Empty name? Error. if (e == 0) { return 0; @@ -1239,8 +1245,8 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, { // Special case for scope which is an interface. We have to look - // in the inherited interfaces as well.. - // Look before parent scopes ! + // in the inherited interfaces as well. + // Look before parent scopes. if (pd_scope_node_type == AST_Decl::NT_interface) { d = look_in_inherited (e, @@ -1271,7 +1277,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, } // If treat_as_ref is true and d is not NULL, add d to - // set of nodes referenced here + // set of nodes referenced here. if (treat_as_ref && d != 0) { Identifier *id = 0; @@ -1327,7 +1333,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, } } - // OK, now return whatever we found + // OK, now return whatever we found. return d; } @@ -1343,7 +1349,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, } // If treat_as_ref is true and d is not 0, add d to - // set of nodes referenced here + // set of nodes referenced here. if (treat_as_ref && d != 0) { add_to_referenced (d, @@ -1351,7 +1357,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, 0); } - // All OK, name fully resolved + // All OK, name fully resolved. if (d != 0) { return d; @@ -1806,9 +1812,9 @@ UTL_Scope::referenced (AST_Decl *e, return I_FALSE; } -// Redefinition of inherited virtual operations +// Redefinition of inherited virtual operations. -// AST Dumping +// AST Dumping. void UTL_Scope::dump (ostream &o) { @@ -1879,6 +1885,12 @@ UTL_Scope::dump (ostream &o) idl_global->indent ()->decrease (); } +int +UTL_Scope::accept (ast_visitor *visitor) +{ + return visitor->visit_scope (this); +} + // How many entries are defined? unsigned long UTL_Scope::nmembers (void) |