2 //=============================================================================
6 * Visitor generating code for Field in the client stubs file.
8 * @author Aniruddha Gokhale
10 //=============================================================================
13 #include "be_visitor_array/array_cs.h"
14 #include "be_visitor_enum/enum_cs.h"
15 #include "be_visitor_sequence/sequence_cs.h"
16 #include "be_visitor_structure/structure_cs.h"
17 #include "be_visitor_union/union_cs.h"
19 // **********************************************
20 // Visitor for field in the client stubs file.
21 // **********************************************
23 be_visitor_field_cs::be_visitor_field_cs (be_visitor_context
*ctx
)
24 : be_visitor_decl (ctx
)
28 be_visitor_field_cs::~be_visitor_field_cs ()
33 be_visitor_field_cs::visit_field (be_field
*node
)
35 be_type
*bt
= dynamic_cast<be_type
*> (node
->field_type ());
39 ACE_ERROR_RETURN ((LM_ERROR
,
40 "(%N:%l) be_visitor_field_cs::"
46 this->ctx_
->node (node
);
48 if (bt
->accept (this) == -1)
50 ACE_ERROR_RETURN ((LM_ERROR
,
51 "(%N:%l) be_visitor_field_cs::"
53 "codegen for field type failed\n"),
61 be_visitor_field_cs::visit_array (be_array
*node
)
63 if (!this->ctx_
->alias ()
64 && node
->is_child (this->ctx_
->scope ()->decl ()))
66 be_visitor_context
ctx (*this->ctx_
);
68 be_visitor_array_cs
visitor (&ctx
);
70 if (node
->accept (&visitor
) == -1)
72 ACE_ERROR_RETURN ((LM_ERROR
,
73 "(%N:%l) be_visitor_field_cs::"
84 be_visitor_field_cs::visit_enum (be_enum
*node
)
86 if (node
->node_type () != AST_Decl::NT_typedef
87 && node
->is_child (this->ctx_
->scope ()->decl ()))
89 be_visitor_context
ctx (*this->ctx_
);
91 be_visitor_enum_cs
visitor (&ctx
);
93 if (node
->accept (&visitor
) == -1)
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 "(%N:%l) be_visitor_field_cs::"
107 be_visitor_field_cs::visit_sequence (be_sequence
*node
)
109 if (node
->node_type () != AST_Decl::NT_typedef
110 && node
->is_child (this->ctx_
->scope ()->decl ()))
112 be_visitor_context
ctx (*this->ctx_
);
114 be_visitor_sequence_cs
visitor (&ctx
);
116 if (node
->accept (&visitor
) == -1)
118 ACE_ERROR_RETURN ((LM_ERROR
,
119 "(%N:%l) be_visitor_field_cs::"
130 be_visitor_field_cs::visit_map (be_map
*)
136 be_visitor_field_cs::visit_structure (be_structure
*node
)
138 if (node
->node_type () != AST_Decl::NT_typedef
139 && node
->is_child (this->ctx_
->scope ()->decl ()))
141 be_visitor_context
ctx (*this->ctx_
);
143 be_visitor_structure_cs
visitor (&ctx
);
145 if (node
->accept (&visitor
) == -1)
147 ACE_ERROR_RETURN ((LM_ERROR
,
148 "(%N:%l) be_visitor_field_cs::"
159 be_visitor_field_cs::visit_structure_fwd (
160 be_structure_fwd
*node
)
163 dynamic_cast<be_structure
*> (node
->full_definition ());
165 return this->visit_structure (s
);
169 be_visitor_field_cs::visit_typedef (be_typedef
*node
)
171 this->ctx_
->alias (node
);
172 be_type
*bt
= node
->primitive_base_type ();
174 if (!bt
|| (bt
->accept (this) == -1))
176 ACE_ERROR_RETURN ((LM_ERROR
,
177 "(%N:%l) be_visitor_union_branch_public_ci::"
179 "Bad primitive type\n"),
183 this->ctx_
->alias (nullptr);
188 be_visitor_field_cs::visit_union (be_union
*node
)
190 if (node
->node_type () != AST_Decl::NT_typedef
191 && node
->is_child (this->ctx_
->scope ()->decl ()))
193 be_visitor_context
ctx (*this->ctx_
);
195 be_visitor_union_cs
visitor (&ctx
);
197 if (node
->accept (&visitor
) == -1)
199 ACE_ERROR_RETURN ((LM_ERROR
,
200 "(%N:%l) be_visitor_field_cs::"
211 be_visitor_field_cs::visit_union_fwd (be_union_fwd
*node
)
214 dynamic_cast<be_union
*> (node
->full_definition ());
216 return this->visit_union (u
);