00001
00002
00003
00004 #include "ast_argument.h"
00005 #include "ast_array.h"
00006 #include "ast_attribute.h"
00007 #include "ast_component.h"
00008 #include "ast_component_fwd.h"
00009 #include "ast_provides.h"
00010 #include "ast_uses.h"
00011 #include "ast_publishes.h"
00012 #include "ast_emits.h"
00013 #include "ast_consumes.h"
00014 #include "ast_constant.h"
00015 #include "ast_enum.h"
00016 #include "ast_eventtype.h"
00017 #include "ast_eventtype_fwd.h"
00018 #include "ast_exception.h"
00019 #include "ast_expression.h"
00020 #include "ast_finder.h"
00021 #include "ast_field.h"
00022 #include "ast_home.h"
00023 #include "ast_interface.h"
00024 #include "ast_interface_fwd.h"
00025 #include "ast_module.h"
00026 #include "ast_native.h"
00027 #include "ast_operation.h"
00028 #include "ast_predefined_type.h"
00029 #include "ast_root.h"
00030 #include "ast_sequence.h"
00031 #include "ast_string.h"
00032 #include "ast_structure.h"
00033 #include "ast_typedef.h"
00034 #include "ast_union.h"
00035 #include "ast_union_fwd.h"
00036 #include "ast_valuebox.h"
00037 #include "ast_valuetype.h"
00038 #include "ast_valuetype_fwd.h"
00039 #include "utl_identifier.h"
00040 #include "utl_string.h"
00041 #include "utl_exceptlist.h"
00042 #include "fe_extern.h"
00043 #include "nr_extern.h"
00044
00045 #include "ifr_adding_visitor.h"
00046 #include "ifr_adding_visitor_operation.h"
00047 #include "ifr_adding_visitor_structure.h"
00048 #include "ifr_adding_visitor_exception.h"
00049 #include "ifr_adding_visitor_union.h"
00050
00051 #include "tao/IFR_Client/IFR_ComponentsC.h"
00052
00053 #include "ace/Vector_T.h"
00054
00055 ifr_adding_visitor::ifr_adding_visitor (
00056 AST_Decl *scope,
00057 bool in_reopened,
00058 bool allow_duplicate_typedefs)
00059 : scope_ (scope),
00060 in_reopened_ (in_reopened),
00061 allow_duplicate_typedefs_ (allow_duplicate_typedefs)
00062 {
00063 }
00064
00065 ifr_adding_visitor::~ifr_adding_visitor (void)
00066 {
00067 }
00068
00069 int
00070 ifr_adding_visitor::visit_scope (UTL_Scope *node)
00071 {
00072
00073 if (node->nmembers () > 0)
00074 {
00075
00076 UTL_ScopeActiveIterator si (node,
00077 UTL_Scope::IK_decls);
00078
00079 AST_Decl *d = 0;
00080
00081
00082 while (!si.is_done ())
00083 {
00084 d = si.item ();
00085
00086 if (d == 0)
00087 {
00088 ACE_ERROR_RETURN ((
00089 LM_ERROR,
00090 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00091 ACE_TEXT (" bad node in this scope\n")
00092 ),
00093 -1
00094 );
00095 }
00096
00097
00098
00099 if (d->node_type () == AST_Decl::NT_pre_defined)
00100 {
00101 si.next ();
00102 continue;
00103 }
00104
00105 if (d->ast_accept (this) == -1)
00106 {
00107 ACE_ERROR_RETURN ((
00108 LM_ERROR,
00109 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_scope -")
00110 ACE_TEXT (" failed to accept visitor\n")
00111 ),
00112 -1
00113 );
00114 }
00115
00116 si.next ();
00117 }
00118 }
00119
00120 return 0;
00121 }
00122
00123 int
00124 ifr_adding_visitor::visit_predefined_type (AST_PredefinedType *node)
00125 {
00126 try
00127 {
00128 this->ir_current_ =
00129 be_global->repository ()->get_primitive (
00130 this->predefined_type_to_pkind (node)
00131 );
00132 }
00133 catch (const CORBA::Exception& ex)
00134 {
00135 ex._tao_print_exception (ACE_TEXT ("visit_predefined_type"));
00136
00137 return -1;
00138 }
00139
00140 return 0;
00141 }
00142
00143 int
00144 ifr_adding_visitor::visit_module (AST_Module *node)
00145 {
00146 if (node->imported () && !be_global->do_included_files ())
00147 {
00148 return 0;
00149 }
00150
00151 CORBA::Container_var new_def;
00152
00153 try
00154 {
00155
00156
00157 CORBA::Contained_var prev_def =
00158 be_global->repository ()->lookup_id (node->repoID ());
00159
00160 if (CORBA::is_nil (prev_def.in ()))
00161 {
00162
00163 CORBA::Container_ptr container =
00164 CORBA::Container::_nil ();
00165
00166 if (be_global->ifr_scopes ().top (container) == 0)
00167 {
00168 new_def = container->create_module (
00169 node->repoID (),
00170 node->local_name ()->get_string (),
00171 node->version ()
00172 );
00173 }
00174 else
00175 {
00176 ACE_ERROR_RETURN ((
00177 LM_ERROR,
00178 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00179 ACE_TEXT (" scope stack is empty\n")
00180 ),
00181 -1
00182 );
00183 }
00184 }
00185 else
00186 {
00187 CORBA::DefinitionKind kind =
00188 prev_def->def_kind ();
00189
00190 if (kind == CORBA::dk_Module)
00191 {
00192
00193
00194
00195
00196
00197
00198 this->in_reopened_ = true;
00199
00200 new_def =
00201 CORBA::ComponentIR::Container::_narrow (prev_def.in ());
00202 }
00203 }
00204
00205 if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
00206 {
00207 ACE_ERROR_RETURN ((
00208 LM_ERROR,
00209 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00210 ACE_TEXT (" scope push failed\n")
00211 ),
00212 -1
00213 );
00214 }
00215
00216 if (this->visit_scope (node) == -1)
00217 {
00218 ACE_ERROR_RETURN ((
00219 LM_ERROR,
00220 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00221 ACE_TEXT (" visit_scope failed\n")
00222 ),
00223 -1
00224 );
00225 }
00226
00227 this->in_reopened_ = false;
00228 CORBA::Container_ptr tmp =
00229 CORBA::Container::_nil ();
00230
00231 if (be_global->ifr_scopes ().pop (tmp) != 0)
00232 {
00233 ACE_ERROR_RETURN ((
00234 LM_ERROR,
00235 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_module -")
00236 ACE_TEXT (" scope pop failed\n")
00237 ),
00238 -1
00239 );
00240 }
00241 }
00242 catch (const CORBA::Exception& ex)
00243 {
00244 ex._tao_print_exception (ACE_TEXT ("visit_module"));
00245
00246 return -1;
00247 }
00248
00249 return 0;
00250 }
00251
00252 int
00253 ifr_adding_visitor::visit_interface (AST_Interface *node)
00254 {
00255 if (node->imported () && !be_global->do_included_files ())
00256 {
00257 return 0;
00258 }
00259
00260 try
00261 {
00262
00263 CORBA::Contained_var prev_def =
00264 be_global->repository ()->lookup_id (node->repoID ());
00265
00266
00267 if (CORBA::is_nil (prev_def.in ()))
00268 {
00269 int status = this->create_interface_def (node);
00270
00271 return status;
00272 }
00273 else
00274 {
00275
00276
00277
00278
00279
00280 if (node->is_defined () && !node->ifr_added ())
00281 {
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 if (!node->ifr_fwd_added () && !node->imported ())
00297 {
00298 CORBA::DefinitionKind kind = prev_def->def_kind ();
00299
00300 if (kind == CORBA::dk_Interface)
00301 {
00302 CORBA::InterfaceDef_var iface =
00303 CORBA::InterfaceDef::_narrow (prev_def.in ());
00304
00305 CORBA::ContainedSeq_var contents =
00306 iface->contents (CORBA::dk_all, true);
00307
00308 for (CORBA::ULong i = 0; i < contents->length (); ++i)
00309 {
00310 contents[i]->destroy ();
00311 }
00312 }
00313 else
00314 {
00315
00316
00317 return this->create_interface_def (node);
00318 }
00319 }
00320
00321 CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
00322
00323 CORBA::InterfaceDefSeq bases (n_parents);
00324 bases.length (n_parents);
00325 CORBA::Contained_var result;
00326
00327 AST_Type **parents = node->inherits ();
00328
00329
00330 for (CORBA::ULong i = 0; i < n_parents; ++i)
00331 {
00332 result =
00333 be_global->repository ()->lookup_id (parents[i]->repoID ());
00334
00335
00336
00337
00338
00339
00340 if (CORBA::is_nil (result.in ()))
00341 {
00342 this->ir_current_ =
00343 CORBA::IDLType::_narrow (prev_def.in ());
00344
00345 return 0;
00346 }
00347
00348 bases[i] =
00349 CORBA::InterfaceDef::_narrow (result.in ());
00350
00351 if (CORBA::is_nil (bases[i]))
00352 {
00353 ACE_ERROR_RETURN ((
00354 LM_ERROR,
00355 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00356 ACE_TEXT ("visit_interface -")
00357 ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
00358 ),
00359 -1
00360 );
00361 }
00362 }
00363
00364 CORBA::InterfaceDef_var extant_def =
00365 CORBA::InterfaceDef::_narrow (prev_def. in ());
00366
00367 extant_def->base_interfaces (bases);
00368
00369 node->ifr_added (true);
00370
00371
00372 if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00373 {
00374 ACE_ERROR_RETURN ((
00375 LM_ERROR,
00376 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00377 ACE_TEXT ("visit_interface -")
00378 ACE_TEXT (" scope push failed\n")
00379 ),
00380 -1
00381 );
00382 }
00383
00384
00385 if (this->visit_scope (node) == -1)
00386 {
00387 ACE_ERROR_RETURN ((
00388 LM_ERROR,
00389 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00390 ACE_TEXT ("visit_interface -")
00391 ACE_TEXT (" visit_scope failed\n")
00392 ),
00393 -1
00394 );
00395 }
00396
00397
00398
00399
00400
00401
00402 this->ir_current_ =
00403 CORBA::IDLType::_duplicate (extant_def.in ());
00404
00405 CORBA::Container_ptr used_scope =
00406 CORBA::Container::_nil ();
00407
00408
00409 if (be_global->ifr_scopes ().pop (used_scope) != 0)
00410 {
00411 ACE_ERROR_RETURN ((
00412 LM_ERROR,
00413 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00414 ACE_TEXT ("visit_interface -")
00415 ACE_TEXT (" scope pop failed\n")
00416 ),
00417 -1
00418 );
00419 }
00420 }
00421 else
00422 {
00423
00424
00425
00426
00427
00428
00429 this->ir_current_ =
00430 CORBA::IDLType::_narrow (prev_def.in ());
00431 }
00432 }
00433 }
00434 catch (const CORBA::Exception& ex)
00435 {
00436 ex._tao_print_exception (ACE_TEXT ("visit_interface"));
00437
00438 return -1;
00439 }
00440
00441 return 0;
00442 }
00443
00444 int
00445 ifr_adding_visitor::visit_interface_fwd (AST_InterfaceFwd *node)
00446 {
00447 if (node->imported () && !be_global->do_included_files ())
00448 {
00449 return 0;
00450 }
00451
00452 AST_Interface *i = node->full_definition ();
00453
00454 try
00455 {
00456
00457 CORBA::Contained_var prev_def =
00458 be_global->repository ()->lookup_id (i->repoID ());
00459
00460 if (CORBA::is_nil (prev_def.in ()))
00461 {
00462
00463
00464
00465
00466
00467 CORBA::InterfaceDefSeq bases (0);
00468 bases.length (0);
00469
00470 CORBA::Container_ptr current_scope =
00471 CORBA::Container::_nil ();
00472
00473 if (be_global->ifr_scopes ().top (current_scope) == 0)
00474 {
00475 if (i->is_local ())
00476 {
00477 this->ir_current_ =
00478 current_scope->create_local_interface (
00479 i->repoID (),
00480 i->local_name ()->get_string (),
00481 i->version (),
00482 bases
00483 );
00484 }
00485 else
00486 {
00487 this->ir_current_ =
00488 current_scope->create_interface (
00489 i->repoID (),
00490 i->local_name ()->get_string (),
00491 i->version (),
00492 bases
00493 );
00494 }
00495
00496 }
00497 else
00498 {
00499 ACE_ERROR_RETURN ((
00500 LM_ERROR,
00501 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00502 ACE_TEXT ("visit_interface_fwd -")
00503 ACE_TEXT (" scope stack is empty\n")
00504 ),
00505 -1
00506 );
00507 }
00508
00509 node->ifr_added (true);
00510 i->ifr_fwd_added (true);
00511 }
00512
00513 }
00514 catch (const CORBA::Exception& ex)
00515 {
00516 ex._tao_print_exception (ACE_TEXT ("visit_interface_fwd"));
00517
00518 return -1;
00519 }
00520
00521 return 0;
00522 }
00523
00524 int
00525 ifr_adding_visitor::visit_valuebox (AST_ValueBox *node)
00526 {
00527 if (node->imported () && !be_global->do_included_files ())
00528 {
00529 return 0;
00530 }
00531
00532 try
00533 {
00534 this->element_type (node->boxed_type ());
00535
00536 CORBA::Container_ptr current_scope =
00537 CORBA::Container::_nil ();
00538
00539 if (be_global->ifr_scopes ().top (current_scope) == 0)
00540 {
00541 this->ir_current_ =
00542 current_scope->create_value_box (
00543 node->repoID (),
00544 node->local_name ()->get_string (),
00545 node->version (),
00546 this->ir_current_.in ()
00547 );
00548 }
00549 else
00550 {
00551 ACE_ERROR_RETURN ((
00552 LM_ERROR,
00553 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_valuebox -")
00554 ACE_TEXT (" scope stack is empty\n")
00555 ),
00556 -1
00557 );
00558 }
00559
00560 node->ifr_added (true);
00561 }
00562 catch (const CORBA::Exception& ex)
00563 {
00564 ex._tao_print_exception (ACE_TEXT ("visit_valuebox"));
00565
00566 return -1;
00567 }
00568
00569 return 0;
00570 }
00571
00572 int
00573 ifr_adding_visitor::visit_valuetype (AST_ValueType *node)
00574 {
00575 if (node->imported () && !be_global->do_included_files ())
00576 {
00577 return 0;
00578 }
00579
00580 try
00581 {
00582
00583 CORBA::Contained_var prev_def =
00584 be_global->repository ()->lookup_id (node->repoID ());
00585
00586
00587 if (CORBA::is_nil (prev_def.in ()))
00588 {
00589 int status = this->create_value_def (node);
00590
00591 return status;
00592 }
00593 else
00594 {
00595
00596
00597
00598
00599
00600 if (node->is_defined () && !node->ifr_added ())
00601 {
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 if (!node->ifr_fwd_added ())
00617 {
00618 CORBA::DefinitionKind kind =
00619 prev_def->def_kind ();
00620
00621 if (kind == CORBA::dk_Value)
00622 {
00623 CORBA::ValueDef_var value =
00624 CORBA::ValueDef::_narrow (prev_def.in ());
00625
00626 CORBA::ContainedSeq_var contents =
00627 value->contents (CORBA::dk_all,
00628 1);
00629
00630 CORBA::ULong length = contents->length ();
00631
00632 for (CORBA::ULong i = 0; i < length; ++i)
00633 {
00634 contents[i]->destroy ();
00635 }
00636 }
00637 else
00638 {
00639 prev_def->destroy ();
00640
00641 int status =
00642 this->create_value_def (node);
00643
00644 return status;
00645 }
00646 }
00647
00648
00649
00650 CORBA::ExtValueDef_var extant_def =
00651 CORBA::ExtValueDef::_narrow (prev_def. in ());
00652
00653
00654
00655 CORBA::ValueDef_var base_vt;
00656 this->fill_base_value (base_vt.out (),
00657 node);
00658
00659 extant_def->base_value (base_vt.in ());
00660
00661
00662
00663 CORBA::ValueDefSeq abstract_base_values;
00664 this->fill_abstract_base_values (abstract_base_values,
00665 node);
00666
00667 extant_def->abstract_base_values (abstract_base_values);
00668
00669
00670
00671 CORBA::InterfaceDefSeq supported;
00672 this->fill_supported_interfaces (supported,
00673 node);
00674
00675 extant_def->supported_interfaces (supported);
00676
00677
00678
00679 CORBA::ExtInitializerSeq initializers;
00680 this->fill_initializers (initializers,
00681 node);
00682
00683 extant_def->ext_initializers (initializers);
00684
00685
00686
00687 extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ()));
00688
00689 extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ()));
00690
00691 extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ()));
00692
00693 node->ifr_added (true);
00694
00695
00696
00697 if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00698 {
00699 ACE_ERROR_RETURN ((
00700 LM_ERROR,
00701 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00702 ACE_TEXT ("visit_valuetype -")
00703 ACE_TEXT (" scope push failed\n")
00704 ),
00705 -1
00706 );
00707 }
00708
00709
00710 if (this->visit_scope (node) == -1)
00711 {
00712 ACE_ERROR_RETURN ((
00713 LM_ERROR,
00714 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00715 ACE_TEXT ("visit_valuetype -")
00716 ACE_TEXT (" visit_scope failed\n")
00717 ),
00718 -1
00719 );
00720 }
00721
00722
00723
00724
00725
00726
00727 this->ir_current_ =
00728 CORBA::IDLType::_duplicate (extant_def.in ());
00729
00730 CORBA::Container_ptr used_scope =
00731 CORBA::Container::_nil ();
00732
00733
00734 if (be_global->ifr_scopes ().pop (used_scope) != 0)
00735 {
00736 ACE_ERROR_RETURN ((
00737 LM_ERROR,
00738 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00739 ACE_TEXT ("visit_valuetype -")
00740 ACE_TEXT (" scope pop failed\n")
00741 ),
00742 -1
00743 );
00744 }
00745 }
00746 else
00747 {
00748
00749
00750
00751
00752
00753
00754 this->ir_current_ =
00755 CORBA::IDLType::_narrow (prev_def.in ());
00756 }
00757 }
00758 }
00759 catch (const CORBA::Exception& ex)
00760 {
00761 ex._tao_print_exception (ACE_TEXT ("visit_valuetype"));
00762
00763 return -1;
00764 }
00765
00766 return 0;
00767 }
00768
00769 int
00770 ifr_adding_visitor::visit_valuetype_fwd (AST_ValueTypeFwd *node)
00771 {
00772 if (node->imported () && !be_global->do_included_files ())
00773 {
00774 return 0;
00775 }
00776
00777 AST_Interface *v = node->full_definition ();
00778
00779 try
00780 {
00781
00782 CORBA::Contained_var prev_def =
00783 be_global->repository ()->lookup_id (v->repoID ());
00784
00785 if (CORBA::is_nil (prev_def.in ()))
00786 {
00787
00788
00789
00790
00791
00792 CORBA::ValueDefSeq abstract_bases (0);
00793 abstract_bases.length (0);
00794 CORBA::InterfaceDefSeq supported (0);
00795 supported.length (0);
00796 CORBA::InitializerSeq initializers (0);
00797 initializers.length (0);
00798
00799 CORBA::Container_ptr current_scope =
00800 CORBA::Container::_nil ();
00801
00802 CORBA::Boolean abstract =
00803 static_cast<CORBA::Boolean> (v->is_abstract ());
00804
00805 if (be_global->ifr_scopes ().top (current_scope) == 0)
00806 {
00807 this->ir_current_ =
00808 current_scope->create_value (
00809 v->repoID (),
00810 v->local_name ()->get_string (),
00811 v->version (),
00812 0,
00813 abstract,
00814 CORBA::ValueDef::_nil (),
00815 0,
00816 abstract_bases,
00817 supported,
00818 initializers
00819 );
00820 }
00821 else
00822 {
00823 ACE_ERROR_RETURN ((
00824 LM_ERROR,
00825 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00826 ACE_TEXT ("visit_valuetype_fwd -")
00827 ACE_TEXT (" scope stack is empty\n")
00828 ),
00829 -1
00830 );
00831 }
00832
00833 node->ifr_added (true);
00834 v->ifr_fwd_added (true);
00835 }
00836 }
00837 catch (const CORBA::Exception& ex)
00838 {
00839 ex._tao_print_exception (ACE_TEXT ("visit_valuetype_fwd"));
00840
00841 return -1;
00842 }
00843
00844 return 0;
00845 }
00846
00847 int
00848 ifr_adding_visitor::visit_component (AST_Component *node)
00849 {
00850 if (node->imported () && !be_global->do_included_files ())
00851 {
00852 return 0;
00853 }
00854
00855 try
00856 {
00857
00858 CORBA::Contained_var prev_def =
00859 be_global->repository ()->lookup_id (node->repoID ());
00860
00861
00862 if (CORBA::is_nil (prev_def.in ()))
00863 {
00864 int status = this->create_component_def (node);
00865
00866 return status;
00867 }
00868 else
00869 {
00870
00871
00872
00873
00874
00875 if (node->is_defined () && !node->ifr_added ())
00876 {
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 if (!node->ifr_fwd_added ())
00892 {
00893 CORBA::DefinitionKind kind =
00894 prev_def->def_kind ();
00895
00896 if (kind == CORBA::dk_Component)
00897 {
00898 CORBA::ComponentIR::ComponentDef_var value =
00899 CORBA::ComponentIR::ComponentDef::_narrow (
00900 prev_def.in ()
00901 );
00902
00903 CORBA::ContainedSeq_var contents =
00904 value->contents (CORBA::dk_all,
00905 1);
00906
00907 CORBA::ULong length = contents->length ();
00908
00909 for (CORBA::ULong i = 0; i < length; ++i)
00910 {
00911 contents[i]->destroy ();
00912 }
00913 }
00914 else
00915 {
00916 prev_def->destroy ();
00917
00918 int status =
00919 this->create_component_def (node);
00920
00921 return status;
00922 }
00923 }
00924
00925
00926
00927 CORBA::ComponentIR::ComponentDef_var extant_def =
00928 CORBA::ComponentIR::ComponentDef::_narrow (
00929 prev_def.in ()
00930 );
00931
00932 CORBA::InterfaceDefSeq supported_interfaces;
00933 this->fill_supported_interfaces (supported_interfaces,
00934 node);
00935
00936 extant_def->supported_interfaces (supported_interfaces);
00937
00938 CORBA::ComponentIR::ComponentDef_var base_component;
00939 this->fill_base_component (base_component.out (),
00940 node);
00941
00942 extant_def->base_component (base_component.in ());
00943
00944 node->ifr_added (true);
00945
00946
00947
00948 if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
00949 {
00950 ACE_ERROR_RETURN ((
00951 LM_ERROR,
00952 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00953 ACE_TEXT ("visit_component -")
00954 ACE_TEXT (" scope push failed\n")
00955 ),
00956 -1
00957 );
00958 }
00959
00960
00961
00962
00963
00964
00965 this->ir_current_ =
00966 CORBA::IDLType::_duplicate (extant_def.in ());
00967
00968
00969 if (this->visit_scope (node) == -1)
00970 {
00971 ACE_ERROR_RETURN ((
00972 LM_ERROR,
00973 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00974 ACE_TEXT ("visit_component -")
00975 ACE_TEXT (" visit_scope failed\n")
00976 ),
00977 -1
00978 );
00979 }
00980
00981 CORBA::Container_ptr used_scope =
00982 CORBA::Container::_nil ();
00983
00984
00985 if (be_global->ifr_scopes ().pop (used_scope) != 0)
00986 {
00987 ACE_ERROR_RETURN ((
00988 LM_ERROR,
00989 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
00990 ACE_TEXT ("visit_interface -")
00991 ACE_TEXT (" scope pop failed\n")
00992 ),
00993 -1
00994 );
00995 }
00996 }
00997 else
00998 {
00999
01000
01001
01002
01003
01004
01005 this->ir_current_ =
01006 CORBA::IDLType::_narrow (prev_def.in ());
01007 }
01008 }
01009 }
01010 catch (const CORBA::Exception& ex)
01011 {
01012 ex._tao_print_exception (ACE_TEXT ("visit_component"));
01013
01014 return -1;
01015 }
01016
01017 return 0;
01018 }
01019
01020 int
01021 ifr_adding_visitor::visit_component_fwd (AST_ComponentFwd *node)
01022 {
01023 if (node->imported () && !be_global->do_included_files ())
01024 {
01025 return 0;
01026 }
01027
01028 AST_Component *c =
01029 AST_Component::narrow_from_decl (node->full_definition ());
01030
01031 try
01032 {
01033
01034 CORBA::Contained_var prev_def =
01035 be_global->repository ()->lookup_id (c->repoID ());
01036
01037 if (CORBA::is_nil (prev_def.in ()))
01038 {
01039 CORBA::Container_ptr current_scope =
01040 CORBA::Container::_nil ();
01041
01042 if (be_global->ifr_scopes ().top (current_scope) == 0)
01043 {
01044 CORBA::ComponentIR::Container_var ccm_scope =
01045 CORBA::ComponentIR::Container::_narrow (
01046 current_scope
01047 );
01048
01049
01050
01051
01052
01053
01054 CORBA::InterfaceDefSeq supported_interfaces;
01055 supported_interfaces.length (0);
01056 CORBA::ComponentIR::ComponentDef_var base_component;
01057
01058
01059 if (node->is_defined ())
01060 {
01061 this->fill_supported_interfaces (supported_interfaces,
01062 c);
01063
01064 this->fill_base_component (base_component.out (),
01065 c);
01066 }
01067
01068 this->ir_current_ =
01069 ccm_scope->create_component (
01070 c->repoID (),
01071 c->local_name ()->get_string (),
01072 c->version (),
01073 base_component.in (),
01074 supported_interfaces
01075 );
01076 }
01077 else
01078 {
01079 ACE_ERROR_RETURN ((
01080 LM_ERROR,
01081 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01082 ACE_TEXT ("visit_component_fwd -")
01083 ACE_TEXT (" scope stack is empty\n")
01084 ),
01085 -1
01086 );
01087 }
01088
01089 node->ifr_added (true);
01090 c->ifr_fwd_added (true);
01091 }
01092 }
01093 catch (const CORBA::Exception& ex)
01094 {
01095 ex._tao_print_exception (ACE_TEXT ("visit_component_fwd"));
01096
01097 return -1;
01098 }
01099
01100 return 0;
01101 }
01102
01103 int
01104 ifr_adding_visitor::visit_provides (AST_Provides *node)
01105 {
01106 ::CORBA::Contained_var contained =
01107 be_global->repository ()->lookup_id (
01108 node->provides_type ()->repoID ());
01109
01110 ::CORBA::InterfaceDef_var interface_type =
01111 ::CORBA::InterfaceDef::_narrow (contained.in ());
01112
01113 ::CORBA::ComponentIR::ComponentDef_var c =
01114 ::CORBA::ComponentIR::ComponentDef::_narrow (
01115 this->ir_current_.in ());
01116
01117 ACE_CString comp_str (c->_interface_repository_id ());
01118 char *local_name = node->local_name ()->get_string ();
01119 this->expand_id (comp_str, local_name);
01120
01121 ::CORBA::ComponentIR::ProvidesDef_var new_def =
01122 c->create_provides (comp_str.fast_rep (),
01123 local_name,
01124 node->provides_type ()->version (),
01125 interface_type.in ());
01126
01127 return 0;
01128 }
01129
01130 int
01131 ifr_adding_visitor::visit_uses (AST_Uses *node)
01132 {
01133 ::CORBA::Contained_var contained =
01134 be_global->repository ()->lookup_id (
01135 node->uses_type ()->repoID ());
01136
01137 ::CORBA::InterfaceDef_var interface_type =
01138 ::CORBA::InterfaceDef::_narrow (contained.in ());
01139
01140 ::CORBA::ComponentIR::ComponentDef_var c =
01141 ::CORBA::ComponentIR::ComponentDef::_narrow (
01142 this->ir_current_.in ());
01143
01144 ACE_CString comp_str (c->_interface_repository_id ());
01145 char *local_name = node->local_name ()->get_string ();
01146 this->expand_id (comp_str, local_name);
01147
01148 ::CORBA::ComponentIR::UsesDef_var new_def =
01149 c->create_uses (comp_str.fast_rep (),
01150 local_name,
01151 node->uses_type ()->version (),
01152 interface_type.in (),
01153 static_cast<CORBA::Boolean> (node->is_multiple ()));
01154
01155 return 0;
01156 }
01157
01158 int
01159 ifr_adding_visitor::visit_publishes (AST_Publishes *node)
01160 {
01161 ::CORBA::Contained_var contained =
01162 be_global->repository ()->lookup_id (
01163 node->publishes_type ()->repoID ());
01164
01165 ::CORBA::ComponentIR::EventDef_var event_type =
01166 ::CORBA::ComponentIR::EventDef::_narrow (contained.in ());
01167
01168 ::CORBA::ComponentIR::ComponentDef_var c =
01169 ::CORBA::ComponentIR::ComponentDef::_narrow (
01170 this->ir_current_.in ());
01171
01172 ACE_CString comp_str (c->_interface_repository_id ());
01173 char *local_name = node->local_name ()->get_string ();
01174 this->expand_id (comp_str, local_name);
01175
01176 ::CORBA::ComponentIR::PublishesDef_var new_def =
01177 c->create_publishes (comp_str.fast_rep (),
01178 local_name,
01179 node->publishes_type ()->version (),
01180 event_type.in ());
01181
01182 return 0;
01183 }
01184
01185 int
01186 ifr_adding_visitor::visit_emits (AST_Emits *node)
01187 {
01188 ::CORBA::Contained_var contained =
01189 be_global->repository ()->lookup_id (
01190 node->emits_type ()->repoID ());
01191
01192 ::CORBA::ComponentIR::EventDef_var event_type =
01193 ::CORBA::ComponentIR::EventDef::_narrow (contained.in ());
01194
01195 ::CORBA::ComponentIR::ComponentDef_var c =
01196 ::CORBA::ComponentIR::ComponentDef::_narrow (
01197 this->ir_current_.in ());
01198
01199 ACE_CString comp_str (c->_interface_repository_id ());
01200 char *local_name = node->local_name ()->get_string ();
01201 this->expand_id (comp_str, local_name);
01202
01203 ::CORBA::ComponentIR::EmitsDef_var new_def =
01204 c->create_emits (comp_str.fast_rep (),
01205 local_name,
01206 node->emits_type ()->version (),
01207 event_type.in ());
01208
01209 return 0;
01210 }
01211
01212 int
01213 ifr_adding_visitor::visit_consumes (AST_Consumes *node)
01214 {
01215 ::CORBA::Contained_var contained =
01216 be_global->repository ()->lookup_id (
01217 node->consumes_type ()->repoID ());
01218
01219 ::CORBA::ComponentIR::EventDef_var event_type =
01220 ::CORBA::ComponentIR::EventDef::_narrow (contained.in ());
01221
01222 ::CORBA::ComponentIR::ComponentDef_var c =
01223 ::CORBA::ComponentIR::ComponentDef::_narrow (
01224 this->ir_current_.in ());
01225
01226 ACE_CString comp_str (c->_interface_repository_id ());
01227 char *local_name = node->local_name ()->get_string ();
01228 this->expand_id (comp_str, local_name);
01229
01230 ::CORBA::ComponentIR::ConsumesDef_var new_def =
01231 c->create_consumes (comp_str.fast_rep (),
01232 local_name,
01233 node->consumes_type ()->version (),
01234 event_type.in ());
01235
01236 return 0;
01237 }
01238
01239 int
01240 ifr_adding_visitor::visit_eventtype (AST_EventType *node)
01241 {
01242 if (node->imported () && !be_global->do_included_files ())
01243 {
01244 return 0;
01245 }
01246
01247 try
01248 {
01249
01250 CORBA::Contained_var prev_def =
01251 be_global->repository ()->lookup_id (node->repoID ());
01252
01253
01254 if (CORBA::is_nil (prev_def.in ()))
01255 {
01256 int status = this->create_event_def (node);
01257
01258 return status;
01259 }
01260 else
01261 {
01262
01263
01264
01265
01266
01267 if (node->is_defined () && !node->ifr_added ())
01268 {
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283 if (!node->ifr_fwd_added ())
01284 {
01285 CORBA::DefinitionKind kind =
01286 prev_def->def_kind ();
01287
01288 if (kind == CORBA::dk_Value)
01289 {
01290 CORBA::ComponentIR::EventDef_var event =
01291 CORBA::ComponentIR::EventDef::_narrow (
01292 prev_def.in ()
01293 );
01294
01295 CORBA::ContainedSeq_var contents =
01296 event->contents (CORBA::dk_all,
01297 1);
01298
01299 CORBA::ULong length = contents->length ();
01300
01301 for (CORBA::ULong i = 0; i < length; ++i)
01302 {
01303 contents[i]->destroy ();
01304 }
01305 }
01306 else
01307 {
01308 prev_def->destroy ();
01309
01310 int status =
01311 this->create_event_def (node);
01312
01313 return status;
01314 }
01315 }
01316
01317
01318
01319 CORBA::ComponentIR::EventDef_var extant_def =
01320 CORBA::ComponentIR::EventDef::_narrow (prev_def. in ());
01321
01322
01323
01324 CORBA::ValueDef_var base_vt;
01325 this->fill_base_value (base_vt.out (),
01326 node);
01327
01328 extant_def->base_value (base_vt.in ());
01329
01330
01331
01332 CORBA::ValueDefSeq abstract_base_values;
01333 this->fill_abstract_base_values (abstract_base_values,
01334 node);
01335
01336 extant_def->abstract_base_values (abstract_base_values);
01337
01338
01339
01340 CORBA::InterfaceDefSeq supported;
01341 this->fill_supported_interfaces (supported,
01342 node);
01343
01344 extant_def->supported_interfaces (supported);
01345
01346
01347
01348 CORBA::ExtInitializerSeq initializers;
01349 this->fill_initializers (initializers,
01350 node);
01351
01352 extant_def->ext_initializers (initializers);
01353
01354
01355
01356 extant_def->is_abstract (static_cast<CORBA::Boolean> (node->is_abstract ()));
01357
01358 extant_def->is_truncatable (static_cast<CORBA::Boolean> (node->truncatable ()));
01359
01360 extant_def->is_custom (static_cast<CORBA::Boolean> (node->custom ()));
01361
01362 node->ifr_added (true);
01363
01364
01365
01366 if (be_global->ifr_scopes ().push (extant_def.in ()) != 0)
01367 {
01368 ACE_ERROR_RETURN ((
01369 LM_ERROR,
01370 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01371 ACE_TEXT ("visit_eventtype -")
01372 ACE_TEXT (" scope push failed\n")
01373 ),
01374 -1
01375 );
01376 }
01377
01378
01379 if (this->visit_scope (node) == -1)
01380 {
01381 ACE_ERROR_RETURN ((
01382 LM_ERROR,
01383 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01384 ACE_TEXT ("visit_eventtype -")
01385 ACE_TEXT (" visit_scope failed\n")
01386 ),
01387 -1
01388 );
01389 }
01390
01391
01392
01393
01394
01395
01396 this->ir_current_ =
01397 CORBA::IDLType::_duplicate (extant_def.in ());
01398
01399 CORBA::Container_ptr used_scope =
01400 CORBA::Container::_nil ();
01401
01402
01403 if (be_global->ifr_scopes ().pop (used_scope) != 0)
01404 {
01405 ACE_ERROR_RETURN ((
01406 LM_ERROR,
01407 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01408 ACE_TEXT ("visit_eventtype -")
01409 ACE_TEXT (" scope pop failed\n")
01410 ),
01411 -1
01412 );
01413 }
01414 }
01415 else
01416 {
01417
01418
01419
01420
01421
01422
01423 this->ir_current_ =
01424 CORBA::IDLType::_narrow (prev_def.in ());
01425 }
01426 }
01427 }
01428 catch (const CORBA::Exception& ex)
01429 {
01430 ex._tao_print_exception (ACE_TEXT ("visit_eventtype"));
01431
01432 return -1;
01433 }
01434
01435 return 0;
01436 }
01437
01438 int
01439 ifr_adding_visitor::visit_eventtype_fwd (AST_EventTypeFwd *node)
01440 {
01441 if (node->imported () && !be_global->do_included_files ())
01442 {
01443 return 0;
01444 }
01445
01446 AST_Interface *v = node->full_definition ();
01447
01448 try
01449 {
01450
01451 CORBA::Contained_var prev_def =
01452 be_global->repository ()->lookup_id (v->repoID ());
01453
01454 if (CORBA::is_nil (prev_def.in ()))
01455 {
01456
01457
01458
01459
01460
01461 CORBA::ValueDefSeq abstract_bases (0);
01462 abstract_bases.length (0);
01463 CORBA::InterfaceDefSeq supported (0);
01464 supported.length (0);
01465 CORBA::ExtInitializerSeq initializers (0);
01466 initializers.length (0);
01467
01468 CORBA::Container_ptr current_scope =
01469 CORBA::Container::_nil ();
01470
01471 if (be_global->ifr_scopes ().top (current_scope) == 0)
01472 {
01473 CORBA::ComponentIR::Container_var ccm_scope =
01474 CORBA::ComponentIR::Container::_narrow (
01475 current_scope
01476 );
01477
01478 CORBA::Boolean abstract =
01479 static_cast<CORBA::Boolean> (v->is_abstract ());
01480
01481 this->ir_current_ =
01482 ccm_scope->create_event (
01483 v->repoID (),
01484 v->local_name ()->get_string (),
01485 v->version (),
01486 0,
01487 abstract,
01488 CORBA::ValueDef::_nil (),
01489 0,
01490 abstract_bases,
01491 supported,
01492 initializers
01493 );
01494 }
01495 else
01496 {
01497 ACE_ERROR_RETURN ((
01498 LM_ERROR,
01499 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01500 ACE_TEXT ("visit_eventtype_fwd -")
01501 ACE_TEXT (" scope stack is empty\n")
01502 ),
01503 -1
01504 );
01505 }
01506
01507 node->ifr_added (true);
01508 v->ifr_fwd_added (true);
01509 }
01510 }
01511 catch (const CORBA::Exception& ex)
01512 {
01513 ex._tao_print_exception (ACE_TEXT ("visit_eventtype_fwd"));
01514
01515 return -1;
01516 }
01517
01518 return 0;
01519 }
01520
01521 int
01522 ifr_adding_visitor::visit_home (AST_Home *node)
01523 {
01524 if (node->imported () && !be_global->do_included_files ())
01525 {
01526 return 0;
01527 }
01528
01529 try
01530 {
01531
01532 CORBA::Contained_var prev_def =
01533 be_global->repository ()->lookup_id (node->repoID ());
01534
01535
01536 if (CORBA::is_nil (prev_def.in ()))
01537 {
01538 int status = this->create_home_def (node);
01539
01540 return status;
01541 }
01542 else
01543 {
01544
01545
01546
01547
01548
01549 if (node->is_defined () && !node->ifr_added ())
01550 {
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565 if (!node->ifr_fwd_added ())
01566 {
01567 CORBA::DefinitionKind kind =
01568 prev_def->def_kind ();
01569
01570 if (kind == CORBA::dk_Component)
01571 {
01572 CORBA::ComponentIR::HomeDef_var value =
01573 CORBA::ComponentIR::HomeDef::_narrow (
01574 prev_def.in ()
01575 );
01576
01577 CORBA::ContainedSeq_var contents =
01578 value->contents (CORBA::dk_all,
01579 1);
01580
01581 CORBA::ULong length = contents->length ();
01582
01583 for (CORBA::ULong i = 0; i < length; ++i)
01584 {
01585 contents[i]->destroy ();
01586 }
01587 }
01588 else
01589 {
01590 prev_def->destroy ();
01591
01592 int status =
01593 this->create_home_def (node);
01594
01595 return status;
01596 }
01597 }
01598
01599
01600
01601 }
01602 else
01603 {
01604
01605
01606
01607
01608
01609
01610 this->ir_current_ =
01611 CORBA::IDLType::_narrow (prev_def.in ());
01612 }
01613 }
01614 }
01615 catch (const CORBA::Exception& ex)
01616 {
01617 ex._tao_print_exception (ACE_TEXT ("visit_home"));
01618
01619 return -1;
01620 }
01621
01622 return 0;
01623 }
01624
01625 int
01626 ifr_adding_visitor::visit_structure (AST_Structure *node)
01627 {
01628 if (node->imported () && !be_global->do_included_files ())
01629 {
01630 return 0;
01631 }
01632
01633 try
01634 {
01635 CORBA::Contained_var prev_def =
01636 be_global->repository ()->lookup_id (node->repoID ());
01637
01638 if (CORBA::is_nil (prev_def.in ()))
01639 {
01640 ifr_adding_visitor_structure visitor (node);
01641 int retval = visitor.visit_structure (node);
01642
01643 if (retval == 0)
01644 {
01645 this->ir_current_ =
01646 CORBA::IDLType::_duplicate (visitor.ir_current ());
01647 }
01648
01649 return retval;
01650 }
01651 else
01652 {
01653 if (node->ifr_added ())
01654 {
01655
01656
01657 this->ir_current_ =
01658 CORBA::StructDef::_narrow (prev_def.in ());
01659 }
01660 else if (node->ifr_fwd_added ())
01661 {
01662
01663
01664
01665
01666 ifr_adding_visitor_structure visitor (node);
01667 int retval = visitor.visit_structure (node);
01668
01669 if (retval == 0)
01670 {
01671 this->ir_current_ =
01672 CORBA::IDLType::_duplicate (visitor.ir_current ());
01673 }
01674
01675 return retval;
01676 }
01677 else
01678 {
01679
01680
01681
01682
01683 prev_def->destroy ();
01684 return this->visit_structure (node);
01685 }
01686 }
01687 }
01688 catch (const CORBA::Exception& ex)
01689 {
01690 ex._tao_print_exception (
01691 ACE_TEXT (
01692 "ifr_adding_visitor::visit_structure"));
01693
01694 return -1;
01695 }
01696
01697 return 0;
01698 }
01699
01700 int
01701 ifr_adding_visitor::visit_structure_fwd (AST_StructureFwd *node)
01702 {
01703 if (node->imported () && !be_global->do_included_files ())
01704 {
01705 return 0;
01706 }
01707
01708 try
01709 {
01710 CORBA::Contained_var prev_def =
01711 be_global->repository ()->lookup_id (node->repoID ());
01712
01713 if (CORBA::is_nil (prev_def.in ()))
01714 {
01715 CORBA::StructMemberSeq dummyMembers;
01716 dummyMembers.length (0);
01717 CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
01718
01719 if (be_global->ifr_scopes ().top (current_scope) != 0)
01720 {
01721 ACE_ERROR_RETURN ((
01722 LM_ERROR,
01723 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01724 ACE_TEXT ("visit_structure_fwd -")
01725 ACE_TEXT (" scope stack is empty\n")
01726 ),
01727 -1
01728 );
01729 }
01730
01731 CORBA::StructDef_var struct_def =
01732 current_scope->create_struct (
01733 node->repoID (),
01734 node->local_name ()->get_string (),
01735 node->version (),
01736 dummyMembers
01737 );
01738
01739 node->full_definition ()->ifr_fwd_added (true);
01740 }
01741 }
01742 catch (const CORBA::Exception& ex)
01743 {
01744 ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::")
01745 ACE_TEXT ("visit_structure_fwd"));
01746
01747 return -1;
01748 }
01749
01750 return 0;
01751 }
01752
01753 int
01754 ifr_adding_visitor::visit_exception (AST_Exception *node)
01755 {
01756 if (node->imported () && !be_global->do_included_files ())
01757 {
01758 return 0;
01759 }
01760
01761 ifr_adding_visitor_exception visitor (node,
01762 this->in_reopened_);
01763
01764
01765
01766
01767 return visitor.visit_exception (node);
01768 }
01769
01770 int
01771 ifr_adding_visitor::visit_enum (AST_Enum *node)
01772 {
01773 if (node->imported () && !be_global->do_included_files ())
01774 {
01775 return 0;
01776 }
01777
01778 try
01779 {
01780
01781 CORBA::Contained_var prev_def =
01782 be_global->repository ()->lookup_id (node->repoID ());
01783
01784
01785 if (CORBA::is_nil (prev_def.in ()))
01786 {
01787 CORBA::ULong member_count =
01788 static_cast<CORBA::ULong> (node->member_count ());
01789
01790 CORBA::EnumMemberSeq members (member_count);
01791 members.length (member_count);
01792
01793 UTL_ScopedName *member_name = 0;
01794
01795
01796 for (CORBA::ULong i = 0; i < member_count; ++i)
01797 {
01798 member_name = node->value_to_name (i);
01799
01800 members[i] =
01801 CORBA::string_dup (
01802 member_name->last_component ()->get_string ()
01803 );
01804 }
01805
01806 CORBA::Container_ptr current_scope =
01807 CORBA::Container::_nil ();
01808
01809 if (be_global->ifr_scopes ().top (current_scope) == 0)
01810 {
01811 this->ir_current_ =
01812 current_scope->create_enum (
01813 node->repoID (),
01814 node->local_name ()->get_string (),
01815 node->version (),
01816 members
01817 );
01818 }
01819 else
01820 {
01821 ACE_ERROR_RETURN ((
01822 LM_ERROR,
01823 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_enum -")
01824 ACE_TEXT (" scope stack is empty\n")
01825 ),
01826 -1
01827 );
01828 }
01829
01830 node->ifr_added (true);
01831 }
01832 else
01833 {
01834
01835
01836
01837
01838 if (!node->ifr_added ())
01839 {
01840 prev_def->destroy ();
01841
01842 return this->visit_enum (node);
01843 }
01844
01845
01846
01847 this->ir_current_ =
01848 CORBA::EnumDef::_narrow (prev_def.in ());
01849 }
01850 }
01851 catch (const CORBA::Exception& ex)
01852 {
01853 ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::visit_enum"));
01854
01855 return -1;
01856 }
01857
01858 return 0;
01859 }
01860
01861 int
01862 ifr_adding_visitor::visit_operation (AST_Operation *node)
01863 {
01864 ifr_adding_visitor_operation visitor (node);
01865
01866 return visitor.visit_operation (node);
01867 }
01868
01869 int
01870 ifr_adding_visitor::visit_field (AST_Field *node)
01871 {
01872 AST_Decl *scope = ScopeAsDecl (node->defined_in ());
01873 AST_Decl::NodeType nt = scope->node_type ();
01874
01875 if (nt == AST_Decl::NT_valuetype || nt == AST_Decl::NT_eventtype)
01876 {
01877 return this->create_value_member (node);
01878 }
01879
01880 AST_Type *ft = AST_Type::narrow_from_decl (node->field_type ());
01881
01882 if (ft == 0)
01883 {
01884 ACE_ERROR_RETURN ((
01885 LM_ERROR,
01886 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01887 ACE_TEXT ("visit_field - ")
01888 ACE_TEXT ("Bad field type\n")
01889 ),
01890 -1
01891 );
01892 }
01893
01894 if (ft->ast_accept (this) == -1)
01895 {
01896 ACE_ERROR_RETURN ((
01897 LM_ERROR,
01898 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
01899 ACE_TEXT ("visit_field - ")
01900 ACE_TEXT ("failed to accept visitor\n")
01901 ),
01902 -1
01903 );
01904 }
01905
01906 return 0;
01907 }
01908
01909 int
01910 ifr_adding_visitor::visit_attribute (AST_Attribute *node)
01911 {
01912 ::CORBA::IDLType_var holder;
01913
01914 try
01915 {
01916 AST_Type *type = node->field_type ();
01917
01918
01919 holder =
01920 ::CORBA::IDLType::_duplicate (this->ir_current_.in ());
01921
01922
01923 this->get_referenced_type (type);
01924
01925 CORBA::AttributeMode mode =
01926 node->readonly () ? CORBA::ATTR_READONLY : CORBA::ATTR_NORMAL;
01927
01928 CORBA::ExceptionDefSeq get_exceptions;
01929 this->fill_get_exceptions (get_exceptions,
01930 node);
01931
01932 CORBA::ExceptionDefSeq set_exceptions;
01933 this->fill_set_exceptions (set_exceptions,
01934 node);
01935
01936 CORBA::Container_ptr current_scope =
01937 CORBA::Container::_nil ();
01938
01939 if (be_global->ifr_scopes ().top (current_scope) == 0)
01940 {
01941 CORBA::DefinitionKind kind =
01942 current_scope->def_kind ();
01943
01944 if (kind == CORBA::dk_Value || kind == CORBA::dk_Event)
01945 {
01946 CORBA::ExtValueDef_var value =
01947 CORBA::ExtValueDef::_narrow (current_scope);
01948
01949 CORBA::ExtAttributeDef_var new_def =
01950 value->create_ext_attribute (
01951 node->repoID (),
01952 node->local_name ()->get_string (),
01953 node->version (),
01954 this->ir_current_.in (),
01955 mode,
01956 get_exceptions,
01957 set_exceptions
01958 );
01959 }
01960 else
01961 {
01962
01963
01964 CORBA::InterfaceAttrExtension_var iface =
01965 CORBA::InterfaceAttrExtension::_narrow (current_scope);
01966
01967 CORBA::ExtAttributeDef_var new_def =
01968 iface->create_ext_attribute (
01969 node->repoID (),
01970 node->local_name ()->get_string (),
01971 node->version (),
01972 this->ir_current_.in (),
01973 mode,
01974 get_exceptions,
01975 set_exceptions
01976 );
01977 }
01978 }
01979 else
01980 {
01981 ACE_ERROR_RETURN ((
01982 LM_ERROR,
01983 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_attribute -")
01984 ACE_TEXT (" scope stack is empty\n")
01985 ),
01986 -1
01987 );
01988 }
01989 }
01990 catch (const CORBA::Exception& ex)
01991 {
01992 ex._tao_print_exception (ACE_TEXT ("visit_attribute"));
01993
01994 return -1;
01995 }
01996
01997
01998 this->ir_current_ =
01999 ::CORBA::IDLType::_duplicate (holder.in ());
02000
02001 return 0;
02002 }
02003
02004 int
02005 ifr_adding_visitor::visit_union (AST_Union *node)
02006 {
02007 if (node->imported () && !be_global->do_included_files ())
02008 {
02009 return 0;
02010 }
02011
02012 try
02013 {
02014 CORBA::Contained_var prev_def =
02015 be_global->repository ()->lookup_id (node->repoID ());
02016
02017 if (CORBA::is_nil (prev_def.in ()))
02018 {
02019 ifr_adding_visitor_union visitor (node);
02020 int retval = visitor.visit_union (node);
02021
02022 if (retval == 0)
02023 {
02024 this->ir_current_ =
02025 CORBA::IDLType::_duplicate (visitor.ir_current ());
02026 }
02027
02028 return retval;
02029 }
02030 else
02031 {
02032 if (node->ifr_added ())
02033 {
02034
02035
02036 this->ir_current_ =
02037 CORBA::UnionDef::_narrow (prev_def.in ());
02038 }
02039 else if (node->ifr_fwd_added ())
02040 {
02041
02042
02043
02044
02045 ifr_adding_visitor_union visitor (node);
02046 int retval = visitor.visit_union (node);
02047
02048 if (retval == 0)
02049 {
02050 this->ir_current_ =
02051 CORBA::IDLType::_duplicate (visitor.ir_current ());
02052 }
02053
02054 return retval;
02055 }
02056 else
02057 {
02058
02059
02060
02061
02062 prev_def->destroy ();
02063 return this->visit_union (node);
02064 }
02065 }
02066 }
02067 catch (const CORBA::Exception& ex)
02068 {
02069 ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::visit_union"));
02070
02071 return -1;
02072 }
02073
02074 return 0;
02075 }
02076
02077 int
02078 ifr_adding_visitor::visit_union_fwd (AST_UnionFwd *node)
02079 {
02080 if (node->imported () && !be_global->do_included_files ())
02081 {
02082 return 0;
02083 }
02084
02085 try
02086 {
02087 CORBA::Contained_var prev_def =
02088 be_global->repository ()->lookup_id (node->repoID ());
02089
02090 if (CORBA::is_nil (prev_def.in ()))
02091 {
02092 CORBA::UnionMemberSeq dummyMembers;
02093 dummyMembers.length (0);
02094 CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
02095
02096 if (be_global->ifr_scopes ().top (current_scope) != 0)
02097 {
02098 ACE_ERROR_RETURN ((
02099 LM_ERROR,
02100 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02101 ACE_TEXT ("visit_union_fwd -")
02102 ACE_TEXT (" scope stack is empty\n")
02103 ),
02104 -1
02105 );
02106 }
02107
02108 CORBA::UnionDef_var union_def =
02109 current_scope->create_union (
02110 node->repoID (),
02111 node->local_name ()->get_string (),
02112 node->version (),
02113 CORBA::IDLType::_nil (),
02114 dummyMembers
02115 );
02116
02117 node->full_definition ()->ifr_fwd_added (true);
02118 }
02119 }
02120 catch (const CORBA::Exception& ex)
02121 {
02122 ex._tao_print_exception (ACE_TEXT ("ifr_adding_visitor::")
02123 ACE_TEXT ("visit_union_fwd"));
02124
02125 return -1;
02126 }
02127
02128 return 0;
02129 }
02130
02131 int
02132 ifr_adding_visitor::visit_constant (AST_Constant *node)
02133 {
02134 if (node->imported () && !be_global->do_included_files ())
02135 {
02136 return 0;
02137 }
02138
02139 const char *id = node->repoID ();
02140
02141 try
02142 {
02143 CORBA::Contained_var prev_def =
02144 be_global->repository ()->lookup_id (id);
02145
02146
02147
02148
02149
02150
02151 if (!CORBA::is_nil (prev_def.in ()))
02152 {
02153
02154
02155
02156
02157 if (!node->ifr_added ())
02158 {
02159 prev_def->destroy ();
02160 }
02161 else
02162 {
02163
02164
02165 return 0;
02166 }
02167 }
02168
02169 AST_Expression::ExprType et = node->et ();
02170 AST_Expression *cv = node->constant_value ();
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180 if (et == AST_Expression::EV_enum)
02181 {
02182
02183
02184
02185 AST_Decl *enum_val =
02186 node->defined_in ()->lookup_by_name (cv->n (), true);
02187 AST_Decl *d = ScopeAsDecl (enum_val->defined_in ());
02188
02189 CORBA::Contained_var contained =
02190 be_global->repository ()->lookup_id (d->repoID ());
02191
02192 this->ir_current_ = CORBA::IDLType::_narrow (contained.in ());
02193 }
02194 else
02195 {
02196
02197
02198 CORBA::PrimitiveKind pkind = this->expr_type_to_pkind (et);
02199
02200 this->ir_current_ =
02201 be_global->repository ()->get_primitive (pkind);
02202 }
02203
02204 CORBA::Any any;
02205 this->load_any (cv->ev (), any);
02206
02207 CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
02208
02209 if (be_global->ifr_scopes ().top (current_scope) == 0)
02210 {
02211 CORBA::ConstantDef_var new_def =
02212 current_scope->create_constant (
02213 id,
02214 node->local_name ()->get_string (),
02215 node->version (),
02216 this->ir_current_.in (),
02217 any
02218 );
02219 }
02220 else
02221 {
02222 ACE_ERROR_RETURN ((
02223 LM_ERROR,
02224 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_constant -")
02225 ACE_TEXT (" scope stack is empty\n")
02226 ),
02227 -1
02228 );
02229 }
02230 }
02231 catch (const CORBA::Exception& ex)
02232 {
02233 ex._tao_print_exception (ACE_TEXT ("visit_constant"));
02234
02235 return -1;
02236 }
02237
02238 return 0;
02239 }
02240
02241 int
02242 ifr_adding_visitor::visit_array (AST_Array *node)
02243 {
02244 try
02245 {
02246 bool owned = false;
02247 AST_Type *bt = node->base_type ();
02248 UTL_Scope *bts = bt->defined_in ();
02249 UTL_Scope *ns = node->defined_in ();
02250
02251 if (bts == ns && !bt->ifr_added ())
02252 {
02253
02254
02255
02256
02257
02258
02259
02260 owned = true;
02261 }
02262
02263 this->element_type (bt, owned);
02264
02265 AST_Expression **dims = node->dims ();
02266
02267 for (unsigned long i = node->n_dims (); i > 0; --i)
02268 {
02269 this->ir_current_ =
02270 be_global->repository ()->create_array (
02271 dims[i - 1]->ev ()->u.ulval,
02272 this->ir_current_.in ()
02273 );
02274 }
02275 }
02276 catch (const CORBA::Exception& ex)
02277 {
02278 ex._tao_print_exception (ACE_TEXT ("visit_array"));
02279
02280 return -1;
02281 }
02282
02283 return 0;
02284 }
02285
02286 int
02287 ifr_adding_visitor::visit_sequence (AST_Sequence *node)
02288 {
02289 try
02290 {
02291 this->element_type (node->base_type ());
02292
02293 this->ir_current_ =
02294 be_global->repository ()->create_sequence (
02295 node->max_size ()->ev ()->u.ulval,
02296 this->ir_current_.in ()
02297 );
02298 }
02299 catch (const CORBA::Exception& ex)
02300 {
02301 ex._tao_print_exception (ACE_TEXT ("visit_sequence"));
02302
02303 return -1;
02304 }
02305
02306 return 0;
02307 }
02308
02309 int
02310 ifr_adding_visitor::visit_string (AST_String *node)
02311 {
02312 AST_Expression *ex = node->max_size ();
02313
02314 AST_Expression::AST_ExprValue *ev = ex->ev ();
02315
02316 CORBA::ULong bound = static_cast<CORBA::ULong> (ev->u.ulval);
02317
02318 try
02319 {
02320 if (node->node_type () == AST_Decl::NT_string)
02321 {
02322 this->ir_current_ =
02323 be_global->repository ()->create_string (bound);
02324 }
02325 else
02326 {
02327 this->ir_current_ =
02328 be_global->repository ()->create_wstring (bound);
02329 }
02330
02331 }
02332 catch (const CORBA::Exception& ex)
02333 {
02334 ex._tao_print_exception (ACE_TEXT ("visit_string"));
02335
02336 return -1;
02337 }
02338
02339 return 0;
02340 }
02341
02342 int
02343 ifr_adding_visitor::visit_typedef (AST_Typedef *node)
02344 {
02345 if (node->imported () && !be_global->do_included_files ())
02346 {
02347 return 0;
02348 }
02349
02350 try
02351 {
02352 this->element_type (node->base_type (), node->owns_base_type ());
02353
02354 CORBA::Container_ptr current_scope =
02355 CORBA::Container::_nil ();
02356
02357 if (be_global->ifr_scopes ().top (current_scope) == 0)
02358 {
02359 this->ir_current_ =
02360 current_scope->create_alias (
02361 node->repoID (),
02362 node->local_name ()->get_string (),
02363 node->version (),
02364 this->ir_current_.in ()
02365 );
02366 }
02367 else
02368 {
02369 ACE_ERROR_RETURN ((
02370 LM_ERROR,
02371 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_typedef -")
02372 ACE_TEXT (" scope stack is empty\n")
02373 ),
02374 -1
02375 );
02376 }
02377
02378 node->ifr_added (true);
02379 }
02380 catch (const CORBA::Exception& ex)
02381 {
02382 if (!this->allow_duplicate_typedefs_)
02383 {
02384 ex._tao_print_exception (ACE_TEXT ("visit_typedef"));
02385
02386 return -1;
02387 }
02388 else
02389 {
02390 ACE_DEBUG ((LM_DEBUG,
02391 "%s %s\n",
02392 ACE_TEXT ("ifr_adding_visitor::visit_typedef - ignoring duplicate typedef"),
02393 node->local_name ()->get_string ()));
02394 }
02395 }
02396
02397 return 0;
02398 }
02399
02400 int
02401 ifr_adding_visitor::visit_root (AST_Root *node)
02402 {
02403 if (be_global->ifr_scopes ().push (be_global->repository ()) != 0)
02404 {
02405 ACE_ERROR_RETURN ((
02406 LM_ERROR,
02407 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02408 ACE_TEXT (" scope push failed\n")
02409 ),
02410 -1
02411 );
02412 }
02413
02414 if (this->visit_scope (node) == -1)
02415 {
02416 ACE_ERROR_RETURN ((
02417 LM_ERROR,
02418 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02419 ACE_TEXT (" visit_scope failed\n")
02420 ),
02421 -1
02422 );
02423 }
02424
02425 CORBA::Container_ptr tmp =
02426 CORBA::Container::_nil ();
02427
02428 if (be_global->ifr_scopes ().pop (tmp) != 0)
02429 {
02430 ACE_ERROR_RETURN ((
02431 LM_ERROR,
02432 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_root -")
02433 ACE_TEXT (" scope pop failed\n")
02434 ),
02435 -1
02436 );
02437 }
02438
02439 return 0;
02440 }
02441
02442 int
02443 ifr_adding_visitor::visit_native (AST_Native *node)
02444 {
02445 if (node->imported () && !be_global->do_included_files ())
02446 {
02447 return 0;
02448 }
02449
02450 try
02451 {
02452 CORBA::Contained_var prev_def =
02453 be_global->repository ()->lookup_id (node->repoID ());
02454
02455 if (CORBA::is_nil (prev_def.in ()))
02456 {
02457 CORBA::Container_ptr current_scope =
02458 CORBA::Container::_nil ();
02459
02460 if (be_global->ifr_scopes ().top (current_scope) == 0)
02461 {
02462 this->ir_current_ =
02463 current_scope->create_native (
02464 node->repoID (),
02465 node->local_name ()->get_string (),
02466 node->version ()
02467 );
02468 }
02469 else
02470 {
02471 ACE_ERROR_RETURN ((
02472 LM_ERROR,
02473 ACE_TEXT ("(%N:%l) ifr_adding_visitor::visit_native -")
02474 ACE_TEXT (" scope stack is empty\n")
02475 ),
02476 -1
02477 );
02478 }
02479
02480 node->ifr_added (true);
02481 }
02482 else
02483 {
02484
02485
02486
02487
02488 if (!node->ifr_added ())
02489 {
02490 prev_def->destroy ();
02491
02492
02493 return this->visit_native (node);
02494 }
02495
02496 this->ir_current_ =
02497 CORBA::NativeDef::_narrow (prev_def.in ());
02498 }
02499 }
02500 catch (const CORBA::Exception& ex)
02501 {
02502 ex._tao_print_exception (ACE_TEXT ("visit_native"));
02503
02504 return -1;
02505 }
02506
02507 return 0;
02508 }
02509
02510 CORBA::PrimitiveKind
02511 ifr_adding_visitor::expr_type_to_pkind (AST_Expression::ExprType et)
02512 {
02513 switch (et)
02514 {
02515 case AST_Expression::EV_short:
02516 return CORBA::pk_short;
02517 case AST_Expression::EV_ushort:
02518 return CORBA::pk_ushort;
02519 case AST_Expression::EV_long:
02520 return CORBA::pk_long;
02521 case AST_Expression::EV_ulong:
02522 return CORBA::pk_ulong;
02523 case AST_Expression::EV_longlong:
02524 return CORBA::pk_longlong;
02525 case AST_Expression::EV_ulonglong:
02526 return CORBA::pk_ulonglong;
02527 case AST_Expression::EV_float:
02528 return CORBA::pk_float;
02529 case AST_Expression::EV_double:
02530 return CORBA::pk_double;
02531 case AST_Expression::EV_longdouble:
02532 return CORBA::pk_longdouble;
02533 case AST_Expression::EV_char:
02534 return CORBA::pk_char;
02535 case AST_Expression::EV_wchar:
02536 return CORBA::pk_wchar;
02537 case AST_Expression::EV_octet:
02538 return CORBA::pk_octet;
02539 case AST_Expression::EV_bool:
02540 return CORBA::pk_boolean;
02541 case AST_Expression::EV_string:
02542 return CORBA::pk_string;
02543 case AST_Expression::EV_wstring:
02544 return CORBA::pk_wstring;
02545 case AST_Expression::EV_any:
02546 return CORBA::pk_any;
02547 case AST_Expression::EV_void:
02548 return CORBA::pk_void;
02549 case AST_Expression::EV_none:
02550 return CORBA::pk_null;
02551 default:
02552 return CORBA::pk_null;
02553 }
02554 }
02555
02556 CORBA::PrimitiveKind
02557 ifr_adding_visitor::predefined_type_to_pkind (AST_PredefinedType *node)
02558 {
02559 switch (node->pt ())
02560 {
02561 case AST_PredefinedType::PT_short:
02562 return CORBA::pk_short;
02563 case AST_PredefinedType::PT_ushort:
02564 return CORBA::pk_ushort;
02565 case AST_PredefinedType::PT_long:
02566 return CORBA::pk_long;
02567 case AST_PredefinedType::PT_ulong:
02568 return CORBA::pk_ulong;
02569 case AST_PredefinedType::PT_longlong:
02570 return CORBA::pk_longlong;
02571 case AST_PredefinedType::PT_ulonglong:
02572 return CORBA::pk_ulonglong;
02573 case AST_PredefinedType::PT_float:
02574 return CORBA::pk_float;
02575 case AST_PredefinedType::PT_double:
02576 return CORBA::pk_double;
02577 case AST_PredefinedType::PT_longdouble:
02578 return CORBA::pk_longdouble;
02579 case AST_PredefinedType::PT_char:
02580 return CORBA::pk_char;
02581 case AST_PredefinedType::PT_wchar:
02582 return CORBA::pk_wchar;
02583 case AST_PredefinedType::PT_octet:
02584 return CORBA::pk_octet;
02585 case AST_PredefinedType::PT_boolean:
02586 return CORBA::pk_boolean;
02587 case AST_PredefinedType::PT_any:
02588 return CORBA::pk_any;
02589 case AST_PredefinedType::PT_void:
02590 return CORBA::pk_void;
02591 case AST_PredefinedType::PT_object:
02592 return CORBA::pk_objref;
02593 case AST_PredefinedType::PT_value:
02594 return CORBA::pk_value_base;
02595 case AST_PredefinedType::PT_pseudo:
02596 {
02597 const char *local_name = node->local_name ()->get_string ();
02598
02599 if (!ACE_OS::strcmp (local_name, "Principal"))
02600 {
02601 return CORBA::pk_Principal;
02602 }
02603 else
02604 {
02605 return CORBA::pk_TypeCode;
02606 }
02607 }
02608 default:
02609 return CORBA::pk_null;
02610 }
02611 }
02612
02613 void
02614 ifr_adding_visitor::load_any (AST_Expression::AST_ExprValue *ev,
02615 CORBA::Any &any)
02616 {
02617 switch (ev->et)
02618 {
02619 case AST_Expression::EV_short:
02620 any <<= ev->u.sval;
02621 break;
02622 case AST_Expression::EV_ushort:
02623 any <<= ev->u.usval;
02624 break;
02625 case AST_Expression::EV_long:
02626 any <<= static_cast<CORBA::Long> (ev->u.lval);
02627 break;
02628 case AST_Expression::EV_ulong:
02629 any <<= static_cast<CORBA::ULong> (ev->u.ulval);
02630 break;
02631 #if !defined (ACE_LACKS_LONGLONG_T)
02632 case AST_Expression::EV_longlong:
02633 any <<= ev->u.llval;
02634 break;
02635 case AST_Expression::EV_ulonglong:
02636 any <<= ev->u.ullval;
02637 break;
02638 #endif
02639 case AST_Expression::EV_float:
02640 any <<= ev->u.fval;
02641 break;
02642 case AST_Expression::EV_double:
02643 any <<= ev->u.dval;
02644 break;
02645 #if 0
02646 case AST_Expression::EV_longdouble:
02647
02648 #endif
02649 case AST_Expression::EV_char:
02650 any <<= CORBA::Any::from_char (ev->u.cval);
02651 break;
02652 case AST_Expression::EV_wchar:
02653 any <<= CORBA::Any::from_wchar (ev->u.wcval);
02654 break;
02655 case AST_Expression::EV_octet:
02656 any <<= CORBA::Any::from_octet (ev->u.oval);
02657 break;
02658 case AST_Expression::EV_bool:
02659 any <<= CORBA::Any::from_boolean ((CORBA::Boolean) ev->u.bval);
02660 break;
02661 case AST_Expression::EV_string:
02662 any <<= ev->u.strval->get_string ();
02663 break;
02664 case AST_Expression::EV_wstring:
02665 {
02666 char *str = ev->u.wstrval;
02667 size_t len = ACE_OS::strlen (str);
02668 CORBA::WChar *wstr = 0;
02669 ACE_NEW (wstr,
02670 CORBA::WChar[len + 1]);
02671
02672 for (size_t i = 0; i < len; ++i)
02673 {
02674 wstr[i] = static_cast<CORBA::WChar> (str[i]);
02675 }
02676
02677 wstr[len] = 0;
02678 any <<= wstr;
02679 delete [] wstr;
02680 break;
02681 }
02682 case AST_Expression::EV_enum:
02683 any <<= static_cast<CORBA::ULong> (ev->u.eval);
02684 break;
02685 default:
02686 break;
02687 }
02688 }
02689
02690 void
02691 ifr_adding_visitor::element_type (AST_Type *base_type, bool owned)
02692 {
02693 AST_Decl::NodeType nt = base_type->node_type ();
02694 bool no_repo_id = nt == AST_Decl::NT_array
02695 || nt == AST_Decl::NT_sequence
02696 || base_type->anonymous ();
02697
02698 if (no_repo_id || owned)
02699 {
02700 if (base_type->ast_accept (this) == -1)
02701 {
02702 ACE_ERROR ((
02703 LM_ERROR,
02704 ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02705 ACE_TEXT (" failed to accept visitor\n")
02706 ));
02707
02708 throw Bailout ();
02709 }
02710 }
02711 else
02712 {
02713 CORBA::Contained_var contained =
02714 be_global->repository ()->lookup_id (base_type->repoID ());
02715
02716 if (CORBA::is_nil (contained.in ()))
02717 {
02718 ACE_ERROR ((
02719 LM_ERROR,
02720 ACE_TEXT ("(%N:%l) ifr_adding_visitor::element_type -")
02721 ACE_TEXT (" lookup_id failed\n")
02722 ));
02723
02724 throw Bailout ();
02725 }
02726
02727 this->ir_current_ = CORBA::IDLType::_narrow (contained.in ());
02728 }
02729 }
02730
02731 int
02732 ifr_adding_visitor::create_interface_def (AST_Interface *node)
02733 {
02734 CORBA::ULong n_parents = static_cast<CORBA::ULong> (node->n_inherits ());
02735 AST_Type **parents = node->inherits ();
02736 CORBA::Contained_var result;
02737 CORBA::AbstractInterfaceDefSeq abs_bases;
02738 CORBA::InterfaceDefSeq bases;
02739
02740 if (node->is_abstract ())
02741 {
02742 abs_bases.length (n_parents);
02743
02744
02745 for (CORBA::ULong i = 0; i < n_parents; ++i)
02746 {
02747 AST_Interface *intf =
02748 AST_Interface::narrow_from_decl (parents[i]);
02749
02750 if (intf == 0)
02751 {
02752 ACE_ERROR_RETURN ((
02753 LM_ERROR,
02754 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02755 ACE_TEXT ("create_interface_def -")
02756 ACE_TEXT (" parent %s is not an interface\n"),
02757 parents[i]->full_name ()),
02758 -1);
02759 }
02760
02761 result =
02762 be_global->repository ()->lookup_id (intf->repoID ());
02763
02764
02765
02766 if (CORBA::is_nil (result.in ()))
02767 {
02768 int status = this->create_interface_def (intf);
02769
02770 if (status != 0)
02771 {
02772 ACE_ERROR_RETURN ((
02773 LM_ERROR,
02774 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02775 ACE_TEXT ("create_interface_def -")
02776 ACE_TEXT (" parent interfacedef creation failed\n")),
02777 -1);
02778 }
02779
02780 bases[i] =
02781 CORBA::AbstractInterfaceDef::_narrow (this->ir_current_.in ());
02782 }
02783 else
02784 {
02785 abs_bases[i] =
02786 CORBA::AbstractInterfaceDef::_narrow (result.in ());
02787 }
02788
02789 if (CORBA::is_nil (abs_bases[i]))
02790 {
02791 ACE_ERROR_RETURN ((
02792 LM_ERROR,
02793 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02794 ACE_TEXT ("create_interface_def -")
02795 ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02796 ),
02797 -1
02798 );
02799 }
02800 }
02801 }
02802 else
02803 {
02804 bases.length (n_parents);
02805
02806
02807 for (CORBA::ULong i = 0; i < n_parents; ++i)
02808 {
02809 AST_Interface *intf =
02810 AST_Interface::narrow_from_decl (parents[i]);
02811
02812 if (intf == 0)
02813 {
02814 ACE_ERROR_RETURN ((
02815 LM_ERROR,
02816 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02817 ACE_TEXT ("create_interface_def -")
02818 ACE_TEXT (" parent %s is not an interface\n"),
02819 parents[i]->full_name ()),
02820 -1);
02821 }
02822
02823 result =
02824 be_global->repository ()->lookup_id (intf->repoID ());
02825
02826
02827
02828 if (CORBA::is_nil (result.in ()))
02829 {
02830 int status = this->create_interface_def (intf);
02831
02832 if (status != 0)
02833 {
02834 ACE_ERROR_RETURN ((
02835 LM_ERROR,
02836 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02837 ACE_TEXT ("create_interface_def -")
02838 ACE_TEXT (" parent interfacedef creation failed\n")
02839 ),
02840 -1
02841 );
02842 }
02843
02844 bases[i] = CORBA::InterfaceDef::_narrow (this->ir_current_.in ());
02845 }
02846 else
02847 {
02848 bases[i] = CORBA::InterfaceDef::_narrow (result.in ());
02849 }
02850
02851 if (CORBA::is_nil (bases[i]))
02852 {
02853 ACE_ERROR_RETURN ((
02854 LM_ERROR,
02855 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02856 ACE_TEXT ("create_interface_def -")
02857 ACE_TEXT (" CORBA::InterfaceDef::_narrow failed\n")
02858 ),
02859 -1
02860 );
02861 }
02862 }
02863 }
02864
02865 CORBA::Container_ptr current_scope =
02866 CORBA::Container::_nil ();
02867
02868 if (be_global->ifr_scopes ().top (current_scope) == 0)
02869 {
02870 CORBA::InterfaceDef_var new_def;
02871
02872 if (node->is_local ())
02873 {
02874 new_def =
02875 current_scope->create_local_interface (
02876 node->repoID (),
02877 node->local_name ()->get_string (),
02878 node->version (),
02879 bases
02880 );
02881 }
02882 else if (node->is_abstract ())
02883 {
02884 new_def =
02885 current_scope->create_abstract_interface (
02886 node->repoID (),
02887 node->local_name ()->get_string (),
02888 node->version (),
02889 abs_bases
02890 );
02891 }
02892 else
02893 {
02894 new_def =
02895 current_scope->create_interface (
02896 node->repoID (),
02897 node->local_name ()->get_string (),
02898 node->version (),
02899 bases
02900 );
02901 }
02902
02903
02904 node->ifr_added (true);
02905
02906
02907 CORBA::Container_var new_scope =
02908 CORBA::Container::_narrow (new_def.in ());
02909
02910 if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
02911 {
02912 ACE_ERROR_RETURN ((
02913 LM_ERROR,
02914 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02915 ACE_TEXT ("create_interface_def -")
02916 ACE_TEXT (" scope push failed\n")
02917 ),
02918 -1
02919 );
02920 }
02921
02922
02923 if (this->visit_scope (node) == -1)
02924 {
02925 ACE_ERROR_RETURN ((
02926 LM_ERROR,
02927 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02928 ACE_TEXT ("create_interface_def -")
02929 ACE_TEXT (" visit_scope failed\n")
02930 ),
02931 -1
02932 );
02933 }
02934
02935
02936
02937
02938
02939
02940
02941 this->ir_current_ =
02942 CORBA::IDLType::_duplicate (new_def.in ());
02943
02944 CORBA::Container_ptr used_scope =
02945 CORBA::Container::_nil ();
02946
02947
02948 if (be_global->ifr_scopes ().pop (used_scope) != 0)
02949 {
02950 ACE_ERROR_RETURN ((
02951 LM_ERROR,
02952 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
02953 ACE_TEXT ("create_interface_def -")
02954 ACE_TEXT (" scope pop failed\n")
02955 ),
02956 -1
02957 );
02958 }
02959 }
02960 else
02961 {
02962 ACE_ERROR_RETURN ((
02963 LM_ERROR,
02964 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_interface_def -")
02965 ACE_TEXT (" scope stack is empty\n")
02966 ),
02967 -1
02968 );
02969 }
02970
02971 return 0;
02972 }
02973
02974 int
02975 ifr_adding_visitor::create_value_def (AST_ValueType *node)
02976 {
02977 CORBA::Container_ptr current_scope =
02978 CORBA::Container::_nil ();
02979
02980 if (be_global->ifr_scopes ().top (current_scope) == 0)
02981 {
02982 CORBA::ValueDef_var base_value;
02983 this->fill_base_value (base_value.out (),
02984 node);
02985
02986 CORBA::ValueDefSeq abstract_base_values;
02987 this->fill_abstract_base_values (abstract_base_values,
02988 node);
02989
02990 CORBA::InterfaceDefSeq supported_interfaces;
02991 this->fill_supported_interfaces (supported_interfaces,
02992 node);
02993
02994 CORBA::ExtInitializerSeq initializers;
02995 this->fill_initializers (initializers,
02996 node);
02997
02998 CORBA::ExtValueDef_var new_def =
02999 current_scope->create_ext_value (
03000 node->repoID (),
03001 node->local_name ()->get_string (),
03002 node->version (),
03003 static_cast<CORBA::Boolean> (node->custom ()),
03004 static_cast<CORBA::Boolean> (node->is_abstract ()),
03005 base_value.in (),
03006 static_cast<CORBA::Boolean> (node->truncatable ()),
03007 abstract_base_values,
03008 supported_interfaces,
03009 initializers
03010 );
03011
03012 node->ifr_added (true);
03013
03014
03015 CORBA::Container_var new_scope =
03016 CORBA::Container::_narrow (new_def.in ());
03017
03018 if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03019 {
03020 ACE_ERROR_RETURN ((
03021 LM_ERROR,
03022 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03023 ACE_TEXT ("create_value_def -")
03024 ACE_TEXT (" scope push failed\n")
03025 ),
03026 -1
03027 );
03028 }
03029
03030
03031 if (this->visit_scope (node) == -1)
03032 {
03033 ACE_ERROR_RETURN ((
03034 LM_ERROR,
03035 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03036 ACE_TEXT ("create_value_def -")
03037 ACE_TEXT (" visit_scope failed\n")
03038 ),
03039 -1
03040 );
03041 }
03042
03043
03044
03045
03046
03047
03048
03049 this->ir_current_ =
03050 CORBA::IDLType::_duplicate (new_def.in ());
03051
03052 CORBA::Container_ptr used_scope =
03053 CORBA::Container::_nil ();
03054
03055
03056 if (be_global->ifr_scopes ().pop (used_scope) != 0)
03057 {
03058 ACE_ERROR_RETURN ((
03059 LM_ERROR,
03060 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03061 ACE_TEXT ("create_value_def -")
03062 ACE_TEXT (" scope pop failed\n")
03063 ),
03064 -1
03065 );
03066 }
03067 }
03068 else
03069 {
03070 ACE_ERROR_RETURN ((
03071 LM_ERROR,
03072 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_def -")
03073 ACE_TEXT (" scope stack is empty\n")
03074 ),
03075 -1
03076 );
03077 }
03078
03079 return 0;
03080 }
03081
03082 int
03083 ifr_adding_visitor::create_component_def (AST_Component *node)
03084 {
03085 CORBA::Container_ptr current_scope =
03086 CORBA::Container::_nil ();
03087
03088 if (be_global->ifr_scopes ().top (current_scope) == 0)
03089 {
03090 CORBA::ComponentIR::ComponentDef_var base_component;
03091 this->fill_base_component (base_component.out (),
03092 node);
03093
03094 CORBA::InterfaceDefSeq supported_interfaces;
03095 this->fill_supported_interfaces (supported_interfaces,
03096 node);
03097
03098 CORBA::ComponentIR::Container_var ccm_scope =
03099 CORBA::ComponentIR::Container::_narrow (current_scope);
03100
03101 CORBA::ComponentIR::ComponentDef_var new_def =
03102 ccm_scope->create_component (node->repoID (),
03103 node->local_name ()->get_string (),
03104 node->version (),
03105 base_component.in (),
03106 supported_interfaces);
03107
03108 node->ifr_added (true);
03109
03110 if (be_global->ifr_scopes ().push (new_def.in ()) != 0)
03111 {
03112 ACE_ERROR_RETURN ((
03113 LM_ERROR,
03114 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03115 ACE_TEXT ("create_component_def -")
03116 ACE_TEXT (" scope push failed\n")
03117 ),
03118 -1
03119 );
03120 }
03121
03122
03123
03124
03125
03126
03127
03128 this->ir_current_ =
03129 CORBA::IDLType::_duplicate (new_def.in ());
03130
03131
03132 if (this->visit_scope (node) == -1)
03133 {
03134 ACE_ERROR_RETURN ((
03135 LM_ERROR,
03136 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03137 ACE_TEXT ("create_component_def -")
03138 ACE_TEXT (" visit_scope failed\n")
03139 ),
03140 -1
03141 );
03142 }
03143
03144 CORBA::Container_ptr used_scope =
03145 CORBA::Container::_nil ();
03146
03147
03148 if (be_global->ifr_scopes ().pop (used_scope) != 0)
03149 {
03150 ACE_ERROR_RETURN ((
03151 LM_ERROR,
03152 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03153 ACE_TEXT ("create_component_def -")
03154 ACE_TEXT (" scope pop failed\n")
03155 ),
03156 -1
03157 );
03158 }
03159 }
03160 else
03161 {
03162 ACE_ERROR_RETURN ((
03163 LM_ERROR,
03164 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_component_def -")
03165 ACE_TEXT (" scope stack is empty\n")
03166 ),
03167 -1
03168 );
03169 }
03170
03171 return 0;
03172 }
03173
03174 int
03175 ifr_adding_visitor::create_home_def (AST_Home *node)
03176 {
03177 CORBA::Container_ptr current_scope =
03178 CORBA::Container::_nil ();
03179
03180 if (be_global->ifr_scopes ().top (current_scope) == 0)
03181 {
03182 CORBA::ComponentIR::HomeDef_var base_home;
03183 this->fill_base_home (base_home.out (),
03184 node);
03185
03186 CORBA::ComponentIR::ComponentDef_var managed_component;
03187 this->fill_managed_component (managed_component.out (),
03188 node);
03189
03190 CORBA::InterfaceDefSeq supported_interfaces;
03191 this->fill_supported_interfaces (supported_interfaces,
03192 node);
03193
03194 CORBA::ValueDef_var primary_key;
03195 this->fill_primary_key (primary_key.out (),
03196 node);
03197
03198 CORBA::ComponentIR::Container_var ccm_scope =
03199 CORBA::ComponentIR::Container::_narrow (current_scope);
03200
03201 CORBA::ComponentIR::HomeDef_var new_def =
03202 ccm_scope->create_home (node->repoID (),
03203 node->local_name ()->get_string (),
03204 node->version (),
03205 base_home.in (),
03206 managed_component.in (),
03207 supported_interfaces,
03208 primary_key.in ());
03209
03210 node->ifr_added (true);
03211
03212
03213 CORBA::Container_var new_scope =
03214 CORBA::Container::_narrow (new_def.in ());
03215
03216 if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03217 {
03218 ACE_ERROR_RETURN ((
03219 LM_ERROR,
03220 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03221 ACE_TEXT ("create_home_def -")
03222 ACE_TEXT (" scope push failed\n")
03223 ),
03224 -1
03225 );
03226 }
03227
03228
03229 if (this->visit_scope (node) == -1)
03230 {
03231 ACE_ERROR_RETURN ((
03232 LM_ERROR,
03233 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03234 ACE_TEXT ("create_home_def -")
03235 ACE_TEXT (" visit_scope failed\n")
03236 ),
03237 -1
03238 );
03239 }
03240
03241
03242
03243 this->visit_all_factories (node,
03244 new_def.in ());
03245
03246 this->visit_all_finders (node,
03247 new_def.in ());
03248
03249
03250
03251
03252
03253
03254
03255 this->ir_current_ =
03256 CORBA::IDLType::_duplicate (new_def.in ());
03257
03258 CORBA::Container_ptr used_scope =
03259 CORBA::Container::_nil ();
03260
03261
03262 if (be_global->ifr_scopes ().pop (used_scope) != 0)
03263 {
03264 ACE_ERROR_RETURN ((
03265 LM_ERROR,
03266 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03267 ACE_TEXT ("create_home_def -")
03268 ACE_TEXT (" scope pop failed\n")
03269 ),
03270 -1
03271 );
03272 }
03273 }
03274 else
03275 {
03276 ACE_ERROR_RETURN ((
03277 LM_ERROR,
03278 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_home_def -")
03279 ACE_TEXT (" scope stack is empty\n")
03280 ),
03281 -1
03282 );
03283 }
03284
03285 return 0;
03286 }
03287
03288 int
03289 ifr_adding_visitor::create_event_def (AST_EventType *node)
03290 {
03291 CORBA::Container_ptr current_scope =
03292 CORBA::Container::_nil ();
03293
03294 if (be_global->ifr_scopes ().top (current_scope) == 0)
03295 {
03296 CORBA::ValueDef_var base_value;
03297 this->fill_base_value (base_value.out (),
03298 node);
03299
03300 CORBA::ValueDefSeq abstract_base_values;
03301 this->fill_abstract_base_values (abstract_base_values,
03302 node);
03303
03304 CORBA::InterfaceDefSeq supported_interfaces;
03305 this->fill_supported_interfaces (supported_interfaces,
03306 node);
03307
03308 CORBA::ExtInitializerSeq initializers;
03309 this->fill_initializers (initializers,
03310 node);
03311
03312 CORBA::ComponentIR::Container_var ccm_scope =
03313 CORBA::ComponentIR::Container::_narrow (current_scope);
03314
03315 CORBA::ExtValueDef_var new_def =
03316 ccm_scope->create_event (
03317 node->repoID (),
03318 node->local_name ()->get_string (),
03319 node->version (),
03320 static_cast<CORBA::Boolean> (node->custom ()),
03321 static_cast<CORBA::Boolean> (node->is_abstract ()),
03322 base_value.in (),
03323 static_cast<CORBA::Boolean> (node->truncatable ()),
03324 abstract_base_values,
03325 supported_interfaces,
03326 initializers
03327 );
03328
03329 node->ifr_added (true);
03330
03331
03332 CORBA::Container_var new_scope =
03333 CORBA::Container::_narrow (new_def.in ());
03334
03335 if (be_global->ifr_scopes ().push (new_scope.in ()) != 0)
03336 {
03337 ACE_ERROR_RETURN ((
03338 LM_ERROR,
03339 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03340 ACE_TEXT ("create_event_def -")
03341 ACE_TEXT (" scope push failed\n")
03342 ),
03343 -1
03344 );
03345 }
03346
03347
03348 if (this->visit_scope (node) == -1)
03349 {
03350 ACE_ERROR_RETURN ((
03351 LM_ERROR,
03352 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03353 ACE_TEXT ("create_event_def -")
03354 ACE_TEXT (" visit_scope failed\n")
03355 ),
03356 -1
03357 );
03358 }
03359
03360
03361
03362
03363
03364
03365
03366 this->ir_current_ =
03367 CORBA::IDLType::_duplicate (new_def.in ());
03368
03369 CORBA::Container_ptr used_scope =
03370 CORBA::Container::_nil ();
03371
03372
03373 if (be_global->ifr_scopes ().pop (used_scope) != 0)
03374 {
03375 ACE_ERROR_RETURN ((
03376 LM_ERROR,
03377 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03378 ACE_TEXT ("create_event_def -")
03379 ACE_TEXT (" scope pop failed\n")
03380 ),
03381 -1
03382 );
03383 }
03384 }
03385 else
03386 {
03387 ACE_ERROR_RETURN ((
03388 LM_ERROR,
03389 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_event_def -")
03390 ACE_TEXT (" scope stack is empty\n")
03391 ),
03392 -1
03393 );
03394 }
03395
03396 return 0;
03397 }
03398
03399 int
03400 ifr_adding_visitor::create_value_member (AST_Field *node)
03401 {
03402 try
03403 {
03404 AST_Type *bt = node->field_type ();
03405 AST_Decl::NodeType nt = bt->node_type ();
03406
03407
03408
03409 if (nt == AST_Decl::NT_pre_defined
03410 || nt == AST_Decl::NT_string
03411 || nt == AST_Decl::NT_wstring
03412 || nt == AST_Decl::NT_array
03413 || nt == AST_Decl::NT_sequence)
03414 {
03415
03416 if (bt->ast_accept (this) != 0)
03417 {
03418 ACE_ERROR_RETURN ((
03419 LM_ERROR,
03420 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03421 ACE_TEXT ("create_value_member -")
03422 ACE_TEXT (" visit base type failed\n")
03423 ),
03424 -1
03425 );
03426 }
03427 }
03428 else
03429 {
03430
03431 CORBA::Contained_var holder =
03432 be_global->repository ()->lookup_id (bt->repoID ());
03433
03434 this->ir_current_ =
03435 CORBA::IDLType::_narrow (holder.in ());
03436 }
03437
03438 CORBA::Visibility vis = CORBA::PUBLIC_MEMBER;
03439
03440 switch (node->visibility ())
03441 {
03442 case AST_Field::vis_PUBLIC:
03443 break;
03444 case AST_Field::vis_PRIVATE:
03445 vis = CORBA::PRIVATE_MEMBER;
03446 break;
03447 default:
03448 ACE_ERROR_RETURN ((
03449 LM_ERROR,
03450 ACE_TEXT ("(%N:%l) ifr_adding_visitor::create_value_member -")
03451 ACE_TEXT (" bad visibility value in node\n")
03452 ),
03453 -1
03454 );
03455 };
03456
03457 CORBA::Container_ptr current_scope = CORBA::Container::_nil ();
03458
03459 if (be_global->ifr_scopes ().top (current_scope) != 0)
03460 {
03461 ACE_ERROR_RETURN ((
03462 LM_ERROR,
03463 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03464 ACE_TEXT ("create_value_member -")
03465 ACE_TEXT (" scope stack empty\n")
03466 ),
03467 -1
03468 );
03469 }
03470
03471 CORBA::ValueDef_var vt =
03472 CORBA::ValueDef::_narrow (current_scope);
03473
03474 CORBA::ValueMemberDef_var vm =
03475 vt->create_value_member (node->repoID (),
03476 node->local_name ()->get_string (),
03477 node->version (),
03478 this->ir_current_.in (),
03479 vis);
03480 }
03481 catch (const CORBA::Exception& ex)
03482 {
03483 ex._tao_print_exception (ACE_TEXT ("create_value_member"));
03484
03485 return -1;
03486 }
03487
03488 return 0;
03489 }
03490
03491 void
03492 ifr_adding_visitor::get_referenced_type (AST_Type *node)
03493 {
03494 switch (node->node_type ())
03495 {
03496
03497
03498
03499 case AST_Decl::NT_pre_defined:
03500 case AST_Decl::NT_string:
03501 case AST_Decl::NT_wstring:
03502 case AST_Decl::NT_array:
03503 case AST_Decl::NT_sequence:
03504 if (node->ast_accept (this) == -1)
03505 {
03506 ACE_ERROR ((
03507 LM_ERROR,
03508 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03509 ACE_TEXT ("get_scope_member -")
03510 ACE_TEXT (" failed to accept visitor\n")
03511 ));
03512 }
03513
03514 break;
03515
03516
03517 default:
03518 {
03519 CORBA::Contained_var prev_def =
03520 be_global->repository ()->lookup_id (node->repoID ());
03521
03522 this->ir_current_ =
03523 CORBA::IDLType::_narrow (prev_def.in ());
03524 break;
03525 }
03526 }
03527 }
03528
03529 void
03530 ifr_adding_visitor::fill_base_value (CORBA::ValueDef_ptr &result,
03531 AST_ValueType *node)
03532 {
03533 result = CORBA::ValueDef::_nil ();
03534 AST_Type *base_value = node->inherits_concrete ();
03535
03536 if (base_value == 0)
03537 {
03538 return;
03539 }
03540
03541 CORBA::Contained_var holder =
03542 be_global->repository ()->lookup_id (
03543 base_value->repoID ()
03544 );
03545
03546 if (!CORBA::is_nil (holder.in ()))
03547 {
03548 result =
03549 CORBA::ValueDef::_narrow (holder.in ());
03550 }
03551 }
03552
03553 void
03554 ifr_adding_visitor::fill_base_component (
03555 CORBA::ComponentIR::ComponentDef_ptr &result,
03556 AST_Component *node
03557 )
03558 {
03559 result = CORBA::ComponentIR::ComponentDef::_nil ();
03560 AST_Component *base_component = node->base_component ();
03561
03562 if (base_component == 0)
03563 {
03564 return;
03565 }
03566
03567 CORBA::Contained_var holder =
03568 be_global->repository ()->lookup_id (
03569 base_component->repoID ()
03570 );
03571
03572 if (!CORBA::is_nil (holder.in ()))
03573 {
03574 result =
03575 CORBA::ComponentIR::ComponentDef::_narrow (holder.in ());
03576 }
03577 }
03578
03579 void
03580 ifr_adding_visitor::fill_base_home (CORBA::ComponentIR::HomeDef_ptr &result,
03581 AST_Home *node)
03582 {
03583 result = CORBA::ComponentIR::HomeDef::_nil ();
03584 AST_Home *base_home = node->base_home ();
03585
03586 if (base_home == 0)
03587 {
03588 return;
03589 }
03590
03591 CORBA::Contained_var holder =
03592 be_global->repository ()->lookup_id (
03593 base_home->repoID ()
03594 );
03595
03596 if (!CORBA::is_nil (holder.in ()))
03597 {
03598 result =
03599 CORBA::ComponentIR::HomeDef::_narrow (holder.in ());
03600 }
03601 else
03602 {
03603
03604
03605 (void) base_home->ast_accept (this);
03606 this->fill_base_home (result,
03607 node);
03608 }
03609 }
03610
03611 void
03612 ifr_adding_visitor::fill_managed_component (
03613 CORBA::ComponentIR::ComponentDef_ptr &result,
03614 AST_Home *node
03615 )
03616 {
03617 result = CORBA::ComponentIR::ComponentDef::_nil ();
03618 AST_Component *managed_component = node->managed_component ();
03619
03620 if (managed_component == 0)
03621 {
03622 return;
03623 }
03624
03625 CORBA::Contained_var holder =
03626 be_global->repository ()->lookup_id (managed_component->repoID ());
03627
03628 if (!CORBA::is_nil (holder.in ()))
03629 {
03630 result =
03631 CORBA::ComponentIR::ComponentDef::_narrow (holder.in ());
03632 }
03633 else
03634 {
03635
03636
03637 (void) managed_component->ast_accept (this);
03638 this->fill_managed_component (result,
03639 node);
03640 }
03641 }
03642
03643 void
03644 ifr_adding_visitor::fill_primary_key (CORBA::ValueDef_ptr &result,
03645 AST_Home *node)
03646 {
03647 result = CORBA::ValueDef::_nil ();
03648 AST_Type *primary_key = node->primary_key ();
03649
03650 if (primary_key == 0)
03651 {
03652 return;
03653 }
03654
03655 CORBA::Contained_var holder =
03656 be_global->repository ()->lookup_id (primary_key->repoID ());
03657
03658 if (!CORBA::is_nil (holder.in ()))
03659 {
03660 result =
03661 CORBA::ValueDef::_narrow (holder.in ());
03662 }
03663 else
03664 {
03665
03666
03667 (void) primary_key->ast_accept (this);
03668 this->fill_primary_key (result,
03669 node);
03670 }
03671 }
03672
03673 void
03674 ifr_adding_visitor::fill_abstract_base_values (CORBA::ValueDefSeq &result,
03675 AST_ValueType *node)
03676 {
03677 CORBA::Long s_length = node->n_inherits ();
03678 result.length (0);
03679
03680
03681
03682
03683 if (s_length > 0)
03684 {
03685 AST_Type **list = node->inherits ();
03686 CORBA::ULong u_length = static_cast<CORBA::ULong> (s_length);
03687 bool first_abs = list[0]->is_abstract ();
03688 result.length (first_abs ? u_length : u_length - 1);
03689
03690 for (CORBA::ULong i = 0; i < u_length; ++i)
03691 {
03692 if (i == 0 && ! first_abs)
03693 {
03694 continue;
03695 }
03696
03697
03698 (void) list[i]->ast_accept (this);
03699
03700 result[first_abs ? i : i - 1] =
03701 CORBA::ValueDef::_narrow (this->ir_current_.in ());
03702 }
03703 }
03704 }
03705
03706 void
03707 ifr_adding_visitor::fill_inherited_interfaces (CORBA::InterfaceDefSeq &result,
03708 AST_Interface *node)
03709 {
03710 result.length (0);
03711 this->fill_interfaces (result,
03712 node->inherits (),
03713 node->n_inherits ());
03714 }
03715
03716 void
03717 ifr_adding_visitor::fill_supported_interfaces (CORBA::InterfaceDefSeq &result,
03718 AST_Interface *node)
03719 {
03720 result.length (0);
03721 CORBA::Long s_length = 0;
03722 AST_Type **list = 0;
03723
03724 switch (node->node_type ())
03725 {
03726 case AST_Decl::NT_valuetype:
03727 case AST_Decl::NT_eventtype:
03728 {
03729 AST_ValueType *v = AST_ValueType::narrow_from_decl (node);
03730 s_length = v->n_supports ();
03731 list = v->supports ();
03732 break;
03733 }
03734 case AST_Decl::NT_component:
03735 {
03736 AST_Component *c = AST_Component::narrow_from_decl (node);
03737 s_length = c->n_supports ();
03738 list = c->supports ();
03739 break;
03740 }
03741 case AST_Decl::NT_home:
03742 {
03743 AST_Home *h = AST_Home::narrow_from_decl (node);
03744 s_length = h->n_supports ();
03745 list = h->supports ();
03746 break;
03747 }
03748 default:
03749 return;
03750 }
03751
03752 this->fill_interfaces (result,
03753 list,
03754 s_length);
03755 }
03756
03757 void
03758 ifr_adding_visitor::fill_interfaces (CORBA::InterfaceDefSeq &result,
03759 AST_Type **list,
03760 CORBA::Long length)
03761 {
03762
03763
03764
03765 if (length > 0)
03766 {
03767 CORBA::ULong u_length = static_cast<CORBA::ULong> (length);
03768 result.length (u_length);
03769
03770 for (CORBA::ULong i = 0; i < u_length; ++i)
03771 {
03772
03773 (void) list[i]->ast_accept (this);
03774
03775 result[i] =
03776 CORBA::InterfaceDef::_narrow (this->ir_current_.in ());
03777 }
03778 }
03779 }
03780
03781 void
03782 ifr_adding_visitor::fill_initializers (CORBA::ExtInitializerSeq &result,
03783 AST_ValueType *node)
03784 {
03785 result.length (0);
03786 AST_Decl *item = 0;
03787 ACE_Vector<AST_Factory *> factories;
03788
03789 for (UTL_ScopeActiveIterator v_iter (node,
03790 UTL_Scope::IK_decls);
03791 !v_iter.is_done ();
03792 v_iter.next ())
03793 {
03794 item = v_iter.item ();
03795
03796 if (item->node_type () == AST_Decl::NT_factory)
03797 {
03798 factories.push_back (AST_Factory::narrow_from_decl (item));
03799 }
03800 }
03801
03802 CORBA::ULong n_factories = factories.size ();
03803
03804 if (n_factories == 0)
03805 {
03806 return;
03807 }
03808
03809 result.length (n_factories);
03810 CORBA::ULong n_args = 0;
03811 AST_Argument *arg = 0;
03812 CORBA::ULong index = 0;
03813 AST_Exception *excp = 0;
03814 CORBA::Contained_var holder;
03815
03816 for (CORBA::ULong i = 0; i < n_factories; ++i)
03817 {
03818 result[i].name =
03819 CORBA::string_dup (factories[i]->local_name ()->get_string ());
03820 n_args = static_cast<CORBA::ULong> (factories[i]->argument_count ());
03821 result[i].members.length (n_args);
03822
03823
03824 for (UTL_ScopeActiveIterator f_iter (factories[i],
03825 UTL_Scope::IK_decls);
03826 !f_iter.is_done ();
03827 f_iter.next (), ++index)
03828 {
03829 arg = AST_Argument::narrow_from_decl (f_iter.item ());
03830 result[i].members[index].name =
03831 CORBA::string_dup (arg->local_name ()->get_string ());
03832 result[i].members[index].type =
03833 CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03834
03835
03836
03837 if (arg->field_type ()->ast_accept (this) != 0)
03838 {
03839 ACE_ERROR ((
03840 LM_ERROR,
03841 ACE_TEXT ("(%N:%l) ifr_adding_visitor::")
03842 ACE_TEXT ("fill_initializers -")
03843 ACE_TEXT (" failed to accept arg type visitor\n")
03844 ));
03845 }
03846
03847 result[i].members[index].type_def =
03848 CORBA::IDLType::_duplicate (this->ir_current_.in ());
03849 }
03850
03851 CORBA::ULong n_exceptions =
03852 static_cast<CORBA::ULong> (factories[i]->n_exceptions ());
03853 result[i].exceptions.length (n_exceptions);
03854 index = 0;
03855
03856 for (UTL_ExceptlistActiveIterator ei (factories[i]->exceptions ());
03857 !ei.is_done ();
03858 ei.next ())
03859 {
03860 excp = AST_Exception::narrow_from_decl (ei.item ());
03861 result[i].exceptions[index].name =
03862 CORBA::string_dup (excp->local_name ()->get_string ());
03863 result[i].exceptions[index].id = excp->repoID ();
03864 result[i].exceptions[index].defined_in =
03865 ScopeAsDecl (excp->defined_in ())->repoID ();
03866 result[i].exceptions[index].version = excp->version ();
03867 result[i].exceptions[index++].type =
03868 CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03869 }
03870 }
03871 }
03872
03873 void
03874 ifr_adding_visitor::fill_get_exceptions (CORBA::ExceptionDefSeq &result,
03875 AST_Attribute *node)
03876 {
03877 this->fill_exceptions (result,
03878 node->get_get_exceptions ());
03879 }
03880
03881 void
03882 ifr_adding_visitor::fill_set_exceptions (CORBA::ExceptionDefSeq &result,
03883 AST_Attribute *node)
03884 {
03885 this->fill_exceptions (result,
03886 node->get_set_exceptions ());
03887 }
03888
03889 void
03890 ifr_adding_visitor::fill_exceptions (CORBA::ExceptionDefSeq &result,
03891 AST_Decl *node)
03892 {
03893 switch (node->node_type ())
03894 {
03895 case AST_Decl::NT_op:
03896 {
03897 AST_Operation *op = AST_Operation::narrow_from_decl (node);
03898 this->fill_exceptions (result,
03899 op->exceptions ());
03900 return;
03901 }
03902 case AST_Decl::NT_factory:
03903 case AST_Decl::NT_finder:
03904 {
03905 AST_Factory *f = AST_Factory::narrow_from_decl (node);
03906 this->fill_exceptions (result,
03907 f->exceptions ());
03908 return;
03909 }
03910 default:
03911 result.length (0);
03912 return;
03913 }
03914 }
03915
03916 void
03917 ifr_adding_visitor::fill_exceptions (CORBA::ExceptionDefSeq &result,
03918 UTL_ExceptList *list)
03919 {
03920 if (list == 0)
03921 {
03922 result.length (0);
03923 return;
03924 }
03925
03926 result.length (static_cast<CORBA::ULong> (list->length ()));
03927 CORBA::ULong index = 0;
03928 AST_Decl *d = 0;
03929 CORBA::Contained_var holder;
03930
03931 for (UTL_ExceptlistActiveIterator ei (list);
03932 !ei.is_done ();
03933 ei.next (), ++index)
03934 {
03935 d = ei.item ();
03936
03937
03938
03939
03940 (void) d->ast_accept (this);
03941
03942 holder = be_global->repository ()->lookup_id (d->repoID ());
03943
03944 result[index] =
03945 CORBA::ExceptionDef::_narrow (holder.in ());
03946 }
03947 }
03948
03949 void
03950 ifr_adding_visitor::fill_params (CORBA::ParDescriptionSeq &result,
03951 UTL_Scope *node)
03952 {
03953 AST_Argument *arg = 0;
03954 CORBA::ULong n_args = static_cast<CORBA::ULong> (node->nmembers ());
03955 result.length (n_args);
03956 CORBA::ULong index = 0;
03957 CORBA::Contained_var holder;
03958
03959 for (UTL_ScopeActiveIterator iter (node,
03960 UTL_Scope::IK_decls);
03961 ! iter.is_done ();
03962 iter.next (), ++index)
03963 {
03964 arg = AST_Argument::narrow_from_decl (iter.item ());
03965 result[index].name =
03966 CORBA::string_dup (arg->local_name ()->get_string ());
03967 result[index].type = CORBA::TypeCode::_duplicate (CORBA::_tc_void);
03968
03969
03970 (void) arg->ast_accept (this);
03971
03972 result[index].type_def =
03973 CORBA::IDLType::_duplicate (this->ir_current_.in ());
03974
03975 result[index].mode = CORBA::PARAM_IN;
03976 }
03977 }
03978
03979 void
03980 ifr_adding_visitor::visit_all_factories (AST_Home *node,
03981 CORBA::ComponentIR::HomeDef_ptr h)
03982 {
03983 CORBA::Contained_var contained;
03984 CORBA::ComponentIR::FactoryDef_var new_def;
03985
03986 for (UTL_ScopeActiveIterator h_iter (node,
03987 UTL_Scope::IK_decls);
03988 !h_iter.is_done ();
03989 h_iter.next ())
03990 {
03991 AST_Decl *d = h_iter.item ();
03992 AST_Decl::NodeType nt = d->node_type ();
03993
03994 if (nt != AST_Decl::NT_factory)
03995 {
03996 continue;
03997 }
03998
03999 AST_Factory *f = AST_Factory::narrow_from_decl (d);
04000
04001 CORBA::ParDescriptionSeq params;
04002 this->fill_params (params, f);
04003
04004 CORBA::ExceptionDefSeq exceptions;
04005 this->fill_exceptions (exceptions, f);
04006
04007 new_def = h->create_factory (f->repoID (),
04008 f->local_name ()->get_string (),
04009 f->version (),
04010 params,
04011 exceptions);
04012 }
04013 }
04014
04015 void
04016 ifr_adding_visitor::visit_all_finders (AST_Home *node,
04017 CORBA::ComponentIR::HomeDef_ptr h)
04018 {
04019 AST_Finder *f = 0;
04020 CORBA::Contained_var contained;
04021 CORBA::ComponentIR::FinderDef_var new_def;
04022
04023 for (UTL_ScopeActiveIterator h_iter (node,
04024 UTL_Scope::IK_decls);
04025 !h_iter.is_done ();
04026 h_iter.next ())
04027 {
04028 f = AST_Finder::narrow_from_decl (h_iter.item ());
04029
04030 if (f == 0)
04031 {
04032 continue;
04033 }
04034
04035 CORBA::ParDescriptionSeq params;
04036 this->fill_params (params, f);
04037
04038 CORBA::ExceptionDefSeq exceptions;
04039 this->fill_exceptions (exceptions, f);
04040
04041 new_def = h->create_finder (f->repoID (),
04042 f->local_name ()->get_string (),
04043 f->version (),
04044 params,
04045 exceptions);
04046 }
04047 }
04048
04049 void
04050 ifr_adding_visitor::expand_id (ACE_CString &str,
04051 const char *local_name)
04052 {
04053 ssize_t pos = str.rfind (':');
04054 str = str.substr (0, pos) + '/' + local_name + str.substr (pos);
04055 }