Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_annotation_member.cpp
blob4c6df6353233e24bb841c68d2b9d37ede0b86584
1 /**
2 * Abstract Syntax Tree Node for a Member Value of an Annotation
3 */
5 #include "ast_annotation_member.h"
6 #include "ast_type.h"
7 #include "utl_scope.h"
9 #include "ast_enum.h"
10 #include "ast_enum_val.h"
12 AST_Decl::NodeType const AST_Annotation_Member::NT =
13 AST_Decl::NT_annotation_member;
15 AST_Annotation_Member::AST_Annotation_Member (
16 AST_Expression::ExprType expr_type, AST_Type *type, UTL_ScopedName *name)
17 : AST_Decl (NT, name),
18 AST_Field (type, name, vis_NA),
19 expr_type_ (expr_type),
20 value_ (nullptr)
24 AST_Annotation_Member::AST_Annotation_Member (
25 AST_Decl::NodeType nt,
26 AST_Expression::ExprType expr_type, AST_Type *type, UTL_ScopedName *name)
27 : AST_Decl (nt, name),
28 AST_Field (nt, type, name, vis_NA),
29 expr_type_ (expr_type),
30 value_ (nullptr)
34 AST_Annotation_Member::AST_Annotation_Member (
35 UTL_ScopedName *name,
36 AST_Annotation_Member *other)
37 : AST_Decl (name, dynamic_cast<AST_Decl*>(other)),
38 AST_Field (name, dynamic_cast<AST_Field*>(other)),
39 expr_type_ (other->expr_type ()),
40 value_ (other->value () ?
41 new AST_Expression (other->value (), other->expr_type ()) : nullptr)
45 AST_Annotation_Member::~AST_Annotation_Member ()
47 delete value_;
50 void
51 AST_Annotation_Member::destroy ()
53 if (value_)
55 value_->destroy ();
57 AST_Field::destroy ();
60 void
61 AST_Annotation_Member::dump (ACE_OSTREAM_TYPE &o)
63 AST_Field::dump (o);
64 if (field_type () && value_)
66 dump_i (o, " default ");
67 if (field_type ()->node_type () == AST_Decl::NT_enum)
69 dynamic_cast<AST_Enum*> (field_type ())->
70 lookup_by_value (value_)->name ()->dump (o);
72 else
74 value_->dump (o);
79 AST_Expression *
80 AST_Annotation_Member::value ()
82 return value_;
85 void
86 AST_Annotation_Member::value (AST_Expression *value)
88 if (value_)
90 value_->destroy ();
91 delete value_;
94 value_ = value;
97 AST_Expression::ExprType
98 AST_Annotation_Member::expr_type ()
100 return expr_type_;
103 bool
104 AST_Annotation_Member::invalid_value ()
106 return !value () || !value ()->ev ();