5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in which
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
56 Mountain View, California 94043
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
65 // Implementation of BE generator class.
67 // This implements the same protocol as AST_Generator but creates instances
68 // of the BE-subclassed classes instead of of AST classes.
70 #include "be_generator.h"
72 #include "be_predefined_type.h"
73 #include "be_module.h"
74 #include "be_valuebox.h"
75 #include "be_valuetype.h"
76 #include "be_valuetype_fwd.h"
77 #include "be_eventtype.h"
78 #include "be_eventtype_fwd.h"
79 #include "be_component.h"
80 #include "be_component_fwd.h"
82 #include "be_porttype.h"
83 #include "be_mirror_port.h"
84 #include "be_connector.h"
85 #include "be_template_module.h"
86 #include "be_template_module_inst.h"
87 #include "be_template_module_ref.h"
88 #include "be_param_holder.h"
89 #include "be_provides.h"
91 #include "be_publishes.h"
93 #include "be_consumes.h"
95 #include "be_union_fwd.h"
96 #include "be_structure.h"
97 #include "be_structure_fwd.h"
98 #include "be_exception.h"
99 #include "be_operation.h"
101 #include "be_field.h"
102 #include "be_argument.h"
103 #include "be_attribute.h"
104 #include "be_union_branch.h"
105 #include "be_union_label.h"
106 #include "be_constant.h"
107 #include "be_expression.h"
108 #include "be_enum_val.h"
109 #include "be_array.h"
110 #include "be_sequence.h"
112 #include "be_string.h"
113 #include "be_typedef.h"
114 #include "be_native.h"
115 #include "be_fixed.h"
116 #include "be_factory.h"
117 #include "be_finder.h"
118 #include "utl_identifier.h"
119 #include "nr_extern.h"
120 #include "ace/config-all.h"
123 be_generator::create_root (UTL_ScopedName
*n
)
125 be_root
*retval
= nullptr;
126 ACE_NEW_RETURN (retval
,
134 be_generator::create_predefined_type (AST_PredefinedType::PredefinedType t
,
137 be_predefined_type
*retval
= nullptr;
138 ACE_NEW_RETURN (retval
,
139 be_predefined_type (t
,
147 be_generator::create_module (UTL_Scope
*s
,
150 AST_Module
*retval
= nullptr;
152 // Check for another module of the same name in this scope.
153 for (UTL_ScopeActiveIterator
iter (s
, UTL_Scope::IK_decls
);
157 // Can't just check node type here, since it could be a
158 // template module or template module instantiation.
159 AST_Module
*m
= dynamic_cast<AST_Module
*> (iter
.item ());
161 if (m
&& m
->local_name ()->compare (n
->last_component ()))
163 // Create this new module with referance to the
164 // "first" previous module found in scope.
165 ACE_NEW_RETURN (retval
, be_module (n
, m
), nullptr);
166 retval
->prefix (const_cast<char *> (m
->prefix ()));
171 // Since the scope didn't contain the same module name, it
172 // doesn't mean that we haven't see it before. If the scope
173 // is itself a module, and has been previously opened, any
174 // of the previous openings may contain a previous opening
175 // of the module we're creating.
176 AST_Module
*prev_module
= dynamic_cast<AST_Module
*> (s
);
179 while (!!(prev_module
= prev_module
->previous_opening ()))
181 for (UTL_ScopeActiveIterator
iter (prev_module
, UTL_Scope::IK_decls
);
185 AST_Module
*m
= dynamic_cast<AST_Module
*> (iter
.item ());
186 if (m
&& m
->local_name ()->compare (n
->last_component ()))
188 // Create this new module with referance to the
189 // "first" previous module found in scope.
190 ACE_NEW_RETURN (retval
, be_module (n
, m
), nullptr);
197 // There is no previous module to be found
198 ACE_NEW_RETURN (retval
, be_module (n
), nullptr);
203 be_generator::create_interface (UTL_ScopedName
*n
,
206 AST_Interface
**ih_flat
,
211 be_interface
*retval
= nullptr;
212 ACE_NEW_RETURN (retval
,
222 /// Trigger this interation over the included pragmas when the
223 /// first local interface is seen in the main file. In an
224 /// executor IDL file (the case we want), this happens near the
225 /// top. In other files, it will do no harm.
226 if (l
&& idl_global
->in_main_file ())
228 FE_Utils::create_implied_ami_uses_stuff ();
235 be_generator::create_interface_fwd (UTL_ScopedName
*n
,
239 AST_Interface
*full_defn
= this->create_interface (n
,
247 be_interface_fwd
*retval
= nullptr;
248 ACE_NEW_RETURN (retval
,
249 be_interface_fwd (full_defn
,
253 full_defn
->fwd_decl (retval
);
258 be_generator::create_valuebox (UTL_ScopedName
*n
,
259 AST_Type
*boxed_type
)
261 be_valuebox
*retval
= nullptr;
262 ACE_NEW_RETURN (retval
,
263 be_valuebox (boxed_type
,
271 be_generator::create_valuetype (UTL_ScopedName
*n
,
274 AST_Type
*inherits_concrete
,
275 AST_Interface
**inherits_flat
,
276 long n_inherits_flat
,
277 AST_Type
**supports_list
,
279 AST_Type
*supports_concrete
,
284 be_valuetype
*retval
= nullptr;
285 ACE_NEW_RETURN (retval
,
304 be_generator::create_valuetype_fwd (UTL_ScopedName
*n
,
307 AST_ValueType
*full_defn
= this->create_valuetype (n
,
320 be_valuetype_fwd
*retval
= nullptr;
321 ACE_NEW_RETURN (retval
,
322 be_valuetype_fwd (full_defn
,
326 full_defn
->fwd_decl (retval
);
331 be_generator::create_eventtype (UTL_ScopedName
*n
,
334 AST_Type
*inherits_concrete
,
335 AST_Interface
**inherits_flat
,
336 long n_inherits_flat
,
337 AST_Type
**supports_list
,
339 AST_Type
*supports_concrete
,
344 be_eventtype
*retval
= nullptr;
345 ACE_NEW_RETURN (retval
,
364 be_generator::create_eventtype_fwd (UTL_ScopedName
*n
,
367 AST_EventType
*full_defn
= this->create_eventtype (n
,
380 be_eventtype_fwd
*retval
= nullptr;
381 ACE_NEW_RETURN (retval
,
382 be_eventtype_fwd (full_defn
,
386 full_defn
->fwd_decl (retval
);
391 be_generator::create_component (UTL_ScopedName
*n
,
392 AST_Component
*base_component
,
393 AST_Type
**supports_list
,
395 AST_Interface
**supports_flat
,
396 long n_supports_flat
)
398 be_component
*retval
= nullptr;
399 ACE_NEW_RETURN (retval
,
412 be_generator::create_component_fwd (UTL_ScopedName
*n
)
414 AST_Component
*full_defn
= this->create_component (n
,
421 be_component_fwd
*retval
= nullptr;
422 ACE_NEW_RETURN (retval
,
423 be_component_fwd (full_defn
,
427 full_defn
->fwd_decl (retval
);
432 be_generator::create_home (UTL_ScopedName
*n
,
434 AST_Component
*managed_component
,
435 AST_Type
*primary_key
,
436 AST_Type
**supports_list
,
438 AST_Interface
**supports_flat
,
439 long n_supports_flat
)
441 be_home
*retval
= nullptr;
442 ACE_NEW_RETURN (retval
,
457 be_generator::create_exception (UTL_ScopedName
*n
,
461 be_exception
*retval
= nullptr;
462 ACE_NEW_RETURN (retval
,
472 be_generator::create_structure (UTL_ScopedName
*n
,
476 be_structure
*retval
= nullptr;
477 ACE_NEW_RETURN (retval
,
487 be_generator::create_structure_fwd (UTL_ScopedName
*n
)
489 AST_Structure
*full_defn
= this->create_structure (n
,
492 be_structure_fwd
*retval
= nullptr;
493 ACE_NEW_RETURN (retval
,
494 be_structure_fwd (full_defn
,
498 full_defn
->fwd_decl (retval
);
503 be_generator::create_enum (UTL_ScopedName
*n
,
507 be_enum
*retval
= nullptr;
508 ACE_NEW_RETURN (retval
,
518 be_generator::create_operation (AST_Type
*rt
,
519 AST_Operation::Flags fl
,
524 be_operation
*retval
= nullptr;
525 ACE_NEW_RETURN (retval
,
537 be_generator::create_field (AST_Type
*ft
,
539 AST_Field::Visibility vis
)
541 be_field
*retval
= nullptr;
542 ACE_NEW_RETURN (retval
,
552 be_generator::create_argument (AST_Argument::Direction d
,
556 be_argument
*retval
= nullptr;
557 ACE_NEW_RETURN (retval
,
567 be_generator::create_attribute (bool ro
,
573 be_attribute
*retval
= nullptr;
574 ACE_NEW_RETURN (retval
,
586 be_generator::create_union (AST_ConcreteType
*dt
,
591 be_union
*retval
= nullptr;
592 ACE_NEW_RETURN (retval
,
603 be_generator::create_union_fwd (UTL_ScopedName
*n
)
605 AST_Union
*full_defn
= this->create_union (nullptr,
609 be_union_fwd
*retval
= nullptr;
610 ACE_NEW_RETURN (retval
,
611 be_union_fwd (full_defn
,
615 full_defn
->fwd_decl (retval
);
620 be_generator::create_union_branch (UTL_LabelList
*ll
,
624 be_union_branch
*retval
= nullptr;
625 ACE_NEW_RETURN (retval
,
635 be_generator::create_union_label (AST_UnionLabel::UnionLabel ul
,
638 be_union_label
*retval
= nullptr;
639 ACE_NEW_RETURN (retval
,
648 be_generator::create_constant (AST_Expression::ExprType et
,
652 be_constant
*retval
= nullptr;
653 ACE_NEW_RETURN (retval
,
663 be_generator::create_expr (UTL_ScopedName
*n
)
665 be_expression
*retval
= nullptr;
666 ACE_NEW_RETURN (retval
,
674 be_generator::create_expr (AST_Expression
*b
,
675 AST_Expression::ExprType t
)
677 be_expression
*retval
= nullptr;
678 ACE_NEW_RETURN (retval
,
687 be_generator::create_expr (AST_Expression::ExprComb c
,
691 be_expression
*retval
= nullptr;
692 ACE_NEW_RETURN (retval
,
702 be_generator::create_expr (ACE_CDR::Long l
)
704 be_expression
*retval
= nullptr;
705 ACE_NEW_RETURN (retval
,
713 be_generator::create_expr (ACE_CDR::LongLong l
)
715 be_expression
*retval
= nullptr;
716 ACE_NEW_RETURN (retval
,
724 be_generator::create_expr (ACE_CDR::Boolean b
)
726 be_expression
*retval
= nullptr;
727 ACE_NEW_RETURN (retval
,
735 be_generator::create_expr (ACE_CDR::ULong l
)
737 be_expression
*retval
= nullptr;
738 ACE_NEW_RETURN (retval
,
746 be_generator::create_expr (ACE_CDR::ULongLong l
)
748 be_expression
*retval
= nullptr;
749 ACE_NEW_RETURN (retval
,
757 be_generator::create_expr (ACE_CDR::ULong l
,
758 AST_Expression::ExprType t
)
760 be_expression
*retval
= nullptr;
761 ACE_NEW_RETURN (retval
,
762 be_expression (l
, t
),
769 be_generator::create_expr (UTL_String
*s
)
771 be_expression
*retval
= nullptr;
772 ACE_NEW_RETURN (retval
,
780 be_generator::create_expr (ACE_CDR::Char c
)
782 be_expression
*retval
= nullptr;
783 ACE_NEW_RETURN (retval
,
791 be_generator::create_expr (ACE_OutputCDR::from_wchar wc
)
793 be_expression
*retval
= nullptr;
794 ACE_NEW_RETURN (retval
,
802 be_generator::create_expr (char *s
)
804 be_expression
*retval
= nullptr;
805 ACE_NEW_RETURN (retval
,
813 be_generator::create_expr (ACE_CDR::Double d
)
815 be_expression
*retval
= nullptr;
816 ACE_NEW_RETURN (retval
,
824 be_generator::create_expr (const ACE_CDR::Fixed
&f
)
826 be_expression
*retval
= nullptr;
827 ACE_NEW_RETURN (retval
,
835 be_generator::create_enum_val (ACE_CDR::ULong v
,
838 be_enum_val
*retval
= nullptr;
839 ACE_NEW_RETURN (retval
,
848 be_generator::create_array (UTL_ScopedName
*n
,
849 ACE_CDR::ULong ndims
,
854 be_array
*retval
= nullptr;
855 ACE_NEW_RETURN (retval
,
867 be_generator::create_sequence (AST_Expression
*v
,
873 be_sequence
*retval
= nullptr;
874 ACE_NEW_RETURN (retval
,
886 be_generator::create_map (AST_Expression
*v
,
893 be_map
*retval
= nullptr;
894 ACE_NEW_RETURN (retval
,
907 be_generator::create_string (AST_Expression
*v
)
909 Identifier
id ("string");
910 UTL_ScopedName
n (&id
,
913 be_string
*retval
= nullptr;
914 ACE_NEW_RETURN (retval
,
915 be_string (AST_Decl::NT_string
,
925 be_generator::create_wstring (AST_Expression
*v
)
927 Identifier
id (sizeof (ACE_CDR::WChar
) == 1
930 UTL_ScopedName
n (&id
,
932 AST_Decl::NodeType nt
= sizeof (ACE_CDR::WChar
) == 1
933 ? AST_Decl::NT_string
934 : AST_Decl::NT_wstring
;
936 be_string
*retval
= nullptr;
937 ACE_NEW_RETURN (retval
,
941 sizeof (ACE_CDR::WChar
)),
948 be_generator::create_fixed (AST_Expression
*digits
,
949 AST_Expression
*scale
)
951 Identifier
id ("fixed");
952 UTL_ScopedName
name (&id
, nullptr);
953 AST_Fixed
*retval
= nullptr;
954 ACE_NEW_RETURN (retval
, be_fixed (&name
, digits
, scale
), nullptr);
959 be_generator::create_typedef (AST_Type
*bt
,
964 be_typedef
*retval
= nullptr;
965 ACE_NEW_RETURN (retval
,
976 be_generator::create_native (UTL_ScopedName
*n
)
978 be_native
*retval
= nullptr;
979 ACE_NEW_RETURN (retval
,
987 be_generator::create_factory (UTL_ScopedName
*n
)
989 be_factory
*retval
= nullptr;
990 ACE_NEW_RETURN (retval
,
998 be_generator::create_finder (UTL_ScopedName
*n
)
1000 be_finder
*retval
= nullptr;
1001 ACE_NEW_RETURN (retval
,
1009 be_generator::create_porttype (UTL_ScopedName
*n
)
1011 be_porttype
*retval
= nullptr;
1012 ACE_NEW_RETURN (retval
,
1020 be_generator::create_provides (UTL_ScopedName
*n
,
1021 AST_Type
*provides_type
)
1023 be_provides
*retval
= nullptr;
1024 ACE_NEW_RETURN (retval
,
1033 be_generator::create_uses (UTL_ScopedName
*n
,
1034 AST_Type
*uses_type
,
1037 be_uses
*retval
= nullptr;
1038 ACE_NEW_RETURN (retval
,
1048 be_generator::create_publishes (UTL_ScopedName
*n
,
1049 AST_Type
*publishes_type
)
1051 be_publishes
*retval
= nullptr;
1052 ACE_NEW_RETURN (retval
,
1061 be_generator::create_emits (UTL_ScopedName
*n
,
1062 AST_Type
*emits_type
)
1064 be_emits
*retval
= nullptr;
1065 ACE_NEW_RETURN (retval
,
1073 be_generator::create_consumes (UTL_ScopedName
*n
,
1074 AST_Type
*consumes_type
)
1076 be_consumes
*retval
= nullptr;
1077 ACE_NEW_RETURN (retval
,
1086 be_generator::create_extended_port (
1088 AST_PortType
*porttype_ref
)
1090 be_extended_port
*retval
= nullptr;
1091 ACE_NEW_RETURN (retval
,
1092 be_extended_port (n
,
1100 be_generator::create_mirror_port (
1102 AST_PortType
*porttype_ref
)
1104 be_mirror_port
*retval
= nullptr;
1105 ACE_NEW_RETURN (retval
,
1114 be_generator::create_connector (
1116 AST_Connector
*base_connector
)
1118 be_connector
*retval
= nullptr;
1119 ACE_NEW_RETURN (retval
,
1127 AST_Template_Module
*
1128 be_generator::create_template_module (
1130 FE_Utils::T_PARAMLIST_INFO
*template_params
)
1132 be_template_module
*retval
= nullptr;
1133 ACE_NEW_RETURN (retval
,
1134 be_template_module (n
,
1141 AST_Template_Module_Inst
*
1142 be_generator::create_template_module_inst (
1144 AST_Template_Module
*ref
,
1145 FE_Utils::T_ARGLIST
*template_args
)
1147 be_template_module_inst
*retval
= nullptr;
1148 ACE_NEW_RETURN (retval
,
1149 be_template_module_inst (n
,
1157 AST_Template_Module_Ref
*
1158 be_generator::create_template_module_ref (
1160 AST_Template_Module
*ref
,
1161 UTL_StrList
*param_refs
)
1163 be_template_module_ref
*retval
= nullptr;
1164 ACE_NEW_RETURN (retval
,
1165 be_template_module_ref (n
,
1174 be_generator::create_param_holder (
1175 UTL_ScopedName
*parameter_name
,
1176 FE_Utils::T_Param_Info
*info
)
1178 be_param_holder
*retval
= nullptr;
1179 ACE_NEW_RETURN (retval
,
1180 be_param_holder (parameter_name
,