2 //=============================================================================
4 * @file operation_exs.cpp
6 * Visitor generating code for Operation in the CIAO executor file.
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 ()),
18 your_code_here_ ("/* Your code here. */"),
19 class_extension_ ("_exec_i")
23 be_visitor_operation_exs::~be_visitor_operation_exs ()
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 ())
36 this->ctx_
->node (node
);
40 // Retrieve the operation return type.
41 be_type
*rt
= dynamic_cast<be_type
*> (node
->return_type ());
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")),
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")),
66 // Generate the operation name
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
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")),
88 // Must set this again, it's been changed by traversals above.
89 this->ctx_
->node (node
);
91 return this->gen_op_body (rt
);
95 be_visitor_operation_exs::scope (be_decl
*node
)
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
)
114 dynamic_cast<be_operation
*> (this->ctx_
->node ());
116 if (! op
->void_return_type ())
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")),