1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// AST_StructureFwd nodes denote forward declarations of IDL structs.
// AST_StructureFwd nodes have a field containing the full declaration
// of the struct, which is initialized when that declaration is
// encountered.
#include "ast_structure_fwd.h"
#include "ast_structure.h"
#include "ast_visitor.h"
#include "utl_identifier.h"
AST_Decl::NodeType const
AST_StructureFwd::NT = AST_Decl::NT_struct_fwd;
AST_StructureFwd::AST_StructureFwd (AST_Structure *full_defn,
UTL_ScopedName *n)
: COMMON_Base (),
AST_Decl (AST_Decl::NT_struct_fwd,
n),
AST_Type (AST_Decl::NT_struct_fwd,
n),
pd_full_definition (full_defn),
is_defined_ (false)
{
}
AST_StructureFwd::~AST_StructureFwd ()
{
}
// Redefinition of inherited virtual operations.
// Dump this AST_StructureFwd node to the ostream o.
void
AST_StructureFwd::dump (ACE_OSTREAM_TYPE &o)
{
this->dump_i (o, "struct ");
this->local_name ()->dump (o);
}
int
AST_StructureFwd::ast_accept (ast_visitor *visitor)
{
return visitor->visit_structure_fwd (this);
}
// Data accessors.
AST_Structure *
AST_StructureFwd::full_definition ()
{
return this->pd_full_definition;
}
void
AST_StructureFwd::set_full_definition (AST_Structure *nfd)
{
this->pd_full_definition->destroy ();
delete this->pd_full_definition;
this->pd_full_definition = nfd;
// In case it's not already set.
this->is_defined_ = true;
}
bool
AST_StructureFwd::is_defined ()
{
return this->is_defined_;
}
void
AST_StructureFwd::set_as_defined ()
{
this->is_defined_ = true;
}
void
AST_StructureFwd::destroy ()
{
if (!this->is_defined_ && nullptr != this->pd_full_definition)
{
this->pd_full_definition->destroy ();
delete this->pd_full_definition;
this->pd_full_definition = nullptr;
}
this->AST_Type::destroy ();
}
bool
AST_StructureFwd::is_fwd ()
{
return true; // This is a fwd declared type
}
// We don't actually want the forward declaration,
// but want to return the full definition member,
// whether defined yet or not.
AST_Decl *
AST_StructureFwd::adjust_found (
bool ignore_fwd,
bool full_def_only)
{
if (ignore_fwd)
{
AST_Structure *s = this->full_definition ();
return (full_def_only && !s->is_defined () ? nullptr : s);
}
return this;
}
|