Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / TAO_IDL / ast / ast_structure_fwd.cpp
blob6f444e67dae8e8718ddeb9e838d59bc1780b274e
1 // AST_StructureFwd nodes denote forward declarations of IDL structs.
2 // AST_StructureFwd nodes have a field containing the full declaration
3 // of the struct, which is initialized when that declaration is
4 // encountered.
6 #include "ast_structure_fwd.h"
7 #include "ast_structure.h"
8 #include "ast_visitor.h"
9 #include "utl_identifier.h"
11 AST_Decl::NodeType const
12 AST_StructureFwd::NT = AST_Decl::NT_struct_fwd;
14 AST_StructureFwd::AST_StructureFwd (AST_Structure *full_defn,
15 UTL_ScopedName *n)
16 : COMMON_Base (),
17 AST_Decl (AST_Decl::NT_struct_fwd,
18 n),
19 AST_Type (AST_Decl::NT_struct_fwd,
20 n),
21 pd_full_definition (full_defn),
22 is_defined_ (false)
26 AST_StructureFwd::~AST_StructureFwd (void)
30 // Redefinition of inherited virtual operations.
32 // Dump this AST_StructureFwd node to the ostream o.
33 void
34 AST_StructureFwd::dump (ACE_OSTREAM_TYPE &o)
36 this->dump_i (o, "struct ");
37 this->local_name ()->dump (o);
40 int
41 AST_StructureFwd::ast_accept (ast_visitor *visitor)
43 return visitor->visit_structure_fwd (this);
46 // Data accessors.
48 AST_Structure *
49 AST_StructureFwd::full_definition (void)
51 return this->pd_full_definition;
54 void
55 AST_StructureFwd::set_full_definition (AST_Structure *nfd)
57 this->pd_full_definition->destroy ();
58 delete this->pd_full_definition;
59 this->pd_full_definition = nfd;
61 // In case it's not already set.
62 this->is_defined_ = true;
65 bool
66 AST_StructureFwd::is_defined (void)
68 return this->is_defined_;
71 void
72 AST_StructureFwd::set_as_defined (void)
74 this->is_defined_ = true;
77 void
78 AST_StructureFwd::destroy (void)
80 if (!this->is_defined_ && 0 != this->pd_full_definition)
82 this->pd_full_definition->destroy ();
83 delete this->pd_full_definition;
84 this->pd_full_definition = 0;
87 this->AST_Type::destroy ();
90 bool
91 AST_StructureFwd::is_fwd (void)
93 return true; // This is a fwd declared type
96 // We don't actually want the forward declaration,
97 // but want to return the full definition member,
98 // whether defined yet or not.
99 AST_Decl *
100 AST_StructureFwd::adjust_found (
101 bool ignore_fwd,
102 bool full_def_only)
104 if (ignore_fwd)
106 AST_Structure *s = this->full_definition ();
107 return (full_def_only && !s->is_defined () ? 0 : s);
110 return this;
113 IMPL_NARROW_FROM_DECL (AST_StructureFwd)