summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-11-05 00:14:10 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-11-05 00:14:10 +0000
commit8b87ee4548c4634300afc8a778b658a903640e77 (patch)
tree59c67c4e2072e2184ed0cfdce1cb4242826cf8fb /TAO/TAO_IDL
parent8c21cda3eb73f58d0896ad84dd4b57da7685288e (diff)
downloadATCD-8b87ee4548c4634300afc8a778b658a903640e77.tar.gz
ChangeLogTag: Sat Nov 4 18:04:21 2000 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL')
-rw-r--r--TAO/TAO_IDL/ast/ast_typedef.cpp17
-rw-r--r--TAO/TAO_IDL/ast/ast_union.cpp391
-rw-r--r--TAO/TAO_IDL/be/be_union.cpp380
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp6
-rw-r--r--TAO/TAO_IDL/be_include/be_union.h33
-rw-r--r--TAO/TAO_IDL/include/ast_typedef.h4
-rw-r--r--TAO/TAO_IDL/include/ast_union.h34
7 files changed, 448 insertions, 417 deletions
diff --git a/TAO/TAO_IDL/ast/ast_typedef.cpp b/TAO/TAO_IDL/ast/ast_typedef.cpp
index e215eed427d..29a5406a993 100644
--- a/TAO/TAO_IDL/ast/ast_typedef.cpp
+++ b/TAO/TAO_IDL/ast/ast_typedef.cpp
@@ -99,6 +99,23 @@ AST_Typedef::~AST_Typedef (void)
{
}
+// Given a typedef node, traverse the chain of base types until they are no
+// more typedefs, and return that most primitive base type.
+AST_Type *
+AST_Typedef::primitive_base_type (void)
+{
+ AST_Type *d = this;
+ AST_Typedef *temp = 0;
+
+ while (d && d->node_type () == AST_Decl::NT_typedef)
+ {
+ temp = AST_Typedef::narrow_from_decl (d);
+ d = AST_Type::narrow_from_decl (temp->base_type ());
+ }
+
+ return d;
+}
+
// Redefinition of inherited virtual operations.
// Dump this AST_Typedef node to the ostream o.
diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp
index 1afba5730e9..8921e524982 100644
--- a/TAO/TAO_IDL/ast/ast_union.cpp
+++ b/TAO/TAO_IDL/ast/ast_union.cpp
@@ -88,13 +88,16 @@ AST_Union::AST_Union (AST_ConcreteType *dt,
UTL_StrList *p,
idl_bool local,
idl_bool abstract)
- : AST_Decl (AST_Decl::NT_union,
+ : AST_Decl (AST_Decl::NT_union,
n,
p),
- UTL_Scope (AST_Decl::NT_union),
- COMMON_Base (local,
- abstract)
+ UTL_Scope (AST_Decl::NT_union),
+ COMMON_Base (local,
+ abstract),
+ default_index_ (-2)
{
+ this->default_value_.computed_ = -2;
+
AST_PredefinedType *pdt = 0;
if (dt == 0)
@@ -464,6 +467,386 @@ AST_Union::lookup_branch (AST_UnionBranch *branch)
return 0;
}
+// Return the default value.
+int
+AST_Union::default_value (AST_Union::DefaultValue &dv)
+{
+ if (this->default_value_.computed_ == -2)
+ {
+ // We need to compute it.
+ if (this->compute_default_value () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::")
+ ACE_TEXT ("default_value - ")
+ ACE_TEXT ("Error computing ")
+ ACE_TEXT ("default value\n")),
+ -1);
+ }
+ }
+
+ dv = this->default_value_;
+ return 0;
+}
+
+// Determine the default value (if any).
+int
+AST_Union::compute_default_value (void)
+{
+ // Check if we really need a default value. This will be true if there is an
+ // explicit default case OR if an implicit default exists because not all
+ // values of the discriminant type are covered by the cases.
+
+ // Compute the total true "case" labels i.e., exclude the "default" case.
+ int total_case_members = 0;
+
+ // Instantiate a scope iterator.
+ UTL_ScopeActiveIterator *si = 0;
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (this,
+ UTL_Scope::IK_decls),
+ -1);
+
+ while (!si->is_done ())
+ {
+ // Get the next AST decl node.
+ AST_UnionBranch *ub =
+ AST_UnionBranch::narrow_from_decl (si->item ());
+
+ if (ub != 0)
+ {
+ // If the label is a case label, increment by 1.
+ for (unsigned long i = 0;
+ i < ub->label_list_length ();
+ ++i)
+ {
+ if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label)
+ {
+ total_case_members++;
+ }
+ }
+ }
+
+ si->next ();
+ }
+
+ delete si;
+
+ // Check if the total_case_members cover the entire
+ // range of values that are permitted by the discriminant type. If they do,
+ // then a default value is not necessary. However, if such an explicit
+ // default case is provided, it must be flagged off as an error. Our
+ // front-end is not able to handle such a case since it is a semantic error
+ // and not a syntax error. Such an error is caught here.
+
+ switch (this->udisc_type ())
+ {
+ case AST_Expression::EV_short:
+ case AST_Expression::EV_ushort:
+ if (total_case_members == ACE_UINT16_MAX + 1)
+ {
+ this->default_value_.computed_ = 0;
+ }
+
+ break;
+ case AST_Expression::EV_long:
+ case AST_Expression::EV_ulong:
+ if ((unsigned int) total_case_members > ACE_UINT32_MAX)
+ {
+ this->default_value_.computed_ = 0;
+ }
+
+ break;
+ case AST_Expression::EV_longlong:
+ case AST_Expression::EV_ulonglong:
+ // Error for now.
+ this->default_value_.computed_ = -1;
+ ACE_ERROR_RETURN ((
+ LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::compute_default_value ")
+ ACE_TEXT ("- unimplemented discriminant type ")
+ ACE_TEXT ("(longlong or ulonglong)\n")
+ ),
+ -1
+ );
+ ACE_NOTREACHED (break;)
+ case AST_Expression::EV_char:
+ if (total_case_members == ACE_OCTET_MAX + 1)
+ {
+ this->default_value_.computed_ = 0;
+ }
+
+ break;
+ case AST_Expression::EV_wchar:
+ if (total_case_members == ACE_WCHAR_MAX + 1)
+ {
+ this->default_value_.computed_ = 0;
+ }
+
+ break;
+ case AST_Expression::EV_bool:
+ if (total_case_members == 2)
+ {
+ this->default_value_.computed_ = 0;
+ }
+
+ break;
+ case AST_Expression::EV_any:
+ // Has to be enum.
+ {
+ AST_Decl *d = AST_Decl::narrow_from_decl (this->disc_type ());
+
+ if (d->node_type () == AST_Decl::NT_typedef)
+ {
+ AST_Typedef *bt = AST_Typedef::narrow_from_decl (d);
+ d = bt->primitive_base_type ();
+ }
+
+ AST_Enum *en = AST_Enum::narrow_from_decl (d);
+
+ if (en != 0)
+ {
+ if (total_case_members == en->member_count ())
+ {
+ this->default_value_.computed_ = 0;
+ }
+ }
+ else
+ {
+ // Error.
+ this->default_value_.computed_ = -1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::")
+ ACE_TEXT ("compute_default_value ")
+ ACE_TEXT ("- disc type not an ENUM\n")),
+ -1);
+ }
+ }
+ break;
+ default:
+ // Error.
+ this->default_value_.computed_ = -1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::compute_default_value")
+ ACE_TEXT (" - Bad discriminant type\n")),
+ -1);
+ ACE_NOTREACHED (break;)
+ } // End of switch
+
+ // If we have determined that we don't need a default case and even then a
+ // default case was provided, flag this off as error.
+ if ((this->default_value_.computed_ == 0)
+ && (this->default_index_ != -1))
+ {
+ // Error.
+ this->default_value_.computed_ = -1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::compute_default_value")
+ ACE_TEXT (" - default clause is invalid here\n")),
+ -1);
+ }
+
+ // Proceed only if necessary.
+ switch (this->default_value_.computed_)
+ {
+ case -1:
+ // Error. We should never be here because errors
+ // have already been caught
+ // above.
+ return -1;
+ case 0:
+ // Nothing more to do.
+ return 0;
+ default:
+ // Proceed further down.
+ break;
+ }
+
+ // Initialization of the default value data member.
+ switch (this->udisc_type ())
+ {
+ case AST_Expression::EV_short:
+ this->default_value_.u.short_val = ACE_INT16_MIN;
+ break;
+ case AST_Expression::EV_ushort:
+ this->default_value_.u.ushort_val = 0;
+ break;
+ case AST_Expression::EV_long:
+ // The +1 is to avert a warning on many compilers.
+ this->default_value_.u.long_val = ACE_INT32_MIN + 1;
+ break;
+ case AST_Expression::EV_ulong:
+ this->default_value_.u.ulong_val = 0;
+ break;
+ case AST_Expression::EV_char:
+ this->default_value_.u.char_val = 0;
+ break;
+ case AST_Expression::EV_wchar:
+ this->default_value_.u.wchar_val = 0;
+ break;
+ case AST_Expression::EV_bool:
+ this->default_value_.u.bool_val = 0;
+ break;
+ case AST_Expression::EV_any:
+ this->default_value_.u.enum_val = 0;
+ break;
+ case AST_Expression::EV_longlong:
+ case AST_Expression::EV_ulonglong:
+ // Unimplemented.
+ default:
+ // Error caught earlier.
+ break;
+ }
+
+ // Proceed until we have found the appropriate default value.
+ while (this->default_value_.computed_ == -2)
+ {
+ // Instantiate a scope iterator.
+ ACE_NEW_RETURN (si,
+ UTL_ScopeActiveIterator (this,
+ UTL_Scope::IK_decls),
+ -1);
+
+ int break_loop = 0;
+
+ while (!si->is_done () && break_loop == 0)
+ {
+ // Get the next AST decl node
+ AST_UnionBranch *ub =
+ AST_UnionBranch::narrow_from_decl (si->item ());
+
+ if (ub != 0)
+ {
+ for (unsigned long i = 0;
+ i < ub->label_list_length () && !break_loop;
+ ++i)
+ {
+ if (ub->label (i)->label_kind ()
+ == AST_UnionLabel::UL_label)
+ {
+ // Not a default.
+ AST_Expression *expr = ub->label (i)->label_val ();
+
+ if (expr == 0)
+ {
+ // Error.
+ this->default_value_.computed_ = -1;
+ ACE_ERROR_RETURN
+ ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) AST_Union::")
+ ACE_TEXT ("compute_default_value - ")
+ ACE_TEXT ("Bad case label value\n")),
+ -1);
+ }
+
+ switch (expr->ev ()->et)
+ {
+ // Check if they match in which case this
+ // cannot be the implicit default value. So
+ // start with a new value and try the whole loop
+ // again because our case labels may not be sorted.
+ case AST_Expression::EV_short:
+ if (this->default_value_.u.short_val
+ == expr->ev ()->u.sval)
+ {
+ this->default_value_.u.short_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_ushort:
+ if (this->default_value_.u.ushort_val
+ == expr->ev ()->u.usval)
+ {
+ this->default_value_.u.ushort_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_long:
+ if (this->default_value_.u.long_val
+ == expr->ev ()->u.lval)
+ {
+ this->default_value_.u.long_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_ulong:
+ if (this->default_value_.u.ulong_val
+ == expr->ev ()->u.ulval)
+ {
+ this->default_value_.u.ulong_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_char:
+ if (this->default_value_.u.char_val
+ == expr->ev ()->u.cval)
+ {
+ this->default_value_.u.char_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_wchar:
+ if (this->default_value_.u.wchar_val
+ == expr->ev ()->u.wcval)
+ {
+ this->default_value_.u.wchar_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_bool:
+ if (this->default_value_.u.bool_val
+ == expr->ev ()->u.bval)
+ {
+ this->default_value_.u.bool_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_any:
+ // this is the case of enums. We maintain
+ // evaluated values which always start with 0
+ if (this->default_value_.u.enum_val
+ == expr->ev ()->u.eval)
+ {
+ this->default_value_.u.enum_val++;
+ break_loop = 1;
+ }
+
+ break;
+ case AST_Expression::EV_longlong:
+ case AST_Expression::EV_ulonglong:
+ // Unimplemented. right now - flag as error.
+ default:
+ // Error.
+ break;
+ } // End of switch.
+ } // if label_Kind == label
+ } // End of for loop going thru all labels.
+ } // If valid union branch.
+
+ si->next ();
+ } // End of while scope iterator loop.
+
+ delete si;
+
+ // We have not aborted the inner loops which means we have found the
+ // default value.
+ if (break_loop == 0)
+ {
+ this->default_value_.computed_ = 1;
+ }
+
+ } // End of outer while (default_value.computed == -2).
+
+ return 0;
+}
+
// Redefinition of inherited virtual operations
// Add this AST_UnionBranch node (a node representing one branch in a
diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp
index 46c7830e526..0c136f5b514 100644
--- a/TAO/TAO_IDL/be/be_union.cpp
+++ b/TAO/TAO_IDL/be/be_union.cpp
@@ -52,11 +52,8 @@ be_union::be_union (AST_ConcreteType *dt,
p),
UTL_Scope (AST_Decl::NT_union),
COMMON_Base (local,
- abstract),
- default_index_ (-2)
+ abstract)
{
- this->default_value_.computed_ = -2;
-
// Always the case.
this->has_constructor (I_TRUE);
}
@@ -796,381 +793,6 @@ be_union::compute_size_type (void)
return 0;
}
-// Return the default value.
-int
-be_union::default_value (be_union::DefaultValue &dv)
-{
- if (this->default_value_.computed_ == -2)
- {
- // We need to compute it.
- if (this->compute_default_value () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::")
- ACE_TEXT ("default_value - ")
- ACE_TEXT ("Error computing ")
- ACE_TEXT ("default value\n")),
- -1);
- }
- }
-
- dv = this->default_value_;
- return 0;
-}
-
-// Determine the implicit default value (if any).
-int
-be_union::compute_default_value (void)
-{
- // Check if we really need a default value. This will be true if there is an
- // explicit default case OR if an implicit default exists because not all
- // values of the discriminant type are covered by the cases.
-
- // Compute the total true "case" labels i.e., exclude the "default" case.
- int total_case_members = 0;
-
- // Instantiate a scope iterator.
- UTL_ScopeActiveIterator *si = 0;
- ACE_NEW_RETURN (si,
- UTL_ScopeActiveIterator (this,
- UTL_Scope::IK_decls),
- -1);
-
- while (!si->is_done ())
- {
- // Get the next AST decl node.
- be_union_branch *ub =
- be_union_branch::narrow_from_decl (si->item ());
-
- if (ub != 0)
- {
- // If the label is a case label, increment by 1.
- for (unsigned long i = 0;
- i < ub->label_list_length ();
- ++i)
- {
- if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label)
- {
- total_case_members++;
- }
- }
- }
-
- si->next ();
- }
-
- delete si;
-
- // Check if the total_case_members cover the entire
- // range of values that are permitted by the discriminant type. If they do,
- // then a default value is not necessary. However, if such an explicit
- // default case is provided, it must be flagged off as an error. Our
- // front-end is not able to handle such a case since it is a semantic error
- // and not a syntax error. Such an error is caught here.
-
- switch (this->udisc_type ())
- {
- case AST_Expression::EV_short:
- case AST_Expression::EV_ushort:
- if (total_case_members == ACE_UINT16_MAX + 1)
- {
- this->default_value_.computed_ = 0;
- }
-
- break;
- case AST_Expression::EV_long:
- case AST_Expression::EV_ulong:
- if ((unsigned int) total_case_members > ACE_UINT32_MAX)
- {
- this->default_value_.computed_ = 0;
- }
-
- break;
- case AST_Expression::EV_longlong:
- case AST_Expression::EV_ulonglong:
- // Error for now.
- this->default_value_.computed_ = -1;
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::compute_default_value ")
- ACE_TEXT ("- unimplemented discriminant type ")
- ACE_TEXT ("(longlong or ulonglong)\n")),
- -1);
- ACE_NOTREACHED (break;)
- case AST_Expression::EV_char:
- if (total_case_members == ACE_OCTET_MAX + 1)
- {
- this->default_value_.computed_ = 0;
- }
-
- break;
- case AST_Expression::EV_wchar:
- if (total_case_members == ACE_WCHAR_MAX + 1)
- {
- this->default_value_.computed_ = 0;
- }
-
- break;
- case AST_Expression::EV_bool:
- if (total_case_members == 2)
- {
- this->default_value_.computed_ = 0;
- }
-
- break;
- case AST_Expression::EV_any:
- // Has to be enum.
- {
- be_decl *d = be_decl::narrow_from_decl (this->disc_type ());
-
- if (d->node_type () == AST_Decl::NT_typedef)
- {
- be_typedef *bt = be_typedef::narrow_from_decl (d);
- d = bt->primitive_base_type ();
- }
-
- be_enum *en = be_enum::narrow_from_decl (d);
-
- if (en != 0)
- {
- if (total_case_members == en->member_count ())
- {
- this->default_value_.computed_ = 0;
- }
- }
- else
- {
- // Error.
- this->default_value_.computed_ = -1;
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::")
- ACE_TEXT ("compute_default_value ")
- ACE_TEXT ("- disc type not an ENUM\n")),
- -1);
- }
- }
- break;
- default:
- // Error.
- this->default_value_.computed_ = -1;
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::compute_default_value ")
- ACE_TEXT ("- Bad discriminant type\n")),
- -1);
- ACE_NOTREACHED (break;)
- } // End of switch
-
- // If we have determined that we don't need a default case and even then a
- // default case was provided, flag this off as error.
- if ((this->default_value_.computed_ == 0)
- && (this->default_index () != -1))
- {
- // Error.
- this->default_value_.computed_ = -1;
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::compute_default_value ")
- ACE_TEXT ("- default clause is invalid here\n")),
- -1);
- }
-
- // Proceed only if necessary.
- switch (this->default_value_.computed_)
- {
- case -1:
- // Error. We should never be here because errors have already been caught
- // above.
- return -1;
- case 0:
- // Nothing more to do.
- return 0;
- default:
- // Proceed further down.
- break;
- }
-
- // Initialization of the default value data member.
- switch (this->udisc_type ())
- {
- case AST_Expression::EV_short:
- this->default_value_.u.short_val = ACE_INT16_MIN;
- break;
- case AST_Expression::EV_ushort:
- this->default_value_.u.ushort_val = 0;
- break;
- case AST_Expression::EV_long:
- // The +1 is to avert a warning on many compilers.
- this->default_value_.u.long_val = ACE_INT32_MIN + 1;
- break;
- case AST_Expression::EV_ulong:
- this->default_value_.u.ulong_val = 0;
- break;
- case AST_Expression::EV_char:
- this->default_value_.u.char_val = 0;
- break;
- case AST_Expression::EV_wchar:
- this->default_value_.u.wchar_val = 0;
- break;
- case AST_Expression::EV_bool:
- this->default_value_.u.bool_val = 0;
- break;
- case AST_Expression::EV_any:
- this->default_value_.u.enum_val = 0;
- break;
- case AST_Expression::EV_longlong:
- case AST_Expression::EV_ulonglong:
- // Unimplemented.
- default:
- // Error caught earlier.
- break;
- }
-
- // Proceed until we have found the appropriate default value.
- while (this->default_value_.computed_ == -2)
- {
- // Instantiate a scope iterator.
- ACE_NEW_RETURN (si,
- UTL_ScopeActiveIterator (this,
- UTL_Scope::IK_decls),
- -1);
-
- int break_loop = 0;
-
- while (!si->is_done () && break_loop == 0)
- {
- // Get the next AST decl node
- be_union_branch *ub =
- be_union_branch::narrow_from_decl (si->item ());
-
- if (ub != 0)
- {
- for (unsigned long i = 0;
- i < ub->label_list_length () && !break_loop;
- ++i)
- {
- if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label)
- {
- // Not a default.
- AST_Expression *expr = ub->label (i)->label_val ();
-
- if (expr == 0)
- {
- // Error.
- this->default_value_.computed_ = -1;
- ACE_ERROR_RETURN
- ((LM_ERROR,
- ACE_TEXT ("(%N:%l) be_union::")
- ACE_TEXT ("compute_default_value - ")
- ACE_TEXT ("Bad case label value\n")),
- -1);
- }
-
- switch (expr->ev ()->et)
- {
- // Check if they match in which case this
- // cannot be the implicit default value. So
- // start with a new value and try the whole loop
- // again because our case labels may not be sorted.
- case AST_Expression::EV_short:
- if (this->default_value_.u.short_val
- == expr->ev ()->u.sval)
- {
- this->default_value_.u.short_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_ushort:
- if (this->default_value_.u.ushort_val
- == expr->ev ()->u.usval)
- {
- this->default_value_.u.ushort_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_long:
- if (this->default_value_.u.long_val
- == expr->ev ()->u.lval)
- {
- this->default_value_.u.long_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_ulong:
- if (this->default_value_.u.ulong_val
- == expr->ev ()->u.ulval)
- {
- this->default_value_.u.ulong_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_char:
- if (this->default_value_.u.char_val
- == expr->ev ()->u.cval)
- {
- this->default_value_.u.char_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_wchar:
- if (this->default_value_.u.wchar_val
- == expr->ev ()->u.wcval)
- {
- this->default_value_.u.wchar_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_bool:
- if (this->default_value_.u.bool_val
- == expr->ev ()->u.bval)
- {
- this->default_value_.u.bool_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_any:
- // this is the case of enums. We maintain
- // evaluated values which always start with 0
- if (this->default_value_.u.enum_val
- == expr->ev ()->u.eval)
- {
- this->default_value_.u.enum_val++;
- break_loop = 1;
- }
-
- break;
- case AST_Expression::EV_longlong:
- case AST_Expression::EV_ulonglong:
- // Unimplemented. right now - flag as error.
- default:
- // Error.
- break;
- } // End of switch.
- } // if label_Kind == label
- } // End of for loop going thru all labels.
- } // If valid union branch.
-
- si->next ();
- } // End of while scope iterator loop.
-
- delete si;
-
- // We have not aborted the inner loops which means we have found the
- // default value.
- if (break_loop == 0)
- {
- this->default_value_.computed_ = 1;
- }
-
- } // End of outer while (default_value.computed == -2).
-
- return 0;
-}
-
idl_bool
be_union::has_duplicate_case_labels (void)
{
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
index ec0d503679b..e75c1e99102 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
@@ -1921,6 +1921,12 @@ be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node)
break;
case AST_Expression::EV_wchar:
+ os->print ("ACE_IDL_NSTOHL (0x%04.4x)",
+ (unsigned short)dv.u.wchar_val);
+ // size of short/wchar aligned to 4 bytes
+ this->tc_offset_ += sizeof (ACE_CDR::ULong);
+ break;
+
case AST_Expression::EV_short:
os->print ("ACE_IDL_NSTOHL (0x%04.4x)",
(unsigned short)dv.u.short_val);
diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h
index 4087069a655..c1c6b8ce00c 100644
--- a/TAO/TAO_IDL/be_include/be_union.h
+++ b/TAO/TAO_IDL/be_include/be_union.h
@@ -76,30 +76,6 @@ public:
DEF_NARROW_FROM_DECL(be_union);
DEF_NARROW_FROM_SCOPE(be_union);
- struct DefaultValue
- {
- union PermittedTypes
- {
- char char_val;
- ACE_CDR::WChar wchar_val;
- unsigned long bool_val;
- ACE_INT16 short_val;
- ACE_UINT16 ushort_val;
- ACE_INT32 long_val;
- ACE_UINT32 ulong_val;
- ACE_UINT32 enum_val;
- // TO-DO - handle (u)longlong types.
- } u;
- long computed_;
- // computed == -1 => error condition
- // == 0 => does not exist because all cases have been covered
- // == 1 => already computed
- // == -2 => initial value
- };
-
- int default_value (DefaultValue &);
- // Get the default value.
-
protected:
virtual int compute_size_type (void);
// Compute the size type if it is unknown.
@@ -107,15 +83,6 @@ protected:
private:
int compute_default_index (void);
// Count the default index.
-
- virtual int compute_default_value (void);
- // Compute the implicit default value (if any).
-
- int default_index_;
- // Default label index (zero based indexing).
-
- DefaultValue default_value_;
- // Implicit default value (if any).
};
#endif
diff --git a/TAO/TAO_IDL/include/ast_typedef.h b/TAO/TAO_IDL/include/ast_typedef.h
index 1a9b2ed03eb..479be13c1ef 100644
--- a/TAO/TAO_IDL/include/ast_typedef.h
+++ b/TAO/TAO_IDL/include/ast_typedef.h
@@ -86,6 +86,10 @@ public:
virtual ~AST_Typedef (void);
+ AST_Type *primitive_base_type (void);
+ // Return the most primitive base type by traversing the chain of typedefed
+ // base types.
+
// Data Accessors.
AST_Type *base_type (void);
diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h
index 07eefb2dd3f..550a78947b2 100644
--- a/TAO/TAO_IDL/include/ast_union.h
+++ b/TAO/TAO_IDL/include/ast_union.h
@@ -108,12 +108,40 @@ public:
DEF_NARROW_FROM_DECL(AST_Union);
DEF_NARROW_FROM_SCOPE(AST_Union);
+ struct DefaultValue
+ {
+ union PermittedTypes
+ {
+ char char_val;
+ ACE_CDR::WChar wchar_val;
+ unsigned long bool_val;
+ ACE_INT16 short_val;
+ ACE_UINT16 ushort_val;
+ ACE_INT32 long_val;
+ ACE_UINT32 ulong_val;
+ ACE_UINT32 enum_val;
+ // TO-DO - handle (u)longlong types.
+ } u;
+ long computed_;
+ // computed == -1 => error condition
+ // == 0 => does not exist because all cases have been covered
+ // == 1 => already computed
+ // == -2 => initial value
+ };
+
+ int default_value (DefaultValue &);
+ // Get the default value.
+
// AST Dumping.
virtual void dump (ostream &);
// Visiting.
virtual int ast_accept (ast_visitor *visitor);
+protected:
+ int default_index_;
+ // Default label index (zero based indexing).
+
private:
// Data.
@@ -140,7 +168,6 @@ private:
// check for duplicate enum labels.
AST_UnionBranch *lookup_enum (AST_UnionBranch *b);
-private:
friend int tao_yyparse (void);
// Scope Management Protocol.
@@ -154,6 +181,11 @@ private:
virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v);
+ virtual int compute_default_value (void);
+ // Compute the default value (if any).
+
+ DefaultValue default_value_;
+ // Default value (if any).
};
#endif // _AST_UNION_AST_UNION_HH