blob: 941a8ab088349a739b4aafce16f26f63d35e28d2 (
plain)
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
|
/**
* Abstract Syntax Tree Node for an application of an annotation.
*/
#ifndef AST_ANNOTATION_APPL_HEADER
#define AST_ANNOTATION_APPL_HEADER
#include "ast_annotation_decl.h"
#include "utl_identifier.h"
#include "ast_expression.h"
#include "ace/Containers_T.h"
#include "ace/Vector_T.h"
/**
* Abstract Syntax Tree Node for an application of an annotation.
*
* Params are implemented as a stack of name, value pairs which are independent
* from the finished annotation members. The members which are AST_Fields subclasses
* stored the same way as fields in AST_Struct.
*/
class TAO_IDL_FE_Export AST_Annotation_Appl : public virtual AST_Annotation_Decl
{
public:
/**
* Store Optional Annotation Parameters
*/
///{
struct Param {
Param ();
~Param ();
Identifier *id;
AST_Expression *expr;
bool used;
typedef ACE_Unbounded_Stack_Iterator<Param*> Iterator;
};
typedef ACE_Unbounded_Stack<Param*> Params;
///}
/// Delete Annotation Parameters
static void delete_params (Params* params);
/**
* Create an Annotation using it's name and parameters
*/
AST_Annotation_Appl (UTL_ScopedName *name, Params *params);
virtual ~AST_Annotation_Appl ();
/// AST Dumping
virtual void dump (ACE_OSTREAM_TYPE &o);
/// Visiting
virtual int ast_accept (ast_visitor *visitor);
/// Cleanup
virtual void destroy ();
static AST_Decl::NodeType const NT;
/**
* Get name of the annotation as written by the user
*/
const char* original_name () const;
/**
* Apply a Annotation Declaration to this Application. This will either fully
* instantiate this object or result in an error, in which case it returns false.
*/
bool apply_from (AST_Annotation_Decl *decl);
/**
* Return pointer to the stack of parameters passed. BACKENDS SHOULDN'T USE
* THIS UNLESS YOU NEED EXACTLY WHAT THE USER PASSED. Backends should use the
* lookup and scope iterator APIs that this class inherits from AST_Scope
* and AST_Struct. Can be null.
*/
Params *params ();
/**
* AST_Annotation_Decl kept in case desired by someone
*
* Will be null if accessed before apply_from() is called or if being used
* without a declaration.
*/
AST_Annotation_Decl *annotation_decl ();
/**
* Return the parameter with the specified name if it's in the stack else
* returns 0.
*/
Param *find_param (const char *name);
private:
/// Name of the Annotation as written
const char *original_name_;
/// Parameters List (Can be null)
Params *params_;
/// The AST_Annotation_Decl (Possibly could be null)
AST_Annotation_Decl *annotation_decl_;
};
struct Decl_Annotations_Pair {
AST_Decl *decl;
AST_Annotation_Appls *annotations;
};
#endif
|