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"
111 #include "be_string.h"
112 #include "be_typedef.h"
113 #include "be_native.h"
114 #include "be_fixed.h"
115 #include "be_factory.h"
116 #include "be_finder.h"
117 #include "utl_identifier.h"
118 #include "nr_extern.h"
119 #include "ace/config-all.h"
122 be_generator::create_root (UTL_ScopedName
*n
)
125 ACE_NEW_RETURN (retval
,
133 be_generator::create_predefined_type (AST_PredefinedType::PredefinedType t
,
136 be_predefined_type
*retval
= 0;
137 ACE_NEW_RETURN (retval
,
138 be_predefined_type (t
,
146 be_generator::create_module (UTL_Scope
*s
,
149 AST_Module
*retval
= 0;
151 // Check for another module of the same name in this scope.
152 for (UTL_ScopeActiveIterator
iter (s
, UTL_Scope::IK_decls
);
156 // Can't just check node type here, since it could be a
157 // template module or template module instantiation.
158 AST_Module
*m
= dynamic_cast<AST_Module
*> (iter
.item ());
160 if (m
&& m
->local_name ()->compare (n
->last_component ()))
162 // Create this new module with referance to the
163 // "first" previous module found in scope.
164 ACE_NEW_RETURN (retval
, be_module (n
, m
), 0);
165 retval
->prefix (const_cast<char *> (m
->prefix ()));
170 // Since the scope didn't contain the same module name, it
171 // doesn't mean that we haven't see it before. If the scope
172 // is itself a module, and has been previously opened, any
173 // of the previous openings may contain a previous opening
174 // of the module we're creating.
175 AST_Module
*prev_module
= dynamic_cast<AST_Module
*> (s
);
178 while (!!(prev_module
= prev_module
->previous_opening ()))
180 for (UTL_ScopeActiveIterator
iter (prev_module
, UTL_Scope::IK_decls
);
184 AST_Module
*m
= dynamic_cast<AST_Module
*> (iter
.item ());
185 if (m
&& m
->local_name ()->compare (n
->last_component ()))
187 // Create this new module with referance to the
188 // "first" previous module found in scope.
189 ACE_NEW_RETURN (retval
, be_module (n
, m
), 0);
196 // There is no previous module to be found
197 ACE_NEW_RETURN (retval
, be_module (n
), 0);
202 be_generator::create_interface (UTL_ScopedName
*n
,
205 AST_Interface
**ih_flat
,
210 be_interface
*retval
= 0;
211 ACE_NEW_RETURN (retval
,
221 /// Trigger this interation over the included pragmas when the
222 /// first local interface is seen in the main file. In an
223 /// executor IDL file (the case we want), this happens near the
224 /// top. In other files, it will do no harm.
225 if (l
&& idl_global
->in_main_file ())
227 FE_Utils::create_implied_ami_uses_stuff ();
234 be_generator::create_interface_fwd (UTL_ScopedName
*n
,
238 AST_Interface
*full_defn
= this->create_interface (n
,
246 be_interface_fwd
*retval
= 0;
247 ACE_NEW_RETURN (retval
,
248 be_interface_fwd (full_defn
,
252 full_defn
->fwd_decl (retval
);
257 be_generator::create_valuebox (UTL_ScopedName
*n
,
258 AST_Type
*boxed_type
)
260 be_valuebox
*retval
= 0;
261 ACE_NEW_RETURN (retval
,
262 be_valuebox (boxed_type
,
270 be_generator::create_valuetype (UTL_ScopedName
*n
,
273 AST_Type
*inherits_concrete
,
274 AST_Interface
**inherits_flat
,
275 long n_inherits_flat
,
276 AST_Type
**supports_list
,
278 AST_Type
*supports_concrete
,
283 be_valuetype
*retval
= 0;
284 ACE_NEW_RETURN (retval
,
303 be_generator::create_valuetype_fwd (UTL_ScopedName
*n
,
306 AST_ValueType
*full_defn
= this->create_valuetype (n
,
319 be_valuetype_fwd
*retval
= 0;
320 ACE_NEW_RETURN (retval
,
321 be_valuetype_fwd (full_defn
,
325 full_defn
->fwd_decl (retval
);
330 be_generator::create_eventtype (UTL_ScopedName
*n
,
333 AST_Type
*inherits_concrete
,
334 AST_Interface
**inherits_flat
,
335 long n_inherits_flat
,
336 AST_Type
**supports_list
,
338 AST_Type
*supports_concrete
,
343 be_eventtype
*retval
= 0;
344 ACE_NEW_RETURN (retval
,
363 be_generator::create_eventtype_fwd (UTL_ScopedName
*n
,
366 AST_EventType
*full_defn
= this->create_eventtype (n
,
379 be_eventtype_fwd
*retval
= 0;
380 ACE_NEW_RETURN (retval
,
381 be_eventtype_fwd (full_defn
,
385 full_defn
->fwd_decl (retval
);
390 be_generator::create_component (UTL_ScopedName
*n
,
391 AST_Component
*base_component
,
392 AST_Type
**supports_list
,
394 AST_Interface
**supports_flat
,
395 long n_supports_flat
)
397 be_component
*retval
= 0;
398 ACE_NEW_RETURN (retval
,
411 be_generator::create_component_fwd (UTL_ScopedName
*n
)
413 AST_Component
*full_defn
= this->create_component (n
,
420 be_component_fwd
*retval
= 0;
421 ACE_NEW_RETURN (retval
,
422 be_component_fwd (full_defn
,
426 full_defn
->fwd_decl (retval
);
431 be_generator::create_home (UTL_ScopedName
*n
,
433 AST_Component
*managed_component
,
434 AST_Type
*primary_key
,
435 AST_Type
**supports_list
,
437 AST_Interface
**supports_flat
,
438 long n_supports_flat
)
441 ACE_NEW_RETURN (retval
,
456 be_generator::create_exception (UTL_ScopedName
*n
,
460 be_exception
*retval
= 0;
461 ACE_NEW_RETURN (retval
,
471 be_generator::create_structure (UTL_ScopedName
*n
,
475 be_structure
*retval
= 0;
476 ACE_NEW_RETURN (retval
,
486 be_generator::create_structure_fwd (UTL_ScopedName
*n
)
489 AST_Structure
*full_defn
= this->create_structure (n
,
492 be_structure_fwd
*retval
= 0;
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
,
508 ACE_NEW_RETURN (retval
,
518 be_generator::create_operation (AST_Type
*rt
,
519 AST_Operation::Flags fl
,
524 be_operation
*retval
= 0;
525 ACE_NEW_RETURN (retval
,
537 be_generator::create_field (AST_Type
*ft
,
539 AST_Field::Visibility vis
)
541 be_field
*retval
= 0;
542 ACE_NEW_RETURN (retval
,
552 be_generator::create_argument (AST_Argument::Direction d
,
556 be_argument
*retval
= 0;
557 ACE_NEW_RETURN (retval
,
567 be_generator::create_attribute (bool ro
,
573 be_attribute
*retval
= 0;
574 ACE_NEW_RETURN (retval
,
586 be_generator::create_union (AST_ConcreteType
*dt
,
591 be_union
*retval
= 0;
592 ACE_NEW_RETURN (retval
,
603 be_generator::create_union_fwd (UTL_ScopedName
*n
)
605 AST_Union
*full_defn
= this->create_union (0,
609 be_union_fwd
*retval
= 0;
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
= 0;
625 ACE_NEW_RETURN (retval
,
635 be_generator::create_union_label (AST_UnionLabel::UnionLabel ul
,
638 be_union_label
*retval
= 0;
639 ACE_NEW_RETURN (retval
,
648 be_generator::create_constant (AST_Expression::ExprType et
,
652 be_constant
*retval
= 0;
653 ACE_NEW_RETURN (retval
,
663 be_generator::create_expr (UTL_ScopedName
*n
)
665 be_expression
*retval
= 0;
666 ACE_NEW_RETURN (retval
,
674 be_generator::create_expr (AST_Expression
*b
,
675 AST_Expression::ExprType t
)
677 be_expression
*retval
= 0;
678 ACE_NEW_RETURN (retval
,
687 be_generator::create_expr (AST_Expression::ExprComb c
,
691 be_expression
*retval
= 0;
692 ACE_NEW_RETURN (retval
,
702 be_generator::create_expr (ACE_CDR::Long l
)
704 be_expression
*retval
= 0;
705 ACE_NEW_RETURN (retval
,
713 be_generator::create_expr (ACE_CDR::LongLong l
)
715 be_expression
*retval
= 0;
716 ACE_NEW_RETURN (retval
,
724 be_generator::create_expr (ACE_CDR::Boolean b
)
726 be_expression
*retval
= 0;
727 ACE_NEW_RETURN (retval
,
735 be_generator::create_expr (ACE_CDR::ULong l
)
737 be_expression
*retval
= 0;
738 ACE_NEW_RETURN (retval
,
746 be_generator::create_expr (ACE_CDR::ULongLong l
)
748 be_expression
*retval
= 0;
749 ACE_NEW_RETURN (retval
,
757 be_generator::create_expr (ACE_CDR::ULong l
,
758 AST_Expression::ExprType t
)
760 be_expression
*retval
= 0;
761 ACE_NEW_RETURN (retval
,
762 be_expression (l
, t
),
769 be_generator::create_expr (UTL_String
*s
)
771 be_expression
*retval
= 0;
772 ACE_NEW_RETURN (retval
,
780 be_generator::create_expr (ACE_CDR::Char c
)
782 be_expression
*retval
= 0;
783 ACE_NEW_RETURN (retval
,
791 be_generator::create_expr (ACE_OutputCDR::from_wchar wc
)
793 be_expression
*retval
= 0;
794 ACE_NEW_RETURN (retval
,
802 be_generator::create_expr (char *s
)
804 be_expression
*retval
= 0;
805 ACE_NEW_RETURN (retval
,
813 be_generator::create_expr (ACE_CDR::Double d
)
815 be_expression
*retval
= 0;
816 ACE_NEW_RETURN (retval
,
824 be_generator::create_expr (const ACE_CDR::Fixed
&f
)
826 be_expression
*retval
= 0;
827 ACE_NEW_RETURN (retval
,
835 be_generator::create_enum_val (ACE_CDR::ULong v
,
838 be_enum_val
*retval
= 0;
839 ACE_NEW_RETURN (retval
,
848 be_generator::create_array (UTL_ScopedName
*n
,
849 ACE_CDR::ULong ndims
,
854 be_array
*retval
= 0;
855 ACE_NEW_RETURN (retval
,
867 be_generator::create_sequence (AST_Expression
*v
,
873 be_sequence
*retval
= 0;
874 ACE_NEW_RETURN (retval
,
886 be_generator::create_string (AST_Expression
*v
)
888 Identifier
id ("string");
889 UTL_ScopedName
n (&id
,
892 be_string
*retval
= 0;
893 ACE_NEW_RETURN (retval
,
894 be_string (AST_Decl::NT_string
,
904 be_generator::create_wstring (AST_Expression
*v
)
906 Identifier
id (sizeof (ACE_CDR::WChar
) == 1
909 UTL_ScopedName
n (&id
,
911 AST_Decl::NodeType nt
= sizeof (ACE_CDR::WChar
) == 1
912 ? AST_Decl::NT_string
913 : AST_Decl::NT_wstring
;
915 be_string
*retval
= 0;
916 ACE_NEW_RETURN (retval
,
920 sizeof (ACE_CDR::WChar
)),
927 be_generator::create_fixed (AST_Expression
*digits
,
928 AST_Expression
*scale
)
930 Identifier
id ("fixed");
931 UTL_ScopedName
name (&id
, 0);
932 AST_Fixed
*retval
= 0;
933 ACE_NEW_RETURN (retval
, be_fixed (&name
, digits
, scale
), 0);
938 be_generator::create_typedef (AST_Type
*bt
,
943 be_typedef
*retval
= 0;
944 ACE_NEW_RETURN (retval
,
955 be_generator::create_native (UTL_ScopedName
*n
)
957 be_native
*retval
= 0;
958 ACE_NEW_RETURN (retval
,
966 be_generator::create_factory (UTL_ScopedName
*n
)
968 be_factory
*retval
= 0;
969 ACE_NEW_RETURN (retval
,
977 be_generator::create_finder (UTL_ScopedName
*n
)
979 be_finder
*retval
= 0;
980 ACE_NEW_RETURN (retval
,
988 be_generator::create_porttype (UTL_ScopedName
*n
)
990 be_porttype
*retval
= 0;
991 ACE_NEW_RETURN (retval
,
999 be_generator::create_provides (UTL_ScopedName
*n
,
1000 AST_Type
*provides_type
)
1002 be_provides
*retval
= 0;
1003 ACE_NEW_RETURN (retval
,
1012 be_generator::create_uses (UTL_ScopedName
*n
,
1013 AST_Type
*uses_type
,
1016 be_uses
*retval
= 0;
1017 ACE_NEW_RETURN (retval
,
1027 be_generator::create_publishes (UTL_ScopedName
*n
,
1028 AST_Type
*publishes_type
)
1030 be_publishes
*retval
= 0;
1031 ACE_NEW_RETURN (retval
,
1040 be_generator::create_emits (UTL_ScopedName
*n
,
1041 AST_Type
*emits_type
)
1043 be_emits
*retval
= 0;
1044 ACE_NEW_RETURN (retval
,
1052 be_generator::create_consumes (UTL_ScopedName
*n
,
1053 AST_Type
*consumes_type
)
1055 be_consumes
*retval
= 0;
1056 ACE_NEW_RETURN (retval
,
1065 be_generator::create_extended_port (
1067 AST_PortType
*porttype_ref
)
1069 be_extended_port
*retval
= 0;
1070 ACE_NEW_RETURN (retval
,
1071 be_extended_port (n
,
1079 be_generator::create_mirror_port (
1081 AST_PortType
*porttype_ref
)
1083 be_mirror_port
*retval
= 0;
1084 ACE_NEW_RETURN (retval
,
1093 be_generator::create_connector (
1095 AST_Connector
*base_connector
)
1097 be_connector
*retval
= 0;
1098 ACE_NEW_RETURN (retval
,
1106 AST_Template_Module
*
1107 be_generator::create_template_module (
1109 FE_Utils::T_PARAMLIST_INFO
*template_params
)
1111 be_template_module
*retval
= 0;
1112 ACE_NEW_RETURN (retval
,
1113 be_template_module (n
,
1120 AST_Template_Module_Inst
*
1121 be_generator::create_template_module_inst (
1123 AST_Template_Module
*ref
,
1124 FE_Utils::T_ARGLIST
*template_args
)
1126 be_template_module_inst
*retval
= 0;
1127 ACE_NEW_RETURN (retval
,
1128 be_template_module_inst (n
,
1136 AST_Template_Module_Ref
*
1137 be_generator::create_template_module_ref (
1139 AST_Template_Module
*ref
,
1140 UTL_StrList
*param_refs
)
1142 be_template_module_ref
*retval
= 0;
1143 ACE_NEW_RETURN (retval
,
1144 be_template_module_ref (n
,
1153 be_generator::create_param_holder (
1154 UTL_ScopedName
*parameter_name
,
1155 FE_Utils::T_Param_Info
*info
)
1157 be_param_holder
*retval
= 0;
1158 ACE_NEW_RETURN (retval
,
1159 be_param_holder (parameter_name
,