2 //=============================================================================
4 * @file argument_invoke.cpp
6 * Visitor to pass arguments to the CDR operators. This one helps in
7 * generating the && and the , at the right place. This one is for the
10 * @author Aniruddha Gokhale
12 //=============================================================================
14 #include "operation.h"
16 // ************************************************************
17 // operation visitor to handle the passing of arguments to the CDR operators
18 // ************************************************************
20 be_visitor_operation_argument_invoke::be_visitor_operation_argument_invoke (
23 : be_visitor_operation_argument (ctx
),
24 last_arg_printed_ (be_visitor_operation_argument_invoke::TAO_ARG_NONE
)
28 be_visitor_operation_argument_invoke::~be_visitor_operation_argument_invoke ()
33 be_visitor_operation_argument_invoke::pre_process (be_decl
*bd
)
35 TAO_OutStream
*os
= this->ctx_
->stream ();
37 be_argument
*arg
= dynamic_cast<be_argument
*> (bd
);
41 ACE_ERROR_RETURN ((LM_ERROR
,
43 "be_visitor_operation_argument_invoke"
45 "Bad argument node\n"),
49 switch (arg
->direction ())
51 case AST_Argument::dir_IN
:
52 if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT
)
54 if (this->last_arg_printed_
!=
55 be_visitor_operation_argument_invoke::TAO_ARG_NONE
)
56 *os
<< " &&" << be_nl
;
58 else if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_INPUT
)
63 case AST_Argument::dir_INOUT
:
64 if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT
)
66 if (this->last_arg_printed_
!=
67 be_visitor_operation_argument_invoke::TAO_ARG_NONE
)
68 *os
<< " &&" << be_nl
;
70 else if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_INPUT
)
72 if (this->last_arg_printed_
!=
73 be_visitor_operation_argument_invoke::TAO_ARG_NONE
)
74 *os
<< " &&" << be_nl
;
77 case AST_Argument::dir_OUT
:
78 if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT
)
82 else if (this->ctx_
->sub_state () == TAO_CodeGen::TAO_CDR_INPUT
)
84 if (this->last_arg_printed_
!=
85 be_visitor_operation_argument_invoke::TAO_ARG_NONE
)
86 *os
<< " &&" << be_nl
;
95 be_visitor_operation_argument_invoke::post_process (be_decl
*bd
)
97 be_argument
*arg
= dynamic_cast<be_argument
*> (bd
);
101 ACE_ERROR_RETURN ((LM_ERROR
,
103 "be_visitor_operation_argument_invoke"
105 "Bad argument node\n"),
109 switch (this->ctx_
->sub_state ())
111 case TAO_CodeGen::TAO_CDR_OUTPUT
:
112 switch (arg
->direction ())
114 case AST_Argument::dir_IN
:
115 // only these arguments get printed
116 this->last_arg_printed_
=
117 be_visitor_operation_argument_invoke::TAO_ARG_IN
;
119 case AST_Argument::dir_INOUT
:
120 // only these arguments get printed
121 this->last_arg_printed_
=
122 be_visitor_operation_argument_invoke::TAO_ARG_INOUT
;
124 case AST_Argument::dir_OUT
:
125 // these arguments don't get printed for the << operator on the stub
129 case TAO_CodeGen::TAO_CDR_INPUT
:
130 switch (arg
->direction ())
132 case AST_Argument::dir_IN
:
133 // these arguments don't get printed for the >> on the stub
135 case AST_Argument::dir_INOUT
:
136 // only these arguments get printed
137 this->last_arg_printed_
=
138 be_visitor_operation_argument_invoke::TAO_ARG_INOUT
;
140 case AST_Argument::dir_OUT
:
141 // only these arguments get printed
142 this->last_arg_printed_
=
143 be_visitor_operation_argument_invoke::TAO_ARG_OUT
;
148 ACE_ERROR_RETURN ((LM_ERROR
,
150 "be_visitor_operation_argument_invoke"