00001
00002
00003
00004 #include "ifr_removing_visitor.h"
00005 #include "utl_scope.h"
00006 #include "ast_root.h"
00007
00008 ACE_RCSID (IFR_Service,
00009 ifr_removing_visitor,
00010 "ifr_removing_visitor.cpp,v 1.9 2003/11/18 14:55:09 smcqueen Exp")
00011
00012 ifr_removing_visitor::ifr_removing_visitor (void)
00013 {
00014 }
00015
00016 ifr_removing_visitor::~ifr_removing_visitor (void)
00017 {
00018 }
00019
00020 int
00021 ifr_removing_visitor::visit_scope (UTL_Scope *node)
00022 {
00023
00024 if (node->nmembers () > 0)
00025 {
00026
00027 UTL_ScopeActiveIterator si (node,
00028 UTL_Scope::IK_decls);
00029
00030 AST_Decl *d = 0;
00031
00032 ACE_DECLARE_NEW_CORBA_ENV;
00033 ACE_TRY
00034 {
00035
00036 while (!si.is_done ())
00037 {
00038 d = si.item ();
00039
00040 if (d == 0)
00041 {
00042 ACE_ERROR_RETURN ((
00043 LM_ERROR,
00044 ACE_TEXT ("(%N:%l) ifr_removing_visitor::visit_scope -")
00045 ACE_TEXT (" bad node in this scope\n")
00046 ),
00047 -1
00048 );
00049 }
00050
00051 if (d->node_type () == AST_Decl::NT_pre_defined)
00052 {
00053
00054 si.next ();
00055 continue;
00056 }
00057
00058 CORBA::Contained_var top_level =
00059 be_global->repository ()->lookup_id (d->repoID ()
00060 ACE_ENV_ARG_PARAMETER);
00061 ACE_TRY_CHECK;
00062
00063 if (!CORBA::is_nil (top_level.in ()))
00064 {
00065
00066
00067
00068 top_level->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00069 ACE_TRY_CHECK;
00070 }
00071
00072 si.next ();
00073 }
00074 }
00075 ACE_CATCHANY
00076 {
00077 ACE_PRINT_EXCEPTION (
00078 ACE_ANY_EXCEPTION,
00079 ACE_TEXT ("ifr_removing_visitor::visit_scope")
00080 );
00081
00082 return -1;
00083 }
00084 ACE_ENDTRY;
00085 }
00086
00087 return 0;
00088 }
00089
00090 int
00091 ifr_removing_visitor::visit_root (AST_Root *node)
00092 {
00093 ACE_DECLARE_NEW_CORBA_ENV;
00094 ACE_TRY
00095 {
00096 CORBA::Container_var new_scope =
00097 CORBA::Container::_narrow (be_global->repository ()
00098 ACE_ENV_ARG_PARAMETER);
00099 ACE_TRY_CHECK;
00100
00101 if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
00102 {
00103 ACE_ERROR_RETURN ((
00104 LM_ERROR,
00105 ACE_TEXT ("(%N:%l) ifr_removing_visitor::visit_root -")
00106 ACE_TEXT (" scope push failed\n")
00107 ),
00108 -1
00109 );
00110 }
00111
00112 if (this->visit_scope (node) == -1)
00113 {
00114 ACE_ERROR_RETURN ((
00115 LM_ERROR,
00116 ACE_TEXT ("(%N:%l) ifr_removing_visitor::visit_root -")
00117 ACE_TEXT (" visit_scope failed\n")
00118 ),
00119 -1
00120 );
00121 }
00122
00123 CORBA::Container_ptr tmp = CORBA::Container::_nil ();
00124
00125 if (be_global->ifr_scopes ().pop (tmp) != 0)
00126 {
00127 ACE_ERROR_RETURN ((
00128 LM_ERROR,
00129 ACE_TEXT ("(%N:%l) ifr_removing_visitor::visit_root -")
00130 ACE_TEXT (" scope pop failed\n")
00131 ),
00132 -1
00133 );
00134 }
00135 }
00136 ACE_CATCHANY
00137 {
00138 ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00139 ACE_TEXT ("visit_root"));
00140
00141 return -1;
00142 }
00143 ACE_ENDTRY;
00144
00145 return 0;
00146 }
00147