dds_visitor Class Reference

#include <dds_visitor.h>

List of all members.

Public Member Functions

 dds_visitor (AST_Decl *scope, bool java_ts_only)
virtual ~dds_visitor ()
virtual int visit_decl (AST_Decl *d)
virtual int visit_scope (UTL_Scope *node)
virtual int visit_type (AST_Type *node)
virtual int visit_predefined_type (AST_PredefinedType *node)
virtual int visit_module (AST_Module *node)
virtual int visit_interface (AST_Interface *node)
virtual int visit_interface_fwd (AST_InterfaceFwd *node)
virtual int visit_valuetype (AST_ValueType *node)
virtual int visit_valuetype_fwd (AST_ValueTypeFwd *node)
virtual int visit_component (AST_Component *node)
virtual int visit_component_fwd (AST_ComponentFwd *node)
virtual int visit_eventtype (AST_EventType *node)
virtual int visit_eventtype_fwd (AST_EventTypeFwd *node)
virtual int visit_home (AST_Home *node)
virtual int visit_factory (AST_Factory *node)
virtual int visit_structure (AST_Structure *node)
virtual int visit_structure_fwd (AST_StructureFwd *node)
virtual int visit_exception (AST_Exception *node)
virtual int visit_expression (AST_Expression *node)
virtual int visit_enum (AST_Enum *node)
virtual int visit_operation (AST_Operation *node)
virtual int visit_field (AST_Field *node)
virtual int visit_argument (AST_Argument *node)
virtual int visit_attribute (AST_Attribute *node)
virtual int visit_union (AST_Union *node)
virtual int visit_union_fwd (AST_UnionFwd *node)
virtual int visit_union_branch (AST_UnionBranch *node)
virtual int visit_union_label (AST_UnionLabel *node)
virtual int visit_constant (AST_Constant *node)
virtual int visit_enum_val (AST_EnumVal *node)
virtual int visit_array (AST_Array *node)
virtual int visit_sequence (AST_Sequence *node)
virtual int visit_string (AST_String *node)
virtual int visit_typedef (AST_Typedef *node)
virtual int visit_root (AST_Root *node)
virtual int visit_native (AST_Native *node)
virtual int visit_valuebox (AST_ValueBox *node)
virtual int visit_template_module (AST_Template_Module *node)
virtual int visit_template_module_inst (AST_Template_Module_Inst *node)
virtual int visit_template_module_ref (AST_Template_Module_Ref *node)
virtual int visit_param_holder (AST_Param_Holder *node)
virtual int visit_porttype (AST_PortType *node)
virtual int visit_provides (AST_Provides *node)
virtual int visit_uses (AST_Uses *node)
virtual int visit_publishes (AST_Publishes *node)
virtual int visit_emits (AST_Emits *node)
virtual int visit_consumes (AST_Consumes *node)
virtual int visit_extended_port (AST_Extended_Port *node)
virtual int visit_mirror_port (AST_Mirror_Port *node)
virtual int visit_connector (AST_Connector *node)
virtual int visit_finder (AST_Finder *node)

Protected Attributes

AST_Decl * scope_
bool error_
bool java_ts_only_


Detailed Description

Definition at line 26 of file dds_visitor.h.


Constructor & Destructor Documentation

dds_visitor::dds_visitor ( AST_Decl *  scope,
bool  java_ts_only 
)

Definition at line 93 of file dds_visitor.cpp.

References composite_generator::add_generator(), be_global, gen_target_(), langmap_generator::init(), BE_GlobalData::LANGMAP_NONE, BE_GlobalData::language_mapping(), lm_gen_, BE_GlobalData::v8(), and v8_gen_.

00094   : scope_(scope), error_(false), java_ts_only_(java_ts_only)
00095 {
00096   if (be_global->v8()) {
00097     gen_target_.add_generator(&v8_gen_);
00098   }
00099   if (be_global->language_mapping() != BE_GlobalData::LANGMAP_NONE) {
00100     gen_target_.add_generator(&lm_gen_);
00101     lm_gen_.init();
00102   }
00103 }

