UTL_ExceptList * ast_visitor_tmpl_module_inst::reify_exception_list ( UTL_ExceptList *orig) { if (orig == 0) { return 0; } UTL_ExceptList *retval = 0; for (UTL_ExceptlistActiveIterator i (orig); !i.is_done (); i.next ()) { AST_Type *ex = AST_Type::narrow_from_decl (this->reify_type (i.item ())); UTL_ExceptList *ex_list = 0; ACE_NEW_RETURN (ex_list, UTL_ExceptList (ex, 0), 0); if (retval == 0) { retval = ex_list; } else { retval->nconc (ex_list); } } return retval; }
int ir_simulator_visitor::visit_operation (AST_Operation *node) { XMI_TRACE ("operation"); Incr_Guard guard (this->associating_); if (!this->associating_) { // not associating, imported, not my concern if (node->imported ()) { return 0; } // not imported, but not associating, need to set the guard else { guard.arm (); } } // associating, import else { node->set_imported (false); } try { // ACE_DEBUG ((LM_DEBUG, "foo")); if (node->return_type ()) { // ACE_DEBUG ((LM_DEBUG, "bar")); node->return_type ()->ast_accept (this); } // **** arguments // **** exceptions UTL_ExceptList *exceptions = node->exceptions (); if (exceptions != 0 && exceptions->length () > 0) { for (UTL_ExceptlistActiveIterator ei (exceptions); !ei.is_done (); ei.next ()) { ei.item ()->ast_accept (this); } } this->visit_scope (node); } catch (Error &err) { err.node (node); } return 0; }
// Dump this AST_Operation node (an operation) to the ostream o. void AST_Operation::dump (ACE_OSTREAM_TYPE &o) { AST_Decl *d = 0; AST_Type *e = 0; UTL_String *s = 0; if (this->pd_flags == OP_oneway) { this->dump_i (o, "oneway "); } else if (this->pd_flags == OP_idempotent) { this->dump_i (o, "idempotent "); } this->pd_return_type->name ()->dump (o); this->dump_i (o, " "); this->local_name ()->dump (o); this->dump_i (o, "("); // Must advance the iterator explicity inside the loop. for (UTL_ScopeActiveIterator i (this, IK_decls); !i.is_done ();) { d = i.item (); d->dump (o); i.next (); if (!i.is_done()) { this->dump_i (o, ", "); } } this->dump_i (o, ")"); if (this->pd_exceptions != 0) { this->dump_i (o, " raises("); // Must advance the iterator explicity inside the loop. for (UTL_ExceptlistActiveIterator ei (this->pd_exceptions); !ei.is_done ();) { e = ei.item (); ei.next (); e->local_name ()->dump (o); if (!ei.is_done()) { this->dump_i (o, ", "); } } this->dump_i (o, ")"); } if (this->pd_context != 0) { this->dump_i (o, " context("); // Must advance the iterator explicity inside the loop. for (UTL_StrlistActiveIterator si (this->pd_context); !si.is_done();) { s = si.item (); si.next (); this->dump_i (o, s->get_string ()); if (!si.is_done()) { this->dump_i (o, ", "); } } this->dump_i (o, ")"); } }
int be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation ( be_operation *node) { be_type *bt = 0; be_visitor_context ctx; TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); // Initialize the return type variable. bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { ACE_ERROR_RETURN (( LM_ERROR, "(%N:%l) be_visitor_ami_handler_reply_stub_operation_cs::" "visit_operation - " "Bad return type\n" ), -1 ); } // Start with the current indentation level. os->indent (); // Generate the return type. Return type is simply void. *os << be_nl_2 << "void" << be_nl; // Get the scope name. be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); if (!parent) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_operation_ami_") ACE_TEXT ("handler_reply_stub_operation_cs::") ACE_TEXT ("visit_operation - ") ACE_TEXT ("node information not sufficient :-<\n")), -1); } // Genereate scope name. *os << parent->full_name (); // Generate the operation name. *os << "::"; *os << this->ctx_->port_prefix ().c_str () << node->local_name () << "_reply_stub (" << be_idt_nl << "TAO_InputCDR &_tao_in," << be_nl << "::Messaging::ReplyHandler_ptr _tao_reply_handler," << be_nl << "::CORBA::ULong reply_status" << ")" << be_uidt << be_uidt_nl << "{" << be_idt_nl; *os << "// Retrieve Reply Handler object." << be_nl; *os << parent->full_name () << "_var " << "_tao_reply_handler_object =" << be_idt_nl; *os << parent->full_name (); *os << "::_narrow (_tao_reply_handler);" << be_uidt << be_nl_2 << "// Exception handling" << be_nl << "switch (reply_status)" << be_nl << "{" << be_idt_nl << "case TAO_AMI_REPLY_OK:" << be_nl << "{" << be_idt << "\n"; // declare variables for arguments ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); be_visitor_operation_argument oad_visitor (&ctx); if (node->accept (&oad_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) ami_handler_reply_stub_operation_cs::" "visit_operation - " "codegen for return var decl failed\n"), -1); } // Demarshal parameters if (this->gen_marshal_and_invoke (node, bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%1) ami_handler_reply_stub_operation_cs::" "visit_operation - " "gen_demarshal_params failed\n"), -1); } *os << "break;" << be_uidt_nl << "}" << be_nl << "case TAO_AMI_REPLY_USER_EXCEPTION:" << be_nl << "case TAO_AMI_REPLY_SYSTEM_EXCEPTION:" << be_nl << "{" << be_idt_nl << "const ACE_Message_Block* cdr = _tao_in.start ();" << be_nl ; const char *exception_data_arg = "0"; const char *exception_count_arg = "0"; // Don't do anything if the exception list is empty. if (node->exceptions ()) { *os << be_nl << "static TAO::Exception_Data " << "exceptions_data [] =" << be_nl; *os << "{" << be_idt_nl; int excep_count = 0; be_exception *ex = 0; // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. // Iterator must be explicitly advanced inside the loop. for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); !ei.is_done ();) { ex = be_exception::narrow_from_decl (ei.item ()); *os << "{" << be_idt_nl << "\"" << ex->repoID () << "\"," << be_nl; // Allocator method. *os << ex->name () << "::_alloc" << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; if (be_global->tc_support ()) { *os << ", " << ex->tc_name (); } else { *os << ", 0"; } *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_uidt_nl << "}"; ++excep_count; ei.next (); if (!ei.is_done ()) { *os << "," << be_nl; } } *os << be_uidt_nl << "};" << be_nl_2; *os << "::CORBA::ULong const exceptions_count = " << excep_count << ";\n" << be_nl; exception_data_arg = "exceptions_data"; exception_count_arg = "exceptions_count"; } *os << "::CORBA::OctetSeq " << "_tao_marshaled_exception (" << be_idt << be_idt_nl << "static_cast <CORBA::ULong> (cdr->length ())," << be_nl << "static_cast <CORBA::ULong> (cdr->length ())," << be_nl << "reinterpret_cast <unsigned char*> (cdr->rd_ptr ())," << be_nl << "0" << be_uidt_nl << ");" << be_uidt_nl; *os << "::Messaging::ExceptionHolder* exception_holder_ptr = 0;" << be_nl << "ACE_NEW (" << be_idt << be_idt_nl << "exception_holder_ptr," << be_nl << "::TAO::ExceptionHolder (" << be_idt_nl << "(reply_status == TAO_AMI_REPLY_SYSTEM_EXCEPTION)," << be_nl << "_tao_in.byte_order ()," << be_nl << "_tao_marshaled_exception," << be_nl << exception_data_arg << "," << be_nl << exception_count_arg << "," << be_nl << "_tao_in.char_translator ()," << be_nl << "_tao_in.wchar_translator ()" << ")" << be_uidt_nl << ");" << be_uidt_nl << be_uidt_nl; *os << "::Messaging::ExceptionHolder_var exception_holder_var = " << "exception_holder_ptr;" << be_nl; *os << "_tao_reply_handler_object->" << node->local_name () << "_excep (" << be_idt << be_idt_nl << "exception_holder_var"; *os << be_uidt_nl << ");" << be_uidt_nl; *os << "break;" << be_uidt_nl << "}" << be_nl; *os << "case TAO_AMI_REPLY_NOT_OK:" << be_idt_nl << "// @@ Michael: Not even the spec mentions this case." << be_nl << "// We have to think about this case." << be_nl << "break;" << be_uidt << be_uidt_nl << "}" << be_uidt << be_uidt_nl; *os << "}"; return 0; }