3 //=============================================================================
5 * @file be_visitor_context.h
7 * This class serves to provide all the necessary context information to the
8 * visitor as it generates code. This may include the scope inside which the
9 * code is generated, the output file that is being used, and others. This
10 * context information will be passed to the abstract/concrete visitor
11 * factory which in turn will use it to construct the right visitor.
13 * @author Aniruddha Gokhale
15 //=============================================================================
17 #ifndef TAO_BE_VISITOR_CONTEXT_H
18 #define TAO_BE_VISITOR_CONTEXT_H
20 #include "ast_visitor_context.h"
24 #include "be_codegen.h"
33 // When interface is defined as macro redefine it as aceinterface
34 #if defined (interface)
35 # define aceinterface interface
37 #endif /* interface */
39 class be_visitor_context
: public ast_visitor_context
42 /// default constructor
43 be_visitor_context ();
45 /// default constructor
46 be_visitor_context (const be_visitor_context
&ctx
);
49 ~be_visitor_context ();
51 /// assignment operator
52 be_visitor_context
&operator= (const be_visitor_context
&ctx
);
59 /// set the output stream
60 void stream (TAO_OutStream
*os
);
63 TAO_OutStream
*stream ();
66 void scope (be_scope
*scope
);
68 /// get the scope in which code will be generated
71 /// current node being visited
72 void node (be_decl
*node
);
74 /// node being visited
77 /// code generation state
78 void state (TAO_CodeGen::CG_STATE
);
80 /// return the code generation state
81 TAO_CodeGen::CG_STATE
state ();
83 /// code generation state
84 void sub_state (TAO_CodeGen::CG_SUB_STATE
);
86 /// return the code generation state
87 TAO_CodeGen::CG_SUB_STATE
sub_state ();
89 /// set the alias node (if any)
90 void alias (be_typedef
*node
);
92 /// return the aliased node (if any)
95 /// set the typedef node (if any)
96 void tdef (be_typedef
*node
);
98 /// return the typedef node (if any)
101 /// set the attribute node if any
102 void attribute (be_attribute
*attr
);
104 /// get the attribute node
105 be_attribute
*attribute ();
107 /// is it the special ctor for exceptions?
108 void exception (bool);
110 /// is it the special ctor for exceptions?
113 /// scope supoorts generation of comma after each element
116 /// are we supposed to generate a comma?
120 * In some cases we need to generate the objects of one interface as
121 * members of a derived visitor (the TIE classes are a good
122 * example). This field is use to hold the interface where we are
123 * *generating* code, as opposed to the interfaces where the methods
124 * or structures are defined.
126 be_interface
*interface () const;
127 void interface (be_interface
*);
129 /// Accessor for the member.
130 ACE_CString
&port_prefix ();
132 /// return the export macro currently in force
133 const char *export_macro () const;
135 /// if anyop export macro is empty, check stub.
136 const char *non_null_export_macro () const;
139 /// code generation state
140 TAO_CodeGen::CG_STATE state_
;
142 /// code generation state
143 TAO_CodeGen::CG_SUB_STATE sub_state_
;
145 /// current output stream
148 /// current scope in which code is generated
154 /// aliased node used as a scoped name to define IDL types.
160 /// attribute node stored here while generating its code
163 /// is it the special ctor for exceptions?
166 /// whether scope should generate a comma after every element
169 /// See the method declaration above.
170 be_interface
*interface_
;
172 /// Used in enough visitors to put it here.
173 ACE_CString port_prefix_
;
176 #if defined (interface)
177 # define interface aceinterface
178 #endif /* interface */
180 #endif /* BE_VISITOR_CONTEXT_H */