dds_visitor::~dds_visitor (  )  [virtual]

Definition at line 105 of file dds_visitor.cpp.

00106 {
00107 }


Member Function Documentation

int dds_visitor::visit_argument ( AST_Argument *  node  )  [virtual]

Definition at line 552 of file dds_visitor.cpp.

00553 {
00554   return 0;
00555 }

int dds_visitor::visit_array ( AST_Array *  node  )  [virtual]

Definition at line 444 of file dds_visitor.cpp.

00445 {
00446   //arrays always appear as typedefs, see visit_typedef ()
00447   return 0;
00448 }

int dds_visitor::visit_attribute ( AST_Attribute *  node  )  [virtual]

Definition at line 437 of file dds_visitor.cpp.

00438 {
00439   // attributes are taken care of by visit_interface ()
00440   return 0;
00441 }

int dds_visitor::visit_component ( AST_Component *  node  )  [virtual]

Definition at line 465 of file dds_visitor.cpp.

00466 {
00467   return 0;
00468 }

int dds_visitor::visit_component_fwd ( AST_ComponentFwd *  node  )  [virtual]

Definition at line 471 of file dds_visitor.cpp.

00472 {
00473   return 0;
00474 }

int dds_visitor::visit_connector ( AST_Connector *  node  )  [virtual]

Definition at line 631 of file dds_visitor.cpp.

00632 {
00633   return 0;
00634 }

int dds_visitor::visit_constant ( AST_Constant *  node  )  [virtual]

Definition at line 336 of file dds_visitor.cpp.

References error_, composite_generator::gen_const(), gen_target_(), and java_ts_only_.

00337 {
00338   const char* name = node->local_name()->get_string();
00339 
00340   BE_Comment_Guard g("CONST", name);
00341 
00342   ACE_UNUSED_ARG(g);
00343 
00344   AST_Decl* d = ScopeAsDecl(node->defined_in());
00345 
00346   bool nested = d && (d->node_type() == AST_Decl::NT_interface);
00347 
00348   if (!java_ts_only_) {
00349     error_ |= !gen_target_.gen_const(node->name(), nested, node);
00350   }
00351 
00352   return 0;
00353 }

int dds_visitor::visit_consumes ( AST_Consumes *  node  )  [virtual]

Definition at line 616 of file dds_visitor.cpp.

00617 {
00618   return 0;
00619 }

int dds_visitor::visit_decl ( AST_Decl *  d  )  [virtual]

Definition at line 557 of file dds_visitor.cpp.

00558 {
00559   return 0;
00560 }

int dds_visitor::visit_emits ( AST_Emits *  node  )  [virtual]

Definition at line 611 of file dds_visitor.cpp.

00612 {
00613   return 0;
00614 }

int dds_visitor::visit_enum ( AST_Enum *  node  )  [virtual]

Definition at line 289 of file dds_visitor.cpp.

References error_, composite_generator::gen_enum(), gen_target_(), java_ts_only_, and scope2vector().

00290 {
00291   const char* name = node->local_name()->get_string();
00292 
00293   BE_Comment_Guard g("ENUM", name);
00294 
00295   ACE_UNUSED_ARG(g);
00296 
00297   vector<AST_EnumVal*> contents;
00298 
00299   scope2vector(contents, node, AST_Decl::NT_enum_val);
00300 
00301   if (!java_ts_only_) {
00302     error_ |= !gen_target_.gen_enum(node, node->name(), contents, node->repoID());
00303   }
00304 
00305   return 0;
00306 }

int dds_visitor::visit_enum_val ( AST_EnumVal *  node  )  [virtual]

Definition at line 537 of file dds_visitor.cpp.

00538 {
00539   return 0;
00540 }

int dds_visitor::visit_eventtype ( AST_EventType *  node  )  [virtual]

Definition at line 477 of file dds_visitor.cpp.

00478 {
00479   return 0;
00480 }

int dds_visitor::visit_eventtype_fwd ( AST_EventTypeFwd *  node  )  [virtual]

Definition at line 483 of file dds_visitor.cpp.

00484 {
00485   return 0;
00486 }

