diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-03 20:41:30 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-12-03 20:41:30 +0000 |
commit | 21812bcc63b961373af1e9f0ed505980b1e8cf09 (patch) | |
tree | bcf3a31748ab8e5b34d0d29267258c0d9c1e9fed | |
parent | 4504fb7e18998f751e800038499dedae15aa41f8 (diff) | |
download | ATCD-21812bcc63b961373af1e9f0ed505980b1e8cf09.tar.gz |
ChangeLogTag: Thu Dec 3 20:39:05 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r-- | modules/TAO/ChangeLog | 12 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/ast/ast_expression.cpp | 83 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/idl.yy | 7 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/y.tab.cpp | 9 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/include/ast_expression.h | 11 |
5 files changed, 100 insertions, 22 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog index 8fc960d20a2..16acc0568f2 100644 --- a/modules/TAO/ChangeLog +++ b/modules/TAO/ChangeLog @@ -1,3 +1,15 @@ +Thu Dec 3 20:39:05 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/include/ast_expression.h: + * TAO_IDL/ast/ast_expression.cpp: + * TAO_IDL/fe/y.tab.cpp: + * TAO_IDL/fe/idl.yy: + + Added check to see if an expression has been created as the + rhs of a constant declaration that is a reference to a + template module parameter. If so, we can skip the coercion + and some of the evaluation until instantiation time. + Thu Dec 3 19:15:15 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/fe/idl.yy: diff --git a/modules/TAO/TAO_IDL/ast/ast_expression.cpp b/modules/TAO/TAO_IDL/ast/ast_expression.cpp index b28fabfbd33..310213152c1 100644 --- a/modules/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/modules/TAO/TAO_IDL/ast/ast_expression.cpp @@ -69,6 +69,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_expression.h" #include "ast_constant.h" #include "ast_typedef.h" +#include "ast_param_holder.h" #include "ast_visitor.h" #include "utl_err.h" @@ -100,9 +101,20 @@ AST_Expression::AST_Expression (UTL_ScopedName *nm) pd_v1 (0), pd_v2 (0), pd_n (nm), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); + + AST_Decl *d = + idl_global->scopes ().top_non_null ()->lookup_by_name (nm, + true); + + if (d->node_type () == AST_Decl::NT_param_holder) + { + this->param_holder_ = + AST_Param_Holder::narrow_from_decl (d); + } } // An AST_Expression denoting a type coercion from another AST_Expression. @@ -113,7 +125,8 @@ AST_Expression::AST_Expression (AST_Expression *v, pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -166,7 +179,8 @@ AST_Expression::AST_Expression (ExprComb c, pd_v1 (ev1), pd_v2 (ev2), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); } @@ -178,7 +192,8 @@ AST_Expression::AST_Expression (ACE_CDR::Short sv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -196,7 +211,8 @@ AST_Expression::AST_Expression (ACE_CDR::UShort usv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -214,7 +230,8 @@ AST_Expression::AST_Expression (ACE_CDR::Long lv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -232,7 +249,8 @@ AST_Expression::AST_Expression (ACE_CDR::Boolean b) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -250,7 +268,8 @@ AST_Expression::AST_Expression (ACE_CDR::ULong ulv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -269,7 +288,8 @@ AST_Expression::AST_Expression (ACE_CDR::ULong ulv, pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -291,7 +311,8 @@ AST_Expression::AST_Expression (ACE_CDR::Float fv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -309,7 +330,8 @@ AST_Expression::AST_Expression (ACE_CDR::Double dv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -327,7 +349,8 @@ AST_Expression::AST_Expression (ACE_CDR::Char cv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -345,7 +368,8 @@ AST_Expression::AST_Expression (ACE_OutputCDR::from_wchar wcv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -363,7 +387,8 @@ AST_Expression::AST_Expression (ACE_CDR::Octet ov) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -381,7 +406,8 @@ AST_Expression::AST_Expression (UTL_String *sv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -403,7 +429,8 @@ AST_Expression::AST_Expression (char *sv) pd_v1 (0), pd_v2 (0), pd_n (0), - tdef (0) + tdef (0), + param_holder_ (0) { this->fill_definition_details (); @@ -2476,6 +2503,14 @@ AST_Expression::eval_symbol (AST_Expression::EvalKind ek) idl_global->err ()->lookup_error (this->pd_n); return 0; } + + // If we are a template parameter placeholder, just skip the + // rest - nothing needs to be evaluated until instantiation + // time. + if (this->param_holder_ != 0) + { + return 0; + } // Do lookup. d = s->lookup_by_name (this->pd_n, @@ -2709,8 +2744,7 @@ AST_Expression::coerce (AST_Expression::ExprType t) } else { - return coerce_value (copy, - t); + return coerce_value (copy, t); } } @@ -2971,6 +3005,12 @@ AST_Expression::get_tdef (void) const return this->tdef; } +bool +AST_Expression::is_param_holder (void) const +{ + return (this->param_holder_ != 0); +} + // Helper functions for expression dumpers. // Dump this binary AST_Expression node to the ostream o. @@ -3214,6 +3254,13 @@ AST_Expression::destroy (void) delete this->pd_n; this->pd_n = 0; + + if (this->param_holder_ != 0) + { + this->param_holder_->destroy (); + delete this->param_holder_; + this->param_holder_ = 0; + } } // Data accessors. diff --git a/modules/TAO/TAO_IDL/fe/idl.yy b/modules/TAO/TAO_IDL/fe/idl.yy index 8331aa936d4..b2b66574b04 100644 --- a/modules/TAO/TAO_IDL/fe/idl.yy +++ b/modules/TAO/TAO_IDL/fe/idl.yy @@ -1760,12 +1760,17 @@ const_dcl : */ if ($9 != 0 && s != 0) { + bool param_holder = + $9->is_param_holder (); + AST_Expression::AST_ExprValue *result = $9->check_and_coerce ($3, tao_enum_constant_decl); tao_enum_constant_decl = 0; - if (result == 0) + // If the expression is a template parameter place + // holder, 'result' will be 0, but it's ok. + if (result == 0 && ! param_holder) { idl_global->err ()->coercion_error ($9, $3); diff --git a/modules/TAO/TAO_IDL/fe/y.tab.cpp b/modules/TAO/TAO_IDL/fe/y.tab.cpp index 8eb5b16c493..81485e71f83 100644 --- a/modules/TAO/TAO_IDL/fe/y.tab.cpp +++ b/modules/TAO/TAO_IDL/fe/y.tab.cpp @@ -4201,12 +4201,17 @@ tao_yyreduce: */ if ((tao_yyvsp[(9) - (9)].exval) != 0 && s != 0) { + bool param_holder = + (tao_yyvsp[(9) - (9)].exval)->is_param_holder (); + AST_Expression::AST_ExprValue *result = (tao_yyvsp[(9) - (9)].exval)->check_and_coerce ((tao_yyvsp[(3) - (9)].etval), tao_enum_constant_decl); tao_enum_constant_decl = 0; - - if (result == 0) + + // If the expression is a template parameter place + // holder, 'result' will be 0, but it's ok. + if (result == 0 && ! param_holder) { idl_global->err ()->coercion_error ((tao_yyvsp[(9) - (9)].exval), (tao_yyvsp[(3) - (9)].etval)); diff --git a/modules/TAO/TAO_IDL/include/ast_expression.h b/modules/TAO/TAO_IDL/include/ast_expression.h index 04342a9f486..8ae76e608ce 100644 --- a/modules/TAO/TAO_IDL/include/ast_expression.h +++ b/modules/TAO/TAO_IDL/include/ast_expression.h @@ -74,6 +74,7 @@ class UTL_String; class UTL_Scope; class ast_visitor; class AST_Decl; +class AST_Param_Holder; // Representation of expression values. @@ -279,10 +280,14 @@ public: // Compare two AST_Expressions. bool operator== (AST_Expression *vc); - long compare (AST_Expression *vc); + // Accessor for the member. AST_Decl *get_tdef (void) const; + + // We don't need to access this member, just determine if is + // 0 or not. + bool is_param_holder (void) const; protected: // Evaluate different sets of operators. @@ -325,6 +330,10 @@ private: AST_Decl *tdef; // Propagates aliased constant type. + + AST_Param_Holder *param_holder_; + // Non-zero if we were created from a reference template param. + private: // Fill out the lineno, filename and definition scope details. void fill_definition_details (void); |