Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_operation / operation_exs.cpp
blob38a7844492b95289dbb54732658908353b41fe44
2 //=============================================================================
3 /**
4 * @file operation_exs.cpp
6 * Visitor generating code for Operation in the CIAO executor file.
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "operation.h"
14 be_visitor_operation_exs::be_visitor_operation_exs (be_visitor_context *ctx)
15 : be_visitor_scope (ctx),
16 os_ (*ctx->stream ()),
17 scope_ (nullptr),
18 your_code_here_ ("/* Your code here. */"),
19 class_extension_ ("_exec_i")
23 be_visitor_operation_exs::~be_visitor_operation_exs ()
27 int
28 be_visitor_operation_exs::visit_operation (be_operation *node)
30 // Impl classes shouldn't have implied AMI operations.
31 if (node->is_sendc_ami ())
33 return 0;
36 this->ctx_->node (node);
38 os_ << be_nl_2;
40 // Retrieve the operation return type.
41 be_type *rt = dynamic_cast<be_type*> (node->return_type ());
43 if (rt == nullptr)
45 ACE_ERROR_RETURN ((LM_ERROR,
46 ACE_TEXT ("be_visitor_operation_exs::")
47 ACE_TEXT ("visit_operation - ")
48 ACE_TEXT ("Bad return type\n")),
49 -1);
52 // Generate the return type mapping (same as in the header file)
53 be_visitor_context ctx = *this->ctx_;
54 be_visitor_operation_rettype rt_visitor (&ctx);
56 if (rt->accept (&rt_visitor) == -1)
58 ACE_ERROR_RETURN ((LM_ERROR,
59 ACE_TEXT ("be_visitor_operation_exs::")
60 ACE_TEXT ("visit_operation - ")
61 ACE_TEXT ("codegen for return ")
62 ACE_TEXT ("type failed\n")),
63 -1);
66 // Generate the operation name
67 os_ << be_nl
68 << this->ctx_->port_prefix ().c_str ()
69 << this->scope_->original_local_name ()->get_string ()
70 << this->class_extension_.c_str () << "::"
71 << node->local_name ();
73 // Generate the argument list, which will use our overrridden
74 // visit_argument().
75 be_visitor_operation_arglist al_visitor (this->ctx_);
76 al_visitor.unused (true);
78 if (node->accept (&al_visitor) == -1)
80 ACE_ERROR_RETURN ((LM_ERROR,
81 ACE_TEXT ("be_visitor_operation_exs::")
82 ACE_TEXT ("visit_operation - ")
83 ACE_TEXT ("codegen for argument ")
84 ACE_TEXT ("list failed\n")),
85 -1);
88 // Must set this again, it's been changed by traversals above.
89 this->ctx_->node (node);
91 return this->gen_op_body (rt);
94 void
95 be_visitor_operation_exs::scope (be_decl *node)
97 this->scope_ = node;
100 void
101 be_visitor_operation_exs::class_extension (const char *extension)
103 this->class_extension_ = extension;
107 be_visitor_operation_exs::gen_op_body (be_type *return_type)
109 os_ << be_nl
110 << "{" << be_idt_nl
111 << your_code_here_;
113 be_operation *op =
114 dynamic_cast<be_operation*> (this->ctx_->node ());
116 if (! op->void_return_type ())
118 os_ << be_nl;
120 be_null_return_emitter emitter (this->ctx_);
122 if (emitter.emit (return_type) == -1)
124 ACE_ERROR_RETURN ((LM_ERROR,
125 ACE_TEXT ("be_visitor_operation_exs::")
126 ACE_TEXT ("gen_op_body - ")
127 ACE_TEXT ("be_null_return_emitter::")
128 ACE_TEXT ("emit() failed\n")),
129 -1);
133 os_ << be_uidt_nl
134 << "}";
136 return 0;