int dds_visitor::visit_exception ( AST_Exception *  node  )  [virtual]

Definition at line 256 of file dds_visitor.cpp.

00257 {
00258   if (node->imported()) {
00259     return 0;
00260   }
00261 
00262   const char* name = node->local_name()->get_string();
00263 
00264   BE_Comment_Guard g("EXCEPTION", name);
00265 
00266   ACE_UNUSED_ARG(g);
00267 
00268   return 0;
00269 }

int dds_visitor::visit_expression ( AST_Expression *  node  )  [virtual]

Definition at line 542 of file dds_visitor.cpp.

00543 {
00544   return 0;
00545 }

int dds_visitor::visit_extended_port ( AST_Extended_Port *  node  )  [virtual]

Definition at line 621 of file dds_visitor.cpp.

00622 {
00623   return 0;
00624 }

int dds_visitor::visit_factory ( AST_Factory *  node  )  [virtual]

Definition at line 495 of file dds_visitor.cpp.

00496 {
00497   return 0;
00498 }

int dds_visitor::visit_field ( AST_Field *  node  )  [virtual]

Definition at line 430 of file dds_visitor.cpp.

00431 {
00432   // fields are taken care of by visit_interface() for arguments and attributes
00433   return 0;
00434 }

int dds_visitor::visit_finder ( AST_Finder *  node  )  [virtual]

Definition at line 636 of file dds_visitor.cpp.

00637 {
00638   return 0;
00639 }

int dds_visitor::visit_home ( AST_Home *  node  )  [virtual]

Definition at line 489 of file dds_visitor.cpp.

00490 {
00491   return 0;
00492 }

int dds_visitor::visit_interface ( AST_Interface *  node  )  [virtual]

Definition at line 180 of file dds_visitor.cpp.

References error_, composite_generator::gen_interf(), gen_target_(), java_ts_only_, and scope2vector().

00181 {
00182   const char* name = node->local_name()->get_string();
00183 
00184   BE_Comment_Guard g("INTERFACE", name);
00185 
00186   ACE_UNUSED_ARG(g);
00187 
00188   vector<AST_Interface*> inherits(node->n_inherits());
00189   for (int i = 0; i < node->n_inherits(); ++i) {
00190     inherits[i] = dynamic_cast<AST_Interface*>(node->inherits()[i]);
00191   }
00192 
00193   vector<AST_Interface*> inherits_flat(node->inherits_flat(),
00194                                        node->inherits_flat()
00195                                        + node->n_inherits_flat());
00196 
00197   vector<AST_Attribute*> attrs;
00198 
00199   scope2vector(attrs, node, AST_Decl::NT_attr);
00200 
00201   vector<AST_Operation*> ops;
00202 
00203   scope2vector(ops, node, AST_Decl::NT_op);
00204 
00205   if (!java_ts_only_) {
00206     error_ |= !gen_target_.gen_interf(node, node->name(), node->is_local(),
00207                                       inherits, inherits_flat, attrs, ops,
00208                                       node->repoID());
00209   }
00210 
00211   if (this->visit_scope(node) == -1) {
00212     ACE_ERROR_RETURN((LM_ERROR,
00213                       ACE_TEXT("(%N:%l) dds_visitor::visit_interface ")
00214                       ACE_TEXT("- visit_scope failed\n")), -1);
00215   }
00216 
00217   return 0;
00218 }

int dds_visitor::visit_interface_fwd ( AST_InterfaceFwd *  node  )  [virtual]

Definition at line 309 of file dds_visitor.cpp.

References error_, composite_generator::gen_interf_fwd(), gen_target_(), and java_ts_only_.

00310 {
00311   const char* name = node->local_name()->get_string();
00312   BE_Comment_Guard g("INTERFACE-FWD", name);
00313   ACE_UNUSED_ARG(g);
00314 
00315   if (!java_ts_only_) {
00316     error_ |= !gen_target_.gen_interf_fwd(node->name());
00317   }
00318 
00319   return 0;
00320 }

int dds_visitor::visit_mirror_port ( AST_Mirror_Port *  node  )  [virtual]

