summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-11-06 18:33:38 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-11-06 18:33:38 +0000
commitf5d0fd67bb42e7bb35a92ad343bb39ac82d1c3da (patch)
treed7d44110b26585ace11b05e6d6fadcd156d754e9 /TAO/TAO_IDL
parent12d218f8f195da5593db40e2ad00bc93d9206f43 (diff)
downloadATCD-f5d0fd67bb42e7bb35a92ad343bb39ac82d1c3da.tar.gz
ChangeLogTag: Mon Nov 6 12:28:41 2000 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL')
-rw-r--r--TAO/TAO_IDL/ast/ast_union.cpp98
-rw-r--r--TAO/TAO_IDL/be/be_union.cpp71
-rw-r--r--TAO/TAO_IDL/be_include/be_union.h7
-rw-r--r--TAO/TAO_IDL/include/ast_union.h13
4 files changed, 87 insertions, 102 deletions
diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp
index 8921e524982..305f584cb33 100644
--- a/TAO/TAO_IDL/ast/ast_union.cpp
+++ b/TAO/TAO_IDL/ast/ast_union.cpp
@@ -180,6 +180,18 @@ AST_Union::~AST_Union (void)
// Public operations.
+// Return the default_index.
+int
+AST_Union::default_index (void)
+{
+ if (this->default_index_ == -2)
+ {
+ this->compute_default_index ();
+ }
+
+ return this->default_index_;
+}
+
// Are we or the parameter node involved in any recursion?
idl_bool
AST_Union::in_recursion (AST_Type *node)
@@ -501,17 +513,14 @@ AST_Union::compute_default_value (void)
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);
+ UTL_ScopeActiveIterator si (this,
+ UTL_Scope::IK_decls);
- while (!si->is_done ())
+ while (!si.is_done ())
{
// Get the next AST decl node.
AST_UnionBranch *ub =
- AST_UnionBranch::narrow_from_decl (si->item ());
+ AST_UnionBranch::narrow_from_decl (si.item ());
if (ub != 0)
{
@@ -527,11 +536,9 @@ AST_Union::compute_default_value (void)
}
}
- si->next ();
+ 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
@@ -636,7 +643,7 @@ AST_Union::compute_default_value (void)
// 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))
+ && (this->default_index () != -1))
{
// Error.
this->default_value_.computed_ = -1;
@@ -702,18 +709,16 @@ AST_Union::compute_default_value (void)
while (this->default_value_.computed_ == -2)
{
// Instantiate a scope iterator.
- ACE_NEW_RETURN (si,
- UTL_ScopeActiveIterator (this,
- UTL_Scope::IK_decls),
- -1);
+ UTL_ScopeActiveIterator si (this,
+ UTL_Scope::IK_decls);
int break_loop = 0;
- while (!si->is_done () && 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 ());
+ AST_UnionBranch::narrow_from_decl (si.item ());
if (ub != 0)
{
@@ -830,11 +835,9 @@ AST_Union::compute_default_value (void)
} // End of for loop going thru all labels.
} // If valid union branch.
- si->next ();
+ 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)
@@ -847,6 +850,61 @@ AST_Union::compute_default_value (void)
return 0;
}
+// Private operations.
+
+// Compute the default index.
+int
+AST_Union::compute_default_index (void)
+{
+ AST_Decl *d = 0;
+ AST_UnionBranch *ub = 0;
+ int i = 0;
+
+ // If default case does not exist, it will have a value of -1 according to
+ // the spec.
+ this->default_index_ = -1;
+
+ // If there are elements in this scope...
+ if (this->nmembers () > 0)
+ {
+ // Instantiate a scope iterator.
+ UTL_ScopeActiveIterator si (this,
+ UTL_Scope::IK_decls);
+ while (!si.is_done ())
+ {
+ // Get the next AST decl node.
+ d = si.item ();
+
+ if (!d->imported ())
+ {
+ ub = AST_UnionBranch::narrow_from_decl (d);
+
+ for (unsigned long j = 0;
+ j < ub->label_list_length ();
+ ++j)
+ {
+ // Check if we are printing the default case.
+ if (ub->label (j)->label_kind ()
+ == AST_UnionLabel::UL_default)
+ {
+ // Zero based indexing.
+ this->default_index_ = i;
+ }
+ }
+
+ // TAO's Typecode class keeps only a member count (not
+ // a label count) so this increment has been moved
+ // out of the inner loop.
+ i++;
+ }
+
+ si.next ();
+ }
+ }
+
+ 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 0c136f5b514..7bdd366aa67 100644
--- a/TAO/TAO_IDL/be/be_union.cpp
+++ b/TAO/TAO_IDL/be/be_union.cpp
@@ -58,77 +58,6 @@ be_union::be_union (AST_ConcreteType *dt,
this->has_constructor (I_TRUE);
}
-// Compute total number of members.
-int
-be_union::compute_default_index (void)
-{
- UTL_ScopeActiveIterator *si = 0;
- AST_Decl *d = 0;
- be_union_branch *bub = 0;
- int i = 0;
-
- // If default case does not exist, it will have a value of -1 according to
- // the spec.
- this->default_index_ = -1;
-
- // If there are elements in this scope...
- if (this->nmembers () > 0)
- {
- // Instantiate a scope iterator.
- ACE_NEW_RETURN (si,
- UTL_ScopeActiveIterator (this,
- UTL_Scope::IK_decls),
- -1);
-
- while (!si->is_done ())
- {
- // Get the next AST decl node.
- d = si->item ();
-
- if (!d->imported ())
- {
- bub = be_union_branch::narrow_from_decl (d);
-
- for (unsigned long j = 0;
- j < bub->label_list_length ();
- ++j)
- {
- // Check if we are printing the default case.
- if (bub->label (j)->label_kind ()
- == AST_UnionLabel::UL_default)
- {
- // Zero based indexing.
- this->default_index_ = i;
- }
- }
-
- // TAO's Typecode class keeps only a member count (not
- // a label count) so this increment has been moved
- // out of the inner loop.
- i++;
- }
-
- si->next ();
- }
-
- delete si;
- }
-
- return 0;
-}
-
-// Return the default_index.
-int
-be_union::default_index (void)
-{
- if (this->default_index_ == -2)
- {
- this->compute_default_index ();
- }
-
- return this->default_index_;
-}
-
// Generate the _var definition for ourself.
int
be_union::gen_var_defn (char *)
diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h
index c1c6b8ce00c..5375b15b334 100644
--- a/TAO/TAO_IDL/be_include/be_union.h
+++ b/TAO/TAO_IDL/be_include/be_union.h
@@ -59,9 +59,6 @@ public:
char *full_name = 0);
// Generate the _out implementation.
- virtual int default_index (void);
- // Return the default index used.
-
virtual idl_bool has_duplicate_case_labels (void);
// Do we have at least one member with multiple case labels?
@@ -79,10 +76,6 @@ public:
protected:
virtual int compute_size_type (void);
// Compute the size type if it is unknown.
-
-private:
- int compute_default_index (void);
- // Count the default index.
};
#endif
diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h
index 550a78947b2..13bf478b216 100644
--- a/TAO/TAO_IDL/include/ast_union.h
+++ b/TAO/TAO_IDL/include/ast_union.h
@@ -132,16 +132,15 @@ public:
int default_value (DefaultValue &);
// Get the default value.
+ virtual int default_index (void);
+ // Return the default index used.
+
// 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.
@@ -184,8 +183,14 @@ private:
virtual int compute_default_value (void);
// Compute the default value (if any).
+ int compute_default_index (void);
+ // Count the default index.
+
DefaultValue default_value_;
// Default value (if any).
+
+ int default_index_;
+ // Default label index (zero based indexing).
};
#endif // _AST_UNION_AST_UNION_HH