2 //=============================================================================
6 * Visitor generating code for Field in the client inline file
8 * @author Aniruddha Gokhale
10 //=============================================================================
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 ()
27 be_visitor_field_ci::visit_field (be_field
*node
)
30 dynamic_cast<be_type
*> (node
->field_type ());
34 ACE_ERROR_RETURN ((LM_ERROR
,
35 "(%N:%l) be_visitor_field_ci::"
41 this->ctx_
->node (node
);
43 if (bt
->accept (this) == -1)
45 ACE_ERROR_RETURN ((LM_ERROR
,
46 "(%N:%l) be_visitor_field_ci::"
48 "codegen for field type failed\n"),
55 // Visit operations on all possible data types that a field can be
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_
);
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::"
81 be_visitor_field_ci::visit_sequence (be_sequence
*)
87 be_visitor_field_ci::visit_map (be_map
*)
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_
);
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::"
116 be_visitor_field_ci::visit_structure_fwd (
117 be_structure_fwd
*node
)
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::"
136 "Bad primitive type\n"),
140 this->ctx_
->alias (nullptr);
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_
);
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::"
168 be_visitor_field_ci::visit_union_fwd (be_union_fwd
*node
)
171 dynamic_cast<be_union
*> (node
->full_definition ());
173 return this->visit_union (u
);