Definition at line 626 of file dds_visitor.cpp.

00627 {
00628   return 0;
00629 }

int dds_visitor::visit_module ( AST_Module *  node  )  [virtual]

Definition at line 162 of file dds_visitor.cpp.

00163 {
00164   const char* name = node->local_name()->get_string();
00165 
00166   BE_Comment_Guard g("MODULE", name);
00167 
00168   ACE_UNUSED_ARG(g);
00169 
00170   if (this->visit_scope(node) == -1) {
00171     ACE_ERROR_RETURN((LM_ERROR,
00172                       ACE_TEXT("(%N:%l) dds_visitor::visit_module -")
00173                       ACE_TEXT(" visit_scope failed\n")), -1);
00174   }
00175 
00176   return 0;
00177 }

int dds_visitor::visit_native ( AST_Native *  node  )  [virtual]

Definition at line 356 of file dds_visitor.cpp.

References error_, composite_generator::gen_native(), gen_target_(), and java_ts_only_.

00357 {
00358   const char* name = node->local_name()->get_string();
00359 
00360   BE_Comment_Guard g("NATIVE", name);
00361 
00362   ACE_UNUSED_ARG(g);
00363 
00364   if (!java_ts_only_) {
00365     error_ |= !gen_target_.gen_native(node, node->name(), node->repoID());
00366   }
00367 
00368   return 0;
00369 }

int dds_visitor::visit_operation ( AST_Operation *  node  )  [virtual]

Definition at line 423 of file dds_visitor.cpp.

00424 {
00425   // operations are taken care of by visit_interface()
00426   return 0;
00427 }

int dds_visitor::visit_param_holder ( AST_Param_Holder *  node  )  [virtual]

Definition at line 586 of file dds_visitor.cpp.

00587 {
00588   return 0;
00589 }

int dds_visitor::visit_porttype ( AST_PortType *  node  )  [virtual]

Definition at line 591 of file dds_visitor.cpp.

00592 {
00593   return 0;
00594 }

int dds_visitor::visit_predefined_type ( AST_PredefinedType *  node  )  [virtual]

Definition at line 503 of file dds_visitor.cpp.

00504 {
00505   return 0;
00506 }

int dds_visitor::visit_provides ( AST_Provides *  node  )  [virtual]

Definition at line 596 of file dds_visitor.cpp.

00597 {
00598   return 0;
00599 }

int dds_visitor::visit_publishes ( AST_Publishes *  node  )  [virtual]

Definition at line 606 of file dds_visitor.cpp.

00607 {
00608   return 0;
00609 }

int dds_visitor::visit_root ( AST_Root *  node  )  [virtual]

Definition at line 112 of file dds_visitor.cpp.

References error_, composite_generator::gen_epilogue(), composite_generator::gen_prologue(), and gen_target_().

00113 {
00114   error_ = false;
00115 
00116   gen_target_.gen_prologue();
00117   if (this->visit_scope(node) == -1) {
00118     ACE_ERROR_RETURN((LM_ERROR,
00119                       ACE_TEXT("(%N:%l) dds_visitor::visit_root -")
00120                       ACE_TEXT(" visit_scope failed\n")), -1);
00121   }
00122   gen_target_.gen_epilogue();
00123 
00124   return (error_) ? -1 : 0;
00125 }

int dds_visitor::visit_scope ( UTL_Scope *  node  )  [virtual]

Definition at line 128 of file dds_visitor.cpp.

00129 {
00130   if (node->nmembers() > 0) {
00131     UTL_ScopeActiveIterator si(node, UTL_Scope::IK_decls);
00132     AST_Decl* d = 0;
00133 
00134     while (!si.is_done()) {
00135       d = si.item();
00136 
00137       if (d == 0) {
00138         ACE_ERROR_RETURN((LM_ERROR,
00139                           ACE_TEXT("(%N:%l) dds_visitor::visit_")
00140                           ACE_TEXT("scope - bad node in this scope\n")), -1);
00141       }
00142 
00143       if (d->node_type() == AST_Decl::NT_pre_defined) {
00144         si.next();
00145         continue;
00146       }
00147 
00148       if (d->ast_accept(this) == -1) {
00149         ACE_ERROR_RETURN((LM_ERROR,
00150                           ACE_TEXT("(%N:%l) dds_visitor::visit_")
00151                           ACE_TEXT("scope - failed to accept visitor\n")), -1);
00152       }
00153 
00154       si.next();
00155     }
00156   }
00157 
00158   return 0;
00159 }

