diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-02 20:06:33 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-02 20:06:33 +0000 |
commit | 49ed55bd1c7af9b4ead73fad0f64d4db62299b4d (patch) | |
tree | 78664e1c266d9f9c533696b13e9b32348f7ccefc /TAO/TAO_IDL | |
parent | 558cd523ef314f3cb138a469f2d8976544ef62ff (diff) | |
download | ATCD-49ed55bd1c7af9b4ead73fad0f64d4db62299b4d.tar.gz |
ChangeLogTag: Mon Oct 2 14:59:44 2000 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL')
60 files changed, 6550 insertions, 5914 deletions
diff --git a/TAO/TAO_IDL/ast/ast_argument.cpp b/TAO/TAO_IDL/ast/ast_argument.cpp index 99b233c0d70..a6ef166b083 100644 --- a/TAO/TAO_IDL/ast/ast_argument.cpp +++ b/TAO/TAO_IDL/ast/ast_argument.cpp @@ -62,58 +62,57 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_argument.cc - Implementation of class AST_Argument.cc - * - * AST_Argument nodes denote arguments to an operation. They - * are AST_Fields with directions. Thus, they have a name - * (an UTL_ScopedName) and a type (a subclass of AST_Type). - * Additionally they have a direction field which takes values - * from the enum AST_Argument::Direction. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Argument nodes denote arguments to an operation. They +// are AST_Fields with directions. Thus, they have a name +// (an UTL_ScopedName) and a type (a subclass of AST_Type). +// Additionally they have a direction field which takes values +// from the enum AST_Argument::Direction. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_argument, "$Id$") -/* - * Static functions - */ +// Static functions. -/* - * Convert an enum Direction value to a char * - */ +// Convert an enum Direction value to a char *. static const char * -direction_to_string(AST_Argument::Direction d) +direction_to_string (AST_Argument::Direction d) { - switch (d) { - case AST_Argument::dir_IN: - return "in"; - case AST_Argument::dir_OUT: - return "out"; - case AST_Argument::dir_INOUT: - return "inout"; - } - return NULL; + switch (d) + { + case AST_Argument::dir_IN: + return "in"; + case AST_Argument::dir_OUT: + return "out"; + case AST_Argument::dir_INOUT: + return "inout"; + } + + return 0; } -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. -AST_Argument::AST_Argument() - : pd_direction(dir_IN) +AST_Argument::AST_Argument (void) + : pd_direction(dir_IN) { } -AST_Argument::AST_Argument(Direction d, AST_Type *ft, UTL_ScopedName *n, - UTL_StrList *p) - : AST_Field(AST_Decl::NT_argument, ft, n, p), - AST_Decl(AST_Decl::NT_argument, n, p), - pd_direction(d) +AST_Argument::AST_Argument (Direction d, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p) + : AST_Field (AST_Decl::NT_argument, + ft, + n, + p), + AST_Decl (AST_Decl::NT_argument, + n, + p), + pd_direction (d) { } @@ -121,40 +120,24 @@ AST_Argument::~AST_Argument (void) { } -/* - * Private operations - */ +// Redefinition of inherited virtual operations. -/* - * Public operations - */ - -/* - * Redefinition of inherited virtual operations - */ - -/* - * Dump this AST_Argument node to the ostream o - */ +// Dump this AST_Argument node to the ostream o. void -AST_Argument::dump(ostream &o) +AST_Argument::dump (ostream &o) { o << direction_to_string(pd_direction) << " "; - AST_Field::dump(o); + AST_Field::dump (o); } -/* - * Data accessors - */ +// Data accessors. AST_Argument::Direction -AST_Argument::direction() +AST_Argument::direction (void) { - return pd_direction; + return this->pd_direction; } -/* - * Narrowing operations - */ +// Narrowing operations. IMPL_NARROW_METHODS1(AST_Argument, AST_Field) IMPL_NARROW_FROM_DECL(AST_Argument) diff --git a/TAO/TAO_IDL/ast/ast_array.cpp b/TAO/TAO_IDL/ast/ast_array.cpp index 9bded9937c8..00a31c1fd39 100644 --- a/TAO/TAO_IDL/ast/ast_array.cpp +++ b/TAO/TAO_IDL/ast/ast_array.cpp @@ -62,139 +62,134 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_array.cc - Implementation of class AST_Array - * - * AST_Array nodes denote array type and field modifiers. - * AST_Array nodes have a list of dimensions (a UTL_ExprList) - * a count of the number of dimensions and a base type (a - * subtype of AST_ConcreteType. This means that we cannot have - * arrays of AST_Interfaces??? - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Array nodes denote array type and field modifiers. +// AST_Array nodes have a list of dimensions (a UTL_ExprList) +// a count of the number of dimensions and a base type (a +// subtype of AST_ConcreteType. This means that we cannot have +// arrays of AST_Interfaces??? + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_array, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Array::AST_Array() - : pd_n_dims(0), - pd_dims(NULL), - pd_base_type(NULL) +// Constructor(s) and destructor. + +AST_Array::AST_Array (void) + : pd_n_dims (0), + pd_dims (0), + pd_base_type (0) { } -AST_Array::AST_Array(UTL_ScopedName *n, - unsigned long nd, - UTL_ExprList *ds, - idl_bool local, - idl_bool abstract) - : AST_Decl(AST_Decl::NT_array, n, NULL), - COMMON_Base (local, abstract), - pd_n_dims(nd), pd_base_type(NULL) +AST_Array::AST_Array (UTL_ScopedName *n, + unsigned long nd, + UTL_ExprList *ds, + idl_bool local, + idl_bool abstract) + : AST_Decl (AST_Decl::NT_array, + n, + 0), + COMMON_Base (local, + abstract), + pd_n_dims (nd), + pd_base_type (0) { - pd_dims = compute_dims(ds, nd); + this->pd_dims = compute_dims (ds, + nd); } AST_Array::~AST_Array (void) { } -/* - * Private operations - */ +// Private operations. -/* - * Compute how many dimensions there are and collect their expressions - * into an array - */ +// Compute how many dimensions there are and collect their expressions +// into an array. AST_Expression ** -AST_Array::compute_dims(UTL_ExprList *ds, unsigned long nds) +AST_Array::compute_dims (UTL_ExprList *ds, + unsigned long nds) { - AST_Expression **result; - UTL_ExprlistActiveIterator *l; - unsigned long i; - - if (ds == NULL) - return NULL; - - result = new AST_Expression *[nds]; - l = new UTL_ExprlistActiveIterator(ds); - - for (i = 0; !(l->is_done()) && i < nds; l->next(), i++) - result[i] = l->item(); - delete l; + if (ds == 0) + { + return 0; + } + + AST_Expression **result = 0; + ACE_NEW_RETURN (result, + AST_Expression *[nds], + 0); + + UTL_ExprlistActiveIterator *iter; + ACE_NEW_RETURN (iter, + UTL_ExprlistActiveIterator (ds), + 0); + + for (unsigned long i = 0; + !iter->is_done() && i < nds; + iter->next(), i++) + { + result[i] = iter->item (); + } + + delete iter; return result; } -/* - * Public operations - */ - - -/* - * Redefinition of inherited virtual operations - */ +// Redefinition of inherited virtual operations. -/* - * Dump this AST_Array node to the ostream o - */ +// Dump this AST_Array node to the ostream o. void -AST_Array::dump(ostream &o) +AST_Array::dump (ostream &o) { - unsigned long i; - - pd_base_type->dump(o); + pd_base_type->dump (o); o << " "; - local_name()->dump(o); - for (i = 0; i < pd_n_dims; i++) { - o << "["; - pd_dims[i]->dump(o); - o << "]"; - } + this->local_name ()->dump (o); + + for (unsigned long i = 0; i < this->pd_n_dims; i++) + { + o << "["; + pd_dims[i]->dump (o); + o << "]"; + } } -/* - * Data accessors - */ +// Data accessors. unsigned long -AST_Array::n_dims() +AST_Array::n_dims (void) { - return pd_n_dims; + return this->pd_n_dims; } AST_Expression ** -AST_Array::dims() +AST_Array::dims (void) { - return pd_dims; + return this->pd_dims; } AST_Type * -AST_Array::base_type() +AST_Array::base_type (void) { - return pd_base_type; + return this->pd_base_type; } void -AST_Array::set_base_type(AST_Type *nbt) +AST_Array::set_base_type (AST_Type *nbt) { - pd_base_type = nbt; + this->pd_base_type = nbt; } void -AST_Array::set_dims(AST_Expression **ds, unsigned long nds) +AST_Array::set_dims (AST_Expression **ds, + unsigned long nds) { - pd_dims = ds; - pd_n_dims = nds; + this->pd_dims = ds; + this->pd_n_dims = nds; } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_Array, AST_ConcreteType) IMPL_NARROW_FROM_DECL(AST_Array) diff --git a/TAO/TAO_IDL/ast/ast_attribute.cpp b/TAO/TAO_IDL/ast/ast_attribute.cpp index 92d7185b044..e286db5b9f7 100644 --- a/TAO/TAO_IDL/ast/ast_attribute.cpp +++ b/TAO/TAO_IDL/ast/ast_attribute.cpp @@ -62,41 +62,41 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_attribute.cc - Implementation of class AST_Attribute.cc - * - * AST_Attribute nodes denote IDL attribute declarations. - * AST_Attribute nodes are AST_Fields with a readonly indication. - * Hence they have a name (an UTL_ScopedName), a type (a subtype - * of AST_Type) and a boolean indicating whether the attribute is - * readonly. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Attribute nodes denote IDL attribute declarations. +// AST_Attribute nodes are AST_Fields with a readonly indication. +// Hence they have a name (an UTL_ScopedName), a type (a subtype +// of AST_Type) and a boolean indicating whether the attribute is +// readonly. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_attribute, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Attribute::AST_Attribute() - : pd_readonly(I_TRUE) +// Constructor(s) and destructor. +AST_Attribute::AST_Attribute (void) + : pd_readonly (I_TRUE) { } -AST_Attribute::AST_Attribute(idl_bool ro, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) - : AST_Field(AST_Decl::NT_attr, ft, n, p), - AST_Decl(AST_Decl::NT_attr, n, p), - COMMON_Base (local, abstract), - pd_readonly(ro) +AST_Attribute::AST_Attribute (idl_bool ro, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) + : AST_Field (AST_Decl::NT_attr, + ft, + n, + p), + AST_Decl (AST_Decl::NT_attr, + n, + p), + COMMON_Base (local, + abstract), + pd_readonly (ro) { } @@ -104,40 +104,25 @@ AST_Attribute::~AST_Attribute (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ +// Redefinition of inherited virtual operations. -/* - * Redefinition of inherited virtual operations - */ - -/* - * Dump this AST_Attribute to the ostream o - */ +// Dump this AST_Attribute to the ostream o. void -AST_Attribute::dump(ostream &o) +AST_Attribute::dump (ostream &o) { - o << (pd_readonly == I_TRUE ? "readonly" : "") << " attribute "; - AST_Field::dump(o); + o << (this->pd_readonly == I_TRUE ? "readonly" : "") + << " attribute "; + AST_Field::dump (o); } -/* - * Data accessors - */ +// Data accessors. idl_bool -AST_Attribute::readonly() +AST_Attribute::readonly (void) { - return pd_readonly; + return this->pd_readonly; } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_Attribute, AST_Field) IMPL_NARROW_FROM_DECL(AST_Attribute) diff --git a/TAO/TAO_IDL/ast/ast_check.cpp b/TAO/TAO_IDL/ast/ast_check.cpp index 363e47e5155..34d86def55d 100644 --- a/TAO/TAO_IDL/ast/ast_check.cpp +++ b/TAO/TAO_IDL/ast/ast_check.cpp @@ -62,86 +62,80 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_check.cc - Check AST nodes representing fwd declared interfaces - * after parse of AST is completed. - * - * The check ensures that for every forward declared interface we also - * saw a full definition of that interface. - */ +// The check ensures that for every forward declared interface we also +// saw a full definition of that interface. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_check, "$Id$") -/* - * Static storage for remembering nodes - */ -static AST_InterfaceFwd **ast_fwds = NULL; -static long ast_n_fwds_used = 0; -static long ast_n_fwds_alloc = 0; +// Static storage for remembering nodes. +static AST_InterfaceFwd **ast_fwds = 0; +static long ast_n_fwds_used = 0; +static long ast_n_fwds_alloc = 0; #undef INCREMENT #define INCREMENT 64 -/* - * Store a node representing a forward declared interface - */ +// Store a node representing a forward declared interface. void -AST_record_fwd_interface(AST_InterfaceFwd *n) +AST_record_fwd_interface (AST_InterfaceFwd *n) { - AST_InterfaceFwd **o_ast_fwds; - long o_ast_n_fwds_alloc; - long i; - - /* - * Make sure there's space to store one more - */ - if (ast_n_fwds_used == ast_n_fwds_alloc) { - if (ast_n_fwds_alloc == 0) { - ast_n_fwds_alloc = INCREMENT; - ast_fwds = new AST_InterfaceFwd *[ast_n_fwds_alloc]; - } else { - o_ast_fwds = ast_fwds; - o_ast_n_fwds_alloc = ast_n_fwds_alloc; - - ast_n_fwds_alloc += INCREMENT; - ast_fwds = new AST_InterfaceFwd *[ast_n_fwds_alloc]; - - for (i = 0; i < o_ast_n_fwds_alloc; i++) - ast_fwds[i] = o_ast_fwds[i]; - - delete o_ast_fwds; + AST_InterfaceFwd **o_ast_fwds = 0; + long o_ast_n_fwds_alloc = 0; + + // Make sure there's space to store one more. + if (ast_n_fwds_used == ast_n_fwds_alloc) + { + if (ast_n_fwds_alloc == 0) + { + ast_n_fwds_alloc = INCREMENT; + ACE_NEW (ast_fwds, + AST_InterfaceFwd *[ast_n_fwds_alloc]); + } + else + { + o_ast_fwds = ast_fwds; + o_ast_n_fwds_alloc = ast_n_fwds_alloc; + + ast_n_fwds_alloc += INCREMENT; + ACE_NEW (ast_fwds, + AST_InterfaceFwd *[ast_n_fwds_alloc]); + + for (long i = 0; i < o_ast_n_fwds_alloc; i++) + { + ast_fwds[i] = o_ast_fwds[i]; + } + + delete o_ast_fwds; + } } - } - /* - * Insert new node - */ + + // Insert new node. ast_fwds[ast_n_fwds_used++] = n; } -/* - * Check that all forward declared interfaces were also defined - */ +// Check that all forward declared interfaces were also defined. void -AST_check_fwd_interface() +AST_check_fwd_interface (void) { - long i; - AST_InterfaceFwd *d; - AST_Interface *itf; - - for (i = 0; i < ast_n_fwds_used; i++) { - d = ast_fwds[i]; - itf = d->full_definition(); - if (!(itf->is_defined())) - { - // The old pointer may now be garbage. - itf->set_file_name (idl_global->filename ()); - - idl_global->err()->fwd_decl_not_defined(itf); - } - } + AST_InterfaceFwd *d = 0; + AST_Interface *itf = 0; + + for (long i = 0; i < ast_n_fwds_used; i++) + { + d = ast_fwds[i]; + itf = d->full_definition (); + + if (!itf->is_defined ()) + { + // The old pointer may now be garbage. + itf->set_file_name (idl_global->filename ()); + + idl_global->err ()->fwd_decl_not_defined (itf); + } + } } diff --git a/TAO/TAO_IDL/ast/ast_concrete_type.cpp b/TAO/TAO_IDL/ast/ast_concrete_type.cpp index 2b2f9149042..bfb3a2d30ec 100644 --- a/TAO/TAO_IDL/ast/ast_concrete_type.cpp +++ b/TAO/TAO_IDL/ast/ast_concrete_type.cpp @@ -62,30 +62,27 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_concrete_type.cc - Implementation of class AST_ConcreteType - * - * AST_ConcreteType nodes denote all non-interface types of IDL. - * They are AST_Type nodes. - */ +// AST_ConcreteType nodes denote all non-interface types of IDL. +// They are AST_Type nodes. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_concrete_type, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_ConcreteType::AST_ConcreteType () +// Constructor(s) and destructor. +AST_ConcreteType::AST_ConcreteType (void) { } -AST_ConcreteType::AST_ConcreteType (AST_Decl::NodeType nt, UTL_ScopedName *n, - UTL_StrList *p) - : AST_Decl (nt, n, p) +AST_ConcreteType::AST_ConcreteType (AST_Decl::NodeType nt, + UTL_ScopedName *n, + UTL_StrList *p) + : AST_Decl (nt, + n, + p) { } @@ -93,20 +90,6 @@ AST_ConcreteType::~AST_ConcreteType (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ - -/* - * Redefinition of inherited virtual operations - */ - -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_ConcreteType, AST_Type) IMPL_NARROW_FROM_DECL(AST_ConcreteType) diff --git a/TAO/TAO_IDL/ast/ast_constant.cpp b/TAO/TAO_IDL/ast/ast_constant.cpp index e7de155511a..4065b039c2a 100644 --- a/TAO/TAO_IDL/ast/ast_constant.cpp +++ b/TAO/TAO_IDL/ast/ast_constant.cpp @@ -62,166 +62,140 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_constant.cc - Implementation of class AST_Constant - * - * AST_Constant nodes denote IDL constant declarations. - * AST_Constants have a value (an AST_Expression) and a value type - * (a value from the enum AST_Expression::ExprType). - * AST_Constant has two constructors, one for use in creating constants - * and the other for use in creating enumerators (see the class - * AST_EnumVal) - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Constant nodes denote IDL constant declarations. +// AST_Constants have a value (an AST_Expression) and a value type +// (a value from the enum AST_Expression::ExprType). +// AST_Constant has two constructors, one for use in creating constants +// and the other for use in creating enumerators (see the class +// AST_EnumVal). + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_constant, "$Id$") -/* - * Static functions - */ +// Static functions. -/* - * Convert a value from the enum AST_Expression::ExprType to a char * - */ +// Convert a value from the enum AST_Expression::ExprType to a char *. static const char * -exprtype_to_string(AST_Expression::ExprType et) +exprtype_to_string (AST_Expression::ExprType et) { - switch (et) { - case AST_Expression::EV_short: - return "short"; - case AST_Expression::EV_ushort: - return "unsigned short"; - case AST_Expression::EV_long: - return "long"; - case AST_Expression::EV_ulong: - return "unsigned long"; - case AST_Expression::EV_float: - return "float"; - case AST_Expression::EV_double: - return "double"; - case AST_Expression::EV_char: - return "char"; - case AST_Expression::EV_octet: - return "octet"; - case AST_Expression::EV_bool: - return "boolean"; - case AST_Expression::EV_string: - return "string"; - case AST_Expression::EV_any: - return "any"; - case AST_Expression::EV_void: - return "void"; - case AST_Expression::EV_none: - return "none"; - case AST_Expression::EV_ulonglong: - return "unsigned long long"; - case AST_Expression::EV_longlong: - return "long long"; - case AST_Expression::EV_wchar: - return "wchar"; - case AST_Expression::EV_wstring: - return "wstring"; - case AST_Expression::EV_longdouble: - return NULL; - } - return NULL; + switch (et) + { + case AST_Expression::EV_short: + return "short"; + case AST_Expression::EV_ushort: + return "unsigned short"; + case AST_Expression::EV_long: + return "long"; + case AST_Expression::EV_ulong: + return "unsigned long"; + case AST_Expression::EV_float: + return "float"; + case AST_Expression::EV_double: + return "double"; + case AST_Expression::EV_char: + return "char"; + case AST_Expression::EV_octet: + return "octet"; + case AST_Expression::EV_bool: + return "boolean"; + case AST_Expression::EV_string: + return "string"; + case AST_Expression::EV_any: + return "any"; + case AST_Expression::EV_void: + return "void"; + case AST_Expression::EV_none: + return "none"; + case AST_Expression::EV_ulonglong: + return "unsigned long long"; + case AST_Expression::EV_longlong: + return "long long"; + case AST_Expression::EV_wchar: + return "wchar"; + case AST_Expression::EV_wstring: + return "wstring"; + case AST_Expression::EV_longdouble: + return 0; + } + + return 0; } -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. -/* - * Default constructor - */ -AST_Constant::AST_Constant() - : pd_constant_value(NULL), pd_et(AST_Expression::EV_none) +// Default constructor. +AST_Constant::AST_Constant (void) + : pd_constant_value (0), + pd_et (AST_Expression::EV_none) { } -/* - * Used in constructing AST_EnumVal nodes - */ -AST_Constant::AST_Constant(AST_Expression::ExprType t, - AST_Decl::NodeType nt, - AST_Expression *v, - UTL_ScopedName *n, - UTL_StrList *p) - : AST_Decl(nt, n, p), - pd_constant_value(idl_global->gen()->create_expr(v, t)), - pd_et(t) +// Used in constructing AST_EnumVal nodes. +AST_Constant::AST_Constant (AST_Expression::ExprType t, + AST_Decl::NodeType nt, + AST_Expression *v, + UTL_ScopedName *n, + UTL_StrList *p) + : AST_Decl (nt, + n, + p), + pd_constant_value (idl_global->gen ()->create_expr (v, t)), + pd_et (t) { } -/* - * Used when constructing AST_Constant nodes - */ -AST_Constant::AST_Constant(AST_Expression::ExprType t, - AST_Expression *v, - UTL_ScopedName *n, - UTL_StrList *p) - : AST_Decl(AST_Decl::NT_const, n, p), - pd_constant_value(idl_global->gen()->create_expr(v, t)), - pd_et(t) +// Used when constructing AST_Constant nodes. +AST_Constant::AST_Constant (AST_Expression::ExprType t, + AST_Expression *v, + UTL_ScopedName *n, + UTL_StrList *p) + : AST_Decl (AST_Decl::NT_const, + n, + p), + pd_constant_value (idl_global->gen ()->create_expr (v, t)), + pd_et (t) { } AST_Constant::~AST_Constant (void) { - if (this->pd_constant_value) + if (this->pd_constant_value != 0) { delete this->pd_constant_value; this->pd_constant_value = 0; } } -/* - * Private operations - */ - -/* - * Public operations - */ - +// Redefinition of inherited virtual operations. -/* - * Redefinition of inherited virtual operations - */ - -/* - * Dump this AST_Constant node to the ostream o - */ +// Dump this AST_Constant node to the ostream o. void -AST_Constant::dump(ostream &o) +AST_Constant::dump (ostream &o) { - o << "const " << exprtype_to_string(pd_et) << " "; - local_name()->dump(o); + o << "const " << exprtype_to_string (pd_et) << " "; + this->local_name ()->dump (o); o << " = "; - pd_constant_value->dump(o); + this->pd_constant_value->dump (o); } -/* - * Data accessors - */ +// Data accessors. AST_Expression * -AST_Constant::constant_value() +AST_Constant::constant_value (void) { - return pd_constant_value; + return this->pd_constant_value; } AST_Expression::ExprType -AST_Constant::et() +AST_Constant::et (void) { - return pd_et; + return this->pd_et; } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_Constant, AST_Decl) IMPL_NARROW_FROM_DECL(AST_Constant) diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index 6ee638fbcb7..e9aaffd7003 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -106,7 +106,7 @@ COMMON_Base::destroy (void) { } -// Constructor(s) and destructor +// Constructor(s) and destructor. AST_Decl::AST_Decl (void) : pd_imported (I_FALSE), @@ -119,7 +119,10 @@ AST_Decl::AST_Decl (void) pd_local_name (0), pd_original_local_name (0), pd_pragmas (0), - pd_added (I_FALSE) + pd_added (I_FALSE), + full_name_ (0), + repoID_ (0), + prefix_ (0) { } @@ -137,7 +140,10 @@ AST_Decl::AST_Decl (NodeType nt, pd_name (0), pd_local_name (n == 0 ? 0 : n->last_component ()->copy ()), pd_pragmas (p), - pd_added (I_FALSE) + pd_added (I_FALSE), + full_name_ (0), + repoID_ (0), + prefix_ (0) { compute_full_name (n); @@ -152,9 +158,9 @@ AST_Decl::~AST_Decl (void) { } -// Private operations +// Private operations. -// Compute the full scoped name of an AST node +// Compute our private UTL_ScopedName member. void AST_Decl::compute_full_name (UTL_ScopedName *n) { @@ -176,10 +182,14 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) d = ScopeAsDecl (this->defined_in ()); if (d != 0) - cn = d->name (); + { + cn = d->name (); + } if (cn != 0) - this->pd_name = (UTL_ScopedName *) cn->copy (); + { + this->pd_name = (UTL_ScopedName *) cn->copy (); + } if (this->pd_local_name != 0) { @@ -219,7 +229,300 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) } } -// Public operations +// Compoute stringified prefix. +void +AST_Decl::compute_prefix (void) +{ + const char* pragma = 0; + + if (this->pragmas () != 0) + { + for (UTL_StrlistActiveIterator i (this->pragmas ()); + !i.is_done (); + i.next ()) + { + const char* s = i.item ()->get_string (); + + if (ACE_OS::strncmp (s, "#pragma prefix", 14) == 0) + { + pragma = s; + } + } + } + + if (pragma != 0) + { + // Skip the space and the " also... + const char* tmp = pragma + 16; + const char* end = ACE_OS::strchr (tmp, '"'); + + if (end == 0) + { + idl_global->err ()->syntax_error ( + IDL_GlobalData::PS_PragmaPrefixSyntax + ); + this->prefix_ = ACE::strnew (""); + return; + } + + int len = end - tmp; + + ACE_NEW (this->prefix_, + char[len + 1]); + + ACE_OS::strncpy (this->prefix_, + tmp, + len); + + this->prefix_[len] = 0; + return; + } + + // Could not find it in the local scope, try to recurse to the top + // scope... + if (this->defined_in () == 0) + { + this->prefix_ = ACE::strnew (""); + } + else + { + UTL_Scope *scope = this->defined_in (); + + if (scope == 0) + { + this->prefix_ = ACE::strnew (""); + } + else + { + AST_Decl *d = ScopeAsDecl (scope); + + if (d != 0) + { + this->prefix_ = ACE::strnew (d->prefix ()); + } + else + { + this->prefix_ = ACE::strnew (""); + } + } + } +} + +// Protected operations. + +// Compute stringified fully scoped name. +void +AST_Decl::compute_full_name (void) +{ + if (this->full_name_ != 0) + { + return; + } + else + { + long namelen = 0; + UTL_IdListActiveIterator *i = 0; + long first = I_TRUE; + long second = I_FALSE; + + // In the first loop, compute the total length. + ACE_NEW (i, + UTL_IdListActiveIterator (this->name ())); + + while (!i->is_done ()) + { + if (!first) + { + namelen += 2; // for "::" + } + else if (second) + { + first = second = I_FALSE; + } + + // Print the identifier. + namelen += ACE_OS::strlen (i->item ()->get_string ()); + + if (first) + { + if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + { + // Does not start with a "". + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } + + i->next (); + } + + delete i; + + ACE_NEW (this->full_name_, + char[namelen + 1]); + + this->full_name_[0] = '\0'; + first = I_TRUE; + second = I_FALSE; + + ACE_NEW (i, + UTL_IdListActiveIterator (this->name ())); + + while (!(i->is_done ())) + { + if (!first) + { + ACE_OS::strcat (this->full_name_, "::"); + } + else if (second) + { + first = second = I_FALSE; + } + + // Print the identifier. + ACE_OS::strcat (this->full_name_, i->item ()->get_string ()); + + if (first) + { + if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + { + // Does not start with a "". + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } + + i->next (); + } + + delete i; + } + + return; +} + +// Compute stringified repository ID. +void +AST_Decl::compute_repoID (void) +{ + if (this->repoID_ != 0) + { + return; + } + else + { + long namelen = 8; // for the prefix "IDL:" and suffix ":1.0" + UTL_IdListActiveIterator *i = 0; + long first = I_TRUE; + long second = I_FALSE; + + // in the first loop compute the total length + namelen += ACE_OS::strlen (this->prefix ()) + 1; + + ACE_NEW (i, + UTL_IdListActiveIterator (this->name ())); + + while (!(i->is_done ())) + { + if (!first) + { + namelen += 1; // for "/" + } + else if (second) + { + first = second = I_FALSE; + } + + // Print the identifier. + namelen += ACE_OS::strlen (i->item ()->get_string ()); + + if (first) + { + if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + { + // Does not start with a "". + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } + + i->next (); + } + + delete i; + + ACE_NEW (this->repoID_, + char[namelen + 1]); + + this->repoID_[0] = '\0'; + + ACE_OS::sprintf (this->repoID_, + "%s", + "IDL:"); + + ACE_OS::strcat (this->repoID_, + this->prefix ()); + + // Add the "/" only if there is a prefix. + if (ACE_OS::strcmp (this->prefix (), "") != 0) + { + ACE_OS::strcat (this->repoID_, "/"); + } + + ACE_NEW (i, + UTL_IdListActiveIterator (this->name ())); + + first = I_TRUE; + second = I_FALSE; + + while (!(i->is_done ())) + { + if (!first) + { + ACE_OS::strcat (this->repoID_, "/"); + } + else if (second) + { + first = second = I_FALSE; + } + + // Print the identifier. + ACE_OS::strcat (this->repoID_, i->item ()->get_string ()); + + if (first) + { + if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + { + // Does not start with a "". + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } + + i->next (); + } + + delete i; + ACE_OS::strcat (this->repoID_, + ":1.0"); + } + + return; +} + +// Public operations. // Return TRUE if one of my ancestor scopes is "s" // and FALSE otherwise. @@ -261,10 +564,61 @@ AST_Decl::destroy (void) delete this->pd_original_local_name; this->pd_original_local_name = 0; + if (this->full_name_ != 0) + { + delete this->full_name_; + this->full_name_ = 0; + } + + if (this->repoID_ != 0) + { + ACE_OS::free (this->repoID_); + this->repoID_ = 0; + } + + if (this->prefix_ != 0) + { + delete this->prefix_; + this->prefix_ = 0; + } + // Pragmas will be done in IDL_GlobalData // because they're not copied. } +const char * +AST_Decl::full_name (void) +{ + if (this->full_name_ == 0) + { + compute_full_name (); + } + + return this->full_name_; +} + +const char * +AST_Decl::repoID (void) +{ + if (this->repoID_ == 0) + { + this->compute_repoID (); + } + + return this->repoID_; +} + +const char * +AST_Decl::prefix (void) +{ + if (this->prefix_ == 0) + { + this->compute_prefix (); + } + + return this->prefix_; +} + // Data accessors. idl_bool @@ -351,7 +705,6 @@ AST_Decl::name (void) return this->pd_name; } - // @@ Wherever compute_* are called, we should remember to delete them // after use. @@ -412,6 +765,7 @@ AST_Decl::compute_name (const char *prefix, if (cn != 0) { result_name = (UTL_ScopedName *) cn->copy (); + if (result_name == 0) { result_name = result_local_name; diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 2ef4ea72f65..36a3787ce24 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -62,27 +62,18 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_enum.cc - Implementation of class AST_Enum - * - * AST_Enum nodes denote IDL enum declarations. - * AST_Enums are a subclass of AST_ConcreteType and UTL_Scope. - * They have a counter denoting the next value to be assigned to - * an enumerator, and a name (a UTL_ScopedName). - */ - -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_enum, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Enum::AST_Enum() - : pd_enum_counter(0) +// Constructor(s) and destructor, + +AST_Enum::AST_Enum (void) + : pd_enum_counter (0), + member_count_ (-1) { } @@ -90,10 +81,14 @@ AST_Enum::AST_Enum (UTL_ScopedName *n, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl(AST_Decl::NT_enum, n, p), - UTL_Scope(AST_Decl::NT_enum), - COMMON_Base (local, abstract), - pd_enum_counter(0) + : AST_Decl (AST_Decl::NT_enum, + n, + p), + UTL_Scope (AST_Decl::NT_enum), + COMMON_Base (local, + abstract), + pd_enum_counter (0), + member_count_ (-1) { } @@ -101,164 +96,235 @@ AST_Enum::~AST_Enum (void) { } -/* - * Private operations - */ +// Private operations. -/* - * Public operations - */ +// Return the member count. +int +AST_Enum::member_count (void) +{ + if (this->member_count_ == -1) + { + this->compute_member_count (); + } -/* - * Look up an enumerator by the value of the supplied expression - */ + return this->member_count_; +} + +// Public operations. + +// Compute total number of members. +int +AST_Enum::compute_member_count (void) +{ + UTL_ScopeActiveIterator *si = 0; + + this->member_count_ = 0; + + // 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. + this->member_count_++; + si->next (); + } + + delete si; + } + + return 0; +} + +// Look up an enumerator by the value of the supplied expression. AST_EnumVal * -AST_Enum::lookup_by_value(const AST_Expression *v) +AST_Enum::lookup_by_value (const AST_Expression *v) { - UTL_ScopeActiveIterator *iter; - AST_EnumVal *item; - AST_Decl *i; - - iter = new UTL_ScopeActiveIterator(this, IK_decls); - - while (!iter->is_done()) { - i = iter->item(); - item = AST_EnumVal::narrow_from_decl(i); - if (item->constant_value() == v) { - delete iter; - return item; + AST_EnumVal *item = 0; + AST_Decl *i = 0; + + UTL_ScopeActiveIterator *iter = 0; + ACE_NEW_RETURN (iter, + UTL_ScopeActiveIterator (this, + IK_decls), + 0); + + while (!iter->is_done ()) + { + i = iter->item (); + item = AST_EnumVal::narrow_from_decl (i); + + if (item->constant_value () == v) + { + delete iter; + return item; + } + + iter->next (); } - iter->next(); - } + delete iter; - return NULL; + return 0; } -/* - * Compute the value to be assigned to the next enumerator. Bump the - * counter - */ +// Compute the value to be assigned to the next enumerator. Bump the +// counter. unsigned long -AST_Enum::next_enum_val() +AST_Enum::next_enum_val (void) { unsigned long i = pd_enum_counter++; return i; } -/* - * Static helper functions - */ +// Static helper functions -/* - * Modify scoped name of an enumval so that it is scoped inside the scope - * in which the enum is defined and not inside the enum itself - */ +// Modify scoped name of an enumval so that it is scoped inside the scope +// in which the enum is defined and not inside the enum itself static UTL_ScopedName * -munge_name_for_enumval(UTL_ScopedName *n, Identifier *last_component) +munge_name_for_enumval (UTL_ScopedName *n, + Identifier *last_component) { - long l = n->length(); - UTL_ScopedName *hold = n; - - /* - * last three components are: - * - scope in which enum is defined - * - scope for enum - * - name of enumval - * - * We want to stop cdr'ing down the list when the head of the - * list is at the name for the scope in which the enum is defined - */ - while (l > 3) { - l--; - n = (UTL_ScopedName *) n->tail(); - } - - n->set_tail(new UTL_IdList(last_component, NULL)); + long len = n->length (); + UTL_ScopedName *hold = n; + + // Last three components are: + // - scope in which enum is defined + // - scope for enum + // - name of enumval + + // We want to stop cdr'ing down the list when the head of the + // list is at the name for the scope in which the enum is defined. + while (len > 3) + { + len--; + n = (UTL_ScopedName *) n->tail (); + } + + UTL_IdList *id = 0; + ACE_NEW_RETURN (id, + UTL_IdList (last_component, + 0), + 0); + + n->set_tail (id); return hold; } -/* - * Redefinition of inherited virtual operations - */ +// Redefinition of inherited virtual operations. -/* - * Add an AST_EnumVal node to this scope - */ -AST_EnumVal *AST_Enum::fe_add_enum_val(AST_EnumVal *t) +// Add an AST_EnumVal node to this scope +AST_EnumVal * +AST_Enum::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; - AST_EnumVal *t1 = NULL; - - if (t != NULL) { - t1 = idl_global->gen()->create_enum_val - (t->constant_value()->coerce(AST_Expression::EV_ulong)->u.ulval, - t->name(), t->pragmas()); - t->set_name(munge_name_for_enumval(t->name(), t->local_name())); - t1->set_name(munge_name_for_enumval(t1->name(), t1->local_name())); - } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + AST_Decl *d = 0; + AST_EnumVal *t1 = 0; + + if (t != 0) + { + unsigned long tmp = + t->constant_value ()->coerce (AST_Expression::EV_ulong)->u.ulval; + + t1 = idl_global->gen ()->create_enum_val (tmp, + t->name (), + t->pragmas ()); + + t->set_name (munge_name_for_enumval (t->name (), + t->local_name ())); + + t1->set_name (munge_name_for_enumval (t1->name (), + t1->local_name ())); } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); - /* - * Add it to enclosing scope - */ - idl_global->scopes()->next_to_top()->fe_add_enum_val(t1); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); + + // Add it to enclosing scope. + idl_global->scopes ()->next_to_top ()->fe_add_enum_val (t1); return t; } -/* - * Dump this AST_Enum to the ostream o - */ +// Dump this AST_Enum to the ostream o void -AST_Enum::dump(ostream &o) +AST_Enum::dump (ostream &o) { - UTL_ScopeActiveIterator *i = new UTL_ScopeActiveIterator(this, IK_decls); - AST_Decl *d; + UTL_ScopeActiveIterator *i = 0; + ACE_NEW (i, + UTL_ScopeActiveIterator (this, + IK_decls)); + + AST_Decl *d = 0; if (this->is_local ()) - o << "(local) "; + { + o << "(local) "; + } else if (this->is_abstract ()) - o << "(abstract) "; + { + o << "(abstract) "; + } o << "enum "; - local_name()->dump(o); + this->local_name ()->dump (o); o << " {\n"; - while (!(i->is_done())) { - d = i->item(); - d->local_name()->dump(o); - i->next(); - if (!(i->is_done())) - o << ", "; - } + while (!i->is_done ()) + { + d = i->item (); + d->local_name()->dump (o); + i->next (); + + if (!i->is_done()) + { + o << ", "; + } + } + delete i; - idl_global->indent()->skip_to(o); + idl_global->indent ()->skip_to (o); o << "}"; } @@ -267,9 +333,8 @@ AST_Enum::destroy (void) { } -/* - * Narrowing methods - */ + +// Narrowing methods IMPL_NARROW_METHODS2(AST_Enum, AST_ConcreteType, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Enum) IMPL_NARROW_FROM_SCOPE(AST_Enum) diff --git a/TAO/TAO_IDL/ast/ast_enum_val.cpp b/TAO/TAO_IDL/ast/ast_enum_val.cpp index 5b41e2cedf3..862b3c25ccc 100644 --- a/TAO/TAO_IDL/ast/ast_enum_val.cpp +++ b/TAO/TAO_IDL/ast/ast_enum_val.cpp @@ -62,33 +62,33 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_enum_val.cc - Implementation of class AST_EnumVal - * - * AST_EnumVals denote IDL enumerator declarations - * AST_EnumVals are a subclass of AST_Constant - * AST_EnumVals have no additional fields - */ +// AST_EnumVals denote IDL enumerator declarations +// AST_EnumVals are a subclass of AST_Constant +// AST_EnumVals have no additional fields. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_enum_val, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_EnumVal::AST_EnumVal() +// Constructor(s) and destructor. +AST_EnumVal::AST_EnumVal (void) { } -AST_EnumVal::AST_EnumVal(unsigned long v, UTL_ScopedName *n, UTL_StrList *p) - : AST_Constant(AST_Expression::EV_ulong, - AST_Decl::NT_enum_val, - new AST_Expression(v), n, p), - AST_Decl(AST_Decl::NT_enum_val, n, p) +AST_EnumVal::AST_EnumVal (unsigned long v, + UTL_ScopedName *n, + UTL_StrList *p) + : AST_Constant (AST_Expression::EV_ulong, + AST_Decl::NT_enum_val, + new AST_Expression (v), + n, + p), + AST_Decl (AST_Decl::NT_enum_val, + n, + p) { } @@ -96,30 +96,15 @@ AST_EnumVal::~AST_EnumVal (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ - - -/* - * Redefinition of inherited virtual operations - */ +// Redefinition of inherited virtual operations. -/* - * Dump this AST_EnumVal to the ostream o - */ +// Dump this AST_EnumVal to the ostream o. void -AST_EnumVal::dump(ostream &o) +AST_EnumVal::dump (ostream &o) { - AST_Constant::dump(o); + AST_Constant::dump (o); } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_EnumVal, AST_Constant) IMPL_NARROW_FROM_DECL(AST_EnumVal) diff --git a/TAO/TAO_IDL/ast/ast_exception.cpp b/TAO/TAO_IDL/ast/ast_exception.cpp index f9718c41e90..6b32011f401 100644 --- a/TAO/TAO_IDL/ast/ast_exception.cpp +++ b/TAO/TAO_IDL/ast/ast_exception.cpp @@ -62,25 +62,19 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_exception.cc - Implementation of class AST_Exception - * - * AST_Exceptions denote IDL exception declarations - * AST_Exceptions are a subclass of AST_Decl (they are not types!) - * and of UTL_Scope - */ +// AST_Exceptions denote IDL exception declarations +// AST_Exceptions are a subclass of AST_Decl (they are not types!) +// and of UTL_Scope. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_exception, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Exception::AST_Exception() +// Constructor(s) and destructor. +AST_Exception::AST_Exception (void) { } @@ -88,8 +82,13 @@ AST_Exception::AST_Exception(UTL_ScopedName *n, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Structure(AST_Decl::NT_except, n, p, local, abstract), - COMMON_Base (local, abstract) + : AST_Structure (AST_Decl::NT_except, + n, + p, + local, + abstract), + COMMON_Base (local, + abstract) { } @@ -97,220 +96,322 @@ AST_Exception::~AST_Exception (void) { } -/* - * Private operations - */ +// Public operations. -/* - * Public operations - */ +// Are we or the parameter node involved in any recursion? +idl_bool +AST_Exception::in_recursion (AST_Type *node) +{ + if (node == 0) + { + // We are determining the recursive status for ourselves. + node = this; + } + // Proceed if the number of members in our scope is greater than 0. + if (this->nmembers () > 0) + { + // Initialize an iterator to iterate thru our scope. + UTL_ScopeActiveIterator *si = 0; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + -1); + // Continue until each element is visited. + while (!si->is_done ()) + { + AST_Field *field = + AST_Field::narrow_from_decl (si->item ()); + + if (field == 0) + { + delete si; + + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Exception::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad field node\n")), + 0); + } + + AST_Type *type = + AST_Type::narrow_from_decl (field->field_type ()); + + if (type == 0) + { + delete si; + + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Exception::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad field type\n")), + 0); + } + + if (type->in_recursion (node)) + { + delete si; + return 1; + } + + si->next (); + } + + delete si; + } + + // Not in recursion + return 0; +} -/* - * Redefinition of inherited virtual operations - */ +// Private operations. -/* - * Add this AST_Field node to the current scope - */ -AST_Field *AST_Exception::fe_add_field(AST_Field *t) +// Add this AST_Field node to the current scope. +AST_Field * +AST_Exception::fe_add_field (AST_Field *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; - } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Union (manifest type declaration) to the current scope - */ -AST_Union *AST_Exception::fe_add_union(AST_Union *t) +// Add this AST_Union (manifest type declaration) to the current scope. +AST_Union * +AST_Exception::fe_add_union (AST_Union *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; - } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to local types. + this->add_to_local_types (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Structure (manifest type declaration) to the current - * scope - */ -AST_Structure *AST_Exception::fe_add_structure(AST_Structure *t) +// Add this AST_Structure (manifest type declaration) to the current +// scope. +AST_Structure * +AST_Exception::fe_add_structure (AST_Structure *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error2(UTL_Error::EIDL_REDEF, t, this); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error2 (UTL_Error::EIDL_REDEF, + t, + this); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; - } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to local types. + this->add_to_local_types (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Enum (manifest type declaration) to the current scope - */ -AST_Enum *AST_Exception::fe_add_enum(AST_Enum *t) +// Add this AST_Enum (manifest type declaration) to the current scope. +AST_Enum * +AST_Exception::fe_add_enum (AST_Enum *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to local types. + this->add_to_local_types (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_EnumVal (enumerator declaration) to the current scope. - * This is done to conform to the C++ scoping rules which declare - * enumerators in the enclosing scope (in addition to declaring them - * in the enum itself) - */ -AST_EnumVal *AST_Exception::fe_add_enum_val(AST_EnumVal *t) +// Add this AST_EnumVal (enumerator declaration) to the current scope. +// This is done to conform to the C++ scoping rules which declare +// enumerators in the enclosing scope (in addition to declaring them +// in the enum itself). +AST_EnumVal * +AST_Exception::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; - } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Exception node to the ostream o - */ +// Dump this AST_Exception node to the ostream o. void -AST_Exception::dump(ostream &o) +AST_Exception::dump (ostream &o) { o << "exception "; - local_name()->dump(o); + this->local_name ()->dump (o); o << " {\n"; - UTL_Scope::dump(o); - idl_global->indent()->skip_to(o); + UTL_Scope::dump (o); + idl_global->indent ()->skip_to (o); o << "}"; } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_Exception, AST_Structure) IMPL_NARROW_FROM_DECL(AST_Exception) IMPL_NARROW_FROM_SCOPE(AST_Exception) diff --git a/TAO/TAO_IDL/ast/ast_expression.cpp b/TAO/TAO_IDL/ast/ast_expression.cpp index 913dbefa78f..4819b86837e 100644 --- a/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/TAO/TAO_IDL/ast/ast_expression.cpp @@ -62,1275 +62,1492 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* * ast_expression.cc - Implementation of class AST_Expression - * - * AST_Expression nodes denote IDL expressions used in the IDL input. - */ +// AST_Expression nodes denote IDL expressions used in the IDL input. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_expression, "$Id$") // Helper function to fill out the details of where this expression -// is defined +// is defined. void -AST_Expression::fill_definition_details() +AST_Expression::fill_definition_details (void) { - pd_defined_in = idl_global->scopes()->depth() > 0 - ? idl_global->scopes()->top() - : 0 ; - pd_line = idl_global->lineno(); - pd_file_name = idl_global->filename(); + this->pd_defined_in = idl_global->scopes()->depth() > 0 + ? idl_global->scopes()->top() + : 0 ; + this->pd_line = idl_global->lineno (); + this->pd_file_name = idl_global->filename (); } -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. -/* - * An AST_Expression denoting a symbolic name - */ +// An AST_Expression denoting a symbolic name. AST_Expression::AST_Expression (UTL_ScopedName *nm) : pd_ec (EC_symbol), - pd_ev (NULL), - pd_v1 (NULL), - pd_v2 (NULL), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), pd_n (nm) { - fill_definition_details (); + this->fill_definition_details (); } -/* - * An AST_Expression denoting a type coercion from another AST_Expression - */ +// An AST_Expression denoting a type coercion from another AST_Expression. AST_Expression::AST_Expression (AST_Expression *v, ExprType t) : pd_ec (EC_none), - pd_ev (NULL), - pd_v1 (NULL), - pd_v2 (NULL), - pd_n (NULL) + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details (); + this->fill_definition_details (); - pd_ev = v->coerce (t); - if (pd_ev == NULL) - idl_global->err ()->coercion_error (v, t); + this->pd_ev = v->coerce (t); + + if (this->pd_ev == 0) + { + idl_global->err ()->coercion_error (v, + t); + } } -/* - * An AST_Expression denoting a binary expression combination from - * two other AST_Expressions - */ +// An AST_Expression denoting a binary expression combination from +// two other AST_Expressions. AST_Expression::AST_Expression (ExprComb c, AST_Expression *ev1, AST_Expression *ev2) : pd_ec (c), - pd_ev (NULL), + pd_ev (0), pd_v1 (ev1), pd_v2 (ev2), - pd_n (NULL) + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); } -/* - * An AST_Expression denoting a short integer - */ -AST_Expression::AST_Expression(short sv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a short integer. +AST_Expression::AST_Expression (short sv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_short; - pd_ev->u.sval = sv; + ACE_NEW (this->pd_ev, + AST_ExprValue); + + this->pd_ev->et = EV_short; + this->pd_ev->u.sval = sv; } -/* - * An AST_Expression denoting an unsigned short integer - */ -AST_Expression::AST_Expression(unsigned short usv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting an unsigned short integer. +AST_Expression::AST_Expression (unsigned short usv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_ushort; - pd_ev->u.usval = usv; + this->pd_ev->et = EV_ushort; + this->pd_ev->u.usval = usv; } -/* - * An AST_Expression denoting a long integer - */ -AST_Expression::AST_Expression(long lv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a long integer. +AST_Expression::AST_Expression (long lv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_long; - pd_ev->u.lval = lv; + this->pd_ev->et = EV_long; + this->pd_ev->u.lval = lv; } -/* - * An AST_Expression denoting a long integer being used as a boolean - */ -AST_Expression::AST_Expression(long lv, ExprType t) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a long integer being used as a boolean. +AST_Expression::AST_Expression (long lv, + ExprType t) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = t; - pd_ev->u.lval = lv; + this->pd_ev->et = EV_long; + this->pd_ev->et = t; + this->pd_ev->u.lval = lv; } -/* - * An AST_Expression denoting an unsigned long integer - */ -AST_Expression::AST_Expression(unsigned long ulv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting an unsigned long integer. +AST_Expression::AST_Expression (unsigned long ulv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (NULL) { - fill_definition_details(); + this->fill_definition_details (); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_ulong; - pd_ev->u.ulval = ulv; + ACE_NEW (this->pd_ev, + AST_ExprValue); + + this->pd_ev->et = EV_ulong; + this->pd_ev->u.ulval = ulv; } -/* - * An AST_Expression denoting a 32-bit floating point number - */ -AST_Expression::AST_Expression(float fv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a 32-bit floating point number. +AST_Expression::AST_Expression (float fv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_float; - pd_ev->u.fval = fv; + ACE_NEW (this->pd_ev, + AST_ExprValue); + + this->pd_ev->et = EV_float; + this->pd_ev->u.fval = fv; } -/* - * An AST_Expression denoting a 64-bit floating point number - */ -AST_Expression::AST_Expression(double dv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a 64-bit floating point number. +AST_Expression::AST_Expression (double dv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (NULL), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_double; - pd_ev->u.dval = dv; + this->pd_ev->et = EV_double; + this->pd_ev->u.dval = dv; } -/* - * An AST_Expression denoting a character - */ -AST_Expression::AST_Expression(char cv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a character. +AST_Expression::AST_Expression (char cv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_char; - pd_ev->u.cval = cv; + this->pd_ev->et = EV_char; + this->pd_ev->u.cval = cv; } -/* - * An AST_Expression denoting a wide character - */ -AST_Expression::AST_Expression(ACE_OutputCDR::from_wchar wcv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a wide character. +AST_Expression::AST_Expression (ACE_OutputCDR::from_wchar wcv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_wchar; - pd_ev->u.wcval = wcv.val_; + this->pd_ev->et = EV_wchar; + this->pd_ev->u.wcval = wcv.val_; } -/* - * An AST_Expression denoting an octet (unsigned char) - */ -AST_Expression::AST_Expression(unsigned char ov) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting an octet (unsigned char). +AST_Expression::AST_Expression (unsigned char ov) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (NULL) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_octet; - pd_ev->u.oval = ov; + this->pd_ev->et = EV_octet; + this->pd_ev->u.oval = ov; } -/* - * An AST_Expression denoting a string (char * encapsulated as a String) - */ -AST_Expression::AST_Expression(UTL_String *sv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a string (char * encapsulated as a String). +AST_Expression::AST_Expression (UTL_String *sv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); + + ACE_NEW (this->pd_ev, + AST_ExprValue); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_string; - pd_ev->u.strval = sv; + this->pd_ev->et = EV_string; + this->pd_ev->u.strval = sv; } -/* - * An AST_Expression denoting a wide string - */ -AST_Expression::AST_Expression(char *sv) - : pd_ec(EC_none), - pd_ev(NULL), - pd_v1(NULL), - pd_v2(NULL), - pd_n(NULL) +// An AST_Expression denoting a wide string. +AST_Expression::AST_Expression (char *sv) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { - fill_definition_details(); + this->fill_definition_details (); - pd_ev = new AST_ExprValue; - pd_ev->et = EV_wstring; - pd_ev->u.wstrval = sv; + ACE_NEW (this->pd_ev, + AST_ExprValue); + + this->pd_ev->et = EV_wstring; + this->pd_ev->u.wstrval = sv; } AST_Expression::~AST_Expression (void) { } -/* - * Static operations - */ +// Static operations. -/* - * Perform the coercion from the given AST_ExprValue to the requested - * ExprType. Return an AST_ExprValue if successful, NULL if failed. - */ +// Perform the coercion from the given AST_ExprValue to the requested +// ExprType. Return an AST_ExprValue if successful, 0 if failed. static AST_Expression::AST_ExprValue * -coerce_value(AST_Expression::AST_ExprValue *ev, AST_Expression::ExprType t) +coerce_value (AST_Expression::AST_ExprValue *ev, + AST_Expression::ExprType t) { - if (ev == NULL) - return NULL; + if (ev == 0) + { + return 0; + } - switch (t) { - case AST_Expression::EV_short: - switch (ev->et) { + switch (t) + { case AST_Expression::EV_short: - return ev; - case AST_Expression::EV_ushort: - if (ev->u.usval > (unsigned short) ACE_INT16_MAX) - return NULL; - ev->u.sval = (short) ev->u.usval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval > (long) ACE_INT16_MAX - || ev->u.lval < (long) ACE_INT16_MIN) - return NULL; - ev->u.sval = (short) ev->u.lval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > (unsigned long) ACE_INT16_MAX) - return NULL; - ev->u.sval = (short) ev->u.ulval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + return ev; + case AST_Expression::EV_ushort: + if (ev->u.usval > (unsigned short) ACE_INT16_MAX) + { + return 0; + } + + ev->u.sval = (short) ev->u.usval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval > (long) ACE_INT16_MAX + || ev->u.lval < (long) ACE_INT16_MIN) + { + return 0; + } + + ev->u.sval = (short) ev->u.lval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > (unsigned long) ACE_INT16_MAX) + { + return 0; + } + + ev->u.sval = (short) ev->u.ulval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_INT16_MAX - || ev->u.llval < (ACE_CDR::LongLong) ACE_INT16_MIN) - return NULL; - ev->u.sval = (short) ev->u.llval; - ev->et = AST_Expression::EV_short; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_INT16_MAX + || ev->u.llval < (ACE_CDR::LongLong) ACE_INT16_MIN) + { + return 0; + } + + ev->u.sval = (short) ev->u.llval; + ev->et = AST_Expression::EV_short; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_INT16_MAX) - return NULL; - ev->u.sval = (short) ev->u.ullval; - ev->et = AST_Expression::EV_short; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_INT16_MAX) + { + return 0; + } + + ev->u.sval = (short) ev->u.ullval; + ev->et = AST_Expression::EV_short; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.sval = (short) ev->u.bval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval > (float) ACE_INT16_MAX - || ev->u.fval < (float) ACE_INT16_MIN) - return NULL; - ev->u.sval = (short) ev->u.fval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval > (double) ACE_INT16_MAX - || ev->u.dval < (double) ACE_INT16_MIN) - return NULL; - ev->u.sval = (short) ev->u.dval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_char: - ev->u.sval = (short) ev->u.cval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_wchar: - if (ev->u.wcval > (ACE_CDR::WChar) ACE_INT16_MAX) - return NULL; - ev->u.sval = (short) ev->u.wcval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_octet: - ev->u.sval = (short) ev->u.oval; - ev->et = AST_Expression::EV_short; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_string: - case AST_Expression::EV_wstring: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_ushort: - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval < 0) - return NULL; - ev->u.usval = (unsigned short) ev->u.sval; - ev->et = AST_Expression::EV_ushort; - return ev; + case AST_Expression::EV_bool: + ev->u.sval = (short) ev->u.bval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval > (float) ACE_INT16_MAX + || ev->u.fval < (float) ACE_INT16_MIN) + { + return 0; + } + + ev->u.sval = (short) ev->u.fval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > (double) ACE_INT16_MAX + || ev->u.dval < (double) ACE_INT16_MIN) + { + return 0; + } + + ev->u.sval = (short) ev->u.dval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_char: + ev->u.sval = (short) ev->u.cval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_wchar: + if (ev->u.wcval > (ACE_CDR::WChar) ACE_INT16_MAX) + { + return 0; + } + + ev->u.sval = (short) ev->u.wcval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_octet: + ev->u.sval = (short) ev->u.oval; + ev->et = AST_Expression::EV_short; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_string: + case AST_Expression::EV_wstring: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_ushort: - return ev; - case AST_Expression::EV_long: - if (ev->u.lval > (long) ACE_UINT16_MAX - || ev->u.lval < 0) - return NULL; - ev->u.usval = (unsigned short) ev->u.lval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > (unsigned long) ACE_UINT16_MAX) - return NULL; - ev->u.usval = (unsigned short) ev->u.ulval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval < 0) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.sval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_ushort: + return ev; + case AST_Expression::EV_long: + if (ev->u.lval > (long) ACE_UINT16_MAX + || ev->u.lval < 0) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.lval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > (unsigned long) ACE_UINT16_MAX) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.ulval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_UINT16_MAX - || ev->u.llval < 0) - return NULL; - ev->u.usval = (unsigned short) ev->u.llval; - ev->et = AST_Expression::EV_ushort; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_UINT16_MAX + || ev->u.llval < 0) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.llval; + ev->et = AST_Expression::EV_ushort; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_UINT16_MAX) - return NULL; - ev->u.usval = (unsigned short) ev->u.ullval; - ev->et = AST_Expression::EV_ushort; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_UINT16_MAX) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.ullval; + ev->et = AST_Expression::EV_ushort; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.usval = (unsigned short) ev->u.bval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval < 0.0 - || ev->u.fval > (float) ACE_UINT16_MAX) - return NULL; - ev->u.usval = (unsigned short) ev->u.fval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval < 0.0 - || ev->u.dval > (double) ACE_UINT16_MAX) - return NULL; - ev->u.usval = (unsigned short) ev->u.dval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_char: - if ((signed char) ev->u.cval < 0) - return NULL; - ev->u.usval = (unsigned short) ev->u.cval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_wchar: - ev->u.usval = (unsigned short) ev->u.wcval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_octet: - ev->u.usval = (unsigned short) ev->u.oval; - ev->et = AST_Expression::EV_ushort; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_long: - switch (ev->et) { - case AST_Expression::EV_short: - ev->u.lval = (long) ev->u.sval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_ushort: - ev->u.lval = (long) ev->u.usval; - ev->et = AST_Expression::EV_long; - return ev; + case AST_Expression::EV_bool: + ev->u.usval = (unsigned short) ev->u.bval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval < 0.0 + || ev->u.fval > (float) ACE_UINT16_MAX) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.fval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval < 0.0 + || ev->u.dval > (double) ACE_UINT16_MAX) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.dval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_char: + if ((signed char) ev->u.cval < 0) + { + return 0; + } + + ev->u.usval = (unsigned short) ev->u.cval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_wchar: + ev->u.usval = (unsigned short) ev->u.wcval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_octet: + ev->u.usval = (unsigned short) ev->u.oval; + ev->et = AST_Expression::EV_ushort; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_long: - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > (unsigned long) ACE_INT32_MAX) - return NULL; - ev->u.lval = (long) ev->u.ulval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + ev->u.lval = (long) ev->u.sval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_ushort: + ev->u.lval = (long) ev->u.usval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_long: + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > (unsigned long) ACE_INT32_MAX) + { + return 0; + } + + ev->u.lval = (long) ev->u.ulval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_INT32_MAX - || ev->u.llval < (ACE_CDR::LongLong) ACE_INT32_MIN) - return NULL; - ev->u.lval = (long) ev->u.llval; - ev->et = AST_Expression::EV_long; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_INT32_MAX + || ev->u.llval < (ACE_CDR::LongLong) ACE_INT32_MIN) + { + return 0; + } + ev->u.lval = (long) ev->u.llval; + ev->et = AST_Expression::EV_long; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_INT32_MAX) - return NULL; - ev->u.lval = (long) ev->u.ullval; - ev->et = AST_Expression::EV_long; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_INT32_MAX) + { + return 0; + } + + ev->u.lval = (long) ev->u.ullval; + ev->et = AST_Expression::EV_long; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.lval = (long) ev->u.bval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval > (float) LONG_MAX - || ev->u.fval < (float) ACE_INT32_MIN) - return NULL; - ev->u.lval = (long) ev->u.fval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval > (double) LONG_MAX - || ev->u.dval < (double) ACE_INT32_MIN) - return NULL; - ev->u.lval = (long) ev->u.dval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_char: - ev->u.lval = (long) ev->u.cval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_wchar: - ev->u.lval = (long) ev->u.wcval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_octet: - ev->u.lval = (long) ev->u.oval; - ev->et = AST_Expression::EV_long; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_ulong: - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval < 0) - return NULL; - ev->u.ulval = (unsigned long) ev->u.sval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_ushort: - ev->u.ulval = (unsigned long) ev->u.usval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval < 0) - return NULL; - ev->u.ulval = (unsigned long) ev->u.lval; - ev->et = AST_Expression::EV_ulong; - return ev; + case AST_Expression::EV_bool: + ev->u.lval = (long) ev->u.bval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval > (float) LONG_MAX + || ev->u.fval < (float) ACE_INT32_MIN) + { + return 0; + } + + ev->u.lval = (long) ev->u.fval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > (double) LONG_MAX + || ev->u.dval < (double) ACE_INT32_MIN) + { + return 0; + } + + ev->u.lval = (long) ev->u.dval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_char: + ev->u.lval = (long) ev->u.cval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_wchar: + ev->u.lval = (long) ev->u.wcval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_octet: + ev->u.lval = (long) ev->u.oval; + ev->et = AST_Expression::EV_long; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_ulong: - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval < 0) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.sval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_ushort: + ev->u.ulval = (unsigned long) ev->u.usval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval < 0) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.lval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_ulong: + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_UINT32_MAX - || ev->u.llval < 0) - return NULL; - ev->u.ulval = (unsigned long) ev->u.llval; - ev->et = AST_Expression::EV_ulong; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_UINT32_MAX + || ev->u.llval < 0) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.llval; + ev->et = AST_Expression::EV_ulong; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return NULL; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_UINT32_MAX) - return NULL; - ev->u.ulval = (unsigned long) ev->u.ullval; - ev->et = AST_Expression::EV_ulong; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_UINT32_MAX) + { + return 0; + } + ev->u.ulval = (unsigned long) ev->u.ullval; + ev->et = AST_Expression::EV_ulong; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.ulval = (unsigned long) ev->u.bval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval < 0.0 - || ev->u.fval > (float) ACE_UINT32_MAX) - return NULL; - ev->u.ulval = (unsigned long) ev->u.fval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval < 0.0 - || ev->u.dval > (double) ACE_UINT32_MAX) - return NULL; - ev->u.ulval = (unsigned long) ev->u.dval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_char: - if ((signed char) ev->u.cval < 0) - return NULL; - ev->u.ulval = (unsigned long) ev->u.cval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_wchar: - ev->u.ulval = (unsigned long) ev->u.wcval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_octet: - ev->u.ulval = (unsigned long) ev->u.oval; - ev->et = AST_Expression::EV_ulong; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_longlong: -#if ! defined (ACE_LACKS_LONGLONG_T) - switch (ev->et) { - case AST_Expression::EV_short: - ev->u.llval = (ACE_CDR::LongLong) ev->u.sval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_ushort: - ev->u.llval = (ACE_CDR::LongLong) ev->u.usval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_long: - ev->u.llval = (ACE_CDR::LongLong) ev->u.lval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_ulong: - ev->u.llval = (ACE_CDR::LongLong) ev->u.ulval; - ev->et = AST_Expression::EV_longlong; - return ev; + case AST_Expression::EV_bool: + ev->u.ulval = (unsigned long) ev->u.bval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval < 0.0 + || ev->u.fval > (float) ACE_UINT32_MAX) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.fval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval < 0.0 + || ev->u.dval > (double) ACE_UINT32_MAX) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.dval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_char: + if ((signed char) ev->u.cval < 0) + { + return 0; + } + + ev->u.ulval = (unsigned long) ev->u.cval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_wchar: + ev->u.ulval = (unsigned long) ev->u.wcval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_octet: + ev->u.ulval = (unsigned long) ev->u.oval; + ev->et = AST_Expression::EV_ulong; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_longlong: - return ev; - case AST_Expression::EV_ulonglong: - if (ev->u.ullval > ACE_INT64_MAX) - return NULL; - ev->u.llval = (ACE_CDR::LongLong) ev->u.ullval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_bool: - ev->u.llval = (ACE_CDR::LongLong) ev->u.bval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval > (float) ACE_INT64_MAX - || ev->u.fval < (float) ACE_INT64_MIN) - return NULL; - ev->u.llval = (ACE_CDR::LongLong) ev->u.fval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval > (double) ACE_INT64_MAX - || ev->u.dval < (double) ACE_INT64_MIN) - return NULL; - ev->u.llval = (ACE_CDR::LongLong) ev->u.dval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_char: - ev->u.llval = (ACE_CDR::LongLong) ev->u.cval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_wchar: - ev->u.llval = (ACE_CDR::LongLong) ev->u.wcval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_octet: - ev->u.llval = (ACE_CDR::LongLong) ev->u.oval; - ev->et = AST_Expression::EV_longlong; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } +#if ! defined (ACE_LACKS_LONGLONG_T) + switch (ev->et) + { + case AST_Expression::EV_short: + ev->u.llval = (ACE_CDR::LongLong) ev->u.sval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_ushort: + ev->u.llval = (ACE_CDR::LongLong) ev->u.usval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_long: + ev->u.llval = (ACE_CDR::LongLong) ev->u.lval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_ulong: + ev->u.llval = (ACE_CDR::LongLong) ev->u.ulval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_longlong: + return ev; + case AST_Expression::EV_ulonglong: + if (ev->u.ullval > ACE_INT64_MAX) + { + return 0; + } + + ev->u.llval = (ACE_CDR::LongLong) ev->u.ullval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_bool: + ev->u.llval = (ACE_CDR::LongLong) ev->u.bval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval > (float) ACE_INT64_MAX + || ev->u.fval < (float) ACE_INT64_MIN) + { + return 0; + } + + ev->u.llval = (ACE_CDR::LongLong) ev->u.fval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > (double) ACE_INT64_MAX + || ev->u.dval < (double) ACE_INT64_MIN) + { + return 0; + } + + ev->u.llval = (ACE_CDR::LongLong) ev->u.dval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_char: + ev->u.llval = (ACE_CDR::LongLong) ev->u.cval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_wchar: + ev->u.llval = (ACE_CDR::LongLong) ev->u.wcval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_octet: + ev->u.llval = (ACE_CDR::LongLong) ev->u.oval; + ev->et = AST_Expression::EV_longlong; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: -#if ! defined (ACE_LACKS_LONGLONG_T) - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval < 0) - return NULL; - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.sval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_ushort: - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.usval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval < 0) - return NULL; - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.lval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_ulong: - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.ulval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_longlong: - if (ev->u.llval < 0) - return NULL; - ev->u.ullval = (ACE_CDR::LongLong) ev->u.llval; - ev->et = AST_Expression::EV_ulonglong; - return ev; case AST_Expression::EV_ulonglong: - return ev; - case AST_Expression::EV_bool: - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.bval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval < 0.0 || ev->u.fval > (float) ACE_UINT64_MAX) - return NULL; - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.fval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval < 0.0 || ev->u.dval > (double) ACE_UINT64_MAX) - return NULL; - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.dval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_char: - if ((signed char) ev->u.cval < 0) - return NULL; - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.cval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_wchar: - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.wcval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_octet: - ev->u.ullval = (ACE_CDR::ULongLong) ev->u.oval; - ev->et = AST_Expression::EV_ulonglong; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } +#if ! defined (ACE_LACKS_LONGLONG_T) + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval < 0) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.sval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_ushort: + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.usval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval < 0) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.lval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_ulong: + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.ulval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_longlong: + if (ev->u.llval < 0) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::LongLong) ev->u.llval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_ulonglong: + return ev; + case AST_Expression::EV_bool: + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.bval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval < 0.0 + || ev->u.fval > (float) ACE_UINT64_MAX) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.fval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval < 0.0 + || ev->u.dval > (double) ACE_UINT64_MAX) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.dval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_char: + if ((signed char) ev->u.cval < 0) + { + return 0; + } + + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.cval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_wchar: + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.wcval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_octet: + ev->u.ullval = (ACE_CDR::ULongLong) ev->u.oval; + ev->et = AST_Expression::EV_ulonglong; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - switch (ev->et) { - case AST_Expression::EV_short: - ev->u.bval = (ev->u.sval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_ushort: - ev->u.bval = (ev->u.usval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_long: - ev->u.bval = (ev->u.lval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_ulong: - ev->u.bval = (ev->u.ulval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_longlong: + case AST_Expression::EV_bool: + switch (ev->et) + { + case AST_Expression::EV_short: + ev->u.bval = (ev->u.sval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_ushort: + ev->u.bval = (ev->u.usval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_long: + ev->u.bval = (ev->u.lval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_ulong: + ev->u.bval = (ev->u.ulval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - ev->u.bval = (ev->u.llval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; + ev->u.bval = (ev->u.llval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - ev->u.bval = (ev->u.ullval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; + ev->u.bval = (ev->u.ullval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - return ev; + case AST_Expression::EV_bool: + return ev; + case AST_Expression::EV_float: + ev->u.bval = (ev->u.fval == 0.0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_double: + ev->u.bval = (ev->u.dval == 0.0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_char: + ev->u.bval = (ev->u.cval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_wchar: + ev->u.bval = (ev->u.wcval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_octet: + ev->u.bval = (ev->u.oval == 0) ? I_FALSE : I_TRUE; + ev->et = AST_Expression::EV_bool; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_float: - ev->u.bval = (ev->u.fval == 0.0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_double: - ev->u.bval = (ev->u.dval == 0.0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_char: - ev->u.bval = (ev->u.cval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_wchar: - ev->u.bval = (ev->u.wcval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_octet: - ev->u.bval = (ev->u.oval == 0) ? I_FALSE : I_TRUE; - ev->et = AST_Expression::EV_bool; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_float: - switch (ev->et) { - case AST_Expression::EV_short: - ev->u.fval = (float) ev->u.sval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_ushort: - ev->u.fval = (float) ev->u.usval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_long: - ev->u.fval = (float) ev->u.lval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_ulong: - ev->u.fval = (float) ev->u.ulval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + ev->u.fval = (float) ev->u.sval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_ushort: + ev->u.fval = (float) ev->u.usval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_long: + ev->u.fval = (float) ev->u.lval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_ulong: + ev->u.fval = (float) ev->u.ulval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > FLT_MAX - || ev->u.llval < -(ACE_FLT_MAX)) - return NULL; - ev->u.fval = (float) ev->u.llval; - ev->et = AST_Expression::EV_float; - return ev; + if (ev->u.llval > FLT_MAX + || ev->u.llval < -(ACE_FLT_MAX)) + { + return 0; + } + ev->u.fval = (float) ev->u.llval; + ev->et = AST_Expression::EV_float; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - // Some compilers don't implement unsigned 64-bit to float conversions, - // so we are stuck with the signed 64-bit max value. - if (ev->u.ullval > ACE_UINT64_MAX - || (ACE_CDR::LongLong) ev->u.ullval > ACE_FLT_MAX) - return NULL; - ev->u.fval = (float) ((ACE_CDR::LongLong) ev->u.ullval); - ev->et = AST_Expression::EV_float; - return ev; + // Some compilers don't implement unsigned 64-bit to float conversions, + // so we are stuck with the signed 64-bit max value. + if (ev->u.ullval > ACE_UINT64_MAX + || (ACE_CDR::LongLong) ev->u.ullval > ACE_FLT_MAX) + { + return 0; + } + + ev->u.fval = (float) ((ACE_CDR::LongLong) ev->u.ullval); + ev->et = AST_Expression::EV_float; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.fval = (float) ((ev->u.bval == I_TRUE) ? 1.0 : 0.0); - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_float: - return ev; + case AST_Expression::EV_bool: + ev->u.fval = (float) ((ev->u.bval == I_TRUE) ? 1.0 : 0.0); + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_float: + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > ACE_FLT_MAX + || ev->u.dval < -(ACE_FLT_MAX)) + { + return 0; + } + + ev->u.fval = (float) ev->u.dval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_char: + ev->u.fval = (float) ev->u.cval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_wchar: + ev->u.fval = (float) ev->u.wcval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_octet: + ev->u.fval = (float) ev->u.oval; + ev->et = AST_Expression::EV_float; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_double: - if (ev->u.dval > ACE_FLT_MAX - || ev->u.dval < -(ACE_FLT_MAX)) - return NULL; - ev->u.fval = (float) ev->u.dval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_char: - ev->u.fval = (float) ev->u.cval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_wchar: - ev->u.fval = (float) ev->u.wcval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_octet: - ev->u.fval = (float) ev->u.oval; - ev->et = AST_Expression::EV_float; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_double: - switch (ev->et) { - case AST_Expression::EV_short: - ev->u.dval = (double) ev->u.sval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_ushort: - ev->u.dval = (double) ev->u.usval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_long: - ev->u.dval = (double) ev->u.lval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_ulong: - ev->u.dval = (double) ev->u.ulval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + ev->u.dval = (double) ev->u.sval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_ushort: + ev->u.dval = (double) ev->u.usval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_long: + ev->u.dval = (double) ev->u.lval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_ulong: + ev->u.dval = (double) ev->u.ulval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - ev->u.dval = (double) ev->u.llval; - ev->et = AST_Expression::EV_double; - return ev; + ev->u.dval = (double) ev->u.llval; + ev->et = AST_Expression::EV_double; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - // Some compilers don't implement unsigned 64-bit to double - // conversions, so we are stuck with the signed 64-bit max value. - if (ev->u.ullval > ACE_INT64_MAX) - return NULL; - ev->u.dval = (double) ((ACE_CDR::LongLong) ev->u.ullval); - ev->et = AST_Expression::EV_double; - return ev; + // Some compilers don't implement unsigned 64-bit to double + // conversions, so we are stuck with the signed 64-bit max value. + if (ev->u.ullval > ACE_INT64_MAX) + { + return 0; + } + + ev->u.dval = (double) ((ACE_CDR::LongLong) ev->u.ullval); + ev->et = AST_Expression::EV_double; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return NULL; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.dval = (ev->u.bval == I_TRUE) ? 1.0 : 0.0; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_float: - ev->u.dval = (double) ev->u.fval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_double: - return ev; + case AST_Expression::EV_bool: + ev->u.dval = (ev->u.bval == I_TRUE) ? 1.0 : 0.0; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_float: + ev->u.dval = (double) ev->u.fval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_double: + return ev; + case AST_Expression::EV_char: + ev->u.dval = (double) ev->u.cval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_wchar: + ev->u.dval = (double) ev->u.wcval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_octet: + ev->u.dval = (double) ev->u.oval; + ev->et = AST_Expression::EV_double; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_char: - ev->u.dval = (double) ev->u.cval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_wchar: - ev->u.dval = (double) ev->u.wcval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_octet: - ev->u.dval = (double) ev->u.oval; - ev->et = AST_Expression::EV_double; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_char: - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval > (short) ACE_CHAR_MAX - || ev->u.sval < (short) ACE_CHAR_MIN) - return NULL; - ev->u.cval = (char) ev->u.sval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_ushort: - if (ev->u.usval > (unsigned short) ACE_CHAR_MAX) - return NULL; - ev->u.cval = (char) ev->u.usval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval > (long) ACE_CHAR_MAX - || ev->u.lval < (long) ACE_CHAR_MIN) - return NULL; - ev->u.cval = (char) ev->u.lval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > (unsigned long) ACE_CHAR_MAX) - return NULL; - ev->u.cval = (char) ev->u.ulval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval > (short) ACE_CHAR_MAX + || ev->u.sval < (short) ACE_CHAR_MIN) + { + return 0; + } + + ev->u.cval = (char) ev->u.sval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_ushort: + if (ev->u.usval > (unsigned short) ACE_CHAR_MAX) + { + return 0; + } + + ev->u.cval = (char) ev->u.usval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval > (long) ACE_CHAR_MAX + || ev->u.lval < (long) ACE_CHAR_MIN) + { + return 0; + } + + ev->u.cval = (char) ev->u.lval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > (unsigned long) ACE_CHAR_MAX) + { + return 0; + } + + ev->u.cval = (char) ev->u.ulval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_CHAR_MAX - || ev->u.llval < (ACE_CDR::LongLong) ACE_CHAR_MIN) - return NULL; - ev->u.cval = (char) ev->u.llval; - ev->et = AST_Expression::EV_char; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_CHAR_MAX + || ev->u.llval < (ACE_CDR::LongLong) ACE_CHAR_MIN) + { + return 0; + } + + ev->u.cval = (char) ev->u.llval; + ev->et = AST_Expression::EV_char; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_CHAR_MAX) - return NULL; - ev->u.cval = (char) ev->u.ullval; - ev->et = AST_Expression::EV_char; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_CHAR_MAX) + { + return 0; + } + + ev->u.cval = (char) ev->u.ullval; + ev->et = AST_Expression::EV_char; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.cval = (char) ev->u.bval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval > (float) ACE_CHAR_MAX - || ev->u.fval < (float) ACE_CHAR_MIN) - return NULL; - ev->u.cval = (char) ev->u.fval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval > (double) ACE_CHAR_MAX - || ev->u.dval < (double) ACE_CHAR_MIN) - return NULL; - ev->u.cval = (char) ev->u.dval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_char: - return ev; + case AST_Expression::EV_bool: + ev->u.cval = (char) ev->u.bval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval > (float) ACE_CHAR_MAX + || ev->u.fval < (float) ACE_CHAR_MIN) + { + return 0; + } + + ev->u.cval = (char) ev->u.fval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > (double) ACE_CHAR_MAX + || ev->u.dval < (double) ACE_CHAR_MIN) + { + return 0; + } + + ev->u.cval = (char) ev->u.dval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_char: + return ev; + case AST_Expression::EV_wchar: + if (ev->u.wcval > (ACE_CDR::WChar) ACE_CHAR_MAX) + { + return 0; + } + + ev->u.cval = (char) ev->u.wcval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_octet: + if (ev->u.oval > (unsigned char) ACE_CHAR_MAX) + { + return 0; + } + + ev->u.cval = (char) ev->u.oval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_wchar: - if (ev->u.wcval > (ACE_CDR::WChar) ACE_CHAR_MAX) - return NULL; - ev->u.cval = (char) ev->u.wcval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_octet: - if (ev->u.oval > (unsigned char) ACE_CHAR_MAX) - return NULL; - ev->u.cval = (char) ev->u.oval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_wchar: - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval < 0) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.sval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_ushort: - ev->u.wcval = (ACE_CDR::WChar) ev->u.usval; - ev->et = AST_Expression::EV_char; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval < 0 - || ev->u.lval > ACE_WCHAR_MAX) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.lval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > ACE_WCHAR_MAX) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.ulval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval < 0) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.sval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_ushort: + ev->u.wcval = (ACE_CDR::WChar) ev->u.usval; + ev->et = AST_Expression::EV_char; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval < 0 + || ev->u.lval > ACE_WCHAR_MAX) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.lval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > ACE_WCHAR_MAX) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.ulval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval > (ACE_CDR::LongLong) ACE_WCHAR_MAX - || ev->u.llval < 0) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.llval; - ev->et = AST_Expression::EV_wchar; - return ev; + if (ev->u.llval > (ACE_CDR::LongLong) ACE_WCHAR_MAX + || ev->u.llval < 0) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.llval; + ev->et = AST_Expression::EV_wchar; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_WCHAR_MAX) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.ullval; - ev->et = AST_Expression::EV_wchar; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_WCHAR_MAX) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.ullval; + ev->et = AST_Expression::EV_wchar; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.wcval = (ACE_CDR::WChar) ev->u.bval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval > (float) ACE_WCHAR_MAX - || ev->u.fval < 0) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.fval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval > (double) ACE_WCHAR_MAX - || ev->u.dval < 0) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.dval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_char: - if ((signed char) ev->u.cval < 0) - return NULL; - ev->u.wcval = (ACE_CDR::WChar) ev->u.cval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_wchar: - return ev; + case AST_Expression::EV_bool: + ev->u.wcval = (ACE_CDR::WChar) ev->u.bval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval > (float) ACE_WCHAR_MAX + || ev->u.fval < 0) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.fval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval > (double) ACE_WCHAR_MAX + || ev->u.dval < 0) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.dval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_char: + if ((signed char) ev->u.cval < 0) + { + return 0; + } + + ev->u.wcval = (ACE_CDR::WChar) ev->u.cval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_wchar: + return ev; + case AST_Expression::EV_octet: + ev->u.wcval = (ACE_CDR::WChar) ev->u.oval; + ev->et = AST_Expression::EV_wchar; + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_octet: - ev->u.wcval = (ACE_CDR::WChar) ev->u.oval; - ev->et = AST_Expression::EV_wchar; - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: - case AST_Expression::EV_any: - case AST_Expression::EV_void: - case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_octet: - switch (ev->et) { - case AST_Expression::EV_short: - if (ev->u.sval < 0 || ev->u.sval > (short) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.sval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_ushort: - if (ev->u.usval > (unsigned short) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.usval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_long: - if (ev->u.lval < 0 - || ev->u.lval > (long) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.lval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_ulong: - if (ev->u.ulval > (unsigned long) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.ulval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + if (ev->u.sval < 0 + || ev->u.sval > (short) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.sval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_ushort: + if (ev->u.usval > (unsigned short) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.usval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_long: + if (ev->u.lval < 0 + || ev->u.lval > (long) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.lval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_ulong: + if (ev->u.ulval > (unsigned long) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.ulval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.llval < 0 - || ev->u.llval > (ACE_CDR::LongLong) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.llval; - ev->et = AST_Expression::EV_octet; - return ev; + if (ev->u.llval < 0 + || ev->u.llval > (ACE_CDR::LongLong) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.llval; + ev->et = AST_Expression::EV_octet; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_ulonglong: + case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.ullval; - ev->et = AST_Expression::EV_octet; - return ev; + if (ev->u.ullval > (ACE_CDR::ULongLong) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.ullval; + ev->et = AST_Expression::EV_octet; + return ev; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case AST_Expression::EV_bool: - ev->u.oval = (unsigned char) ((ev->u.bval == I_FALSE) ? 1 : 0); - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_float: - if (ev->u.fval < 0.0 - || ev->u.fval > (float) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.fval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_double: - if (ev->u.dval < 0.0 - || ev->u.dval > (double) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.dval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_char: - if ((signed char) ev->u.cval < 0) - return NULL; - ev->u.oval = (unsigned char) ev->u.cval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_wchar: - if (ev->u.wcval > (ACE_CDR::WChar) ACE_OCTET_MAX) - return NULL; - ev->u.oval = (unsigned char) ev->u.wcval; - ev->et = AST_Expression::EV_octet; - return ev; - case AST_Expression::EV_octet: - return ev; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_string: + case AST_Expression::EV_bool: + ev->u.oval = (unsigned char) ((ev->u.bval == I_FALSE) ? 1 : 0); + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_float: + if (ev->u.fval < 0.0 + || ev->u.fval > (float) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.fval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_double: + if (ev->u.dval < 0.0 + || ev->u.dval > (double) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.dval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_char: + if ((signed char) ev->u.cval < 0) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.cval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_wchar: + if (ev->u.wcval > (ACE_CDR::WChar) ACE_OCTET_MAX) + { + return 0; + } + + ev->u.oval = (unsigned char) ev->u.wcval; + ev->et = AST_Expression::EV_octet; + return ev; + case AST_Expression::EV_octet: + return ev; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_string: + case AST_Expression::EV_any: + case AST_Expression::EV_void: + case AST_Expression::EV_none: + return 0; + } case AST_Expression::EV_any: + switch (ev->et) + { + case AST_Expression::EV_any: + return ev; + default: + return 0; + } case AST_Expression::EV_void: + switch (ev->et) + { + case AST_Expression::EV_void: + return ev; + default: + return 0; + } case AST_Expression::EV_none: - return NULL; - } - case AST_Expression::EV_any: - switch (ev->et) { - case AST_Expression::EV_any: - return ev; - default: - return NULL; - } - case AST_Expression::EV_void: - switch (ev->et) { - case AST_Expression::EV_void: - return ev; - default: - return NULL; - } - case AST_Expression::EV_none: - return NULL; - case AST_Expression::EV_string: - switch (ev->et) { + return 0; case AST_Expression::EV_string: - return ev; - default: - return NULL; + switch (ev->et) + { + case AST_Expression::EV_string: + return ev; + default: + return 0; + } + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + return 0; } - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - return NULL; - } - return NULL; + + return 0; } -/* - * Evaluate the expression wrt the evaluation kind requested. Supported - * evaluation kinds are - * - EK_const: The expression must evaluate to a constant - * - EK_positive_int: The expression must further evaluate to a - * positive integer - */ +// Evaluate the expression wrt the evaluation kind requested. Supported +// evaluation kinds are +// - EK_const: The expression must evaluate to a constant +// - EK_positive_int: The expression must further evaluate to a +// positive integer + // @@(JP) This just maps one enum to another. It's a temporary fix, // but AST_Expression::EvalKind should go eventually. static AST_Expression::AST_ExprValue * @@ -1359,890 +1576,1020 @@ eval_kind(AST_Expression::AST_ExprValue *ev, AST_Expression::EvalKind ek) case AST_Expression::EK_octet: return coerce_value (ev, AST_Expression::EV_octet); default: - return NULL; + return 0; } } -/* - * Private operations - */ +// Private operations. -/* - * Apply binary operators to an AST_Expression after evaluating - * its sub-expressions. - * Operations supported: - * - * '+', '-', '*', '/' - */ +// Apply binary operators to an AST_Expression after evaluating +// its sub-expressions. +// Operations supported: '+', '-', '*', '/' AST_Expression::AST_ExprValue * -AST_Expression::eval_bin_op(AST_Expression::EvalKind ek) +AST_Expression::eval_bin_op (AST_Expression::EvalKind ek) { - AST_ExprValue *retval = NULL; - - if (pd_v1 == NULL || pd_v2 == NULL) - return NULL; - pd_v1->set_ev(pd_v1->eval_internal(ek)); - if (pd_v1->ev() == NULL) - return NULL; - pd_v1->set_ev(pd_v1->coerce(EV_double)); - if (pd_v1->ev() == NULL) - return NULL; - pd_v2->set_ev(pd_v2->eval_internal(ek)); - if (pd_v2->ev() == NULL) - return NULL; - pd_v2->set_ev(pd_v2->coerce(EV_double)); - if (pd_v2->ev() == NULL) - return NULL; - - retval = new AST_ExprValue; + AST_ExprValue *retval = 0; + + if (this->pd_v1 == 0 || this->pd_v2 == 0) + { + return 0; + } + + this->pd_v1->set_ev (this->pd_v1->eval_internal (ek)); + + if (this->pd_v1->ev () == 0) + { + return 0; + } + + this->pd_v1->set_ev (this->pd_v1->coerce (EV_double)); + + if (this->pd_v1->ev () == 0) + { + return 0; + } + + this->pd_v2->set_ev (this->pd_v2->eval_internal (ek)); + + if (this->pd_v2->ev () == 0) + { + return 0; + } + + this->pd_v2->set_ev (this->pd_v2->coerce(EV_double)); + + if (pd_v2->ev () == 0) + { + return 0; + } + + ACE_NEW_RETURN (retval, + AST_ExprValue, + 0); + retval->et = EV_double; - switch (pd_ec) { - case EC_mod: - if (pd_v2->ev()->u.lval == 0) - return NULL; - retval->u.lval = pd_v1->ev()->u.lval % pd_v2->ev()->u.lval; - break; - case EC_add: - retval->u.dval = pd_v1->ev()->u.dval + pd_v2->ev()->u.dval; - break; - case EC_minus: - retval->u.dval = pd_v1->ev()->u.dval - pd_v2->ev()->u.dval; - break; - case EC_mul: - retval->u.dval = pd_v1->ev()->u.dval * pd_v2->ev()->u.dval; - break; - case EC_div: - if (pd_v2->ev()->u.dval == 0.0) - return NULL; - retval->u.dval = pd_v1->ev()->u.dval / pd_v2->ev()->u.dval; - break; - default: - return NULL; - } + switch (this->pd_ec) + { + case EC_mod: + if (this->pd_v2->ev ()->u.lval == 0) + { + return 0; + } + + retval->u.lval = + this->pd_v1->ev ()->u.lval % this->pd_v2->ev ()->u.lval; + break; + case EC_add: + retval->u.dval = + this->pd_v1->ev ()->u.dval + this->pd_v2->ev ()->u.dval; + break; + case EC_minus: + retval->u.dval = + this->pd_v1->ev ()->u.dval - this->pd_v2->ev ()->u.dval; + break; + case EC_mul: + retval->u.dval = + this->pd_v1->ev ()->u.dval * this->pd_v2->ev ()->u.dval; + break; + case EC_div: + if (this->pd_v2->ev ()->u.dval == 0.0) + { + return 0; + } + + retval->u.dval = + this->pd_v1->ev ()->u.dval / this->pd_v2->ev ()->u.dval; + break; + default: + return 0; + } + return retval; } -/* - * Apply bitwise operations to an AST_Expression after evaluating - * its sub-expressions. - * Operations supported: - * - * '%', '|', '&', '^', '<<', '>>' - */ +// Apply bitwise operations to an AST_Expression after evaluating +// its sub-expressions. +// Operations supported: '%', '|', '&', '^', '<<', '>>' AST_Expression::AST_ExprValue * -AST_Expression::eval_bit_op(AST_Expression::EvalKind ek) +AST_Expression::eval_bit_op (AST_Expression::EvalKind ek) { - AST_Expression::AST_ExprValue *retval=NULL; + AST_Expression::AST_ExprValue *retval = 0; - if (pd_v1 == NULL || pd_v2 == NULL) - return NULL; + if (this->pd_v1 == 0 || this->pd_v2 == 0) + { + return 0; + } - pd_v1->set_ev (pd_v1->eval_internal (ek)); - pd_v2->set_ev (pd_v2->eval_internal (ek)); - if (pd_v1->ev () == NULL || pd_v2->ev () == NULL ) - return NULL; + this->pd_v1->set_ev (this->pd_v1->eval_internal (ek)); + this->pd_v2->set_ev (this->pd_v2->eval_internal (ek)); - retval = new AST_ExprValue; + if (this->pd_v1->ev () == 0 || this->pd_v2->ev () == 0 ) + { + return 0; + } + + ACE_NEW_RETURN (retval, + AST_ExprValue, + 0); // @@(JP) The rest will have to be expanded to handle 64-bit ints. if (ek == EK_ulong) { - pd_v1->set_ev (pd_v1->coerce (EV_ulong)); - pd_v2->set_ev (pd_v2->coerce (EV_ulong)); + this->pd_v1->set_ev (this->pd_v1->coerce (EV_ulong)); + this->pd_v2->set_ev (this->pd_v2->coerce (EV_ulong)); retval->et = EV_ulong; } else { - pd_v1->set_ev (pd_v1->coerce (EV_long)); - pd_v2->set_ev (pd_v2->coerce (EV_long)); + this->pd_v1->set_ev (this->pd_v1->coerce (EV_long)); + this->pd_v2->set_ev (this->pd_v2->coerce (EV_long)); retval->et = EV_long; } - if (pd_v1->ev () == NULL || pd_v2->ev () == NULL) - return NULL; + if (this->pd_v1->ev () == 0 || this->pd_v2->ev () == 0) + { + return 0; + } if (ek == EK_ulong) { - switch (pd_ec) + switch (this->pd_ec) { case EC_or: - retval->u.ulval = pd_v1->ev ()->u.ulval | pd_v2->ev ()->u.ulval; + retval->u.ulval = + this->pd_v1->ev ()->u.ulval | this->pd_v2->ev ()->u.ulval; break; case EC_xor: - retval->u.ulval = pd_v1->ev ()->u.ulval ^ pd_v2->ev ()->u.ulval; + retval->u.ulval = + this->pd_v1->ev ()->u.ulval ^ this->pd_v2->ev ()->u.ulval; break; case EC_and: - retval->u.ulval = pd_v1->ev ()->u.ulval & pd_v2->ev ()->u.ulval; + retval->u.ulval = + this->pd_v1->ev ()->u.ulval & this->pd_v2->ev ()->u.ulval; break; case EC_left: - retval->u.ulval = pd_v1->ev ()->u.ulval << pd_v2->ev ()->u.ulval; + retval->u.ulval = + this->pd_v1->ev ()->u.ulval << this->pd_v2->ev ()->u.ulval; break; case EC_right: - retval->u.ulval = pd_v1->ev ()->u.ulval >> pd_v2->ev ()->u.ulval; + retval->u.ulval = + this->pd_v1->ev ()->u.ulval >> this->pd_v2->ev ()->u.ulval; break; default: - return NULL; + return 0; } } else { - switch (pd_ec) + switch (this->pd_ec) { case EC_or: - retval->u.lval = pd_v1->ev ()->u.lval | pd_v2->ev ()->u.lval; + retval->u.lval = + this->pd_v1->ev ()->u.lval | this->pd_v2->ev ()->u.lval; break; case EC_xor: - retval->u.lval = pd_v1->ev ()->u.lval ^ pd_v2->ev ()->u.lval; + retval->u.lval = + this->pd_v1->ev ()->u.lval ^ this->pd_v2->ev ()->u.lval; break; case EC_and: - retval->u.lval = pd_v1->ev ()->u.lval & pd_v2->ev ()->u.lval; + retval->u.lval = + this->pd_v1->ev ()->u.lval & this->pd_v2->ev ()->u.lval; break; case EC_left: - retval->u.lval = pd_v1->ev ()->u.lval << pd_v2->ev ()->u.lval; + retval->u.lval = + this->pd_v1->ev ()->u.lval << this->pd_v2->ev ()->u.lval; break; case EC_right: - retval->u.lval = pd_v1->ev ()->u.lval >> pd_v2->ev ()->u.lval; + retval->u.lval = + this->pd_v1->ev ()->u.lval >> this->pd_v2->ev ()->u.lval; break; default: - return NULL; + return 0; } } return retval; } -/* - * Apply unary operators to an AST_Expression after evaluating its - * sub-expression. - * Operations supported: - * - * '-', '+', '~' - */ +// Apply unary operators to an AST_Expression after evaluating its +// sub-expression. +// Operations supported: '-', '+', '~' AST_Expression::AST_ExprValue * -AST_Expression::eval_un_op(AST_Expression::EvalKind ek) +AST_Expression::eval_un_op (AST_Expression::EvalKind ek) { - AST_ExprValue *retval = NULL; + AST_ExprValue *retval = 0; + + if (this->pd_ev != 0) + { + return this->pd_ev; + } - if (pd_ev != NULL) - return pd_ev; + if (this->pd_v1 == 0) + { + return 0; + } - if (pd_v1 == NULL) - return NULL; + this->pd_v1->set_ev (this->pd_v1->eval_internal (ek)); - pd_v1->set_ev(pd_v1->eval_internal(ek)); - if (pd_v1->ev() == NULL) - return NULL; + if (this->pd_v1->ev () == 0) + { + return 0; + } + + ACE_NEW_RETURN (retval, + AST_ExprValue, + 0); - retval = new AST_ExprValue; retval->et = EV_double; - switch (pd_ec) - { + switch (this->pd_ec) + { case EC_u_plus: - pd_v1->set_ev(pd_v1->coerce(EV_double)); - if (pd_v1->ev() == NULL) - return NULL; - retval->u.dval = pd_v1->ev()->u.dval; + this->pd_v1->set_ev (this->pd_v1->coerce (EV_double)); + + if (this->pd_v1->ev () == 0) + { + return 0; + } + + retval->u.dval = this->pd_v1->ev ()->u.dval; break; case EC_u_minus: - pd_v1->set_ev(pd_v1->coerce(EV_double)); - if (pd_v1->ev() == NULL) - return NULL; - retval->u.dval = -(pd_v1->ev()->u.dval); + this->pd_v1->set_ev (this->pd_v1->coerce (EV_double)); + + if (this->pd_v1->ev () == 0) + { + return 0; + } + + retval->u.dval = -(this->pd_v1->ev ()->u.dval); break; case EC_bit_neg: - if (pd_v1->ev() == NULL) - return NULL; + if (this->pd_v1->ev () == 0) + { + return 0; + } - switch (pd_v1->ev ()->et) + switch (this->pd_v1->ev ()->et) { case EV_short: retval->et = EV_short; - retval->u.sval = ~pd_v1->ev ()->u.sval; + retval->u.sval = ~this->pd_v1->ev ()->u.sval; break; case EV_ushort: retval->et = EV_ushort; - retval->u.usval = ~pd_v1->ev ()->u.usval; + retval->u.usval = ~this->pd_v1->ev ()->u.usval; break; case EV_long: retval->et = EV_long; - retval->u.lval = ~pd_v1->ev ()->u.lval; + retval->u.lval = ~this->pd_v1->ev ()->u.lval; break; case EV_ulong: retval->et = EV_ulong; - retval->u.ulval = ~pd_v1->ev ()->u.ulval; + retval->u.ulval = ~this->pd_v1->ev ()->u.ulval; break; #if ! defined (ACE_LACKS_LONGLONG_T) case EV_longlong: retval->et = EV_longlong; - retval->u.llval = ~pd_v1->ev ()->u.llval; + retval->u.llval = ~this->pd_v1->ev ()->u.llval; break; case EV_ulonglong: retval->et = EV_ulonglong; - retval->u.ullval = ~pd_v1->ev ()->u.ullval; + retval->u.ullval = ~this->pd_v1->ev ()->u.ullval; break; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ case EV_octet: retval->et = EV_octet; - retval->u.oval = ~pd_v1->ev ()->u.oval; + retval->u.oval = ~this->pd_v1->ev ()->u.oval; break; default: - return NULL; + return 0; } break; default: - return NULL; + return 0; } return retval; } -/* - * Evaluate a symbolic AST_Expression by looking up the named - * symbol. - */ +// Evaluate a symbolic AST_Expression by looking up the named +// symbol. AST_Expression::AST_ExprValue * -AST_Expression::eval_symbol(AST_Expression::EvalKind ek) +AST_Expression::eval_symbol (AST_Expression::EvalKind ek) { - UTL_Scope *s = 0; - AST_Decl *d = 0; - AST_Constant *c = 0; - - /* - * Is there a symbol stored? - */ - if (pd_n == NULL) { - idl_global->err()->eval_error(this); - return NULL; - } - /* - * Get current scope for lookup - */ - if (idl_global->scopes()->depth() > 0) - s = idl_global->scopes()->top_non_null(); - if (s == NULL) { - idl_global->err()->lookup_error(pd_n); - return NULL; - } - /* - * Do lookup - */ - d = s->lookup_by_name(pd_n, I_TRUE); - if (d == NULL) { - idl_global->err()->lookup_error(pd_n); - return NULL; - } - /* - * Is it a constant? - */ - if (d->node_type() != AST_Decl::NT_const && - d->node_type() != AST_Decl::NT_enum_val) { - idl_global->err()->constant_expected(pd_n, d); - return NULL; - } - /* - * OK, now evaluate the constant we just got, to produce its value - */ - c = AST_Constant::narrow_from_decl(d); - if (c == NULL) return NULL; - return c->constant_value()->eval_internal(ek); + UTL_Scope *s = 0; + AST_Decl *d = 0; + AST_Constant *c = 0; + + // Is there a symbol stored? + if (this->pd_n == 0) + { + idl_global->err ()->eval_error (this); + return 0; + } + + // Get current scope for lookup. + if (idl_global->scopes ()->depth() > 0) + { + s = idl_global->scopes ()->top_non_null (); + } + + if (s == 0) + { + idl_global->err ()->lookup_error (this->pd_n); + return 0; + } + + // Do lookup. + d = s->lookup_by_name (this->pd_n, + I_TRUE); + + if (d == 0) + { + idl_global->err ()->lookup_error (this->pd_n); + return 0; + } + + // Is it a constant? + if (d->node_type () != AST_Decl::NT_const + && d->node_type () != AST_Decl::NT_enum_val) + { + idl_global->err ()->constant_expected (this->pd_n, + d); + return 0; + } + + // OK, now evaluate the constant we just got, to produce its value. + c = AST_Constant::narrow_from_decl (d); + + if (c == 0) + { + return 0; + } + + return c->constant_value ()->eval_internal (ek); } -/* - * Coerce "this" to the ExprType required. Returns a copy of the - * original ExprValue with the coercion applied, if successful, or - * NULL if failed. - */ +// Coerce "this" to the ExprType required. Returns a copy of the +// original ExprValue with the coercion applied, if successful, or +// 0 if failed. AST_Expression::AST_ExprValue * -AST_Expression::coerce(AST_Expression::ExprType t) +AST_Expression::coerce (AST_Expression::ExprType t) { - /* - * Is it already of the right type? - */ - if (pd_ev != NULL && pd_ev->et == t) - return pd_ev; - /* - * OK, must coerce - * - * First, evaluate it, then try to coerce result type - * If already evaluated, return the result - */ + // Is it already of the right type? + if (this->pd_ev != 0 && this->pd_ev->et == t) + { + return this->pd_ev; + } + + // OK, must coerce. + // First, evaluate it, then try to coerce result type. + // If already evaluated, return the result. switch (t) { case EV_short: - pd_ev = eval_internal (EK_short); + this->pd_ev = this->eval_internal (EK_short); break; case EV_ushort: - pd_ev = eval_internal (EK_ushort); + this->pd_ev = this->eval_internal (EK_ushort); break; case EV_long: - pd_ev = eval_internal (EK_long); + this->pd_ev = this->eval_internal (EK_long); break; case EV_ulong: - pd_ev = eval_internal (EK_ulong); + this->pd_ev = this->eval_internal (EK_ulong); break; #if ! defined (ACE_LACKS_LONGLONG_T) case EV_longlong: - pd_ev = eval_internal (EK_longlong); + this->pd_ev = this->eval_internal (EK_longlong); break; case EV_ulonglong: - pd_ev = eval_internal (EK_ulonglong); + this->pd_ev = this->eval_internal (EK_ulonglong); break; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ case EV_octet: - pd_ev = eval_internal (EK_octet); + this->pd_ev = this->eval_internal (EK_octet); break; default: - pd_ev = eval_internal (EK_const); + this->pd_ev = this->eval_internal (EK_const); break; } - if (pd_ev == NULL) - return NULL; + if (pd_ev == 0) + { + return 0; + } - /* - * Create a copy to contain coercion result - */ + // Create a copy to contain coercion result. AST_ExprValue *copy = 0; ACE_NEW_RETURN (copy, AST_ExprValue, 0); - copy->et = pd_ev->et; + copy->et = this->pd_ev->et; - switch (pd_ev->et) + switch (this->pd_ev->et) { case EV_longdouble: case EV_wstring: case EV_void: case EV_none: case EV_any: - return NULL; + return 0; case EV_short: - copy->u.sval = pd_ev->u.sval; + copy->u.sval = this->pd_ev->u.sval; break; case EV_ushort: - copy->u.usval = pd_ev->u.usval; + copy->u.usval = this->pd_ev->u.usval; break; case EV_long: - copy->u.lval = pd_ev->u.lval; + copy->u.lval = this->pd_ev->u.lval; break; case EV_ulong: - copy->u.ulval = pd_ev->u.ulval; + copy->u.ulval = this->pd_ev->u.ulval; break; case EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - copy->u.llval = pd_ev->u.llval; + copy->u.llval = this->pd_ev->u.llval; break; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ case EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - copy->u.ullval = pd_ev->u.ullval; + copy->u.ullval = this->pd_ev->u.ullval; break; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return NULL; + return 0; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ case EV_bool: - copy->u.bval = pd_ev->u.bval; + copy->u.bval = this->pd_ev->u.bval; break; case EV_float: - copy->u.fval = pd_ev->u.fval; + copy->u.fval = this->pd_ev->u.fval; break; case EV_double: - copy->u.dval = pd_ev->u.dval; + copy->u.dval = this->pd_ev->u.dval; break; case EV_char: - copy->u.cval = pd_ev->u.cval; + copy->u.cval = this->pd_ev->u.cval; break; case EV_wchar: - copy->u.wcval = pd_ev->u.wcval; + copy->u.wcval = this->pd_ev->u.wcval; break; case EV_octet: - copy->u.oval = pd_ev->u.oval; + copy->u.oval = this->pd_ev->u.oval; break; case EV_string: - copy->u.strval = pd_ev->u.strval; + copy->u.strval = this->pd_ev->u.strval; break; } - return coerce_value(copy, t); + return coerce_value (copy, + t); } -/* - * Eval used internally - */ +// Eval used internally. AST_Expression::AST_ExprValue * -AST_Expression::eval_internal(AST_Expression::EvalKind ek) +AST_Expression::eval_internal (AST_Expression::EvalKind ek) { - /* - * Already evaluated? - */ - if (this->pd_ev != NULL) - return eval_kind(this->pd_ev, ek); - /* - * OK, must evaluate operator - */ - switch (this->pd_ec) { - case EC_add: - case EC_minus: - case EC_mul: - case EC_div: - case EC_mod: - this->pd_ev = eval_bin_op(ek); - return eval_kind(this->pd_ev, ek); - case EC_or: - case EC_xor: - case EC_and: - case EC_left: - case EC_right: - this->pd_ev = eval_bit_op(ek); - return eval_kind(this->pd_ev, ek); - case EC_u_plus: - case EC_u_minus: - case EC_bit_neg: - this->pd_ev = eval_un_op(ek); - return eval_kind(this->pd_ev, ek); - case EC_symbol: - this->pd_ev = eval_symbol(ek); - return eval_kind(this->pd_ev, ek); - case EC_none: - return NULL; - } - return NULL; + // Already evaluated? + if (this->pd_ev != 0) + { + return eval_kind (this->pd_ev, + ek); + } + + // OK, must evaluate operator. + switch (this->pd_ec) + { + case EC_add: + case EC_minus: + case EC_mul: + case EC_div: + case EC_mod: + this->pd_ev = this->eval_bin_op (ek); + return eval_kind (this->pd_ev, + ek); + case EC_or: + case EC_xor: + case EC_and: + case EC_left: + case EC_right: + this->pd_ev = this->eval_bit_op (ek); + return eval_kind (this->pd_ev, + ek); + case EC_u_plus: + case EC_u_minus: + case EC_bit_neg: + this->pd_ev = this->eval_un_op (ek); + return eval_kind (this->pd_ev, + ek); + case EC_symbol: + this->pd_ev = this->eval_symbol (ek); + return eval_kind (this->pd_ev, + ek); + case EC_none: + return 0; + } + + return 0; } -/* - * Public operations - */ +// Public operations. -/* - * Evaluate an AST_Expression, producing an AST_ExprValue or NULL - */ +// Evaluate an AST_Expression, producing an AST_ExprValue or 0. AST_Expression::AST_ExprValue * -AST_Expression::eval(AST_Expression::EvalKind ek) +AST_Expression::eval (AST_Expression::EvalKind ek) { - AST_Expression::AST_ExprValue *v = NULL; - - /* - * Call internal evaluator which does not coerce value to - * EvalKind-expected format - */ - v = eval_internal(ek); - /* - * Then coerce according to EvalKind-expected format - */ - return eval_kind(v, ek); + // Call internal evaluator which does not coerce value to + // EvalKind-expected format + AST_Expression::AST_ExprValue *v = this->eval_internal (ek); + + // Then coerce according to EvalKind-expected format. + return eval_kind (v, + ek); } -/* - * Evaluate "this", assigning the value to the pd_ev field. - */ +// Evaluate "this", assigning the value to the pd_ev field. void -AST_Expression::evaluate(EvalKind ek) +AST_Expression::evaluate (EvalKind ek) { - pd_ev = eval_internal(ek); - pd_ev = eval_kind(pd_ev, ek); + this->pd_ev = this->eval_internal (ek); + this->pd_ev = eval_kind (pd_ev, + ek); } -/* - * Expression equality comparison operator - */ +// Expression equality comparison operator. long -AST_Expression::operator==(AST_Expression *vc) +AST_Expression::operator== (AST_Expression *vc) { - if (pd_ec != vc->ec()) - return I_FALSE; - evaluate(EK_const); - vc->evaluate(EK_const); - if (pd_ev == NULL || vc->ev() == NULL) - return I_FALSE; - if (pd_ev->et != vc->ev()->et) - return I_FALSE; - switch (pd_ev->et) { - case EV_short: - return (pd_ev->u.sval == vc->ev()->u.sval) ? I_TRUE : I_FALSE; - case EV_ushort: - return (pd_ev->u.usval == vc->ev()->u.usval) ? I_TRUE : I_FALSE; - case EV_long: - return (pd_ev->u.lval == vc->ev()->u.lval) ? I_TRUE : I_FALSE; - case EV_ulong: - return (pd_ev->u.ulval == vc->ev()->u.ulval) ? I_TRUE : I_FALSE; - case EV_float: - return (pd_ev->u.fval == vc->ev()->u.fval) ? I_TRUE : I_FALSE; - case EV_double: - return (pd_ev->u.dval == vc->ev()->u.dval) ? I_TRUE : I_FALSE; - case EV_char: - return (pd_ev->u.cval == vc->ev()->u.cval) ? I_TRUE : I_FALSE; - case EV_wchar: - return (pd_ev->u.wcval == vc->ev()->u.wcval) ? I_TRUE : I_FALSE; - case EV_octet: - return (pd_ev->u.oval == vc->ev()->u.oval) ? I_TRUE : I_FALSE; - case EV_bool: - return (pd_ev->u.lval == vc->ev()->u.lval) ? I_TRUE : I_FALSE; - case EV_string: - if (pd_ev->u.strval == NULL) - { - if (vc->ev()->u.strval == NULL) - return I_TRUE; - else - return I_FALSE; - } - else if (vc->ev()->u.strval == NULL) + if (this->pd_ec != vc->ec ()) + { + return I_FALSE; + } + + this->evaluate (EK_const); + vc->evaluate (EK_const); + + if (pd_ev == 0 || vc->ev() == 0) + { return I_FALSE; - else - return (pd_ev->u.strval == vc->ev()->u.strval) ? I_TRUE : I_FALSE; - case EV_longlong: + } + + if (this->pd_ev->et != vc->ev ()->et) + { + return I_FALSE; + } + + switch (pd_ev->et) + { + case EV_short: + return this->pd_ev->u.sval == vc->ev ()->u.sval ? I_TRUE : I_FALSE; + case EV_ushort: + return this->pd_ev->u.usval == vc->ev ()->u.usval ? I_TRUE : I_FALSE; + case EV_long: + return this->pd_ev->u.lval == vc->ev ()->u.lval ? I_TRUE : I_FALSE; + case EV_ulong: + return this->pd_ev->u.ulval == vc->ev()->u.ulval ? I_TRUE : I_FALSE; + case EV_float: + return this->pd_ev->u.fval == vc->ev ()->u.fval ? I_TRUE : I_FALSE; + case EV_double: + return this->pd_ev->u.dval == vc->ev ()->u.dval ? I_TRUE : I_FALSE; + case EV_char: + return this->pd_ev->u.cval == vc->ev ()->u.cval ? I_TRUE : I_FALSE; + case EV_wchar: + return this->pd_ev->u.wcval == vc->ev ()->u.wcval ? I_TRUE : I_FALSE; + case EV_octet: + return this->pd_ev->u.oval == vc->ev ()->u.oval ? I_TRUE : I_FALSE; + case EV_bool: + return this->pd_ev->u.lval == vc->ev ()->u.lval ? I_TRUE : I_FALSE; + case EV_string: + if (this->pd_ev->u.strval == 0) + { + if (vc->ev ()->u.strval == 0) + { + return I_TRUE; + } + else + { + return I_FALSE; + } + } + else if (vc->ev ()->u.strval == 0) + { + return I_FALSE; + } + else + { + return this->pd_ev->u.strval == vc->ev ()->u.strval + ? I_TRUE + : I_FALSE; + } + + case EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - return (pd_ev->u.llval == vc->ev()->u.llval) ? I_TRUE : I_FALSE; + return pd_ev->u.llval == vc->ev ()->u.llval ? I_TRUE : I_FALSE; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return I_FALSE; + return I_FALSE; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case EV_ulonglong: + case EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - return (pd_ev->u.ullval == vc->ev()->u.ullval) ? I_TRUE : I_FALSE; + return pd_ev->u.ullval == vc->ev()->u.ullval ? I_TRUE : I_FALSE; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return I_FALSE; + return I_FALSE; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case EV_longdouble: - case EV_wstring: - case EV_any: - case EV_void: - case EV_none: - return I_FALSE; - } + case EV_longdouble: + case EV_wstring: + case EV_any: + case EV_void: + case EV_none: + return I_FALSE; + } + return I_FALSE; } long -AST_Expression::compare(AST_Expression *vc) +AST_Expression::compare (AST_Expression *vc) { - if (pd_ec != vc->ec()) - return I_FALSE; - evaluate(EK_const); - vc->evaluate(EK_const); - if (pd_ev == NULL || vc->ev() == NULL) - return I_FALSE; - if (pd_ev->et != vc->ev()->et) - return I_FALSE; - switch (pd_ev->et) { - case EV_short: - return (pd_ev->u.sval == vc->ev()->u.sval) ? I_TRUE : I_FALSE; - case EV_ushort: - return (pd_ev->u.usval == vc->ev()->u.usval) ? I_TRUE : I_FALSE; - case EV_long: - return (pd_ev->u.lval == vc->ev()->u.lval) ? I_TRUE : I_FALSE; - case EV_ulong: - return (pd_ev->u.ulval == vc->ev()->u.ulval) ? I_TRUE : I_FALSE; - case EV_float: - return (pd_ev->u.fval == vc->ev()->u.fval) ? I_TRUE : I_FALSE; - case EV_double: - return (pd_ev->u.dval == vc->ev()->u.dval) ? I_TRUE : I_FALSE; - case EV_char: - return (pd_ev->u.cval == vc->ev()->u.cval) ? I_TRUE : I_FALSE; - case EV_wchar: - return (pd_ev->u.wcval == vc->ev()->u.wcval) ? I_TRUE : I_FALSE; - case EV_octet: - return (pd_ev->u.oval == vc->ev()->u.oval) ? I_TRUE : I_FALSE; - case EV_bool: - return (pd_ev->u.lval == vc->ev()->u.lval) ? I_TRUE : I_FALSE; - case EV_string: - if (pd_ev->u.strval == NULL) { - if (vc->ev()->u.strval == NULL) - return I_TRUE; - else - return I_FALSE; - } else if (vc->ev()->u.strval == NULL) + if (this->pd_ec != vc->ec ()) + { + return I_FALSE; + } + + this->evaluate (EK_const); + vc->evaluate (EK_const); + + if (this->pd_ev == 0 || vc->ev () == 0) + { + return I_FALSE; + } + + if (this->pd_ev->et != vc->ev ()->et) + { return I_FALSE; - else - return (pd_ev->u.strval == vc->ev()->u.strval) ? I_TRUE : I_FALSE; - case EV_longlong: + } + + switch (this->pd_ev->et) + { + case EV_short: + return this->pd_ev->u.sval == vc->ev ()->u.sval ? I_TRUE : I_FALSE; + case EV_ushort: + return this->pd_ev->u.usval == vc->ev ()->u.usval ? I_TRUE : I_FALSE; + case EV_long: + return this->pd_ev->u.lval == vc->ev ()->u.lval ? I_TRUE : I_FALSE; + case EV_ulong: + return this->pd_ev->u.ulval == vc->ev ()->u.ulval ? I_TRUE : I_FALSE; + case EV_float: + return this->pd_ev->u.fval == vc->ev ()->u.fval ? I_TRUE : I_FALSE; + case EV_double: + return this->pd_ev->u.dval == vc->ev ()->u.dval ? I_TRUE : I_FALSE; + case EV_char: + return this->pd_ev->u.cval == vc->ev ()->u.cval ? I_TRUE : I_FALSE; + case EV_wchar: + return this->pd_ev->u.wcval == vc->ev ()->u.wcval ? I_TRUE : I_FALSE; + case EV_octet: + return this->pd_ev->u.oval == vc->ev ()->u.oval ? I_TRUE : I_FALSE; + case EV_bool: + return this->pd_ev->u.lval == vc->ev ()->u.lval ? I_TRUE : I_FALSE; + case EV_string: + if (this->pd_ev->u.strval == 0) + { + if (vc->ev ()->u.strval == 0) + { + return I_TRUE; + } + else + { + return I_FALSE; + } + } + else if (vc->ev ()->u.strval == 0) + { + return I_FALSE; + } + else + { + return this->pd_ev->u.strval == vc->ev ()->u.strval ? I_TRUE : I_FALSE; + } + + case EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) - return (pd_ev->u.llval == vc->ev()->u.llval) ? I_TRUE : I_FALSE; + return this->pd_ev->u.llval == vc->ev ()->u.llval ? I_TRUE : I_FALSE; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return I_FALSE; + return I_FALSE; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case EV_ulonglong: + case EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) - return (pd_ev->u.ullval == vc->ev()->u.ullval) ? I_TRUE : I_FALSE; + return this->pd_ev->u.ullval == vc->ev ()->u.ullval ? I_TRUE : I_FALSE; #else /* ! defined (ACE_LACKS_LONGLONG_T) */ - return I_FALSE; + return I_FALSE; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - case EV_longdouble: - case EV_wstring: - case EV_any: - case EV_void: - case EV_none: - return I_FALSE; - } + case EV_longdouble: + case EV_wstring: + case EV_any: + case EV_void: + case EV_none: + return I_FALSE; + } + return I_FALSE; } -/* - * Redefinition of inherited virtual operations - */ - -/* - * Helper functions for expression dumpers - */ +// Helper functions for expression dumpers. -/* - * Dump this binary AST_Expression node to the ostream o - */ +// Dump this binary AST_Expression node to the ostream o. static void -dump_binary_expr(ostream &o, const char *s, AST_Expression *n1, AST_Expression *n2) +dump_binary_expr (ostream &o, + const char *s, + AST_Expression *n1, + AST_Expression *n2) { - if (n1 != NULL) n1->dump(o); + if (n1 != 0) + { + n1->dump (o); + } + o << " " << s << " "; - if (n2 != NULL) n2->dump(o); + + if (n2 != 0) + { + n2->dump (o); + } } -/* - * Dump this unary AST_Expression node to the ostream o - */ +// Dump this unary AST_Expression node to the ostream o. static void -dump_unary_expr(ostream &o, const char *s, AST_Expression *e) +dump_unary_expr (ostream &o, + const char *s, + AST_Expression *e) { o << s; - e->dump(o); + e->dump (o); } -/* - * Dump the supplied AST_ExprValue to the ostream o - */ +// Dump the supplied AST_ExprValue to the ostream o. static void -dump_expr_val(ostream &o, AST_Expression::AST_ExprValue *ev) +dump_expr_val (ostream &o, + AST_Expression::AST_ExprValue *ev) { - switch (ev->et) { - case AST_Expression::EV_short: - o << ev->u.sval; - break; - case AST_Expression::EV_ushort: - o << ev->u.usval; - break; - case AST_Expression::EV_long: - o << ev->u.lval; - break; - case AST_Expression::EV_ulong: - o << ev->u.ulval; - break; - case AST_Expression::EV_float: - o << ev->u.fval; - break; - case AST_Expression::EV_double: - o << ev->u.dval; - break; - case AST_Expression::EV_char: - o << ev->u.cval; - break; - case AST_Expression::EV_wchar: - o << ev->u.wcval; - break; - case AST_Expression::EV_octet: - o << ev->u.oval; - break; - case AST_Expression::EV_bool: - o << (ev->u.bval == I_TRUE ? "TRUE" : "FALSE"); - break; - case AST_Expression::EV_string: - if (ev->u.strval != NULL) - ev->u.strval->dump(o); - case AST_Expression::EV_longlong: + switch (ev->et) + { + case AST_Expression::EV_short: + o << ev->u.sval; + break; + case AST_Expression::EV_ushort: + o << ev->u.usval; + break; + case AST_Expression::EV_long: + o << ev->u.lval; + break; + case AST_Expression::EV_ulong: + o << ev->u.ulval; + break; + case AST_Expression::EV_float: + o << ev->u.fval; + break; + case AST_Expression::EV_double: + o << ev->u.dval; + break; + case AST_Expression::EV_char: + o << ev->u.cval; + break; + case AST_Expression::EV_wchar: + o << ev->u.wcval; + break; + case AST_Expression::EV_octet: + o << ev->u.oval; + break; + case AST_Expression::EV_bool: + o << (ev->u.bval == I_TRUE ? "TRUE" : "FALSE"); + break; + case AST_Expression::EV_string: + if (ev->u.strval != NULL) + ev->u.strval->dump(o); + case AST_Expression::EV_longlong: #if ! defined (ACE_LACKS_LONGLONG_T) -// o << ev->u.llval; +// o << ev->u.llval; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ break; case AST_Expression::EV_ulonglong: #if ! defined (ACE_LACKS_LONGLONG_T) -// o << ev->u.ullval; +// o << ev->u.ullval; #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - break; - case AST_Expression::EV_longdouble: - case AST_Expression::EV_wstring: - case AST_Expression::EV_any: - case AST_Expression::EV_none: - case AST_Expression::EV_void: - break; - } + break; + case AST_Expression::EV_longdouble: + case AST_Expression::EV_wstring: + case AST_Expression::EV_any: + case AST_Expression::EV_none: + case AST_Expression::EV_void: + break; + } } -/* - * Dump an AST_Expression node to the ostream o - */ +// Dump an AST_Expression node to the ostream o. void -AST_Expression::dump(ostream &o) +AST_Expression::dump (ostream &o) { - /* - * See if it was a constant or was evaluated already - */ - if (pd_ev != NULL) { - dump_expr_val(o, pd_ev); - return; - } - /* - * OK, must print out an expression - */ - switch (pd_ec) { - /* - * Binary expressions: - */ - case EC_add: - dump_binary_expr(o, "+", pd_v1, pd_v2); - break; - case EC_minus: - dump_binary_expr(o, "-", pd_v1, pd_v2); - break; - case EC_mul: - dump_binary_expr(o, "*", pd_v1, pd_v2); - break; - case EC_div: - dump_binary_expr(o, "/", pd_v1, pd_v2); - break; - case EC_mod: - dump_binary_expr(o, "%", pd_v1, pd_v2); - break; - case EC_or: - dump_binary_expr(o, "|", pd_v1, pd_v2); - break; - case EC_xor: - dump_binary_expr(o, "^", pd_v1, pd_v2); - break; - case EC_and: - dump_binary_expr(o, "&", pd_v1, pd_v2); - break; - case EC_left: - dump_binary_expr(o, "<<", pd_v1, pd_v2); - break; - case EC_right: - dump_binary_expr(o, ">>", pd_v1, pd_v2); - break; - /* - * Unary expressions: - */ - case EC_u_plus: - dump_unary_expr(o, "+", pd_v1); - break; - case EC_u_minus: - dump_unary_expr(o, "-", pd_v1); - break; - case EC_bit_neg: - dump_unary_expr(o, "~", pd_v1); - break; - /* - * Unevaluated symbol - */ - case EC_symbol: - pd_n->dump(o); - break; - case EC_none: - break; - default: - o << ACE_TEXT ("unsupported dump mode for expression with ec == ") - << (int) pd_ec ; - break; - } + // See if it was a constant or was evaluated already. + if (this->pd_ev != 0) + { + dump_expr_val (o, + this->pd_ev); + return; + } + + // OK, must print out an expression. + switch (this->pd_ec) + { + // Binary expressions: + case EC_add: + dump_binary_expr (o, + "+", + this->pd_v1, + this->pd_v2); + break; + case EC_minus: + dump_binary_expr (o, + "-", + this->pd_v1, + this->pd_v2); + break; + case EC_mul: + dump_binary_expr (o, + "*", + this->pd_v1, + this->pd_v2); + break; + case EC_div: + dump_binary_expr (o, + "/", + this->pd_v1, + this->pd_v2); + break; + case EC_mod: + dump_binary_expr (o, + "%", + this->pd_v1, + this->pd_v2); + break; + case EC_or: + dump_binary_expr (o, + "|", + this->pd_v1, + this->pd_v2); + break; + case EC_xor: + dump_binary_expr (o, + "^", + this->pd_v1, + this->pd_v2); + break; + case EC_and: + dump_binary_expr (o, + "&", + this->pd_v1, + this->pd_v2); + break; + case EC_left: + dump_binary_expr (o, + "<<", + this->pd_v1, + this->pd_v2); + break; + case EC_right: + dump_binary_expr (o, + ">>", + this->pd_v1, + this->pd_v2); + break; + // Unary expressions. + case EC_u_plus: + dump_unary_expr (o, + "+", + this->pd_v1); + break; + case EC_u_minus: + dump_unary_expr (o, + "-", + this->pd_v1); + break; + case EC_bit_neg: + dump_unary_expr (o, + "~", + this->pd_v1); + break; + // Unevaluated symbol. + case EC_symbol: + this->pd_n->dump (o); + break; + case EC_none: + break; + default: + o << ACE_TEXT ("unsupported dump mode for expression with ec == ") + << (int) this->pd_ec ; + break; + } } -/* - * Data accessors - */ +// Data accessors. UTL_Scope * -AST_Expression::defined_in() +AST_Expression::defined_in (void) { - return pd_defined_in; + return this->pd_defined_in; } void -AST_Expression::set_defined_in(UTL_Scope *d) +AST_Expression::set_defined_in (UTL_Scope *d) { - pd_defined_in = d; + this->pd_defined_in = d; } long -AST_Expression::line() +AST_Expression::line (void) { - return pd_line; + return this->pd_line; } void -AST_Expression::set_line(long l) +AST_Expression::set_line (long l) { - pd_line = l; + this->pd_line = l; } UTL_String * -AST_Expression::file_name() +AST_Expression::file_name (void) { - return pd_file_name; + return this->pd_file_name; } void -AST_Expression::set_file_name(UTL_String *f) +AST_Expression::set_file_name (UTL_String *f) { - pd_file_name = f; + this->pd_file_name = f; } AST_Expression::ExprComb -AST_Expression::ec() +AST_Expression::ec (void) { - return pd_ec; + return this->pd_ec; } void -AST_Expression::set_ec(AST_Expression::ExprComb new_ec) +AST_Expression::set_ec (AST_Expression::ExprComb new_ec) { - pd_ec = new_ec; + this->pd_ec = new_ec; } AST_Expression::AST_ExprValue * -AST_Expression::ev() +AST_Expression::ev (void) { - return pd_ev; + return this->pd_ev; } void -AST_Expression::set_ev(AST_Expression::AST_ExprValue *new_ev) +AST_Expression::set_ev (AST_Expression::AST_ExprValue *new_ev) { - pd_ev = new_ev; + this->pd_ev = new_ev; } AST_Expression * -AST_Expression::v1() +AST_Expression::v1 (void) { - return pd_v1; + return this->pd_v1; } void -AST_Expression::set_v1(AST_Expression *e) +AST_Expression::set_v1 (AST_Expression *e) { - - pd_v1 = e; + this->pd_v1 = e; } AST_Expression * -AST_Expression::v2() +AST_Expression::v2 (void) { - return pd_v2; + return this->pd_v2; } void -AST_Expression::set_v2(AST_Expression *e) +AST_Expression::set_v2 (AST_Expression *e) { - pd_v2 = e; + this->pd_v2 = e; } UTL_ScopedName * -AST_Expression::n() +AST_Expression::n (void) { - return pd_n; + return this->pd_n; } void -AST_Expression::set_n(UTL_ScopedName *new_n) +AST_Expression::set_n (UTL_ScopedName *new_n) { - pd_n = new_n; + this->pd_n = new_n; } diff --git a/TAO/TAO_IDL/ast/ast_field.cpp b/TAO/TAO_IDL/ast/ast_field.cpp index f161ab4d5bf..5f5e07e7118 100644 --- a/TAO/TAO_IDL/ast/ast_field.cpp +++ b/TAO/TAO_IDL/ast/ast_field.cpp @@ -62,64 +62,56 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_field.cc - Implementation of class AST_Field - * - * AST_Fields denote fields in IDL structure, union and exception - * declarations. AST_Field is also used as a superclass of AST_Argument - * and AST_UnionBranch. - * AST_Fields have a field type (a subclass of AST_Type) and a name - * (a UTL_ScopedName) - * - * AST_Field supplies two constructors, one to be used in constructing - * AST_Field nodes, the other to be used in constructing AST_Argument - * nodes and AST_UnionBranch nodes. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Fields denote fields in IDL structure, union and exception +// declarations. AST_Field is also used as a superclass of AST_Argument +// and AST_UnionBranch. +// AST_Fields have a field type (a subclass of AST_Type) and a name +// (a UTL_ScopedName). + +// AST_Field supplies two constructors, one to be used in constructing +// AST_Field nodes, the other to be used in constructing AST_Argument +// nodes and AST_UnionBranch nodes. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_field, "$Id$") -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. -/* - * Default constructor - */ -AST_Field::AST_Field () - : pd_field_type (NULL), +// Default constructor. +AST_Field::AST_Field (void) + : pd_field_type (0), pd_visibility (vis_NA) { } -/* - * To be used when constructing an AST_Field node - */ +// To be used when constructing an AST_Field node. AST_Field::AST_Field (AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p, Visibility vis) - : AST_Decl (AST_Decl::NT_field, n, p), - pd_field_type (ft), - pd_visibility (vis) + : AST_Decl (AST_Decl::NT_field, + n, + p), + pd_field_type (ft), + pd_visibility (vis) { } -/* - * To be used when constructing a node of a subclass of AST_Field - */ +// To be used when constructing a node of a subclass of AST_Field. AST_Field::AST_Field (AST_Decl::NodeType nt, AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p, Visibility vis) - : AST_Decl (nt, n, p), - pd_field_type (ft), - pd_visibility (vis) + : AST_Decl (nt, + n, + p), + pd_field_type (ft), + pd_visibility (vis) { } @@ -127,26 +119,13 @@ AST_Field::~AST_Field (void) { } -/* - * Private operations - */ +// Redefinition of inherited virtual operations. -/* - * Public operations - */ - - -/* - * Redefinition of inherited virtual operations - */ - -/* - * Dump this AST_Field node to the ostream o - */ +// Dump this AST_Field node to the ostream o. void AST_Field::dump (ostream &o) { - switch (visibility ()) + switch (this->pd_visibility) { case vis_PRIVATE: o << "private "; @@ -157,29 +136,26 @@ AST_Field::dump (ostream &o) case vis_NA: break; } - pd_field_type->local_name ()->dump (o); + + this->pd_field_type->local_name ()->dump (o); o << " "; - local_name ()->dump (o); + this->local_name ()->dump (o); } -/* - * Data accessors - */ +// Data accessors. AST_Type * -AST_Field::field_type () +AST_Field::field_type (void) { - return pd_field_type; + return this->pd_field_type; } AST_Field::Visibility -AST_Field::visibility () +AST_Field::visibility (void) { - return pd_visibility; + return this->pd_visibility; } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS1(AST_Field, AST_Decl) IMPL_NARROW_FROM_DECL(AST_Field) diff --git a/TAO/TAO_IDL/ast/ast_generator.cpp b/TAO/TAO_IDL/ast/ast_generator.cpp index eb6e2cca258..9231cfb1d98 100644 --- a/TAO/TAO_IDL/ast/ast_generator.cpp +++ b/TAO/TAO_IDL/ast/ast_generator.cpp @@ -62,73 +62,70 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_generator.cc - Implements the base AST node generator - * - * The generator protocol is explained in detail in the IDL CFE - * design document. - * The AST_Generator class provides operations to instantiate any - * of the AST nodes. It contains an operation for every constructor - * of every AST class. - */ - -#include "idl.h" -#include "idl_extern.h" +// The generator protocol is explained in detail in the IDL CFE +// design document. +// The AST_Generator class provides operations to instantiate any +// of the AST nodes. It contains an operation for every constructor +// of every AST class. + +#include "idl.h" +#include "idl_extern.h" #include "ace/config-all.h" ACE_RCSID(ast, ast_generator, "$Id$") -/* - * Constructors - */ - -/* - * Private operations - */ - -/* - * Public operations - */ +// Public operations. -/* - * Construct an AST_PredefinedType node (a predefined type) - */ +// Construct an AST_PredefinedType node (a predefined type). AST_PredefinedType * -AST_Generator::create_predefined_type(AST_PredefinedType::PredefinedType t, - UTL_ScopedName *n, - UTL_StrList *p) +AST_Generator::create_predefined_type (AST_PredefinedType::PredefinedType t, + UTL_ScopedName *n, + UTL_StrList *p) { - return new AST_PredefinedType(t, n, p); + AST_PredefinedType *retval = 0; + ACE_NEW_RETURN (retval, + AST_PredefinedType (t, + n, + p), + 0); + + return retval; } -/* - * Construct an AST_Module node (a module) - */ -AST_Module * +// Construct an AST_Module node (a module). +AST_Module * AST_Generator::create_module (UTL_Scope *, UTL_ScopedName *n, UTL_StrList *p) { - return new AST_Module(n, p); + AST_Module *retval = 0; + ACE_NEW_RETURN (retval, + AST_Module (n, + p), + 0); + + return retval; } -/* - * Construct an AST_Root node (a node representing the root of an AST) - */ +// Construct an AST_Root node (a node representing the root of an AST). AST_Root * -AST_Generator::create_root(UTL_ScopedName *n, - UTL_StrList *p) +AST_Generator::create_root (UTL_ScopedName *n, + UTL_StrList *p) { - return new AST_Root(n, p); + AST_Root *retval = 0; + ACE_NEW_RETURN (retval, + AST_Root (n, + p), + 0); + + return retval; } -/* - * Construct an AST_Interface node (an interface) - */ -AST_Interface * +// Construct an AST_Interface node (an interface). +AST_Interface * AST_Generator::create_interface (UTL_ScopedName *n, AST_Interface **ih, long nih, @@ -138,39 +135,52 @@ AST_Generator::create_interface (UTL_ScopedName *n, idl_bool l, idl_bool a) { - return new AST_Interface (n, - ih, - nih, - ih_flat, - nih_flat, - p, - l, - a); -} + AST_Interface *retval = 0; + ACE_NEW_RETURN (retval, + AST_Interface (n, + ih, + nih, + ih_flat, + nih_flat, + p, + l, + a), + 0); -/* - * Construct an AST_InterfaceFwd node (a node representing the forward - * declaration of an interface) - */ -AST_InterfaceFwd * -AST_Generator::create_interface_fwd(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) -{ - return new AST_InterfaceFwd (this->create_interface (n, 0, -1, 0, 0, p, local, abstract), - n, - p); + return retval; } -/* - * Create a be_valuetype node - */ +// Construct an AST_InterfaceFwd node (a node representing the forward +// declaration of an interface). +AST_InterfaceFwd * +AST_Generator::create_interface_fwd (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) +{ + AST_InterfaceFwd *retval = 0; + ACE_NEW_RETURN (retval, + AST_InterfaceFwd (this->create_interface (n, + 0, + -1, + 0, + 0, + p, + local, + abstract), + n, + p), + 0); + + return retval; +} + +// Create a be_valuetype node. AST_Interface * -AST_Generator::create_valuetype(UTL_ScopedName *, - AST_Interface ** /* ih */, - long /* nih */, - UTL_StrList *) +AST_Generator::create_valuetype (UTL_ScopedName *, + AST_Interface ** /* ih */, + long /* nih */, + UTL_StrList *) { // Valuetypes are represented as be_valuetype derived from be_interface, // which derives from AST_Interface. If you construct a backend which @@ -184,347 +194,476 @@ AST_Generator::create_valuetype(UTL_ScopedName *, return 0; } -/* - * Create a be_valuetype_fwd node - */ +// Create a be_valuetype_fwd node. AST_InterfaceFwd * AST_Generator::create_valuetype_fwd (UTL_ScopedName *, UTL_StrList *) { // see note in create_valuetype() - // dummy placeholder must return true from is_valuetype() + // dummy placeholder must return true from is_valuetype(). ACE_ASSERT (0); return 0; } -/* - * Construct an AST_Exception node (an exception) - */ -AST_Exception * -AST_Generator::create_exception(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) +// Construct an AST_Exception node (an exception). +AST_Exception * +AST_Generator::create_exception (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) { - return new AST_Exception(n, p, local, abstract); -} + AST_Exception *retval = 0; + ACE_NEW_RETURN (retval, + AST_Exception (n, + p, + local, + abstract), + 0); -/* - * Construct an AST_Structure node (a struct) - */ -AST_Structure * -AST_Generator::create_structure(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) -{ - return new AST_Structure(n, p, local, abstract); + return retval; } -/* - * Construct an AST_Enum node (an enum) - */ -AST_Enum * -AST_Generator::create_enum(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) +// Construct an AST_Structure node (a struct). +AST_Structure * +AST_Generator::create_structure (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) { - return new AST_Enum(n, p, local, abstract); -} + AST_Structure *retval = 0; + ACE_NEW_RETURN (retval, + AST_Structure (n, + p, + local, + abstract), + 0); -/* - * Construct an AST_Operation node (an operation on an interface) - */ -AST_Operation * -AST_Generator::create_operation(AST_Type *rt, - AST_Operation::Flags fl, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) -{ - return new AST_Operation(rt, fl, n, p, local, abstract); + return retval; } -/* - * Construct an AST_Field node (a field in a struct, union or exception) - */ -AST_Field * -AST_Generator::create_field(AST_Type *ft, - UTL_ScopedName *n, +// Construct an AST_Enum node (an enum). +AST_Enum * +AST_Generator::create_enum (UTL_ScopedName *n, UTL_StrList *p, - AST_Field::Visibility vis) + idl_bool local, + idl_bool abstract) { - return new AST_Field(ft, n, p, vis); -} + AST_Enum *retval = 0; + ACE_NEW_RETURN (retval, + AST_Enum (n, + p, + local, + abstract), + 0); -/* - * Construct an AST_Argument node (an argument to an operation) - */ -AST_Argument * -AST_Generator::create_argument(AST_Argument::Direction d, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p) -{ - return new AST_Argument(d, ft, n, p); + return retval; } -/* - * Construct an AST_Attribute node (an attribute) - */ -AST_Attribute * -AST_Generator::create_attribute(idl_bool ro, +// Construct an AST_Operation node (an operation on an interface). +AST_Operation * +AST_Generator::create_operation (AST_Type *rt, + AST_Operation::Flags fl, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) +{ + AST_Operation *retval = 0; + ACE_NEW_RETURN (retval, + AST_Operation (rt, + fl, + n, + p, + local, + abstract), + 0); + + return retval; +} + +// Construct an AST_Field node (a field in a struct, union or exception). +AST_Field * +AST_Generator::create_field (AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p, + AST_Field::Visibility vis) +{ + AST_Field *retval = 0; + ACE_NEW_RETURN (retval, + AST_Field (ft, + n, + p, + vis), + 0); + + return retval; +} + +// Construct an AST_Argument node (an argument to an operation). +AST_Argument * +AST_Generator::create_argument (AST_Argument::Direction d, AST_Type *ft, UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) + UTL_StrList *p) { - return new AST_Attribute(ro, - ft, - n, - p, - local, - abstract); -} + AST_Argument *retval = 0; + ACE_NEW_RETURN (retval, + AST_Argument (d, + ft, + n, + p), + 0); -/* - * Construct an AST_Union node (a union) - */ -AST_Union * -AST_Generator::create_union(AST_ConcreteType *dt, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) -{ - return new AST_Union(dt, - n, - p, - local, - abstract); + return retval; } -/* - * Construct an AST_UnionBranch node (a branch in a union) - */ +// Construct an AST_Attribute node (an attribute). +AST_Attribute * +AST_Generator::create_attribute (idl_bool ro, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) +{ + AST_Attribute *retval = 0; + ACE_NEW_RETURN (retval, + AST_Attribute (ro, + ft, + n, + p, + local, + abstract), + 0); + + return retval; +} + +// Construct an AST_Union node (a union). +AST_Union * +AST_Generator::create_union (AST_ConcreteType *dt, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) +{ + AST_Union *retval = 0; + ACE_NEW_RETURN (retval, + AST_Union (dt, + n, + p, + local, + abstract), + 0); + + return retval; +} + +// Construct an AST_UnionBranch node (a branch in a union). AST_UnionBranch * -AST_Generator::create_union_branch(UTL_LabelList *ll, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p) +AST_Generator::create_union_branch (UTL_LabelList *ll, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p) { - return new AST_UnionBranch(ll, ft, n, p); -} + AST_UnionBranch *retval = 0; + ACE_NEW_RETURN (retval, + AST_UnionBranch (ll, + ft, + n, + p), + 0); -/* - * Construct an AST_UnionLabel node (a label in a union) - */ -AST_UnionLabel * -AST_Generator::create_union_label(AST_UnionLabel::UnionLabel ul, - AST_Expression *v) -{ - return new AST_UnionLabel(ul, v); + return retval; } -/* - * Construct an AST_Constant node (a constant) - */ -AST_Constant * -AST_Generator::create_constant(AST_Expression::ExprType et, - AST_Expression *ev, - UTL_ScopedName *n, - UTL_StrList *p) +// Construct an AST_UnionLabel node (a label in a union). +AST_UnionLabel * +AST_Generator::create_union_label (AST_UnionLabel::UnionLabel ul, + AST_Expression *v) { - return new AST_Constant(et, ev, n, p); -} + AST_UnionLabel *retval = 0; + ACE_NEW_RETURN (retval, + AST_UnionLabel (ul, + v), + 0); -/* - * Construct an AST_Expression node denoting a symbolic name - */ -AST_Expression * -AST_Generator::create_expr(UTL_ScopedName *n) -{ - return new AST_Expression(n); + return retval; } -/* - * Construct an AST_Expression denoting a coercion - */ -AST_Expression * -AST_Generator::create_expr(AST_Expression *v, - AST_Expression::ExprType t) +// Construct an AST_Constant node (a constant). +AST_Constant * +AST_Generator::create_constant (AST_Expression::ExprType et, + AST_Expression *ev, + UTL_ScopedName *n, + UTL_StrList *p) { - return new AST_Expression(v, t); + AST_Constant *retval = 0; + ACE_NEW_RETURN (retval, + AST_Constant (et, + ev, + n, + p), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a binary combinator - * of two other AST_Expression nodes - */ -AST_Expression * -AST_Generator::create_expr(AST_Expression::ExprComb c, - AST_Expression *v1, - AST_Expression *v2) +// Construct an AST_Expression node denoting a symbolic name. +AST_Expression * +AST_Generator::create_expr (UTL_ScopedName *n) { - return new AST_Expression(c, v1, v2); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (n), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a long integer - */ -AST_Expression * -AST_Generator::create_expr(long v) +// Construct an AST_Expression denoting a coercion. +AST_Expression * +AST_Generator::create_expr (AST_Expression *v, + AST_Expression::ExprType t) { - return new AST_Expression(v); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (v, + t), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a long integer being used - * as a boolean - */ +// Construct an AST_Expression node denoting a binary combinator. +// of two other AST_Expression nodes AST_Expression * -AST_Generator::create_expr(long v, AST_Expression::ExprType t) +AST_Generator::create_expr (AST_Expression::ExprComb c, + AST_Expression *v1, + AST_Expression *v2) { - return new AST_Expression(v, t); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (c, + v1, + v2), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting an unsigned long integer - */ -AST_Expression * -AST_Generator::create_expr(unsigned long v) +// Construct an AST_Expression node denoting a long integer. +AST_Expression * +AST_Generator::create_expr (long v) { - return new AST_Expression(v); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (v), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a string (a char * - * encapsulated as String) - */ -AST_Expression * -AST_Generator::create_expr(UTL_String *s) +// Construct an AST_Expression node denoting a long integer being used. +// as a boolean +AST_Expression * +AST_Generator::create_expr (long v, + AST_Expression::ExprType t) { - return new AST_Expression(s); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (v, + t), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a character - */ -AST_Expression * -AST_Generator::create_expr(char c) +// Construct an AST_Expression node denoting an unsigned long integer. +AST_Expression * +AST_Generator::create_expr (unsigned long v) { - return new AST_Expression(c); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (v), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a wide character - */ -AST_Expression * -AST_Generator::create_expr(ACE_OutputCDR::from_wchar wc) +// Construct an AST_Expression node denoting a string (a char * +// encapsulated as String). +AST_Expression * +AST_Generator::create_expr (UTL_String *s) { - return new AST_Expression(wc); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (s), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a wide string - */ -AST_Expression * -AST_Generator::create_expr(char *s) +// Construct an AST_Expression node denoting a character. +AST_Expression * +AST_Generator::create_expr (char c) { - return new AST_Expression(s); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (c), + 0); + + return retval; } -/* - * Construct an AST_Expression node denoting a 64-bit floating point number - */ -AST_Expression * -AST_Generator::create_expr(double d) +// Construct an AST_Expression node denoting a wide character. +AST_Expression * +AST_Generator::create_expr (ACE_OutputCDR::from_wchar wc) { - return new AST_Expression(d); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (wc), + 0); + + return retval; } -/* - * Construct an AST_EnumVal node (an enumerator) - */ -AST_EnumVal * -AST_Generator::create_enum_val(unsigned long v, - UTL_ScopedName *n, - UTL_StrList *p) +// Construct an AST_Expression node denoting a wide string. +AST_Expression * +AST_Generator::create_expr (char *s) { - return new AST_EnumVal(v, n, p); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (s), + 0); + + return retval; } -/* - * Construct an AST_Array node (an array type or field modifier) - */ -AST_Array * -AST_Generator::create_array(UTL_ScopedName *n, - unsigned long ndims, - UTL_ExprList *dims, - idl_bool local, - idl_bool abstract) +// Construct an AST_Expression node denoting a 64-bit floating point number. +AST_Expression * +AST_Generator::create_expr (double d) { - return new AST_Array(n, - ndims, - dims, - local, - abstract); + AST_Expression *retval = 0; + ACE_NEW_RETURN (retval, + AST_Expression (d), + 0); + + return retval; } -/* - * Construct an AST_Sequence node (a sequence type definition) - */ -AST_Sequence * -AST_Generator::create_sequence(AST_Expression *ms, - AST_Type *bt, - idl_bool local, - idl_bool abstract) +// Construct an AST_EnumVal node (an enumerator). +AST_EnumVal * +AST_Generator::create_enum_val (unsigned long v, + UTL_ScopedName *n, + UTL_StrList *p) +{ + AST_EnumVal *retval = 0; + ACE_NEW_RETURN (retval, + AST_EnumVal (v, + n, + p), + 0); + + return retval; +} + +// Construct an AST_Array node (an array type or field modifier). +AST_Array * +AST_Generator::create_array (UTL_ScopedName *n, + unsigned long ndims, + UTL_ExprList *dims, + idl_bool local, + idl_bool abstract) +{ + AST_Array *retval = 0; + ACE_NEW_RETURN (retval, + AST_Array (n, + ndims, + dims, + local, + abstract), + 0); + + return retval; +} + +// Construct an AST_Sequence node (a sequence type definition). +AST_Sequence * +AST_Generator::create_sequence (AST_Expression *ms, + AST_Type *bt, + idl_bool local, + idl_bool abstract) { - return new AST_Sequence(ms, bt, local, abstract); + AST_Sequence *retval = 0; + ACE_NEW_RETURN (retval, + AST_Sequence (ms, + bt, + local, + abstract), + 0); + + return retval; } -/* - * Construct an AST_String node (a string type definition) - */ -AST_String * -AST_Generator::create_string(AST_Expression *ms) +// Construct an AST_String node (a string type definition). +AST_String * +AST_Generator::create_string (AST_Expression *ms) { - return new AST_String(ms); + AST_String *retval = 0; + ACE_NEW_RETURN (retval, + AST_String (ms), + 0); + + return retval; } -/* - * Construct an AST_String node denoting a wide string type definition - */ +// Construct an AST_String node denoting a wide string type definition. AST_String * -AST_Generator::create_wstring(AST_Expression *ms) +AST_Generator::create_wstring (AST_Expression *ms) { - return new AST_String(ms, sizeof(ACE_OS::WChar)); + AST_String *retval = 0; + ACE_NEW_RETURN (retval, + AST_String (ms, + sizeof(ACE_OS::WChar)), + 0); + + return retval; } -/* - * Construct an AST_Typedef node (a typedef) - */ -AST_Typedef * -AST_Generator::create_typedef(AST_Type *bt, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract) +// Construct an AST_Typedef node (a typedef). +AST_Typedef * +AST_Generator::create_typedef (AST_Type *bt, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract) { - return new AST_Typedef(bt, n, p, local, abstract); + AST_Typedef *retval = 0; + ACE_NEW_RETURN (retval, + AST_Typedef (bt, + n, + p, + local, + abstract), + 0); + + return retval; } -/* - * Construct an AST_Native node - */ +// Construct an AST_Native node. AST_Native * AST_Generator::create_native (UTL_ScopedName *n, UTL_StrList *p) { - return new AST_Native (n, p); + AST_Native *retval = 0; + ACE_NEW_RETURN (retval, + AST_Native (n, + p), + 0); + + return retval; } + diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index 6678ad66144..db62e6ac95d 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -62,31 +62,26 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_interface.cc - Implementation of class AST_Interface - * - * AST_Interfaces denote IDL interface definitions - * AST_Interfaces are subclasses of AST_Type and UTL_Scope - * AST_Interfaces have an array of inherited interfaces and - * a count of the number of inherited interfaces. This count - * represents the total number of unique (recursively) inherited - * interfaces. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Interfaces denote IDL interface definitions +// AST_Interfaces are subclasses of AST_Type and UTL_Scope +// AST_Interfaces have an array of inherited interfaces and +// a count of the number of inherited interfaces. This count +// represents the total number of unique (recursively) inherited +// interfaces. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_interface, "$Id$") -/* - * Constructor(s) and destructor - */ +// Constructor(s) and destructor. + AST_Interface::AST_Interface (void) - : pd_inherits (NULL), + : pd_inherits (0), pd_n_inherits (0), - pd_inherits_flat (NULL), + pd_inherits_flat (0), pd_n_inherits_flat (0) { } @@ -99,9 +94,12 @@ AST_Interface::AST_Interface(UTL_ScopedName *n, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl (AST_Decl::NT_interface, n, p), + : AST_Decl (AST_Decl::NT_interface, + n, + p), UTL_Scope (AST_Decl::NT_interface), - COMMON_Base (local, abstract), + COMMON_Base (local, + abstract), pd_inherits (ih), pd_n_inherits (nih), pd_inherits_flat (ih_flat), @@ -113,34 +111,31 @@ AST_Interface::~AST_Interface (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ - +// Public operations -idl_bool AST_Interface::is_valuetype (void) +idl_bool +AST_Interface::is_valuetype (void) { return 0; } -idl_bool AST_Interface::is_abstract_valuetype (void) +idl_bool +AST_Interface::is_abstract_valuetype (void) { return 0; } -void AST_Interface::set_abstract_valuetype (void) +void +AST_Interface::set_abstract_valuetype (void) { ACE_ASSERT (0); } -void AST_Interface::be_replace_operation (AST_Decl *old_op, - AST_Decl *new_op) +void +AST_Interface::be_replace_operation (AST_Decl *old_op, + AST_Decl *new_op) { replace_scope (old_op, new_op); @@ -149,158 +144,140 @@ void AST_Interface::be_replace_operation (AST_Decl *old_op, new_op); } -void AST_Interface::be_add_operation (AST_Operation *op) +void +AST_Interface::be_add_operation (AST_Operation *op) { fe_add_operation (op); } -/* - * Redefinition of inherited virtual operations - */ - -/* - * Add an AST_Constant node (a constant declaration) to this scope - */ -AST_Constant *AST_Interface::fe_add_constant (AST_Constant *t) +// Add an AST_Constant node (a constant declaration) to this scope. +AST_Constant * +AST_Interface::fe_add_constant (AST_Constant *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor(d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Exception node (an exception declaration) to this scope - */ -AST_Exception *AST_Interface::fe_add_exception (AST_Exception *t) +// Add an AST_Exception node (an exception declaration) to this scope. +AST_Exception * +AST_Interface::fe_add_exception (AST_Exception *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Attribute node (an attribute declaration) to this scope - */ -AST_Attribute *AST_Interface::fe_add_attribute (AST_Attribute *t) +// Add an AST_Attribute node (an attribute declaration) to this scope. +AST_Attribute * +AST_Interface::fe_add_attribute (AST_Attribute *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } /* * Already defined and cannot be redefined? Or already used? */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { @@ -308,7 +285,7 @@ AST_Attribute *AST_Interface::fe_add_attribute (AST_Attribute *t) t, this, d); - return NULL; + return 0; } if (referenced (d, t->local_name ())) @@ -317,43 +294,38 @@ AST_Attribute *AST_Interface::fe_add_attribute (AST_Attribute *t) t, this, d); - return NULL; + return 0; } if (t->has_ancestor(d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } - -/* - * Add this AST_Field node (a field declaration) to this scope - * (only for valuetypes) - */ -AST_Field *AST_Interface::fe_add_field (AST_Field *t) +// Add this AST_Field node (a field declaration) to this scope +// (only for valuetypes). +AST_Field * +AST_Interface::fe_add_field (AST_Field *t) { #ifdef IDL_HAS_VALUETYPE - AST_Decl *d; - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { @@ -361,35 +333,33 @@ AST_Field *AST_Interface::fe_add_field (AST_Field *t) t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; @@ -399,150 +369,133 @@ AST_Field *AST_Interface::fe_add_field (AST_Field *t) #endif /* IDL_HAS_VALUETYPE */ } - -/* - * Add an AST_Operation node (an operation declaration) to this scope - */ -AST_Operation *AST_Interface::fe_add_operation(AST_Operation *t) +// Add an AST_Operation node (an operation declaration) to this scope. +AST_Operation * +AST_Interface::fe_add_operation(AST_Operation *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Structure (a struct declaration) to this scope - */ -AST_Structure *AST_Interface::fe_add_structure (AST_Structure *t) +// Add an AST_Structure (a struct declaration) to this scope. +AST_Structure * +AST_Interface::fe_add_structure (AST_Structure *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, - d); - return NULL; + d); + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Enum node (an enum declaration) to this scope - */ -AST_Enum *AST_Interface::fe_add_enum (AST_Enum *t) +// Add an AST_Enum node (an enum declaration) to this scope. +AST_Enum * +AST_Interface::fe_add_enum (AST_Enum *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; - } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + return 0; + } + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { @@ -550,185 +503,167 @@ AST_Enum *AST_Interface::fe_add_enum (AST_Enum *t) t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Union (a union declaration) to this scope - */ -AST_Union *AST_Interface::fe_add_union (AST_Union *t) +// Add an AST_Union (a union declaration) to this scope. +AST_Union * +AST_Interface::fe_add_union (AST_Union *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_EnumVal node (an enumerator) to this scope. - * This is done to conform to the C++ scoping rules which declare - * enumerators in the enclosing scope (in addition to declaring them - * in the enum itself) - */ -AST_EnumVal *AST_Interface::fe_add_enum_val (AST_EnumVal *t) +// Add an AST_EnumVal node (an enumerator) to this scope. +// This is done to conform to the C++ scoping rules which declare +// enumerators in the enclosing scope (in addition to declaring them +// in the enum itself). +AST_EnumVal * +AST_Interface::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { - if (!can_be_redefined(d)) + if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } - if (t->has_ancestor(d)) + if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Typedef (a typedef) to the current scope - */ -AST_Typedef *AST_Interface::fe_add_typedef(AST_Typedef *t) +// Add an AST_Typedef (a typedef) to the current scope. +AST_Typedef * +AST_Interface::fe_add_typedef (AST_Typedef *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { @@ -736,137 +671,134 @@ AST_Typedef *AST_Interface::fe_add_typedef(AST_Typedef *t) t, this, d); - return NULL; + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Native (a native declaration) to this scope - */ -AST_Native *AST_Interface::fe_add_native (AST_Native *t) +// Add an AST_Native (a native declaration) to this scope. +AST_Native * +AST_Interface::fe_add_native (AST_Native *t) { - AST_Decl *d; + AST_Decl *d = 0; - /* - * Can't add to interface which was not yet defined - */ - if (!is_defined ()) + // Can't add to interface which was not yet defined. + if (!this->is_defined ()) { idl_global->err ()->error2 (UTL_Error::EIDL_DECL_NOT_DEFINED, this, t); - return NULL; + return 0; } - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add (t, I_FALSE)) != NULL) + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) { if (!can_be_redefined (d)) { idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, t, - this, - d); - return NULL; + this, + d); + return 0; } - if (referenced (d, t->local_name ())) + if (this->referenced (d, t->local_name ())) { idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + return 0; } if (t->has_ancestor (d)) { idl_global->err ()->redefinition_in_scope (t, d); - return NULL; + return 0; } } - /* - * Add it to scope - */ - add_to_scope (t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced (t, - I_FALSE, - t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Interface node to the ostream o - */ +// Dump this AST_Interface node to the ostream o. void AST_Interface::dump (ostream &o) { - long i; - if (this->is_valuetype ()) { if (this->is_abstract_valuetype ()) - o << "abstract "; + { + o << "abstract "; + } o << "valuetype "; } else { if (this->is_abstract ()) - o << "abstract "; + { + o << "abstract "; + } else if (this->is_local ()) - o << "local "; + { + o << "local "; + } + o << "interface "; } - local_name ()->dump (o); + this->local_name ()->dump (o); o << " "; - if (pd_n_inherits > 0) + if (this->pd_n_inherits > 0) { o << ": "; - for (i = 0; i < pd_n_inherits; i++) + for (long i = 0; i < this->pd_n_inherits; i++) { - pd_inherits[i]->local_name( )->dump (o); + this->pd_inherits[i]->local_name ()->dump (o); - if (i < pd_n_inherits - 1) - o << ", "; + if (i < this->pd_n_inherits - 1) + { + o << ", "; + } } } @@ -883,11 +815,12 @@ AST_Interface::fwd_redefinition_helper (AST_Interface *&i, { // Fwd redefinition should be in the same scope, so local // lookup is all that's needed. - AST_Decl *d = s->lookup_by_name_local (i->local_name (), 0); + AST_Decl *d = s->lookup_by_name_local (i->local_name (), + 0); - AST_Interface *fd = NULL; + AST_Interface *fd = 0; - if (i != NULL && d != NULL) + if (i != NULL && d != 0) { // See if we're defining a forward declared interface. if (d->node_type () == AST_Decl::NT_interface) @@ -896,17 +829,17 @@ AST_Interface::fwd_redefinition_helper (AST_Interface *&i, fd = AST_Interface::narrow_from_decl (d); // Successful? - if (fd == NULL) + if (fd == 0) { - // Should we give an error here? ... no, look in fe_add_interface + // Should we give an error here? + // No, look in fe_add_interface. } - // If it is a forward declared interface.. else if (!fd->is_defined ()) { // Check if redefining in same scope. If a module is reopened, - // a new pointer in created, and the first term below will be true. - // In that case, the scoped names must be compared. + // a new pointer in created, and the first term below will be + // true. In that case, the scoped names must be compared. if (fd->defined_in () != s && !AST_Interface::compare_names (fd, i)) @@ -915,20 +848,18 @@ AST_Interface::fwd_redefinition_helper (AST_Interface *&i, i, fd); } - - // All OK, do the redefinition + // All OK, do the redefinition. else { - - // only redefinition of the same kind - if ((i->is_local () != fd->is_local ()) + // Only redefinition of the same kind. + if (i->is_local () != fd->is_local () # ifdef IDL_HAS_VALUETYPE - ||(i->is_valuetype () != fd->is_valuetype ()) - || (i->is_abstract_valuetype () != fd->is_abstract_valuetype ()) - || (i->is_abstract () != fd->is_abstract ()) + || i->is_valuetype () != fd->is_valuetype () + || i->is_abstract_valuetype () != + fd->is_abstract_valuetype () + || i->is_abstract () != fd->is_abstract () # endif /* IDL_HAS_VALUETYPE */ ) - { idl_global->err ()->error2 (UTL_Error::EIDL_REDEF, i, @@ -940,7 +871,7 @@ AST_Interface::fwd_redefinition_helper (AST_Interface *&i, fd->redefine (i, p); - // Use full definition node + // Use full definition node. delete i; i = fd; } @@ -949,10 +880,7 @@ AST_Interface::fwd_redefinition_helper (AST_Interface *&i, } } - -/* - * Data accessors - */ +// Data accessors. void AST_Interface::redefine (AST_Interface *from, @@ -980,37 +908,37 @@ AST_Interface::redefine (AST_Interface *from, AST_Interface ** AST_Interface::inherits (void) { - return pd_inherits; + return this->pd_inherits; } void AST_Interface::set_inherits (AST_Interface **i) { - pd_inherits = i; + this->pd_inherits = i; } long AST_Interface::n_inherits (void) { - return pd_n_inherits; + return this->pd_n_inherits; } void AST_Interface::set_n_inherits (long i) { - pd_n_inherits = i; + this->pd_n_inherits = i; } AST_Interface ** AST_Interface::inherits_flat (void) { - return pd_inherits_flat; + return this->pd_inherits_flat; } void AST_Interface::set_inherits_flat (AST_Interface **i) { - pd_inherits_flat = i; + this->pd_inherits_flat = i; } long @@ -1022,7 +950,7 @@ AST_Interface::n_inherits_flat (void) void AST_Interface::set_n_inherits_flat (long i) { - pd_n_inherits_flat = i; + this->pd_n_inherits_flat = i; } // Get the scoped names and, if they are the same @@ -1044,10 +972,15 @@ AST_Interface::compare_names (AST_Interface *that, Identifier *that_id = 0; Identifier *other_id = 0; - UTL_IdListActiveIterator *that_iter = - new UTL_IdListActiveIterator (that_name); - UTL_IdListActiveIterator *other_iter = - new UTL_IdListActiveIterator (other_name); + UTL_IdListActiveIterator *that_iter = 0; + ACE_NEW_RETURN (that_iter, + UTL_IdListActiveIterator (that_name), + I_FALSE); + + UTL_IdListActiveIterator *other_iter = 0; + ACE_NEW_RETURN (other_iter, + UTL_IdListActiveIterator (other_name), + I_FALSE); for (int i = 0; i < that_length; i++) { @@ -1072,28 +1005,32 @@ AST_Interface::compare_names (AST_Interface *that, } void -AST_Interface::inherited_name_clash () +AST_Interface::inherited_name_clash (void) { - AST_Decl *my_member, *parent1_member, *parent2_member; + AST_Decl *my_member = 0; + AST_Decl *parent1_member = 0; + AST_Decl *parent2_member = 0; // Compare our members with those of each parent. - UTL_ScopeActiveIterator *my_members = - new UTL_ScopeActiveIterator (DeclAsScope (this), - UTL_Scope::IK_decls); + UTL_ScopeActiveIterator *my_members = 0; + ACE_NEW (my_members, + UTL_ScopeActiveIterator (DeclAsScope (this), + UTL_Scope::IK_decls)); - while (!(my_members->is_done ())) + while (!my_members->is_done ()) { my_member = my_members->item (); Identifier *id = my_member->local_name (); for (int i = 0; i < this->pd_n_inherits_flat; i ++) { - UTL_ScopeActiveIterator *parent_members = - new UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), - UTL_Scope::IK_decls); + UTL_ScopeActiveIterator *parent_members = 0; + ACE_NEW (parent_members, + UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), + UTL_Scope::IK_decls)); - while (!(parent_members->is_done ())) + while (!parent_members->is_done ()) { parent1_member = parent_members->item (); AST_Decl::NodeType nt = parent1_member->node_type (); @@ -1146,11 +1083,12 @@ AST_Interface::inherited_name_clash () for (int i = 0; i < this->pd_n_inherits_flat - 1; i++) { - UTL_ScopeActiveIterator *parent1_members = - new UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), - UTL_Scope::IK_decls); + UTL_ScopeActiveIterator *parent1_members = 0; + ACE_NEW (parent1_members, + UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), + UTL_Scope::IK_decls)); - while (!(parent1_members->is_done ())) + while (!parent1_members->is_done ()) { parent1_member = parent1_members->item (); AST_Decl::NodeType nt1 = parent1_member->node_type (); @@ -1163,13 +1101,14 @@ AST_Interface::inherited_name_clash () for (int j = i + 1; j < this->pd_n_inherits_flat; j++) { - UTL_ScopeActiveIterator *parent2_members = - new UTL_ScopeActiveIterator ( - DeclAsScope (pd_inherits_flat[j]), - UTL_Scope::IK_decls - ); - - while (!(parent2_members->is_done ())) + UTL_ScopeActiveIterator *parent2_members = 0; + ACE_NEW (parent2_members, + UTL_ScopeActiveIterator ( + DeclAsScope (pd_inherits_flat[j]), + UTL_Scope::IK_decls + )); + + while (!parent2_members->is_done ()) { parent2_member = parent2_members->item (); AST_Decl::NodeType nt2 = @@ -1232,9 +1171,7 @@ AST_Interface::destroy (void) { } -/* - * Narrowing methods - */ +// Narrowing methods. IMPL_NARROW_METHODS2(AST_Interface, AST_Type, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Interface) IMPL_NARROW_FROM_SCOPE(AST_Interface) diff --git a/TAO/TAO_IDL/ast/ast_operation.cpp b/TAO/TAO_IDL/ast/ast_operation.cpp index 064b54c8053..6172e8edbe7 100644 --- a/TAO/TAO_IDL/ast/ast_operation.cpp +++ b/TAO/TAO_IDL/ast/ast_operation.cpp @@ -62,35 +62,32 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_operation.cc - Implementation of class AST_Operation - * - * AST_Operation nodes denote IDL operation declarations - * AST_Operations are a subclass of AST_Decl (they are not a type!) - * and of UTL_Scope (the arguments are managed in a scope). - * AST_Operations have a return type (a subclass of AST_Type), - * a bitfield for denoting various properties of the operation (the - * values are ORed together from constants defined in the enum - * AST_Operation::FLags), a name (a UTL_ScopedName), a context - * (implemented as a list of Strings, a UTL_StrList), and a raises - * clause (implemented as an array of AST_Exceptions). - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Operation nodes denote IDL operation declarations +// AST_Operations are a subclass of AST_Decl (they are not a type!) +// and of UTL_Scope (the arguments are managed in a scope). +// AST_Operations have a return type (a subclass of AST_Type), +// a bitfield for denoting various properties of the operation (the +// values are ORed together from constants defined in the enum +// AST_Operation::FLags), a name (a UTL_ScopedName), a context +// (implemented as a list of Strings, a UTL_StrList), and a raises +// clause (implemented as an array of AST_Exceptions). + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_operation, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Operation::AST_Operation () - : pd_return_type(NULL), - pd_flags(OP_noflags), - pd_context(NULL), - pd_exceptions(NULL) +// Constructor(s) and destructor. + +AST_Operation::AST_Operation (void) + : pd_return_type (0), + pd_flags (OP_noflags), + pd_context (0), + pd_exceptions( 0), + argument_count_ (-1), + has_native_ (0) { } @@ -100,53 +97,138 @@ AST_Operation::AST_Operation (AST_Type *rt, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl(AST_Decl::NT_op, n, p), + : AST_Decl(AST_Decl::NT_op, + n, + p), UTL_Scope(AST_Decl::NT_op), - COMMON_Base (local, abstract), - pd_return_type(rt), - pd_flags(fl), - pd_context(NULL), - pd_exceptions(NULL) + COMMON_Base (local, + abstract), + pd_return_type (rt), + pd_flags (fl), + pd_context (0), + pd_exceptions (0), + argument_count_ (-1), + has_native_ (0) { - AST_PredefinedType *pdt; - - /* - * Check that if the operation is oneway, the return type must be void - */ - if (rt != NULL && pd_flags == OP_oneway) { - if (rt->node_type() != AST_Decl::NT_pre_defined) - idl_global->err()->error1(UTL_Error::EIDL_NONVOID_ONEWAY, this); - else { - pdt = AST_PredefinedType::narrow_from_decl(rt); - if (pdt == NULL || pdt->pt() != AST_PredefinedType::PT_void) - idl_global->err()->error1(UTL_Error::EIDL_NONVOID_ONEWAY, this); + AST_PredefinedType *pdt = 0; + + // Check that if the operation is oneway, the return type must be void. + if (rt != 0 && pd_flags == OP_oneway) + { + if (rt->node_type () != AST_Decl::NT_pre_defined) + { + idl_global->err ()->error1 (UTL_Error::EIDL_NONVOID_ONEWAY, + this); + } + else + { + pdt = AST_PredefinedType::narrow_from_decl (rt); + + if (pdt == 0 || pdt->pt () != AST_PredefinedType::PT_void) + { + idl_global->err ()->error1 (UTL_Error::EIDL_NONVOID_ONEWAY, + this); + } + } } - } } AST_Operation::~AST_Operation (void) { } -/* - * Private operations - */ +// Public operations. -/* - * Public operations - */ +// Return the member count. +int +AST_Operation::argument_count (void) +{ + this->compute_argument_attr (); -/* - * Redefinition of inherited virtual operations - */ + return this->argument_count_; +} -/* - * Add this context (a UTL_StrList) to this scope - */ +// Return if any argument or the return type is a <native> type. +int +AST_Operation::has_native (void) +{ + this->compute_argument_attr (); + + return this->has_native_; +} + +void +AST_Operation::destroy (void) +{ +} + +// Private operations. + +// Compute total number of members. +int +AST_Operation::compute_argument_attr (void) +{ + if (this->argument_count_ != -1) + { + return 0; + } + + AST_Decl *d = 0; + AST_Type *type = 0; + AST_Argument *arg = 0; + + this->argument_count_ = 0; + + // If there are elements in this scope. + if (this->nmembers () > 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. + d = si->item (); + + if (d->node_type () == AST_Decl::NT_argument) + { + this->argument_count_++; + + arg = AST_Argument::narrow_from_decl (d); + + type = AST_Type::narrow_from_decl (arg->field_type ()); + + if (type->node_type () == AST_Decl::NT_native) + { + this->has_native_ = 1; + } + } + + si->next (); + } + + delete si; + } + + type = AST_Type::narrow_from_decl (this->return_type ()); + + if (type->node_type () == AST_Decl::NT_native) + { + this->has_native_ = 1; + } + + return 0; +} + +// Add this context (a UTL_StrList) to this scope. UTL_StrList * -AST_Operation::fe_add_context(UTL_StrList *t) +AST_Operation::fe_add_context (UTL_StrList *t) { - pd_context = t; + this->pd_context = t; return t; } @@ -154,205 +236,270 @@ AST_Operation::fe_add_context(UTL_StrList *t) UTL_ExceptList * AST_Operation::be_add_exceptions (UTL_ExceptList *t) { - if (pd_exceptions) - idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES, this); + if (this->pd_exceptions != 0) + { + idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES, + this); + } else - pd_exceptions = t; + { + this->pd_exceptions = t; + } - return pd_exceptions; + return this->pd_exceptions; } -/* - * Add these exceptions (identified by name) to this scope. - * This looks up each name to resolve it to the name of a known - * exception, and then adds the referenced exception to the list - * of exceptions that this operation can raise. - * - * NOTE: No attempt is made to ensure that exceptions are mentioned - * only once.. - */ +// Add these exceptions (identified by name) to this scope. +// This looks up each name to resolve it to the name of a known +// exception, and then adds the referenced exception to the list +// exceptions that this operation can raise. + +// NOTE: No attempt is made to ensure that exceptions are mentioned +// only once.. UTL_NameList * -AST_Operation::fe_add_exceptions(UTL_NameList *t) +AST_Operation::fe_add_exceptions (UTL_NameList *t) { - UTL_NamelistActiveIterator *nl_i; - UTL_ScopedName *nl_n; - UTL_Scope *fs = idl_global->scopes()->top(); - AST_Exception *fe; - AST_Decl *d; - - // Macro to avoid "warning: unused parameter" type warning. - ACE_UNUSED_ARG (fs); - - pd_exceptions = NULL; - nl_i = new UTL_NamelistActiveIterator(t); - while (!(nl_i->is_done())) { - nl_n = nl_i->item(); - d = lookup_by_name(nl_n, I_TRUE); - if (d == NULL || d->node_type() != AST_Decl::NT_except) { - idl_global->err()->lookup_error(nl_n); - delete nl_i; - return NULL; + UTL_NamelistActiveIterator *nl_i = 0; + UTL_ScopedName *nl_n = 0; + AST_Exception *fe = 0; + AST_Decl *d = 0; + + this->pd_exceptions = 0; + + ACE_NEW_RETURN (nl_i, + UTL_NamelistActiveIterator(t), + 0); + + while (!nl_i->is_done()) + { + nl_n = nl_i->item (); + + d = lookup_by_name (nl_n, + I_TRUE); + + if (d == 0 || d->node_type() != AST_Decl::NT_except) + { + idl_global->err ()->lookup_error (nl_n); + delete nl_i; + return 0; + } + + fe = AST_Exception::narrow_from_decl (d); + + if ((this->flags () == AST_Operation::OP_oneway) && fe) + { + idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES, + this); + } + + if (fe == 0) + { + idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES, + this); + return 0; + } + + if (this->pd_exceptions == 0) + { + ACE_NEW_RETURN (this->pd_exceptions, + UTL_ExceptList (fe, + 0), + 0); + } + else + { + UTL_ExceptList *el = 0; + ACE_NEW_RETURN (el, + UTL_ExceptList (fe, + 0), + 0); + + this->pd_exceptions->nconc (el); + } + + nl_i->next (); } - fe = AST_Exception::narrow_from_decl(d); - if ((this->flags () == AST_Operation::OP_oneway) && fe) - idl_global->err ()->error1 (UTL_Error::EIDL_ILLEGAL_RAISES, this); - if (fe == NULL) { - idl_global->err()->error1(UTL_Error::EIDL_ILLEGAL_RAISES, this); - return NULL; - } - if (pd_exceptions == NULL) - pd_exceptions = new UTL_ExceptList(fe, NULL); - else - pd_exceptions->nconc(new UTL_ExceptList(fe, NULL)); - nl_i->next(); - } delete nl_i; - return t; } -/* - * Add this AST_Argument node (an operation argument declaration) - * to this scope - */ -AST_Argument *AST_Operation::fe_add_argument(AST_Argument *t) +// Add this AST_Argument node (an operation argument declaration) +// to this scope. +AST_Argument * +AST_Operation::fe_add_argument (AST_Argument *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_by_name_local(t->local_name(), 0)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_by_name_local (t->local_name(), 0)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + + // Cannot add OUT or INOUT argument to oneway operation. + if ((t->direction () == AST_Argument::dir_OUT + || t->direction() == AST_Argument::dir_INOUT) + && pd_flags == OP_oneway) + { + idl_global->err ()->error2 (UTL_Error::EIDL_ONEWAY_CONFLICT, + t, + this); + return 0; } - } - /* - * Cannot add OUT or INOUT argument to oneway operation - */ - if ((t->direction() == AST_Argument::dir_OUT || - t->direction() == AST_Argument::dir_INOUT) && - pd_flags == OP_oneway) { - idl_global->err()->error2(UTL_Error::EIDL_ONEWAY_CONFLICT, t, this); - return NULL; - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Operation node (an operation) to the ostream o - */ +// Dump this AST_Operation node (an operation) to the ostream o. void -AST_Operation::dump(ostream &o) +AST_Operation::dump (ostream &o) { - UTL_ScopeActiveIterator *i; - UTL_StrlistActiveIterator *si; - UTL_ExceptlistActiveIterator *ei; - AST_Decl *d; - AST_Exception *e; - UTL_String *s; - - if (pd_flags == OP_oneway) - o << "oneway "; - else if (pd_flags == OP_idempotent) - o << "idempotent "; - - i = new UTL_ScopeActiveIterator(this, IK_decls); - pd_return_type->name()->dump(o); + UTL_ScopeActiveIterator *i = 0; + UTL_StrlistActiveIterator *si = 0; + UTL_ExceptlistActiveIterator *ei = 0; + AST_Decl *d = 0; + AST_Exception *e = 0; + UTL_String *s = 0; + + if (this->pd_flags == OP_oneway) + { + o << "oneway "; + } + else if (this->pd_flags == OP_idempotent) + { + o << "idempotent "; + } + + ACE_NEW (i, + UTL_ScopeActiveIterator (this, + IK_decls)); + + this->pd_return_type->name ()->dump (o); o << " "; - local_name()->dump(o); + this->local_name ()->dump (o); o << "("; - while (!(i->is_done())) { - d = i->item(); - d->dump(o); - i->next(); - if (!(i->is_done())) - o << ", "; - } + + while (!i->is_done()) + { + d = i->item (); + d->dump (o); + i->next (); + + if (!i->is_done()) + { + o << ", "; + } + } + delete i; o << ")"; - if (pd_exceptions != NULL) { - o << " raises("; - ei = new UTL_ExceptlistActiveIterator(pd_exceptions); - while (!(ei->is_done())) { - e = ei->item(); - ei->next(); - e->local_name()->dump(o); - if (!(ei->is_done())) - o << ", "; - } - delete ei; - o << ")"; - } - if (pd_context != NULL) { - o << " context("; - si = new UTL_StrlistActiveIterator(pd_context); - while (!(si->is_done())) { - s = si->item(); - si->next(); - o << s->get_string(); - if (!(si->is_done())) - o << ", "; + if (this->pd_exceptions != 0) + { + o << " raises("; + + ACE_NEW (ei, + UTL_ExceptlistActiveIterator (pd_exceptions)); + + while (!ei->is_done()) + { + e = ei->item (); + ei->next (); + e->local_name ()->dump (o); + + if (!ei->is_done()) + { + o << ", "; + } + } + + delete ei; + o << ")"; } - delete si; - o << ")"; - } -} -void -AST_Operation::destroy (void) -{ + if (this->pd_context != 0) + { + o << " context("; + + ACE_NEW (si, + UTL_StrlistActiveIterator (pd_context)); + + while (!si->is_done()) + { + s = si->item (); + si->next (); + o << s->get_string (); + + if (!si->is_done()) + { + o << ", "; + } + } + + delete si; + o << ")"; + } } -/* - * Data accessors - */ +// Data accessors AST_Type * -AST_Operation::return_type() +AST_Operation::return_type (void) { - return pd_return_type; + return this->pd_return_type; } AST_Operation::Flags -AST_Operation::flags() +AST_Operation::flags (void) { - return pd_flags; + return this->pd_flags; } UTL_StrList * -AST_Operation::context() +AST_Operation::context (void) { - return pd_context; + return this->pd_context; } UTL_ExceptList * -AST_Operation::exceptions() +AST_Operation::exceptions (void) { - return pd_exceptions; + return this->pd_exceptions; } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS2(AST_Operation, AST_Decl, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Operation) IMPL_NARROW_FROM_SCOPE(AST_Operation) diff --git a/TAO/TAO_IDL/ast/ast_predefined_type.cpp b/TAO/TAO_IDL/ast/ast_predefined_type.cpp index 4de85b318fd..6b5c0ec3e56 100644 --- a/TAO/TAO_IDL/ast/ast_predefined_type.cpp +++ b/TAO/TAO_IDL/ast/ast_predefined_type.cpp @@ -62,37 +62,33 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_predefined_type.cc - Implementation of class AST_PredefinedType - * - * AST_PredefinedType nodes denote the various predefined types such - * as long, short, etc. that are available in IDL. Each AST_PredefinedType - * node has a field (the value of this field is from the enum - * AST_PredefinedType::PredefinedType) which denotes the specific predefined - * type that this node represents. There is only one node in the entire - * AST which represents each predefined type, such as long etc. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_PredefinedType nodes denote the various predefined types such +// as long, short, etc. that are available in IDL. Each AST_PredefinedType +// node has a field (the value of this field is from the enum +// AST_PredefinedType::PredefinedType) which denotes the specific predefined +// type that this node represents. There is only one node in the entire +// AST which represents each predefined type, such as long etc. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_predefined_type, "$Id$") -/* - * Constructor(s) - */ -AST_PredefinedType::AST_PredefinedType () - : pd_pt(PT_long) +// Constructor(s). +AST_PredefinedType::AST_PredefinedType (void) + : pd_pt (PT_long) { } AST_PredefinedType::AST_PredefinedType (PredefinedType t, UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl(AST_Decl::NT_pre_defined, n, p), - pd_pt(t) + : AST_Decl (AST_Decl::NT_pre_defined, + n, + p), + pd_pt (t) { } @@ -100,38 +96,23 @@ AST_PredefinedType::~AST_PredefinedType (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ +// Redefinition of inherited virtual operations. - -/* - * Redefinition of inherited virtual operations - */ - -/* - * Dump this AST_PredefinedType node to the ostream o - */ +// Dump this AST_PredefinedType node to the ostream o. void -AST_PredefinedType::dump(ostream &o) +AST_PredefinedType::dump (ostream &o) { - AST_Decl::dump(o); + AST_Decl::dump (o); } -/* - * Data accessors - */ +// Data accessors. AST_PredefinedType::PredefinedType -AST_PredefinedType::pt() +AST_PredefinedType::pt (void) { - return pd_pt; + return this->pd_pt; } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS1(AST_PredefinedType, AST_ConcreteType) IMPL_NARROW_FROM_DECL(AST_PredefinedType) diff --git a/TAO/TAO_IDL/ast/ast_redef.cpp b/TAO/TAO_IDL/ast/ast_redef.cpp index 743fe52f677..943d507e64e 100644 --- a/TAO/TAO_IDL/ast/ast_redef.cpp +++ b/TAO/TAO_IDL/ast/ast_redef.cpp @@ -62,50 +62,44 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_redef.cc - Implement utility function to decide when redefinition - * is allowed - */ - -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_redef, "$Id$") -/* - * Return TRUE if the node d represents an IDL construct whose name - * can be redefined. - */ +// Return TRUE if the node d represents an IDL construct whose name +// can be redefined. idl_bool -can_be_redefined(AST_Decl *d) +can_be_redefined (AST_Decl *d) { - switch (d->node_type()) { - case AST_Decl::NT_module: - case AST_Decl::NT_interface: - case AST_Decl::NT_interface_fwd: - case AST_Decl::NT_const: - case AST_Decl::NT_except: - case AST_Decl::NT_argument: - case AST_Decl::NT_enum_val: - case AST_Decl::NT_string: - case AST_Decl::NT_wstring: - case AST_Decl::NT_array: - case AST_Decl::NT_sequence: - case AST_Decl::NT_union: - case AST_Decl::NT_struct: - case AST_Decl::NT_enum: - case AST_Decl::NT_typedef: - return I_TRUE; - - case AST_Decl::NT_union_branch: - case AST_Decl::NT_field: - case AST_Decl::NT_attr: - case AST_Decl::NT_op: - case AST_Decl::NT_pre_defined: - default: - return I_FALSE; - } + switch (d->node_type ()) + { + case AST_Decl::NT_module: + case AST_Decl::NT_interface: + case AST_Decl::NT_interface_fwd: + case AST_Decl::NT_const: + case AST_Decl::NT_except: + case AST_Decl::NT_argument: + case AST_Decl::NT_enum_val: + case AST_Decl::NT_string: + case AST_Decl::NT_wstring: + case AST_Decl::NT_array: + case AST_Decl::NT_sequence: + case AST_Decl::NT_union: + case AST_Decl::NT_struct: + case AST_Decl::NT_enum: + case AST_Decl::NT_typedef: + return I_TRUE; + + case AST_Decl::NT_union_branch: + case AST_Decl::NT_field: + case AST_Decl::NT_attr: + case AST_Decl::NT_op: + case AST_Decl::NT_pre_defined: + default: + return I_FALSE; + } } diff --git a/TAO/TAO_IDL/ast/ast_sequence.cpp b/TAO/TAO_IDL/ast/ast_sequence.cpp index c4d28152312..203621866a8 100644 --- a/TAO/TAO_IDL/ast/ast_sequence.cpp +++ b/TAO/TAO_IDL/ast/ast_sequence.cpp @@ -62,29 +62,23 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_sequence.cc - Implementation of class AST_Sequence - * - * AST_Sequence nodes represent IDL sequence declarations. - * AST_Sequence is a subclass of AST_ConcreteType. - * AST_Sequence nodes have a maximum size (an AST_Expression which - * must evaluate to a positive integer) and a base type (a subclass - * of AST_Type). - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Sequence nodes represent IDL sequence declarations. +// AST_Sequence is a subclass of AST_ConcreteType. +// AST_Sequence nodes have a maximum size (an AST_Expression which +// must evaluate to a positive integer) and a base type (a subclass +// of AST_Type). + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_sequence, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Sequence::AST_Sequence () - : pd_max_size(0), - pd_base_type(NULL) +// Constructor(s) and destructor. +AST_Sequence::AST_Sequence (void) + : pd_max_size (0), + pd_base_type (0) { } @@ -93,61 +87,105 @@ AST_Sequence::AST_Sequence (AST_Expression *ms, idl_bool local, idl_bool abstract) : AST_Decl(AST_Decl::NT_sequence, - new UTL_ScopedName (new Identifier ("sequence", 1, 0, I_FALSE), - NULL), - NULL), - COMMON_Base (bt->is_local () || local, - abstract), - pd_max_size(ms), - pd_base_type(bt) + new UTL_ScopedName (new Identifier ("sequence", + 1, + 0, + I_FALSE), + 0), + 0), + COMMON_Base (bt->is_local () || local, + abstract), + pd_max_size (ms), + pd_base_type (bt) { + // Check if we are bounded or unbounded. An expression value of 0 means + // unbounded. + if (ms->ev ()->u.ulval == 0) + { + this->unbounded_ = I_TRUE; + } + else + { + this->unbounded_ = I_FALSE; + } } AST_Sequence::~AST_Sequence (void) { } -/* - * Private operations - */ +// Public operations. -/* - * Public operations - */ +idl_bool +AST_Sequence::in_recursion (AST_Type *node) +{ + if (node == 0) + { + // There has to be a parameter + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Sequence::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad parameter node\n")), + 0); + } + + AST_Type *type = AST_Type::narrow_from_decl (this->base_type ()); + + if (!type) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Sequence::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad base type\n")), + 0); + } + + if (!ACE_OS::strcmp (node->full_name (), + type->full_name ())) + { + // They match. + return 1; + } + else + { + // Not in recursion. + return 0; + } +} -/* - * Redefinition of inherited virtual operations - */ +// Redefinition of inherited virtual operations. -/* - * Dump this AST_Sequence node to the ostream o - */ +// Dump this AST_Sequence node to the ostream o. void -AST_Sequence::dump(ostream &o) +AST_Sequence::dump (ostream &o) { o << "sequence <"; - pd_base_type->dump(o); + this->pd_base_type->dump (o); o << ", "; - pd_max_size->dump(o); + this->pd_max_size->dump (o); o << ">"; } -/* - * Data accessors - */ +// Data accessors. AST_Expression * -AST_Sequence::max_size() +AST_Sequence::max_size (void) { - return pd_max_size; + return this->pd_max_size; } AST_Type * -AST_Sequence::base_type() +AST_Sequence::base_type (void) +{ + return this->pd_base_type; +} + +idl_bool +AST_Sequence::unbounded (void) const { - return pd_base_type; + return this->unbounded_; } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS1(AST_Sequence, AST_ConcreteType) IMPL_NARROW_FROM_DECL(AST_Sequence) diff --git a/TAO/TAO_IDL/ast/ast_structure.cpp b/TAO/TAO_IDL/ast/ast_structure.cpp index 359df71621f..c56ad9eaae8 100644 --- a/TAO/TAO_IDL/ast/ast_structure.cpp +++ b/TAO/TAO_IDL/ast/ast_structure.cpp @@ -62,25 +62,19 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_structure.cc - Implementation of class AST_Structure - * - * AST_Structure nodes denote IDL struct declarations. - * AST_Structure is a subclass of AST_ConcreteType and of UTL_Scope (the - * structure's fields are managed in a scope). - */ +// AST_Structure nodes denote IDL struct declarations. +// AST_Structure is a subclass of AST_ConcreteType and of UTL_Scope (the +// structure's fields are managed in a scope). -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_structure, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Structure::AST_Structure() +// Constructor(s) and destructor. +AST_Structure::AST_Structure (void) : member_count_ (-1), local_struct_ (-1) { @@ -90,9 +84,12 @@ AST_Structure::AST_Structure (UTL_ScopedName *n, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl (AST_Decl::NT_struct, n, p), + : AST_Decl (AST_Decl::NT_struct, + n, + p), UTL_Scope (AST_Decl::NT_struct), - COMMON_Base (local, abstract), + COMMON_Base (local, + abstract), member_count_ (-1), local_struct_ (-1) { @@ -103,9 +100,12 @@ AST_Structure::AST_Structure (AST_Decl::NodeType nt, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl(nt, n, p), + : AST_Decl (nt, + n, + p), UTL_Scope(nt), - COMMON_Base (local, abstract), + COMMON_Base (local, + abstract), member_count_ (-1), local_struct_ (-1) { @@ -115,289 +115,402 @@ AST_Structure::~AST_Structure (void) { } -// compute total number of members +// Are we or the parameter node involved in any recursion? +idl_bool +AST_Structure::in_recursion (AST_Type *node) +{ + if (node == 0) + { + // We are determining the recursive status for ourselves. + node = this; + } + + // Proceed if the number of members in our scope is greater than 0. + if (this->nmembers () > 0) + { + // Initialize an iterator to iterate over our scope. + UTL_ScopeActiveIterator *si = 0; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + -1); + // Continue until each element is visited. + while (!si->is_done ()) + { + AST_Field *field = + AST_Field::narrow_from_decl (si->item ()); + + if (field == 0) + // This will be an enum value or other legitimate non-field + // member - in any case, no recursion. + { + si->next (); + continue; + } + + AST_Type *type = + AST_Type::narrow_from_decl (field->field_type ()); + + if (type == 0) + { + delete si; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Structure::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad field type\n")), + 0); + } + + if (type->in_recursion (node)) + { + delete si; + return 1; + } + + si->next (); + } + + delete si; + } + + // Not in recursion. + return 0; +} + +// Compute total number of members. int AST_Structure::compute_member_count (void) { - UTL_ScopeActiveIterator *si; // iterator - this->member_count_ = 0; - // if there are elements in this scope + // If there are elements in this scope. if (this->nmembers () > 0) { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls); - - while (!(si->is_done ())) + // Instantiate a scope iterator. + UTL_ScopeActiveIterator *si = 0; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + -1); + + while (!si->is_done ()) { this->member_count_++; si->next (); - } // end of while + } - delete si; // free the iterator object + delete si; } return 0; } -// return the member count +// Return the member count. int AST_Structure::member_count (void) { if (this->member_count_ == -1) - this->compute_member_count (); + { + this->compute_member_count (); + } return this->member_count_; } idl_bool -AST_Structure::is_local () +AST_Structure::is_local (void) { - if (this->local_struct_ == -1) - { - if (this->is_local_) + if (this->local_struct_ == -1) + { + if (this->is_local_) + { this->local_struct_ = this->is_local_; - else - { - this->local_struct_ = 0; - UTL_ScopeActiveIterator *si; // iterator - - if (this->nmembers () > 0) - { - // instantiate a scope iterator. - si = new UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls); - - while (!(si->is_done ())) - { - if (si->item ()->is_local ()) - { - this->local_struct_ = I_TRUE; - break; - } - si->next (); - } // end of while - - delete si; // free the iterator object - } - } - } - return this->local_struct_; -} - -/* - * Private operations - */ + } + else + { + this->local_struct_ = 0; + + if (this->nmembers () > 0) + { + // Instantiate a scope iterator. + UTL_ScopeActiveIterator *si = 0; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + 0); + + while (!si->is_done ()) + { + if (si->item ()->is_local ()) + { + this->local_struct_ = I_TRUE; + break; + } + + si->next (); + } + + delete si; + } + } + } -/* - * Public operations - */ + return this->local_struct_; +} -/* - * Redefinition of inherited virtual operations - */ +// Private operations. -/* - * Add this AST_Field node (a field declaration) to this scope - */ -AST_Field *AST_Structure::fe_add_field(AST_Field *t) +// Add this AST_Field node (a field declaration) to this scope. +AST_Field * +AST_Structure::fe_add_field (AST_Field *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Structure node (a manifest struct type) to this scope - */ -AST_Structure *AST_Structure::fe_add_structure(AST_Structure *t) +// Add an AST_Structure node (a manifest struct type) to this scope. +AST_Structure * +AST_Structure::fe_add_structure (AST_Structure *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add an AST_Union node (a manifest union type) to this scope - */ -AST_Union *AST_Structure::fe_add_union(AST_Union *t) +// Add an AST_Union node (a manifest union type) to this scope. +AST_Union * +AST_Structure::fe_add_union (AST_Union *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Enum node (a manifest enum declaration) to this scope - */ -AST_Enum *AST_Structure::fe_add_enum(AST_Enum *t) +// Add this AST_Enum node (a manifest enum declaration) to this scope. +AST_Enum * +AST_Structure::fe_add_enum (AST_Enum *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_EnumVal node (an enumerator declaration) to this scope. - * This is done to conform to the C++ scoping rules which declare - * enumerators in the enclosing scope (in addition to declaring them - * in the enum itself) - */ -AST_EnumVal *AST_Structure::fe_add_enum_val(AST_EnumVal *t) +// Add this AST_EnumVal node (an enumerator declaration) to this scope. +// This is done to conform to the C++ scoping rules which declare +// enumerators in the enclosing scope (in addition to declaring them +// in the enum itself). +AST_EnumVal * +AST_Structure::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Structure node to the ostream o - */ +// Dump this AST_Structure node to the ostream o. void -AST_Structure::dump(ostream &o) +AST_Structure::dump (ostream &o) { if (this->is_local ()) - o << "(local) "; + { + o << "(local) "; + } else - o << "(abstract) "; + { + o << "(abstract) "; + } o << "struct "; - AST_Decl::dump(o); + AST_Decl::dump (o); o << " {\n"; - UTL_Scope::dump(o); - idl_global->indent()->skip_to(o); + UTL_Scope::dump (o); + idl_global->indent ()->skip_to( o); o << "}"; } @@ -406,7 +519,7 @@ AST_Structure::destroy (void) { } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS2(AST_Structure, AST_ConcreteType, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Structure) IMPL_NARROW_FROM_SCOPE(AST_Structure) diff --git a/TAO/TAO_IDL/ast/ast_type.cpp b/TAO/TAO_IDL/ast/ast_type.cpp index 2cb1f996cd8..6d8dbb9e8b1 100644 --- a/TAO/TAO_IDL/ast/ast_type.cpp +++ b/TAO/TAO_IDL/ast/ast_type.cpp @@ -62,31 +62,27 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_type.cc - Implementation of class AST_Type - * - * AST_Type is the base class for all AST classes which represent - * IDL type constructs. - */ +// AST_Type is the base class for all AST classes which represent +// IDL type constructs. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_type, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Type::AST_Type () +// Constructor(s) and destructor. +AST_Type::AST_Type (void) { } AST_Type::AST_Type (AST_Decl::NodeType nt, UTL_ScopedName *n, UTL_StrList *p) - : AST_Decl (nt, n, p) + : AST_Decl (nt, + n, + p) { } @@ -94,19 +90,14 @@ AST_Type::~AST_Type (void) { } -/* - * Private operations - */ - -/* - * Public operations - */ - - -/* - * Redefinition of inherited virtual operations - */ +// Public operations. +idl_bool +AST_Type::in_recursion (AST_Type *) +{ + // By default we are not involved in recursion. + return 0; +} // Narrowing IMPL_NARROW_METHODS1(AST_Type, AST_Decl) diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp index 0853714cf54..49b5db19b5c 100644 --- a/TAO/TAO_IDL/ast/ast_union.cpp +++ b/TAO/TAO_IDL/ast/ast_union.cpp @@ -62,30 +62,24 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ -/* - * ast_union.cc - Implementation of class AST_Union - * - * AST_Union nodes represent IDL union declarations. - * AST_Union is a subclass of AST_ConcreteType and of UTL_Scope (the - * union branches are managed in a scope). - * AST_Union nodes have a discriminator type (a subclass of AST_ConcreteType), - * a name (an UTL_ScopedName) and a field denoting the discriminator type if - * it is a primitive type (the value of this field is from the union - * AST_Expression::ExprType and serves as a cache). This field is used - * to compute coercions for labels based on the expected discriminator type. - */ - -#include "idl.h" -#include "idl_extern.h" +// AST_Union nodes represent IDL union declarations. +// AST_Union is a subclass of AST_ConcreteType and of UTL_Scope (the +// union branches are managed in a scope). +// AST_Union nodes have a discriminator type (a subclass of AST_ConcreteType), +// a name (an UTL_ScopedName) and a field denoting the discriminator type if +// it is a primitive type (the value of this field is from the union +// AST_Expression::ExprType and serves as a cache). This field is used +// to compute coercions for labels based on the expected discriminator type. + +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(ast, ast_union, "$Id$") -/* - * Constructor(s) and destructor - */ -AST_Union::AST_Union () +// Constructor(s) and destructor. +AST_Union::AST_Union (void) { } @@ -94,476 +88,663 @@ AST_Union::AST_Union (AST_ConcreteType *dt, UTL_StrList *p, idl_bool local, idl_bool abstract) - : AST_Decl (AST_Decl::NT_union, n, p), + : AST_Decl (AST_Decl::NT_union, + n, + p), UTL_Scope(AST_Decl::NT_union), - COMMON_Base (local, abstract) + COMMON_Base (local, + abstract) { - AST_PredefinedType *pdt; - - if (dt == NULL) { - pd_disc_type = NULL; - pd_udisc_type = AST_Expression::EV_none; - return; - } - /* - * If the discriminator type is a predefined type - * then install the equivalent coercion target type in - * the pd_udisc_type field. - */ - if (dt->node_type() == AST_Decl::NT_pre_defined) { - pdt = AST_PredefinedType::narrow_from_decl(dt); - if (pdt == NULL) { - pd_disc_type = NULL; - pd_udisc_type = AST_Expression::EV_none; - return; + AST_PredefinedType *pdt = 0; + + if (dt == 0) + { + this->pd_disc_type = 0; + this->pd_udisc_type = AST_Expression::EV_none; + return; + } + + // If the discriminator type is a predefined type + // then install the equivalent coercion target type in + // the pd_udisc_type field. + if (dt->node_type () == AST_Decl::NT_pre_defined) + { + pdt = AST_PredefinedType::narrow_from_decl (dt); + + if (pdt == 0) + { + this->pd_disc_type = 0; + this->pd_udisc_type = AST_Expression::EV_none; + return; + } + + pd_disc_type = dt; + + switch (pdt->pt ()) + { + case AST_PredefinedType::PT_long: + this->pd_udisc_type = AST_Expression::EV_long; + break; + case AST_PredefinedType::PT_ulong: + this->pd_udisc_type = AST_Expression::EV_ulong; + break; + case AST_PredefinedType::PT_short: + this->pd_udisc_type = AST_Expression::EV_short; + break; + case AST_PredefinedType::PT_ushort: + this->pd_udisc_type = AST_Expression::EV_ushort; + break; + case AST_PredefinedType::PT_char: + this->pd_udisc_type = AST_Expression::EV_char; + break; + case AST_PredefinedType::PT_wchar: + this->pd_udisc_type = AST_Expression::EV_wchar; + break; + case AST_PredefinedType::PT_octet: + this->pd_udisc_type = AST_Expression::EV_octet; + break; + case AST_PredefinedType::PT_boolean: + this->pd_udisc_type = AST_Expression::EV_bool; + break; + default: + this->pd_udisc_type = AST_Expression::EV_none; + this->pd_disc_type = 0; + break; + } + } + else if (dt->node_type() == AST_Decl::NT_enum) + { + this->pd_udisc_type = AST_Expression::EV_any; + this->pd_disc_type = dt; + } + else + { + this->pd_udisc_type = AST_Expression::EV_none; + this->pd_disc_type = 0; } - pd_disc_type = dt; - switch (pdt->pt()) { - case AST_PredefinedType::PT_long: - pd_udisc_type = AST_Expression::EV_long; - break; - case AST_PredefinedType::PT_ulong: - pd_udisc_type = AST_Expression::EV_ulong; - break; - case AST_PredefinedType::PT_short: - pd_udisc_type = AST_Expression::EV_short; - break; - case AST_PredefinedType::PT_ushort: - pd_udisc_type = AST_Expression::EV_ushort; - break; - case AST_PredefinedType::PT_char: - pd_udisc_type = AST_Expression::EV_char; - break; - case AST_PredefinedType::PT_wchar: - pd_udisc_type = AST_Expression::EV_wchar; - break; - case AST_PredefinedType::PT_octet: - pd_udisc_type = AST_Expression::EV_octet; - break; - case AST_PredefinedType::PT_boolean: - pd_udisc_type = AST_Expression::EV_bool; - break; - default: - pd_udisc_type = AST_Expression::EV_none; - pd_disc_type = NULL; - break; + + if (this->pd_disc_type == 0) + { + idl_global->err ()->error2 (UTL_Error::EIDL_DISC_TYPE, + this, + dt); } - } else if (dt->node_type() == AST_Decl::NT_enum) { - pd_udisc_type = AST_Expression::EV_any; - pd_disc_type = dt; - } else { - pd_udisc_type = AST_Expression::EV_none; - pd_disc_type = NULL; - } - - if (pd_disc_type == NULL) - idl_global->err()->error2(UTL_Error::EIDL_DISC_TYPE, this, dt); } AST_Union::~AST_Union (void) { } -/* - * Private operations - */ +// Public operations. -/* - * Look up the default branch in union - */ +// Are we or the parameter node involved in any recursion? +idl_bool +AST_Union::in_recursion (AST_Type *node) +{ + if (node == 0) + { + // We are determining the recursive status for ourselves. + node = this; + } + + // Proceed if the number of members in our scope is greater than 0. + if (this->nmembers () > 0) + { + // Initialize an iterator to iterate thru our scope. + UTL_ScopeActiveIterator *si = 0; + ACE_NEW_RETURN (si, + UTL_ScopeActiveIterator (this, + UTL_Scope::IK_decls), + 0); + // Continue until each element is visited. + while (!si->is_done ()) + { + AST_UnionBranch *field = + AST_UnionBranch::narrow_from_decl (si->item ()); + + if (field == 0) + { + delete si; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Union::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad field node\n")), + 0); + } + + AST_Type *type = + AST_Type::narrow_from_decl (field->field_type ()); + + if (type == 0) + { + delete si; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("(%N:%l) AST_Union::") + ACE_TEXT ("in_recursion - ") + ACE_TEXT ("bad field type\n")), + 0); + } + + if (type->in_recursion (node)) + { + delete si; + return 1; + } + + si->next (); + } + + delete si; + } + + // Not in recursion. + return 0; +} + +// Look up the default branch in union. AST_UnionBranch * -AST_Union::lookup_default() +AST_Union::lookup_default (void) { - UTL_ScopeActiveIterator *i = new UTL_ScopeActiveIterator(this, IK_both); - AST_UnionBranch *b; - AST_Decl *d; - - while (!(i->is_done())) { - d = i->item(); - if (d->node_type() == AST_Decl::NT_union_branch) { - b = AST_UnionBranch::narrow_from_decl(d); - if (b == NULL) { - i->next(); - continue; - } - if (b->label() != NULL && - b->label()->label_kind() == AST_UnionLabel::UL_default) { - idl_global->err()->error2(UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; - } + UTL_ScopeActiveIterator *i = 0; + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + IK_both), + 0); + + AST_UnionBranch *b = 0; + AST_Decl *d = 0; + + while (!i->is_done()) + { + d = i->item (); + + if (d->node_type () == AST_Decl::NT_union_branch) + { + b = AST_UnionBranch::narrow_from_decl (d); + + if (b == 0) + { + i->next (); + continue; + } + + if (b->label() != 0 + && b->label ()->label_kind () == AST_UnionLabel::UL_default) + { + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + this, + b); + delete i; + return b; + } + } + + i->next (); } - i->next(); - } + delete i; return NULL; } -/* - * Look up a branch by label - */ +// Look up a branch by label. AST_UnionBranch * -AST_Union::lookup_label(AST_UnionBranch *b) +AST_Union::lookup_label (AST_UnionBranch *b) { - AST_UnionLabel *l = b->label(); - UTL_ScopeActiveIterator *i; - AST_Decl *d; - AST_UnionBranch *fb; - - if (l->label_val() == NULL) - return b; - l->label_val()->set_ev(l->label_val()->coerce(pd_udisc_type)); - if (l->label_val()->ev() == NULL) { - idl_global->err()->eval_error(l->label_val()); - return b; - } - - i = new UTL_ScopeActiveIterator(this, IK_decls); - - while (!(i->is_done())) { - d = i->item(); - if (d->node_type() == AST_Decl::NT_union_branch) { - fb = AST_UnionBranch::narrow_from_decl(d); - if (fb == NULL) { - i->next(); - continue; - } - if (fb->label() != NULL && - fb->label()->label_kind() == AST_UnionLabel::UL_label && - fb->label()->label_val()->compare(l->label_val())) { - idl_global->err()->error2(UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; - } + AST_UnionLabel *label = b->label (); + AST_Expression *lv = label->label_val (); + + if (label->label_val () == 0) + { + return b; } - i->next(); - } + + AST_Decl *d = 0; + AST_UnionBranch *fb = 0; + + lv->set_ev(lv->coerce (this->pd_udisc_type)); + + if (lv->ev () == 0) + { + idl_global->err ()->eval_error (lv); + return b; + } + + UTL_ScopeActiveIterator *i = 0; + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + IK_decls), + 0); + + while (!i->is_done()) + { + d = i->item (); + + if (d->node_type () == AST_Decl::NT_union_branch) + { + fb = AST_UnionBranch::narrow_from_decl (d); + + if (fb == 0) + { + i->next (); + continue; + } + + if (fb->label() != 0 + && fb->label ()->label_kind () == AST_UnionLabel::UL_label + && fb->label ()->label_val ()->compare (lv)) + { + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + this, + b); + delete i; + return b; + } + } + + i->next(); + } + delete i; - return NULL; + return 0; } -/* - * Look up a branch in an enum which is the discriminator type for this - * union, based on the label value which must be an enumerator in that - * enum. - */ +// Look up a branch in an enum which is the discriminator type for this +// union, based on the label value which must be an enumerator in that +// enum. AST_UnionBranch * -AST_Union::lookup_enum(AST_UnionBranch *b) +AST_Union::lookup_enum (AST_UnionBranch *b) { - AST_UnionLabel *l = b->label(); - AST_Expression *v; - AST_Enum *e = AST_Enum::narrow_from_decl(pd_disc_type); - UTL_ScopeActiveIterator *i; - AST_Decl *d; - AST_UnionBranch *fb; - - if (e == NULL) return NULL; - if (l->label_val() == NULL) - return b; - v = l->label_val(); - /* - * Expecting a symbol label - */ - if (v->ec() != AST_Expression::EC_symbol) { - idl_global->err()->enum_val_expected(this, l); - return b; - } - /* - * See if the symbol defines a constant in the discriminator enum - */ - d = e->lookup_by_name(v->n(), I_TRUE); - if (d == NULL || d->defined_in() != e) { - idl_global->err()->enum_val_lookup_failure(this, e, v->n()); - return b; - } - /* - * OK, now see if this symbol is already used as the label of - * some other branch - */ - i = new UTL_ScopeActiveIterator(this, IK_decls); - while (!(i->is_done())) { - d = i->item(); - if (d->node_type() == AST_Decl::NT_union_branch) { - fb = AST_UnionBranch::narrow_from_decl(d); - if (fb == NULL) { - i->next(); - continue; - } - if (fb->label() != NULL && - fb->label()->label_kind() == AST_UnionLabel::UL_label && - fb->label()->label_val()->compare (l->label_val())) { - idl_global->err()->error2(UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; - } + AST_UnionLabel *label = b->label(); + AST_Expression *lv = label->label_val (); + AST_Expression *v = 0; + AST_Enum *e = AST_Enum::narrow_from_decl (this->pd_disc_type); + AST_Decl *d = 0; + AST_UnionBranch *fb = 0; + + if (e == 0) + { + return 0; + } + + if (lv == 0) + { + return b; } - i->next(); - } + + // Expecting a symbol label. + if (lv->ec () != AST_Expression::EC_symbol) + { + idl_global->err ()->enum_val_expected (this, + label); + return b; + } + + // See if the symbol defines a constant in the discriminator enum. + UTL_ScopedName *sn = lv->n (); + d = e->lookup_by_name (sn, + I_TRUE); + + if (d == 0 || d->defined_in () != e) + { + idl_global->err ()->enum_val_lookup_failure (this, + e, + sn); + return b; + } + + // OK, now see if this symbol is already used as the label of + // some other branch. + UTL_ScopeActiveIterator *i = 0; + ACE_NEW_RETURN (i, + UTL_ScopeActiveIterator (this, + IK_decls), + 0); + + while (!i->is_done()) + { + d = i->item (); + + if (d->node_type () == AST_Decl::NT_union_branch) + { + fb = AST_UnionBranch::narrow_from_decl (d); + + if (fb == 0) + { + i->next (); + continue; + } + + if (fb->label() != 0 + && fb->label ()->label_kind () == AST_UnionLabel::UL_label + && fb->label ()->label_val ()->compare (lv)) + { + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + this, + b); + delete i; + return b; + } + } + + i->next(); + } + delete i; return NULL; } -/* - * Look up a branch by value. This is the top level branch label resolution - * entry point. It dispatches to the right lookup function depending on the - * union discriminator type. - */ +// Look up a branch by value. This is the top level branch label resolution +// entry point. It dispatches to the right lookup function depending on the +// union discriminator type. AST_UnionBranch * -AST_Union::lookup_branch(AST_UnionBranch *branch) +AST_Union::lookup_branch (AST_UnionBranch *branch) { - AST_UnionLabel *l = NULL; - - if (branch != NULL) - l = branch->label(); - - if (l != NULL) { - if (l->label_kind() == AST_UnionLabel::UL_default) - return lookup_default(); - if (pd_udisc_type == AST_Expression::EV_any) - /* CONVENTION: indicates enum discr */ - return lookup_enum(branch); - return lookup_label(branch); - } - return NULL; -} + AST_UnionLabel *label = 0; -/* - * Public operations - */ + if (branch != 0) + { + label = branch->label (); + } -/* - * Redefinition of inherited virtual operations - */ + if (label != 0) + { + if (label->label_kind () == AST_UnionLabel::UL_default) + { + return lookup_default (); + } -/* - * Add this AST_UnionBranch node (a node representing one branch in a - * union declaration) to this scope - */ -AST_UnionBranch *AST_Union::fe_add_union_branch(AST_UnionBranch *t) + if (this->pd_udisc_type == AST_Expression::EV_any) + { + // CONVENTION: indicates enum discriminant. + return lookup_enum(branch); + } + + return lookup_label (branch); + } + + return 0; +} + +// Redefinition of inherited virtual operations + +// Add this AST_UnionBranch node (a node representing one branch in a +// union declaration) to this scope +AST_UnionBranch * +AST_Union::fe_add_union_branch (AST_UnionBranch *t) { - AST_Decl *d; - - /* - * If this is a malformed branch, don't do anything with it - */ - if (t == NULL || t->label() == NULL) - return NULL; - /* - * If branch with that label already exists, complain - */ - if (lookup_branch(t) != NULL) { - idl_global->err()->error2(UTL_Error::EIDL_MULTIPLE_BRANCH, this, t); - return NULL; - } - /* - * If branch with same field name exists, complain - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; + AST_Decl *d = 0; + + // If this is a malformed branch, don't do anything with it. + if (t == 0 || t->label() == 0) + { + return 0; } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; + + // If branch with that label already exists, complain. + if (lookup_branch (t) != 0) + { + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + this, + t); + return 0; } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + + // If branch with same field name exists, complain. + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Union (manifest union type) to this scope - */ -AST_Union *AST_Union::fe_add_union(AST_Union *t) +// Add this AST_Union (manifest union type) to this scope. +AST_Union * +AST_Union::fe_add_union (AST_Union *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Structure node (manifest struct type) to this scope - */ -AST_Structure *AST_Union::fe_add_structure(AST_Structure *t) +// Add this AST_Structure node (manifest struct type) to this scope. +AST_Structure * +AST_Union::fe_add_structure (AST_Structure *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_Enum node (manifest enum type) to this scope - */ -AST_Enum *AST_Union::fe_add_enum(AST_Enum *t) +// Add this AST_Enum node (manifest enum type) to this scope. +AST_Enum * +AST_Union::fe_add_enum (AST_Enum *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to local types - */ - add_to_local_types(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Add this AST_EnumVal node (enumerator declaration) to this scope. - * This is done to conform to the C++ scoping rules which declare - * enumerators in the enclosing scope (in addition to declaring them - * in the enum itself) - */ -AST_EnumVal *AST_Union::fe_add_enum_val(AST_EnumVal *t) +// Add this AST_EnumVal node (enumerator declaration) to this scope. +// This is done to conform to the C++ scoping rules which declare +// enumerators in the enclosing scope (in addition to declaring them +// in the enum itself). +AST_EnumVal * +AST_Union::fe_add_enum_val (AST_EnumVal *t) { - AST_Decl *d; - - /* - * Already defined and cannot be redefined? Or already used? - */ - if ((d = lookup_for_add(t, I_FALSE)) != NULL) { - if (!can_be_redefined(d)) { - idl_global->err()->error3(UTL_Error::EIDL_REDEF, t, this, d); - return NULL; - } - if (referenced(d, t->local_name ())) { - idl_global->err()->error3(UTL_Error::EIDL_DEF_USE, t, this, d); - return NULL; - } - if (t->has_ancestor(d)) { - idl_global->err()->redefinition_in_scope(t, d); - return NULL; + AST_Decl *d = 0; + + // Already defined and cannot be redefined? Or already used? + if ((d = lookup_for_add (t, I_FALSE)) != 0) + { + if (!can_be_redefined (d)) + { + idl_global->err ()->error3 (UTL_Error::EIDL_REDEF, + t, + this, + d); + return 0; + } + + if (this->referenced (d, t->local_name ())) + { + idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE, + t, + this, + d); + return 0; + } + + if (t->has_ancestor (d)) + { + idl_global->err ()->redefinition_in_scope (t, + d); + return 0; + } } - } - /* - * Add it to scope - */ - add_to_scope(t); - /* - * Add it to set of locally referenced symbols - */ - add_to_referenced(t, I_FALSE, t->local_name ()); + + // Add it to scope. + this->add_to_scope (t); + + // Add it to set of locally referenced symbols. + this->add_to_referenced (t, + I_FALSE, + t->local_name ()); return t; } -/* - * Dump this AST_Union node to the ostream o - */ +// Dump this AST_Union node to the ostream o. void -AST_Union::dump(ostream &o) +AST_Union::dump (ostream &o) { o << "union "; - local_name()->dump(o); + this->local_name ()->dump (o); o << " switch ("; - pd_disc_type->local_name()->dump(o); + this->pd_disc_type->local_name ()->dump (o); o << ") {\n"; - UTL_Scope::dump(o); - idl_global->indent()->skip_to(o); + UTL_Scope::dump (o); + idl_global->indent ()->skip_to (o); o << "}"; } -/* - * Data accessors - */ +// Data accessors. AST_ConcreteType * -AST_Union::disc_type() +AST_Union::disc_type (void) { - return pd_disc_type; + return this->pd_disc_type; } AST_Expression::ExprType -AST_Union::udisc_type() +AST_Union::udisc_type (void) { - return pd_udisc_type; + return this->pd_udisc_type; } -// Narrowing +// Narrowing. IMPL_NARROW_METHODS2(AST_Union, AST_ConcreteType, UTL_Scope) IMPL_NARROW_FROM_DECL(AST_Union) IMPL_NARROW_FROM_SCOPE(AST_Union) diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index 39102e42ba1..649c7544b10 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -40,10 +40,7 @@ be_decl::be_decl (void) cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), cli_inline_cdr_op_gen_ (I_FALSE), - full_name_ (0), flat_name_ (0), - repoID_ (0), - prefix_ (0), size_type_ (be_decl::SIZE_UNKNOWN), has_constructor_ (I_FALSE) { @@ -68,10 +65,7 @@ be_decl::be_decl (AST_Decl::NodeType type, cli_stub_any_op_gen_ (I_FALSE), cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), - full_name_ (0), flat_name_ (0), - repoID_ (0), - prefix_ (0), size_type_ (be_decl::SIZE_UNKNOWN), has_constructor_ (I_FALSE) { @@ -98,7 +92,7 @@ be_decl::size_type (void) void be_decl::size_type (be_decl::SIZE_TYPE st) { - // p\Precondition - you cannot set somebody's sizetype to unknown. + // Precondition - you cannot set somebody's sizetype to unknown. ACE_ASSERT (st != be_decl::SIZE_UNKNOWN); // Size type can be VARIABLE or FIXED. @@ -116,111 +110,6 @@ be_decl::size_type (be_decl::SIZE_TYPE st) } } -const char* -be_decl::full_name (void) -{ - if (!this->full_name_) - compute_full_name (); - - return this->full_name_; -} - -// Compute stringified fully scoped name -void -be_decl::compute_full_name (void) -{ - if (this->full_name_ != 0) - { - return; - } - else - { - long namelen = 0; - UTL_IdListActiveIterator *i = 0; - long first = I_TRUE; - long second = I_FALSE; - - // In the first loop, compute the total length. - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) - { - if (!first) - { - namelen += 2; // for "::" - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - namelen += ACE_OS::strlen (i->item ()->get_string ()); - - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - - i->next (); - } - - delete i; - - ACE_NEW (this->full_name_, - char[namelen + 1]); - this->full_name_[0] = '\0'; - first = I_TRUE; - second = I_FALSE; - - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) - { - if (!first) - { - ACE_OS::strcat (this->full_name_, "::"); - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - ACE_OS::strcat (this->full_name_, i->item ()->get_string ()); - - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - - i->next (); - } - - delete i; - } - - return; -} - void be_decl::compute_full_name (const char *prefix, const char *suffix, @@ -452,126 +341,6 @@ be_decl::compute_flat_name (const char *prefix, name = result_str.rep (); } -const char * -be_decl::repoID (void) -{ - if (this->repoID_ == 0) - { - this->compute_repoID (); - } - - return this->repoID_; -} - - -// compute stringified repository ID -void -be_decl::compute_repoID (void) -{ - if (this->repoID_ != 0) - { - return; - } - else - { - long namelen = 8; // for the prefix "IDL:" and suffix ":1.0" - UTL_IdListActiveIterator *i = 0; - long first = I_TRUE; - long second = I_FALSE; - - // in the first loop compute the total length - namelen += ACE_OS::strlen (this->prefix ()) + 1; - - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) - { - if (!first) - { - namelen += 1; // for "/" - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - namelen += ACE_OS::strlen (i->item ()->get_string ()); - - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - - i->next (); - } - - delete i; - - ACE_NEW (this->repoID_, - char[namelen + 1]); - this->repoID_[0] = '\0'; - ACE_OS::sprintf (this->repoID_, "%s", "IDL:"); - ACE_OS::strcat (this->repoID_, this->prefix ()); - - // Add the "/" only if there is a prefix. - if (ACE_OS::strcmp (this->prefix (), "") != 0) - { - ACE_OS::strcat (this->repoID_, "/"); - } - - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - first = I_TRUE; - second = I_FALSE; - - while (!(i->is_done ())) - { - if (!first) - { - ACE_OS::strcat (this->repoID_, "/"); - } - else if (second) - { - first = second = I_FALSE; - } - - // Print the identifier. - ACE_OS::strcat (this->repoID_, i->item ()->get_string ()); - - if (first) - { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) - { - // Does not start with a "". - first = I_FALSE; - } - else - { - second = I_TRUE; - } - } - - i->next (); - } - - delete i; - ACE_OS::strcat (this->repoID_, ":1.0"); - } - - return; -} - // Apply the prefix and suffix to the local name and compute the // repoID. Both the parameters should be non-null. void @@ -747,118 +516,14 @@ be_decl::compute_repoID (const char *prefix, name = repoID.rep (); } - - -void -be_decl::compute_prefix (void) -{ - const char* pragma = 0; - if (this->pragmas () != 0) - { - for (UTL_StrlistActiveIterator i (this->pragmas ()); - !i.is_done (); - i.next ()) - { - const char* s = i.item ()->get_string (); - - if (ACE_OS::strncmp (s, "#pragma prefix", 14) == 0) - { - pragma = s; - } - } - } - - if (pragma != 0) - { - // Skip the space and the " also... - const char* tmp = pragma + 16; - const char* end = ACE_OS::strchr (tmp, '"'); - - if (end == 0) - { - idl_global->err ()->syntax_error ( - IDL_GlobalData::PS_PragmaPrefixSyntax - ); - this->prefix_ = ACE::strnew (""); - return; - } - - int l = end - tmp; - ACE_NEW (this->prefix_, - char[l + 1]); - ACE_OS::strncpy (this->prefix_, tmp, end - tmp); - this->prefix_[l] = 0; - return; - } - - // Could not find it in the local scope, try to recurse to the top - // scope... - if (this->defined_in () == 0) - { - this->prefix_ = ACE::strnew (""); - } - else - { - be_scope* scope = - be_scope::narrow_from_scope (this->defined_in ()); - - if (scope == 0) - { - this->prefix_ = ACE::strnew (""); - } - else - { - be_decl *d = scope->decl (); - - if (d != 0) - { - this->prefix_ = ACE::strnew (d->prefix ()); - } - else - { - this->prefix_ = ACE::strnew (""); - } - } - } -} - void be_decl::destroy (void) { - if (this->full_name_ != 0) - { - delete this->full_name_; - this->full_name_ = 0; - } - if (this->flat_name_ != 0) { delete this->flat_name_; this->flat_name_ = 0; } - - if (this->repoID_ != 0) - { - ACE_OS::free (this->repoID_); - this->repoID_ = 0; - } - - if (this->prefix_ != 0) - { - delete this->prefix_; - this->prefix_ = 0; - } -} - -const char* -be_decl::prefix (void) -{ - if (this->prefix_ == 0) - { - this->compute_prefix (); - } - - return this->prefix_; } idl_bool diff --git a/TAO/TAO_IDL/be/be_enum.cpp b/TAO/TAO_IDL/be/be_enum.cpp index 474fa8b9838..0569da441f5 100644 --- a/TAO/TAO_IDL/be/be_enum.cpp +++ b/TAO/TAO_IDL/be/be_enum.cpp @@ -43,54 +43,11 @@ be_enum::be_enum (UTL_ScopedName *n, p), UTL_Scope (AST_Decl::NT_enum), COMMON_Base (local, - abstract), - member_count_ (-1) + abstract) { this->size_type (be_decl::FIXED); } -// Compute total number of members. -int -be_enum::compute_member_count (void) -{ - UTL_ScopeActiveIterator *si = 0; - - this->member_count_ = 0; - - // 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. - this->member_count_++; - si->next (); - } - - delete si; - } - - return 0; -} - -// return the member count -int -be_enum::member_count (void) -{ - if (this->member_count_ == -1) - { - this->compute_member_count (); - } - - return this->member_count_; -} - // Convert a numeric value to the string name UTL_ScopedName * be_enum::value_to_name (const unsigned long v) diff --git a/TAO/TAO_IDL/be/be_exception.cpp b/TAO/TAO_IDL/be/be_exception.cpp index 5d35ad7320f..5581a1c2fc6 100644 --- a/TAO/TAO_IDL/be/be_exception.cpp +++ b/TAO/TAO_IDL/be/be_exception.cpp @@ -47,71 +47,8 @@ be_exception::be_exception (UTL_ScopedName *n, COMMON_Base (local, abstract) { - this->size_type (be_decl::VARIABLE); // Always the case. -} - -// Are we or the parameter node involved in any recursion -idl_bool -be_exception::in_recursion (be_type *node) -{ - if (node == 0) - { - // We are determining the recursive status for ourselves. - node = this; - } - - // Proceed if the number of members in our scope is greater than 0. - if (this->nmembers () > 0) - { - // Initialize an iterator to iterate thru our scope. - UTL_ScopeActiveIterator *si = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - -1); - // Continue until each element is visited. - while (!si->is_done ()) - { - be_field *field = be_field::narrow_from_decl (si->item ()); - - if (field == 0) - { - delete si; - - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_exception::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad field node\n")), - 0); - } - - be_type *type = be_type::narrow_from_decl (field->field_type ()); - - if (type == 0) - { - delete si; - - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_exception::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad field type\n")), - 0); - } - - if (type->in_recursion (node)) - { - delete si; - return 1; - } - - si->next (); - } - - delete si; - } - - // Not in recursion - return 0; + // Always the case. + this->size_type (be_decl::VARIABLE); } void diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 3741c62a52c..368a435953f 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -37,8 +37,8 @@ be_interface::be_interface (void) { ACE_NEW (this->strategy_, be_interface_default_strategy (this)); - this->size_type (be_decl::VARIABLE); // always the case - this->has_constructor (I_TRUE); // always the case + this->size_type (be_decl::VARIABLE); // Always the case. + this->has_constructor (I_TRUE); // Always the case. } // Constructor used to build the AST. diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index 5572d74edae..d470bef61b1 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -26,8 +26,6 @@ ACE_RCSID(be, be_operation, "$Id$") be_operation::be_operation (void) - : argument_count_ (-1), - has_native_ (0) { ACE_NEW (this->strategy_, be_operation_default_strategy (this)); @@ -50,9 +48,7 @@ be_operation::be_operation (AST_Type *rt, p), UTL_Scope (AST_Decl::NT_op), COMMON_Base (local, - abstract), - argument_count_ (-1), - has_native_ (0) + abstract) { ACE_NEW (this->strategy_, be_operation_default_strategy (this)); @@ -61,70 +57,8 @@ be_operation::be_operation (AST_Type *rt, be_operation::~be_operation (void) { - // We know that it cannot be 0, but.. - if (!this->strategy_) - { - delete this->strategy_; - } } - -// Compute total number of members. -int -be_operation::compute_argument_attr (void) -{ - if (this->argument_count_ != -1) - { - return 0; - } - - this->argument_count_ = 0; - - // If there are elements in this scope. - if (this->nmembers () > 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_Decl *d = si->item (); - - if (d->node_type () == AST_Decl::NT_argument) - { - this->argument_count_++; - be_argument *arg = be_argument::narrow_from_decl (d); - be_type* type = - be_type::narrow_from_decl (arg->field_type ()); - - if (type->base_node_type () == AST_Decl::NT_native) - { - this->has_native_ = 1; - } - } - - si->next (); - } - - delete si; - } - - be_type* type = be_type::narrow_from_decl (this->return_type ()); - - if (type->base_node_type () == AST_Decl::NT_native) - { - this->has_native_ = 1; - } - - return 0; -} - - int be_operation::void_return_type (void) { @@ -141,23 +75,6 @@ be_operation::void_return_type (void) return 0; } } -// Return the member count. -int -be_operation::argument_count (void) -{ - this->compute_argument_attr (); - - return this->argument_count_; -} - -// Return if any argument or the return type is a <native> type. -int -be_operation::has_native (void) -{ - this->compute_argument_attr (); - - return this->has_native_; -} be_argument * be_operation::add_argument_to_scope (be_argument *arg) diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index 565a4bf13e6..923160c9742 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -182,16 +182,16 @@ be_predefined_type::be_predefined_type (AST_PredefinedType::PredefinedType t, } // Computes the repoID. - compute_repoID (); + this->compute_repoID (); // Computes the fully scoped name. - compute_full_name (); + AST_Decl::compute_full_name (); // Computes the fully scoped typecode name. - compute_tc_name (); + this->compute_tc_name (); // Compute the flattened fully scoped name. - compute_flat_name (); + this->compute_flat_name (); } // Overriden method. @@ -383,12 +383,12 @@ be_predefined_type::compute_repoID (void) } else { - be_decl::compute_repoID (); + AST_Decl::compute_repoID (); } break; default: - be_decl::compute_repoID (); + AST_Decl::compute_repoID (); break; } } diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index 36fcbe36852..d1e4c42365f 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -50,17 +50,6 @@ be_sequence::be_sequence (AST_Expression *v, abstract), mt_ (be_sequence::MNG_UNKNOWN) { - // Check if we are bounded or unbounded. An expression value of 0 means - // unbounded. - if (v->ev ()->u.ulval == 0) - { - this->unbounded_ = I_TRUE; - } - else - { - this->unbounded_ = I_FALSE; - } - // A sequence data type is always VARIABLE. this->size_type (be_decl::VARIABLE); @@ -68,12 +57,6 @@ be_sequence::be_sequence (AST_Expression *v, this->has_constructor (I_TRUE); } -idl_bool -be_sequence::unbounded (void) const -{ - return this->unbounded_; -} - // Helper to create_name. char * be_sequence::gen_name (void) @@ -136,7 +119,7 @@ be_sequence::gen_name (void) } // Append the size (if any). - if (this->unbounded_ == 0) + if (this->unbounded () == I_FALSE) { ACE_OS::sprintf (namebuf, "%s_%lu", @@ -423,43 +406,6 @@ be_sequence::instance_name () return namebuf; } -idl_bool -be_sequence::in_recursion (be_type *node) -{ - if (node == 0) - { - // There has to be a parameter - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_sequence::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad parameter node\n")), - 0); - } - - be_type *type = be_type::narrow_from_decl (this->base_type ()); - - if (!type) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_sequence::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad base type\n")), - 0); - } - - if (!ACE_OS::strcmp (node->full_name (), - type->full_name ())) - { - // They match. - return 1; - } - else - { - // Not in recursion. - return 0; - } -} - void be_sequence::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index d5de6f70aa2..259f0d65438 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -702,65 +702,6 @@ be_structure::compute_size_type (void) return 0; } -// Are we or the parameter node involved in any recursion? -idl_bool -be_structure::in_recursion (be_type *node) -{ - if (node == 0) - { - // We are determining the recursive status for ourselves. - node = this; - } - - // Proceed if the number of members in our scope is greater than 0. - if (this->nmembers () > 0) - { - // Initialize an iterator to iterate over our scope. - UTL_ScopeActiveIterator *si = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - -1); - // Continue until each element is visited. - while (!si->is_done ()) - { - be_field *field = be_field::narrow_from_decl (si->item ()); - - if (field == 0) - // This will be an enum value or other legitimate non-field - // member - in any case, no recursion. - { - si->next (); - continue; - } - - be_type *type = be_type::narrow_from_decl (field->field_type ()); - - if (type == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_structure::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad field type\n")), - 0); - } - - if (type->in_recursion (node)) - { - delete si; - return 1; - } - si->next (); - } - - delete si; - } - - // Not in recursion. - return 0; -} - void be_structure::destroy (void) { diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index d25a52f5959..44b647df47e 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -598,13 +598,6 @@ be_type::base_node_type (void) const return ACE_const_cast (be_type*, this)->node_type (); } -idl_bool -be_type::in_recursion (be_type *) -{ - // By default we are not involved in recursion. - return 0; -} - // Cleanup method void be_type::destroy (void) diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index 7fcebfc36cf..46c7830e526 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -796,69 +796,6 @@ be_union::compute_size_type (void) return 0; } -// Are we or the parameter node involved in any recursion? -idl_bool -be_union::in_recursion (be_type *node) -{ - if (node == 0) - { - // We are determining the recursive status for ourselves. - node = this; - } - - // Proceed if the number of members in our scope is greater than 0. - if (this->nmembers () > 0) - { - // Initialize an iterator to iterate thru our scope. - UTL_ScopeActiveIterator *si = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - 0); - // Continue until each element is visited. - while (!si->is_done ()) - { - be_union_branch *field = - be_union_branch::narrow_from_decl (si->item ()); - - if (field == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_union::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad field node\n")), - 0); - } - - be_type *type = be_type::narrow_from_decl (field->field_type ()); - - if (type == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_union::") - ACE_TEXT ("in_recursion - ") - ACE_TEXT ("bad field type\n")), - 0); - } - - if (type->in_recursion (node)) - { - delete si; - return 1; - } - - si->next (); - } - - delete si; - } - - // Not in recursion. - return 0; -} - // Return the default value. int be_union::default_value (be_union::DefaultValue &dv) diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 9294dc67cc3..044270f9baa 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -72,6 +72,8 @@ be_valuetype::be_valuetype (UTL_ScopedName *n, n, p), UTL_Scope (AST_Decl::NT_interface), + COMMON_Base (0, + set_abstract), full_obv_skel_name_ (0), abstract_ (set_abstract) { diff --git a/TAO/TAO_IDL/be_include/be_decl.h b/TAO/TAO_IDL/be_include/be_decl.h index 8b07d24a171..9b3d14101ce 100644 --- a/TAO/TAO_IDL/be_include/be_decl.h +++ b/TAO/TAO_IDL/be_include/be_decl.h @@ -62,15 +62,9 @@ public: virtual SIZE_TYPE size_type (void); // Return our size type. - const char *full_name (void); - // Return the stringified full name. - const char *flat_name (void); // Return the flattened full scoped name. - const char *repoID (void); - // Retrieve the repository ID. - // Methods used by the interface type strategy. void compute_full_name (const char *prefix, const char *suffix, @@ -93,9 +87,6 @@ public: // End of Methods use by the interface type strategy. - const char* prefix (void); - // Retrieve the repository ID prefix. - virtual idl_bool is_nested (void); // Determines if we are inside of a nested scope or not. @@ -152,18 +143,9 @@ protected: virtual int compute_size_type (void); // Determine our size type and set it if it is unknown. - virtual void compute_full_name (void); - // Computes the fully scoped name - virtual void compute_flat_name (void); // Compute the flattened fully scoped name. - virtual void compute_repoID (void); - // Computes the repoID. - - virtual void compute_prefix (void); - // Computes the prefix for the repoID. - virtual void destroy (); // Cleanup function. @@ -183,18 +165,9 @@ protected: idl_bool cli_stub_cdr_op_gen_; idl_bool cli_inline_cdr_op_gen_; - char *full_name_; - // Our full scoped name. - char *flat_name_; // Flattened fully scoped name. - char *repoID_; - // Repository ID. - - char *prefix_; - // The repository ID prefix. - SIZE_TYPE size_type_; // Whether we are fixed or variable size (by default fixed). diff --git a/TAO/TAO_IDL/be_include/be_enum.h b/TAO/TAO_IDL/be_include/be_enum.h index e79f7f8ec8b..496e138684e 100644 --- a/TAO/TAO_IDL/be_include/be_enum.h +++ b/TAO/TAO_IDL/be_include/be_enum.h @@ -44,9 +44,6 @@ public: idl_bool abstract); // Constructor. - virtual int member_count (void); - // Return the count of members - // Convert a numeric value to the enum's string name for it. virtual UTL_ScopedName *value_to_name (const unsigned long v); @@ -62,11 +59,6 @@ public: DEF_NARROW_FROM_SCOPE (be_enum); private: - int compute_member_count (void); - // Count the number of members. - - int member_count_; - // Number of members. }; #endif diff --git a/TAO/TAO_IDL/be_include/be_exception.h b/TAO/TAO_IDL/be_include/be_exception.h index eb321b5fedc..e10e6c24f47 100644 --- a/TAO/TAO_IDL/be_include/be_exception.h +++ b/TAO/TAO_IDL/be_include/be_exception.h @@ -25,9 +25,6 @@ public: idl_bool abstract); // Constructor. - virtual idl_bool in_recursion (be_type *node = 0); - // Check if we or the parameter node is in recursion. - virtual void destroy (void); // Cleanup function. diff --git a/TAO/TAO_IDL/be_include/be_operation.h b/TAO/TAO_IDL/be_include/be_operation.h index c31d343aea6..dbbbe8beb4b 100644 --- a/TAO/TAO_IDL/be_include/be_operation.h +++ b/TAO/TAO_IDL/be_include/be_operation.h @@ -48,20 +48,12 @@ public: idl_bool abstract); // Constructor - ~be_operation (); + ~be_operation (void); // Destructor. - int void_return_type (); + int void_return_type (void); // Returns 1 if the operation has a void return type. - virtual int argument_count (void); - // Return the count of members. - - virtual int has_native (void); - // Any of the arguments or the return value is a <native> type. - // This is important because in that case no code should be - // generated for the stubs. - be_argument *add_argument_to_scope (be_argument *arg); // Add an argument to the scope. @@ -80,12 +72,12 @@ public: int has_extra_code_generation (TAO_CodeGen::CG_STATE current_state); // Returns true if we have to genrate extra code. - be_operation *marshaling (); + be_operation *marshaling (void); // returns the operation containing special marshaling information, // this makes sense if not all arguments get marshaled, e.g. AMI // sendc_ operations. - be_operation *arguments (); + be_operation *arguments (void); // Returns a customized arguments list, e.g. AMI sendc_ operations // only use the in and inout arguments but not the out arguments, // also the first argument is the reply handler. @@ -99,15 +91,6 @@ protected: int compute_size_type (void); // Compute the size type if it is unknown. - int compute_argument_attr (void); - // Count the number of arguments. - - int argument_count_; - // Number of arguments. - - int has_native_; - // Is any argument of type native. - be_operation_strategy *strategy_; // Member for holding the strategy for covering // differences between various operations, e.g. sendc_, raise_ diff --git a/TAO/TAO_IDL/be_include/be_sequence.h b/TAO/TAO_IDL/be_include/be_sequence.h index 48a06be6bc7..caef7cdfed1 100644 --- a/TAO/TAO_IDL/be_include/be_sequence.h +++ b/TAO/TAO_IDL/be_include/be_sequence.h @@ -67,18 +67,12 @@ public: virtual MANAGED_TYPE managed_type (void); // Return the managed type. - virtual idl_bool unbounded (void) const; - // Is this sequence bounded or not. - // Scope management functions. virtual AST_Sequence *fe_add_sequence (AST_Sequence *); virtual be_decl *decl (void); // Overridden method on the be_scope class. - virtual idl_bool in_recursion (be_type *node = 0); - // Are we or the node represented by node involved in recursion. - virtual void destroy (void); // Cleanup method. @@ -97,9 +91,6 @@ protected: // Helper to create_name. private: - idl_bool unbounded_; - // Whether we are bounded or unbounded. - MANAGED_TYPE mt_; // Our managed type. }; diff --git a/TAO/TAO_IDL/be_include/be_structure.h b/TAO/TAO_IDL/be_include/be_structure.h index 34f72f26755..6b95da27dc6 100644 --- a/TAO/TAO_IDL/be_include/be_structure.h +++ b/TAO/TAO_IDL/be_include/be_structure.h @@ -58,9 +58,6 @@ public: char *full_name = 0); // Generate the _out implementation. - virtual idl_bool in_recursion (be_type *node = 0); - // Are we or the node represented by node involved in recursion. - virtual void destroy (void); // Cleanup method. diff --git a/TAO/TAO_IDL/be_include/be_type.h b/TAO/TAO_IDL/be_include/be_type.h index 2bd1a4f808b..7329c779cb5 100644 --- a/TAO/TAO_IDL/be_include/be_type.h +++ b/TAO/TAO_IDL/be_include/be_type.h @@ -88,11 +88,6 @@ public: // recursive simply using "base_type->node_type()" will not work, so // the most "unaliased" type is needed. - virtual idl_bool in_recursion (be_type *node = 0); - // Determine if we are involved in some kind of limited recursion. Most types - // cannot be involved except structs and unions. - // If the parameter is 0, we are trying to determine this for ourselves. - virtual void destroy (void); // Clean up allocated members. diff --git a/TAO/TAO_IDL/be_include/be_union.h b/TAO/TAO_IDL/be_include/be_union.h index 6591abdfe8f..4087069a655 100644 --- a/TAO/TAO_IDL/be_include/be_union.h +++ b/TAO/TAO_IDL/be_include/be_union.h @@ -62,9 +62,6 @@ public: virtual int default_index (void); // Return the default index used. - virtual idl_bool in_recursion (be_type *node = 0); - // Are we or the parameter node involved in some kind of recursion? - virtual idl_bool has_duplicate_case_labels (void); // Do we have at least one member with multiple case labels? diff --git a/TAO/TAO_IDL/be_include/be_valuetype.h b/TAO/TAO_IDL/be_include/be_valuetype.h index 4988600777e..165dcaf9856 100644 --- a/TAO/TAO_IDL/be_include/be_valuetype.h +++ b/TAO/TAO_IDL/be_include/be_valuetype.h @@ -37,8 +37,11 @@ public: be_valuetype (void); // Default constructor. - be_valuetype (UTL_ScopedName *n, AST_Interface **ih, long nih, - UTL_StrList *p, idl_bool set_abstract = 0); + be_valuetype (UTL_ScopedName *n, + AST_Interface **ih, + long nih, + UTL_StrList *p, + idl_bool set_abstract = 0); // Constructor that sets its scoped name <n>, a list of inherited valuetypes // and supported interfaces <ih>, the number of inherited interfaces <nih>, // and any pragmas <p>. @@ -46,22 +49,15 @@ public: ~be_valuetype (void); // Destructor. - virtual void redefine (AST_Interface *from, UTL_StrList *p); + virtual void redefine (AST_Interface *from, + UTL_StrList *p); - idl_bool opt_accessor (); + idl_bool opt_accessor (void); // Should generate optimized form? virtual int gen_var_defn (char *local_name = 0); // Generate the _var class definition. - // Virtual void gen_def_ctors (TAO_OutStream* os); - // Call the default constructors of all the base classes. - - - - // Virtual void gen_copy_ctors (TAO_OutStream* os); - // Call the copy constructors of all the base classes. - virtual int gen_var_impl (char *local_name = 0, char *full_name = 0); // Generate the implementation for the _var class. @@ -91,14 +87,8 @@ public: // Return length of encapsulation. #endif - // virtual int traverse_inheritance_graph (tao_code_emitter gen, - // TAO_OutStream *os); - // template method using breadth first traversal of inheritance graph - - // const char *relative_skel_name (const char *other_class_name); - // Relative skeleton name. - const char *field_pd_prefix (void); + const char *field_pd_postfix (void); // For building the name for private data fields. @@ -108,9 +98,13 @@ public: // Visiting. virtual int accept (be_visitor *visitor); - virtual idl_bool is_valuetype (); - virtual idl_bool is_abstract_valuetype (); - virtual void set_abstract_valuetype (); + virtual idl_bool is_valuetype (void); + + // Data accessors. + + virtual idl_bool is_abstract_valuetype (void); + + virtual void set_abstract_valuetype (void); // Narrowing. DEF_NARROW_METHODS1 (be_valuetype, be_interface); @@ -122,7 +116,8 @@ public: private: - char * full_obv_skel_name_; + char *full_obv_skel_name_; + idl_bool abstract_; }; diff --git a/TAO/TAO_IDL/include/ast_argument.h b/TAO/TAO_IDL/include/ast_argument.h index 9ce7f09b33d..7556eae350a 100644 --- a/TAO/TAO_IDL/include/ast_argument.h +++ b/TAO/TAO_IDL/include/ast_argument.h @@ -62,57 +62,58 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_ARGUMENT_AST_ARGUMENT_HH #define _AST_ARGUMENT_AST_ARGUMENT_HH // Representation of argument to operation: -// // An argument is a field with a direction attached -/* -** DEPENDENCIES: ast_field.hh, utl_scoped_name.hh, ast_type.hh -** utl_strlist.hh, ast_decl.hh -** -** USE: Included from ast.hh -*/ - -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "ast_field.h" +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "ast_field.h" class TAO_IDL_FE_Export AST_Argument : public virtual AST_Field { public: - // Define enum with values denoting argument passing directions - enum Direction {dir_IN, dir_OUT, dir_INOUT}; + // Define enum with values denoting argument passing directions. + enum Direction + { + dir_IN, + dir_OUT, + dir_INOUT + }; + + // Operations. - // Operations + // Constructor(s). + AST_Argument (void); - // Constructor(s) - AST_Argument (); - AST_Argument (Direction direction, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p); + AST_Argument (Direction direction, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p); + // Destructor. virtual ~AST_Argument (void); - // Data Accessors - Direction direction(); + // Data Accessors. + Direction direction (void); // Narrowing DEF_NARROW_METHODS1(AST_Argument, AST_Field); DEF_NARROW_FROM_DECL(AST_Argument); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - const Direction pd_direction; // Argument direction + // Data. + + const Direction pd_direction; + // Argument direction }; #endif // _AST_ARGUMENT_AST_ARGUMENT_HH diff --git a/TAO/TAO_IDL/include/ast_array.h b/TAO/TAO_IDL/include/ast_array.h index a3af6e32aa2..16a2ec42794 100644 --- a/TAO/TAO_IDL/include/ast_array.h +++ b/TAO/TAO_IDL/include/ast_array.h @@ -62,61 +62,67 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_ARRAY_AST_ARRAY_HH #define _AST_ARRAY_AST_ARRAY_HH // Representation of array declaration: -// // An array is a combination of a list of dimensions and a base type -/* -** DEPENDENCIES: ast_concrete_type.hh, utl_exprlist.hh, ast_type.hh, -** ast_decl.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_Array : public virtual AST_ConcreteType { public: - // Operations + // Operations. + + // Constructor(s). + AST_Array (void); - // Constructor(s) - AST_Array (); AST_Array (UTL_ScopedName *n, unsigned long ndims, UTL_ExprList *dims, idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Array (void); - // Data Accessors - unsigned long n_dims(); - AST_Expression **dims(); - void set_dims(AST_Expression **, unsigned long); - AST_Type *base_type(); - void set_base_type(AST_Type *nbt); + // Data Accessors. + + unsigned long n_dims (void); + + AST_Expression **dims (void); - // Narrowing + void set_dims (AST_Expression **, + unsigned long); + + AST_Type *base_type (void); + + void set_base_type (AST_Type *nbt); + + // Narrowing. DEF_NARROW_METHODS1(AST_Array, AST_ConcreteType); DEF_NARROW_FROM_DECL(AST_Array); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - unsigned long pd_n_dims; // How many dimensions? - AST_Expression **pd_dims; // Their expressions - AST_Type *pd_base_type; // Base type of array + // Data. + + unsigned long pd_n_dims; + // How many dimensions? + + AST_Expression **pd_dims; + // Their expressions. + + AST_Type *pd_base_type; + // Base type of array. - // Operations + // Operations. - // Compute how many dimensions - AST_Expression **compute_dims(UTL_ExprList *dims, - unsigned long ndims); + // Compute how many dimensions. + AST_Expression **compute_dims (UTL_ExprList *dims, + unsigned long ndims); }; #endif // _AST_ARRAY_AST_ARRAY_HH diff --git a/TAO/TAO_IDL/include/ast_attribute.h b/TAO/TAO_IDL/include/ast_attribute.h index b822ce57c79..3c1fd213ca2 100644 --- a/TAO/TAO_IDL/include/ast_attribute.h +++ b/TAO/TAO_IDL/include/ast_attribute.h @@ -62,29 +62,22 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_ATTRIBUTE_AST_ATTRIBUTE_HH #define _AST_ATTRIBUTE_AST_ATTRIBUTE_HH // Representation of attribute declaration: -// // An attribute is a field with a readonly property -/* -** DEPENDENCIES: ast_field.hh, ast_type.hh, utl_scoped_name.hh, -** utl_strlist.hh, ast_decl.hh -** -** USE: Included from ast.h -*/ - class TAO_IDL_FE_Export AST_Attribute : public virtual AST_Field { public: - // Operations + // Operations. + + // Constructor(s). + AST_Attribute (void); - // Constructor(s) - AST_Attribute (); AST_Attribute (idl_bool readonly, AST_Type *ft, UTL_ScopedName *n, @@ -92,21 +85,25 @@ public: idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Attribute (void); - // Data Accessors - idl_bool readonly(); + // Data Accessors. + + idl_bool readonly (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS1(AST_Attribute, AST_Field); DEF_NARROW_FROM_DECL(AST_Attribute); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - const idl_bool pd_readonly; // Is attribute read-only? + // Data. + + const idl_bool pd_readonly; + // Is attribute read-only? }; #endif // _AST_ATTRIBUTE_AST_ATTRIBUTE_HH diff --git a/TAO/TAO_IDL/include/ast_concrete_type.h b/TAO/TAO_IDL/include/ast_concrete_type.h index 1e61f3cf3eb..2cb530907c9 100644 --- a/TAO/TAO_IDL/include/ast_concrete_type.h +++ b/TAO/TAO_IDL/include/ast_concrete_type.h @@ -62,35 +62,30 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_CONCRETE_TYPE_AST_CONCRETE_TYPE_HH #define _AST_CONCRETE_TYPE_AST_CONCRETE_TYPE_HH -// Class for all concrete types -// -// This is useful to group together IDL types other than objects - -/* -** DEPENDENCIES: ast_type.hh, ast_decl.hh, utl_scoped_name.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ +// Class for all concrete types. +// This is useful to group together IDL types other than objects. class TAO_IDL_FE_Export AST_ConcreteType : public virtual AST_Type { public: - // Operations + // Operations. + + // Constructor(s). + AST_ConcreteType (void); - // Constructor(s) - AST_ConcreteType (); AST_ConcreteType (AST_Decl::NodeType nt, UTL_ScopedName *n, UTL_StrList *p); + // Destructor. virtual ~AST_ConcreteType (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS1(AST_ConcreteType, AST_Type); DEF_NARROW_FROM_DECL(AST_ConcreteType); }; diff --git a/TAO/TAO_IDL/include/ast_constant.h b/TAO/TAO_IDL/include/ast_constant.h index 2bf783ef3ed..b59ab4be8f4 100644 --- a/TAO/TAO_IDL/include/ast_constant.h +++ b/TAO/TAO_IDL/include/ast_constant.h @@ -62,7 +62,7 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_CONSTANT_AST_CONSTANT_HH #define _AST_CONSTANT_AST_CONSTANT_HH @@ -77,41 +77,47 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // parameter. This constructor is used from AST_EnumVal, which is // just a glorified AST_Constant -/* -** DEPENDENCIES: ast_decl.hh, ast_expression.hh, utl_scoped_name.hh, -** utl_strlist.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_Constant : public virtual AST_Decl { public: - // Operations - - // Constructor(s) - AST_Constant(); - AST_Constant(AST_Expression::ExprType et, AST_Decl::NodeType nt, - AST_Expression *ev, UTL_ScopedName *n, UTL_StrList *p); - AST_Constant(AST_Expression::ExprType et, AST_Expression *ev, - UTL_ScopedName *n, UTL_StrList *p); + // Operations. + + // Constructor(s). + AST_Constant (void); + + AST_Constant (AST_Expression::ExprType et, + AST_Decl::NodeType nt, + AST_Expression *ev, + UTL_ScopedName *n, + UTL_StrList *p); + + AST_Constant (AST_Expression::ExprType et, + AST_Expression *ev, + UTL_ScopedName *n, + UTL_StrList *p); + + // Destructor. virtual ~AST_Constant (void); - // Data Accessors - AST_Expression *constant_value(); - AST_Expression::ExprType et(); + // Data Accessors. + AST_Expression *constant_value (void); + + AST_Expression::ExprType et (void); // Narrowing DEF_NARROW_METHODS1(AST_Constant, AST_Decl); DEF_NARROW_FROM_DECL(AST_Constant); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - AST_Expression *pd_constant_value; // The value - AST_Expression::ExprType pd_et; // Its expr type + // Data. + AST_Expression *pd_constant_value; + // The value. + + AST_Expression::ExprType pd_et; + // Its expression type. }; #endif // _AST_CONSTANT_AST_CONSTANT_HH diff --git a/TAO/TAO_IDL/include/ast_decl.h b/TAO/TAO_IDL/include/ast_decl.h index c9fa7e4ab0f..66f6c7a7fc5 100644 --- a/TAO/TAO_IDL/include/ast_decl.h +++ b/TAO/TAO_IDL/include/ast_decl.h @@ -80,11 +80,11 @@ trademarks or registered trademarks of Sun Microsystems, Inc. ** USE: Included from ast.hh */ -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "idl_bool.h" -#include "utl_scoped_name.h" -#include "utl_string.h" +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "idl_bool.h" +#include "utl_scoped_name.h" +#include "utl_string.h" // This is for AIX w/IBM C++ class Identifier; @@ -105,10 +105,10 @@ public: virtual idl_bool is_local (void); virtual idl_bool is_abstract (void); - // A no-op, overridden in the BE classes + // A no-op, overridden in the child classes. virtual void destroy (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS0(COMMON_Base); protected: @@ -119,68 +119,93 @@ protected: class TAO_IDL_FE_Export AST_Decl : public virtual COMMON_Base { public: - // Enum defining the different kinds of AST nodes + // Enum defining the different kinds of AST nodes. enum NodeType { - NT_module // Denotes a module - , NT_root // Denotes the root of AST - , NT_interface // Denotes an interface - , NT_interface_fwd // Fwd declared interface - , NT_const // Denotes a constant - , NT_except // Denotes an exception - , NT_attr // Denotes an attribute - , NT_op // Denotes an operation - , NT_argument // Denotes an op. argument - , NT_union // Denotes a union - , NT_union_branch // Denotes a union branch - , NT_struct // Denotes a structure - , NT_field // Denotes a field in structure - , NT_enum // Denotes an enumeration - , NT_enum_val // Denotes an enum. value - , NT_string // Denotes an IDL string - , NT_wstring // Denotes an IDL wstring - , NT_array // Denotes an IDL array - , NT_sequence // Denotes an IDL sequence - , NT_typedef // Denotes a typedef - , NT_pre_defined // Denotes a predefined type - , NT_native // Denotes a native type - // dependent on the programming - // language + NT_module // Denotes a module + , NT_root // Denotes the root of AST + , NT_interface // Denotes an interface + , NT_interface_fwd // Fwd declared interface + , NT_const // Denotes a constant + , NT_except // Denotes an exception + , NT_attr // Denotes an attribute + , NT_op // Denotes an operation + , NT_argument // Denotes an op. argument + , NT_union // Denotes a union + , NT_union_branch // Denotes a union branch + , NT_struct // Denotes a structure + , NT_field // Denotes a field in structure + , NT_enum // Denotes an enumeration + , NT_enum_val // Denotes an enum. value + , NT_string // Denotes an IDL string + , NT_wstring // Denotes an IDL wstring + , NT_array // Denotes an IDL array + , NT_sequence // Denotes an IDL sequence + , NT_typedef // Denotes a typedef + , NT_pre_defined // Denotes a predefined type + , NT_native // Denotes a native type + // dependent on the programming + // language }; - // Operations + // Operations. + + // Constructor(s). + AST_Decl (void); + + AST_Decl (NodeType type, + UTL_ScopedName *n, + UTL_StrList *pragmas); + + virtual ~AST_Decl (void); + + // Data Accessors. + + idl_bool imported (void); + + void set_imported (idl_bool is_it); + + idl_bool in_main_file (void); + + void set_in_main_file (idl_bool is_it); + + UTL_Scope *defined_in (void); + + void set_defined_in (UTL_Scope *); - // Constructor(s) - AST_Decl(); - AST_Decl(NodeType type, UTL_ScopedName *n, UTL_StrList *pragmas); - virtual ~AST_Decl(); - - // Data Accessors - idl_bool imported(); - void set_imported(idl_bool is_it); - idl_bool in_main_file(); - void set_in_main_file(idl_bool is_it); - UTL_Scope *defined_in(); - void set_defined_in(UTL_Scope *); - NodeType node_type(); - long line(); - void set_line(long l); - UTL_String *file_name(); - void set_file_name(UTL_String *s); - - UTL_ScopedName *name(); - - UTL_ScopedName *compute_name (const char *prefix, const char *suffix); + NodeType node_type (void); + + long line (void); + + void set_line (long l); + + UTL_String *file_name (void); + + void set_file_name (UTL_String *s); + + UTL_ScopedName *name (void); + + UTL_ScopedName *compute_name (const char *prefix, + const char *suffix); // Variation of the <name>. Computes scoped name string, applying // prefix and suffix to the local name component. - void set_name(UTL_ScopedName *n); + void set_name (UTL_ScopedName *n); - Identifier *local_name (); + Identifier *local_name (void); - Identifier *compute_local_name (const char *prefix, const char *sufix); + Identifier *compute_local_name (const char *prefix, + const char *sufix); // Apply prefix and suffix to the local name and return. - // + virtual const char *full_name (void); + // Return the stringified full name. + + const char *repoID (void); + // Retrieve the repository ID. + + const char *prefix (void); + // Retrieve the repository ID prefix. + // If there is _cxx_ in the beginning, we will remove that and keep // a copy of the original name. TAO IDL's front end adds _cxx_ // prefix to the all the reserved keywords. But when we invoke the @@ -194,44 +219,91 @@ public: void original_local_name (Identifier *); // Set. - void add_pragmas(UTL_StrList *p); - UTL_StrList *pragmas(); - idl_bool added(); - void set_added(idl_bool is_it); + void add_pragmas (UTL_StrList *p); + + UTL_StrList *pragmas (void); - // Narrowing + idl_bool added (void); + + void set_added (idl_bool is_it); + + // Narrowing. DEF_NARROW_METHODS0(AST_Decl); DEF_NARROW_FROM_DECL(AST_Decl); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); // Cleanup method. virtual void destroy (void); // Other operations - // Return TRUE if "this" has "s" as an ancestor - idl_bool has_ancestor(AST_Decl *s); + // Return TRUE if "this" has "s" as an ancestor. + idl_bool has_ancestor (AST_Decl *s); + +protected: + // These are not private because they're used by + // be_predefined_type' constructor. + + char *repoID_; + // Repository ID. + + void compute_repoID (void); + // Computes the repoID. + + void compute_full_name (void); + // Computes the stringified scoped name. private: // Data - idl_bool pd_imported; // Imported? - idl_bool pd_in_main_file; // Defined in main file? - UTL_Scope *pd_defined_in; // Scope - NodeType pd_node_type; // What kind of node - long pd_line; // Line defined in - UTL_String *pd_file_name; // What file defined in - UTL_ScopedName *pd_name; // As given - Identifier *pd_local_name; // Name in scope - Identifier *pd_original_local_name; // _cxx_ removed if any. - UTL_StrList *pd_pragmas; // Pragmas - idl_bool pd_added; // already added + + idl_bool pd_imported; + // Imported? + + idl_bool pd_in_main_file; + // Defined in main file? + + UTL_Scope *pd_defined_in; + // Scope. + + NodeType pd_node_type; + // What kind of node. + + long pd_line; + // Line defined in. + + UTL_String *pd_file_name; + // What file defined in. + + UTL_ScopedName *pd_name; + // As given. + + Identifier *pd_local_name; + // Name in scope. + + Identifier *pd_original_local_name; + // _cxx_ removed if any. + + UTL_StrList *pd_pragmas; + // Pragmas. + + idl_bool pd_added; + // Already added. + + char *full_name_; + // Our full scoped name. + + char *prefix_; + // The repository ID prefix. // Operations - // Compute the full name of an AST node - void compute_full_name(UTL_ScopedName *n); + void compute_prefix (void); + // Computes the prefix for the repoID. + + // Compute the full name of an AST node. + void compute_full_name (UTL_ScopedName *n); }; #endif // _AST_DECL_AST_DECL_HH diff --git a/TAO/TAO_IDL/include/ast_enum.h b/TAO/TAO_IDL/include/ast_enum.h index 1a6455c0e89..4aa7bb1b8ad 100644 --- a/TAO/TAO_IDL/include/ast_enum.h +++ b/TAO/TAO_IDL/include/ast_enum.h @@ -80,15 +80,16 @@ class TAO_IDL_FE_Export AST_Enum : public virtual AST_ConcreteType, public virtual UTL_Scope { public: - // Operations + // Operations. // Constructor(s) - AST_Enum (); + AST_Enum (void); AST_Enum (UTL_ScopedName *n, UTL_StrList *p, idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Enum (void); // Narrowing @@ -96,28 +97,35 @@ public: DEF_NARROW_FROM_DECL(AST_Enum); DEF_NARROW_FROM_SCOPE(AST_Enum); - // AST Dumping - virtual void dump(ostream &); - - // Other operations + // AST Dumping. + virtual void dump (ostream &); // Look up an AST_EnumVal by value - virtual AST_EnumVal *lookup_by_value(const AST_Expression *v); + virtual AST_EnumVal *lookup_by_value (const AST_Expression *v); + + // Get value to be assigned to next enumerator. + virtual unsigned long next_enum_val (void); - // Get value to be assigned to next enumerator - virtual unsigned long next_enum_val(); + // Return the count of members + virtual int member_count (void); // Cleanup function. virtual void destroy (void); private: - // Data - unsigned long pd_enum_counter; // Value for next - // enumerator - // Scope management - friend int tao_yyparse(); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); + friend int tao_yyparse (void); + + int compute_member_count (void); + // Count the number of members. + + int member_count_; + // Number of members. + + unsigned long pd_enum_counter; + // Value for next enumerator. + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); + // Scope Management. }; #endif // _AST_ENUM_AST_ENUM_HH diff --git a/TAO/TAO_IDL/include/ast_enum_val.h b/TAO/TAO_IDL/include/ast_enum_val.h index 47a67f101c8..4fdb844c440 100644 --- a/TAO/TAO_IDL/include/ast_enum_val.h +++ b/TAO/TAO_IDL/include/ast_enum_val.h @@ -62,41 +62,36 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_ENUM_VAL_AST_ENUM_VAL_HH #define _AST_ENUM_VAL_AST_ENUM_VAL_HH -// Representation of enumerator in enum: -// -// An enumerator is a constant of type unsigned long +// Representation of enumerator in enum. -/* -** DEPENDENCIES: ast_constant.hh, utl_scoped_name.hh, utl_strlist.hh, -** ast_decl.hh -** -** USE: Included from ast.hh -*/ +// An enumerator is a constant of type unsigned long. class TAO_IDL_FE_Export AST_EnumVal : public virtual AST_Constant { public: - // Operations + // Operations. + + // Constructor(s). + AST_EnumVal (void); - // Constructor(s) - AST_EnumVal (); AST_EnumVal (unsigned long v, UTL_ScopedName *n, UTL_StrList *p); + // Destructor. virtual ~AST_EnumVal (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS1(AST_EnumVal, AST_Constant); DEF_NARROW_FROM_DECL(AST_EnumVal); - // AST Dumping - virtual void dump(ostream &); + // AST Dumping. + virtual void dump (ostream &); }; #endif // _AST_ENUM_VAL_AST_ENUM_VAL_HH diff --git a/TAO/TAO_IDL/include/ast_exception.h b/TAO/TAO_IDL/include/ast_exception.h index 632a1625915..ce22104d985 100644 --- a/TAO/TAO_IDL/include/ast_exception.h +++ b/TAO/TAO_IDL/include/ast_exception.h @@ -62,36 +62,25 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_EXCEPTION_AST_EXCEPTION_HH #define _AST_EXCEPTION_AST_EXCEPTION_HH -// Representation of exception -// -// NOTE: An exception is not a type according to the CORBAS 1.1 -// -// NOTE: add(AST_ConcreteType *) is defined here because an exception +// NOTE: add (AST_ConcreteType *) is defined here because an exception // can contain locally defined types in addition to fields. // -// NOTE: add(AST_EnumValue *) is defined here because enums can +// NOTE: add (AST_EnumValue *) is defined here because enums can // be defined manifest locally; the constants defined in these // enums are inserted in the enclosing scope. It is unlikely that // a BE writer will need to overload this function in AST_Exception. -/* -** DEPENDENCIES: ast_decl.hh, ast_structure.hh, utl_scope.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_Exception : public virtual AST_Structure { public: - // Operations + // Constructor(s). + AST_Exception (void); - // Constructor(s) - AST_Exception (); AST_Exception (UTL_ScopedName *n, UTL_StrList *p, idl_bool local, @@ -99,24 +88,26 @@ public: virtual ~AST_Exception (void); + virtual idl_bool in_recursion (AST_Type *node = 0); + // Check if we or the parameter node is in recursion. + // Narrowing DEF_NARROW_METHODS1(AST_Exception, AST_Structure); DEF_NARROW_FROM_DECL(AST_Exception); DEF_NARROW_FROM_SCOPE(AST_Exception); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - friend int tao_yyparse(); - // Scope Management Protocol - - virtual AST_Field *fe_add_field(AST_Field *f); - virtual AST_Union *fe_add_union(AST_Union *u); - virtual AST_Structure *fe_add_structure(AST_Structure *s); - virtual AST_Enum *fe_add_enum(AST_Enum *e); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); + friend int tao_yyparse (void); + // Scope Management Protocol + virtual AST_Field *fe_add_field (AST_Field *f); + virtual AST_Union *fe_add_union (AST_Union *u); + virtual AST_Structure *fe_add_structure (AST_Structure *s); + virtual AST_Enum *fe_add_enum (AST_Enum *e); + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); }; #endif // _AST_EXCEPTION_AST_EXCEPTION_HH diff --git a/TAO/TAO_IDL/include/ast_expression.h b/TAO/TAO_IDL/include/ast_expression.h index 7c69f84380f..f1ed7c3edf8 100644 --- a/TAO/TAO_IDL/include/ast_expression.h +++ b/TAO/TAO_IDL/include/ast_expression.h @@ -62,190 +62,236 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_EXPRESSION_AST_EXPRESSION_HH #define _AST_EXPRESSION_AST_EXPRESSION_HH #include "ace/CDR_Stream.h" -// Representation of expression values - -/* -** DEPENDENCIES: NONE -** -** USE: Included from ast.hh -*/ +// Representation of expression values. -// An expression (and maybe its value, if computed) +// An expression (and maybe its value, if computed). class TAO_IDL_FE_Export AST_Expression { public: - // Enum to define all the different operators to combine expressions - enum ExprComb { - EC_add // '+' - , EC_minus // '-' - , EC_mul // '*' - , EC_div // '/' - , EC_mod // '%' - , EC_or // '|' - , EC_xor // '^' - , EC_and // '&' - , EC_left // '<<' - , EC_right // '>>' - , EC_u_plus // unary '+' - , EC_u_minus // unary '-' - , EC_bit_neg // '~' - , EC_none // No operator (missing) - , EC_symbol // a symbol (function or constant name) - }; + // Enum to define all the different operators to combine expressions. + enum ExprComb + { + EC_add // '+' + , EC_minus // '-' + , EC_mul // '*' + , EC_div // '/' + , EC_mod // '%' + , EC_or // '|' + , EC_xor // '^' + , EC_and // '&' + , EC_left // '<<' + , EC_right // '>>' + , EC_u_plus // unary '+' + , EC_u_minus // unary '-' + , EC_bit_neg // '~' + , EC_none // No operator (missing). + , EC_symbol // A symbol (function or constant name). + }; // Enum to define the different kinds of evaluation possible - // Extend this for more kinds of evaluation as required - enum EvalKind { - EK_const // Must evaluate to constant - , EK_positive_int // Must evaluate to positive integer + // Extend this for more kinds of evaluation as required. + enum EvalKind + { + EK_const // Must evaluate to constant. + , EK_positive_int // Must evaluate to positive integer. // @@ (JP) I added these to get the ~ operator to work with all the // relevant aritmetic types, but eventually, we should get rid of // this whole enum. - , EK_short - , EK_ushort - , EK_long - , EK_ulong - , EK_longlong - , EK_ulonglong - , EK_octet - }; - - // Enum to define expression type - enum ExprType { - EV_short // Expression value is short - , EV_ushort // Expression value is unsigned short - , EV_long // Expression value is long - , EV_ulong // Expression value is unsigned long - , EV_longlong // Expression value is long long - , EV_ulonglong // Expression value is unsigned long long - , EV_float // Expression value is 32-bit float - , EV_double // Expression value is 64-bit float - , EV_longdouble // Expression value is 128-bit float - , EV_char // Expression value is char - , EV_wchar // Expression value is wide char - , EV_octet // Expression value is unsigned char - , EV_bool // Expression value is boolean - , EV_string // Expression value is char * - , EV_wstring // Expression value is wide string - , EV_any // Expression value is any of above - , EV_void // Expression value is void (absent) - , EV_none // Expression value is missing - }; - - // Structure to describe value of constant expression and its type - struct AST_ExprValue { - union { - short sval; // Contains short expression value - unsigned short usval; // Contains unsigned short expr value - long lval; // Contains long expression value - unsigned long ulval; // Contains unsigned long expr value - unsigned long bval; // Contains boolean expression value + , EK_short + , EK_ushort + , EK_long + , EK_ulong + , EK_longlong + , EK_ulonglong + , EK_octet + }; + + // Enum to define expression type. + enum ExprType + { + EV_short // Expression value is short. + , EV_ushort // Expression value is unsigned short. + , EV_long // Expression value is long. + , EV_ulong // Expression value is unsigned long. + , EV_longlong // Expression value is long long. + , EV_ulonglong // Expression value is unsigned long long. + , EV_float // Expression value is 32-bit float. + , EV_double // Expression value is 64-bit float. + , EV_longdouble // Expression value is 128-bit float. + , EV_char // Expression value is char. + , EV_wchar // Expression value is wide char. + , EV_octet // Expression value is unsigned char. + , EV_bool // Expression value is boolean. + , EV_string // Expression value is char *. + , EV_wstring // Expression value is wide string. + , EV_any // Expression value is any of above. + , EV_void // Expression value is void (absent). + , EV_none // Expression value is missing. + }; + + // Structure to describe value of constant expression and its type. + struct AST_ExprValue + { + union + { + short sval; // Contains short expression value. + unsigned short usval; // Contains unsigned short expr value. + long lval; // Contains long expression value. + unsigned long ulval; // Contains unsigned long expr value. + unsigned long bval; // Contains boolean expression value. #if ! defined (ACE_LACKS_LONGLONG_T) - ACE_CDR::LongLong llval; // Contains long long expr value - ACE_CDR::ULongLong ullval; // Contains unsigned long long expr value + ACE_CDR::LongLong llval; // Contains long long expr value. + ACE_CDR::ULongLong ullval; // Contains unsigned long long expr value. #endif /* ! defined (ACE_LACKS_LONGLONG_T) */ - float fval; // Contains 32-bit float expr value - double dval; // Contains 64-bit float expr value - char cval; // Contains char expression value - ACE_CDR::WChar wcval; // Contains wchar expression value - unsigned char oval; // Contains unsigned char expr value - UTL_String *strval; // Contains String * expr value - char *wstrval; // Contains wide string expr value - unsigned long eval; // Contains enumeration value - } u; - ExprType et; - }; - - // Operations - - // Constructor(s) - AST_Expression(AST_Expression *v, ExprType t); - - AST_Expression(ExprComb c, AST_Expression *v1, AST_Expression *v2); - - AST_Expression(short s); - AST_Expression(unsigned short us); - AST_Expression(long l); - AST_Expression(long l, ExprType t); - AST_Expression(unsigned long ul); - AST_Expression(float f); - AST_Expression(double d); - AST_Expression(char c); - AST_Expression(ACE_OutputCDR::from_wchar wc); - AST_Expression(unsigned char uc); - AST_Expression(UTL_String *s); - AST_Expression(char *s); - AST_Expression(UTL_ScopedName *n); + float fval; // Contains 32-bit float expr value. + double dval; // Contains 64-bit float expr value. + char cval; // Contains char expression value. + ACE_CDR::WChar wcval; // Contains wchar expression value. + unsigned char oval; // Contains unsigned char expr value. + UTL_String *strval; // Contains String * expr value. + char *wstrval; // Contains wide string expr value. + unsigned long eval; // Contains enumeration value. + } u; + + ExprType et; + }; + + // Operations. + + // Constructor(s). + AST_Expression (AST_Expression *v, + ExprType t); + + AST_Expression (ExprComb c, + AST_Expression *v1, + AST_Expression *v2); + + AST_Expression (short s); + + AST_Expression (unsigned short us); + + AST_Expression (long l); + + AST_Expression (long l, + ExprType t); + AST_Expression (unsigned long ul); + + AST_Expression (float f); + + AST_Expression (double d); + + AST_Expression (char c); + + AST_Expression (ACE_OutputCDR::from_wchar wc); + + AST_Expression (unsigned char uc); + + AST_Expression (UTL_String *s); + + AST_Expression (char *s); + + AST_Expression (UTL_ScopedName *n); + + // Destructor. virtual ~AST_Expression (void); - // Data Accessors - UTL_Scope *defined_in(); - void set_defined_in(UTL_Scope *d); - long line(); - void set_line(long l); - UTL_String *file_name(); - void set_file_name(UTL_String *f); - ExprComb ec(); - void set_ec(ExprComb new_ec); - AST_ExprValue *ev(); - void set_ev(AST_ExprValue *new_ev); - AST_Expression *v1(); - void set_v1(AST_Expression *e); - AST_Expression *v2(); - void set_v2(AST_Expression *e); - UTL_ScopedName *n(); - void set_n(UTL_ScopedName *new_n); - - // AST Dumping - virtual void dump(ostream &o); - - // Other operations - - // Evaluation and value coercion - virtual AST_ExprValue *eval(EvalKind ek); - virtual AST_ExprValue *coerce(ExprType t); - - // Evaluate then store value inside this AST_Expression - virtual void evaluate(EvalKind ek); - - // Compare to AST_Expressions - virtual long operator==(AST_Expression *vc); - virtual long compare(AST_Expression *vc); + // Data Accessors. + UTL_Scope *defined_in (void); + void set_defined_in (UTL_Scope *d); + + long line (void); + void set_line (long l); + + UTL_String *file_name (void); + void set_file_name (UTL_String *f); + + ExprComb ec (void); + void set_ec (ExprComb new_ec); + + AST_ExprValue *ev (void); + void set_ev (AST_ExprValue *new_ev); + + AST_Expression *v1 (void); + void set_v1 (AST_Expression *e); + + AST_Expression *v2 (void); + void set_v2 (AST_Expression *e); + + UTL_ScopedName *n (void); + void set_n (UTL_ScopedName *new_n); + + // AST Dumping. + virtual void dump (ostream &o); + + // Other operations. + + // Evaluation and value coercion. + + virtual AST_ExprValue *eval (EvalKind ek); + + virtual AST_ExprValue *coerce (ExprType t); + + // Evaluate then store value inside this AST_Expression. + virtual void evaluate (EvalKind ek); + + // Compare to AST_Expressions. + + virtual long operator== (AST_Expression *vc); + + virtual long compare (AST_Expression *vc); protected: - // Evaluate different sets of operators - virtual AST_ExprValue *eval_bin_op(EvalKind ek); - virtual AST_ExprValue *eval_bit_op(EvalKind ek); - virtual AST_ExprValue *eval_un_op(EvalKind ek); - virtual AST_ExprValue *eval_symbol(EvalKind ek); + // Evaluate different sets of operators. + virtual AST_ExprValue *eval_bin_op (EvalKind ek); + + virtual AST_ExprValue *eval_bit_op (EvalKind ek); + + virtual AST_ExprValue *eval_un_op (EvalKind ek); + + virtual AST_ExprValue *eval_symbol (EvalKind ek); private: - // Data - UTL_Scope *pd_defined_in; // Scope - long pd_line; // Line defined in - UTL_String *pd_file_name; // What file defined in + // Data. + + UTL_Scope *pd_defined_in; + // Scope. + + long pd_line; + // Line defined in. + + UTL_String *pd_file_name; + // What file defined in. + + ExprComb pd_ec; + // What combinator. + + AST_ExprValue *pd_ev; + // Computed value. + + AST_Expression *pd_v1; + // 1st sub-expression. + + AST_Expression *pd_v2; + // 2nd sub-expression. - ExprComb pd_ec; // What combinator - AST_ExprValue *pd_ev; // computed value - AST_Expression *pd_v1; // 1st sub-expression - AST_Expression *pd_v2; // 2nd sub-expression - UTL_ScopedName *pd_n; // symbolic name (if any) + UTL_ScopedName *pd_n; + // Symbolic name (if any). // Operations - // Fill out the lineno, filename and definition scope details - void fill_definition_details(); + // Fill out the lineno, filename and definition scope details. + void fill_definition_details (void); - // Internal evaluation - virtual AST_ExprValue *eval_internal(EvalKind ek); + // Internal evaluation. + virtual AST_ExprValue *eval_internal (EvalKind ek); }; #endif // _AST_EXPR_VAL_AST_EXPR_VAL_HH diff --git a/TAO/TAO_IDL/include/ast_field.h b/TAO/TAO_IDL/include/ast_field.h index 4c96b3f86ec..c85684b5761 100644 --- a/TAO/TAO_IDL/include/ast_field.h +++ b/TAO/TAO_IDL/include/ast_field.h @@ -62,13 +62,13 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_FIELD_AST_FIELD_HH #define _AST_FIELD_AST_FIELD_HH // Representation of a generic field -// + // Used as member in structures, exceptions and unions, and as a base // type for attributes and arguments to operations // @@ -76,25 +76,25 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // is used directly inside a structure, the second when it is used as // the base type for attributes and operations. -/* -** DEPENDENCIES: ast_decl.hh, ast_type.hh, utl_scoped_name.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ - -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "ast_decl.h" +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "ast_decl.h" class TAO_IDL_FE_Export AST_Field : public virtual AST_Decl { public: - enum Visibility {vis_NA, vis_PUBLIC, vis_PRIVATE}; - // Operations + enum Visibility + { + vis_NA, + vis_PUBLIC, + vis_PRIVATE + }; + + // Operations. - // Constructor(s) - AST_Field (); + // Constructor(s). + AST_Field (void); AST_Field (AST_Type *field_type, UTL_ScopedName *n, @@ -109,21 +109,25 @@ public: virtual ~AST_Field (void); - // Data Accessors - AST_Type *field_type(); - Visibility visibility(); + // Data Accessors. + AST_Type *field_type (void); + + Visibility visibility (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS1(AST_Field, AST_Decl); DEF_NARROW_FROM_DECL(AST_Field); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - AST_Type *pd_field_type; // Base type for field - Visibility pd_visibility; + // Data. + + AST_Type *pd_field_type; + // Base type for field. + + Visibility pd_visibility; }; #endif // _AST_FIELD_AST_FIELD_HH diff --git a/TAO/TAO_IDL/include/ast_generator.h b/TAO/TAO_IDL/include/ast_generator.h index e6ae673407b..a9fd8a7064a 100644 --- a/TAO/TAO_IDL/include/ast_generator.h +++ b/TAO/TAO_IDL/include/ast_generator.h @@ -62,196 +62,193 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_GENERATOR_AST_GENERATOR_HH #define _AST_GENERATOR_AST_GENERATOR_HH -// ast_generator.h -// -// Defines base class for generators - -/* -** DEPENDENCIES: ast_predefined_type.hh utl_scoped_name.hh utl_strlist.hh -** ast_module.hh ast_root.hh ast_interface.hh -** ast_interface_fwd.hh ast_exception.hh ast_structure.hh -** ast_enum.hh ast_operation.hh ast_type.hh ast_field.hh -** ast_argument.hh ast_attribute.hh ast_union.hh -** ast_concrete_type.hh ast_union_branch.hh ast_union_label.hh -** ast_expression.hh ast_enum_val.hh ast_array.hh -** ast_sequence.hh ast_string.hh ast_typedef.hh -** -** USE: Included from ast.hh -*/ +// Defines base class for node generators. class TAO_IDL_FE_Export AST_Generator { public: - // Operations - - // Create a node representing a predefined type - virtual AST_PredefinedType - *create_predefined_type(AST_PredefinedType::PredefinedType t, - UTL_ScopedName *n, - UTL_StrList *p); - - // Create a node representing a module - virtual AST_Module *create_module(UTL_Scope *s, - UTL_ScopedName *n, - UTL_StrList *p); - - // Create a node representing a module which is the root of an AST - virtual AST_Root *create_root(UTL_ScopedName *n, + // Operations. + + // Create a node representing a predefined type. + virtual AST_PredefinedType *create_predefined_type ( + AST_PredefinedType::PredefinedType t, + UTL_ScopedName *n, + UTL_StrList *p + ); + + // Create a node representing a module. + virtual AST_Module *create_module (UTL_Scope *s, + UTL_ScopedName *n, UTL_StrList *p); - // Create a node representing an interface - virtual AST_Interface *create_interface(UTL_ScopedName *n, - AST_Interface **ih, - long nih, - AST_Interface **ih_flat, - long nih_flat, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing a forward declaration of an interface - virtual AST_InterfaceFwd *create_interface_fwd(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing an valuetype - virtual AST_Interface *create_valuetype(UTL_ScopedName *n, - AST_Interface **ih, - long nih, - UTL_StrList *p); - - // Create a node representing a forward declaration of an valuetype - virtual AST_InterfaceFwd *create_valuetype_fwd(UTL_ScopedName *n, - UTL_StrList *p); - - // Create a node representing an exception - virtual AST_Exception *create_exception(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing a structure - virtual AST_Structure *create_structure(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing an enum - virtual AST_Enum *create_enum(UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing an operation on an interface - virtual AST_Operation *create_operation(AST_Type *rt, - AST_Operation::Flags fl, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); + // Create a node representing a module which is the root of an AST. + virtual AST_Root *create_root (UTL_ScopedName *n, + UTL_StrList *p); + + // Create a node representing an interface. + virtual AST_Interface *create_interface (UTL_ScopedName *n, + AST_Interface **ih, + long nih, + AST_Interface **ih_flat, + long nih_flat, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing a forward declaration of an interface. + virtual AST_InterfaceFwd *create_interface_fwd (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing an valuetype. + virtual AST_Interface *create_valuetype (UTL_ScopedName *n, + AST_Interface **ih, + long nih, + UTL_StrList *p); + + // Create a node representing a forward declaration of an valuetype. + virtual AST_InterfaceFwd *create_valuetype_fwd (UTL_ScopedName *n, + UTL_StrList *p); + + // Create a node representing an exception. + virtual AST_Exception *create_exception (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing a structure. + virtual AST_Structure *create_structure (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing an enum. + virtual AST_Enum *create_enum (UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing an operation on an interface. + virtual AST_Operation *create_operation (AST_Type *rt, + AST_Operation::Flags fl, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); // Create a node representing a field in a structure, exception or - // union - virtual AST_Field *create_field(AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p, - AST_Field::Visibility vis = AST_Field::vis_NA); - - // Create a node representing an argument to an operation - virtual AST_Argument *create_argument(AST_Argument::Direction d, + // union. + virtual AST_Field *create_field (AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p, + AST_Field::Visibility vis = + AST_Field::vis_NA); + + // Create a node representing an argument to an operation. + virtual AST_Argument *create_argument (AST_Argument::Direction d, AST_Type *ft, UTL_ScopedName *n, UTL_StrList *p); - // Create a node representing an attribute - virtual AST_Attribute *create_attribute(idl_bool ro, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing a union - virtual AST_Union *create_union(AST_ConcreteType *dt, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing one branch in a union - virtual AST_UnionBranch *create_union_branch(UTL_LabelList *ll, - AST_Type *ft, - UTL_ScopedName *n, - UTL_StrList *p); - - // Create a node representing a label on a union branch + // Create a node representing an attribute. + virtual AST_Attribute *create_attribute (idl_bool ro, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing a union. + virtual AST_Union *create_union (AST_ConcreteType *dt, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + + // Create a node representing one branch in a union. + virtual AST_UnionBranch *create_union_branch (UTL_LabelList *ll, + AST_Type *ft, + UTL_ScopedName *n, + UTL_StrList *p); + + // Create a node representing a label on a union branch. virtual AST_UnionLabel *create_union_label(AST_UnionLabel::UnionLabel ul, AST_Expression *lv); // Create a node representing a constant - virtual AST_Constant *create_constant(AST_Expression::ExprType et, + virtual AST_Constant *create_constant (AST_Expression::ExprType et, AST_Expression *ev, UTL_ScopedName *n, UTL_StrList *p); - // Create various kinds of nodes representing expressions - virtual AST_Expression *create_expr(UTL_ScopedName *n); - virtual AST_Expression *create_expr(AST_Expression *v, - AST_Expression::ExprType t); - virtual AST_Expression *create_expr(AST_Expression::ExprComb c, - AST_Expression *v1, - AST_Expression *v2); - virtual AST_Expression *create_expr(long v); - virtual AST_Expression *create_expr(long v, - AST_Expression::ExprType t); - virtual AST_Expression *create_expr(unsigned long v); - virtual AST_Expression *create_expr(UTL_String *s); - virtual AST_Expression *create_expr(char *s); - virtual AST_Expression *create_expr(char c); - virtual AST_Expression *create_expr(ACE_OutputCDR::from_wchar wc); - virtual AST_Expression *create_expr(double d); - - // Create a node representing an enumerator - virtual AST_EnumVal *create_enum_val(unsigned long v, - UTL_ScopedName *n, - UTL_StrList *p); + // Create various kinds of nodes representing expressions. - // Create a node representing an array type - virtual AST_Array *create_array(UTL_ScopedName *n, - unsigned long ndims, - UTL_ExprList *dims, - idl_bool local, - idl_bool abstract); + virtual AST_Expression *create_expr (UTL_ScopedName *n); + + virtual AST_Expression *create_expr (AST_Expression *v, + AST_Expression::ExprType t); - // Create a node representing a sequence type - virtual AST_Sequence *create_sequence(AST_Expression *v, + virtual AST_Expression *create_expr (AST_Expression::ExprComb c, + AST_Expression *v1, + AST_Expression *v2); + + virtual AST_Expression *create_expr (long v); + + virtual AST_Expression *create_expr (long v, + AST_Expression::ExprType t); + + virtual AST_Expression *create_expr (unsigned long v); + + virtual AST_Expression *create_expr (UTL_String *s); + + virtual AST_Expression *create_expr (char *s); + + virtual AST_Expression *create_expr (char c); + + virtual AST_Expression *create_expr (ACE_OutputCDR::from_wchar wc); + + virtual AST_Expression *create_expr (double d); + + // Create a node representing an enumerator. + virtual AST_EnumVal *create_enum_val (unsigned long v, + UTL_ScopedName *n, + UTL_StrList *p); + + // Create a node representing an array type. + virtual AST_Array *create_array (UTL_ScopedName *n, + unsigned long ndims, + UTL_ExprList *dims, + idl_bool local, + idl_bool abstract); + + // Create a node representing a sequence type. + virtual AST_Sequence *create_sequence (AST_Expression *v, AST_Type *bt, idl_bool local, idl_bool abstract); - // Create a node representing a string type - virtual AST_String *create_string(AST_Expression *v); + // Create a node representing a string type. + virtual AST_String *create_string (AST_Expression *v); - // Create a node representing a wide string type - virtual AST_String *create_wstring(AST_Expression *v); + // Create a node representing a wide string type. + virtual AST_String *create_wstring (AST_Expression *v); - // Create a node representing a type renaming (typedef) - virtual AST_Typedef *create_typedef(AST_Type *bt, - UTL_ScopedName *n, - UTL_StrList *p, - idl_bool local, - idl_bool abstract); - - // Create a node representing a native - virtual AST_Native *create_native (UTL_ScopedName *n, - UTL_StrList *p); + // Create a node representing a type renaming (typedef). + virtual AST_Typedef*create_typedef (AST_Type *bt, + UTL_ScopedName *n, + UTL_StrList *p, + idl_bool local, + idl_bool abstract); + // Create a node representing a native. + virtual AST_Native *create_native (UTL_ScopedName *n, + UTL_StrList *p); }; #endif // _AST_GENERATOR_AST_GENERATOR_HH diff --git a/TAO/TAO_IDL/include/ast_interface.h b/TAO/TAO_IDL/include/ast_interface.h index 2e9beaa23c7..0e621d01dd1 100644 --- a/TAO/TAO_IDL/include/ast_interface.h +++ b/TAO/TAO_IDL/include/ast_interface.h @@ -62,38 +62,29 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_INTERFACE_AST_INTERFACE_HH #define _AST_INTERFACE_AST_INTERFACE_HH -// Representation of interface: -// -// NOTE: add(AST_EnumValue *) is defined here because enums can +// NOTE: add (AST_EnumValue *) is defined here because enums can // be defined manifest locally; the constants defined in these // enums are inserted in the enclosing scope. -/* -** DEPENDENCIES: ast_type.hh, utl_scope.hh, ast_decl.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ - -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "ast_type.h" -#include "utl_scope.h" -#include "ast_decl.h" +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "ast_type.h" +#include "utl_scope.h" +#include "ast_decl.h" class TAO_IDL_FE_Export AST_Interface : public virtual AST_Type, public virtual UTL_Scope { public: - // Operations - - // Constructor(s) + // Constructor(s). AST_Interface (void); + AST_Interface (UTL_ScopedName *n, AST_Interface **ih, long nih, @@ -105,7 +96,7 @@ public: virtual ~AST_Interface (void); - // Data Accessors + // Data Accessors. static void fwd_redefinition_helper (AST_Interface *&i, UTL_Scope *s, UTL_StrList *p); @@ -114,16 +105,23 @@ public: UTL_StrList *p); AST_Interface **inherits (void); + void set_inherits (AST_Interface **i); + long n_inherits (void); + void set_n_inherits (long i); AST_Interface **inherits_flat (void); + void set_inherits_flat (AST_Interface **i); + long n_inherits_flat (void); + void set_n_inherits_flat (long i); void be_add_operation (AST_Operation *); + void be_replace_operation (AST_Decl *old_op, AST_Decl *new_op); @@ -136,7 +134,9 @@ public: } virtual idl_bool is_valuetype (void); + virtual idl_bool is_abstract_valuetype (void); + virtual void set_abstract_valuetype (void); // Check if any member's name clashes with a parent's @@ -147,45 +147,53 @@ public: // Cleanup function. virtual void destroy (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS2(AST_Interface, AST_Type, UTL_Scope); DEF_NARROW_FROM_DECL(AST_Interface); DEF_NARROW_FROM_SCOPE(AST_Interface); - // AST Dumping - virtual void dump (ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: // Helper function for fwd_redefinition_helper. static idl_bool compare_names (AST_Interface *that, AST_Interface *other); - // Data - // Immediate ancestors - AST_Interface **pd_inherits; // Inherited interfaces - // This is an array of pointers - // to the inherited interfaces - long pd_n_inherits; // How many of them? - - // All ancestors - AST_Interface **pd_inherits_flat; - long pd_n_inherits_flat; - - // Scope Management Protocol - friend int tao_yyparse(); - - virtual AST_Constant *fe_add_constant(AST_Constant *c); - virtual AST_Exception *fe_add_exception(AST_Exception *e); - virtual AST_Attribute *fe_add_attribute(AST_Attribute *a); - virtual AST_Field *fe_add_field(AST_Field *o); - virtual AST_Operation *fe_add_operation(AST_Operation *o); - virtual AST_Union *fe_add_union(AST_Union *u); - virtual AST_Structure *fe_add_structure(AST_Structure *s); - virtual AST_Enum *fe_add_enum(AST_Enum *e); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); - virtual AST_Typedef *fe_add_typedef(AST_Typedef *t); - virtual AST_Native *fe_add_native (AST_Native *n); + // Data. + + // Immediate ancestors. + AST_Interface **pd_inherits; + long pd_n_inherits; + + // All ancestors. + AST_Interface **pd_inherits_flat; + long pd_n_inherits_flat; + + // Scope Management Protocol. + friend int tao_yyparse (void); + + virtual AST_Constant *fe_add_constant (AST_Constant *c); + + virtual AST_Exception *fe_add_exception (AST_Exception *e); + + virtual AST_Attribute *fe_add_attribute(AST_Attribute *a); + + virtual AST_Field *fe_add_field (AST_Field *o); + + virtual AST_Operation *fe_add_operation(AST_Operation *o); + + virtual AST_Union *fe_add_union (AST_Union *u); + + virtual AST_Structure *fe_add_structure (AST_Structure *s); + + virtual AST_Enum *fe_add_enum (AST_Enum *e); + + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); + + virtual AST_Typedef *fe_add_typedef (AST_Typedef *t); + virtual AST_Native *fe_add_native (AST_Native *n); }; #endif // _AST_INTERFACE_AST_INTERFACE_HH diff --git a/TAO/TAO_IDL/include/ast_operation.h b/TAO/TAO_IDL/include/ast_operation.h index 8782b6f8064..eef588426f7 100644 --- a/TAO/TAO_IDL/include/ast_operation.h +++ b/TAO/TAO_IDL/include/ast_operation.h @@ -62,43 +62,35 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_OPERATION_AST_OPERATION_HH #define _AST_OPERATION_AST_OPERATION_HH -// Representation of operation declaration: - -/* -** DEPENDENCIES: ast_decl.hh, utl_scope.hh, ast_type.hh, utl_strlist.hh, -** utl_exceptlist.hh, utl_scoped_name.hh -** -** USE: included from ast.hh -*/ - -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "utl_list.h" -#include "ast_decl.h" -#include "utl_scope.h" -#include "utl_scoped_name.h" +// Representation of operation declaration. +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "utl_list.h" +#include "ast_decl.h" +#include "utl_scope.h" +#include "utl_scoped_name.h" class TAO_IDL_FE_Export AST_Operation : public virtual AST_Decl, public virtual UTL_Scope { public: - // Define enum with flags for operation attributes - enum Flags { - OP_noflags // No flags present - , OP_oneway // Operation is oneway - , OP_idempotent // Operation is idempotent + // Define enum with flags for operation attributes. + enum Flags + { + OP_noflags // No flags present. + , OP_oneway // Operation is oneway. + , OP_idempotent // Operation is idempotent. }; - // Operations + // Constructor(s). + AST_Operation (void); - // Constructor(s) - AST_Operation (); AST_Operation (AST_Type *return_type, Flags flags, UTL_ScopedName *n, @@ -106,21 +98,36 @@ public: idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Operation (void); - // Data Accessors - AST_Type *return_type(); - Flags flags(); - UTL_StrList *context(); - UTL_ExceptList *exceptions(); + // Data Accessors. + + AST_Type *return_type (void); + + Flags flags (void); + + UTL_StrList *context (void); - // Narrowing + UTL_ExceptList *exceptions (void); + + // Public operations. + + virtual int argument_count (void); + // Return the count of members. + + virtual int has_native (void); + // Any of the arguments or the return value is a <native> type. + // This is important because in that case no code should be + // generated for the stubs. + + // Narrowing. DEF_NARROW_METHODS2(AST_Operation, AST_Decl, UTL_Scope); DEF_NARROW_FROM_DECL(AST_Operation); DEF_NARROW_FROM_SCOPE(AST_Operation); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); // Method to add exceptions UTL_ExceptList *be_add_exceptions (UTL_ExceptList *t); @@ -129,21 +136,37 @@ public: virtual void destroy (void); private: - // Data - AST_Type *pd_return_type; // Return type - Flags pd_flags; // Operation flags - UTL_StrList *pd_context; // Context - UTL_ExceptList *pd_exceptions; // Exceptions raised + // Data. + + AST_Type *pd_return_type; + // Return type + + Flags pd_flags; + // Operation flags + + UTL_StrList *pd_context; + // Context + + UTL_ExceptList *pd_exceptions; + // Exceptions raised + + int argument_count_; + // Number of arguments. + + int has_native_; + // Is any argument of type native. + + // Operations. - // Scope Management Protocol - friend int tao_yyparse(); + int compute_argument_attr (void); + // Count the number of arguments. - virtual AST_Argument *fe_add_argument(AST_Argument *a); - virtual UTL_StrList *fe_add_context(UTL_StrList *c); - // Add context - virtual UTL_NameList *fe_add_exceptions(UTL_NameList *e); - // exceptions + // Scope Management Protocol. + friend int tao_yyparse (void); + virtual AST_Argument *fe_add_argument (AST_Argument *a); + virtual UTL_StrList *fe_add_context (UTL_StrList *c); + virtual UTL_NameList *fe_add_exceptions (UTL_NameList *e); }; #endif // _AST_OPERATION_AST_OPERATION_HH diff --git a/TAO/TAO_IDL/include/ast_predefined_type.h b/TAO/TAO_IDL/include/ast_predefined_type.h index b4a568eea7a..444d42e51a3 100644 --- a/TAO/TAO_IDL/include/ast_predefined_type.h +++ b/TAO/TAO_IDL/include/ast_predefined_type.h @@ -62,7 +62,7 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_PREDEFINED_TYPE_AST_PREDEFINED_TYPE_HH #define _AST_PREDEFINED_TYPE_AST_PREDEFINED_TYPE_HH @@ -72,18 +72,12 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // Instances of this class are inserted into the global context by // the front end before the start of parsing. -/* -** DEPENDENCIES: ast_concrete_type.hh, utl_scoped_name.hh, utl_strlist.hh, -** ast_decl.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_PredefinedType : public virtual AST_ConcreteType { public: - // Enum for all the different predefined types - enum PredefinedType { + // Enum for all the different predefined types. + enum PredefinedType + { PT_long // Predefined type "long" , PT_ulong // Predefined type "unsigned long" , PT_longlong // Predefined type "long long" @@ -100,12 +94,12 @@ public: , PT_any // Predefined type "any" , PT_void // Predefined type "void" , PT_pseudo // Predefined type for pseudo objects - }; + }; - // Operations + // Operations. - // Constructor(s) - AST_PredefinedType (); + // Constructor(s). + AST_PredefinedType (void); AST_PredefinedType (PredefinedType t, UTL_ScopedName *n, @@ -113,19 +107,21 @@ public: virtual ~AST_PredefinedType (void); - // Data Accessors - PredefinedType pt(); + // Data Accessors. + PredefinedType pt (void); // Narrowing DEF_NARROW_METHODS1(AST_PredefinedType, AST_ConcreteType); DEF_NARROW_FROM_DECL(AST_PredefinedType); // AST Dumping - virtual void dump(ostream &o); + virtual void dump (ostream &o); private: - // Data - const PredefinedType pd_pt; // The specific predefined type + // Data. + + const PredefinedType pd_pt; + // The specific predefined type. }; #endif // _AST_PREDEFINED_TYPE_AST_PREDEFINED_TYPE_HH diff --git a/TAO/TAO_IDL/include/ast_sequence.h b/TAO/TAO_IDL/include/ast_sequence.h index dadab4584e1..3cea1dc3c36 100644 --- a/TAO/TAO_IDL/include/ast_sequence.h +++ b/TAO/TAO_IDL/include/ast_sequence.h @@ -62,29 +62,22 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_SEQUENCE_AST_SEQUENCE_HH #define _AST_SEQUENCE_AST_SEQUENCE_HH // Representation of sequence declaration: // -// A sequence is a combination of a maximum size and a base type - -/* -** DEPENDENCIES: ast_concrete_type.hh, ast_type.hh, ast_decl.hh, -** ast_expression.hh -** -** USE: Included from ast.hh -*/ +// A sequence is a combination of a maximum size and a base type. class TAO_IDL_FE_Export AST_Sequence : public virtual AST_ConcreteType { public: - // Operations + // Operations. - // Constructor(s) - AST_Sequence (); + // Constructor(s). + AST_Sequence (void); AST_Sequence (AST_Expression *max_size, AST_Type *bt, @@ -93,21 +86,35 @@ public: virtual ~AST_Sequence (void); - // Data Accessors - AST_Expression *max_size(); - AST_Type *base_type(); + virtual idl_bool in_recursion (AST_Type *node = 0); + // Are we or the node represented by node involved in recursion. + + // Data Accessors. + AST_Expression *max_size (void); - // Narrowing + AST_Type *base_type (void); + + virtual idl_bool unbounded (void) const; + // Is this sequence bounded or not. + + // Narrowing. DEF_NARROW_METHODS1(AST_Sequence, AST_ConcreteType); DEF_NARROW_FROM_DECL(AST_Sequence); - // AST Dumping - virtual void dump(ostream &o); + // AST Dumping. + virtual void dump (ostream &o); private: - // Data - AST_Expression *pd_max_size; // Maximum sequence size - AST_Type *pd_base_type; // Sequence base type + // Data. + AST_Expression *pd_max_size; + // Maximum sequence size. + + AST_Type *pd_base_type; + // Sequence base type. + + idl_bool unbounded_; + // Whether we are bounded or unbounded. + }; #endif // _AST_SEQUENCE_AST_SEQUENCE_HH diff --git a/TAO/TAO_IDL/include/ast_structure.h b/TAO/TAO_IDL/include/ast_structure.h index 151678e4a84..ceac23811eb 100644 --- a/TAO/TAO_IDL/include/ast_structure.h +++ b/TAO/TAO_IDL/include/ast_structure.h @@ -62,36 +62,29 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_STRUCTURE_AST_STRUCTURE_HH #define _AST_STRUCTURE_AST_STRUCTURE_HH // Representation of structure: // -// NOTE: add(AST_ConcreteType *) is defined here because a structure +// NOTE: add (AST_ConcreteType *) is defined here because a structure // can contain locally defined types in addition to fields. // -// NOTE: add(AST_EnumValue *) is defined here because enums can +// NOTE: add (AST_EnumValue *) is defined here because enums can // be defined manifest locally; the constants defined in these // enums are inserted in the enclosing scope. It is unlikely that // a BE writer will need to overload this function in AST_Structure. -/* -** DEPENDENCIES: ast_concrete_type.hh, utl_scope.hh, utl_scoped_name.hh, -** utl_strlist.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_Structure : public virtual AST_ConcreteType, public virtual UTL_Scope { public: - // Operations + // Operations. - // Constructor(s) - AST_Structure (); + // Constructor(s). + AST_Structure (void); AST_Structure (UTL_ScopedName *n, UTL_StrList *p, @@ -104,42 +97,48 @@ public: idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Structure (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS2(AST_Structure, AST_ConcreteType, UTL_Scope); DEF_NARROW_FROM_DECL(AST_Structure); DEF_NARROW_FROM_SCOPE(AST_Structure); virtual int member_count (void); - // return the count of members + // Return the count of members. - virtual idl_bool is_local (void); + virtual idl_bool is_local (void); // Overwrite the is_local method. - // AST Dumping - virtual void dump(ostream &o); + virtual idl_bool in_recursion (AST_Type *node = 0); + // Are we or the node represented by node involved in recursion. + + // AST Dumping. + virtual void dump (ostream &o); // Cleanup function. virtual void destroy (void); private: - friend int tao_yyparse(); - // Scope Management Protocol + friend int tao_yyparse (void); + // Scope Management Protocol. + + virtual AST_Union *fe_add_union (AST_Union *u); + + virtual AST_Structure *fe_add_structure (AST_Structure *s); + + virtual AST_Field *fe_add_field (AST_Field *f); - virtual AST_Union *fe_add_union(AST_Union *u); - virtual AST_Structure *fe_add_structure(AST_Structure *s); - virtual AST_Field *fe_add_field(AST_Field *f); - virtual AST_Enum *fe_add_enum(AST_Enum *e); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); + virtual AST_Enum *fe_add_enum (AST_Enum *e); - //=helper + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); int compute_member_count (void); - // count the number of members + // Count the number of members. int member_count_; - // number of members + // Number of members. idl_bool local_struct_; // We also need to determine whether we contain any local type. diff --git a/TAO/TAO_IDL/include/ast_type.h b/TAO/TAO_IDL/include/ast_type.h index 8b1fd29b7b5..323407aa322 100644 --- a/TAO/TAO_IDL/include/ast_type.h +++ b/TAO/TAO_IDL/include/ast_type.h @@ -62,7 +62,7 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_TYPE_AST_TYPE_HH #define _AST_TYPE_AST_TYPE_HH @@ -70,34 +70,34 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // Class for all IDL types // // This is useful wherever any IDL type defining construct can appear -// such as the base type for a typedef or array +// such as the base type for a typedef or array. -/* -** DEPENDENCIES: ast_decl.hh, utl_scoped_name.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ - -#include "idl_fwd.h" -#include "idl_narrow.h" -#include "ast_decl.h" +#include "idl_fwd.h" +#include "idl_narrow.h" +#include "ast_decl.h" class TAO_IDL_FE_Export AST_Type : public virtual AST_Decl { public: - // Operations + // Operations. - // Constructor(s) - AST_Type (); + // Constructor(s). + AST_Type (void); AST_Type (AST_Decl::NodeType nt, UTL_ScopedName *n, UTL_StrList *p); + // Destructor. virtual ~AST_Type (void); - // Narrowing + virtual idl_bool in_recursion (AST_Type *node = 0); + // Determine if we are involved in some kind of limited recursion. + // Most types cannot be involved except structs and unions. + // If the parameter is 0, we are trying to determine this for ourselves. + + // Narrowing. DEF_NARROW_METHODS1(AST_Type, AST_Decl); DEF_NARROW_FROM_DECL(AST_Type); }; diff --git a/TAO/TAO_IDL/include/ast_union.h b/TAO/TAO_IDL/include/ast_union.h index c24306022ed..89d58eed971 100644 --- a/TAO/TAO_IDL/include/ast_union.h +++ b/TAO/TAO_IDL/include/ast_union.h @@ -62,35 +62,28 @@ NOTE: SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are trademarks or registered trademarks of Sun Microsystems, Inc. - */ +*/ #ifndef _AST_UNION_AST_UNION_HH #define _AST_UNION_AST_UNION_HH // Representation of union declaration: // -// NOTE: add(AST_ConcreteType *) is defined here because a union +// NOTE: add (AST_ConcreteType *) is defined here because a union // can contain locally defined types in addition to fields. // -// NOTE: add(AST_EnumValue *) is defined here because enums can +// NOTE: add (AST_EnumValue *) is defined here because enums can // be defined manifest locally; the constants defined in these // enums are inserted in the enclosing scope. It is unlikely that // a BE writer will need to overload this function in AST_Union. -/* -** DEPENDENCIES: ast_concrete_type.hh, utl_scope.hh, ast_union_branch.hh, -** ast_union_label.hh, utl_scoped_name.hh, utl_strlist.hh -** -** USE: Included from ast.hh -*/ - class TAO_IDL_FE_Export AST_Union : public virtual AST_Structure { public: - // Operations + // Operations. - // Constructor(s) - AST_Union (); + // Constructor(s). + AST_Union (void); AST_Union (AST_ConcreteType *disc_type, UTL_ScopedName *n, @@ -98,51 +91,65 @@ public: idl_bool local, idl_bool abstract); + // Destructor. virtual ~AST_Union (void); - // Data Accessors - AST_ConcreteType *disc_type(); - AST_Expression::ExprType udisc_type(); + virtual idl_bool in_recursion (AST_Type *node = 0); + // Are we or the parameter node involved in some kind of recursion? + + // Data Accessors. + + AST_ConcreteType *disc_type (void); + + AST_Expression::ExprType udisc_type (void); - // Narrowing + // Narrowing. DEF_NARROW_METHODS1(AST_Union, AST_Structure); DEF_NARROW_FROM_DECL(AST_Union); DEF_NARROW_FROM_SCOPE(AST_Union); - // AST Dumping - virtual void dump(ostream &); + // AST Dumping. + virtual void dump (ostream &); private: - // Data - AST_ConcreteType *pd_disc_type; // Discriminator type - AST_Expression::ExprType pd_udisc_type; // Its expression type - /* Convention: udisc_type == EV_any denotes an enum value */ + // Data. - // Operations + AST_ConcreteType *pd_disc_type; + // Discriminator type. - // Look up a branch by node pointer - AST_UnionBranch *lookup_branch(AST_UnionBranch *branch); + AST_Expression::ExprType pd_udisc_type; + // Its expression type. + // Convention: udisc_type == EV_any denotes an enum value. - // Look up the branch with the "default" label - AST_UnionBranch *lookup_default(); + // Operations. + + // Look up a branch by node pointer. + AST_UnionBranch *lookup_branch(AST_UnionBranch *branch); + + // Look up the branch with the "default" label. + AST_UnionBranch *lookup_default (void); // Look up a branch given a branch with a label. This is used to - // check for duplicate labels - AST_UnionBranch *lookup_label(AST_UnionBranch *b); + // check for duplicate labels. + AST_UnionBranch *lookup_label (AST_UnionBranch *b); // Look up a union branch given an enumerator. This is used to - // check for duplicate enum labels - AST_UnionBranch *lookup_enum(AST_UnionBranch *b); + // check for duplicate enum labels. + AST_UnionBranch *lookup_enum (AST_UnionBranch *b); private: - friend int tao_yyparse(); - // Scope Management Protocol - - virtual AST_Union *fe_add_union(AST_Union *u); - virtual AST_UnionBranch *fe_add_union_branch(AST_UnionBranch *b); - virtual AST_Structure *fe_add_structure(AST_Structure *s); - virtual AST_Enum *fe_add_enum(AST_Enum *e); - virtual AST_EnumVal *fe_add_enum_val(AST_EnumVal *v); + friend int tao_yyparse (void); + // Scope Management Protocol. + + virtual AST_Union *fe_add_union (AST_Union *u); + + virtual AST_UnionBranch *fe_add_union_branch (AST_UnionBranch *b); + + virtual AST_Structure *fe_add_structure (AST_Structure *s); + + virtual AST_Enum *fe_add_enum (AST_Enum *e); + + virtual AST_EnumVal *fe_add_enum_val (AST_EnumVal *v); }; |