2 //=============================================================================
6 * Visitor that calls the visitor for arguments.
8 * @author Aniruddha Gokhale
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 ()
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
))
48 case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS
:
49 if (!this->last_node (bd
))
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::"
71 "codegen for scope failed\n"),
79 be_visitor_operation_argument::visit_argument (be_argument
*node
)
81 // Get the visitor that will dump the argument's mapping in the operation
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.
90 dynamic_cast<be_operation
*> (this->ctx_
->scope ());
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "(%N:%l) be_visitor_arglist::"
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.
105 intf
= this->ctx_
->attribute ()
106 ? dynamic_cast<be_interface
*> (this->ctx_
->attribute ()->defined_in ())
107 : dynamic_cast<be_interface
*> (op
->defined_in ());
111 ACE_ERROR_RETURN ((LM_ERROR
,
112 "(%N:%l) be_visitor_arglist::"
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
);
129 case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS
:
131 be_visitor_args_vardecl_ss
visitor (&ctx
);
132 status
= node
->accept (&visitor
);
135 case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS
:
137 be_visitor_args_marshal_ss
visitor (&ctx
);
138 status
= node
->accept (&visitor
);
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
);
148 case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS
:
150 be_visitor_args_upcall_ss
visitor (&ctx
);
151 status
= node
->accept (&visitor
);
156 ACE_ERROR_RETURN ((LM_ERROR
,
157 "(%N:%l) be_visitor_argument::"
166 ACE_ERROR_RETURN ((LM_ERROR
,
167 "(%N:%l) be_visitor_argument::"
170 "codegen for argument failed\n"),