int dds_visitor::visit_sequence ( AST_Sequence *  node  )  [virtual]

Definition at line 416 of file dds_visitor.cpp.

00417 {
00418   //sequences always appear as typedefs, see visit_typedef ()
00419   return 0;
00420 }

int dds_visitor::visit_string ( AST_String *  node  )  [virtual]

Definition at line 509 of file dds_visitor.cpp.

00510 {
00511   return 0;
00512 }

int dds_visitor::visit_structure ( AST_Structure *  node  )  [virtual]

Definition at line 221 of file dds_visitor.cpp.

References be_global, error_, field_check_anon(), composite_generator::gen_struct(), gen_target_(), java_ts_generator::generate(), BE_GlobalData::java(), and java_ts_only_.

00222 {
00223   const char* name = node->local_name()->get_string();
00224 
00225   BE_Comment_Guard g("STRUCT", name);
00226 
00227   ACE_UNUSED_ARG(g);
00228 
00229   size_t nfields = node->nfields();
00230   vector<AST_Field*> fields;
00231   fields.reserve(nfields);
00232 
00233   for (CORBA::ULong i = 0; i < nfields; ++i) {
00234     AST_Field** f;
00235     node->field(f, i);
00236     if (!field_check_anon(*f, "struct", name)) {
00237       error_ = true;
00238       return -1;
00239     }
00240     fields.push_back(*f);
00241   }
00242 
00243   if (!java_ts_only_) {
00244     error_ |= !gen_target_.gen_struct(node, node->name(), fields,
00245                                       node->size_type(), node->repoID());
00246   }
00247 
00248   if (be_global->java()) {
00249     java_ts_generator::generate(node->name());
00250   }
00251 
00252   return 0;
00253 }

int dds_visitor::visit_structure_fwd ( AST_StructureFwd *  node  )  [virtual]

Definition at line 323 of file dds_visitor.cpp.

References error_, composite_generator::gen_struct_fwd(), gen_target_(), and java_ts_only_.

00324 {
00325   const char* name = node->local_name()->get_string();
00326   BE_Comment_Guard g("STRUCT-FWD", name);
00327 
00328   if (!java_ts_only_) {
00329     error_ |= !gen_target_.gen_struct_fwd(node->name(), node->size_type());
00330   }
00331 
00332   return 0;
00333 }

int dds_visitor::visit_template_module ( AST_Template_Module *  node  )  [virtual]

Definition at line 568 of file dds_visitor.cpp.

00569 {
00570   return 0;
00571 }

int dds_visitor::visit_template_module_inst ( AST_Template_Module_Inst *  node  )  [virtual]

Definition at line 574 of file dds_visitor.cpp.

00575 {
00576   return 0;
00577 }

int dds_visitor::visit_template_module_ref ( AST_Template_Module_Ref *  node  )  [virtual]

Definition at line 580 of file dds_visitor.cpp.

00581 {
00582   return 0;
00583 }

int dds_visitor::visit_type ( AST_Type *  node  )  [virtual]

Definition at line 547 of file dds_visitor.cpp.

00548 {
00549   return 0;
00550 }

int dds_visitor::visit_typedef ( AST_Typedef *  node  )  [virtual]

Definition at line 272 of file dds_visitor.cpp.

References error_, gen_target_(), composite_generator::gen_typedef(), and java_ts_only_.

00273 {
00274   const char* name = node->local_name()->get_string();
00275 
00276   BE_Comment_Guard g("TYPEDEF", name);
00277 
00278   ACE_UNUSED_ARG(g);
00279 
00280   if (!java_ts_only_) {
00281     error_ |= !gen_target_.gen_typedef(node, node->name(), node->base_type(),
00282                                        node->repoID());
00283   }
00284 
00285   return 0;
00286 }

