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 / argument.cpp
blob8eb0700cea0ee8c17d4feb2c47ef5611368d69f5
2 //=============================================================================
3 /**
4 * @file argument.cpp
6 * Visitor that calls the visitor for arguments.
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "operation.h"
14 // ************************************************************
15 // Generic operation visitor to handle the pre/post
16 // do_static_call/upcall stuff with arguments.
17 // ************************************************************
19 be_visitor_operation_argument::be_visitor_operation_argument (
20 be_visitor_context *ctx
22 : be_visitor_operation (ctx)
26 be_visitor_operation_argument::~be_visitor_operation_argument ()
30 int
31 be_visitor_operation_argument::post_process (be_decl *bd)
33 TAO_OutStream *os = this->ctx_->stream ();
35 // If we are not the last parameter, we insert a comma. This is only
36 // applicable for the upcalls or the call to (de)marshal that we use in the
37 // interpreted marshaling.
38 switch (this->ctx_->state ())
40 case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS:
41 case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS:
42 if (!this->last_node (bd))
44 *os << "," << be_nl;
47 break;
48 case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS:
49 if (!this->last_node (bd))
51 *os << ",";
54 break;
55 default:
56 break;
59 return 0;
62 int
63 be_visitor_operation_argument::visit_operation (be_operation *node)
65 // All we do is hand over code generation to our scope.
66 if (this->visit_scope (node) == -1)
68 ACE_ERROR_RETURN ((LM_ERROR,
69 "(%N:%l) be_visitor_operation_argument::"
70 "visit_operation - "
71 "codegen for scope failed\n"),
72 -1);
75 return 0;
78 int
79 be_visitor_operation_argument::visit_argument (be_argument *node)
81 // Get the visitor that will dump the argument's mapping in the operation
82 // signature.
83 be_visitor_context ctx (*this->ctx_);
85 // First grab the interface definition inside which this operation is
86 // defined. We need this since argument types may very well be declared
87 // inside the scope of the interface node. In such cases, we would like to
88 // generate the appropriate relative scoped names.
89 be_operation *op =
90 dynamic_cast<be_operation*> (this->ctx_->scope ());
92 if (op == nullptr)
94 ACE_ERROR_RETURN ((LM_ERROR,
95 "(%N:%l) be_visitor_arglist::"
96 "visit_argument - "
97 "Bad operation\n"),
98 -1);
101 // We need the interface node in which this operation was defined. However,
102 // if this operation node was an attribute node in disguise, we get this
103 // information from the context.
104 be_interface *intf;
105 intf = this->ctx_->attribute ()
106 ? dynamic_cast<be_interface*> (this->ctx_->attribute ()->defined_in ())
107 : dynamic_cast<be_interface*> (op->defined_in ());
109 if (!intf)
111 ACE_ERROR_RETURN ((LM_ERROR,
112 "(%N:%l) be_visitor_arglist::"
113 "visit_argument - "
114 "Bad interface\n"),
115 -1);
118 ctx.scope (intf);
119 int status = 0;
121 switch (this->ctx_->state ())
123 case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS:
125 be_visitor_args_invoke_cs visitor (&ctx);
126 status = node->accept (&visitor);
127 break;
129 case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS:
131 be_visitor_args_vardecl_ss visitor (&ctx);
132 status = node->accept (&visitor);
133 break;
135 case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS:
137 be_visitor_args_marshal_ss visitor (&ctx);
138 status = node->accept (&visitor);
139 break;
141 case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS:
143 ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS);
144 be_visitor_args_upcall_ss visitor (&ctx);
145 status = node->accept (&visitor);
146 break;
148 case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS:
150 be_visitor_args_upcall_ss visitor (&ctx);
151 status = node->accept (&visitor);
152 break;
154 default:
156 ACE_ERROR_RETURN ((LM_ERROR,
157 "(%N:%l) be_visitor_argument::"
158 "visit_argument - "
159 "Bad context\n"),
160 -1);
164 if (status == -1)
166 ACE_ERROR_RETURN ((LM_ERROR,
167 "(%N:%l) be_visitor_argument::"
169 "visit_argument - "
170 "codegen for argument failed\n"),
171 -1);
174 return 0;