Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_field / field_ci.cpp
blobfabd02fc260a955534998444e43868561a0e2d2e
2 //=============================================================================
3 /**
4 * @file field_ci.cpp
6 * Visitor generating code for Field in the client inline file
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "field.h"
13 #include "be_visitor_array/array_ci.h"
14 #include "be_visitor_structure/structure_ci.h"
15 #include "be_visitor_union/union_ci.h"
17 be_visitor_field_ci::be_visitor_field_ci (be_visitor_context *ctx)
18 : be_visitor_decl (ctx)
22 be_visitor_field_ci::~be_visitor_field_ci ()
26 int
27 be_visitor_field_ci::visit_field (be_field *node)
29 be_type *bt =
30 dynamic_cast<be_type*> (node->field_type ());
32 if (!bt)
34 ACE_ERROR_RETURN ((LM_ERROR,
35 "(%N:%l) be_visitor_field_ci::"
36 "visit_field - "
37 "Bad field type\n"),
38 -1);
41 this->ctx_->node (node);
43 if (bt->accept (this) == -1)
45 ACE_ERROR_RETURN ((LM_ERROR,
46 "(%N:%l) be_visitor_field_ci::"
47 "visit_field - "
48 "codegen for field type failed\n"),
49 -1);
52 return 0;
55 // Visit operations on all possible data types that a field can be
57 int
58 be_visitor_field_ci::visit_array (be_array *node)
60 if (!this->ctx_->alias ()
61 && node->is_child (this->ctx_->scope ()->decl ()))
63 be_visitor_context ctx (*this->ctx_);
64 ctx.node (node);
65 be_visitor_array_ci visitor (&ctx);
67 if (node->accept (&visitor) == -1)
69 ACE_ERROR_RETURN ((LM_ERROR,
70 "(%N:%l) be_visitor_field_ci::"
71 "visit_array - "
72 "codegen failed\n"),
73 -1);
77 return 0;
80 int
81 be_visitor_field_ci::visit_sequence (be_sequence *)
83 return 0;
86 int
87 be_visitor_field_ci::visit_map (be_map *)
89 return 0;
92 int
93 be_visitor_field_ci::visit_structure (be_structure *node)
95 if (node->node_type () != AST_Decl::NT_typedef
96 && node->is_child (this->ctx_->scope ()->decl ()))
98 be_visitor_context ctx (*this->ctx_);
99 ctx.node (node);
100 be_visitor_structure_ci visitor (&ctx);
102 if (node->accept (&visitor) == -1)
104 ACE_ERROR_RETURN ((LM_ERROR,
105 "(%N:%l) be_visitor_field_ci::"
106 "visit_struct - "
107 "codegen failed\n"),
108 -1);
112 return 0;
116 be_visitor_field_ci::visit_structure_fwd (
117 be_structure_fwd *node)
119 be_structure *s =
120 dynamic_cast<be_structure*> (node->full_definition ());
122 return this->visit_structure (s);
126 be_visitor_field_ci::visit_typedef (be_typedef *node)
128 this->ctx_->alias (node);
129 be_type *bt = node->primitive_base_type ();
131 if (!bt || (bt->accept (this) == -1))
133 ACE_ERROR_RETURN ((LM_ERROR,
134 "(%N:%l) be_visitor_union_branch_public_ci::"
135 "visit_typedef - "
136 "Bad primitive type\n"),
137 -1);
140 this->ctx_->alias (nullptr);
141 return 0;
145 be_visitor_field_ci::visit_union (be_union *node)
147 if (node->node_type () != AST_Decl::NT_typedef
148 && node->is_child (this->ctx_->scope ()->decl ()))
150 be_visitor_context ctx (*this->ctx_);
151 ctx.node (node);
152 be_visitor_union_ci visitor (&ctx);
154 if (node->accept (&visitor) == -1)
156 ACE_ERROR_RETURN ((LM_ERROR,
157 "(%N:%l) be_visitor_field_ci::"
158 "visit_union - "
159 "codegen failed\n"),
160 -1);
164 return 0;
168 be_visitor_field_ci::visit_union_fwd (be_union_fwd *node)
170 be_union *u =
171 dynamic_cast<be_union*> (node->full_definition ());
173 return this->visit_union (u);