int dds_visitor::visit_union ( AST_Union *  node  )  [virtual]

Definition at line 372 of file dds_visitor.cpp.

References error_, field_check_anon(), gen_target_(), composite_generator::gen_union(), and java_ts_only_.

00373 {
00374   const char* name = node->local_name()->get_string();
00375 
00376   BE_Comment_Guard g("UNION", name);
00377 
00378   ACE_UNUSED_ARG(g);
00379 
00380   vector<AST_UnionBranch*> branches;
00381 
00382   size_t nfields = node->nfields();
00383 
00384   branches.reserve(nfields);
00385 
00386   for (CORBA::ULong i = 0; i < nfields; ++i) {
00387     AST_Field** f;
00388     node->field(f, i);
00389     if (!field_check_anon(*f, "union", name)) {
00390       error_ = true;
00391       return -1;
00392     }
00393 
00394     AST_UnionBranch* ub = AST_UnionBranch::narrow_from_decl(*f);
00395 
00396     if (!ub) {
00397       std::cerr << "ERROR - expected union to contain UnionBranches\n";
00398       error_ = true;
00399       return 0;
00400     }
00401 
00402     branches.push_back(ub);
00403   }
00404 
00405   if (!java_ts_only_) {
00406     error_ |= !gen_target_.gen_union(node, node->name(), branches, node->disc_type(),
00407                                      node->repoID());
00408   }
00409 
00410   return 0;
00411 }

int dds_visitor::visit_union_branch ( AST_UnionBranch *  node  )  [virtual]

Definition at line 527 of file dds_visitor.cpp.

00528 {
00529   return 0;
00530 }

int dds_visitor::visit_union_fwd ( AST_UnionFwd *  node  )  [virtual]

Definition at line 515 of file dds_visitor.cpp.

References error_, gen_target_(), composite_generator::gen_union_fwd(), and java_ts_only_.

00516 {
00517   const char* name = node->local_name()->get_string();
00518   BE_Comment_Guard g("UNION-FWD", name);
00519 
00520   if (!java_ts_only_) {
00521     error_ |= !gen_target_.gen_union_fwd(node, node->name(), node->size_type());
00522   }
00523 
00524   return 0;
00525 }

int dds_visitor::visit_union_label ( AST_UnionLabel *  node  )  [virtual]

Definition at line 532 of file dds_visitor.cpp.

00533 {
00534   return 0;
00535 }

int dds_visitor::visit_uses ( AST_Uses *  node  )  [virtual]

Definition at line 601 of file dds_visitor.cpp.

00602 {
00603   return 0;
00604 }

int dds_visitor::visit_valuebox ( AST_ValueBox *  node  )  [virtual]

Definition at line 562 of file dds_visitor.cpp.

00563 {
00564   return 0;
00565 }

int dds_visitor::visit_valuetype ( AST_ValueType *  node  )  [virtual]

Definition at line 453 of file dds_visitor.cpp.

00454 {
00455   return 0;
00456 }

int dds_visitor::visit_valuetype_fwd ( AST_ValueTypeFwd *  node  )  [virtual]

Definition at line 459 of file dds_visitor.cpp.

00460 {
00461   return 0;
00462 }


Member Data Documentation

bool dds_visitor::error_ [protected]

Definition at line 136 of file dds_visitor.h.

Referenced by visit_constant(), visit_enum(), visit_interface(), visit_interface_fwd(), visit_native(), visit_root(), visit_structure(), visit_structure_fwd(), visit_typedef(), visit_union(), and visit_union_fwd().

bool dds_visitor::java_ts_only_ [protected]

Definition at line 137 of file dds_visitor.h.

Referenced by visit_constant(), visit_enum(), visit_interface(), visit_interface_fwd(), visit_native(), visit_structure(), visit_structure_fwd(), visit_typedef(), visit_union(), and visit_union_fwd().

AST_Decl* dds_visitor::scope_ [protected]

Definition at line 135 of file dds_visitor.h.


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:05:56 2016 for OpenDDS by  doxygen 1.4.7