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 // AST_Expression nodes denote IDL expressions used in the IDL input.
67 #include "ast_expression.h"
68 #include "ast_constant.h"
69 #include "ast_typedef.h"
70 #include "ast_param_holder.h"
71 #include "ast_visitor.h"
72 #include "ast_generator.h"
73 #include "ast_enum_val.h"
76 #include "utl_scope.h"
77 #include "utl_string.h"
79 #include "nr_extern.h"
80 #include "global_extern.h"
83 #include "ace/OS_NS_stdio.h"
84 // FUZZ: disable check_for_streams_include
85 #include "ace/streams.h"
87 AST_Expression::ExprType
88 AST_Expression::eval_kind_to_expr_type (AST_Expression::EvalKind eval_kind
)
101 case EK_positive_int
:
109 case EK_floating_point
:
118 idl_global
->err ()->misc_error ("eval_kind_to_expr_type can't handle EK_const");
122 idl_global
->err ()->misc_error ("eval_kind_to_expr_type unhandled EvalKind");
126 // Helper function to fill out the details of where this expression
129 AST_Expression::fill_definition_details (void)
131 this->pd_defined_in
= idl_global
->scopes ().depth () > 0
132 ? idl_global
->scopes ().top ()
134 this->pd_line
= idl_global
->lineno ();
135 this->pd_file_name
= idl_global
->filename ();
139 // An AST_Expression denoting a symbolic name.
140 AST_Expression::AST_Expression (UTL_ScopedName
*nm
)
149 this->fill_definition_details ();
152 idl_global
->scopes ().top_non_null ()->lookup_by_name (nm
,
155 if (d
->node_type () == AST_Decl::NT_param_holder
)
157 this->param_holder_
=
158 dynamic_cast<AST_Param_Holder
*> (d
);
162 // An AST_Expression denoting a type coercion from another AST_Expression.
163 AST_Expression::AST_Expression (AST_Expression
*v
,
173 AST_Param_Holder
*ph
= v
->param_holder_
;
174 this->fill_definition_details ();
175 enum_parent (v
->enum_parent ());
177 // If we are here because one string constant has
178 // another one as its rhs, we must copy the UTL_String
179 // so both can be destroyed at cleanup.
182 ACE_NEW (this->pd_ev
,
185 ACE_NEW (this->pd_ev
->u
.strval
,
186 UTL_String (v
->pd_ev
->u
.strval
, true));
188 this->pd_ev
->et
= EV_string
;
190 else if (EV_wstring
== t
)
192 ACE_NEW (this->pd_ev
,
195 this->pd_ev
->u
.wstrval
= ACE::strnew (v
->pd_ev
->u
.wstrval
);
196 this->pd_ev
->et
= EV_string
;
202 this->pd_ev
= v
->coerce (t
);
204 if (this->pd_ev
== 0)
206 idl_global
->err ()->coercion_error (v
, t
);
211 // The param info member isn't managed by this type,
212 // so we can just pass the pointer to the new expr.
213 this->param_holder_
=
214 idl_global
->gen ()->create_param_holder (
216 const_cast<FE_Utils::T_Param_Info
*> (ph
->info ()));
222 dynamic_cast<UTL_ScopedName
*> (v
->pd_n
->copy ());
227 // An AST_Expression denoting a binary expression combination from
228 // two other AST_Expressions.
229 AST_Expression::AST_Expression (ExprComb c
,
240 this->fill_definition_details ();
243 // An AST_Expression denoting a short integer.
244 AST_Expression::AST_Expression (ACE_CDR::Short sv
)
253 this->fill_definition_details ();
255 ACE_NEW (this->pd_ev
,
258 this->pd_ev
->et
= EV_short
;
259 this->pd_ev
->u
.sval
= sv
;
262 // An AST_Expression denoting an unsigned short integer.
263 AST_Expression::AST_Expression (ACE_CDR::UShort usv
)
272 this->fill_definition_details ();
274 ACE_NEW (this->pd_ev
,
277 this->pd_ev
->et
= EV_ushort
;
278 this->pd_ev
->u
.usval
= usv
;
281 // An AST_Expression denoting a long integer.
282 AST_Expression::AST_Expression (ACE_CDR::Long lv
)
291 this->fill_definition_details ();
293 ACE_NEW (this->pd_ev
,
296 this->pd_ev
->et
= EV_long
;
297 this->pd_ev
->u
.lval
= lv
;
300 // An AST_Expression denoting a long integer.
301 AST_Expression::AST_Expression (ACE_CDR::LongLong llv
)
310 this->fill_definition_details ();
312 ACE_NEW (this->pd_ev
,
315 this->pd_ev
->et
= EV_longlong
;
316 this->pd_ev
->u
.llval
= llv
;
319 // An AST_Expression denoting a boolean.
320 AST_Expression::AST_Expression (ACE_CDR::Boolean b
)
329 this->fill_definition_details ();
331 ACE_NEW (this->pd_ev
,
334 this->pd_ev
->et
= EV_bool
;
335 this->pd_ev
->u
.bval
= b
;
338 // An AST_Expression denoting an unsigned long integer.
339 AST_Expression::AST_Expression (ACE_CDR::ULong ulv
)
348 this->fill_definition_details ();
350 ACE_NEW (this->pd_ev
,
353 this->pd_ev
->et
= EV_ulong
;
354 this->pd_ev
->u
.ulval
= ulv
;
357 // An AST_Expression denoting an unsigned long long integer.
358 AST_Expression::AST_Expression (ACE_CDR::ULongLong ulv
)
367 this->fill_definition_details ();
369 ACE_NEW (this->pd_ev
,
372 this->pd_ev
->et
= EV_ulonglong
;
373 this->pd_ev
->u
.ullval
= ulv
;
376 // An AST_Expression denoting an unsigned long integer.
377 AST_Expression::AST_Expression (ACE_CDR::ULong ulv
,
387 this->fill_definition_details ();
389 ACE_NEW (this->pd_ev
,
393 this->pd_ev
->u
.ullval
= ulv
;
396 // An AST_Expression denoting a 32-bit floating point number.
397 AST_Expression::AST_Expression (ACE_CDR::Float fv
)
406 this->fill_definition_details ();
408 ACE_NEW (this->pd_ev
,
411 this->pd_ev
->et
= EV_float
;
412 this->pd_ev
->u
.fval
= fv
;
415 // An AST_Expression denoting a 64-bit floating point number.
416 AST_Expression::AST_Expression (ACE_CDR::Double dv
)
425 this->fill_definition_details ();
427 ACE_NEW (this->pd_ev
,
430 this->pd_ev
->et
= EV_double
;
431 this->pd_ev
->u
.dval
= dv
;
434 // An AST_Expression denoting a character.
435 AST_Expression::AST_Expression (ACE_CDR::Char cv
)
444 this->fill_definition_details ();
446 ACE_NEW (this->pd_ev
,
449 this->pd_ev
->et
= EV_char
;
450 this->pd_ev
->u
.cval
= cv
;
453 // An AST_Expression denoting a wide character.
454 AST_Expression::AST_Expression (ACE_OutputCDR::from_wchar wcv
)
463 this->fill_definition_details ();
465 ACE_NEW (this->pd_ev
,
468 this->pd_ev
->et
= EV_wchar
;
469 this->pd_ev
->u
.wcval
= wcv
.val_
;
472 // An AST_Expression denoting an octet (unsigned char).
473 AST_Expression::AST_Expression (ACE_CDR::Octet ov
)
482 this->fill_definition_details ();
484 ACE_NEW (this->pd_ev
,
487 this->pd_ev
->et
= EV_octet
;
488 this->pd_ev
->u
.oval
= ov
;
491 // An AST_Expression denoting a string (char * encapsulated as a String).
492 AST_Expression::AST_Expression (UTL_String
*sv
)
501 this->fill_definition_details ();
503 ACE_NEW (this->pd_ev
,
506 UTL_String
*new_str
= 0;
508 UTL_String (sv
, true));
510 this->pd_ev
->u
.strval
= new_str
;
511 this->pd_ev
->et
= EV_string
;
514 // An AST_Expression denoting a wide string.
515 AST_Expression::AST_Expression (char *sv
)
524 this->fill_definition_details ();
526 ACE_NEW (this->pd_ev
,
529 this->pd_ev
->et
= EV_wstring
;
530 this->pd_ev
->u
.wstrval
= ACE::strnew (sv
);
533 AST_Expression::AST_Expression (const ACE_CDR::Fixed
&f
)
542 this->fill_definition_details ();
544 ACE_NEW (this->pd_ev
,
547 this->pd_ev
->et
= EV_fixed
;
548 this->pd_ev
->u
.fixedval
= f
;
551 AST_Expression::~AST_Expression (void)
556 AST_Expression::AST_ExprValue::AST_ExprValue (void)
559 this->et
= AST_Expression::EV_none
;
562 // Static operations.
564 // Perform the coercion from the given AST_ExprValue to the requested
565 // ExprType. Return an AST_ExprValue if successful, 0 if failed.
566 static AST_Expression::AST_ExprValue
*
567 coerce_value (AST_Expression::AST_ExprValue
*ev
,
568 AST_Expression::ExprType t
)
580 // Avoid Coverity issue with "Assignment of overlapping memory" by using a
581 // temporary value and setting ev->u at the end if there wasn't an error.
582 AST_Expression::AST_ExprValue::Value tmp
;
585 case AST_Expression::EV_short
:
588 case AST_Expression::EV_ushort
:
589 if (ev
->u
.usval
> (ACE_CDR::UShort
) ACE_INT16_MAX
)
594 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.usval
;
596 case AST_Expression::EV_long
:
597 if (ev
->u
.lval
> (ACE_CDR::Long
) ACE_INT16_MAX
598 || ev
->u
.lval
< (ACE_CDR::Long
) ACE_INT16_MIN
)
603 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.lval
;
605 case AST_Expression::EV_ulong
:
606 if (ev
->u
.ulval
> (ACE_CDR::ULong
) ACE_INT16_MAX
)
611 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.ulval
;
613 case AST_Expression::EV_longlong
:
614 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_INT16_MAX
615 || ev
->u
.llval
< (ACE_CDR::LongLong
) ACE_INT16_MIN
)
620 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.llval
;
622 case AST_Expression::EV_ulonglong
:
623 if ((ev
->u
.ullval
& ACE_INT16_MAX
) != ev
->u
.ullval
)
628 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.ullval
;
630 case AST_Expression::EV_bool
:
631 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.bval
;
633 case AST_Expression::EV_float
:
634 if (ev
->u
.fval
> (ACE_CDR::Float
) ACE_INT16_MAX
635 || ev
->u
.fval
< (ACE_CDR::Float
) ACE_INT16_MIN
)
640 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.fval
;
642 case AST_Expression::EV_double
:
643 if (ev
->u
.dval
> (ACE_CDR::Double
) ACE_INT16_MAX
644 || ev
->u
.dval
< (ACE_CDR::Double
) ACE_INT16_MIN
)
649 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.dval
;
651 case AST_Expression::EV_char
:
652 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.cval
;
654 case AST_Expression::EV_wchar
:
655 if (ev
->u
.wcval
> (ACE_CDR::WChar
) ACE_INT16_MAX
)
660 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.wcval
;
662 case AST_Expression::EV_octet
:
663 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.oval
;
665 case AST_Expression::EV_int8
:
666 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.int8val
;
668 case AST_Expression::EV_uint8
:
669 tmp
.sval
= (ACE_CDR::Short
) ev
->u
.uint8val
;
676 case AST_Expression::EV_ushort
:
679 case AST_Expression::EV_short
:
685 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.sval
;
687 case AST_Expression::EV_long
:
688 if (ev
->u
.lval
> (ACE_CDR::Long
) ACE_UINT16_MAX
694 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.lval
;
696 case AST_Expression::EV_ulong
:
697 if (ev
->u
.ulval
> (ACE_CDR::ULong
) ACE_UINT16_MAX
)
702 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.ulval
;
704 case AST_Expression::EV_longlong
:
705 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_UINT16_MAX
711 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.llval
;
713 case AST_Expression::EV_ulonglong
:
714 if ((ev
->u
.ullval
& ACE_UINT16_MAX
) != ev
->u
.ullval
)
719 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.ullval
;
721 case AST_Expression::EV_bool
:
722 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.bval
;
724 case AST_Expression::EV_float
:
726 || ev
->u
.fval
> (ACE_CDR::Float
) ACE_UINT16_MAX
)
731 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.fval
;
733 case AST_Expression::EV_double
:
735 || ev
->u
.dval
> (ACE_CDR::Double
) ACE_UINT16_MAX
)
740 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.dval
;
742 case AST_Expression::EV_char
:
743 if ((signed char) ev
->u
.cval
< 0)
748 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.cval
;
750 case AST_Expression::EV_wchar
:
751 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.wcval
;
753 case AST_Expression::EV_octet
:
754 tmp
.usval
= (ACE_CDR::UShort
) ev
->u
.oval
;
756 case AST_Expression::EV_int8
:
757 if (ev
->u
.int8val
< 0) return 0;
758 tmp
.usval
= static_cast<ACE_CDR::UShort
> (ev
->u
.int8val
);
760 case AST_Expression::EV_uint8
:
761 tmp
.usval
= static_cast<ACE_CDR::UShort
> (ev
->u
.uint8val
);
768 case AST_Expression::EV_long
:
771 case AST_Expression::EV_short
:
772 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.sval
;
774 case AST_Expression::EV_ushort
:
775 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.usval
;
777 case AST_Expression::EV_ulong
:
778 if (ev
->u
.ulval
> (ACE_CDR::ULong
) ACE_INT32_MAX
)
783 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.ulval
;
785 case AST_Expression::EV_longlong
:
786 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_INT32_MAX
787 || ev
->u
.llval
< (ACE_CDR::LongLong
) ACE_INT32_MIN
)
791 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.llval
;
793 case AST_Expression::EV_ulonglong
:
794 if ((ev
->u
.ullval
& ACE_INT32_MAX
) != ev
->u
.ullval
)
799 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.ullval
;
801 case AST_Expression::EV_bool
:
802 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.bval
;
804 case AST_Expression::EV_float
:
805 if (ev
->u
.fval
> (ACE_CDR::Float
) ACE_INT32_MAX
806 || ev
->u
.fval
< (ACE_CDR::Float
) ACE_INT32_MIN
)
811 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.fval
;
813 case AST_Expression::EV_double
:
814 if (ev
->u
.dval
> (ACE_CDR::Double
) ACE_INT32_MAX
815 || ev
->u
.dval
< (ACE_CDR::Double
) ACE_INT32_MIN
)
820 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.dval
;
822 case AST_Expression::EV_char
:
823 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.cval
;
825 case AST_Expression::EV_wchar
:
826 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.wcval
;
828 case AST_Expression::EV_octet
:
829 tmp
.lval
= (ACE_CDR::Long
) ev
->u
.oval
;
831 case AST_Expression::EV_int8
:
832 tmp
.lval
= static_cast<ACE_CDR::Long
> (ev
->u
.int8val
);
834 case AST_Expression::EV_uint8
:
835 tmp
.lval
= static_cast<ACE_CDR::Long
> (ev
->u
.uint8val
);
842 case AST_Expression::EV_ulong
:
845 case AST_Expression::EV_short
:
851 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.sval
;
853 case AST_Expression::EV_ushort
:
854 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.usval
;
856 case AST_Expression::EV_long
:
862 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.lval
;
864 case AST_Expression::EV_longlong
:
865 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_UINT32_MAX
871 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.llval
;
873 case AST_Expression::EV_ulonglong
:
874 if ((ev
->u
.ullval
& ACE_UINT32_MAX
) != ev
->u
.ullval
)
878 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.ullval
;
880 case AST_Expression::EV_bool
:
881 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.bval
;
883 case AST_Expression::EV_float
:
885 || ev
->u
.fval
> (ACE_CDR::Float
) ACE_UINT32_MAX
)
890 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.fval
;
892 case AST_Expression::EV_double
:
894 || ev
->u
.dval
> (ACE_CDR::Double
) ACE_UINT32_MAX
)
899 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.dval
;
901 case AST_Expression::EV_char
:
902 if ((signed char) ev
->u
.cval
< 0)
907 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.cval
;
909 case AST_Expression::EV_wchar
:
910 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.wcval
;
912 case AST_Expression::EV_octet
:
913 tmp
.ulval
= (ACE_CDR::ULong
) ev
->u
.oval
;
915 case AST_Expression::EV_int8
:
916 if (ev
->u
.int8val
< 0) return 0;
917 tmp
.ulval
= static_cast<ACE_CDR::ULong
> (ev
->u
.int8val
);
919 case AST_Expression::EV_uint8
:
920 tmp
.ulval
= static_cast<ACE_CDR::ULong
> (ev
->u
.uint8val
);
927 case AST_Expression::EV_longlong
:
930 case AST_Expression::EV_short
:
931 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.sval
;
933 case AST_Expression::EV_ushort
:
934 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.usval
;
936 case AST_Expression::EV_long
:
937 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.lval
;
939 case AST_Expression::EV_ulong
:
940 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.ulval
;
942 case AST_Expression::EV_ulonglong
:
943 if (ev
->u
.ullval
> ACE_INT64_MAX
)
948 tmp
.llval
= static_cast<ACE_CDR::LongLong
> (ev
->u
.ullval
);
950 case AST_Expression::EV_bool
:
951 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.bval
;
953 case AST_Expression::EV_float
:
954 if (ev
->u
.fval
> (ACE_CDR::Float
) ACE_INT64_MAX
955 || ev
->u
.fval
< (ACE_CDR::Float
) ACE_INT64_MIN
)
960 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.fval
;
962 case AST_Expression::EV_double
:
963 if (ev
->u
.dval
> (ACE_CDR::Double
) ACE_INT64_MAX
964 || ev
->u
.dval
< (ACE_CDR::Double
) ACE_INT64_MIN
)
969 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.dval
;
971 case AST_Expression::EV_char
:
972 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.cval
;
974 case AST_Expression::EV_wchar
:
975 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.wcval
;
977 case AST_Expression::EV_octet
:
978 tmp
.llval
= (ACE_CDR::LongLong
) ev
->u
.oval
;
980 case AST_Expression::EV_int8
:
981 tmp
.llval
= static_cast<ACE_CDR::LongLong
> (ev
->u
.int8val
);
983 case AST_Expression::EV_uint8
:
984 tmp
.llval
= static_cast<ACE_CDR::LongLong
> (ev
->u
.int8val
);
991 case AST_Expression::EV_ulonglong
:
994 case AST_Expression::EV_short
:
1000 tmp
.ullval
= ev
->u
.sval
;
1002 case AST_Expression::EV_ushort
:
1003 tmp
.ullval
= ev
->u
.usval
;
1005 case AST_Expression::EV_long
:
1011 tmp
.ullval
= ev
->u
.lval
;
1013 case AST_Expression::EV_ulong
:
1014 tmp
.ullval
= ev
->u
.ulval
;
1016 case AST_Expression::EV_longlong
:
1017 if (ev
->u
.llval
< 0)
1022 tmp
.ullval
= static_cast<ACE_CDR::LongLong
> (ev
->u
.llval
);
1024 case AST_Expression::EV_bool
:
1025 tmp
.ullval
= ev
->u
.bval
;
1027 case AST_Expression::EV_float
:
1028 if (ev
->u
.fval
< 0.0
1029 || ev
->u
.fval
> (ACE_CDR::Float
) ACE_UINT64_MAX
)
1034 tmp
.ullval
= static_cast<ACE_CDR::ULongLong
> (ev
->u
.fval
);
1036 case AST_Expression::EV_double
:
1037 if (ev
->u
.dval
< 0.0
1038 || ev
->u
.dval
> (ACE_CDR::Double
) ACE_UINT64_MAX
)
1043 tmp
.ullval
= static_cast<ACE_CDR::ULongLong
> (ev
->u
.dval
);
1045 case AST_Expression::EV_char
:
1046 if ((signed char) ev
->u
.cval
< 0)
1051 tmp
.ullval
= ev
->u
.cval
;
1053 case AST_Expression::EV_wchar
:
1054 tmp
.ullval
= ev
->u
.wcval
;
1056 case AST_Expression::EV_octet
:
1057 tmp
.ullval
= ev
->u
.oval
;
1059 case AST_Expression::EV_int8
:
1060 if (ev
->u
.int8val
< 0) return 0;
1061 tmp
.ullval
= static_cast<ACE_CDR::ULongLong
> (ev
->u
.int8val
);
1063 case AST_Expression::EV_uint8
:
1064 tmp
.ullval
= static_cast<ACE_CDR::ULongLong
> (ev
->u
.uint8val
);
1071 case AST_Expression::EV_bool
:
1074 case AST_Expression::EV_short
:
1075 tmp
.bval
= (ev
->u
.sval
== 0) ? false : true;
1077 case AST_Expression::EV_ushort
:
1078 tmp
.bval
= (ev
->u
.usval
== 0) ? false : true;
1080 case AST_Expression::EV_long
:
1081 tmp
.bval
= (ev
->u
.lval
== 0) ? false : true;
1083 case AST_Expression::EV_ulong
:
1084 tmp
.bval
= (ev
->u
.ulval
== 0) ? false : true;
1086 case AST_Expression::EV_longlong
:
1087 tmp
.bval
= (ev
->u
.llval
== 0) ? false : true;
1089 case AST_Expression::EV_ulonglong
:
1090 tmp
.bval
= (ev
->u
.ullval
== 0) ? false : true;
1092 case AST_Expression::EV_float
:
1093 tmp
.bval
= ACE::is_equal (ev
->u
.fval
, 0.0f
) ? false : true;
1095 case AST_Expression::EV_double
:
1096 tmp
.bval
= ACE::is_equal (ev
->u
.dval
, 0.0) ? false : true;
1098 case AST_Expression::EV_char
:
1099 tmp
.bval
= (ev
->u
.cval
== 0) ? false : true;
1101 case AST_Expression::EV_wchar
:
1102 tmp
.bval
= (ev
->u
.wcval
== 0) ? false : true;
1104 case AST_Expression::EV_octet
:
1105 tmp
.bval
= (ev
->u
.oval
== 0) ? false : true;
1107 case AST_Expression::EV_int8
:
1108 tmp
.bval
= ev
->u
.int8val
? true : false;
1110 case AST_Expression::EV_uint8
:
1111 tmp
.bval
= ev
->u
.uint8val
? true : false;
1118 case AST_Expression::EV_float
:
1121 case AST_Expression::EV_short
:
1122 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.sval
;
1124 case AST_Expression::EV_ushort
:
1125 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.usval
;
1127 case AST_Expression::EV_long
:
1128 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.lval
;
1130 case AST_Expression::EV_ulong
:
1131 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.ulval
;
1133 case AST_Expression::EV_longlong
:
1134 if (ev
->u
.llval
> ACE_FLT_MAX
1135 || ev
->u
.llval
< ACE_FLT_LOWEST
)
1139 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.llval
;
1141 case AST_Expression::EV_ulonglong
:
1142 tmp
.fval
= (ACE_CDR::Float
) ((ACE_CDR::LongLong
) ev
->u
.ullval
);
1144 case AST_Expression::EV_bool
:
1145 tmp
.fval
= ev
->u
.bval
? 1.0f
: 0.0f
;
1147 case AST_Expression::EV_double
:
1148 if (ev
->u
.dval
> ACE_FLT_MAX
1149 || ev
->u
.dval
< ACE_FLT_LOWEST
)
1154 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.dval
;
1156 case AST_Expression::EV_char
:
1157 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.cval
;
1159 case AST_Expression::EV_wchar
:
1160 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.wcval
;
1162 case AST_Expression::EV_octet
:
1163 tmp
.fval
= (ACE_CDR::Float
) ev
->u
.oval
;
1165 case AST_Expression::EV_int8
:
1166 tmp
.fval
= static_cast<ACE_CDR::Float
> (ev
->u
.int8val
);
1168 case AST_Expression::EV_uint8
:
1169 tmp
.fval
= static_cast<ACE_CDR::Float
> (ev
->u
.uint8val
);
1176 case AST_Expression::EV_double
:
1179 case AST_Expression::EV_short
:
1180 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.sval
;
1182 case AST_Expression::EV_ushort
:
1183 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.usval
;
1185 case AST_Expression::EV_long
:
1186 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.lval
;
1188 case AST_Expression::EV_ulong
:
1189 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.ulval
;
1191 case AST_Expression::EV_longlong
:
1192 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.llval
;
1194 case AST_Expression::EV_ulonglong
:
1195 // Some compilers don't implement unsigned 64-bit to double
1196 // conversions, so we are stuck with the signed 64-bit max value.
1197 if (ev
->u
.ullval
> ACE_INT64_MAX
)
1202 tmp
.dval
= (ACE_CDR::Double
) ((ACE_CDR::LongLong
) ev
->u
.ullval
);
1204 case AST_Expression::EV_bool
:
1205 tmp
.dval
= ev
->u
.bval
? 1.0 : 0.0;
1207 case AST_Expression::EV_float
:
1208 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.fval
;
1210 case AST_Expression::EV_char
:
1211 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.cval
;
1213 case AST_Expression::EV_wchar
:
1214 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.wcval
;
1216 case AST_Expression::EV_octet
:
1217 tmp
.dval
= (ACE_CDR::Double
) ev
->u
.oval
;
1219 case AST_Expression::EV_int8
:
1220 tmp
.dval
= static_cast<ACE_CDR::Double
> (ev
->u
.int8val
);
1222 case AST_Expression::EV_uint8
:
1223 tmp
.dval
= static_cast<ACE_CDR::Double
> (ev
->u
.uint8val
);
1230 case AST_Expression::EV_int8
:
1231 case AST_Expression::EV_char
:
1234 case AST_Expression::EV_short
:
1235 if (ev
->u
.sval
> (ACE_CDR::Short
) ACE_CHAR_MAX
1236 || ev
->u
.sval
< (ACE_CDR::Short
) ACE_CHAR_MIN
)
1241 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.sval
;
1243 case AST_Expression::EV_ushort
:
1244 if (ev
->u
.usval
> (ACE_CDR::UShort
) ACE_CHAR_MAX
)
1249 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.usval
;
1251 case AST_Expression::EV_long
:
1252 if (ev
->u
.lval
> (ACE_CDR::Long
) ACE_CHAR_MAX
1253 || ev
->u
.lval
< (ACE_CDR::Long
) ACE_CHAR_MIN
)
1258 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.lval
;
1260 case AST_Expression::EV_ulong
:
1261 if (ev
->u
.ulval
> (ACE_CDR::ULong
) ACE_CHAR_MAX
)
1266 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.ulval
;
1268 case AST_Expression::EV_longlong
:
1269 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_CHAR_MAX
1270 || ev
->u
.llval
< (ACE_CDR::LongLong
) ACE_CHAR_MIN
)
1275 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.llval
;
1277 case AST_Expression::EV_ulonglong
:
1278 if ((ev
->u
.ullval
& ACE_CHAR_MAX
) != ev
->u
.ullval
)
1283 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.ullval
;
1285 case AST_Expression::EV_bool
:
1286 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.bval
;
1288 case AST_Expression::EV_float
:
1289 if (ev
->u
.fval
> (ACE_CDR::Float
) ACE_CHAR_MAX
1290 || ev
->u
.fval
< (ACE_CDR::Float
) ACE_CHAR_MIN
)
1295 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.fval
;
1297 case AST_Expression::EV_double
:
1298 if (ev
->u
.dval
> (ACE_CDR::Double
) ACE_CHAR_MAX
1299 || ev
->u
.dval
< (ACE_CDR::Double
) ACE_CHAR_MIN
)
1304 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.dval
;
1306 case AST_Expression::EV_wchar
:
1307 if (ev
->u
.wcval
> (ACE_CDR::WChar
) ACE_CHAR_MAX
)
1312 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.wcval
;
1314 case AST_Expression::EV_uint8
:
1315 case AST_Expression::EV_octet
:
1316 if (ev
->u
.oval
> (unsigned char) ACE_CHAR_MAX
)
1321 tmp
.cval
= (ACE_CDR::Char
) ev
->u
.oval
;
1323 case AST_Expression::EV_int8
:
1324 case AST_Expression::EV_char
:
1332 case AST_Expression::EV_wchar
:
1335 case AST_Expression::EV_short
:
1341 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.sval
;
1343 case AST_Expression::EV_ushort
:
1344 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.usval
;
1346 case AST_Expression::EV_long
:
1348 || ev
->u
.lval
> ACE_WCHAR_MAX
)
1353 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.lval
;
1355 case AST_Expression::EV_ulong
:
1356 if (ev
->u
.ulval
> ACE_WCHAR_MAX
)
1361 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.ulval
;
1363 case AST_Expression::EV_longlong
:
1364 if (ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_WCHAR_MAX
1370 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.llval
;
1372 case AST_Expression::EV_ulonglong
:
1373 if ((ev
->u
.ullval
& ACE_WCHAR_MAX
) != ev
->u
.ullval
)
1378 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.ullval
;
1380 case AST_Expression::EV_bool
:
1381 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.bval
;
1383 case AST_Expression::EV_float
:
1384 if (ev
->u
.fval
> (ACE_CDR::Float
) ACE_WCHAR_MAX
1390 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.fval
;
1392 case AST_Expression::EV_double
:
1393 if (ev
->u
.dval
> (ACE_CDR::Double
) ACE_WCHAR_MAX
1399 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.dval
;
1401 case AST_Expression::EV_char
:
1402 case AST_Expression::EV_int8
:
1403 if ((signed char) ev
->u
.cval
< 0)
1408 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.cval
;
1410 case AST_Expression::EV_octet
:
1411 tmp
.wcval
= (ACE_CDR::WChar
) ev
->u
.oval
;
1413 case AST_Expression::EV_uint8
:
1414 tmp
.wcval
= static_cast<ACE_CDR::WChar
> (ev
->u
.uint8val
);
1421 case AST_Expression::EV_uint8
:
1422 case AST_Expression::EV_octet
:
1425 case AST_Expression::EV_short
:
1427 || ev
->u
.sval
> (ACE_CDR::Short
) ACE_OCTET_MAX
)
1432 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.sval
;
1434 case AST_Expression::EV_ushort
:
1435 if (ev
->u
.usval
> (ACE_CDR::UShort
) ACE_OCTET_MAX
)
1440 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.usval
;
1442 case AST_Expression::EV_long
:
1444 || ev
->u
.lval
> (ACE_CDR::Long
) ACE_OCTET_MAX
)
1449 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.lval
;
1451 case AST_Expression::EV_ulong
:
1452 if (ev
->u
.ulval
> (ACE_CDR::ULong
) ACE_OCTET_MAX
)
1457 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.ulval
;
1459 case AST_Expression::EV_longlong
:
1461 || ev
->u
.llval
> (ACE_CDR::LongLong
) ACE_OCTET_MAX
)
1466 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.llval
;
1468 case AST_Expression::EV_ulonglong
:
1469 if ((ev
->u
.ullval
& ACE_OCTET_MAX
) != ev
->u
.ullval
)
1474 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.ullval
;
1476 case AST_Expression::EV_bool
:
1477 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.bval
? 1 : 0;
1479 case AST_Expression::EV_float
:
1480 if (ev
->u
.fval
< 0.0
1481 || ev
->u
.fval
> (ACE_CDR::Float
) ACE_OCTET_MAX
)
1486 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.fval
;
1488 case AST_Expression::EV_double
:
1489 if (ev
->u
.dval
< 0.0
1490 || ev
->u
.dval
> (ACE_CDR::Double
) ACE_OCTET_MAX
)
1495 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.dval
;
1497 case AST_Expression::EV_int8
:
1498 case AST_Expression::EV_char
:
1499 if ((signed char) ev
->u
.cval
< 0)
1504 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.cval
;
1506 case AST_Expression::EV_wchar
:
1507 if (ev
->u
.wcval
> (ACE_CDR::WChar
) ACE_OCTET_MAX
)
1512 tmp
.oval
= (ACE_CDR::Octet
) ev
->u
.wcval
;
1514 case AST_Expression::EV_uint8
:
1515 case AST_Expression::EV_octet
:
1523 case AST_Expression::EV_enum
:
1526 case AST_Expression::EV_ulong
:
1540 // Integer literals may not be assigned to floating point constants,
1543 incompatible_types (AST_Expression::ExprType t1
,
1544 AST_Expression::ExprType t2
)
1548 case AST_Expression::EV_short
:
1549 case AST_Expression::EV_ushort
:
1550 case AST_Expression::EV_long
:
1551 case AST_Expression::EV_ulong
:
1552 case AST_Expression::EV_longlong
:
1553 case AST_Expression::EV_ulonglong
:
1554 case AST_Expression::EV_octet
:
1555 case AST_Expression::EV_bool
:
1556 case AST_Expression::EV_int8
:
1557 case AST_Expression::EV_uint8
:
1560 case AST_Expression::EV_short
:
1561 case AST_Expression::EV_ushort
:
1562 case AST_Expression::EV_long
:
1563 case AST_Expression::EV_ulong
:
1564 case AST_Expression::EV_longlong
:
1565 case AST_Expression::EV_ulonglong
:
1566 case AST_Expression::EV_octet
:
1567 case AST_Expression::EV_bool
:
1568 case AST_Expression::EV_int8
:
1569 case AST_Expression::EV_uint8
:
1574 case AST_Expression::EV_float
:
1575 case AST_Expression::EV_double
:
1576 case AST_Expression::EV_longdouble
:
1579 case AST_Expression::EV_float
:
1580 case AST_Expression::EV_double
:
1581 case AST_Expression::EV_longdouble
:
1586 case AST_Expression::EV_fixed
:
1587 return t2
!= AST_Expression::EV_fixed
;
1593 // Evaluate the expression wrt the evaluation kind requested. Supported
1594 // evaluation kinds are
1595 // - EK_const: The expression must evaluate to a constant
1596 // - EK_positive_int: The expression must further evaluate to a
1599 // @@(JP) This just maps one enum to another. It's a temporary fix,
1600 // but AST_Expression::EvalKind should go eventually.
1601 static AST_Expression::AST_ExprValue
*
1602 eval_kind (AST_Expression::AST_ExprValue
*ev
, AST_Expression::EvalKind ek
)
1604 // Make a copy to simplify the memory management logic.
1605 AST_Expression::AST_ExprValue
*newval
= 0;
1606 ACE_NEW_RETURN (newval
,
1607 AST_Expression::AST_ExprValue
,
1615 AST_Expression::AST_ExprValue
*retval
= 0;
1619 case AST_Expression::EK_const
:
1622 case AST_Expression::EK_positive_int
:
1623 retval
= coerce_value (newval
, AST_Expression::EV_ulong
);
1625 case AST_Expression::EK_short
:
1626 retval
= coerce_value (newval
, AST_Expression::EV_short
);
1628 case AST_Expression::EK_ushort
:
1629 retval
= coerce_value (newval
, AST_Expression::EV_ushort
);
1631 case AST_Expression::EK_long
:
1632 retval
= coerce_value (newval
, AST_Expression::EV_long
);
1634 case AST_Expression::EK_ulong
:
1635 retval
= coerce_value (newval
, AST_Expression::EV_ulong
);
1637 case AST_Expression::EK_longlong
:
1638 retval
= coerce_value (newval
, AST_Expression::EV_longlong
);
1640 case AST_Expression::EK_ulonglong
:
1641 retval
= coerce_value (newval
, AST_Expression::EV_ulonglong
);
1643 case AST_Expression::EK_octet
:
1644 retval
= coerce_value (newval
, AST_Expression::EV_octet
);
1646 case AST_Expression::EK_bool
:
1647 retval
= coerce_value (newval
, AST_Expression::EV_bool
);
1649 case AST_Expression::EK_fixed_point
:
1650 retval
= coerce_value (newval
, AST_Expression::EV_fixed
);
1652 case AST_Expression::EK_int8
:
1653 retval
= coerce_value (newval
, AST_Expression::EV_int8
);
1655 case AST_Expression::EK_uint8
:
1656 retval
= coerce_value (newval
, AST_Expression::EV_uint8
);
1658 case AST_Expression::EK_floating_point
:
1659 retval
= coerce_value (newval
, AST_Expression::EV_double
);
1663 // Sometimes the call above to coerce_value() will return an
1664 // evaluated newval, other times 0. But a heap-allocated
1665 // ExprValue is not always passed to coerce_value(), so we
1666 // have to manage it here, where we know it is always a 'new'.
1667 if (retval
!= newval
)
1676 // Private operations.
1678 // @@@ (JP) CORBA 2.6 and earlier say that in a constant expression,
1679 // each subexpression must fall within the range of the assigned type.
1680 // However, this may be hard for the compiler in some cases (must
1681 // evaluate all grouping possibilities). So there is an outstanding
1682 // issue, #1139, and the best guess is that it will ultimately be
1683 // decided that only the final value must fall within the range of
1684 // the assigned type. So there are no checks here, only in coerce().
1686 // Apply binary operators to an AST_Expression after evaluating
1687 // its sub-expressions.
1688 // Operations supported: '+', '-', '*', '/'
1689 template <typename Type
>
1691 do_eval_bin_op (AST_Expression::ExprComb op
, Type a
, Type b
, Type
&result
)
1695 case AST_Expression::EC_add
:
1698 case AST_Expression::EC_minus
:
1701 case AST_Expression::EC_mul
:
1704 case AST_Expression::EC_div
:
1705 if (!b
) return false;
1715 template <typename Type
>
1717 do_eval_bin_op_float (AST_Expression::ExprComb op
, Type a
, Type b
, Type
&result
)
1719 if (op
== AST_Expression::EC_div
)
1724 return do_eval_bin_op (op
, a
, b
, result
);
1727 AST_Expression::AST_ExprValue
*
1728 AST_Expression::eval_bin_op (AST_Expression::EvalKind ek
)
1730 AST_ExprValue
*retval
= 0;
1732 if (this->pd_v1
== 0 || this->pd_v2
== 0)
1737 this->pd_v1
->set_ev (this->pd_v1
->eval_internal (ek
));
1738 this->pd_v2
->set_ev (this->pd_v2
->eval_internal (ek
));
1740 if (this->pd_v1
->ev () == 0 || this->pd_v2
->ev () == 0)
1745 ExprType
const expr_type
= ek
== EK_const
?
1746 pd_v1
->ev ()->et
: eval_kind_to_expr_type (ek
);
1747 if (expr_type
== EV_none
) return 0;
1749 ACE_NEW_RETURN (retval
,
1753 pd_v1
->set_ev (pd_v1
->coerce (expr_type
));
1754 pd_v2
->set_ev (pd_v2
->coerce (expr_type
));
1755 retval
->et
= expr_type
;
1757 bool success
= false;
1761 success
= do_eval_bin_op
<ACE_CDR::Int8
> (pd_ec
,
1762 pd_v1
->ev ()->u
.int8val
, pd_v2
->ev ()->u
.int8val
, retval
->u
.int8val
);
1766 success
= do_eval_bin_op
<ACE_CDR::UInt8
> (pd_ec
,
1767 pd_v1
->ev ()->u
.uint8val
, pd_v2
->ev ()->u
.uint8val
, retval
->u
.uint8val
);
1771 success
= do_eval_bin_op
<ACE_CDR::Short
> (pd_ec
,
1772 pd_v1
->ev ()->u
.sval
, pd_v2
->ev ()->u
.sval
, retval
->u
.sval
);
1776 success
= do_eval_bin_op
<ACE_CDR::UShort
> (pd_ec
,
1777 pd_v1
->ev ()->u
.usval
, pd_v2
->ev ()->u
.usval
, retval
->u
.usval
);
1781 success
= do_eval_bin_op
<ACE_CDR::Long
> (pd_ec
,
1782 pd_v1
->ev ()->u
.lval
, pd_v2
->ev ()->u
.lval
, retval
->u
.lval
);
1786 success
= do_eval_bin_op
<ACE_CDR::ULong
> (pd_ec
,
1787 pd_v1
->ev ()->u
.ulval
, pd_v2
->ev ()->u
.ulval
, retval
->u
.ulval
);
1791 success
= do_eval_bin_op
<ACE_CDR::LongLong
> (pd_ec
,
1792 pd_v1
->ev ()->u
.llval
, pd_v2
->ev ()->u
.llval
, retval
->u
.llval
);
1796 success
= do_eval_bin_op
<ACE_CDR::ULongLong
> (pd_ec
,
1797 pd_v1
->ev ()->u
.ullval
, pd_v2
->ev ()->u
.ullval
, retval
->u
.ullval
);
1801 success
= do_eval_bin_op
<ACE_CDR::Octet
> (pd_ec
,
1802 pd_v1
->ev ()->u
.oval
, pd_v2
->ev ()->u
.oval
, retval
->u
.oval
);
1806 success
= do_eval_bin_op_float
<ACE_CDR::Double
> (pd_ec
,
1807 pd_v1
->ev ()->u
.dval
, pd_v2
->ev ()->u
.dval
, retval
->u
.dval
);
1811 success
= do_eval_bin_op
<ACE_CDR::Fixed
> (pd_ec
,
1812 pd_v1
->ev ()->u
.fixedval
, pd_v2
->ev ()->u
.fixedval
, retval
->u
.fixedval
);
1828 template <typename Type
>
1830 do_eval_mod_op (Type a
, Type b
, Type
&result
)
1839 // Apply binary operators to an AST_Expression after evaluating
1840 // its sub-expressions.
1841 // Operations supported: '%'
1842 AST_Expression::AST_ExprValue
*
1843 AST_Expression::eval_mod_op (AST_Expression::EvalKind ek
)
1845 AST_ExprValue
*retval
= 0;
1847 if (this->pd_v1
== 0 || this->pd_v2
== 0)
1852 this->pd_v1
->set_ev (this->pd_v1
->eval_internal (ek
));
1853 this->pd_v2
->set_ev (this->pd_v2
->eval_internal (ek
));
1855 if (this->pd_v1
->ev () == 0 || this->pd_v2
->ev () == 0)
1860 ExprType
const expr_type
= ek
== EK_const
?
1861 pd_v1
->ev ()->et
: eval_kind_to_expr_type (ek
);
1862 if (expr_type
== EV_none
) return 0;
1864 ACE_NEW_RETURN (retval
,
1868 pd_v1
->set_ev (pd_v1
->coerce (expr_type
));
1869 pd_v2
->set_ev (pd_v2
->coerce (expr_type
));
1870 retval
->et
= expr_type
;
1872 bool success
= false;
1876 success
= do_eval_mod_op
<ACE_CDR::Int8
> (
1877 pd_v1
->ev ()->u
.int8val
, pd_v2
->ev ()->u
.int8val
, retval
->u
.int8val
);
1881 success
= do_eval_mod_op
<ACE_CDR::UInt8
> (
1882 pd_v1
->ev ()->u
.uint8val
, pd_v2
->ev ()->u
.uint8val
, retval
->u
.uint8val
);
1886 success
= do_eval_mod_op
<ACE_CDR::Short
> (
1887 pd_v1
->ev ()->u
.sval
, pd_v2
->ev ()->u
.sval
, retval
->u
.sval
);
1891 success
= do_eval_mod_op
<ACE_CDR::UShort
> (
1892 pd_v1
->ev ()->u
.usval
, pd_v2
->ev ()->u
.usval
, retval
->u
.usval
);
1896 success
= do_eval_mod_op
<ACE_CDR::Long
> (
1897 pd_v1
->ev ()->u
.lval
, pd_v2
->ev ()->u
.lval
, retval
->u
.lval
);
1901 success
= do_eval_mod_op
<ACE_CDR::ULong
> (
1902 pd_v1
->ev ()->u
.ulval
, pd_v2
->ev ()->u
.ulval
, retval
->u
.ulval
);
1906 success
= do_eval_mod_op
<ACE_CDR::LongLong
> (
1907 pd_v1
->ev ()->u
.llval
, pd_v2
->ev ()->u
.llval
, retval
->u
.llval
);
1911 success
= do_eval_mod_op
<ACE_CDR::ULongLong
> (
1912 pd_v1
->ev ()->u
.ullval
, pd_v2
->ev ()->u
.ullval
, retval
->u
.ullval
);
1916 success
= do_eval_mod_op
<ACE_CDR::Octet
> (
1917 pd_v1
->ev ()->u
.oval
, pd_v2
->ev ()->u
.oval
, retval
->u
.oval
);
1933 // Apply bitwise operations to an AST_Expression after evaluating
1934 // its sub-expressions.
1935 // Operations supported: '%', '|', '&', '^', '<<', '>>'
1937 template <typename Type
>
1939 do_eval_bit_op_no_shift (AST_Expression::ExprComb op
, Type a
, Type b
, Type
&result
)
1943 case AST_Expression::EC_or
:
1946 case AST_Expression::EC_xor
:
1949 case AST_Expression::EC_and
:
1959 template <typename Type
>
1961 do_eval_bit_op (AST_Expression::ExprComb op
, Type a
, Type b
, Type
&result
)
1965 case AST_Expression::EC_left
:
1968 case AST_Expression::EC_right
:
1972 return do_eval_bit_op_no_shift (op
, a
, b
, result
);
1978 AST_Expression::AST_ExprValue
*
1979 AST_Expression::eval_bit_op (AST_Expression::EvalKind ek
)
1981 AST_Expression::AST_ExprValue
*retval
= 0;
1983 if (this->pd_v1
== 0 || this->pd_v2
== 0)
1988 this->pd_v1
->set_ev (this->pd_v1
->eval_internal (ek
));
1989 this->pd_v2
->set_ev (this->pd_v2
->eval_internal (ek
));
1991 if (this->pd_v1
->ev () == 0 || this->pd_v2
->ev () == 0)
1996 ExprType
const expr_type
= eval_kind_to_expr_type (ek
);
1997 if (expr_type
== EV_none
) return 0;
1999 ACE_NEW_RETURN (retval
,
2003 pd_v1
->set_ev (pd_v1
->coerce (expr_type
));
2004 pd_v2
->set_ev (pd_v2
->coerce (expr_type
));
2005 retval
->et
= expr_type
;
2007 bool success
= false;
2011 success
= do_eval_bit_op
<ACE_CDR::Int8
> (pd_ec
,
2012 pd_v1
->ev ()->u
.int8val
, pd_v2
->ev ()->u
.int8val
, retval
->u
.int8val
);
2016 success
= do_eval_bit_op
<ACE_CDR::UInt8
> (pd_ec
,
2017 pd_v1
->ev ()->u
.uint8val
, pd_v2
->ev ()->u
.uint8val
, retval
->u
.uint8val
);
2021 success
= do_eval_bit_op
<ACE_CDR::Short
> (pd_ec
,
2022 pd_v1
->ev ()->u
.sval
, pd_v2
->ev ()->u
.sval
, retval
->u
.sval
);
2026 success
= do_eval_bit_op
<ACE_CDR::UShort
> (pd_ec
,
2027 pd_v1
->ev ()->u
.usval
, pd_v2
->ev ()->u
.usval
, retval
->u
.usval
);
2031 success
= do_eval_bit_op
<ACE_CDR::Long
> (pd_ec
,
2032 pd_v1
->ev ()->u
.lval
, pd_v2
->ev ()->u
.lval
, retval
->u
.lval
);
2036 success
= do_eval_bit_op
<ACE_CDR::ULong
> (pd_ec
,
2037 pd_v1
->ev ()->u
.ulval
, pd_v2
->ev ()->u
.ulval
, retval
->u
.ulval
);
2041 success
= do_eval_bit_op
<ACE_CDR::LongLong
> (pd_ec
,
2042 pd_v1
->ev ()->u
.llval
, pd_v2
->ev ()->u
.llval
, retval
->u
.llval
);
2046 success
= do_eval_bit_op
<ACE_CDR::ULongLong
> (pd_ec
,
2047 pd_v1
->ev ()->u
.ullval
, pd_v2
->ev ()->u
.ullval
, retval
->u
.ullval
);
2051 success
= do_eval_bit_op
<ACE_CDR::Octet
> (pd_ec
,
2052 pd_v1
->ev ()->u
.oval
, pd_v2
->ev ()->u
.oval
, retval
->u
.oval
);
2056 success
= do_eval_bit_op_no_shift
<ACE_CDR::Boolean
> (pd_ec
,
2057 pd_v1
->ev ()->u
.bval
, pd_v2
->ev ()->u
.bval
, retval
->u
.bval
);
2073 // Apply unary operators to an AST_Expression after evaluating its
2075 // Operations supported: '-', '+', '~'
2076 AST_Expression::AST_ExprValue
*
2077 AST_Expression::eval_un_op (AST_Expression::EvalKind ek
)
2079 AST_ExprValue
*retval
= 0;
2081 if (this->pd_ev
!= 0)
2086 if (this->pd_v1
== 0)
2091 this->pd_v1
->set_ev (this->pd_v1
->eval_internal (ek
));
2093 if (this->pd_v1
->ev () == 0)
2098 ACE_NEW_RETURN (retval
,
2102 if (this->pd_v1
->ev ()->et
== EV_fixed
)
2104 retval
->et
= EV_fixed
;
2105 switch (this->pd_ec
)
2108 retval
->u
.fixedval
= this->pd_v1
->ev ()->u
.fixedval
;
2111 retval
->u
.fixedval
= -this->pd_v1
->ev ()->u
.fixedval
;
2120 retval
->et
= EV_double
;
2122 switch (this->pd_ec
)
2125 this->pd_v1
->set_ev (this->pd_v1
->coerce (EV_double
));
2127 if (this->pd_v1
->ev () == 0)
2134 retval
->u
.dval
= this->pd_v1
->ev ()->u
.dval
;
2137 this->pd_v1
->set_ev (this->pd_v1
->coerce (EV_double
));
2139 if (this->pd_v1
->ev () == 0)
2146 retval
->u
.dval
= -(this->pd_v1
->ev ()->u
.dval
);
2149 if (this->pd_v1
->ev () == 0)
2156 switch (this->pd_v1
->ev ()->et
)
2159 retval
->u
.sval
= ~this->pd_v1
->ev ()->u
.sval
;
2162 retval
->u
.usval
= ~this->pd_v1
->ev ()->u
.usval
;
2165 retval
->u
.lval
= ~this->pd_v1
->ev ()->u
.lval
;
2168 retval
->u
.ulval
= ~this->pd_v1
->ev ()->u
.ulval
;
2171 retval
->u
.llval
= ~this->pd_v1
->ev ()->u
.llval
;
2174 retval
->u
.ullval
= ~this->pd_v1
->ev ()->u
.ullval
;
2177 retval
->u
.oval
= ~this->pd_v1
->ev ()->u
.oval
;
2180 retval
->u
.int8val
= ~pd_v1
->ev ()->u
.int8val
;
2183 retval
->u
.uint8val
= ~pd_v1
->ev ()->u
.uint8val
;
2190 retval
->et
= pd_v1
->ev ()->et
;
2202 // Evaluate a symbolic AST_Expression by looking up the named
2204 AST_Expression::AST_ExprValue
*
2205 AST_Expression::eval_symbol (AST_Expression::EvalKind ek
)
2209 AST_Constant
*c
= 0;
2211 // Is there a symbol stored?
2212 if (this->pd_n
== 0)
2214 idl_global
->err ()->eval_error (this);
2218 // Get current scope for lookup.
2219 if (idl_global
->scopes ().depth () > 0)
2221 s
= idl_global
->scopes ().top_non_null ();
2226 idl_global
->err ()->lookup_error (this->pd_n
);
2230 // If we are a template parameter placeholder, just skip the
2231 // rest - nothing needs to be evaluated until instantiation
2233 if (this->param_holder_
!= 0)
2239 d
= s
->lookup_by_name (this->pd_n
,
2244 idl_global
->err ()->lookup_error (this->pd_n
);
2248 // Is it a constant?
2249 if (d
->node_type () != AST_Decl::NT_const
2250 && d
->node_type () != AST_Decl::NT_enum_val
)
2252 idl_global
->err ()->constant_expected (this->pd_n
,
2257 if (d
->node_type () == AST_Decl::NT_enum_val
)
2259 AST_EnumVal
*enumval
= dynamic_cast<AST_EnumVal
*> (d
);
2260 enum_parent (enumval
->enum_parent ());
2263 // OK, now evaluate the constant we just got, to produce its value.
2264 c
= dynamic_cast<AST_Constant
*> (d
);
2271 return c
->constant_value ()->eval_internal (ek
);
2275 AST_Expression::type_mismatch (AST_Expression::ExprType t
)
2277 if (this->pd_ev
!= 0)
2279 return incompatible_types (this->pd_ev
->et
, t
);
2282 bool v1_mismatch
= 0;
2283 bool v2_mismatch
= 0;
2285 if (this->pd_v1
!= 0)
2287 v1_mismatch
= this->pd_v1
->type_mismatch (t
);
2290 if (this->pd_v2
!= 0)
2292 v2_mismatch
= this->pd_v2
->type_mismatch (t
);
2295 return v1_mismatch
| v2_mismatch
;
2298 // Coerce "this" to the ExprType required. Returns a copy of the
2299 // original ExprValue with the coercion applied, if successful, or
2301 AST_Expression::AST_ExprValue
*
2302 AST_Expression::check_and_coerce (AST_Expression::ExprType t
,
2307 AST_Decl
*enum_val
=
2308 idl_global
->scopes ().top_non_null ()->lookup_by_name (this->pd_n
,
2313 AST_Decl
*enum_decl
= ScopeAsDecl (enum_val
->defined_in ());
2315 if (d
->node_type () == AST_Decl::NT_typedef
)
2317 AST_Typedef
*td
= dynamic_cast<AST_Typedef
*> (d
);
2318 d
= td
->primitive_base_type ();
2323 idl_global
->err ()->incompatible_type_error (this);
2329 if (this->type_mismatch (t
))
2331 idl_global
->err ()->incompatible_type_error (this);
2335 if (d
!= 0 && d
->node_type () == AST_Decl::NT_typedef
)
2340 return this->coerce (t
);
2343 // Coerce "this" to the ExprType required. Returns a copy of the
2344 // original ExprValue with the coercion applied, if successful, or
2346 AST_Expression::AST_ExprValue
*
2347 AST_Expression::coerce (AST_Expression::ExprType t
)
2349 AST_ExprValue
*tmp
= 0;
2351 // First, evaluate it, then try to coerce result type.
2352 // If already evaluated, return the result.
2356 tmp
= this->eval_internal (EK_int8
);
2359 tmp
= this->eval_internal (EK_uint8
);
2362 tmp
= this->eval_internal (EK_short
);
2365 tmp
= this->eval_internal (EK_ushort
);
2368 tmp
= this->eval_internal (EK_long
);
2371 tmp
= this->eval_internal (EK_ulong
);
2374 tmp
= this->eval_internal (EK_longlong
);
2377 tmp
= this->eval_internal (EK_ulonglong
);
2380 tmp
= this->eval_internal (EK_octet
);
2383 tmp
= this->eval_internal (EK_bool
);
2386 tmp
= this->eval_internal (EK_fixed_point
);
2391 tmp
= eval_internal (EK_floating_point
);
2401 tmp
= eval_internal (EK_const
);
2416 // Create a copy to contain coercion result.
2417 AST_ExprValue
*copy
= 0;
2418 ACE_NEW_RETURN (copy
,
2422 copy
->et
= this->pd_ev
->et
;
2424 switch (this->pd_ev
->et
)
2433 copy
->u
.ulval
= this->pd_ev
->u
.ulval
;
2436 copy
->u
.sval
= this->pd_ev
->u
.sval
;
2439 copy
->u
.usval
= this->pd_ev
->u
.usval
;
2442 copy
->u
.lval
= this->pd_ev
->u
.lval
;
2445 copy
->u
.ulval
= this->pd_ev
->u
.ulval
;
2448 copy
->u
.llval
= this->pd_ev
->u
.llval
;
2451 copy
->u
.ullval
= this->pd_ev
->u
.ullval
;
2454 copy
->u
.bval
= this->pd_ev
->u
.bval
;
2457 copy
->u
.fval
= this->pd_ev
->u
.fval
;
2460 copy
->u
.dval
= this->pd_ev
->u
.dval
;
2463 copy
->u
.cval
= this->pd_ev
->u
.cval
;
2466 copy
->u
.wcval
= this->pd_ev
->u
.wcval
;
2469 copy
->u
.oval
= this->pd_ev
->u
.oval
;
2472 copy
->u
.strval
= this->pd_ev
->u
.strval
;
2475 copy
->u
.wstrval
= this->pd_ev
->u
.wstrval
;
2478 copy
->u
.fixedval
= this->pd_ev
->u
.fixedval
;
2481 copy
->u
.int8val
= this->pd_ev
->u
.int8val
;
2484 copy
->u
.uint8val
= this->pd_ev
->u
.uint8val
;
2491 if (this->pd_ev
->et
== t
)
2497 AST_ExprValue
*ev
= coerce_value (copy
, t
);
2501 // coerce_value() will either return 'copy' or
2502 // return 0 without freeing 'copy'. It's
2503 // deleted here instead of putting a zillion
2504 // delete statments inside coerce_value().
2513 // Eval used internally.
2514 AST_Expression::AST_ExprValue
*
2515 AST_Expression::eval_internal (AST_Expression::EvalKind ek
)
2517 // Already evaluated?
2518 if (this->pd_ev
!= 0)
2520 return eval_kind (this->pd_ev
,
2524 // OK, must evaluate operator.
2525 switch (this->pd_ec
)
2531 this->pd_ev
= this->eval_bin_op (ek
);
2532 return eval_kind (this->pd_ev
,
2535 this->pd_ev
= this->eval_mod_op (ek
);
2536 return eval_kind (this->pd_ev
,
2543 this->pd_ev
= this->eval_bit_op (ek
);
2544 return eval_kind (this->pd_ev
,
2549 this->pd_ev
= this->eval_un_op (ek
);
2550 return eval_kind (this->pd_ev
,
2553 this->pd_ev
= this->eval_symbol (ek
);
2554 return eval_kind (this->pd_ev
,
2563 // Public operations.
2565 // Evaluate "this", assigning the value to the pd_ev field.
2567 AST_Expression::evaluate (EvalKind ek
)
2569 AST_ExprValue
*tmp
= eval_kind (this->pd_ev
, ek
);
2573 // Artifact of expressions doing double duty for all template
2574 // args. At this point, we have knowledge that we must be an
2575 // enum constant, so we set the expression type here, rather
2576 // than at the point of creation.
2577 if (ek
== AST_Expression::EK_const
&& this->pd_n
!= 0)
2579 this->pd_ev
->et
= AST_Expression::EV_enum
;
2583 // Expression equality comparison operator.
2585 AST_Expression::operator== (AST_Expression
*vc
)
2587 return compare (vc
);
2591 AST_Expression::compare (AST_Expression
*vc
)
2593 if (this->pd_ec
!= vc
->ec ())
2598 this->evaluate (EK_const
);
2599 vc
->evaluate (EK_const
);
2601 if (pd_ev
== 0 || vc
->ev () == 0)
2606 if (this->pd_ev
->et
!= vc
->ev ()->et
)
2614 return this->pd_ev
->u
.sval
== vc
->ev ()->u
.sval
;
2616 return this->pd_ev
->u
.usval
== vc
->ev ()->u
.usval
;
2618 return this->pd_ev
->u
.lval
== vc
->ev ()->u
.lval
;
2620 return this->pd_ev
->u
.ulval
== vc
->ev ()->u
.ulval
;
2622 return ACE::is_equal (this->pd_ev
->u
.fval
, vc
->ev ()->u
.fval
);
2624 return ACE::is_equal (this->pd_ev
->u
.dval
, vc
->ev ()->u
.dval
);
2626 return this->pd_ev
->u
.cval
== vc
->ev ()->u
.cval
;
2628 return this->pd_ev
->u
.wcval
== vc
->ev ()->u
.wcval
;
2630 return this->pd_ev
->u
.oval
== vc
->ev ()->u
.oval
;
2632 return this->pd_ev
->u
.lval
== vc
->ev ()->u
.lval
;
2634 return !ACE_OS::strcmp (pd_ev
->u
.strval
->get_string (),
2635 vc
->ev ()->u
.strval
->get_string ());
2637 return !ACE_OS::strcmp (pd_ev
->u
.wstrval
, vc
->ev ()->u
.wstrval
);
2639 return pd_ev
->u
.llval
== vc
->ev ()->u
.llval
;
2641 return pd_ev
->u
.ullval
== vc
->ev ()->u
.ullval
;
2643 return pd_ev
->u
.fixedval
== vc
->ev ()->u
.fixedval
;
2645 return pd_ev
->u
.eval
== vc
->ev ()->u
.eval
;
2647 return pd_ev
->u
.int8val
== vc
->ev ()->u
.int8val
;
2649 return pd_ev
->u
.uint8val
== vc
->ev ()->u
.uint8val
;
2656 AST_Expression::get_tdef (void) const
2662 AST_Expression::param_holder (void) const
2664 return this->param_holder_
;
2667 // Helper functions for expression dumpers.
2669 // Dump this binary AST_Expression node to the ostream o.
2671 dump_binary_expr (ACE_OSTREAM_TYPE
&o
,
2681 o
<< " " << s
<< " ";
2689 // Dump this unary AST_Expression node to the ostream o.
2691 dump_unary_expr (ACE_OSTREAM_TYPE
&o
,
2699 // Dump the supplied AST_ExprValue to the ostream o.
2701 dump_expr_val (ACE_OSTREAM_TYPE
&o
, AST_Expression::AST_ExprValue
*ev
)
2705 case AST_Expression::EV_short
:
2708 case AST_Expression::EV_ushort
:
2711 case AST_Expression::EV_long
:
2714 case AST_Expression::EV_ulong
:
2715 case AST_Expression::EV_enum
:
2718 case AST_Expression::EV_float
:
2721 case AST_Expression::EV_double
:
2724 case AST_Expression::EV_char
:
2727 case AST_Expression::EV_wchar
:
2728 #ifdef ACE_HAS_CPP20
2734 case AST_Expression::EV_octet
:
2738 o
<< "0x" << std::hex
<< std::setw (2) << std::setfill ('0') << unsigned (ev
->u
.oval
);
2742 case AST_Expression::EV_bool
:
2743 o
<< (ev
->u
.bval
== true ? "TRUE" : "FALSE");
2745 case AST_Expression::EV_string
:
2746 if (ev
->u
.strval
!= 0)
2748 ev
->u
.strval
->dump (o
);
2752 o
<< "(null string)";
2755 case AST_Expression::EV_longlong
:
2758 case AST_Expression::EV_ulonglong
:
2761 case AST_Expression::EV_fixed
:
2762 o
<< ev
->u
.fixedval
;
2764 case AST_Expression::EV_int8
:
2765 o
<< static_cast<short> (ev
->u
.int8val
);
2767 case AST_Expression::EV_uint8
:
2768 o
<< static_cast<unsigned short> (ev
->u
.uint8val
);
2770 case AST_Expression::EV_longdouble
:
2771 case AST_Expression::EV_wstring
:
2772 case AST_Expression::EV_any
:
2773 case AST_Expression::EV_object
:
2774 case AST_Expression::EV_void
:
2775 case AST_Expression::EV_none
:
2779 o
<< "(Can not dump type " << AST_Expression::exprtype_to_string (ev
->et
) << ")";
2782 // Dump an AST_Expression node to the ostream o.
2784 AST_Expression::dump (ACE_OSTREAM_TYPE
&o
)
2786 // See if it was a constant or was evaluated already.
2787 if (this->pd_ev
!= 0)
2789 dump_expr_val (o
, this->pd_ev
);
2793 // OK, must print out an expression.
2794 switch (this->pd_ec
)
2796 // Binary expressions:
2798 dump_binary_expr (o
,
2804 dump_binary_expr (o
,
2810 dump_binary_expr (o
,
2816 dump_binary_expr (o
,
2822 dump_binary_expr (o
,
2828 dump_binary_expr (o
,
2834 dump_binary_expr (o
,
2840 dump_binary_expr (o
,
2846 dump_binary_expr (o
,
2852 dump_binary_expr (o
,
2857 // Unary expressions.
2873 // Unevaluated symbol.
2876 this->pd_n
->dump (o
);
2878 o
<< ACE_TEXT ("(nil symbolic name)");
2881 o
<< ACE_TEXT ("(none)");
2884 o
<< ACE_TEXT ("unsupported dump mode for expression with ec == ")
2885 << (int) this->pd_ec
;
2891 AST_Expression::ast_accept (ast_visitor
*visitor
)
2893 return visitor
->visit_expression (this);
2897 AST_Expression::destroy (void)
2899 if (0 != this->pd_ev
)
2901 if (EV_string
== this->pd_ev
->et
)
2903 this->pd_ev
->u
.strval
->destroy ();
2904 delete this->pd_ev
->u
.strval
;
2905 this->pd_ev
->u
.strval
= 0;
2907 else if (EV_wstring
== this->pd_ev
->et
)
2909 ACE::strdelete (this->pd_ev
->u
.wstrval
);
2910 this->pd_ev
->u
.wstrval
= 0;
2916 if (this->pd_v1
!= 0)
2918 this->pd_v1
->destroy ();
2923 if (this->pd_v2
!= 0)
2925 this->pd_v2
->destroy ();
2930 if (this->pd_n
!= 0)
2932 this->pd_n
->destroy ();
2937 if (this->param_holder_
!= 0)
2939 this->param_holder_
->destroy ();
2940 delete this->param_holder_
;
2941 this->param_holder_
= 0;
2948 AST_Expression::defined_in (void)
2950 return this->pd_defined_in
;
2954 AST_Expression::set_defined_in (UTL_Scope
*d
)
2956 this->pd_defined_in
= d
;
2960 AST_Expression::line (void)
2962 return this->pd_line
;
2966 AST_Expression::set_line (long l
)
2972 AST_Expression::file_name (void)
2974 return this->pd_file_name
;
2978 AST_Expression::set_file_name (UTL_String
*f
)
2980 this->pd_file_name
= f
;
2983 AST_Expression::ExprComb
2984 AST_Expression::ec (void)
2989 AST_Expression::AST_ExprValue
*
2990 AST_Expression::ev (void)
2996 AST_Expression::set_ev (AST_Expression::AST_ExprValue
*new_ev
)
2999 this->pd_ev
= new_ev
;
3003 AST_Expression::v1 (void)
3009 AST_Expression::set_v1 (AST_Expression
*e
)
3015 AST_Expression::v2 (void)
3021 AST_Expression::set_v2 (AST_Expression
*e
)
3027 AST_Expression::n (void)
3033 AST_Expression::set_n (UTL_ScopedName
*new_n
)
3039 AST_Expression::exprtype_to_string (ExprType t
)
3042 case AST_Expression::EV_short
:
3044 case AST_Expression::EV_ushort
:
3045 return "unsigned short";
3046 case AST_Expression::EV_long
:
3048 case AST_Expression::EV_ulong
:
3049 return "unsigned long";
3050 case AST_Expression::EV_float
:
3052 case AST_Expression::EV_double
:
3054 case AST_Expression::EV_char
:
3056 case AST_Expression::EV_octet
:
3058 case AST_Expression::EV_bool
:
3060 case AST_Expression::EV_string
:
3062 case AST_Expression::EV_enum
:
3064 case AST_Expression::EV_void
:
3066 case AST_Expression::EV_none
:
3068 case AST_Expression::EV_wchar
:
3070 case AST_Expression::EV_longlong
:
3072 case AST_Expression::EV_ulonglong
:
3074 case AST_Expression::EV_longdouble
:
3075 return "longdouble";
3076 case AST_Expression::EV_wstring
:
3078 case AST_Expression::EV_any
:
3080 case AST_Expression::EV_object
:
3082 case AST_Expression::EV_fixed
:
3084 case AST_Expression::EV_uint8
:
3086 case AST_Expression::EV_int8
:
3090 return "<UNKNOWN TYPE>";
3094 AST_Expression::enum_parent ()
3096 return enum_parent_
;
3100 AST_Expression::enum_parent (AST_Enum
*node
)
3102 enum_parent_
= node
;